callstack

Get run time type of stack frames

邮差的信 提交于 2019-12-19 09:56:28
问题 I was wondering if it were possible to obtain the run time type of method callers in the stack trace. Consider the following example: class Parent { public void Foo() { var stack = new StackTrace(); foreach (var frame in stack.GetFrames()) { var methodInfo = frame.GetMethod(); Console.WriteLine("{0} (ReflectedType: {1})", methodInfo.ToString(), methodInfo.DeclaringType); } } } class Child : Parent { } If I create an instance of Child and call Foo var child = new Child(); child.Foo(); Foo will

how to catch a “Maximum call stack size exceeded” error?

被刻印的时光 ゝ 提交于 2019-12-19 09:49:57
问题 try { requestAnimationFrame(function re(){ re(); })} catch (e){ console.log(e); } I tried above code in console, it doesn't work as expected. It seems to me that although requestAnimationFrame(function re(){ re(); })} will eventually trigger an error, what throws to the try is insteadly the animation's id. How do I catch such a "Maximum call stack size exceeded" error? 回答1: the thing about catching a maximum stack size exceeded error is I'm not sure how it would work. The only thing that the

How do you find the caller function? [duplicate]

此生再无相见时 提交于 2019-12-18 16:56:55
问题 This question already has answers here : Closed 11 years ago . Closed as exact duplicate of "How can I find the method that called the current method?" Is this possible with c#? void main() { Hello(); } void Hello() { // how do you find out the caller is function 'main'? } 回答1: Console.WriteLine(new StackFrame(1).GetMethod().Name); However, this is not robust, especially as optimisations (such as JIT inlining) can monkey with the perceived stack frames. 回答2: From here: System.Diagnostics

Get function callers' information in python

牧云@^-^@ 提交于 2019-12-18 15:51:35
问题 I want to get information about the callers of a specific function in python. For example: class SomeClass(): def __init__(self, x): self.x = x def caller(self): return special_func(self.x) def special_func(x): print "My caller is the 'caller' function in an 'SomeClass' class." Is it possible with python? 回答1: Yes, the sys._getframe() function let's you retrieve frames from the current execution stack, which you can then inspect with the methods and documentation found in the inspect module;

How to print call stack in Swift?

怎甘沉沦 提交于 2019-12-18 10:15:18
问题 In Objective-C, you can print the call stack by doing the following: NSLog(@"%@", [NSThread callStackSymbols]); How do you do this in Swift without using Foundation class? 回答1: As Jacobson says, use the following: Swift 2: print(NSThread.callStackSymbols()) Swift 3 / Swift 4: print(Thread.callStackSymbols) That's Swift code. It's using a Foundation method, but so does 90%+ of what you do on iOS. EDIT: Note that the formatting looks better if you use: Thread.callStackSymbols.forEach{print($0)}

Profiling JavaScript Code on nodejs - Possible Approaches

丶灬走出姿态 提交于 2019-12-18 09:43:08
问题 My aim is to develop a java script profiler for nodejs . The requirements are as under : Should be able to fetch call stack . Get Time stamp information. Get number of iterations. My chief concern is that i should not modify the source file ( .js file ) . I have seen all the available profiling options for JavaScript code on node js . The problem i face is that most of them require manual injection of the profiling specific code into my source code. Here is an example var profiler = new

Is there a way to examine the stack variables at runtime in C#?

冷暖自知 提交于 2019-12-18 04:21:41
问题 Is there a way to dump the contents of the stack at runtime? I am interested in both the parent functions information (name, parameters, line) which I know I can get with the StackTrace and StackFrame classes. However, I would also like to get the variables in the stack (local variables declared in the method that called the one is currently executing). Since the Visual Studio debugger can do this, I think there may be a way to also do it at runtime within the code. Is there such a way? 回答1:

Is there a way to examine the stack variables at runtime in C#?

五迷三道 提交于 2019-12-18 04:21:04
问题 Is there a way to dump the contents of the stack at runtime? I am interested in both the parent functions information (name, parameters, line) which I know I can get with the StackTrace and StackFrame classes. However, I would also like to get the variables in the stack (local variables declared in the method that called the one is currently executing). Since the Visual Studio debugger can do this, I think there may be a way to also do it at runtime within the code. Is there such a way? 回答1:

Why is it better to use the ebp than the esp register to locate parameters on the stack?

断了今生、忘了曾经 提交于 2019-12-17 21:36:06
问题 I am new to MASM. I have confusion regarding these pointer registers. I would really appreciate if you guys help me. Thanks 回答1: Encoding an addressing mode using [ebp + disp8] is one byte shorter than [esp+disp8] , because using ESP as a base register requires a SIB byte. See rbp not allowed as SIB base? for details. (That question title is asking about the fact that [ebp] has to be encoded as [ebp+0] .) The first time [esp + disp8] is used after a push or pop, or after a call , will require

“RangeError: Maximum call stack size exceeded” Why?

最后都变了- 提交于 2019-12-17 15:35:05
问题 If I run Array.apply(null, new Array(1000000)).map(Math.random); on Chrome 33, I get RangeError: Maximum call stack size exceeded Why? 回答1: 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()); } 回答2: Here it fails at Array.apply(null, new Array