arch, base, sim: Replace Copy(String)?(In|Out) with equivalent code.
This expands those functions into code which extracts the virt proxy and then uses the appropriate method on it. This has two benefits. First, the Copy* functions where mostly redundant wrappers around the methods the proxy port already had. Second, using them forced a particular port which might not actually be what the user wanted. Change-Id: I62084631dd080061e3c74997125164f40da2d77c Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/18575 Reviewed-by: Jason Lowe-Power <jason@lowepower.com> Maintainer: Jason Lowe-Power <jason@lowepower.com> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
@@ -111,7 +111,7 @@ ProcessInfo::name(Addr ksp) const
|
||||
return "console";
|
||||
|
||||
char comm[256];
|
||||
CopyStringOut(tc, comm, task + name_off, sizeof(comm));
|
||||
tc->getVirtProxy().readString(comm, task + name_off, sizeof(comm));
|
||||
if (!comm[0])
|
||||
return "startup";
|
||||
|
||||
@@ -311,8 +311,7 @@ StackTrace::decodePrologue(Addr sp, Addr callpc, Addr func, int &size,
|
||||
ra = 0;
|
||||
|
||||
for (Addr pc = func; pc < callpc; pc += sizeof(MachInst)) {
|
||||
MachInst inst;
|
||||
CopyOut(tc, (uint8_t *)&inst, pc, sizeof(MachInst));
|
||||
MachInst inst = tc->getVirtProxy().read<MachInst>(pc);
|
||||
|
||||
int reg, disp;
|
||||
if (decodeStack(inst, disp)) {
|
||||
@@ -323,7 +322,7 @@ StackTrace::decodePrologue(Addr sp, Addr callpc, Addr func, int &size,
|
||||
size += disp;
|
||||
} else if (decodeSave(inst, reg, disp)) {
|
||||
if (!ra && reg == ReturnAddressReg) {
|
||||
CopyOut(tc, (uint8_t *)&ra, sp + disp, sizeof(Addr));
|
||||
ra = tc->getVirtProxy().read<Addr>(sp + disp);
|
||||
if (!ra) {
|
||||
// panic("no return address value pc=%#x\n", pc);
|
||||
return false;
|
||||
|
||||
@@ -104,7 +104,7 @@ ProcessInfo::name(Addr ksp) const
|
||||
return "unknown";
|
||||
|
||||
char comm[256];
|
||||
CopyStringOut(tc, comm, task + name_off, sizeof(comm));
|
||||
tc->getVirtProxy().readString(comm, task + name_off, sizeof(comm));
|
||||
if (!comm[0])
|
||||
return "startup";
|
||||
|
||||
|
||||
@@ -58,9 +58,7 @@ class ThreadInfo
|
||||
return false;
|
||||
}
|
||||
|
||||
CopyOut(tc, &data, addr, sizeof(T));
|
||||
|
||||
data = TheISA::gtoh(data);
|
||||
data = tc->getVirtProxy().read<T>(addr, TheISA::GuestByteOrder);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -98,29 +96,23 @@ class ThreadInfo
|
||||
// Note that in Linux 4.10 the thread_info struct will no longer have a
|
||||
// pointer to the task_struct for arm64. See:
|
||||
// https://patchwork.kernel.org/patch/9333699/
|
||||
int32_t offset;
|
||||
int32_t offset = 0;
|
||||
if (!get_data("thread_info_task", offset))
|
||||
return 0;
|
||||
|
||||
if (!thread_info)
|
||||
thread_info = curThreadInfo();
|
||||
|
||||
Addr addr;
|
||||
CopyOut(tc, &addr, thread_info + offset, sizeof(addr));
|
||||
|
||||
return addr;
|
||||
return tc->getVirtProxy().read<Addr>(thread_info + offset);
|
||||
}
|
||||
|
||||
int32_t
|
||||
curTaskPIDFromTaskStruct(Addr task_struct) {
|
||||
int32_t offset;
|
||||
int32_t offset = 0;
|
||||
if (!get_data("task_struct_pid", offset))
|
||||
return -1;
|
||||
|
||||
int32_t pid;
|
||||
CopyOut(tc, &pid, task_struct + offset, sizeof(pid));
|
||||
|
||||
return pid;
|
||||
return tc->getVirtProxy().read<int32_t>(task_struct + offset);
|
||||
}
|
||||
|
||||
int32_t
|
||||
@@ -132,14 +124,11 @@ class ThreadInfo
|
||||
int32_t
|
||||
curTaskTGIDFromTaskStruct(Addr task_struct)
|
||||
{
|
||||
int32_t offset;
|
||||
int32_t offset = 0;
|
||||
if (!get_data("task_struct_tgid", offset))
|
||||
return -1;
|
||||
|
||||
int32_t tgid;
|
||||
CopyOut(tc, &tgid, task_struct + offset, sizeof(tgid));
|
||||
|
||||
return tgid;
|
||||
return tc->getVirtProxy().read<int32_t>(task_struct + offset);
|
||||
}
|
||||
|
||||
int32_t
|
||||
@@ -151,16 +140,13 @@ class ThreadInfo
|
||||
int64_t
|
||||
curTaskStartFromTaskStruct(Addr task_struct)
|
||||
{
|
||||
int32_t offset;
|
||||
int32_t offset = 0;
|
||||
if (!get_data("task_struct_start_time", offset))
|
||||
return -1;
|
||||
|
||||
int64_t data;
|
||||
// start_time is actually of type timespec, but if we just
|
||||
// grab the first long, we'll get the seconds out of it
|
||||
CopyOut(tc, &data, task_struct + offset, sizeof(data));
|
||||
|
||||
return data;
|
||||
return tc->getVirtProxy().read<int64_t>(task_struct + offset);
|
||||
}
|
||||
|
||||
int64_t
|
||||
@@ -172,8 +158,8 @@ class ThreadInfo
|
||||
std::string
|
||||
curTaskNameFromTaskStruct(Addr task_struct)
|
||||
{
|
||||
int32_t offset;
|
||||
int32_t size;
|
||||
int32_t offset = 0;
|
||||
int32_t size = 0;
|
||||
|
||||
if (!get_data("task_struct_comm", offset))
|
||||
return "FailureIn_curTaskName";
|
||||
@@ -182,7 +168,7 @@ class ThreadInfo
|
||||
return "FailureIn_curTaskName";
|
||||
|
||||
char buffer[size + 1];
|
||||
CopyStringOut(tc, buffer, task_struct + offset, size);
|
||||
tc->getVirtProxy().readString(buffer, task_struct + offset, size);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
@@ -200,10 +186,7 @@ class ThreadInfo
|
||||
if (!get_data("task_struct_mm", offset))
|
||||
return -1;
|
||||
|
||||
int32_t mm_ptr;
|
||||
CopyOut(tc, &mm_ptr, task_struct + offset, sizeof(mm_ptr));
|
||||
|
||||
return mm_ptr;
|
||||
return tc->getVirtProxy().read<int32_t>(task_struct + offset);
|
||||
}
|
||||
|
||||
int32_t
|
||||
|
||||
@@ -84,7 +84,7 @@ ProcessInfo::name(Addr ksp) const
|
||||
return "console";
|
||||
|
||||
char comm[256];
|
||||
CopyStringOut(tc, comm, task + name_off, sizeof(comm));
|
||||
tc->getVirtProxy().readString(comm, task + name_off, sizeof(comm));
|
||||
if (!comm[0])
|
||||
return "startup";
|
||||
|
||||
@@ -202,8 +202,7 @@ StackTrace::decodePrologue(Addr sp, Addr callpc, Addr func,
|
||||
ra = 0;
|
||||
|
||||
for (Addr pc = func; pc < callpc; pc += sizeof(MachInst)) {
|
||||
MachInst inst;
|
||||
CopyOut(tc, (uint8_t *)&inst, pc, sizeof(MachInst));
|
||||
MachInst inst = tc->getVirtProxy().read<MachInst>(pc);
|
||||
|
||||
int reg, disp;
|
||||
if (decodeStack(inst, disp)) {
|
||||
@@ -213,7 +212,7 @@ StackTrace::decodePrologue(Addr sp, Addr callpc, Addr func,
|
||||
size += disp;
|
||||
} else if (decodeSave(inst, reg, disp)) {
|
||||
if (!ra && reg == ReturnAddressReg) {
|
||||
CopyOut(tc, (uint8_t *)&ra, sp + disp, sizeof(Addr));
|
||||
ra = tc->getVirtProxy().read<Addr>(sp + disp);
|
||||
if (!ra) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ ProcessInfo::name(Addr ksp) const
|
||||
return "console";
|
||||
|
||||
char comm[256];
|
||||
CopyStringOut(tc, comm, task + name_off, sizeof(comm));
|
||||
tc->getVirtProxy().readString(comm, task + name_off, sizeof(comm));
|
||||
if (!comm[0])
|
||||
return "startup";
|
||||
|
||||
@@ -164,8 +164,7 @@ StackTrace::decodePrologue(Addr sp, Addr callpc, Addr func,
|
||||
ra = 0;
|
||||
|
||||
for (Addr pc = func; pc < callpc; pc += sizeof(MachInst)) {
|
||||
MachInst inst;
|
||||
CopyOut(tc, (uint8_t *)&inst, pc, sizeof(MachInst));
|
||||
MachInst inst = tc->getVirtProxy().read<MachInst>(pc);
|
||||
|
||||
int reg, disp;
|
||||
if (decodeStack(inst, disp)) {
|
||||
@@ -176,7 +175,7 @@ StackTrace::decodePrologue(Addr sp, Addr callpc, Addr func,
|
||||
size += disp;
|
||||
} else if (decodeSave(inst, reg, disp)) {
|
||||
if (!ra && reg == ReturnAddressReg) {
|
||||
CopyOut(tc, (uint8_t *)&ra, sp + disp, sizeof(Addr));
|
||||
ra = tc->getVirtProxy().read<Addr>(sp + disp);
|
||||
if (!ra) {
|
||||
// panic("no return address value pc=%#x\n", pc);
|
||||
return false;
|
||||
|
||||
@@ -170,7 +170,7 @@ CPA::swSmBegin(ThreadContext *tc)
|
||||
debugSymbolTable->findNearestSymbol(
|
||||
tc->readIntReg(ReturnAddressReg), st, junk);
|
||||
|
||||
CopyStringOut(tc, sm, args[0], 50);
|
||||
tc->getVirtProxy().readString(sm, args[0], 50);
|
||||
System *sys = tc->getSystemPtr();
|
||||
StringWrap name(sys->name());
|
||||
|
||||
@@ -256,7 +256,7 @@ CPA::swSmEnd(ThreadContext *tc)
|
||||
|
||||
Arguments args(tc);
|
||||
char sm[50];
|
||||
CopyStringOut(tc, sm, args[0], 50);
|
||||
tc->getVirtProxy().readString(sm, args[0], 50);
|
||||
System *sys = tc->getSystemPtr();
|
||||
doSwSmEnd(sys, tc->contextId(), sm, getFrame(tc));
|
||||
}
|
||||
@@ -324,7 +324,7 @@ CPA::swExplictBegin(ThreadContext *tc)
|
||||
|
||||
Arguments args(tc);
|
||||
char st[50];
|
||||
CopyStringOut(tc, st, args[1], 50);
|
||||
tc->getVirtProxy().readString(st, args[1], 50);
|
||||
|
||||
StringWrap name(tc->getSystemPtr()->name());
|
||||
DPRINTF(Annotate, "Explict begin of state %s\n", st);
|
||||
@@ -428,7 +428,7 @@ CPA::swQ(ThreadContext *tc)
|
||||
char q[50];
|
||||
Arguments args(tc);
|
||||
uint64_t id = args[0];
|
||||
CopyStringOut(tc, q, args[1], 50);
|
||||
tc->getVirtProxy().readString(q, args[1], 50);
|
||||
int32_t count = args[2];
|
||||
System *sys = tc->getSystemPtr();
|
||||
|
||||
@@ -459,7 +459,7 @@ CPA::swDq(ThreadContext *tc)
|
||||
char q[50];
|
||||
Arguments args(tc);
|
||||
uint64_t id = args[0];
|
||||
CopyStringOut(tc, q, args[1], 50);
|
||||
tc->getVirtProxy().readString(q, args[1], 50);
|
||||
int32_t count = args[2];
|
||||
System *sys = tc->getSystemPtr();
|
||||
|
||||
@@ -488,7 +488,7 @@ CPA::swPq(ThreadContext *tc)
|
||||
char q[50];
|
||||
Arguments args(tc);
|
||||
uint64_t id = args[0];
|
||||
CopyStringOut(tc, q, args[1], 50);
|
||||
tc->getVirtProxy().readString(q, args[1], 50);
|
||||
System *sys = tc->getSystemPtr();
|
||||
int32_t count = args[2];
|
||||
|
||||
@@ -523,7 +523,7 @@ CPA::swRq(ThreadContext *tc)
|
||||
char q[50];
|
||||
Arguments args(tc);
|
||||
uint64_t id = args[0];
|
||||
CopyStringOut(tc, q, args[1], 50);
|
||||
tc->getVirtProxy().readString(q, args[1], 50);
|
||||
System *sys = tc->getSystemPtr();
|
||||
int32_t count = args[2];
|
||||
|
||||
@@ -554,7 +554,7 @@ CPA::swWf(ThreadContext *tc)
|
||||
char q[50];
|
||||
Arguments args(tc);
|
||||
uint64_t id = args[0];
|
||||
CopyStringOut(tc, q, args[1], 50);
|
||||
tc->getVirtProxy().readString(q, args[1], 50);
|
||||
System *sys = tc->getSystemPtr();
|
||||
int32_t count = args[3];
|
||||
|
||||
@@ -568,7 +568,7 @@ CPA::swWf(ThreadContext *tc)
|
||||
|
||||
if (!!args[2]) {
|
||||
char sm[50];
|
||||
CopyStringOut(tc, sm, args[2], 50);
|
||||
tc->getVirtProxy().readString(sm, args[2], 50);
|
||||
doSwSmEnd(tc->getSystemPtr(), tc->contextId(), sm, getFrame(tc));
|
||||
}
|
||||
}
|
||||
@@ -582,7 +582,7 @@ CPA::swWe(ThreadContext *tc)
|
||||
char q[50];
|
||||
Arguments args(tc);
|
||||
uint64_t id = args[0];
|
||||
CopyStringOut(tc, q, args[1], 50);
|
||||
tc->getVirtProxy().readString(q, args[1], 50);
|
||||
System *sys = tc->getSystemPtr();
|
||||
int32_t count = args[3];
|
||||
|
||||
@@ -596,7 +596,7 @@ CPA::swWe(ThreadContext *tc)
|
||||
|
||||
if (!!args[2]) {
|
||||
char sm[50];
|
||||
CopyStringOut(tc, sm, args[2], 50);
|
||||
tc->getVirtProxy().readString(sm, args[2], 50);
|
||||
doSwSmEnd(tc->getSystemPtr(), tc->contextId(), sm, getFrame(tc));
|
||||
}
|
||||
}
|
||||
@@ -610,7 +610,7 @@ CPA::swSq(ThreadContext *tc)
|
||||
char q[50];
|
||||
Arguments args(tc);
|
||||
uint64_t id = args[0];
|
||||
CopyStringOut(tc, q, args[1], 50);
|
||||
tc->getVirtProxy().readString(q, args[1], 50);
|
||||
System *sys = tc->getSystemPtr();
|
||||
StringWrap name(sys->name());
|
||||
int32_t size = args[2];
|
||||
@@ -678,7 +678,7 @@ CPA::swAq(ThreadContext *tc)
|
||||
char q[50];
|
||||
Arguments args(tc);
|
||||
uint64_t id = args[0];
|
||||
CopyStringOut(tc, q, args[1], 50);
|
||||
tc->getVirtProxy().readString(q, args[1], 50);
|
||||
System *sys = tc->getSystemPtr();
|
||||
StringWrap name(sys->name());
|
||||
int32_t size = args[2];
|
||||
@@ -714,7 +714,7 @@ CPA::swLink(ThreadContext *tc)
|
||||
|
||||
char lsm[50];
|
||||
Arguments args(tc);
|
||||
CopyStringOut(tc, lsm, args[0], 50);
|
||||
tc->getVirtProxy().readString(lsm, args[0], 50);
|
||||
System *sys = tc->getSystemPtr();
|
||||
StringWrap name(sys->name());
|
||||
|
||||
@@ -738,7 +738,7 @@ CPA::swLink(ThreadContext *tc)
|
||||
|
||||
if (!!args[2]) {
|
||||
char sm[50];
|
||||
CopyStringOut(tc, sm, args[2], 50);
|
||||
tc->getVirtProxy().readString(sm, args[2], 50);
|
||||
doSwSmEnd(tc->getSystemPtr(), tc->contextId(), sm, getFrame(tc));
|
||||
}
|
||||
}
|
||||
@@ -789,7 +789,7 @@ CPA::swSyscallLink(ThreadContext *tc)
|
||||
|
||||
char lsm[50];
|
||||
Arguments args(tc);
|
||||
CopyStringOut(tc, lsm, args[0], 50);
|
||||
tc->getVirtProxy().readString(lsm, args[0], 50);
|
||||
System *sys = tc->getSystemPtr();
|
||||
StringWrap name(sys->name());
|
||||
int sysi = getSys(sys);
|
||||
@@ -815,7 +815,7 @@ CPA::swSyscallLink(ThreadContext *tc)
|
||||
|
||||
if (!!args[1]) {
|
||||
char sm[50];
|
||||
CopyStringOut(tc, sm, args[1], 50);
|
||||
tc->getVirtProxy().readString(sm, args[1], 50);
|
||||
doSwSmEnd(tc->getSystemPtr(), tc->contextId(), sm, getFrame(tc));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,10 +34,9 @@
|
||||
#include <cassert>
|
||||
#include <memory>
|
||||
|
||||
#include "cpu/thread_context.hh"
|
||||
#include "mem/fs_translating_port_proxy.hh"
|
||||
|
||||
class ThreadContext;
|
||||
|
||||
class Arguments
|
||||
{
|
||||
protected:
|
||||
@@ -137,13 +136,13 @@ class Arguments
|
||||
template <class T>
|
||||
operator T *() {
|
||||
T *buf = (T *)data->alloc(sizeof(T));
|
||||
CopyOut(tc, buf, getArg(sizeof(T)), sizeof(T));
|
||||
tc->getVirtProxy().readBlob(getArg(sizeof(T)), buf, sizeof(T));
|
||||
return buf;
|
||||
}
|
||||
|
||||
operator char *() {
|
||||
char *buf = data->alloc(2048);
|
||||
CopyStringOut(tc, buf, getArg(), 2048);
|
||||
tc->getVirtProxy().readString(buf, getArg(), 2048);
|
||||
return buf;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -377,9 +377,8 @@ addsymbol(ThreadContext *tc, Addr addr, Addr symbolAddr)
|
||||
if (!FullSystem)
|
||||
panicFsOnlyPseudoInst("addSymbol");
|
||||
|
||||
char symb[100];
|
||||
CopyStringOut(tc, symb, symbolAddr, 100);
|
||||
std::string symbol(symb);
|
||||
std::string symbol;
|
||||
tc->getVirtProxy().readString(symbol, symbolAddr);
|
||||
|
||||
DPRINTF(Loader, "Loaded symbol: %s @ %#llx\n", symbol, addr);
|
||||
|
||||
@@ -525,7 +524,7 @@ readfile(ThreadContext *tc, Addr vaddr, uint64_t len, uint64_t offset)
|
||||
}
|
||||
|
||||
close(fd);
|
||||
CopyIn(tc, vaddr, buf, result);
|
||||
tc->getVirtProxy().writeBlob(vaddr, buf, result);
|
||||
delete [] buf;
|
||||
return result;
|
||||
}
|
||||
@@ -538,10 +537,8 @@ writefile(ThreadContext *tc, Addr vaddr, uint64_t len, uint64_t offset,
|
||||
vaddr, len, offset, filename_addr);
|
||||
|
||||
// copy out target filename
|
||||
char fn[100];
|
||||
std::string filename;
|
||||
CopyStringOut(tc, fn, filename_addr, 100);
|
||||
filename = std::string(fn);
|
||||
tc->getVirtProxy().readString(filename, filename_addr);
|
||||
|
||||
OutputStream *out;
|
||||
if (offset == 0) {
|
||||
@@ -563,7 +560,7 @@ writefile(ThreadContext *tc, Addr vaddr, uint64_t len, uint64_t offset,
|
||||
|
||||
// copy out data and write to file
|
||||
char *buf = new char[len];
|
||||
CopyOut(tc, buf, vaddr, len);
|
||||
tc->getVirtProxy().readBlob(vaddr, buf, len);
|
||||
os->write(buf, len);
|
||||
if (os->fail() || os->bad())
|
||||
panic("Error while doing writefile!\n");
|
||||
|
||||
Reference in New Issue
Block a user