473,666 Members | 2,120 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Call Stack

What is call stack?
I am sorry if its perceived as an off topic.
Jul 22 '05 #1
3 2364
Vinodh Kumar P wrote:
What is call stack?
I am sorry if its perceived as an off topic.


A common understanding of what a call stack is can be illustrated
easily here:

void foo();
void bar();
int main() {
// here the call stack is
// int main(void)
// __some_internal _c++_startup_co de
foo();
}

void foo() {
// here the call stack is
// void foo(void)
// int main(void)
// __some_internal _c++_startup_co de
// as you can see the current function (foo) is at the top
// of the call stack
bar();
}

void bar () {
// here the call stack is
// void bar(void)
// void foo(void)
// int main(void)
// __some_internal _c++_startup_co de
// as you can see the current function (bar) is now at the top
// of the call stack
}

As to the definition, it's probably "a structure that reflects the path
to a particular place in the program's execution from the beginning via
all function calls".

A call stack does not reflect how the program got to that point except
by tracking the function calls.

<offtopic>
The usefulness of the call stack is in the fact that often you can infer
the execution steps from it by looking what functions are in the middle.
It also often contains the information _from_where_ each function call
was made (file name and line number), especially if the code is compiled
with debugging information. Also, many debuggers are capable of showing
the values of the arguments passed into the function. [My example doesn't
have any arguments]
</offtopic>

Victor
Jul 22 '05 #2
In message <cl**********@n ews.mch.sbs.de> , Vinodh Kumar P
<vi****@here.co m> writes
What is call stack?
It's the record of which functions were called and have not yet
returned, on the way to the current point of execution. Debuggers
usually provide some way of viewing it.
I am sorry if its perceived as an off topic.


As a generic concept it's almost on-topic, though there's nothing
C++-specific about it. How it's implemented on any particular platform
would definitely be off-topic.

--
Richard Herring
Jul 22 '05 #3
Vinodh Kumar P wrote:
What is call stack?


I used Google

http://www.google.com/

to search for

+"call stack" +"C++"

and I found lots of stuff.
Jul 22 '05 #4

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

Similar topics

5
3171
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 (similar to dbx "where" command"). I am working with IBM compiler and AIX but any other OS/compiler solution would be interesting as well. To answer the inevitable question why I want this, I am writing a simple profiler for my library....
3
4930
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 longjmp().Only via using asm? It is strange that I have searched the google groups and FAQs of this group and "googled" the internet but find none useful info. Thanks for any reply!
1
4778
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 ThreadPool.QueueUserWorkItem) When I try to walk the stack from a location that has been called via QueueUserWorkItem, the stack stops at the point where the thread was launched. Is there a way to walk back further into the parent thread's stack (at the time...
11
3890
by: Yahoo | last post by:
I have a programming issue where I need to know the whole history of the call stack to ensure it was never within a given method (specifically my own method). I am hooking into the XmlDocument nodechanged event, I need to from this event call modify a different node in this xmldocument, thus without somekind of check we will be off in an infinite loop. Currently I am using the System.Diagnostics classes but feel its not right to use these...
3
1528
by: Tommy Vercetti | last post by:
I have a complex threading deadlock scenario that I've been able to reproduce in the debugger. I hit break and look at the call stack which should tell me what I need. Except I only get the very bottom of the call stack: KERNEL32.DLL!7c573b28() KERNEL32.DLL!7c573b50() boost_thread-vc71-mt-gd-1_31d.dll!boost::detail::condition_impl::do_wait() Line 198 + 0xf C++ Sniper.exe!boost::condition::do_wait<boost::mutex>() Line 150 + 0xd C++
5
1850
by: Bob Day | last post by:
Using vs 2003, vb.net It is not clear from the documentation, but it appears that a raised event will traverse up the call stack upwards until it reaches its handler. Is this correct? See the code snippet below. The event raised in sub1 or class three will be caught in Class1 event handler (I know below is not syntactically correct, but you get the idea). Class 1 '------------------
24
6573
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 the stack pointer should go upwards when there are "push" operations, and stack pointer should go downards when there are "pop" operations?? If this is the case, the address should go upwards (increasing) or downards (decreasing) then? i.e....
0
5400
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 well-known example is the use of CallWindowProc to call a function gotten via LoadLibrary/GetProcAddress. For example, I've seen code similar to the following which can register/unregister a COM DLL where the path to the DLL is known only at runtime -- in...
1
3101
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{
0
8449
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8360
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8876
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8784
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
5666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4198
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4371
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1777
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.