I'm using XE8 with the latest madExcept. I want to get a stack trace of the current thread, and post it to a log file (I want to see the call stack of how I got to this particular place in the code). This is not during an exception condition. I followed other posts here, and called madStackTrace.StackTrace, but it just returns '00000000 ???'. I've even traced through the call but could not tease out why I only get a 'blank' stack trace.
I've also tried madExcept.GetThreadStackTrace( GetCurrentThreadId ), but this returns a blank string. Hmm.
I'm sure I'm missing something basic, but thought I'd see if anyone can set me straight?
Cheers,
Wayne
StackTrace only returns '00000000 ???'
Re: StackTrace only returns '00000000 ???'
Are we talking about x86 or x64?
-
- Posts: 3
- Joined: Thu Dec 26, 2013 8:30 pm
Re: StackTrace only returns '00000000 ???'
I'm x64, Windows 8.1.
Re: StackTrace only returns '00000000 ???'
Sorry, should have been clearer. I mean the bitdepth of your exe, not the bitdepth of the OS.
Unfortunately the x64 stack trace win32 API which madExcept uses often produces 00000000 when trying to capture the stack trace of the current thread, if you do this outside of a try..except block. One ugly workaround is this:
http://help.madshi.net/madExceptUnit.ht ... StackTrace
Unfortunately the x64 stack trace win32 API which madExcept uses often produces 00000000 when trying to capture the stack trace of the current thread, if you do this outside of a try..except block. One ugly workaround is this:
Code: Select all
try
raise Exception.Create('Dummy');
except
stackTraceStr := GetCrashStackTrace(...);
end;
-
- Posts: 3
- Joined: Thu Dec 26, 2013 8:30 pm
Re: StackTrace only returns '00000000 ???'
Yes, I am compiling a 64 bit app AND running in 64 bit 8.1.
I tried your example and it works; I now get a stack trace that was what I was expecting. This might be a bit expensive in time, but that is another matter I will consider. Thanks for the quick reply! We love madshi here in Tucson!
Cheers,
Wayne
I tried your example and it works; I now get a stack trace that was what I was expecting. This might be a bit expensive in time, but that is another matter I will consider. Thanks for the quick reply! We love madshi here in Tucson!
Cheers,
Wayne
Re: StackTrace only returns '00000000 ???'
Glad to hear that!
In theory performance should not be a problem. Raising and handling an exception in a try..except block should be very fast. The calculation of the callstack will consume much more time than the exception handling. However, the one annoying thing is that when you run in the IDE, the debugger will probably complain about each exception and stop on it. So you could try something like "if IsDebuggerPresent" to only raise the dummy exception when running outside a debugger.
In theory performance should not be a problem. Raising and handling an exception in a try..except block should be very fast. The calculation of the callstack will consume much more time than the exception handling. However, the one annoying thing is that when you run in the IDE, the debugger will probably complain about each exception and stop on it. So you could try something like "if IsDebuggerPresent" to only raise the dummy exception when running outside a debugger.