callstack

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

我是研究僧i 提交于 2019-11-28 09:00:13
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 were declared (the stack is unwound). void f() { SomeKindOfException ex(...); throw ex; } void g() { try { f(); } catch (SomeKindOfException& ex) { //Handling code... } } I've added a print statement to SomeKindOfException's destructor and it shows that ex is destructed once it goes out of scope in f() but then it's caught in g() and destructed again

Determine calling function in javascript [duplicate]

梦想与她 提交于 2019-11-28 08:50:25
Possible Duplicate: How do you find out the caller function in JavaScript? How can I find out in a javascript function which was the calling (the former in the call stack) function? I would like to determine if the former called function is a __doPostback in the onbeforeunload event. Each function has a caller property defined. From https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Function/caller : function myFunc() { if (myFunc.caller == null) { return ("The function was called from the top!"); } else return ("This function's caller was " + myFunc.caller); } } The

How to get Java Call Stack of a running application

妖精的绣舞 提交于 2019-11-28 06:58:19
I am working on very huge java web based application. As there is no proper logging done while development so its very difficult for me to put break point and debug the app as i dont know execution order. Is there any mechanism to get complete Call Stack of the the running java application after I perform some actions. I searched it on net for long time but cannot came to concrete solution. Please suggest me if something is there for it. Thanks Mikhail Vladimirov Method 1: Use jstack utility from command line (part of the JDK distro). Method 2: Send signal 3 to the java process, it will dump

How to Log Stack Frames with Windows x64

放肆的年华 提交于 2019-11-28 03:29:33
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 reliable way to write only the return adresses into the logfile. I tried several ways: Trial 1: Pointer Arithmetic: CONTEXT Context; RtlCaptureContext(&Context); char *eNextBP = (char *)Context.Rdi; for(ULONG Frame = 0; eNextBP ; Frame++) { char *pBP = eNextBP; eNextBP = *(char **)pBP; // Next BP in Stack fprintf(LogFile, "*** %2d called from %016LX

How exactly does the callstack work?

可紊 提交于 2019-11-28 02:36:43
I'm trying to get a deeper understanding of how the low level operations of programming languages work and especially how they interact with the OS/CPU. I've probably read every answer in every stack/heap related thread here on Stack Overflow, and they are all brilliant. But there is still one thing that I didn't fully understand yet. Consider this function in pseudo code which tends to be valid Rust code ;-) fn foo() { let a = 1; let b = 2; let c = 3; let d = 4; // line X doSomething(a, b); doAnotherThing(c, d); } This is how I assume the stack to look like on line X: Stack a +-------------+

Why does calling setTimeout with parenthesis not start a new callstack?

扶醉桌前 提交于 2019-11-28 00:26:56
The following code has a new callstack when the debugger fires in d (jsfiddle here ) function c() { setTimeout( d, 1000 ); } function d() { debugger; } c(); If we modify the code to use setTimeout( d(), 1000 ); which has brackets (parenthesis:) function c() { setTimeout( d(), 1000 ); } function d() { debugger; } c(); then the callstack has both c() and d() (jsfiddle here ). Why? You are not passing setTimeout the function d in the second example; you are instead passing d() , which is the result of calling d . The result of calling d is undefined since it returns nothing, which converts to the

What is the purpose of the _chkstk() function?

人盡茶涼 提交于 2019-11-27 22:43:00
I recently used the /FAsu Visual C++ compiler option to output the source + assembly of a particularly long member function definition. In the assembly output, after the stack frame is set up, there is a single call to a mysterious _chkstk() function. The MSDN page on _chkstk() does not explain the reason why this function is called. I have also seen the Stack Overflow question Allocating a buffer of more a page size on stack will corrupt memory? , but I do not understand what the OP and the accepted answer are talking about. What is the purpose of the _chkstk() CRT function? What does it do?

“RangeError: Maximum call stack size exceeded” Why?

房东的猫 提交于 2019-11-27 18:39:33
If I run Array.apply(null, new Array(1000000)).map(Math.random); on Chrome 33, I get RangeError: Maximum call stack size exceeded Why? Browsers can't handle that many arguments. See this snippet for example: alert.apply(window, new Array(1000000000)); This yields RangeError: Maximum call stack size exceeded which is the same as in your problem. To solve that, do: var arr = []; for(var i = 0; i < 1000000; i++){ arr.push(Math.random()); } Farid Nouri Neshat Here it fails at Array.apply(null, new Array(1000000)) and not the .map call. All functions arguments must fit on callstack(at least

List of all function calls made in an application

一个人想着一个人 提交于 2019-11-27 18:12:06
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 called from these called functions and so on. Is there a way to get this in gdb? Or could you give me suggestions on how to get this? How can we list all the functions being called in an application For any realistically sized application, this list will have thousands of entries, which will probably make it useless. You can find out all functions

c++ stack trace from unhandled exception?

泄露秘密 提交于 2019-11-27 18:00:46
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 how to use the backtrace library to generate a stack trace from a given point in the program. However, this won't help when my terminate-replacement is called since at that point the stack has been unwound. Yet if I simply allow the program to abort() , it will produce a core-dump which contains the full stack information from the point at which