Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In the DWARF info, what do they exactly mean by the DW_OP registers?

I am trying to parse the DWARF info and then using that information get the local variables from a program using a pin tool. It is kind of like using pin as GDB on steroids. However, I am having troubles understanding what they mean by the registers they have for the local variables and allocated ones.

For example,

<2>< 1214>  DW_TAG_variable
    DW_AT_name                  mts
    DW_AT_decl_line             69
    DW_AT_type                  <90>
    DW_AT_location              DW_OP_breg4+44

I understand that, in order to get the data from the variable mts, I have to add 44 to some register, my problem is that I don't exactly which register they are talking about. How should I interpret this? I couldn't find anything online.

Another examples are the DW_OP_fbreg, DW_OP_breg5 and so on.

Anyone knows which registers are they talking about in an x86 context? Are they talking about ebp or esp? Thanks.

like image 264
attis Avatar asked Sep 09 '25 23:09

attis


1 Answers

It's a symbolic register name. See the xxx_map_dwarf_register methods in WineHQ's source for:

  • i386
  • x86_64
  • sparc
  • arm

For example, DW_OP_breg4 is ESP on i386.

Also see the following if you haven't done so already.

  • http://source.winehq.org/source/dlls/dbghelp/dwarf.c
  • http://www.dwarfstd.org/doc/040408.1.html
like image 145
vladr Avatar answered Sep 12 '25 12:09

vladr



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!