'grail' fixes for arm32:
[valgrind.git] / gdbserver_tests / filter_gdb
blob204c0fc04821e1cb3e37e817187597519f5c6b19
1 #! /bin/sh
3 # filter the output of gdb.
5 PATTERNFILE=$(mktemp filter_gdb.tmp.XXXXXXXXXX)
6 cat > $PATTERNFILE <<EOF
7 # delete the initial lines between the launch of vgdb and the
8 # output of the echo command telling it is launched.
9 # This removes a whole lot of uninteresting lines varying
10 # with OS/glibc/gdb dep
11 /Remote debugging using/,/vgdb launched process attached/d
13 # general way to delete uninteresting and varying lines.
14 /filter_gdb BEGIN drop/,/filter_gdb END drop/d
16 # initial tty control character sent by gdb 7.0
17 s/^\e\[?1034hReading symbols/Reading symbols/
19 # remove message about missing debuginfos
20 /^Missing separate debuginfo/d
22 # suppress lines telling file _exit.c does not exist
23 /\/_exit.c: No such file or directory/d
25 # Remove some Suse package manager messages
26 /^Try: zypper install -C/d
28 # Remove vgdb message
29 /relaying data between gdb and process/d
31 # Anonymise pid numbers
32 s/pid [0-9][0-9]*/pid ..../g
34 # filter 'remote target killed' messages (produced by gdb >= 8.2)
35 /(Remote target) killed/d
37 # Anonymise Thread numbers
38 s/Thread [0-9][0-9]*/Thread ..../g
40 # delete thread switches
41 /\[Switching to Thread ....\]/d
43 # ??? Probably we had a 'Switching ' message in front of
44 # a frame line ?
45 s/\(\[Switching to thread [1234] (Thread ....)\]\)#0/\1\n#0/
47 # Anonymise info threads output (e.g. which thread is running and syscall)
48 s/^\([ \* ] [0-9] Thread .... (tid [0-9] VgTs_WaitSys) 0x........ in\).*$/\1 syscall .../
50 # Newer gdb say Thread .... hit Breakpoint, we expect just Breakpoint.
51 s/^Thread .... hit Breakpoint /Breakpoint /
53 # We expect "Program received" instead of "Thread .... received"
54 s/^Thread .... received /Program received /
56 s/#[0-9]\( 0x........ in sleeper_or_burner\)/#.\1/
58 # Some gdb versions don't show the source line:number after switching
59 # threads in #0 0x........ in do_burn ().
60 s/\(#0 0x........ in do_burn ()\) at sleepers.c:41/\1/
63 # delete Reading symbols file lines
64 # Note: The 'done.' in "Reading symbols from <exe>...done."
65 # is optional (bugzilla 406357).
66 /^Reading symbols from .*\.\.\.\(done\.\)\?/d
68 # delete Loaded symbols file lines
69 /^Loaded symbols for .*$/d
71 # delete language switch messages.
72 /^Current language.*/d
73 /^The current source language is.*/d
75 # 'exited with code' and 'exited normally' are printed slightly
76 # differently between gdb versions, normalize to "Program exited...".
77 s/^.*\( exited with code [0-9]\+\).$/Program\1\./g
78 s/^.*\( exited normally\).$/Program\1\./g
80 # remove gdb prompts.
81 s/(gdb) //g
83 # remove gdb continuation prompts.
84 s/^>[> ]*//
86 # remove gdb done prompts.
87 /^done\.$/d
89 # anonymise a 'general' system calls stack trace part
90 s/in _dl_sysinfo_int80 () from \/lib\/ld-linux.so.*/in syscall .../
92 # anonymise kill syscall.
93 s/in kill ().*$/in syscall .../
95 # anonymise syscall on ppc64 (bugzilla #284305)
96 s/in .*kill ().*$/in syscall .../
99 s/in _dl_sysinfo_int80 ()/in syscall .../
100 /^ from \/lib\/ld-linux.so.*$/d
101 s/\(0x........\) in ?? () from \/lib.*$/\1 in syscall .../
102 s/\(0x........\) in ?? ()$/\1 in syscall .../
104 # 4 expressions to cover glibc 2.27 way to do a select, such as
105 # * 1 Thread 5548 (tid 1 VgTs_WaitSys) 0x0000000004f6203f in __GI___select (
106 # nfds=0, readfds=0x0, writefds=0x0, exceptfds=0x0, timeout=0x30a0e0 <t>)
107 # at ../sysdeps/unix/sysv/linux/select.c:41
108 # If select.c sources are present, we can also get a line containing:
109 # return SYSCALL_CANCEL....
110 s/in __select .*/in syscall .../
111 /exceptfds/d
112 /sysv\/linux\/select\.c/d
113 /return SYSCALL_CANCEL /d
115 # a more specialised system call select stack trace part
116 # (on 32 bits, we have an int_80, on 64 bits, directly select)
117 s/in \(.__\)\{0,1\}select () from \/.*$/in syscall .../
119 /^ from \/lib\/libc.so.*$/d
120 /^ from \/lib64\/libc.so.*$/d
121 /^ from \/lib64\/.*\/libc.so.*$/d
123 # and yet another (gdb 7.0 way) to get a system call
124 s/in select ()$/in syscall .../
126 # and yet another (gdb 7.0 arm way) to get a system call
127 s/in \.__select ()$/in syscall .../
129 # + yet another way to get a select system call
130 s/in select () at \.\.\/sysdeps\/unix\/syscall-template\.S.*$/in syscall .../
132 # filter out names which starts with a "."
133 # such names are used for "function descriptors" on ppc64
134 # bugzilla 406561
135 s/in \.__select () at \.\.\/sysdeps\/unix\/syscall-template\.S.*$/in syscall .../
137 # cleanup some lines for a system call (on ubuntu 10 64 bits)
138 # (pay attention : there are tab characters there in)
139 /^[ ]*at \.\.\/sysdeps\/unix\/syscall-template\.S/d
140 /^[ ]*in \.\.\/sysdeps\/unix\/syscall-template\.S/d
142 /^[1-9][0-9]*[ ]*\.\.\/sysdeps\/unix\/syscall-template\.S/d
143 /^[1-9][0-9]*[ ]in *\.\.\/sysdeps\/unix\/syscall-template\.S/d
144 /^[1-9][0-9]*[ ]T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS)/d
146 # and yet another (Solaris way) to get a poll system call
147 # (on 32 bits, we have /lib/libc.so.*, on 64 bits, /lib/64/libc.so.*)
148 s/in __pollsys () from \/.*$/in syscall .../
149 /^ from \/lib\/64\/libc.so.*$/d
151 # which registers can't be modified
152 s/\(Could not write register \)".*"/\1 "xxx"/
153 s/\(ERROR changing register \).*$/\1 xxx regno y/
155 # special transform for arm/ppc watchpoints which have an additional address
156 # at the beginning
157 s/0x........ in \(main (argc=1, argv=0x........) at watchpoints.c:[24][3689]\)/\1/
159 s/0x........ in \(main () at clean_after_fork.c:34\)/\1/
161 # SIGFPE backtrace is varying so much that we just remove all lines
162 # after the signal trapping using an expr in this sed, followed by another sed.
163 s/\(^.*signal SIGFPE.*$\)/\1\nafter trap SIGFPE/
165 # gdb might also try to show the "entry value" p=p@entry=0x...
166 s/p=p@entry=0x/p=0x/
168 # for hgtls the breakpoint p=... address might show var location.
169 s/\(^Breakpoint 1, tls_ptr (p=0x........\) <tests[0-9+]*>\() at tls.c:55\)/\1\2/
171 /Id Target Id *Frame/d
172 s/^\([ \*] [1234] \) *Thread /\1Thread /
174 # Ordering of ' Thread .... (tid .' might differ between gdb version,
175 # so remove all such lines except the "current" one (starts with '*').
176 s/^ [0-9] Thread .... (tid [0-9] .*$//
178 # transform info thread of 7.3 into the layout of 7.2 and before.
179 s/VgTs_WaitSys) 0x/VgTs_WaitSys) 0x/
181 # delete lines telling that some memory can't be accessed: this is
182 # a.o. produced by gdb 7.2 on arm (same with standard gdbserver)
183 /Cannot access memory at address 0x......../d
185 # Filter 'New thread' lines
186 # gdb 7.9 reports new threads at different moment than the previous versions.
187 # Filter these new threads lines so as to not be dependent on this
188 # gdb aspect.
189 /\[New Thread/d
191 # 406355
192 # adjust filtering for the new gdb output
193 # mcsigpass and mcsignopass tests fails due to the slightly different
194 # gdb output. Filter the tests output to make it the same for different
195 # gdb version. Change mcsigpass and mcsignopass .exp to fit filtered
196 # .out.
197 s/^0x........ in \(\w\+ (\)/\1/
199 # delete empty lines (the last line (only made of prompts) sometimes
200 # finishes with a new line, sometimes not ???).
201 /^$/d
206 dir=`dirname $0`
208 $dir/filter_stderr |
210 # Anonymise addresses
211 $dir/../tests/filter_addresses |
213 # memcheck stuff
214 $dir/filter_memcheck_monitor "$@" |
216 # memcheck filter might leave some "..." lines, we are not interested
217 sed -e '/^\ \ \ \ \.\.\.$/d' |
219 # Anonymise or remove, using the big list of PATTERN prepared above
220 sed -f $PATTERNFILE |
222 # remove all the lines telling where the SIGFPE was trapped.
223 sed -e '/after trap SIGFPE/,/after continue SIGFPE/d' |
225 # join together two lines that gdb 7.1 splits in two (???)
226 # (in a separate sed, as the below influences the behaviour of the other expressions)
227 sed -e :a -e '$!N;s/\n at sleepers.c:39/ at sleepers.c:39/;ta' -e 'P;D'
229 rm $PATTERNFILE