473,513 Members | 2,368 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to get complete call stack ?

Hi,

With the following c-like code:

void test3(void) {
string* s = NULL;
cout << s.length();
}

void test2(void) {
test3();
}

void test1(void) {
test2();
}

int main(int argc, char**argv) {
test1();
}

an exception will be thrown out of the main thread. If I analyzse the
core dump with a debugger, the call stack will show me the following
call order:

test3
test2
test1
main

indicating that the exception comes from test3().

But now if a similar code is executed from a class:

class C {
public:
void test1() {
test2();
}

void test2() {
test3();
}

void test3() {
string* s = NULL;
cout << s.length();
}
};

int main(int argc, char**argv) {
C c;
c.test1();
}

the call stack will only show:

c::test1
main
Does anybody know why ? Is it a compiler issue (I'm using ms-visual
c++ 6) ?
Is there a way to get the complete call stack ?

many thanks

Marc-Andre
Jul 19 '05 #1
1 10171

"Marc-Andre Michel" <no***********@yahoo.com> wrote in message news:44**************************@posting.google.c om...
class C {
public:
void test1() {
test2();
}

void test2() {
test3();
}

void test3() {
string* s = NULL;
cout << s.length();
}
};

When you define a class in this way (the function definition inside the class definition),
the functions are treated as if they were declared inline. As a result the compiler most
likely just inserts the two lines from test3 in the first context that it can recognize the
inline.

As for VC++, you can disable inlining, it's on the optimization tab in the C/C++ settings
panel. In general, if you are in DEBUG configuration, inlining has already been disabled for you

Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2356
by: Vinodh Kumar P | last post by:
What is call stack? I am sorry if its perceived as an off topic.
5
3158
by: Adrian | last post by:
Is there a way (understandably non-portable) to get the call stack from within a function? That is, assuming the application has been compiled with symbols, get the list of calling function names...
3
4904
by: Cong Wang | last post by:
Hi,all! I found an interesting problem,it is that how to implement a C function which can be called once and return twice? Just like the POSIX function fork() or the library function...
1
4767
by: Jason Coyne | last post by:
I am trying to use the StackTrace class to get my current stack trace for some logging. Everything is working fine, except when I am using threading (specifically WaitCallBack and...
24
6547
by: John | last post by:
I know this is a very fundamental question. I am still quite confused if the program call stack stack should always grows upwards from the bottom, or the opposite, or doesn't matter?? That means...
4
3252
by: Jono | last post by:
Hi Everyone, As it says in the title, I'm looking for a way to display a page while long running operations are performed on the server. Ideally, I'd like some way to push the current request...
0
5374
by: Mike S | last post by:
I've seen examples of using the CallWindowProc Windows API function to call functions through their addresses in VB6 -- a clever workaround to emulate C-like function pointer semantics. A...
1
3090
by: George2 | last post by:
Hello everyone, Such code segment is used to check whether function call or exception- handling mechanism runs out of memory first (written by Bjarne), void perverted() { try{
1
3899
by: piyushgpt1 | last post by:
My company has a web application running on JBoss-2.4.4_Tomcat-4.0.1. It works fine for a few days, but once or twice in a week, getting the exception :- Error : Runnable did not complete within...
0
7175
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7391
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7553
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7120
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7542
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5100
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3247
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
809
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
466
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.