开发者

Getting value of stack pointer while stack unwinding with dwarf2

In DWARF2 debugging format, stack unwinding is supported with the help of CFI(Call Frame Inform开发者_运维知识库ation) present in .debug_frame section. This is precisely a table that keeps a rule for every register to get its value in previous frame. However, all of these rules relies on the fact that the registers are saved on stack at some location. This is not true for getting value of stack pointer in previous frame register when there is no frame-pointer. In such cases, stack pointer may not be saved on stack but just managed by incrementing and decrementing its value. However, there is no way in dwarf2 (or dwarf format in general) to indicate that the register value is an expression over its current value. So, my question is, how can one get the value of stack pointer during stack unwinding with dwarf2 debugging format (when no frame-pointer is there).

-BV


It seems that dwarf3 supports DW_CFA_val_offset for such a case. So, this can be used to record value of SP in previous frame based on a arithmetic expression over current value. Another possible solution could be to save stack pointer on stack itself (will work with dwarf2). This can be done at -O0 optimization level where the code efficiency is not that important.


See this discussion on what seems to be your problem. I am uncertain as to whether the proposals have yet made it into the current standard.


I went to this discussion. But, was just wondering if someone has ever tried to solve it through some other way. One way that I can think of is to an unnecessary save of stack-pointer on stack itself. Then use, this location to get the value of sp for previous frame.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜