2 # $Id: tracemunch,v 1.3 2002/09/22 16:31:18 tom Exp $
3 ##############################################################################
4 # Copyright (c) 1998,2002 Free Software Foundation, Inc. #
6 # Permission is hereby granted, free of charge, to any person obtaining a #
7 # copy of this software and associated documentation files (the "Software"), #
8 # to deal in the Software without restriction, including without limitation #
9 # the rights to use, copy, modify, merge, publish, distribute, distribute #
10 # with modifications, sublicense, and/or sell copies of the Software, and to #
11 # permit persons to whom the Software is furnished to do so, subject to the #
12 # following conditions: #
14 # The above copyright notice and this permission notice shall be included in #
15 # all copies or substantial portions of the Software. #
17 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
18 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, #
19 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL #
20 # THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER #
21 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING #
22 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER #
23 # DEALINGS IN THE SOFTWARE. #
25 # Except as contained in this notice, the name(s) of the above copyright #
26 # holders shall not be used in advertising or otherwise to promote the sale, #
27 # use or other dealings in this Software without prior written #
29 ##############################################################################
30 # tracemunch -- compactify ncurses trace logs
32 # The error logs produced by ncurses with tracing enabled can be very tedious
33 # to wade through. This script helps by compacting runs of log lines that
34 # can be conveniently expressed as higher-level operations.
37 $putattr="PutAttrChar\\('(.)' = 0x.., {A_NORMAL}\\) at \\(([0-9]+), ([0-9]+)\\)";
38 $waddnstr="waddnstr\\(0x([0-9a-f]+),\"([^\"]+)\",[0-9]+\\) called {A_NORMAL}";
46 $arg =~ s/$curscr/curscr/ if ($curscr);
47 $arg =~ s/$newscr/newscr/ if ($newscr);
48 $arg =~ s/$stdscr/stdscr/ if ($stdscr);
49 for $n (0..$#win_addr) {
50 $arg =~ s/$win_addr[$n]/window$n/ if $win_addr[$n];
59 # Transform window pointer addresses so it's easier to compare logs
60 $awaiting = "curscr" if ($_ =~ /creating curscr/);
61 $awaiting = "newscr" if ($_ =~ /creating newscr/);
62 $awaiting = "stdscr" if ($_ =~ /creating stdscr/);
63 if ($_ =~ /^create :window 0x([0-9a-f]+)/) {
65 if ($awaiting eq "curscr") {
67 } elsif ($awaiting eq "newscr") {
69 } elsif ($awaiting eq "stdscr") {
72 $win_addr[$win_nums] = $addr;
73 $win_nums = $win_nums + 1;
76 } elsif ($_ =~ /^\.\.\.deleted win=0x([0-9a-f]+)/) {
78 if ($addr eq $curscr) {
80 } elsif ($addr eq $newscr) {
82 } elsif ($addr eq $stdscr) {
85 for $n (0..$#win_addr) {
86 if ($win_addr[$n] eq $addr) {
93 # Compactify runs of PutAttrChar calls (TR_CHARPUT)
101 if ($_ =~ /$putattr/) {
102 $putattr_chars .= $1;
107 print "RUN of PutAttrChar()s: \"$putattr_chars\" from ${starty}, ${startx}\n";
111 # Compactify runs of waddnstr calls (TR_CALLS)
112 if ($_ =~ /$waddnstr/)
114 $waddnstr_chars = $2;
118 if ($_ =~ /$waddnstr/ && $1 eq $winaddr) {
119 $waddnstr_chars .= $2;
124 $winaddstr = &transaddr($winaddr);
125 print "RUN of waddnstr()s: $winaddr, \"$waddnstr_chars\"\n";
129 # More transformations can go here
131 # Repeated runs of anything
132 $anyline = &transaddr($_);
135 if (&transaddr($_) eq $anyline) {
141 if ($repeatcount > 1) {
142 print "${repeatcount} REPEATS OF $anyline";
151 # tracemunch ends here