Click here to Skip to main content
15,886,799 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, i am newly to c++ and debugging with gdb. I tryed to debug my program where the value of global variable gets empty in some part of the code . I compile the program with -g , then run gdb command and set the variable to be watched with watch [variable_name]. Than run command , and the program stop at the line of assigning, but after continue-command, program did not stops on any line till the end..My program has many files respectively translation units. This is all I think.. Do I miss something?

What I have tried:

I saw, that the address of that variable which value I am interested in did not change from the moment of its creation, but somehow its value does.
Posted
Updated 2-Dec-22 4:03am
v2
Comments
Richard MacCutchan 2-Dec-22 10:12am    
Can you show the code, and explain where you set the watchpoint?
Деян Цонев 3-Dec-22 2:16am    
code part ******************************
else
{
system_config.outboundHost = pSockOutboundConfigElement->Attribute(SOCKET_CONFIG_XML_OUTBOUND_HOST_ATTR); // on the line //of assignment I set the watchpoint, and the next line is the line where stops, and after c //command program don't stop any more, but the value get's changed somewhere
if ( system_config.outboundHost == nullptr )
throw MISSING_ATTRIBUTE SOCKET_CONFIG_XML_OUTBOUND_HOST_ATTR;

code part*****************************
Richard MacCutchan 3-Dec-22 3:19am    
Exactly which address do you set in the watchpoint, and where does the referenced item get changed? Please use the Improve question link above, and add the details to your question.
Деян Цонев 2-Dec-22 12:53pm    
I set it after running the gdb command. Where should it be set? I thought the watch command can be use this way, but even if I set it right before the assignment of the variable which I watch , again the result is only one stop on line, when the first assignment is set by me and the second where I am debbuging is not shown.
Richard MacCutchan 2-Dec-22 13:53pm    
If you wish to reply to a comment then please use the Reply button above the message. As it stands I was not alerted to your comments.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900