I'm reading the book http://www.cs.indiana.edu/~geobrown/book.pdf and I have a question regarding the Exercise 3.1.2 on page 50.

It ask to set a watchpoint on i. I set a watchpoint but it never break the code. I tried breakpoint a function as the book said and it worked.

It is related to tool stlink?

thanks :)

  • \$\begingroup\$ It may be that this does not work; watchpoints are tricky to support, extremely so if the variable is not declared volatile. There are almost always alternative techniques you can employ with a little creative thinking. \$\endgroup\$ – Chris Stratton Mar 28 '13 at 16:48

If the source code was compiled so that it could be easily debugged (typically the switch -g) then you can just call in your GDB client:

watch x

Where x is the variable in your code you want to watch. Although its highly likely that it might not be supported by your GDB client for you microcontroller.

  • \$\begingroup\$ Thanks! I removed the optimization flag -O1 and now the watch works :) \$\endgroup\$ – metRo_ Mar 31 '13 at 18:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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