From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 7/7] Add dump_stack function
Date: Thu, 26 Jan 2012 14:26:53 +0100 [thread overview]
Message-ID: <1327584413-23055-8-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1327584413-23055-1-git-send-email-s.hauer@pengutronix.de>
At least ARM allows us to dump the stack, but we currently
have no prototype for this. Add a dump_stack prototype and
provide a static inline function for architectures without
stack dump support. Also, call dump_stack() in panic() to
provide more information in the case of a panic.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
arch/arm/cpu/interrupts.c | 5 +++++
arch/arm/include/asm/barebox.h | 39 +++------------------------------------
include/common.h | 9 +++++++++
lib/vsprintf.c | 2 ++
4 files changed, 19 insertions(+), 36 deletions(-)
diff --git a/arch/arm/cpu/interrupts.c b/arch/arm/cpu/interrupts.c
index 3d2077f..c4f9113 100644
--- a/arch/arm/cpu/interrupts.c
+++ b/arch/arm/cpu/interrupts.c
@@ -73,6 +73,11 @@ void show_regs (struct pt_regs *regs)
#endif
}
+void dump_stack(void)
+{
+ unwind_backtrace(NULL);
+}
+
static void __noreturn do_exception(struct pt_regs *pt_regs)
{
show_regs(pt_regs);
diff --git a/arch/arm/include/asm/barebox.h b/arch/arm/include/asm/barebox.h
index c9372da..2b08d68 100644
--- a/arch/arm/include/asm/barebox.h
+++ b/arch/arm/include/asm/barebox.h
@@ -1,41 +1,8 @@
-/*
- * (C) Copyright 2002
- * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
- * Marius Groeger <mgroeger@sysgo.de>
- *
- * (C) Copyright 2002
- * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
- * Alex Zuepke <azu@sysgo.de>
- *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- *
- ********************************************************************
- * NOTE: This header file defines an interface to barebox. Including
- * this (unmodified) header file in another file is considered normal
- * use of barebox, and does *not* fall under the heading of "derived
- * work".
- ********************************************************************
- */
-
#ifndef _BAREBOX_H_
#define _BAREBOX_H_ 1
-//typedef struct bd_info {} bd_t;
+#ifdef CONFIG_ARM_UNWIND
+#define ARCH_HAS_STACK_DUMP
+#endif
#endif /* _BAREBOX_H_ */
diff --git a/include/common.h b/include/common.h
index 2f37dd8..74a697d 100644
--- a/include/common.h
+++ b/include/common.h
@@ -119,6 +119,15 @@ uint32_t crc32_no_comp(uint32_t, const void*, unsigned int);
/* common/console.c */
int ctrlc (void);
+#ifdef ARCH_HAS_STACK_DUMP
+void dump_stack(void);
+#else
+static inline void dump_stack(void)
+{
+ printf("no stack data available\n");
+}
+#endif
+
#define MEMAREA_SIZE_SPECIFIED 1
struct memarea_info {
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 4165f97..9763515 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -625,6 +625,8 @@ void __noreturn panic(const char *fmt, ...)
putchar('\n');
va_end(args);
+ dump_stack();
+
led_trigger(LED_TRIGGER_PANIC, TRIGGER_ENABLE);
#if defined (CONFIG_PANIC_HANG)
--
1.7.8.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
prev parent reply other threads:[~2012-01-26 13:27 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-26 13:26 some debug patches Sascha Hauer
2012-01-26 13:26 ` [PATCH 1/7] console: remove unused function prototypes Sascha Hauer
2012-01-26 13:26 ` [PATCH 2/7] kfifo: change kfifo_init to work with a preallocated fifo Sascha Hauer
2012-01-26 13:26 ` [PATCH 3/7] console: make it work without malloc Sascha Hauer
2012-01-26 13:26 ` [PATCH 4/7] ARM: panic on div 0 Sascha Hauer
2012-01-26 13:26 ` [PATCH 5/7] initcalls: do not hang if an initcall fails Sascha Hauer
2012-01-26 13:26 ` [PATCH 6/7] startup: use regular debug statements in initcall debugging Sascha Hauer
2012-01-26 13:26 ` Sascha Hauer [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1327584413-23055-8-git-send-email-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox