Function Calling Context Encoding for Multithread Distinction
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing methods for distinguishing function calling contexts in multiple threads result in high storage overheads and inefficient analysis due to the need for decoding to obtain thread information, affecting analysis precision and efficiency.
Innovation Solution
An encoding method that encodes the calling context of a function based on thread and function creation relationships, using a thread calling context encoding graph (TEG) and function calling context encoding graph (CEG), allowing for efficient distinction of contexts without decoding, thus reducing storage and analysis time.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Measurement precision
If function call string is used to distinguish different calling contexts, then analysis precision is improved, but storage overhead is excessively high
Solution Approach 1:
The patent transforms the function call string from a full textual representation to a compressed encoding format. By changing the parameter representation from complete strings to encoded values, the system maintains the ability to distinguish different calling contexts while dramatically reducing storage requirements. The encoding preserves the essential identifying information without storing the complete function call paths.
2Quantity of substance
If function call string is encoded to reduce storage overhead, then storage overhead is reduced, but thread information cannot be distinguished
Solution Approach 1:
The patent segments the calling context information into separate components: function call path information and thread information. By dividing the encoding into distinct segments, the system can compress the function call path while maintaining separate, identifiable thread information. This segmentation allows both components to be efficiently stored and processed independently.
Solution Approach 2:
The patent introduces thread ID as an intermediary element that directly identifies the thread without requiring decoding of the full function call string. The thread ID acts as a mediator between the compressed function call encoding and the original thread information, enabling efficient thread distinction without the need for complete string storage or repeated decoding operations.
3Ease of operation
If thread information is obtained through repeated decoding, then thread information can be accessed, but analysis time overhead is large
Solution Approach 1:
The patent performs preliminary encoding of thread information alongside the function call encoding. By preparing and storing the thread ID in advance during the encoding process, the system eliminates the need for repeated decoding operations during analysis. The thread information is ready for immediate access without requiring time-consuming decoding operations.
4Measurement precision
If function call string is stored to distinguish calling contexts, then analysis precision is improved, but device complexity increases
Solution Approach 1:
The patent changes the data representation parameters from complete function call strings to compressed encoded values. This parameter transformation reduces the amount of data that needs to be stored and processed, thereby reducing device complexity while maintaining the ability to distinguish different calling contexts with the same analysis precision.
Data Source
Figure 1~2
Figure 3(a)~3(b)
Figure 4
AI summary
This application provides an encoding method and a decoding method for a function calling context, and an apparatus. The encoding method includes: obtaining encoding values corresponding to creation relationships between a plurality of threads in program code, and obtaining, based on the encoding values corresponding to the creation relationships between the plurality of threads and calling context information of a target function, an encoding result of a context of a thread to which the target function belongs. According to the method in this application, the encoding result of the context of the thread to which the target function belongs can be obtained, so that different calling contexts of functions in a plurality of threads can be distinguished. This helps improve analysis efficiency and analysis precision.