Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
By Mark F. Brown
<mark.brown314@gmail.com>
CC BY-SA
[1]
Preparation
You will need an x86 Linux machine
You will need developer tools
binutils: objdump, readelf, nm
gdb
gcc
I will be going through all of these
examples live.
Presentation is located here:
goo.gl/Ocyrk
What is the Core?
Core is an archaic name for memory
Magnetic-core memory was an early
form of random access memory
The term core comes from
conventional transformers whose
windings surround a magnetic core
[2]
Superseded by semiconductor memory
Not to be mixed-up with Processors
(Cores)
What is a Core Dump?
Core dump is a recorded state of the
working memory of a process image
Process state snapshot is also stored
Stored in a standard binary format
e.g.
ELF in Linux (We will cover this platform on
x86)
Macho in Mac OS X
Why Should I Care?
Cross architecture and cross platform
debugging technique
Great way to obtain postmortem
information from customers! :-)
Good way for OSS developers to get
postmortem information from users.
It is hardcore!
How To Trigger a Core Dump
Process level core dumps are triggered
via a dumpable signal (asynchronous
notication).
Terminal control character
Trigger them via kill(2)
Erroneous behavior which triggers a
dumpable signal.
Example dumpable signals
SIGILL (illegal instruction)
SIGQUIT (keyboard quit)
SIGSEGV (invalid memory reference)
SIGABT/SIGIOT (abnormal process termination
via: abort(3))
Congure the Environment
To enable core dumps you need to
congure the proper resource limits.
hard limit can be increased only by root.
hard limit can be decreased by any user.
soft limit can be set to less then or equal
hard limit by any user.
ulimit (sh/bash) manages user resource
limits
Congure user/resource limit core
size:
# ulimit -S -c unlimited
# ulimit -S -c <size in kilobytes>
Lets Try Generating a Core
1. # ulimit -S -c unlimited
2. # sleep 3000
3. Press Control + Backslash (^\)
4. Terminal will state:
^\Quit (core dumped)
5. # ls core* (mileage may vary based on distribution
settings)
6. # le <core le>
Lets Generate a Core Dump
Programmatically
Download le simple_abort.tar.bz at
http://goo.gl/1tSgz
getrlimit(2) gets resource limit
setrlimit(2) sets resource limit
RLIMIT_CORE points to core dumps
struct rlimit contains both the hard and
soft limits
e.g. setrlimit(RLIMIT_CORE, &limit);
Typical User Space Memory
Layout (32-bit x86)
Examining Live Maps*
cat /proc/<PID>/maps
From my x86 machine:
007e6000-00801000 r-xp 00000000 08:06 261396 /lib/ld-2.11.1.so
00801000-00802000 r--p 0001a000 08:06 261396 /lib/ld-2.11.1.so
00802000-00803000 rw-p 0001b000 08:06 261396 /lib/ld-2.11.1.so
00c99000-00c9a000 r-xp 00000000 00:00 0 [vdso]
00cee000-00e41000 r-xp 00000000 08:06 389813 /lib/libc-2.11.1.so
00e41000-00e42000 ---p 00153000 08:06 389813 /lib/libc-2.11.1.so
00e42000-00e44000 r--p 00153000 08:06 389813 /lib/libc-2.11.1.so
00e44000-00e45000 rw-p 00155000 08:06 389813 /lib/libc-2.11.1.so
00e45000-00e48000 rw-p 00000000 00:00 0
08048000-0804f000 r-xp 00000000 08:06 142 /bin/sleep
0804f000-08050000 r--p 00006000 08:06 142 /bin/sleep
08050000-08051000 rw-p 00007000 08:06 142 /bin/sleep
097c3000-097e4000 rw-p 00000000 00:00 0 [heap]