Jump to content
Fabrizio The Cat

CPP builder 12.1 CE: Debug problem

Recommended Posts

Hi all,

after several days of problem debugging a large project, i decided to simplify my life.

 

So i ha have created a new project with the default form only.

Put on it a button and a label.

The button code is:

 

{

int a =1;

int b;

int c;

 

 b=2;

 

c=a+b:

label1->Caption=c;

}

 

a breakpoint on 'b=2' row

The ide when in debug mode show: 'watch list', 'local variables' and 'Call stack' views

first time: Running the program and pushed the button the program stops;

Adding a, b and c variables to the watch list:

in the watch list: a=1 b=0 c=853538 (seems random)

local variables is completely blank as Call stack

.

pressing F8 -> b = 0 c = 853538

pressing F8 -> b = 0 c = 853538

F9 -> the program continue and show the label and the correct value.

 

Closed the ide, launched again and stopped:

in the watch list all 3 variables are with [Evaluating...] value (don't change after lot of time)

and no changes tracing with F8.

 

As i think it's a local problem, what can i do to have the debugger working?

 

Thanks to all that will help me.

 

Fabrizio

 

Edited by Fabrizio The Cat

Share this post


Link to post

It's possible that the compiler has optimised away most of your code, just leaving it with label1->Caption=3. does the same thing happen if you turn off optimisation?

Share this post


Link to post
2 hours ago, Des101 said:

It's possible that the compiler has optimised away most of your code, just leaving it with label1->Caption=3. does the same thing happen if you turn off optimisation?

Thanks for the answer.

Good idea but in Options -> C++ Compiler -> Optimizations 'Disable all optimizations' is selected.  Just verified.

And this wouldn't affect the blank Call stack view, i suppose nor the watch list unresponsive.

 

I have noted that i can see the values in the watch list clicking right mouse button and then selecting the 'enable all'  menu item (note the watches are all emabled...) but this seems force to refresh the view.

Others ideas?

Share this post


Link to post

The uninitialized values of b & c are not surprising, they'll potentially just be what was last in memory at the address that's being used for them.

 

Regarding what the debugger is showing, we regularly get the same/similar behaviour in Delphi for inline variables (wrong values or unable to display) and at times rubbish values for normal local variables as well 😞

 

 

Share this post


Link to post
11 hours ago, Mark NZ said:

The uninitialized values of b & c are not surprising, they'll potentially just be what was last in memory at the address that's being used for them.

Hi Mark, Yes, this is normal as the variables aren't initialized. 

11 hours ago, Mark NZ said:

Regarding what the debugger is showing, we regularly get the same/similar behaviour in Delphi for inline variables (wrong values or unable to display) and at times rubbish values for normal local variables as well 😞

My problem is not the wrong values showed, but the debugger that don't show or refresh the actual value of the variables (local or not) during the debug. Also is a large problem the empty 'call stack'  view.

 

I think: this may be a bad value in the settings but there are hundreds of items; may be a strange bug in the compiler (missing information in code?) or in the debugger itself; some rubbish in the compiler output files that make confusion.

 

Thank you for the collaboration.

Edited by Fabrizio The Cat

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×