Play around with debug dwarf!
This is a quick repository to reproduce some issues I'm having with reading dwarf in Go.
The first issue is that the DW_AT_vtable_elem_location that is found via
dwarfdump I don't see when parsing in Go. To reproduce the example in c++:
$ cd cpp
$ make
$ dwarfdump -a vtable > output.txtAnd then look in the output for the attribute (it's all over the place!). This is important to validate because DWARF varies quite a bit depending on your compiler! It's not good practice, but if you don't have c compilers available (and maybe you have a compatible architecture) I included the binary in the repo (kids don't do this at home! 😄️)
Go doesn't expose the Dwarf directly (the parser) in debug/dwarf, so I had to tweak it to make some of the functions public, and I'm providing that here in pkg. To run you'll first need to compile the vtable binary (as shown avove) and then do:
$ go run main.go ROFL! So in reproducing this bug, the version I wrote here works like a charm! Here we see the virtual table element location attributes:
$ go run main.go vtable
getname : VtableElementLocation : [16 3]
warmblooded : VtableElementLocation : [16 0]
getname : VtableElementLocation : [16 3]
getname : VtableElementLocation : [16 0]
warmblooded : VtableElementLocation : [16 1]The attribute is indeed being found, and it's likely a bug in the way I'm saving the entry in my more complex use case. This will be hugely helpful in me debugging.