FAT Binary Debugging Optimized Code
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Debugging optimized code is challenging due to the lack of correlation between source and object code, making source-level debugging difficult, and requiring developers to choose between maintaining non-optimized code for efficient debugging or rebuilding with non-optimized settings for performance.
Innovation Solution
A method involving the generation of a FAT binary that includes both optimized and non-optimized native code, allowing the loader to automatically load the appropriate version based on debugging mode, enabling source-level debugging without rebuilding the code.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Speed
If optimized code is used, then execution performance is improved, but source-level debugging capability deteriorates
Solution Approach 1:
The binary is segmented into multiple sections: an optimized native code section for performance-critical paths and a non-optimized native code section for debugging. The FAT binary structure allows the debugger to selectively load and execute the non-optimized section while maintaining the optimized build for normal operation, thus resolving the contradiction between performance and debugging capability
Solution Approach 2:
The FAT binary serves multiple functions: it acts as both the optimized executable for production and contains embedded non-optimized code for debugging purposes. This multi-functionality eliminates the need for separate binary files, allowing a single artifact to support both performance-critical execution and source-level debugging without requiring code rebuilding
2Difficulty of detecting and measuring
If non-optimized code is used, then source-level debugging capability is improved, but execution performance deteriorates
Solution Approach 1:
The system dynamically selects which code section to load and execute based on the operational context. During normal operation, the optimized native code section is loaded for maximum performance. When debugging is required, the system switches to loading the non-optimized native code section from the same FAT binary, providing dynamic adaptation between performance and debugging modes without requiring different binary builds
3Difficulty of detecting and measuring
If code is rebuilt with non-optimized settings for debugging, then source-level debugging capability is improved, but build time increases
Solution Approach 1:
The non-optimized native code is compiled and prepared in advance during the same build process as the optimized code, but stored separately within the FAT binary structure. This preliminary preparation eliminates the need for time-consuming rebuilds during debugging sessions, as the debugger can immediately load and execute the pre-prepared non-optimized code section without triggering a new compilation
4Loss of energy
If optimized code is used, then resource efficiency is improved, but debugging productivity deteriorates
Solution Approach 1:
Different quality levels of code are applied to different sections of the binary. The optimized native code provides maximum resource efficiency for execution paths that do not require debugging, while the non-optimized native code section maintains source-level correlation for debugging activities. This local differentiation allows the system to achieve both resource efficiency and debugging productivity without compromise
Data Source
AI summary
Embodiments of the present invention provide a method, computer program product, and system for debugging optimized code. The system includes a FAT binary, wherein the FAT binary comprises a non-optimized native code and an internal representation of a program's source code. An optimus program is configured to transform the internal representation of the program's source code into a fully optimized native code. The system also includes an enhanced loader, wherein the enhanced loader is configured to communicate with a debugger to determine a type of code to load.


