Wrapper Functions for Restrictive Calling Convention Instrumentation

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Instrumenting software programs for platforms with restrictive calling conventions, such as the X64 extension, often introduces errors by disrupting the storage of variables and stack formats, violating the platform's conventions.

Innovation Solution

The method involves using wrapper functions to preserve and restore the state of the platform, allowing probe functions to be called without violating the calling conventions, by transferring control to a wrapper function that executes the probe and maintains the platform's state.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Measurement precision

If probes are inserted directly into the binary file to instrument the program, then performance analysis capability is improved, but errors are introduced by violating calling conventions and disrupting stack formats

Engineering Contradiction:
Improveperformance analysis capabilityVSAvoidprogram correctness
Core Design Contradiction:
Measurement precisionVSReliability

Solution Approach 1:

The patent introduces wrapper functions as intermediary components between the probe functions and the instrumented code. These wrapper functions act as mediators that handle the complex tasks of preserving platform state, managing stack formats, and restoring register values according to calling conventions. This intermediary layer enables performance probing while maintaining program correctness, as the wrappers isolate the probe functions from direct interaction with the constrained binary code structure.

Inventive Principle:
Principle #24Intermediary (Mediator)

Solution Approach 2:

The instrumentation process is segmented into distinct functional components: wrapper functions that handle state management, probe functions that perform measurement, and restoration functions that revert changes. This segmentation allows each component to specialize in a specific task, with wrapper functions managing the complexity of calling convention compliance while probe functions focus solely on performance measurement. The separation reduces errors by confining state-modifying operations to controlled wrapper functions.

Inventive Principle:
Principle #1Segmentation

2Measurement precision

If probes are inserted to record detailed operating state information, then measurement precision is improved, but device complexity increases due to state preservation and restoration requirements

Engineering Contradiction:
Improveoperating state recording accuracyVSAvoidinstrumentation structure complexity
Core Design Contradiction:
Measurement precisionVSDevice complexity

Solution Approach 1:

The wrapper functions serve multiple purposes: they preserve platform state before probe execution, restore state after probe execution, manage stack frame formats, and handle register value preservation. This multi-functionality consolidates what could be separate complex mechanisms into a single versatile component, reducing overall instrumentation complexity while maintaining measurement precision.

Inventive Principle:
Principle #6Universality (Multi-functionality)

Solution Approach 2:

The wrapper functions automatically manage their own state preservation and restoration operations without requiring external intervention. The instrumentation system self-services by having the wrappers handle their own housekeeping tasks of saving and restoring platform state, which reduces the complexity burden on the overall system architecture.

Inventive Principle:
Principle #25Self-service

Data Source

PatentUS7757218B2Method of instrumenting code having restrictive calling conventions
Publication Date: 2010.07.13 MICROSOFT TECHNOLOGY LICENSING LLC
  • US7757218B2 patent drawing
  • US7757218B2 patent drawing
  • US7757218B2 patent drawing

AI summary

A development environment for computer programs in which programs under test may be instrumented with probe functions. The probe functions are called through a wrapper function structured to comply with restrictive calling conventions of the platform for which the computer program is developed. By complying with the calling convention, proper operation of the computer program is achieved during testing even if an exception handler, or other program element that relies on compliance with the calling convention, is invoked. Once instrumented, the computer program may be tested to determine whether it executes desired logic function to determine the performance of the program or for other test functions.