cassemblygdbwatchpoint

C - make watchpoint with assembly


Like what gdb do with watchpoint, I want to put a watchpoint programmatically in C. I heard that is possible with assembly. In the current time I know only for breakpoints like this instruction :

int i=0;
while(1){
    i++;
    if(i >= 10)
         asm("int");/*break*/
} 

After searching, it exist a possibility to display assembly's instruction using TUI mode and reuse it in my program but it doesn't work.

gdb -q ./prog -tui
gdb: TUI mode is not supported

Thanks for help.


Solution

  • On x86, to make a hardware watchpoint, you'll need to program one of the debug registers. You can start here.