Re: Fwd: How to dump the stack to serial without running GDB?
yes, that is perfectly possible.
I implemented this for a Coldfire/m68k system in eCos v2_0_40, but it should
be fairly similar for your target platform and a current eCos.
In the following description, i will refer to m68k.
In ecos/packages/hal/m68k/arch/current/src/hal_m68k.c, there is the function
"void hal_m68k_exception_handler(HAL_SavedRegisters* regs)".
With the right options enabled (or a little hack), it will stop there, or,
with a kernel, call cyg_hal_deliver_exception() in
This in turn calls Cyg_Thread::deliver_exception() in
ecos/packages/kernel/current/src/common/thread.cxx, which would call
Cyg_Exception_Control::deliver_exception() back in except.cxx.
There, simply extend cyg_null_exception_handler() to print all the debugging
information desired, including the saved registers, a few stack bytes, and a
call trace. The cleaner way is to register a handler doing that for all
(or all relevant) exceptions.
Hopping through the stack to follow the function calls may be
various pitfalls to be avoided, so do add many plausibility and memory range
checks there to prevent from exceptions on exceptions.
The above approach replaces GDB handling with a console printout of
information. Changing it to decide at run-time between printing or
should be fairly simple.
Note that during the product's life cycle, i also added
like features in places other than handling CPU exceptions, to ease
This includes allocation failures, assertions, and watchdog warnings, which
would report the current thread and a trace shortly before an impending
time-out reset (but keep running the program, as it might service the
just in the nick of time).
(Also note that the latter included a few fundamental changes in the context
switching logics, as the watchdog warning was implemented using a timer,
handler may be called from ISR/DSR limbo rather than an actual thread
On 2013-05-09 09:19, Elad Yosef wrote:
> Hi all,
> I want to implement back-trace that will dump the stack into console
> when exception occurs.
> The GDB stub is in the RedBoot and I can't run the GDB all the time in
> all systems.
> Is there a way to dump the stack (linux like back-trace) with having
> the GDB connected?
> Sub-contractors that are willing to take the challenge are welcomed.