StackTrace only returns '00000000 ???'

delphi package - automated exception handling
Post Reply
wshowalter
Posts: 3
Joined: Thu Dec 26, 2013 8:30 pm

StackTrace only returns '00000000 ???'

Post by wshowalter »

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
madshi
Site Admin
Posts: 10753
Joined: Sun Mar 21, 2004 5:25 pm

Re: StackTrace only returns '00000000 ???'

Post by madshi »

Are we talking about x86 or x64?
wshowalter
Posts: 3
Joined: Thu Dec 26, 2013 8:30 pm

Re: StackTrace only returns '00000000 ???'

Post by wshowalter »

I'm x64, Windows 8.1.
madshi
Site Admin
Posts: 10753
Joined: Sun Mar 21, 2004 5:25 pm

Re: StackTrace only returns '00000000 ???'

Post by madshi »

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:

Code: Select all

try
  raise Exception.Create('Dummy');
except
  stackTraceStr := GetCrashStackTrace(...);
end;
http://help.madshi.net/madExceptUnit.ht ... StackTrace
wshowalter
Posts: 3
Joined: Thu Dec 26, 2013 8:30 pm

Re: StackTrace only returns '00000000 ???'

Post by wshowalter »

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
madshi
Site Admin
Posts: 10753
Joined: Sun Mar 21, 2004 5:25 pm

Re: StackTrace only returns '00000000 ???'

Post by madshi »

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.
Post Reply