coretrace
Introduction
Coretrace is a lightweight tool for debugging of embedded Linux applications.
It works by analysing core files from crashed applications and outputs a short
plain-text backtrace, suitable for putting into logfiles.
The basic idea is to let the failing unit do self analysis of core files. When
your remote application crashes it would of course be nice if one could get
the whole core home to do some real debugging with e.g. gdb, but unfortunately
this is not an option for many embedded systems. Your upstream bandwidth might
be to limited, the central management software may perhaps don't support binary
data or the customer might simply not like passing files from his network around
the globe. In any of these cases coretrace will probably be a "good enough" tradeoff.
It's not a tool used in the early development stage but rather in maintenance.
Being a utility in production systems it can be used for long term stability tests or
tracking down rare crashes.
Non-interactive small-sized embedded systems is the primary target, thus small
footprint is of major concern, it will be stored on flash. Currently the compiled
size is approximately 20 kb.
Basic usage
-
A simple backtrace:
$ coretrace -e myapp -c core
-
Insert the trace into syslog with a pipe:
$ coretrace -e myapp -c core | logger
-
How to check for crashes and launch your application in one stroke:
$ [ -f core ] && \
coretrace -e myapp -c core >crash.log; \
rm -f core; \
./myapp
Your application can then easily read the logfile
(/tmp/crash.log) and alert an operator.
Screenshot, read explanation of the output in
tips below.
Automatic usage
Kernel v2.6.19 and later can be configured to invoke a core file analyzer
automaticaly when a crash occur. There is no need to actually write
the core file to disk any more, instead one can have it piped to the
standard input of coretrace in real-time and have the resulting backtrace
end up in the syslog. Read core(5) and "Piping core dumps to a
program" for additional information.
Note: you need to execute
these commands as the root user.
Supported platforms
Runs on
x86,
x86-64 (AMD64),
ARM,
PowerPC and
Etrax (cris)
Linux systems.
Requirements
-
Compile your application with framepointers enabled! These general
CFLAGS are recommended in your
Makefile:
CFLAGS += -g -fno-omit-frame-pointer -fno-optimize-sibling-calls
CFLAGS += -fno-strict-aliasing -fno-crossjumping
CFLAGS += -falign-functions
The enabled debuging has a price though, performance of you app may
(very) slightly decrease.
-
For the x86 and x86-64 architectures this additional CFLAG
is nice too:
CFLAGS += -mno-omit-leaf-frame-pointer
-
For the ARM architecture these additional CFLAGS
are nice too:
CFLAGS += -fno-short-enums -mapcs-frame -mno-sched-prolog
-
For the PowerPC architecture these additional CFLAGS
are nice too:
CFLAGS += -mcpu=powerpc -m32 -meabi
-
For the CRISv10 architecture these additional CFLAGS
are nice too:
CFLAGS += -m32bit -mstack-align -mlinux
-
Your target system must use ELF binaries as default
(most Linux systems do).
Downloads
Get your copy here
Building
-
For the x86 and x86-64 support, unpack the archive and run:
$ tar -xvzf coretrace.tar.gz
$ make
-
For the ARM support one must first give some arguments since there
are many different names and flavors of cross-gcc's. An example of
cross building for recent
Debian ARM-ports:
$ tar -xvzf coretrace.tar.gz
$ make CC=arm-none-linux-gnueabi-gcc coretrace-arm
-
For the PowerPC support one must first give some arguments since there
are many different names and flavors of cross-gcc's. An example of building
for MPC8xx:
$ tar -xvzf coretrace.tar.gz
$ make CC=powerpc-860-linux-gnu-gcc coretrace-ppc
-
For the Cris support, unpack the archive and run:
$ tar -xvzf coretrace.tar.gz
$ make coretrace-cris
-
There is no "make install"
target since this is way to dependant upon your particular
embedded system. You need to copy coretrace-xxx into
/usr/bin yourself.
License
coretrace is
GPL.
Authors
Tips
Bugs / known issues
Help is appreciated
-
Debug of x86 applications doesn't work when built for x86-64.
-
Signal trampolines ain't handled yet.
-
To simple build/makefile. Could easily fail.
-
Only C source code compiled with gcc has been tested enough.
Todo
Help is appreciated
-
Thread support. Even though this ain't frequently used in
embedded systems it would be nice.
-
Better C++ support by adding parsing of DWARF2 stack
unwind runtime information.