Call-Stack Frame Retrieval Using Direct Memory Structures
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing methods for obtaining detailed information about a stack frame in a call stack, such as method names and source code line numbers, are either limited in the information they provide or require complex and unstable underlying technologies with compatibility issues across different system versions.
Innovation Solution
A method and apparatus that involve applying for specific memory areas to store method pointers and instruction offset values in a controlled manner, followed by using a stack frame information obtaining functional module to retrieve detailed information like method names, class names, and source code line numbers, ensuring stability and compatibility across system versions.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Loss of information
If PrettyMethod function is used to obtain method information, then method name can be obtained, but source code line number cannot be obtained
Solution Approach 1:
The patent segments the information retrieval process into distinct components: method pointer extraction, instruction offset value extraction, and separate lookup operations for method names and line numbers. This segmentation allows each component to be optimized independently and resolves the contradiction by enabling complete information retrieval without increasing overall system complexity.
Solution Approach 2:
The patent introduces intermediary data structures (such as method ID tables and line number tables) that act as mediators between the raw stack trace data and the final information output. These intermediaries enable efficient lookup and retrieval of both method names and line numbers, resolving the limitation of the PrettyMethod function while maintaining system simplicity.
2Loss of information
If underlying technologies are used to obtain dex_file information, then class name and method name can be obtained, but implementation becomes complex and stability is difficult to guarantee
Solution Approach 1:
The patent extracts the essential information (method pointers and instruction offset values) directly from the stack trace without relying on complex underlying technologies or dex_file parsing. By taking out only the necessary data elements and processing them through simplified lookup tables, the patent achieves complete information retrieval while ensuring stability and compatibility across different system versions.
Solution Approach 2:
The patent uses lightweight, version-agnostic data structures and lookup tables that can be easily created and discarded, rather than relying on heavy, version-dependent underlying technologies. This approach ensures reliability across system versions while maintaining implementation simplicity.
3Loss of information
If multiple underlying technologies are required to obtain detailed information, then information completeness improves, but adaptability workload increases
Solution Approach 1:
The patent creates a universal information retrieval mechanism that works across different system versions using the same core approach. The method uses standardized lookup tables and direct extraction techniques that are version-agnostic, providing complete information without requiring adaptation to different system versions, thus resolving the contradiction between information completeness and adaptability workload.
Data Source
AI summary
Provided are a method and apparatus for obtaining information of a stack frame in a call stack, a device, and a medium. The method includes: obtaining to-be-processed call stack with an abnormality during running of a program, each area element of the to-be-processed call stack including a method pointer and corresponding instruction offset value; applying for a first memory area used to store the method pointer and the corresponding instruction offset value; applying for a second memory area, and storing an address of the first memory area into a first area element in the second memory area; applying for a third memory area, and storing an address of the second memory area into a target storage area in the third memory area; and obtaining information of each stack frame in the to-be-processed call stack based on the address of the second memory area stored in the target storage area.


