Add instructions for stable branch pullups
[openafs-wiki.git] / debugging.mdwn
1 ## Debugging Servers
2
3 Servers are multithreaded, so if one hangs, it is most interesting to see what the different threads are doing. Using gdb, you can get a stack trace of all threads (provided, you compiled your server with "--enable-debug").
4
5 First, we need to get the pid and the full path of the server (e.g. fileserver):
6
7     PID=`ps -eaf | grep fileserver | grep -v grep | awk '{print $2}'`
8     SRV_PATH=`ps -eaf | grep fileserver | grep -v grep | awk '{print $9}'`
9
10 for other servers, this might be different, so double-check
11
12
13 Then we need to attach the gdb and make it display the stack of all threads :
14     
15     gdb --batch --eval-command="thread apply all where" $SRV_PATH $PID > /tmp/threads.log
16
17 After this you might use the attached script [[threadLogParser.py]] to display the intersting threads.
18
19 e.g.
20
21     threadLogParser.py -g /tmp/threads.log -e rx_GetCall
22
23 displays only threads which are not in this boring rx_GetCall (threads are waiting for a new call).
24
25
26 ## Debugging Clients
27
28 ### unix client tracing with fstrace
29
30 Low-level debugging of a client can be done using "fstrace".  The analysis of
31 the "fstrace" output requires detailed knowledge of cache manager internals.
32 "fstrace" logs to an internal memory based ring buffer, which can be dumped to
33 a file for analysis.
34
35 To capture a trace, set the ring buffer size, enable the tracing to the buffer,
36 run your tests, then dump the buffer. The following example creates a 1 Mb buffer:
37
38     fstrace setlog -buffersize 1024
39     fstrace setset -active
40     fstrace clear
41
42     -- do your tests --
43
44     fstrace dump -file /tmp/fstrace.out
45
46
47 To disable the tracing when you are done:
48
49     fstrace setset -inactive
50
51
52 ### intermittent issues
53
54 Unfortunately, "fstrace" produces a lot of output, so it is may not be easy to catch an intermittent error-condition.
55
56 The attached script [[ClientTracing.py]] (presently for Unix only) gives you the opportunity to continuously run a fstrace, <br/>
57 where the output is stored in rotating log-files. 
58
59 In case of an external-event (the existence of a predefined file), it saves this log and does not overwrite it again.
60 Thus, all you need to do is to write a script which creates this predefined file, when that event happens.
61
62
63 ### defined issue
64
65 When you exactly know how to reproduce the issue, or you don't want to install python on your client, you can use the attached script [[ClientTracing.bat]] (for Windows only). It is setting up the client tracing, starting up a tshark (terminal-version of wireshark) and waits for you to tell it to stop tracing. In order to synchronize the timestamps of the wireshark log and the afsd-trace-log, a "dir \\\\AFS\grand.central.org" is issued on startup. The logfiles are copied to a predefined directory. The script itself should be self-explanatory.]