1

I am working on a lengthy C code split across different files. While debugging, I would like the simulation to stop wherever the value of a certain parameter is changed (not to a specific value).

I have come across watchpoint and watch expression feature in eclipse what is the difference, what would be best suited to track a certain parameter?

Not an expert here, so please be kind :) Thanks :)

howlger
  • 31,050
  • 11
  • 59
  • 99
user750066
  • 43
  • 6

1 Answers1

1

According to official docs at Watchpoints:

A watchpoint is a special breakpoint that stops the execution of an application whenever the value of a given expression changes, without specifying where it might occur. Unlike breakpoints (which are line-specific), watchpoints are associated with files. They take effect whenever a specified condition is true, regardless of when or where it occurred. You can set a watchpoint on a global variable by highlighting the variable in the editor, or by selecting it in the Outline view.

To set a watchpoint on a global variable:

  1. Highlight the variable in the editor, or select it in the Outline view.
  2. Click Run > Toggle Watchpoint.
  3. Do any of the following:

    To stop execution when the watch expression is read, select the Read check box.

    To stop execution when the watch expression is written to, select the Write check box.

  4. The watchpoint appears in the Breakpoints view list.

So, I guess, the watchpoint itself is defined by the watchpoint expression.

Dr. Andrey Belkin
  • 795
  • 1
  • 9
  • 28
  • Thanks, any idea what the watchpoint 'range' refers to? I couldn't find this anywhere... – user750066 Feb 19 '20 at 11:24
  • 1
    @user750066 Some ideas: 1) https://mcuoneclipse.com/2018/08/11/tutorial-catching-rogue-memory-accesses-with-eclipse-and-gdb-watchpoints/ 2) https://community.nxp.com/thread/442312 – Dr. Andrey Belkin Feb 19 '20 at 11:34
  • I think the memory location of the parameter which needs to be tracked needs to be added as a watchpoint... variables -> (select the variable) view memory -> (select the relevant memory) add a watchpoint... Now the issue I face is, the struct has multiple members and the above method halts the process each time any of the variable of the struct is being modified... Unsure if this makes total sense, still digging.. – user750066 Feb 19 '20 at 15:01