Watchpoints in shared memory?

I am debugging an issue in a PostgreSQL patch where a word in shared memory seems to be overwritten unintentionally.

Valgrind doesn't help as it can't track shared memory interactions between multiple processes.

The address being overwritten is fairly stable, but not completely fixed, although it is always identified by a pointer in the global structure, initialized at the start of startup by each process.

I am trying to find a way to get a stack trace whenever any process writes to the address of interest, but it turned out to be rather complicated than I expected.

gdb

watchpoints don't help as gdb can't follow fork()

and set the same clock for child processes. Doing this manually with multiple gdb processes is very cumbersome due to the number of child processes that PostgreSQL uses and the timing issues associated with manual configuration.

perf

User-space probes looked promising, but they seem to be function bound only, there is no explicit way to catch a write to a memory address.

So, is there a way to capture stack traces for each writer at a given shared memory address across multiple processes?

+3


source to share


1 answer


gdb cannot follow fork () and set the same clock for child processes



A fairly recent GDB can do this. Documentation here and here .

+1


source







All Articles