8000 Use the debugger rendez-vous to populate the module list on Linux · Issue #142 · rust-minidump/minidump-writer · GitHub
[go: up one dir, main page]

Skip to content
Dismiss alert

Use the debugger rendez-vous to populate the module list on Linux #142

Closed

Description

@gabrielesvelto

Issue #141 reminded me that we need a better way to populate the module list that doesn't rely on the contents of /proc/<pid>/maps because the latter might not be accessible or because the way the libraries are laid out makes it hard to coalesce the various entries that show up in that file.

The most robust way to do this I can think of is by using the debugger rendez-vous which - by virtue of being used by all debuggers - should be pretty much always available and less finicky than /proc/<pid>/maps.

Here's what we should do: first of all we'll have to find the DT_DEBUG dynamic section inside the executable of the process we're dumping. That section should contain the r_debug structure (note that while I'm pointing to the code in glibc this should also work for bionic, musl, ...). We should verify we're using the right version (r_version == 1 IIRC) and then follow r_link_mal. Each entry in that list is a link_map structure that points to one of the modules in the system. From there it's just a matter of parsing the ELF header which will give us the size of the module as well as the rest of the information we care about (like the SONAME and build ID).

Of course we could keep the /proc/<pid>/maps path as a fallback in case it fails, but I suspect this would be more reliable than that, not less. Also, it wouldn't require I/O which is a plus.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0