6

After setting the first (and only possible) hardware watchpoint via watch varname in GDB, it's not possible to remove it via delete.

Even if I just exit GDB, this watchpoint seems to be enabled till the next reboot. When I try to set another hardware watchpoint after GDB is restarted, a kernel message appears in logs telling me, all hardware watchpoints are already taken. It seems like it's the same problem as in Setting GDB hardware watchpoint/how to set software watchpoint, but because I need a hardware watchpoint, the solution does not apply.

Is there a tool or a syscall to remove this (or all) hardware watchpoint? The CPU is an Core i5 and the Linux kernel is 3.0.0-17-generic from Ubuntu 11.10 (Oneiric Ocelot).

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Sven
  • 7,335
  • 4
  • 15
  • 14
  • 1
    This sounds like a bug. gdb uses ptrace to add/remove hardware breakpoints. So, you can try running gdb under strace and look for ptrace calls related to hardware breakpoints and hopefully, it should give you some clue about what's happening. Also, make sure you are running the latest kernel and gdb. Trying the upstream kernel is another option. – Naveen May 06 '12 at 16:58
  • How do you try to remove it and what happens? Did you try latest gdb (7.4)? – dbrank0 May 06 '12 at 20:46
  • Thanks for your help - I upgraded the kernel today to 3.0.0-19 and I'm now able to create more than one hardware watchpoint and they are automatically removed when gdb is closed. – Sven May 07 '12 at 11:34

2 Answers2

12

Use watchpoints (sometimes called data breakpoints). It can handle it as normal breakpoints, as follows:

(gdb) info watchpoints
Num     Type           Disp Enb Address            What
2       acc watchpoint keep y                      x

(gdb) delete 2

(gdb) info watchpoints
No watchpoints.
(gdb)

A good reference is Setting Watchpoints.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
debug
  • 991
  • 10
  • 14
2

After setting the first (and only possible) hardware watchpoint via watch varname in gdb it's not possible to remove it via delete.

The statement above is false. What led you to conclude it is true?

Is there a tool or a syscall to remove this (or all) hardware watchpoint?

No such tool is necessary. Simply quit GDB, and all breakpoints and watchpoints will be gone. Or do (gdb) delete (without specifying a break point), and confirm that you want to delete all.

Employed Russian
  • 199,314
  • 34
  • 295
  • 362
  • Sorry, I'm not able to reproduce the behaviour. After the update to 3.0.0-19 today everything seems fine. – Sven May 07 '12 at 11:35