Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: Vadim on December 14, 2018, 02:28:08 pm

Title: Call stack window
Post by: Vadim on December 14, 2018, 02:28:08 pm
Can anyone please tell what does the second column in Call stack window named "Address" show?
Title: Re: Call stack window
Post by: BlueHazzard on December 14, 2018, 02:47:27 pm
The address of the function?
Title: Re: Call stack window
Post by: Vadim on December 14, 2018, 03:38:06 pm
I really hoped so :),
but then in code I wrote printf("%p\n", main); and it showed different address (of main()) from that that was shown in Call stack window. I may be wrong but I just cant understand why. May you please explain it?
Title: Re: Call stack window
Post by: blauzahn on December 14, 2018, 06:45:32 pm
os, cb-version, compiler, debugger, c or c++?

On my computer the address within the call-stack window shows e.g. 0x40065b depending on the instruction where you stopped whereas watch and printed value is 0x400652
(ubuntu 18.04, cb svn 11511, g++-trunk (GCC) 9.0.0 20181210, gdb (Ubuntu 8.2-0ubuntu1~18.04) 8.2, c++).

Please try debugging "step into instruction" and you see what I mean.

Please be aware that main is a somewhat special function. Some programmer even say that main is not really a function at all since it is
the designated entry point to a program. You are not supposed to call it.

https://en.cppreference.com/w/cpp/language/main_function (https://en.cppreference.com/w/cpp/language/main_function)
Title: Re: Call stack window
Post by: Vadim on December 14, 2018, 07:55:49 pm
Ive attached the picture of the source code and all.
Windows 8, Code::Blocks 17.12, mingw32-g++ Compiler, gdb32 Debugger, C++.

May you, please, explain why there is a difference between addresses shown in the Call stack window and the Console?
Shouldn't they be the same?
Title: Re: Call stack window
Post by: oBFusCATed on December 15, 2018, 12:19:10 am
You'll have to ask in a forum/mailing list which supports gdb for the exact answer.

Most probably gdb prints the stack frame which is not the same as the function address. Also it seems The FirstFunction have been inlinded.
Title: Re: Call stack window
Post by: Vadim on December 15, 2018, 12:10:53 pm
Thank you!