remove duplicate profile event code that is already in
[gem5.git] / test / nmtest.cc
1 /*
2 * Copyright (c) 2002-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29 #include <iostream>
30 #include <string>
31 #include <vector>
32
33 #include "base/loader/object_file.hh"
34 #include "base/loader/symtab.hh"
35 #include "base/misc.hh"
36 #include "base/str.hh"
37
38 using namespace std;
39 Tick curTick;
40
41 ostream *outputStream = &cout;
42
43 int
44 main(int argc, char *argv[])
45 {
46 if (argc != 2 && argc != 3)
47 panic("usage: %s <filename> <symbol>\n", argv[0]);
48
49 ObjectFile *obj = createObjectFile(argv[1]);
50 if (!obj)
51 panic("file not found\n");
52
53 SymbolTable symtab;
54 obj->loadGlobalSymbols(&symtab);
55 obj->loadLocalSymbols(&symtab);
56
57 if (argc == 2) {
58 SymbolTable::ATable::const_iterator i = symtab.getAddrTable().begin();
59 SymbolTable::ATable::const_iterator end = symtab.getAddrTable().end();
60 while (i != end) {
61 cprintf("%#x %s\n", i->first, i->second);
62 ++i;
63 }
64 } else {
65 string symbol = argv[2];
66 Addr address;
67
68 if (symbol[0] == '0' && symbol[1] == 'x') {
69 if (to_number(symbol, address) &&
70 symtab.findSymbol(address, symbol))
71 cprintf("address = %#x, symbol = %s\n", address, symbol);
72 else
73 cprintf("address = %#x was not found\n", address);
74 } else {
75 if (symtab.findAddress(symbol, address))
76 cprintf("symbol = %s address = %#x\n", symbol, address);
77 else
78 cprintf("symbol = %s was not found\n", symbol);
79 }
80 }
81
82 return 0;
83 }