Crash Dump Analysis: Dtrace & Systemtap
Crash Dump Analysis: Dtrace & Systemtap
Dynamic Tracing
Safety
Total observability
Probe
Provider
Consumer
31
st
January 2005
27
th
October 2007
2
nd
September 2008
21
st
February 2010
Linux
SystemTap
Linux-native analogy
QNX
Port in progress
3
rd
party software with DTrace probes
Apache
MySQL
PostgreSQL
X.Org
Firefox
Oracle JVM
Similar to C or AWK
Default predicate/action
probe /predicate/ {
actions
}
Crash Dump Analysis MFF UK DTrace 9
D probes
provider:module:function:name
Wild characters *, ?, []
Can be escaped by \
Special probes
Can be absent
Implicitly true
probe /predicate/ {
actions
}
Crash Dump Analysis MFF UK DTrace 13
D actions
List of statements
Separated by semicolon
No branching, no loops
Pointers
Scalar arrays
int values[5][6];
Strings
Structures
Records of several
other types
Type declared in a
similar way as in C
Variables must be
declared explicitly
Members are
accessed via . and ->
operators
struct callinfo {
uint64_t ts;
uint64_t calls;
};
struct callinfo info[string];
syscall::read:entry,
syscall::write:entry {
info[probefunc]ts ! ti"esta"p;
info[probefunc]calls##;
}
$%& {
printf'(read )d )d*n(,
info[(read(]ts,
info[(read(]calls+;
printf'(write )d )d*n(,
info[(write(]ts,
info[(write(]calls+;
}
Crash Dump Analysis MFF UK DTrace 18
D types (4)
Unions
Bit-fields
Enumerations
Typedefs
All similar as in C
Inlines
Typed constants
Arithmetic
+ - * / %
Relational
Logical
&& || ^^ !
Short-circuit evaluation
Bitwise
Assignment
= += -= *= /= %= &= |=
^= <<= >>=
Return values as in C
Increment and
decrement
++ --
Crash Dump Analysis MFF UK DTrace 20
DTrace operators (2)
Conditional expression
Typecasting
Scalar variables
Associative arrays
Thread-local variables
Clause-local variables
The value is kept for multiple clauses associated with the same
probe
syscall::read:entry {
t8is-B;alue ! >;
}
/= $?plicit declaration =/
t8is int ;alue;
syscall::read:entry {
t8is-B;alue ! >;
}
Crash Dump Analysis MFF UK DTrace 25
DTrace aggregations
Aggregation functions
count()
sum(scalar)
avg(scalar)
min(scalar)
max(scalar)
quantize(scalar)
args[]
uintptr_t caller
kthread_t *curthread
string cwd
string execname
trace(expr)
tracemem(address, bytes)
Copy given number of bytes from the given address to the buffer
printf(format, ...)
Safety checks
Crash Dump Analysis MFF UK DTrace 31
Using action statements (2)
printa(aggregation)
printa(format, aggregation)
stack()
stack(frames)
ustack()
ustack(frames)
Addresses are not looked up by the kernel, but by the user space
consumer (later)
Crash Dump Analysis MFF UK DTrace 32
Using action statements (3)
ustack(frames, string_size)
Output user space stack trace with symbol lookup (in kernel)
The kernel allocates string_size bytes for the output of the symbol
lookup
The probe provider must annotate the user space stack with run-
time symbol annotations to make the lookup possible
jstack()
jstack(frames)
jstack(frames, string_size)
Conversion formats
%a
Pointer as kernel
symbol name
%c
ASCII character
%C
Printable ASCII or
escape
%e
Float as [-]d.dddedd
%f
Float as [-]ddd.ddd
%p
Hexadecimal pointer
%s
ASCII string
%S
*alloca(size)
*copyin(addr, size)
Copy size bytes from the user memory of the current process to
scratch memory
*copyinstr(addr)
mutex_owned(*mutex)
*mutex_owner(*mutex)
mutex_type_adaptive(*mutex)
Crash Dump Analysis MFF UK DTrace 36
Subroutines (3)
strlen(string)
strjoin(*str, *str)
basename(*str)
dirname(*str)
cleanpath(*str)
rand()
In a deterministic way
stop()
Stop the current process (e.g. to dump the core or attach mdb)
raise(signal)
panic()
Crash Dump Analysis MFF UK DTrace 38
Destructive actions (2)
system(program, ...)
breakpoint()
chill(nanoseconds)
exit(status)
Exit the tracing session and return the given status to the
consumer
Crash Dump Analysis MFF UK DTrace 40
Speculative tracing
You can tell that you are interested in the data from
a probe n only after probe n+k (k > 0) is fired
speculation()
speculate(id)
commit(id)
In entry
In return
interrupt-start
interrupt-complete
Executing a binary
Exiting a process
Receiving signals
Crash Dump Analysis MFF UK DTrace 48
Provider: sched
Changing of priorities
Thread waking up
Crash Dump Analysis MFF UK DTrace 49
Provider: io
Interval-based probes
Crash Dump Analysis MFF UK DTrace 52
DTrace and mdb
Only in-kernel data which has not yet been processed by an user
space consumer can be displayed
http://docs.sun.com/app/docs/doc/817-6223