* [ECOS] Fwd: How to dump the stack to serial without running GDB?
[not found] ` <CAOFa9c0Mryq0yL9gwZQkRLMGQ=Sibs9FCbC0T31vvWddKYqraw@mail.gmail.com>
@ 2013-05-09 7:19 ` Elad Yosef
2013-05-09 11:16 ` Gunnar Ruthenberg
0 siblings, 1 reply; 2+ messages in thread
From: Elad Yosef @ 2013-05-09 7:19 UTC (permalink / raw)
To: eCos Discussion, ecos-discuss
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.
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [ECOS] Fwd: How to dump the stack to serial without running GDB?
2013-05-09 7:19 ` [ECOS] Fwd: How to dump the stack to serial without running GDB? Elad Yosef
@ 2013-05-09 11:16 ` Gunnar Ruthenberg
0 siblings, 0 replies; 2+ messages in thread
From: Gunnar Ruthenberg @ 2013-05-09 11:16 UTC (permalink / raw)
To: ecos-discuss, ecos-discuss; +Cc: Elad Yosef
Hi,
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
ecos/packages/kernel/current/src/common/except.cxx.
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
non-trivial with
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
debugging
information. Changing it to decide at run-time between printing or
handling GDB
should be fairly simple.
Note that during the product's life cycle, i also added
core-dump/stack-trace
like features in places other than handling CPU exceptions, to ease
debugging.
This includes allocation failures, assertions, and watchdog warnings, which
would report the current thread and a trace shortly before an impending
watchdog
time-out reset (but keep running the program, as it might service the
watchdog
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,
whose
handler may be called from ISR/DSR limbo rather than an actual thread
context.)
Regards
gunnar.
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.
>
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-05-09 11:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <CAOFa9c3C+Fy53Nv-BPLR+dKype6RLsQ0v9iakfe=fbae=XZGiw@mail.gmail.com>
[not found] ` <CAOFa9c0Mryq0yL9gwZQkRLMGQ=Sibs9FCbC0T31vvWddKYqraw@mail.gmail.com>
2013-05-09 7:19 ` [ECOS] Fwd: How to dump the stack to serial without running GDB? Elad Yosef
2013-05-09 11:16 ` Gunnar Ruthenberg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).