77

For my current embedded application I am trying to put GDB watch point at a fixed memory address.

As an example, my application updates the following address: 0x10793ad0. In order to be sure which part of the code is corrupting the value, I tried

watch 0x10793ad0

Even though GDB does not print any error after this, it is not able to break during execution even though I verified the value is getting modified at between start and end of execution.

Questions:

  1. Can I really put watch at a fixed address? I didn't come across any such example online.
  2. Is this the right way or am I missing something?
Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
maniac_inside
  • 908
  • 1
  • 7
  • 8
  • for reference: what you did there, was to watch an expression: `0x10793ad0` -> the literal value. that value is constant of course, does not change and therefore no break triggered. __hint:__ use `disp(lay) ` to check the result before using it to break on – Florian Jun 04 '22 at 07:39

1 Answers1

116

The right way to set watchpoint on address is watch *0x10793ad0. See gdb doc

ks1322
  • 33,961
  • 14
  • 109
  • 164
  • 28
    If you're using a fixed address because you want to watch a variable outside the local scope, use `watch -l localptr->member` instead. – Nathan Kidd Feb 04 '15 at 19:01