Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

delve/dwarf/line.Parse() only reads first directory table and file name table #143

Closed
mpictor opened this issue Jun 3, 2015 · 2 comments

Comments

@mpictor
Copy link

mpictor commented Jun 3, 2015

I guess this isn't an issue with ELF files generated by gc, but I'm trying to extract data from C++ libs. It would be nice if your dwarf package wasn't limited to golang 😄

If I use line.Parse() on the .debug_line section of one lib I have, it sees the files and dirs in the first pair of tables, but not the second pair.

On that file, readelf sees two dir tables and two file tables (see below).

I think line.Parse() shouldn't assume that all remaining data is instructions, as it does at line 45. I'm able to work around this by calling Parse() again on a slice starting at DebugLinePrologue.Length + 4. This appears to work correctly even on libraries with as many as 82 directory and file table pairs.


Output of $ readelf -Wwl /path/to/icu_data-l64d-4-0.so:

Raw dump of debug contents of section .debug_line:

  Offset:                      0x0
  Length:                      296
  DWARF Version:               2
  Prologue Length:             290
  Minimum Instruction Length:  1
  Initial value of 'is_stmt':  1
  Line Base:                   -5
  Line Range:                  14
  Opcode Base:                 13

 Opcodes:
  Opcode 1 has 0 args
  Opcode 2 has 1 args
  Opcode 3 has 1 args
  Opcode 4 has 1 args
  Opcode 5 has 1 args
  Opcode 6 has 0 args
  Opcode 7 has 0 args
  Opcode 8 has 0 args
  Opcode 9 has 1 args
  Opcode 10 has 0 args
  Opcode 11 has 0 args
  Opcode 12 has 1 args

 The Directory Table:
  /path/to/winhost/linux64/x86_64/x86_64-i3mingw32host-linux-gnu/sysroot/usr/include
  ../common/unicode
  /path/to/dists/icu/source/stubdata

 The File Name Table:
  Entry Dir     Time    Size    Name
  1     1       0       0       stdint.h
  2     2       0       0       udata.h
  3     3       0       0       stubdata.c

 Line Number Statements:

  Offset:                      0x12c
  Length:                      787
  DWARF Version:               2
  Prologue Length:             684
  Minimum Instruction Length:  1
  Initial value of 'is_stmt':  1
  Line Base:                   -5
  Line Range:                  14
  Opcode Base:                 13

 Opcodes:
  Opcode 1 has 0 args
  Opcode 2 has 1 args
  Opcode 3 has 1 args
  Opcode 4 has 1 args
  Opcode 5 has 1 args
  Opcode 6 has 0 args
  Opcode 7 has 0 args
  Opcode 8 has 0 args
  Opcode 9 has 1 args
  Opcode 10 has 0 args
  Opcode 11 has 0 args
  Opcode 12 has 1 args

 The Directory Table:
  /path/to/inc/system/somemoduleregistry
  gen/debug/l64/obj
  /path/to/winhost/linux64/x86_64/lib/gcc/x86_64-i3mingw32host-linux-gnu/4.8.1/include
  /path/to/winhost/linux64/x86_64/x86_64-i3mingw32host-linux-gnu/sysroot/usr/include/bits
  /path/to/winhost/linux64/x86_64/x86_64-i3mingw32host-linux-gnu/sysroot/usr/include

 The File Name Table:
  Entry Dir     Time    Size    Name
  1     1       0       0       registry.h
  2     2       0       0       tmp_manifest_datae58d12755ddb176ad98bdcc842e958ed.cpp
  3     3       0       0       stddef.h
  4     4       0       0       types.h
  5     5       0       0       libio.h
  6     1       0       0       common.h
  7     5       0       0       stdio.h

 Line Number Statements:
  Extended opcode 2: set Address to 0xdea
  Advance Line by 214 to 215
  Copy
  Special opcode 118: advance Address by 8 to 0xdf2 and Line by 1 to 216
  Special opcode 118: advance Address by 8 to 0xdfa and Line by 1 to 217
  Advance PC by 2 to 0xdfc
  Extended opcode 1: End of Sequence

  Set File Name to entry 2 in the File Name Table
<and so on...>
@derekparker
Copy link
Member

I have thought about breaking the dwarf stuff out into a completely separate package, in case it would be useful for other projects.

Would you mind putting together a PR for this? Otherwise I'll keep this issue open and try to get to it as soon as I can.

@mpictor
Copy link
Author

mpictor commented Jun 9, 2015

I wish I had the time, but I don't. Sorry!

nclifton pushed a commit to nclifton/delve that referenced this issue Feb 24, 2021
…line (go-delve#143)

* and together the two integration script run commands

* drop sender integration test

* separate webhook from sender integration tests in workflow

* not using shell scripts for the integration tests

* prob with run

* typo

* attempt to exit script with appropriate exit code

* recombine integration tests

* some odd syntax is required

* fixed integration test run shell scripts

* restored fix to the webhook integration tests for health check postgres not available test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants