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

Add SymbolIndex and kallsyms helpers #388

Merged
merged 6 commits into from
Oct 12, 2024
Merged

Commits on Sep 30, 2024

  1. libdrgn: util: add qsort_arg() helper function

    In commit c8ff872 ("Support systems without qsort_r"), usage of qsort_r
    was eliminated because it is a glibc extension. There was discussion of
    creating a utility function that implements qsort_r(), but the approach
    described uses thread local variables, so it is not actually reentrant,
    and it was dropped to avoid confusion.
    
    However, upcoming commits will also prefer a comparator function which
    takes an argument, and they also won't require a reentrant
    implementation. Add this helper in with a name that shouldn't spark
    confusion: qsort_arg().
    
    Signed-off-by: Stephen Brennan <[email protected]>
    brenns10 committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    395071a View commit details
    Browse the repository at this point in the history
  2. python: Add helper for returning list of Symbols

    This will be reused in an upcoming commit.
    
    Signed-off-by: Stephen Brennan <[email protected]>
    brenns10 committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    f64287a View commit details
    Browse the repository at this point in the history

Commits on Oct 10, 2024

  1. libdrgn, python: add SymbolIndex

    The Symbol Finder API gives us the ability to register a dynamic
    callback for symbol lookup. However, many common use cases are satisfied
    by a simple static list of symbols. Correct and efficient lookup in this
    simple case is rather tricky. Implement a new type, SymbolIndex, which
    can take a list of symbols and index them for efficient lookup by name
    or address.
    
    Signed-off-by: Stephen Brennan <[email protected]>
    brenns10 committed Oct 10, 2024
    Configuration menu
    Copy the full SHA
    fda9b25 View commit details
    Browse the repository at this point in the history

Commits on Oct 11, 2024

  1. helpers: linux: add vmlinux kallsyms helpers

    When properly configured, Linux contains its own symbol table within
    kernel memory at runtime. It is exposed as the /proc/kallsyms file,
    which is the easiest way to consume it, for live kernels.
    
    However, with recent changes to the Linux kernel in 6.0, necessary
    symbols are exposed within VMCOREINFO that allow us to interpret the
    data structures inside kernel memory, without needing debuginfo. This
    allows us to write helpers that can load kallsyms on vmcores, or on live
    systems.
    
    Signed-off-by: Stephen Brennan <[email protected]>
    brenns10 committed Oct 11, 2024
    Configuration menu
    Copy the full SHA
    151c9bc View commit details
    Browse the repository at this point in the history
  2. helpers: linux: add module kallsyms helpers

    Add Python helpers which load module kallsyms and return a symbol index
    for them. Unlike the /proc/kallsyms and built-in kallsyms, these are
    quite easy to handle using regular Python & drgn code, so implement them
    as Python helpers.
    
    There are (at least) two use cases for these helpers:
    1. After loading CTF and built-in vmlinux kallsyms, support for module
       kallsyms is still necessary.
    2. Sometimes, people only extract vmlinux DWARF debuginfo. Adding module
       symbols can allow stack traces and other symbolization to work even
       without module debuginfo.
    
    Signed-off-by: Stephen Brennan <[email protected]>
    brenns10 committed Oct 11, 2024
    Configuration menu
    Copy the full SHA
    19ab162 View commit details
    Browse the repository at this point in the history
  3. libdrgn: add lifetime to drgn_symbol, reduce copying

    The SymbolIndex structure owns the memory for symbols and names, and
    once added to the Program, it cannot be removed. Making copies of any of
    these symbols is purely a waste: we should be able to treat them as
    static. So add a lifetime and allow the SymbolIndex to specify static,
    avoiding unnecessary copies and frees.
    
    Signed-off-by: Stephen Brennan <[email protected]>
    brenns10 committed Oct 11, 2024
    Configuration menu
    Copy the full SHA
    ee3f77f View commit details
    Browse the repository at this point in the history