arm Posted December 3, 2003 Posted December 3, 2003 I would like to have the possibility to trace with the normal stack dump the actual values of the parameters? Does anybody know how to get them from stack ? In detail: with stackTrace.GetFrame(frameCount); and stackFrame.GetMethod(); I can get the called methods on stack and with reflection the type and count of the parameters but i can see no way to get the actual value of each parameter which would help a lot in a log-file in case of an exception! Quote
RickAtKnowWare Posted March 3, 2006 Posted March 3, 2006 I'm trying to do this too. Did you ever find a way to do it? Quote
*Experts* Nerseus Posted March 3, 2006 *Experts* Posted March 3, 2006 You can see the parameter values in VS. In the Call Stack, double click on the line you want and then you can examine the values from the context of that call. For example, look at this C# program: static void Test2(int i) { Debug.WriteLine(i); } static void Test(int i) { i++; Test2(i); } [sTAThread] static void Main() { int i = 5; Test(i); } Set a breakpoint on the line "Debug.WriteLine...". If you look at i, it shows 6. In the callstack, find the line and double click it: Test.exe!Class1.Main() Line 34 Now if you examine i, you'll see it's still 5. It's showing you that it passed 5 to the function Test. The key is the double click in the Call Stack, which sets context to that line of code. -ner Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
arm Posted March 4, 2006 Author Posted March 4, 2006 My problem is not to see the values in the debugger but to write them in a log-file while program is running! Quote
mskeel Posted March 4, 2006 Posted March 4, 2006 I know when you catch an exception there are a lot of options as far as the data you can extract from an exception. The stack trace is one of them but there might be more. You can pragmatically log that information from your catch block. MSDN on Exception. Hopefully that helps. Quote
Leaders snarfblam Posted March 4, 2006 Leaders Posted March 4, 2006 VS can do it, but it does it through the runtime environment, which your code can't directly manipulate. The Exception class has a private variable named _stackTrace which contains raw binary data, but I couldn't decipher it or find any info about it. From the look of things, this probably isn't a very simple task, to say the least. Quote [sIGPIC]e[/sIGPIC]
mskeel Posted March 6, 2006 Posted March 6, 2006 It's been a while since I've had to do this, but I used to use core dumps (which held a stack trace in them) in conjuction with a debugger to get that sort of informaiton. Granted this was with gcc and it seems that the JIT Debugger stops core dumps from ever happening, but perhaps you can force it and use the VS debugger to decipher the binary? This isn't a fancy solution but what about just logging the values yourself? Function Super(String arg1) { Try { DoStuff() } Catch (exception) { Log(exception.StackTrace) Log(exception.Message) Log(arg1) } }Of course, that won't work if you don't have access to the code. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.