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

feat: support resolve symbols in mini debug info(".gnu_debugdata") #3590

Merged
merged 3 commits into from
Oct 1, 2024

Conversation

zmj64351508
Copy link
Contributor

@zmj64351508 zmj64351508 commented Sep 25, 2024

Mini debug info is stored in a lzma-compressed section named ".gnu_debugdata" in elf. More information can be found in https://archive.fosdem.org/2020/schedule/event/debugging_mini/attachments/slides/4059/export/events/attachments/debugging_mini/slides/4059/fosdem2020_minidebuginfo_kkleine.pdf

When it fails to get symbol in ".symtab", it will try to find the ".gnu_debugdata" section, uncompressing it and read the data as another elf to get the real "symtab" and "dynsym". (note: even if ".dynsym" exists, ".gnu_debugdata" can store more symbols)

Unfortunately, the original MMapedElfFile can't accept an in-memory area as the data of elf file. To reuse the original code to get the symbols, some changes are made:

  1. elfmmap.go is split into 2 structs(files):
    a. the origin struct MMapedElfFile
    b. the new struct InMemElfFile, which is responsible to parse elf for the uncompressed .gnu_debugdata. The original MMapedElfFile also reuse this struct to read elf.
  2. A new interface ElfSymbolReader, which is used by struct SymbolTable to get the symbol string.
  3. A new struct SymbolTableWithMiniDebugInfo to combine symbols in original elf and mini debug elf.
  4. A new interface SymbolTableInterface to abstract SymbolTable and SymbolTableWithMiniDebugInfo.

@zmj64351508 zmj64351508 requested review from korniltsev and a team as code owners September 25, 2024 11:12
@korniltsev
Copy link
Collaborator

I will take a look into the PR some time later this week. Please add at least one test extracting symbols from this mini debug info

@zmj64351508 zmj64351508 marked this pull request as draft September 26, 2024 04:24
@zmj64351508 zmj64351508 marked this pull request as draft September 26, 2024 04:24
@zmj64351508 zmj64351508 force-pushed the minidebug branch 3 times, most recently from 52b2dac to c17890d Compare September 27, 2024 08:56
@zmj64351508 zmj64351508 marked this pull request as ready for review September 27, 2024 09:50
@zmj64351508
Copy link
Contributor Author

PR Updated, including test

@korniltsev
Copy link
Collaborator

Thanks. I will be able to take a look next week.

Copy link
Collaborator

@korniltsev korniltsev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

@korniltsev korniltsev merged commit fba3a07 into grafana:main Oct 1, 2024
29 checks passed
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

Successfully merging this pull request may close these issues.

2 participants