Skip to content

[Bug] Extremely slow loading using gdbserver on android #1189

@shemesh999

Description

@shemesh999

GEF+GDB version

GEF: (Standalone)
Blob Hash(/Users/XXX/.gdbinit-gef.py): 7ce988f7a16de5f485c0fa48e0c095444ac7dfe4
SHA256(/Users/XXX/.gdbinit-gef.py): 4c198f277af3b02d7be5875c91798682c71352fb397cef1b15d0e597e2e8b669
GDB: 16.3
GDB-Python: 3.13

Operating System

Android

Describe the issue you encountered

When connecting to gdbserver on android (even without gef), there is a large list of warnings for sections that are not found. These will generally take a few seconds, and will depend on the number of libraries the process uses. I use "set sysroot" to point to these libraries locally and save some time.
However, after installing gef, attaching to gdbserver for a specific process may take more than a minute. Trying to understand why, I've realized that gef will call new_objfile_handler on every loaded library. Moreover, it will attempt to open files such as ".gnu_debugdata for ", which will always fail as this is not a valid library name.

Adding the lines:
if evt and evt.new_objfile.filename and " for " in evt.new_objfile.filename:
return

at the start of 'new_objfile_handler' cut this time by half, but waiting 35 seconds for the process to attach is still way too long.

Do you read the docs and look at previously closed issues/PRs for similar cases?

No

Architecture impacted

  • X86
  • X64
  • ARM
  • ARM64
  • MIPS
  • MIPS64
  • PPC
  • PPC64
  • RISCV

Describe your issue. Without a proper reproduction step-by-step, your issue will be ignored.

  1. In your android device, execute the following: "su -c <GDB_SERVER> --attach 127.0.0.1:7070 $(pidof )
  2. On you connecting computer, execute "adb forward tcp:7070 tcp:7070"
  3. Execute 'gdb -ex "set sysroot " -ex "target remote 127.0.0.1:7070"'

You will see that connecting to any process which loads a significant number of libraries will take more than a minute.

Minimalist test case

Use this field for a minimal code to compile and spot the issue:

// compile with gcc -fPIE -pic -o my_issue.out my_issue.c
int main(){ return 0; }

You can also provide a Dockerfile if you prefer

Additional context?

  • Screenshots
  • Callstack
  • Coredumps
  • If possible and useful, please upload the binary

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions