Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove all hardware watchpoints in Linux kernel 3.0.0

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).

like image 223
Sven Avatar asked May 06 '12 15:05

Sven


People also ask

How do you remove watchpoints?

Deleting WatchpointsChoose Goto ® Control debugging ® Watchpoints or the Watchpoints pushbutton to display the watchpoint list. Choose the trashcan icon in the line containing the watchpoint you want to delete.

How to remove watchpoints in gdb?

5.4 How do I disable watchpoints? [top] [toc] Active watchpoints show up the breakpoint list. Use the info breakpoints command to get this list. Then use the disable command to turn off a watchpoint, just like disabling a breakpoint.

What is hardware watchpoint?

Hardware watchpoints - allow execution to halt when a read or write access is made to a data variable address. Count Event - can be used to measure clock cycles between two points in the code. Data Access Count - can be used to determine the number of times a data variable address has been accessed.

How to remove the breakpoints in gdb?

With the clear command you can delete breakpoints according to where they are in your program. With the delete command you can delete individual breakpoints, watchpoints, or catchpoints by specifying their breakpoint numbers.


2 Answers

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.

like image 170
debug Avatar answered Sep 22 '22 14:09

debug


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.

like image 32
Employed Russian Avatar answered Sep 23 '22 14:09

Employed Russian