source: trunk/IPs/systemC/processor/Morpheo/Script/instruction_flow.sh @ 114

Last change on this file since 114 was 114, checked in by rosiere, 15 years ago

1) Fix bug with previous commit
2) Add test libc
3) Change Dhrystone

  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 3.0 KB
Line 
1#!/bin/bash
2
3#-----------------------------------------------------------
4# $Id: instruction_flow.sh 114 2009-04-16 22:35:37Z rosiere $
5#-----------------------------------------------------------
6
7#-----[ usage ]---------------------------------------------
8function usage ()
9{
10    echo "Usage     : ${0} file1 file2";
11    echo "Arguments : ";
12    echo " * file1 : instruction flow file";
13    echo " * file2 : symbol file";
14    echo "format for file1 : xxx address xxx. address is in hexadecimal without 0x or additionnal 0";
15    exit;
16}
17
18#-----[ test_usage ]----------------------------------------
19function test_usage ()
20{
21    if test ${#} -ne 2; then
22        usage ${*};
23    fi;
24}
25
26#-----[ main ]----------------------------------------------
27function main ()
28{
29    test_usage ${*};
30
31    # Read symbol file and take function address and function name
32    local -ai array_address_begin;
33    local -ai array_address_end;
34    local -a array_name;
35
36    # first slot
37    array_address_begin[0]=0;
38    array_name[0]="???";
39
40    local -i cpt=1;
41    while read line; do
42        local type=$(echo ${line} | cut -d' ' -f2);
43
44        # Test if the symbol is in text section
45        if test "${type}" = "T"; then
46            local address_begin=$(echo ${line} | cut -d' ' -f1);
47            local name=$(   echo ${line} | cut -d' ' -f3);
48
49            # erase additionnal 0
50            declare str=$(expr match "${address_begin}" '.*\(^[0]*\)');
51            address_begin=$(printf %d 0x${address_begin#${str}});
52
53            local address_end=$((${address_begin}-1));
54
55            array_address_begin[${cpt}]=${address_begin};
56            array_address_end[$((${cpt}-1))]=${address_end};
57            array_name[${cpt}]="${name}";
58
59            #echo "${address_begin} ${name}";
60
61            cpt=$((${cpt}+1));
62        fi;
63    done < ${2};
64
65    # last slot
66    array_address_end[$((${cpt}-1))]=$(printf %d 0xffffffff);
67
68#    cpt=0;
69#    while test ${cpt} -ne ${#array_address_begin[*]}; do
70#        address_begin=${array_address_begin[${cpt}]};
71#        address_end=${array_address_end[${cpt}]};
72#        name=${array_name[${cpt}]};
73#
74#        echo "${address_begin} ${address_end} ${name}";
75#
76#        cpt=$((${cpt}+1));
77#    done;
78
79     # Read instruction flow file
80    while read line; do
81         # extract address
82       
83        local name="";
84        local -i address_current=$(printf %d 0x$(echo ${line} | cut -d' ' -f2));
85       
86         # search in address file if match
87        cpt=0;
88        while test ${cpt} -ne ${#array_address_begin[*]}; do
89            local -i address_begin=${array_address_begin[${cpt}]};
90            local -i address_end=${array_address_end[${cpt}]};
91           
92             # test if address_curent match with a address in symbol file
93            if test ${address_current} -ge ${address_begin} -a ${address_current} -lt ${address_end}; then
94                name=${array_name[${cpt}]};
95                break;
96            fi;
97           
98            cpt=$((${cpt}+1));
99        done;
100       
101        echo "${line} ${name}";
102       
103    done < ${1};
104
105}
106
107#-----[ Corps ]---------------------------------------------
108main ${*};
Note: See TracBrowser for help on using the repository browser.