Flavius
Flavius

Reputation: 13826

Watchpoints for shared objects

How can I add a watchpoint in .gdbinit for a specific memory location which is going to be allocated on the heap from within a shared object .so?

The following would work if the .so would be already loaded:

watch *((TOKEN*)0x084E4C40)

However I want to put this in .gdbinit, but that doesn't work, because it has no knowledge about the TOKEN data type, saying:

No symbol "TOKEN" in current context.

If I do wait until the .so is loaded, I can do that.

For breakpoints I was able to do:

set breakpoint pending on

However there seems to be nothing similar for watchpoints.

The only thing I could imagine is to somehow load the debugging symbols from the .so file right before setting the watchpoint.

But how to do that?

Upvotes: 1

Views: 107

Answers (1)

n. m. could be an AI
n. m. could be an AI

Reputation: 120079

You don't really need the symbol, only the size of the memory chunk you want to watch. Use this command

watch *(char(*)[NNN])0x084E4C40

where NNN is sizeof(TOKEN).

Upvotes: 3

Related Questions