Put a breakpoint with GDB in function without symbols

358 views Asked by At

I debug a remote Linux process with GdbServer. And I want to put a breakpoint in some function.

The problem is that this process use ASLR so each time that process load in another address. I can watch in /proc/PID/maps the base address of the process and calculate where the function is located but this is tedious.

Is there a way to put break point with GDB in address the rebase? So the GDB will automatically calculate the rebase of the process?

1

There are 1 answers

1
Employed Russian On

Is there a way to put break point

All the ways you can put a breakpoint in GDB are documented here.

You want something like $image_base(myprogram) + image_offset, which is not a supported address location.

What you could do is write a shell wrapper which computes the desired address and invokes GDB. Something along the lines of:

#/bin/bash

PID="$1"  # process we'll attach.
IMAGE_BASE="0x$(grep myprogram /proc/$PID/maps | sed -e 's/-.*//' -eq)"
IMAGE_OFFSET=0x1234  # use whatever offset corresponds to your function

exec gdb -p "$PID" -ex "break *($IMAGE_BASE+$IMAGE_OFFSET)"