US 12,443,475 B2
Method and apparatus for obtaining information of stack frame in call stack, device, and medium
Hongkai Liu, Beijing (CN)
Assigned to Beijing Bytedance Network Technology Co., Ltd., Beijing (CN)
Appl. No. 18/277,005
Filed by Beijing Bytedance Network Technology Co., Ltd., Beijing (CN)
PCT Filed Feb. 28, 2022, PCT No. PCT/CN2022/078365
§ 371(c)(1), (2) Date Aug. 11, 2023,
PCT Pub. No. WO2022/199331, PCT Pub. Date Sep. 29, 2022.
Claims priority of application No. 202110303887.1 (CN), filed on Mar. 22, 2021.
Prior Publication US 2024/0126627 A1, Apr. 18, 2024
Int. Cl. G06F 11/07 (2006.01); G06F 11/00 (2006.01)
CPC G06F 11/006 (2013.01) [G06F 11/0766 (2013.01); G06F 11/0787 (2013.01); G06F 2201/87 (2013.01)] 20 Claims
OG exemplary drawing
 
1. A method for obtaining information of a stack frame in a call stack, comprising:
obtaining a to-be-processed call stack with an abnormality during running of a program, each area element of the to-be-processed call stack comprising a method pointer and an instruction offset value corresponding to the method pointer, where a total number of area elements of the to-be-processed call stack is N;
applying for a first memory area, a first half of area elements of the first memory area being used to store the method pointer, and a second half of the area elements of the first memory area being used to store the instruction offset value corresponding to the method pointer, wherein a total number of the area elements of the first memory area is 2N;
obtaining an address of the first memory area;
applying for a second memory area, and storing the address of the first memory area into a first area element in the second memory area, wherein a total number of area elements of the second memory area is N+1;
obtaining an address of the second memory area;
applying for a third memory area, obtaining a target storage area in the third memory area, and storing the address of the second memory area into the target storage area; and
obtaining information of each stack frame in the to-be-processed call stack by executing a code segment corresponding to a stack frame information obtaining functional module getStackTrace based on the address of the second memory area stored in the target storage area.