How to calculate CFA from go dwarf

조회수 153회
읽지 않은 첫 메시지로 건너뛰기

Poonai

읽지 않음,
2021. 8. 31. 오전 7:29:5021. 8. 31.
받는사람 golang-nuts
I'm trying to learn how debugger works. With the help of this blog https://eli.thegreenplace.net/2011/01/27/how-debuggers-work-part-2-breakpoints
I'm able to set breakpoint and continue.

In the next step of learning, I wanted to learn how to extract values of variables. 

But, the dwarf output says the frame base addrs as: 1 byte block: 9c (DW_OP_call_frame_cfa)

 <0><48a28>: Abbrev Number: 1 (DW_TAG_compile_unit)
    <48a29>   DW_AT_name        : main
    <48a2e>   DW_AT_language    : 22 (Go)
    <48a2f>   DW_AT_stmt_list   : 0x26b2c
    <48a33>   DW_AT_low_pc      : 0x498200
    <48a3b>   DW_AT_ranges      : 0x28a70
    <48a3f>   DW_AT_comp_dir    : .
    <48a41>   DW_AT_producer    : Go cmd/compile go1.16.6; -N -l
    <48a60>   Unknown AT value: 2905: main
 <1><48a65>: Abbrev Number: 3 (DW_TAG_subprogram)
    <48a66>   DW_AT_name        : main.main
    <48a70>   DW_AT_low_pc      : 0x498200
    <48a78>   DW_AT_high_pc     : 0x4982e5
    <48a80>   DW_AT_frame_base  : 1 byte block: 9c (DW_OP_call_frame_cfa)
    <48a82>   DW_AT_decl_file   : 0x2
    <48a86>   DW_AT_external    : 1
 <2><48a87>: Abbrev Number: 21 (DW_TAG_lexical_block)
    <48a88>   DW_AT_low_pc      : 0x498223
    <48a90>   DW_AT_high_pc     : 0x4982d9
 <3><48a98>: Abbrev Number: 10 (DW_TAG_variable)
    <48a99>   DW_AT_name        : variableToTrace
    <48aa9>   DW_AT_decl_line   : 11
    <48aaa>   DW_AT_type        : <0x4ab9f>
    <48aae>   DW_AT_location    : 3 byte block: 91 b0 7f (DW_OP_fbreg: -80)

I wanted to readt variableToTrace. to my understanding, I can read the variable from CFA-80

But don't know how to calculate CFA. 

Can anyone help me with this?

Ian Lance Taylor

읽지 않음,
2021. 9. 10. 오후 5:25:0621. 9. 10.
받는사람 Poonai, golang-nuts
You are looking at the debug_info information, which describes a lot
of things but doesn't describe the call frame. To see the call frame
information use "readelf --debug=frames" or "readelf
--debug=frames-interp".

Ian
전체답장
작성자에게 답글
전달
새 메시지 0개