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

Allow naming and configuring order of type, object, and symbol finders #393

Merged
merged 6 commits into from
Jun 5, 2024

Commits on Jun 5, 2024

  1. libdrgn: add interface for registering chains of named handlers

    This will be used to allow providing names for type, object, and symbol
    finders and configuring which ones are called and in what order. We
    might even want this for memory readers. I'm assuming there will only be
    a handful of handlers on a given list, but the enabled handlers will be
    called frequently, and there may be many lists. The implementation is
    therefore optimized for fast iteration and small size, and we don't
    cache anything that would speed up reconfiguring the list.
    
    Signed-off-by: Omar Sandoval <[email protected]>
    osandov committed Jun 5, 2024
    Configuration menu
    Copy the full SHA
    07b9270 View commit details
    Browse the repository at this point in the history
  2. Allow naming and configuring order of symbol finders

    Currently, the bare-bones add_symbol_finder() interface only allows
    adding a symbol finder that is called before any existing finders. It'd
    be useful to be able to specify the order that symbol finders should be
    called in and to selectively enable and disable them. To do that, we
    also need finders to have a name to identify them by. So, replace
    add_symbol_finder() (which hasn't been in a release yet) with a set of
    interfaces providing this flexibility: register_symbol_finder(),
    set_enabled_symbol_finders(), registered_symbol_finders(), and
    enabled_symbol_finders(). Also change the callback signature to take the
    program.
    
    In particular, this flexibility will be very useful for a plugin system:
    pre-installed plugins can register symbol finders that the user can
    choose to enable or disable.
    
    Signed-off-by: Omar Sandoval <[email protected]>
    osandov committed Jun 5, 2024
    Configuration menu
    Copy the full SHA
    8ebbb4f View commit details
    Browse the repository at this point in the history
  3. python: add TypeKindSet

    C type finders are passed a bitset of type kinds, but Python type
    finders currently get called for each type kind. An upcoming update to
    the type finder interface will fix this, but we need a set of TypeKinds,
    and we'd rather not construct a real Python set for it. Instead, add a
    TypeKindSet bitset that satisfies the collections.abc.Set interface.
    
    Signed-off-by: Omar Sandoval <[email protected]>
    osandov committed Jun 5, 2024
    Configuration menu
    Copy the full SHA
    e1def32 View commit details
    Browse the repository at this point in the history
  4. Allow naming and configuring order of type finders

    Like for symbol finders, we want extra flexibility around configuring
    type finders. The type finder callback signature also has a couple of
    warts: it doesn't take the program since it was added before types
    needed to be constructed from a program, and it is called separately for
    each type kind since originally type lookups were for only one kind.
    While we're adding a new interface, let's fix these warts: pass the
    program and a set of type kinds. However, we need to keep the old
    add_type_finder() interface for backwards compatibility.
    
    Signed-off-by: Omar Sandoval <[email protected]>
    osandov committed Jun 5, 2024
    Configuration menu
    Copy the full SHA
    8bdd63c View commit details
    Browse the repository at this point in the history
  5. libdrgn: linux_kernel: deduplicate kernel-specific program setup

    The ELF and libkdumpfile paths have duplicated logic for adding the
    Linux kernel object finder and setting the default language to C. Factor
    them out into a common helper.
    
    Signed-off-by: Omar Sandoval <[email protected]>
    osandov committed Jun 5, 2024
    Configuration menu
    Copy the full SHA
    66c2576 View commit details
    Browse the repository at this point in the history
  6. Allow naming and configuring order of object finders

    This one doesn't need any changes to the callback signature, just the
    new interface. We also keep add_object_finder() for compatibility.
    
    Signed-off-by: Omar Sandoval <[email protected]>
    osandov committed Jun 5, 2024
    Configuration menu
    Copy the full SHA
    b859caf View commit details
    Browse the repository at this point in the history