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

POC feat(symbolization): Add DWARF symbolization with debuginfod support #3799

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

marcsanmi
Copy link
Contributor

@marcsanmi marcsanmi commented Dec 20, 2024

Context

This PR introduces a POC implementation for DWARF debug information symbolization. The implementation can fetch debug info from debuginfod servers or local files and resolve memory addresses to source code locations.

Key features

  • Remote debug info fetching via debuginfod
  • Local debug info file support
  • DWARF debug info parsing and address resolution
  • Support for inline function resolution
  • Memory address normalization for different ELF types

Note: While this POC demonstrates the core symbolization functionality, a production-ready implementation would require several additional components: a robust debuginfod client with retries and rate limiting, proper caching mechanisms, fallback symbolization methods (e.g., symtab) when DWARF isn't available, better error handling, and security considerations around file handling and network requests.

To run it:

  1. Run the main program with default debuginfod server and buildID
  2. Optionally modify the client to use a local debug info file
  3. Optionally enable SymbolizeAll to explore all available symbols

Example usage in main.go shows both specific address symbolization and full binary exploration (commented out by default as they are alternative approaches).

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.

would be nice to have some benchmarks of symbolizing different amount of locations and different file sizes, I think it can help us to pick the right place and architecture for using this


// Save the debuginfo to a temporary file
tempDir := os.TempDir()
filePath := filepath.Join(tempDir, fmt.Sprintf("%s.elf", buildID))
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: this may cause a path traversal, allowing somebody to specify buildID as ../../.../ we should sanitize user provided data in buildID

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