5
int global = 0;

int main() {
    int local = 0;
    local = 1;
    global = 1;
}

I can create a watchpoint for global with:

  • highlight the variable declaration
  • Run -> Toggle watchpoint

and then the program breaks whenever global is modified.

However, if I try this with local an error popup appears:

This operation is unavailable on the current selection. Please select or place the cursor on a field.

GDB allows that with the watch command, using hardware watchpoints.

I know that this can give weird results if the stack frame exits, but that is fine.

Eclipse 4.7.0, CDT 9.3, Ubuntu 16.04.

Related: Setting Memory Breakpoints in Eclipse

Ciro Santilli OurBigBook.com
  • 347,512
  • 102
  • 1,199
  • 985
  • The referenced Eclipse bug is about JDT (Java) instead of CDT. Search for [watchpoints local](https://bugs.eclipse.org/bugs/buglist.cgi?longdesc=watchpoint%20local&longdesc_type=allwordssubstr&product=CDT&query_format=advanced) or [watch point local](https://bugs.eclipse.org/bugs/buglist.cgi?longdesc=watch%20point%20local&longdesc_type=allwordssubstr&product=CDT&query_format=advanced) in CDT instead. – howlger Aug 20 '17 at 08:59
  • @howlger thanks, you are right. I did a global search for those terms, and looked into most of those search results. If you find one that is dead on, please answer the question with it :-) – Ciro Santilli OurBigBook.com Aug 20 '17 at 10:16