On Dec 20, 2012, at 8:08 AM, "Pollo, Luis Fernando" <luis.po...@hp.com> wrote:
> Is there a (simple) way to print a call stack trace as part of debug output
> (particularly when an ASSERT is triggered)?
>
The generic answer is no. It is very compiler specific, and can even be
optimization level specific. For example with Visual Studio and X64 you need
the debug information, and thus a debugger, to unwind the stack. For clang and
X64 it is possible to unwind the stack in C code.
> Any other debugging techniques you would recommend, assuming no availability
> of either a processor probe or the serial/USB debug agent in the firmware to
> use a software debugger?
>
You may be able to use __builtin_return_address() and __builtin_frame_address()
to extract some useful information, but it is compiler specific as to how much
info is available. You usually always have access to
__builtin_return_address(0) and __builtin_frame_address(0), but it is compiler
specific if you can extract more info. So this is something you could
investigate with your compiler. You can also Bing/Google about these builtins
to get more context.
So for example if you are getting the ASSERT() in a library function you can
get the callers address. From doing some profiling work with backtraces I can
tell you that about 4 deep usually gets you out of almost all the libraries
back into the calling module. If you can't get more than
__builtin_return_address(0) to work you may have to instrument intermediate
calls in the libraries to print out __builtin_return_address(0), so when you
hit the ASSERT() you can see the stack backtrace. This assumes you have a
specific ASSERT() you are debugging, and you can insert debug code to debug
that ASSERT().
Thanks,
Andrew Fish
> Thanks,
>
> Luis F. Pollo
> Brazil R&D - PCL
> +55 51 2121 3864
>
> ------------------------------------------------------------------------------
> LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
> Remotely access PCs and mobile devices and provide instant support
> Improve your efficiency, and focus on delivering more value-add services
> Discover what IT Professionals Know. Rescue delivers
> http://p.sf.net/sfu/logmein_12329d2d_______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/edk2-devel
------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel