srgothard's Avatar
srgothard 4
25 Asked
542 Answered
202 Best
1
No one has voted on this question yet :(
3 years, 1 month ago

How do you have a variable's value printed each time you step in gdb?

I remember when I would debug a C++ program with gdb that I could set it so that a particular variable's value would be displayed each time I stepped to the next line of code. I've tried the "watch" command, but it seems to show the variable only when it is changed. I've searched the help files, and I can't find it. Any ideas?
Tip for best answer: M$1.00
Separate topics with commas, or by pressing return. Use the delete or backspace key to edit or remove existing topics.

You can leave an optional "tip" with Mahalo's virtual currency, Mahalo Dollars. If you are asking a difficult question that might require some research, or if you'd like a wide variety of feedback, a higher tip often leads to more answers to your question.

M$

What is Your Answer?

0
0
0

1 Answer

0
warlrus's Avatar
warlrus | 3 years, 1 month ago
3
I think you need to use awatch to achieve this:

http://www.unknownroad.com/rtfm/gdbtut/gdbwatch.html#RDWR

You can leave an optional "tip" with Mahalo's virtual currency, Mahalo Dollars. If you are asking a difficult question that might require some research, or if you'd like a wide variety of feedback, a higher tip often leads to more answers to your question.

M$
srgothard's Avatar
srgothard | 3 years, 1 month ago Report

awatch doesn't seem to print it every time I step.

srgothard's Avatar
srgothard | 3 years ago Report

I remembered it! It's "display ". I was helping a student with his code, and it hit me.

Report Abuse

Post Reply Cancel

Learn something new with our FREE educational apps!

Private lessons in the comfort of your own home. Get back in shape or finally pick up a guitar with our great experts guiding you the whole way!
Learn Guitar
Learn Hip Hop
Learn Pilates