Support loading in a symbol file.

arch/alpha/freebsd/system.cc:
arch/alpha/isa/decoder.isa:
arch/alpha/linux/system.cc:
arch/alpha/system.cc:
arch/alpha/tru64/system.cc:
    Let symbol files be read in so that profiling can happen on the binaries as well.
python/m5/objects/System.py:
    Add in symbol files.
sim/pseudo_inst.cc:
    Load in a specified symbol file.
sim/pseudo_inst.hh:
    Allow for symbols to be loaded.
sim/system.hh:
    Support symbol file.
util/m5/m5.c:
util/m5/m5op.S:
    Add support to m5 util for loading symbols (and readfile).

--HG--
extra : convert_revision : f10c1049bcd7b22b98c73052c0666b964aff222b
This commit is contained in:
Kevin Lim 2006-08-23 16:57:07 -04:00
parent de321175f2
commit 4a2c50bc8f
11 changed files with 96 additions and 0 deletions

View file

@ -111,6 +111,7 @@ BEGIN_DECLARE_SIM_OBJECT_PARAMS(FreebsdAlphaSystem)
Param<string> boot_osflags;
Param<string> readfile;
Param<string> symbolfile;
Param<unsigned int> init_param;
Param<uint64_t> system_type;
@ -133,6 +134,7 @@ BEGIN_INIT_SIM_OBJECT_PARAMS(FreebsdAlphaSystem)
INIT_PARAM_DFLT(boot_osflags, "flags to pass to the kernel during boot",
"a"),
INIT_PARAM_DFLT(readfile, "file to read startup script from", ""),
INIT_PARAM_DFLT(symbolfile, "file to read symbols from", ""),
INIT_PARAM_DFLT(init_param, "numerical value to pass into simulator", 0),
INIT_PARAM_DFLT(system_type, "Type of system we are emulating", 34),
INIT_PARAM_DFLT(system_rev, "Revision of system we are emulating", 1<<10),
@ -155,6 +157,7 @@ CREATE_SIM_OBJECT(FreebsdAlphaSystem)
p->boot_osflags = boot_osflags;
p->init_param = init_param;
p->readfile = readfile;
p->symbolfile = symbolfile;
p->system_type = system_type;
p->system_rev = system_rev;
p->bin = bin;

View file

@ -785,6 +785,9 @@ decode OPCODE default Unknown::unknown() {
AlphaPseudo::m5exit(xc->xcBase(), R16);
}}, No_OpClass, IsNonSpeculative);
0x30: initparam({{ Ra = xc->xcBase()->getCpuPtr()->system->init_param; }});
0x31: loadsymbol({{
AlphaPseudo::loadsymbol(xc->xcBase());
}}, No_OpClass, IsNonSpeculative);
0x40: resetstats({{
AlphaPseudo::resetstats(xc->xcBase(), R16, R17);
}}, IsNonSpeculative);

View file

@ -233,6 +233,7 @@ BEGIN_DECLARE_SIM_OBJECT_PARAMS(LinuxAlphaSystem)
Param<string> boot_osflags;
Param<string> readfile;
Param<string> symbolfile;
Param<unsigned int> init_param;
Param<uint64_t> system_type;
@ -255,6 +256,7 @@ BEGIN_INIT_SIM_OBJECT_PARAMS(LinuxAlphaSystem)
INIT_PARAM_DFLT(boot_osflags, "flags to pass to the kernel during boot",
"a"),
INIT_PARAM_DFLT(readfile, "file to read startup script from", ""),
INIT_PARAM_DFLT(symbolfile, "file to read symbols from", ""),
INIT_PARAM_DFLT(init_param, "numerical value to pass into simulator", 0),
INIT_PARAM_DFLT(system_type, "Type of system we are emulating", 34),
INIT_PARAM_DFLT(system_rev, "Revision of system we are emulating", 1<<10),
@ -277,6 +279,7 @@ CREATE_SIM_OBJECT(LinuxAlphaSystem)
p->boot_osflags = boot_osflags;
p->init_param = init_param;
p->readfile = readfile;
p->symbolfile = symbolfile;
p->system_type = system_type;
p->system_rev = system_rev;
p->bin = bin;

View file

@ -242,6 +242,7 @@ BEGIN_DECLARE_SIM_OBJECT_PARAMS(AlphaSystem)
Param<std::string> boot_osflags;
Param<std::string> readfile;
Param<std::string> symbolfile;
Param<unsigned int> init_param;
Param<uint64_t> system_type;
@ -264,6 +265,7 @@ BEGIN_INIT_SIM_OBJECT_PARAMS(AlphaSystem)
INIT_PARAM_DFLT(boot_osflags, "flags to pass to the kernel during boot",
"a"),
INIT_PARAM_DFLT(readfile, "file to read startup script from", ""),
INIT_PARAM_DFLT(symbolfile, "file to read symbols from", ""),
INIT_PARAM_DFLT(init_param, "numerical value to pass into simulator", 0),
INIT_PARAM_DFLT(system_type, "Type of system we are emulating", 34),
INIT_PARAM_DFLT(system_rev, "Revision of system we are emulating", 1<<10),
@ -286,6 +288,7 @@ CREATE_SIM_OBJECT(AlphaSystem)
p->boot_osflags = boot_osflags;
p->init_param = init_param;
p->readfile = readfile;
p->symbolfile = symbolfile;
p->system_type = system_type;
p->system_rev = system_rev;
p->bin = bin;

View file

@ -105,6 +105,7 @@ BEGIN_DECLARE_SIM_OBJECT_PARAMS(Tru64AlphaSystem)
Param<string> boot_osflags;
Param<string> readfile;
Param<string> symbolfile;
Param<unsigned int> init_param;
Param<uint64_t> system_type;
@ -126,6 +127,7 @@ BEGIN_INIT_SIM_OBJECT_PARAMS(Tru64AlphaSystem)
INIT_PARAM_DFLT(boot_osflags, "flags to pass to the kernel during boot",
"a"),
INIT_PARAM_DFLT(readfile, "file to read startup script from", ""),
INIT_PARAM_DFLT(symbolfile, "file to read symbols from", ""),
INIT_PARAM_DFLT(init_param, "numerical value to pass into simulator", 0),
INIT_PARAM_DFLT(system_type, "Type of system we are emulating", 12),
INIT_PARAM_DFLT(system_rev, "Revision of system we are emulating", 2<<1),
@ -147,6 +149,7 @@ CREATE_SIM_OBJECT(Tru64AlphaSystem)
p->boot_osflags = boot_osflags;
p->init_param = init_param;
p->readfile = readfile;
p->symbolfile = symbolfile;
p->system_type = system_type;
p->system_rev = system_rev;
p->bin = bin;

View file

@ -11,6 +11,7 @@ class System(SimObject):
binned_fns = VectorParam.String([], "functions broken down and binned")
kernel = Param.String("file that contains the kernel code")
readfile = Param.String("", "file to read startup script from")
symbolfile = Param.String("", "file to get the symbols from")
class AlphaSystem(System):
type = 'AlphaSystem'

View file

@ -149,6 +149,54 @@ namespace AlphaPseudo
SimExit(when, "m5_exit instruction encountered");
}
void
loadsymbol(ExecContext *xc)
{
const string &filename = xc->getCpuPtr()->system->params()->symbolfile;
if (filename.empty()) {
return;
}
std::string buffer;
ifstream file(filename.c_str());
if (!file)
fatal("file error: Can't open symbol table file %s\n", filename);
while (!file.eof()) {
getline(file, buffer);
if (buffer.empty())
continue;
int idx = buffer.find(' ');
if (idx == string::npos)
continue;
string address = "0x" + buffer.substr(0, idx);
eat_white(address);
if (address.empty())
continue;
// Skip over letter and space
string symbol = buffer.substr(idx + 3);
eat_white(symbol);
if (symbol.empty())
continue;
Addr addr;
if (!to_number(address, addr))
continue;
if (!xc->getSystemPtr()->kernelSymtab->insert(addr, symbol))
continue;
DPRINTF(Loader, "Loaded symbol: %s @ %#llx\n", symbol, addr);
}
file.close();
}
void
resetstats(ExecContext *xc, Tick delay, Tick period)
{

View file

@ -51,6 +51,7 @@ namespace AlphaPseudo
void ivle(ExecContext *xc);
void m5exit(ExecContext *xc, Tick delay);
void m5exit_old(ExecContext *xc);
void loadsymbol(ExecContext *xc);
void resetstats(ExecContext *xc, Tick delay, Tick period);
void dumpstats(ExecContext *xc, Tick delay, Tick period);
void dumpresetstats(ExecContext *xc, Tick delay, Tick period);

View file

@ -137,6 +137,7 @@ class System : public SimObject
std::string kernel_path;
std::string readfile;
std::string symbolfile;
};
protected:

View file

@ -30,6 +30,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "m5op.h"
@ -165,6 +166,22 @@ main(int argc, char *argv[])
}
}
if (COMPARE("readfile")) {
char buf[256*1024];
int offset = 0;
int len;
if (argc != 2)
usage();
while ((len = m5_readfile(buf, sizeof(buf), offset)) > 0) {
write(STDOUT_FILENO, buf, len);
offset += len;
}
return 0;
}
if (COMPARE("checkpoint")) {
switch (argc) {
case 4:
@ -182,5 +199,10 @@ main(int argc, char *argv[])
return 0;
}
if (COMPARE("loadsymbol")) {
m5_loadsymbol(arg1);
return 0;
}
usage();
}

View file

@ -38,6 +38,7 @@
#define exit_old_func 0x20 // deprectated!
#define exit_func 0x21
#define initparam_func 0x30
#define loadsymbol_func 0x31
#define resetstats_func 0x40
#define dumpstats_func 0x41
#define dumprststats_func 0x42
@ -72,6 +73,7 @@ func:
#define IVLE(reg) INST(m5_op, reg, 0, ivle_func)
#define M5EXIT(reg) INST(m5_op, reg, 0, exit_func)
#define INITPARAM(reg) INST(m5_op, reg, 0, initparam_func)
#define LOADSYMBOL(reg) INST(m5_op, reg, 0, loadsymbol_func)
#define RESET_STATS(r1, r2) INST(m5_op, r1, r2, resetstats_func)
#define DUMP_STATS(r1, r2) INST(m5_op, r1, r2, dumpstats_func)
#define DUMPRST_STATS(r1, r2) INST(m5_op, r1, r2, dumprststats_func)
@ -139,6 +141,12 @@ LEAF(m5_initparam)
RET
END(m5_initparam)
.align 4
LEAF(m5_loadsymbol)
LOADSYMBOL(0)
RET
END(m5_loadsymbol)
.align 4
LEAF(m5_reset_stats)
RESET_STATS(16, 17)