Questions tagged [callstack]

A stack that stores details of the functions called by a program in sequence, so that each function can return on completion to the code that called it.

A call stack is a stack data structure that stores information about the active subroutines of a computer program. This kind of stack is also known as an execution stack, control stack, run-time stack, or machine stack, and is often shortened to just "the stack".

A call stack is used for several related purposes, but the main reason for having one is to keep track of the point to which each active subroutine should return control when it finishes executing. An active subroutine is one that has been called but is yet to complete execution after which control should be handed back to the point of call. Such activations of subroutines may be nested to any level (recursive as a special case), hence the stack structure.

Source: Wikipedia (Call Stack)

For errors relating to overflowing the call stack use .

1119 questions
34
votes
10 answers

Call-stack for exceptions in C++

Today, in my C++ multi-platform code, I have a try-catch around every function. In every catch block I add the current function's name to the exception and throw it again, so that in the upmost catch block (where I finally print the exception's…
Igor
  • 26,650
  • 27
  • 89
  • 114
33
votes
2 answers

movq (%rsp), %rsp assembly stack pointer load?

I was reading some code and was not sure what this line does: movq (%rsp), %rsp
jamesatha
  • 7,280
  • 14
  • 37
  • 54
33
votes
3 answers

c++ stack trace from unhandled exception?

This question has been asked before and there have been windows-specific answers but no satisfactory gcc answer. I can use set_terminate() to set a function that will be called (in place of terminate()) when an unhandled exception is thrown. I know…
c-urchin
  • 4,344
  • 6
  • 28
  • 30
32
votes
6 answers

Is there any way to set a breakpoint in gdb that is conditional on the call stack?

I am debugging C++ in gdb 7.1 on Linux. I have a function a() that is called in many places in the code. I want to set a breakpoint in it, but only if it was called from b(). Is there any way to do it? Is there any way to do it only if b() was…
Nathan Fellman
  • 122,701
  • 101
  • 260
  • 319
29
votes
1 answer

What is the default stack size in Node.js?

I know how to set the stack size thanks to: How can I increase the maximum call stack size in Node.js But, what is the default size? (ie how do I get to the PHP equivalent of phpinfo())
blak3r
  • 16,066
  • 16
  • 78
  • 98
28
votes
1 answer

How to get the full call stack from Valgrind?

I run Valgrind with the following parameters: --leak-check=full --show-reachable=yes --leak-resolution=high --num-callers=100 --trace-children=yes In memory leaks log, I see some error messages with full stack trace up to main, but some messages…
Michael Lukin
  • 829
  • 3
  • 9
  • 19
27
votes
5 answers

List of all function calls made in an application

How can we list all the functions being called in an application. I tried using GDB but its backtrace list only upto the main function call. I need deeper list i.e list of all the functions being called by the main function and the function being…
broun
  • 2,483
  • 5
  • 40
  • 55
27
votes
4 answers

JavaScript exception handling - displaying the line number

When catching / handling exceptions in JavaScript, how can I determine what the call stack was when the exception occurred? (and also if possible what the line number was) try { // etc... } catch (ex) { // At this point here I want to be…
Justin
  • 84,773
  • 49
  • 224
  • 367
25
votes
3 answers

Is stack memory contiguous?

How does the compiler enforce the stack memory to be contiguous, does it cause the memory to be moved everytime while the program is running or does it reserve the memory on stack needed by program before running it?
user2133
  • 253
  • 3
  • 6
25
votes
6 answers

How are exceptions allocated on the stack caught beyond their scope?

In the following code, the stack-based variable 'ex' is thrown and caught in a function beyond the scope in which ex was declared. This seems a bit strange to me, since (AFAIK) stack-based variables cannot be used outside the scope in which they…
John Doe
  • 285
  • 3
  • 5
24
votes
12 answers

How to Log Stack Frames with Windows x64

I am using Stackdumps with Win32, to write all return adresses into my logfile. I match these with a mapfile later on (see my article [Post Mortem Debugging][1]). EDIT:: Problem solved - see my own answer below. With Windows x64 i do not find a…
RED SOFT ADAIR
  • 12,032
  • 10
  • 54
  • 92
24
votes
13 answers

How to get the name of the calling class in Java?

I would like some help on this matter, Example: public class A { private void foo() { //Who invoked me? } } public class B extends A {} public class C extends A {} public class D { C.foo(); } This is basically the scenario.…
Mark Buhagiar
  • 261
  • 1
  • 2
  • 7
24
votes
3 answers

Wrong line numbers from addr2line

I try to find the exact line of a call in the backtrace in C++ program. Right now I am using these lines (from the man page of backtrace) to get the trace: void *bt_buffer[1000]; char **bt_strings; int bt_nptrs = backtrace(bt_buffer, 1000); …
steffen
  • 8,572
  • 11
  • 52
  • 90
22
votes
3 answers

How can I navigate the call stack in Visual Studio using just the keyboard?

My current solution is to hit AltD, W, C, which navigates via the menus to the call stack, and then I can use the arrows to navigate. But once I press Enter on a particular frame, I have to repeat again. Is there a more fluid way to navigate the…
joshcomley
  • 28,099
  • 24
  • 107
  • 147
22
votes
3 answers

"[Lightweight Function]" in the call stack

I'm debugging a program (VS2008), and I was stepping through lines of code. I came across one line where a delegate function was being called, and I tried to step into it. However, rather than stepping into the method as I expected, the method was…
Smashery
  • 57,848
  • 30
  • 97
  • 128
1 2
3
74 75