From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18876 invoked by alias); 9 May 2013 11:16:08 -0000 Mailing-List: contact ecos-discuss-help@ecos.sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: ecos-discuss-owner@ecos.sourceware.org Received: (qmail 18864 invoked by uid 89); 9 May 2013 11:16:07 -0000 X-Spam-SWARE-Status: No, score=-4.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM,KHOP_THREADED,RCVD_IN_DNSWL_NONE,RCVD_IN_HOSTKARMA_NO,RCVD_IN_HOSTKARMA_YE,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.1 Received: from mout.gmx.net (HELO mout.gmx.net) (212.227.17.22) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Thu, 09 May 2013 11:16:06 +0000 Received: from mailout-de.gmx.net ([10.1.76.33]) by mrigmx.server.lan (mrigmx002) with ESMTP (Nemesis) id 0MDjZQ-1Um0T60U7K-00H9df for ; Thu, 09 May 2013 13:16:02 +0200 Received: (qmail invoked by alias); 09 May 2013 11:16:01 -0000 Received: from cable-158-181-67-186.cust.telecolumbus.net (EHLO [192.168.0.100]) [158.181.67.186] by mail.gmx.net (mp033) with SMTP; 09 May 2013 13:16:01 +0200 Message-ID: <518B8573.9030109@gmx.net> Date: Thu, 09 May 2013 11:16:00 -0000 From: Gunnar Ruthenberg User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: ecos-discuss@ecos.sourceware.org, ecos-discuss@sources.redhat.com CC: Elad Yosef References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [ECOS] Fwd: How to dump the stack to serial without running GDB? X-SW-Source: 2013-05/txt/msg00012.txt.bz2 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