[2] | 1 | #! /usr/bin/perl -w |
---|
| 2 | |
---|
| 3 | ### -------------------------------------------------------------- ### |
---|
| 4 | # # |
---|
| 5 | # File : log_trace.pl # |
---|
| 6 | # Authors : Sroka Marek # |
---|
| 7 | # Date : 20/07/2006 # |
---|
| 8 | # Modif. : 18/08/2006 # |
---|
| 9 | # Version : 1.0 # |
---|
| 10 | # # |
---|
| 11 | # Origin : this description has been developed by CAO-VLSI team # |
---|
| 12 | # at ASIM laboratory, University Pierre et Marie Curie # |
---|
| 13 | # 4 Place Jussieu 75252 Paris Cedex 05 - France # |
---|
| 14 | # # |
---|
| 15 | ### -------------------------------------------------------------- ### |
---|
| 16 | |
---|
| 17 | my $TAB1='| '; |
---|
| 18 | my $TAB2='+--'; |
---|
| 19 | |
---|
| 20 | sub usage() |
---|
| 21 | { |
---|
| 22 | print "usage : $0 rob_trace_file nm_file\n"; |
---|
| 23 | print " * rob_trace_file : Trace file generate by simulation\n"; |
---|
| 24 | print " * nm_file : List of symbol (generate by nm)\n"; |
---|
| 25 | exit(1); |
---|
| 26 | } |
---|
| 27 | |
---|
| 28 | my $rob = $ARGV[0]; |
---|
| 29 | my $nm = $ARGV[1]; |
---|
| 30 | |
---|
| 31 | if (not defined $rob) |
---|
| 32 | { |
---|
| 33 | usage(); |
---|
| 34 | } |
---|
| 35 | |
---|
| 36 | unless (defined $nm) |
---|
| 37 | { |
---|
| 38 | usage(); |
---|
| 39 | } |
---|
| 40 | |
---|
| 41 | my %calls=(); |
---|
| 42 | my %end=(); |
---|
| 43 | |
---|
| 44 | open (nm_f,$nm) or die "could not open $nm : $!\n"; |
---|
| 45 | |
---|
| 46 | my $current_section; |
---|
| 47 | |
---|
| 48 | while ($line = <nm_f>) |
---|
| 49 | { |
---|
| 50 | if ($line =~ /([0-9a-f]{8}) [Tt] (.*)/) |
---|
| 51 | { |
---|
| 52 | my $addr=hex $1; |
---|
| 53 | $calls{$addr}=$2; |
---|
| 54 | $end{$current_section} = $addr if (defined $current_section); |
---|
| 55 | $current_section=$addr; |
---|
| 56 | } |
---|
| 57 | } |
---|
| 58 | |
---|
| 59 | $end{$current_section}=0xffffffff; |
---|
| 60 | |
---|
| 61 | close nm_f; |
---|
| 62 | |
---|
| 63 | my @pile = (); |
---|
| 64 | my $depth = 0; |
---|
| 65 | open (rob_f,$rob) or die "could not open $rob : $!\n"; |
---|
| 66 | |
---|
| 67 | print "[ time ] ","depth"," ","address "," ","function\n"; |
---|
| 68 | |
---|
| 69 | while (<rob_f>) |
---|
| 70 | { |
---|
| 71 | if (/(\d+) inst OK - \@([0-9a-f]{8})/) |
---|
| 72 | { |
---|
| 73 | my $addr = hex $2; |
---|
| 74 | my $time = sprintf "%-8d",$1; |
---|
| 75 | my $print_addr = sprintf "%-8x",$addr; |
---|
| 76 | |
---|
| 77 | if (exists $calls{$addr}) |
---|
| 78 | { |
---|
| 79 | my $print_depth = sprintf "%-5d",$depth; |
---|
| 80 | $depth = $depth + 1; |
---|
| 81 | |
---|
| 82 | #print "[ $time ] ",$print_depth," ",$print_addr," ",$TAB1x@pile,"[1;32m$calls{$addr}[0m\n"; |
---|
| 83 | print "[ $time ] ",$print_depth," ",$print_addr," ",$TAB1 x(@pile-1),$TAB2," $calls{$addr}\n"; |
---|
| 84 | push(@pile,$addr); |
---|
| 85 | } |
---|
| 86 | |
---|
| 87 | while (@pile and ($addr < $pile[-1] or $addr >= $end{$pile[-1]})) |
---|
| 88 | { |
---|
| 89 | $depth = $depth - 1; |
---|
| 90 | my $print_depth = sprintf "%-5d",$depth; |
---|
| 91 | |
---|
| 92 | my $end=pop(@pile); |
---|
| 93 | #print "[ $time ] ",$print_depth," "," "," ",$TAB2x@pile,"[0;31m$calls{$end}[0m\n"; |
---|
| 94 | print "[ $time ] ",$print_depth," "," "," ",$TAB1 x@pile," $calls{$end}\n"; |
---|
| 95 | } |
---|
| 96 | } |
---|
| 97 | } |
---|
| 98 | close rob_f; |
---|