Author Topic: Does C::B have the function of watchpoint?  (Read 4287 times)

Offline gjj2828

  • Single posting newcomer
  • *
  • Posts: 4
Does C::B have the function of watchpoint?
« on: February 01, 2009, 03:05:55 pm »
I've found that C::B can show the value of variables when debugging. But I cannot find how to set watchpoint to variables? Does C::B have the function of watchpoint?

Thx...

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5234
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Does C::B have the function of watchpoint?
« Reply #1 on: February 01, 2009, 03:36:41 pm »
Open the Watch window when you're debugging.
See attachment picture below.


[attachment deleted by admin]
« Last Edit: February 01, 2009, 03:38:25 pm by ollydbg »
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline gjj2828

  • Single posting newcomer
  • *
  • Posts: 4
Re: Does C::B have the function of watchpoint?
« Reply #2 on: February 01, 2009, 05:05:26 pm »
Open the Watch window when you're debugging.
See attachment picture below.


Thank you very much for your reply.

I see that in the watch window, I can find the value of variables. But I want B::C to give me some messages when mine specified variable is changed when the program is running in the debugging mode. That is watchpoint's purpose. I don't konw how to do that. Could you show me the way?

Thx...

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5234
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Does C::B have the function of watchpoint?
« Reply #3 on: February 01, 2009, 05:16:43 pm »
Sorry, I can't give your the answer.
You can read the GDB's manual to get the answer yourself. It is like a "memory break point".
Or, You can write a small code to check variable changed or not.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline gjj2828

  • Single posting newcomer
  • *
  • Posts: 4
Re: Does C::B have the function of watchpoint?
« Reply #4 on: February 01, 2009, 07:37:27 pm »
Sorry, I can't give your the answer.
You can read the GDB's manual to get the answer yourself. It is like a "memory break point".
Or, You can write a small code to check variable changed or not.

I've read the CodeBlocks Manual but find nothing about watchpoint. But thank you all the same. Maybe C::B cannot do that today. But I think watchpoint is very important when you develope a massive project and facing some bug arising from memory leak.

Since you mentioned GDB's manual, please let me ask some questions, because I'm not familiar with it.

1.Can GDB running at windows platform?
2.I have installed codeblocks-8.02-setup.exe. I think it has contained the GDB Plugins. Am I right? Will I need to find GDB and install it again?
3.I've found a GDB's manual link http://www.gnu.org/software/gdb/documentation/. Is it right?
4.I've checked every corner of CodeBlocks's interface but found noting about watchpoint. If GDB's manual would help me, does it mean I will debug program through commond line with no GUI?

Thx...

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5234
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Does C::B have the function of watchpoint?
« Reply #5 on: February 02, 2009, 02:32:56 am »
Sorry, I'm not a gdb export, so, I can only give my suggestion.
1, install nightly build version
2, install TDM-MinGW
3, You can debug in GUI.

 :D
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline gjj2828

  • Single posting newcomer
  • *
  • Posts: 4
Re: Does C::B have the function of watchpoint?
« Reply #6 on: February 02, 2009, 03:12:44 am »
Sorry, I'm not a gdb export, so, I can only give my suggestion.
1, install nightly build version
2, install TDM-MinGW
3, You can debug in GUI.

 :D

Thank you for your advice. I'll take it.
You are so kind and your advice is so helpful.

Thx... :D

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5234
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Does C::B have the function of watchpoint?
« Reply #7 on: February 07, 2009, 08:27:02 am »
See here if you want to add "watch point" in GDB
http://sources.redhat.com/gdb/current/onlinedocs/gdb_6.html#SEC35
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.