* configure.ac: New switch for disabling -O2 (--disable-optimizations).
[cacao.git] / contrib / log2xml.pl
old mode 100755 (executable)
new mode 100644 (file)
index b9b8d51..89e83cf
@@ -1,6 +1,6 @@
 #!/usr/bin/perl -w
 # ======================================================================
-# log2xml - This script translates cacao -verbosecall ouput into a
+# log2xml - This script translates cacao -verbosecall output into a
 #           more readable XML format. It also separates the output of
 #           different threads and is able to ignore commonly called
 #           (uninteresting) methods.
 # You may want to edit the opt_ignore options below.
 #
 # Author  : Edwin Steiner
-# Revision: $Id: log2xml.pl 2304 2005-04-14 19:44:00Z edwin $
+# Revision:
 #
 # $Log$
+# Revision 1.5  2005/04/15 09:33:34  edwin
+# preserve indentation of log text
+#
+# Revision 1.4  2005/04/15 09:06:54  edwin
+# output more valid xml
+#
+# Revision 1.3  2005/04/14 20:11:04  edwin
+# typo
+#
+# Revision 1.2  2005/04/14 20:10:20  edwin
+# disabled debug print, added vim boilerplate
+#
 # Revision 1.1  2005/04/14 19:44:00  edwin
 # added log2xml.pl and log2xml.vim
 #
@@ -138,6 +150,17 @@ sub write_xml_leave ( $$ )
        print $file "</call>\n";
 }
 
+sub write_xml_never_returns ( $$ )
+{
+       my ($thread,$node) = @_;
+
+       my $file = $files{$thread};
+       print $file '<never_returns';
+       print $file ' name="' . quote($node->{NAME}) . '"';
+       print $file "/>\n";
+       print $file "</call>\n";
+}
+
 sub write_xml_node ( $$ )
 {
        my ($thread,$node) = @_;
@@ -166,11 +189,13 @@ sub write_xml_header ( $ )
 {
        my ($file) = @_;
        print $file '<?xml version="1.0"?>'."\n";
+       print $file "<thread>\n";
 }
 
 sub write_xml_end ( $ )
 {
        my ($file) = @_;
+       print $file "</thread>\n";
 }
 
 # ======================================================================
@@ -373,7 +398,7 @@ sub process_text ( $$ )
 {
        my ($thread,$text) = @_;
 
-       print STDERR "$.: $text\n";
+       print STDERR "$.: $text\n";
 
        if ($opt_no_text_for_ignored && $ignore_level{$thread} > 0) {
                return;
@@ -395,8 +420,8 @@ sub main
                my $lastthread;
                while (<>) {
                        chomp($_);
-                       if (/LOG: \[(\S+)\]\s+(.*)/) {
-                               my ($thread,$log) = ($1,$2);
+                       if (/LOG: \[(\S+)\](\s*)(.*)/) {
+                               my ($thread,$space,$log) = ($1,$2,$3);
                                thread_register($thread);
                                $lastthread = $thread;
                                if ($log =~ /(1st_call|called|finished):\s*(.*)/) {
@@ -406,7 +431,7 @@ sub main
                                        process_exception($thread,$1,$2);
                                }
                                else {
-                                       process_text($thread,$log);
+                                       process_text($thread,$space.$log);
                                }
                        }
                        else {
@@ -434,7 +459,14 @@ sub main
                                write_xml_frame($thread,$top);
                                $ign--;
                    }
+                       pop @{$stacks{$thread}} for 1..$ignore_level{$thread};
+               }
+               while (scalar @{$stacks{$thread}} > 1) {
+                               my $top = $stacks{$thread}->[-1];
+                               write_xml_never_returns($thread,$top);
+                               pop @{$stacks{$thread}};
                }
+               write_xml_end($files{$thread});
                $files{$thread}->close();
        }
        print STDERR "processed $. lines\n";
@@ -442,3 +474,5 @@ sub main
 
 main();
 
+# vim: noet ts=4 sw=4 ai
+