1#! /bin/sh
2
3# filter the output of gdb.
4
5dir=`dirname $0`
6
7$dir/filter_stderr                                                  |
8
9# Anonymise addresses
10$dir/../tests/filter_addresses                                      |
11
12# memcheck stuff
13$dir/filter_memcheck_monitor                                        |
14
15
16# Anonymise or remove :
17#       delete the initial lines between the launch of vgdb and the
18#         output of the echo command telling it is launched.
19#         This removes a whole lot of uninteresting lines varying
20#         with OS/glibc/gdb dep
21#       initial tty control character sent by gdb 7.0
22#       remove missing debuginfos
23#       vgdb message
24#       pid numbers
25#       Thread numbers
26#       delete thread switches
27#       info threads output (e.g. which thread is running and syscall)
28#       delete Reading symbols file lines
29#       delete Loaded symbols file lines
30#       delete language switch messages.
31#       remove gdb prompts.
32#       remove gdb continuation prompts.
33#       remove gdb done prompts.
34#       a 'general' system calls stack trace part
35#       a more specialised system call select stack trace part
36#             (on 32 bits, we have an int_80, on 64 bits, directly select)
37#       and yet another (gdb 7.0 way) to get a system call
38#       and yet another (gdb 7.0 arm way) to get a system call
39#       and cleanup some lines for a system call (on ubuntu 10 64 bits)
40#           (pay attention : there are tab characters there in)
41#           + yet another way to get a select system call
42#       which registers can't be modified
43#       special transform for arm/ppc watchpoints which have an additional address
44#              at the beginning
45#       SIGFPE backtrace is varying so much that we just remove all lines
46#       after the signal trapping using an expr in this sed, followed by another sed.
47#       transform info thread of 7.3 into the layout of 7.2 and before.
48#       delete lines telling that some memory can't be accessed: this is
49#         a.o. produced by gdb 7.2 on arm (same with standard gdbserver)
50#       delete empty lines (the last line (only made of prompts) sometimes
51#           finishes with a new line, sometimes not ???).
52sed -e '/Remote debugging using/,/vgdb launched process attached/d'                                   \
53    -e 's/^\[?1034hReading symbols/Reading symbols/'                                                \
54    -e '/^Missing separate debuginfo/d'                                                               \
55    -e '/^Try: zypper install -C/d'                                                                   \
56    -e 's/\(relaying data between gdb and process \)[0-9][0-9]*/\1..../'                              \
57    -e 's/pid [0-9][0-9]*/pid ..../g'                                                                 \
58    -e 's/Thread [0-9][0-9]*/Thread ..../g'                                                           \
59    -e '/\[Switching to Thread ....\]/d'                                                              \
60    -e 's/\(\[Switching to thread [1234] (Thread ....)\]\)#0/\1\n#0/'                                 \
61    -e 's/^\([ \* ] [0-9] Thread .... (tid [0-9] VgTs_WaitSys)  0x........ in\).*$/\1 syscall .../'   \
62    -e 's/#[0-9]\(  0x........ in sleeper_or_burner\)/#.\1/'                                          \
63    -e '/^Reading symbols from .*\.\.\.done\./d'                                                      \
64    -e '/^Loaded symbols for .*$/d'                                                                   \
65    -e '/^Current language.*/d'                                                                       \
66    -e '/^The current source language is.*/d'                                                         \
67    -e 's/(gdb) //g'                                                                                  \
68    -e 's/^>[> ]*//'                                                                                  \
69    -e '/^done\.$/d'                                                                                  \
70    -e 's/in _dl_sysinfo_int80 () from \/lib\/ld-linux.so.*/in syscall .../'                          \
71    -e 's/in kill ().*$/in syscall .../'                                                              \
72    -e 's/in .*kill ().*$/in syscall .../'                                                            \
73    -e 's/in _dl_sysinfo_int80 ()/in syscall .../'                                                    \
74    -e '/^   from \/lib\/ld-linux.so.*$/d'                                                            \
75    -e 's/\(0x........\) in ?? () from \/lib.*$/\1 in syscall .../'                                   \
76    -e 's/\(0x........\) in ?? ()$/\1 in syscall .../'                                                \
77    -e 's/in \(.__\)\{0,1\}select () from \/.*$/in syscall .../'                                      \
78    -e '/^   from \/lib\/libc.so.*$/d'                                                                \
79    -e '/^   from \/lib64\/libc.so.*$/d'                                                              \
80    -e '/^   from \/lib64\/.*\/libc.so.*$/d'                                                         \
81    -e 's/in select ()$/in syscall .../'                                                              \
82    -e 's/in \.__select ()$/in syscall .../'                                                          \
83    -e 's/in select () at \.\.\/sysdeps\/unix\/syscall-template\.S.*$/in syscall .../'                \
84    -e '/^[ 	]*at \.\.\/sysdeps\/unix\/syscall-template\.S/d'                                      \
85    -e '/^[ 	]*in \.\.\/sysdeps\/unix\/syscall-template\.S/d'                                      \
86    -e '/^[1-9][0-9]*[ 	]*\.\.\/sysdeps\/unix\/syscall-template\.S/d'                                 \
87    -e '/^[1-9][0-9]*[ 	]in *\.\.\/sysdeps\/unix\/syscall-template\.S/d'                              \
88    -e 's/\(Could not write register \)".*"/\1 "xxx"/'                                                \
89    -e 's/\(ERROR changing register \).*$/\1 xxx regno y/'                                            \
90    -e 's/0x........ in \(main (argc=1, argv=0x........) at watchpoints.c:[24][3689]\)/\1/'           \
91    -e 's/0x........ in \(main () at clean_after_fork.c:34\)/\1/'                                     \
92    -e 's/\(^.*signal SIGFPE.*$\)/\1\nafter trap SIGFPE/'                                             \
93    -e '/Id   Target Id         Frame/d'                                                              \
94    -e 's/^\([ \*] [1234] \) *Thread /\1Thread /'                                                     \
95    -e 's/VgTs_WaitSys) 0x/VgTs_WaitSys)  0x/'                                                        \
96    -e '/Cannot access memory at address 0x......../d'                                                \
97    -e '/^$/d'                                                                                        |
98
99# remove all the lines telling where the SIGFPE was trapped.
100sed -e '/after trap SIGFPE/,/after continue SIGFPE/d'                                                 |
101
102# join together two lines that gdb 7.1 splits in two (???)
103# (in a separate sed, as the below influences the behaviour of the other expressions)
104sed    -e :a -e '$!N;s/\n    at sleepers.c:39/ at sleepers.c:39/;ta' -e 'P;D' 
105
106