sewardj | 3b29048 | 2011-05-06 21:02:55 +0000 | [diff] [blame] | 1 | #! /bin/sh |
| 2 | |
| 3 | # filter the output of gdb. |
| 4 | |
| 5 | dir=`dirname $0` |
| 6 | |
| 7 | $dir/filter_stderr | |
| 8 | |
| 9 | # Anonymise addresses |
| 10 | $dir/../tests/filter_addresses | |
| 11 | |
| 12 | # memcheck stuff |
philippe | a22f59d | 2012-01-26 23:13:52 +0000 | [diff] [blame] | 13 | $dir/filter_memcheck_monitor "$@" | |
sewardj | 3b29048 | 2011-05-06 21:02:55 +0000 | [diff] [blame] | 14 | |
philippe | d6a9809 | 2012-10-14 18:16:41 +0000 | [diff] [blame] | 15 | # memcheck filter might leave some "..." lines, we are not interested |
| 16 | sed -e '/^\ \ \ \ \.\.\.$/d' | |
sewardj | 3b29048 | 2011-05-06 21:02:55 +0000 | [diff] [blame] | 17 | |
| 18 | # Anonymise or remove : |
sewardj | eefeeb7 | 2011-05-10 11:01:07 +0000 | [diff] [blame] | 19 | # delete the initial lines between the launch of vgdb and the |
| 20 | # output of the echo command telling it is launched. |
| 21 | # This removes a whole lot of uninteresting lines varying |
| 22 | # with OS/glibc/gdb dep |
philippe | d719453 | 2014-04-24 21:52:02 +0000 | [diff] [blame] | 23 | # then have a general way to delete uninteresting and vayring |
| 24 | # lines. |
philippe | a460df8 | 2014-04-26 20:40:41 +0000 | [diff] [blame] | 25 | # suppress lines telling file _exit.c does not exist |
sewardj | 3b29048 | 2011-05-06 21:02:55 +0000 | [diff] [blame] | 26 | # initial tty control character sent by gdb 7.0 |
| 27 | # remove missing debuginfos |
| 28 | # vgdb message |
| 29 | # pid numbers |
| 30 | # Thread numbers |
| 31 | # delete thread switches |
| 32 | # info threads output (e.g. which thread is running and syscall) |
| 33 | # delete Reading symbols file lines |
| 34 | # delete Loaded symbols file lines |
sewardj | eefeeb7 | 2011-05-10 11:01:07 +0000 | [diff] [blame] | 35 | # delete language switch messages. |
sewardj | 3b29048 | 2011-05-06 21:02:55 +0000 | [diff] [blame] | 36 | # remove gdb prompts. |
| 37 | # remove gdb continuation prompts. |
| 38 | # remove gdb done prompts. |
| 39 | # a 'general' system calls stack trace part |
| 40 | # a more specialised system call select stack trace part |
| 41 | # (on 32 bits, we have an int_80, on 64 bits, directly select) |
| 42 | # and yet another (gdb 7.0 way) to get a system call |
| 43 | # and yet another (gdb 7.0 arm way) to get a system call |
| 44 | # and cleanup some lines for a system call (on ubuntu 10 64 bits) |
| 45 | # (pay attention : there are tab characters there in) |
| 46 | # + yet another way to get a select system call |
sewardj | 8eb8bab | 2015-07-21 14:44:28 +0000 | [diff] [blame] | 47 | # and yet another (Solaris way) to get a poll system call |
| 48 | # (on 32 bits, we have /lib/libc.so.*, on 64 bits, /lib/64/libc.so.*) |
sewardj | 3b29048 | 2011-05-06 21:02:55 +0000 | [diff] [blame] | 49 | # which registers can't be modified |
| 50 | # special transform for arm/ppc watchpoints which have an additional address |
| 51 | # at the beginning |
sewardj | 7629180 | 2011-05-31 07:09:06 +0000 | [diff] [blame] | 52 | # SIGFPE backtrace is varying so much that we just remove all lines |
| 53 | # after the signal trapping using an expr in this sed, followed by another sed. |
sewardj | 6b7357b | 2011-05-27 13:23:44 +0000 | [diff] [blame] | 54 | # transform info thread of 7.3 into the layout of 7.2 and before. |
sewardj | 3b29048 | 2011-05-06 21:02:55 +0000 | [diff] [blame] | 55 | # delete lines telling that some memory can't be accessed: this is |
| 56 | # a.o. produced by gdb 7.2 on arm (same with standard gdbserver) |
| 57 | # delete empty lines (the last line (only made of prompts) sometimes |
| 58 | # finishes with a new line, sometimes not ???). |
philippe | 0447bbd | 2012-10-17 21:32:03 +0000 | [diff] [blame] | 59 | # 'exited with code' and 'exited normally' are printed slightly |
| 60 | # differently between gdb versions, normalize to "Program exited...". |
mjw | 7697dd1 | 2014-08-22 10:14:28 +0000 | [diff] [blame] | 61 | # for hgtls the breakpoint p=... address might show var location. |
mjw | acb3929 | 2014-08-28 21:42:45 +0000 | [diff] [blame] | 62 | # gdb might also try to show the "entry value" p=p@entry=0x... |
mjw | d704f73 | 2014-09-02 10:16:42 +0000 | [diff] [blame] | 63 | # Some gdb versions don't show the source line:number after switching |
| 64 | # threads in #0 0x........ in do_burn (). |
sewardj | d142f99 | 2011-05-17 17:15:07 +0000 | [diff] [blame] | 65 | sed -e '/Remote debugging using/,/vgdb launched process attached/d' \ |
philippe | d719453 | 2014-04-24 21:52:02 +0000 | [diff] [blame] | 66 | -e '/filter_gdb BEGIN drop/,/filter_gdb END drop/d' \ |
sewardj | eefeeb7 | 2011-05-10 11:01:07 +0000 | [diff] [blame] | 67 | -e 's/^\[?1034hReading symbols/Reading symbols/' \ |
sewardj | d142f99 | 2011-05-17 17:15:07 +0000 | [diff] [blame] | 68 | -e '/^Missing separate debuginfo/d' \ |
philippe | a460df8 | 2014-04-26 20:40:41 +0000 | [diff] [blame] | 69 | -e '/\/_exit.c: No such file or directory/d' \ |
sewardj | d142f99 | 2011-05-17 17:15:07 +0000 | [diff] [blame] | 70 | -e '/^Try: zypper install -C/d' \ |
sewardj | 3b29048 | 2011-05-06 21:02:55 +0000 | [diff] [blame] | 71 | -e 's/\(relaying data between gdb and process \)[0-9][0-9]*/\1..../' \ |
| 72 | -e 's/pid [0-9][0-9]*/pid ..../g' \ |
| 73 | -e 's/Thread [0-9][0-9]*/Thread ..../g' \ |
| 74 | -e '/\[Switching to Thread ....\]/d' \ |
sewardj | 6b7357b | 2011-05-27 13:23:44 +0000 | [diff] [blame] | 75 | -e 's/\(\[Switching to thread [1234] (Thread ....)\]\)#0/\1\n#0/' \ |
sewardj | 3b29048 | 2011-05-06 21:02:55 +0000 | [diff] [blame] | 76 | -e 's/^\([ \* ] [0-9] Thread .... (tid [0-9] VgTs_WaitSys) 0x........ in\).*$/\1 syscall .../' \ |
| 77 | -e 's/#[0-9]\( 0x........ in sleeper_or_burner\)/#.\1/' \ |
sewardj | 8eb8bab | 2015-07-21 14:44:28 +0000 | [diff] [blame] | 78 | -e 's/\(#0 0x........ in do_burn ()\) at sleepers.c:41/\1/' \ |
sewardj | 3b29048 | 2011-05-06 21:02:55 +0000 | [diff] [blame] | 79 | -e '/^Reading symbols from .*\.\.\.done\./d' \ |
| 80 | -e '/^Loaded symbols for .*$/d' \ |
sewardj | eefeeb7 | 2011-05-10 11:01:07 +0000 | [diff] [blame] | 81 | -e '/^Current language.*/d' \ |
| 82 | -e '/^The current source language is.*/d' \ |
philippe | a460df8 | 2014-04-26 20:40:41 +0000 | [diff] [blame] | 83 | -e 's/^.*\( exited with code [0-9]\+\).$/Program\1\./g' \ |
| 84 | -e 's/^.*\( exited normally\).$/Program\1\./g' \ |
sewardj | 3b29048 | 2011-05-06 21:02:55 +0000 | [diff] [blame] | 85 | -e 's/(gdb) //g' \ |
| 86 | -e 's/^>[> ]*//' \ |
| 87 | -e '/^done\.$/d' \ |
| 88 | -e 's/in _dl_sysinfo_int80 () from \/lib\/ld-linux.so.*/in syscall .../' \ |
sewardj | b2572b5 | 2011-06-26 09:36:38 +0000 | [diff] [blame] | 89 | -e 's/in kill ().*$/in syscall .../' \ |
florian | 71fe57f | 2011-10-20 22:49:58 +0000 | [diff] [blame] | 90 | -e 's/in .*kill ().*$/in syscall .../' \ |
sewardj | 3b29048 | 2011-05-06 21:02:55 +0000 | [diff] [blame] | 91 | -e 's/in _dl_sysinfo_int80 ()/in syscall .../' \ |
| 92 | -e '/^ from \/lib\/ld-linux.so.*$/d' \ |
sewardj | d142f99 | 2011-05-17 17:15:07 +0000 | [diff] [blame] | 93 | -e 's/\(0x........\) in ?? () from \/lib.*$/\1 in syscall .../' \ |
sewardj | eefeeb7 | 2011-05-10 11:01:07 +0000 | [diff] [blame] | 94 | -e 's/\(0x........\) in ?? ()$/\1 in syscall .../' \ |
sewardj | 3b29048 | 2011-05-06 21:02:55 +0000 | [diff] [blame] | 95 | -e 's/in \(.__\)\{0,1\}select () from \/.*$/in syscall .../' \ |
| 96 | -e '/^ from \/lib\/libc.so.*$/d' \ |
sewardj | eefeeb7 | 2011-05-10 11:01:07 +0000 | [diff] [blame] | 97 | -e '/^ from \/lib64\/libc.so.*$/d' \ |
philippe | 2c89107 | 2014-04-23 21:27:07 +0000 | [diff] [blame] | 98 | -e '/^ from \/lib64\/.*\/libc.so.*$/d' \ |
sewardj | 3b29048 | 2011-05-06 21:02:55 +0000 | [diff] [blame] | 99 | -e 's/in select ()$/in syscall .../' \ |
sewardj | eefeeb7 | 2011-05-10 11:01:07 +0000 | [diff] [blame] | 100 | -e 's/in \.__select ()$/in syscall .../' \ |
sewardj | 3b29048 | 2011-05-06 21:02:55 +0000 | [diff] [blame] | 101 | -e 's/in select () at \.\.\/sysdeps\/unix\/syscall-template\.S.*$/in syscall .../' \ |
| 102 | -e '/^[ ]*at \.\.\/sysdeps\/unix\/syscall-template\.S/d' \ |
| 103 | -e '/^[ ]*in \.\.\/sysdeps\/unix\/syscall-template\.S/d' \ |
| 104 | -e '/^[1-9][0-9]*[ ]*\.\.\/sysdeps\/unix\/syscall-template\.S/d' \ |
| 105 | -e '/^[1-9][0-9]*[ ]in *\.\.\/sysdeps\/unix\/syscall-template\.S/d' \ |
philippe | a17ec01 | 2012-09-24 21:12:41 +0000 | [diff] [blame] | 106 | -e '/^[1-9][0-9]*[ ]T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS)/d' \ |
sewardj | 8eb8bab | 2015-07-21 14:44:28 +0000 | [diff] [blame] | 107 | -e 's/in __pollsys () from \/.*$/in syscall .../' \ |
| 108 | -e '/^ from \/lib\/64\/libc.so.*$/d' \ |
sewardj | 3b29048 | 2011-05-06 21:02:55 +0000 | [diff] [blame] | 109 | -e 's/\(Could not write register \)".*"/\1 "xxx"/' \ |
| 110 | -e 's/\(ERROR changing register \).*$/\1 xxx regno y/' \ |
| 111 | -e 's/0x........ in \(main (argc=1, argv=0x........) at watchpoints.c:[24][3689]\)/\1/' \ |
sewardj | f5194b3 | 2011-07-04 22:00:41 +0000 | [diff] [blame] | 112 | -e 's/0x........ in \(main () at clean_after_fork.c:34\)/\1/' \ |
sewardj | 7629180 | 2011-05-31 07:09:06 +0000 | [diff] [blame] | 113 | -e 's/\(^.*signal SIGFPE.*$\)/\1\nafter trap SIGFPE/' \ |
mjw | acb3929 | 2014-08-28 21:42:45 +0000 | [diff] [blame] | 114 | -e 's/p=p@entry=0x/p=0x/' \ |
mjw | 7697dd1 | 2014-08-22 10:14:28 +0000 | [diff] [blame] | 115 | -e 's/\(^Breakpoint 1, tls_ptr (p=0x........\) <tests[0-9+]*>\() at tls.c:55\)/\1\2/' \ |
sewardj | 6b7357b | 2011-05-27 13:23:44 +0000 | [diff] [blame] | 116 | -e '/Id Target Id Frame/d' \ |
| 117 | -e 's/^\([ \*] [1234] \) *Thread /\1Thread /' \ |
| 118 | -e 's/VgTs_WaitSys) 0x/VgTs_WaitSys) 0x/' \ |
sewardj | 3b29048 | 2011-05-06 21:02:55 +0000 | [diff] [blame] | 119 | -e '/Cannot access memory at address 0x......../d' \ |
philippe | 03f0fc1 | 2015-06-20 22:22:56 +0000 | [diff] [blame] | 120 | -e '/\[New Thread/d' \ |
philippe | a460df8 | 2014-04-26 20:40:41 +0000 | [diff] [blame] | 121 | -e '/^$/d' | |
sewardj | 7629180 | 2011-05-31 07:09:06 +0000 | [diff] [blame] | 122 | |
| 123 | # remove all the lines telling where the SIGFPE was trapped. |
philippe | a460df8 | 2014-04-26 20:40:41 +0000 | [diff] [blame] | 124 | sed -e '/after trap SIGFPE/,/after continue SIGFPE/d' | |
sewardj | 3b29048 | 2011-05-06 21:02:55 +0000 | [diff] [blame] | 125 | |
| 126 | # join together two lines that gdb 7.1 splits in two (???) |
| 127 | # (in a separate sed, as the below influences the behaviour of the other expressions) |
sewardj | 7629180 | 2011-05-31 07:09:06 +0000 | [diff] [blame] | 128 | sed -e :a -e '$!N;s/\n at sleepers.c:39/ at sleepers.c:39/;ta' -e 'P;D' |
sewardj | 3b29048 | 2011-05-06 21:02:55 +0000 | [diff] [blame] | 129 | |