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