GDB has an option to set watchpoint on register*, how does it work ? what happens during context switching ? why the only implementation is for mips ?

Is there a way to make it work for lldb also ?

  • *watch $eax == 0x0000ffff

1 Answer 1


You can probably find the details in GDB’s source code but I think it just single-steps the program until the condition matches. IIRC this is done for any condition that can’t be handled by a hardware breakpoint.

  • there is a link to GDB source code in the question, can you explain how it's not effected by context switch ?
    – whoopdedoo
    Mar 19, 2019 at 15:58
  • @Iddo: The hardware registers are not sensitive to context switching. Usually, they are just ignored by the OS.
    – perror
    Mar 20, 2019 at 8:50
  • can you please provide a prove for that statement ? and why only implementation are for MIPS ?
    – whoopdedoo
    Mar 20, 2019 at 10:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.