syswrap openat2 for all linux arches
[valgrind.git] / gdbserver_tests / filter_gdb.in
blob16186dfe2c9bfe060aea0e0ab7ede8860f28d477
1 #! /bin/sh
3 # filter the output of gdb.
5 SED=@SED@
7 PATTERNFILE=$(mktemp filter_gdb.tmp.XXXXXXXXXX)
8 cat > $PATTERNFILE <<EOF
9 # delete the initial lines between the launch of vgdb and the
10 # output of the echo command telling it is launched.
11 # This removes a whole lot of uninteresting lines varying
12 # with OS/glibc/gdb dep
13 /Remote debugging using/,/vgdb launched process attached/d
15 # general way to delete uninteresting and varying lines.
16 /filter_gdb BEGIN drop/,/filter_gdb END drop/d
18 # delete messages produced by valgrind python code loading.
19 /Loaded.*valgrind-monitor.py$/d
20 /Type "help valgrind" for more info\.$/d
21 # and remove loading error messages when python scripts haven't
22 # been installed yet (running against vg-in-place)
23 /warning: Missing auto-load script.*/d
24 /of file .*vgpreload.*so.*/d
25 /Use.*info auto-load python-scripts.*/d
27 # delete messages produced when GDB auto-load denies loading python code.
28 # Note that the first pattern is also present in filter_vgdb.in
29 # as this line is output on stderr.
30 /warning: File .*valgrind-monitor.py.*declined.*/d
31 /To enable execution of this file add/,/info "(gdb)Auto-loading safe path"/d
33 # initial tty control character sent by gdb 7.0
34 s/^\e\[?1034hReading symbols/Reading symbols/
36 # remove message about missing debuginfos
37 /^Missing separate debuginfo/d
39 # remove messages about not being able to download debuginfos
40 /^Download failed: /d
42 # suppress lines telling file _exit.c does not exist
43 /\/_exit.c: No such file or directory/d
45 # On FreeBSD if the base and/or lib32 dbg components
46 # are installed but not system source then these
47 # errors get produced by GDB
48 /\(rtld_start.S\|kill.S\|_exit.S\|_select.S\): No such file or directory/d
50 # Remove some Suse package manager messages
51 /^Try: zypper install -C/d
53 # Remove vgdb message
54 /relaying data between gdb and process/d
56 # Anonymise pid numbers
57 s/pid [0-9][0-9]*/pid ..../g
59 # filter 'remote target killed' messages (produced by gdb >= 8.2)
60 /(Remote target) killed/d
62 # Anonymise Thread numbers
63 s/Thread [0-9][0-9]*/Thread ..../g
65 # delete thread switches
66 /\[Switching to Thread ....\]/d
68 # ??? Probably we had a 'Switching ' message in front of
69 # a frame line ?
70 s/\(\[Switching to thread [1234] (Thread ....)\]\)#0/\1\n#0/
72 # Anonymise info threads output (e.g. which thread is running and syscall)
73 s/^\([ \* ] [0-9] Thread .... (tid [0-9] VgTs_WaitSys) 0x........ in\).*$/\1 syscall .../
75 # Newer gdb say Thread .... hit Breakpoint, we expect just Breakpoint.
76 s/^Thread .... hit Breakpoint /Breakpoint /
78 # We expect "Program received" instead of "Thread .... received"
79 s/^Thread .... received /Program received /
81 s/#[0-9]\( 0x........ in sleeper_or_burner\)/#.\1/
83 # Some gdb versions don't show the source line:number after switching
84 # threads in #0 0x........ in do_burn ().
85 s/\(#0 0x........ in do_burn ()\) at sleepers.c:41/\1/
88 # delete Reading symbols file lines
89 # Note: The 'done.' in "Reading symbols from <exe>...done."
90 # is optional (bugzilla 406357).
91 /^Reading symbols from .*\.\.\.\(done\.\)\?/d
93 # delete Loaded symbols file lines
94 /^Loaded symbols for .*$/d
96 # delete language switch messages.
97 /^Current language.*/d
98 /^The current source language is.*/d
100 # 'exited with code' and 'exited normally' are printed slightly
101 # differently between gdb versions, normalize to "Program exited...".
102 s/^.*\( exited with code [0-9]\+\).$/Program\1\./g
103 s/^.*\( exited normally\).$/Program\1\./g
105 # remove gdb prompts.
106 s/(gdb) //g
108 # remove gdb continuation prompts.
109 s/^>[> ]*//
111 # remove gdb done prompts.
112 /^done\.$/d
114 # anonymise a 'general' system calls stack trace part
115 s/in _dl_sysinfo_int80 () from \/lib\/ld-linux.so.*/in syscall .../
117 # anonymise kill syscall.
118 s/in kill ().*$/in syscall .../
120 # anonymise syscall on ppc64 (bugzilla #284305)
121 s/in .*kill ().*$/in syscall .../
124 s/in _dl_sysinfo_int80 ()/in syscall .../
125 /^ from \/lib\/ld-linux.so.*$/d
126 s/\(0x........\) in ?? () from \/lib.*$/\1 in syscall .../
127 s/\(0x........\) in ?? ()$/\1 in syscall .../
129 # 4 expressions to cover glibc 2.27 way to do a select, such as
130 # * 1 Thread 5548 (tid 1 VgTs_WaitSys) 0x0000000004f6203f in __GI___select (
131 # nfds=0, readfds=0x0, writefds=0x0, exceptfds=0x0, timeout=0x30a0e0 <t>)
132 # at ../sysdeps/unix/sysv/linux/select.c:41
133 # If select.c sources are present, we can also get a line containing:
134 # return SYSCALL_CANCEL....
135 s/in __select .*/in syscall .../
136 s/in __select$/in syscall .../
137 s/in _select ()/in syscall .../
138 /nfds=/d
139 /exceptfds=/d
140 /timeout=/d
141 /sysv\/linux\/select\.c/d
142 /sysv\/linux\/generic\/select.c/d
143 /return SYSCALL_CANCEL /d
144 /r = SYSCALL_CANCEL /d
146 # a more specialised system call select stack trace part
147 # (on 32 bits, we have an int_80, on 64 bits, directly select)
148 s/in \(.__\)\{0,1\}select () from \/.*$/in syscall .../
150 /^ from \/lib.*\/libc.so.*$/d
151 /^ from \/lib64.*\/libc.so.*$/d
152 /^ from \/lib64.*\/.*\/libc.so.*$/d
153 /^ from \/lib64.*\/.*\/libc-.*.so/d
154 s/ from \/lib\/libc\.so.*//
156 # and yet another (gdb 7.0 way) to get a system call
157 s/in select ()$/in syscall .../
159 # and yet another (gdb 7.0 arm way) to get a system call
160 s/in \.__select ()$/in syscall .../
162 # + yet another way to get a select system call
163 s/in select () at \.\.\/sysdeps\/unix\/syscall-template\.S.*$/in syscall .../
165 # FreeBSD system call
166 s/_select () at _select.S:.*$/0x........ in syscall .../
168 # FreeBSD system call again
169 /in _select.S/d
171 # FreeBSD system call
172 s/kill () at kill.S:.*$/0x........ in syscall .../
174 # filter out names which starts with a "."
175 # such names are used for "function descriptors" on ppc64
176 # bugzilla 406561
177 s/in \.__select () at \.\.\/sysdeps\/unix\/syscall-template\.S.*$/in syscall .../
179 # cleanup some lines for a system call (on ubuntu 10 64 bits)
180 # (pay attention : there are tab characters there in)
181 /^[ ]*at \.\.\/sysdeps\/unix\/syscall-template\.S/d
182 /^[ ]*in \.\.\/sysdeps\/unix\/syscall-template\.S/d
184 /^[1-9][0-9]*[ ]*\.\.\/sysdeps\/unix\/syscall-template\.S/d
185 /^[1-9][0-9]*[ ]in *\.\.\/sysdeps\/unix\/syscall-template\.S/d
186 /^[1-9][0-9]*[ ]T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS)/d
188 # and yet another (Solaris way) to get a poll system call
189 # (on 32 bits, we have /lib/libc.so.*, on 64 bits, /lib/64/libc.so.*)
190 s/in __pollsys () from \/.*$/in syscall .../
191 /^ from \/lib\/64\/libc.so.*$/d
193 # which registers can't be modified
194 s/\(Could not write register \)".*"/\1 "xxx"/
195 s/\(ERROR changing register \).*$/\1 xxx regno y/
197 # special transform for arm/ppc watchpoints which have an additional address
198 # at the beginning
199 s/0x........ in \(main (argc=1, argv=0x........) at watchpoints.c:[24][3689]\)/\1/
201 s/0x........ in \(main () at clean_after_fork.c:34\)/\1/
203 # SIGFPE backtrace is varying so much that we just remove all lines
204 # after the signal trapping using an expr in this sed, followed by another sed.
205 s/\(^.*signal SIGFPE.*$\)/\1\nafter trap SIGFPE/
207 # gdb might also try to show the "entry value" p=p@entry=0x...
208 s/p=p@entry=0x/p=0x/
210 # for hgtls the breakpoint p=... address might show var location.
211 s/\(^Breakpoint 1, tls_ptr (p=0x........\) <tests[0-9+]*>\() at tls.c:55\)/\1\2/
213 /Id Target Id *Frame/d
214 s/^\([ \*] [1234] \) *Thread /\1Thread /
216 # Ordering of ' Thread .... (tid .' might differ between gdb version,
217 # so remove all such lines except the "current" one (starts with '*').
218 s/^ [0-9] Thread .... (tid [0-9] .*$//
220 # transform info thread of 7.3 into the layout of 7.2 and before.
221 s/VgTs_WaitSys) 0x/VgTs_WaitSys) 0x/
223 # delete lines telling that some memory can't be accessed: this is
224 # a.o. produced by gdb 7.2 on arm (same with standard gdbserver)
225 /Cannot access memory at address 0x......../d
227 # Filter 'New thread' lines
228 # gdb 7.9 reports new threads at different moment than the previous versions.
229 # Filter these new threads lines so as to not be dependent on this
230 # gdb aspect.
231 /\[New Thread/d
233 # 406355
234 # adjust filtering for the new gdb output
235 # mcsigpass and mcsignopass tests fails due to the slightly different
236 # gdb output. Filter the tests output to make it the same for different
237 # gdb version. Change mcsigpass and mcsignopass .exp to fit filtered
238 # .out.
239 s/^0x........ in \(\w\+ (\)/\1/
241 # delete empty lines (the last line (only made of prompts) sometimes
242 # finishes with a new line, sometimes not ???).
243 /^$/d
248 dir=`dirname $0`
250 $dir/filter_stderr |
252 # Anonymise addresses
253 $dir/../tests/filter_addresses |
255 # memcheck stuff
256 $dir/filter_memcheck_monitor "$@" |
258 # memcheck filter might leave some "..." lines, we are not interested
259 $SED -e '/^\ \ \ \ \.\.\.$/d' |
261 # Anonymise or remove, using the big list of PATTERN prepared above
262 $SED -f $PATTERNFILE |
264 # remove all the lines telling where the SIGFPE was trapped.
265 $SED -e '/after trap SIGFPE/,/after continue SIGFPE/d' |
267 # join together two lines that gdb 7.1 splits in two (???)
268 # (in a separate sed, as the below influences the behaviour of the other expressions)
269 $SED -e :a -e '$!N;s/\n at sleepers.c:39/ at sleepers.c:39/;ta' -e 'P;D'
271 rm $PATTERNFILE