diff options
author | Gabe Black <gabeblack@google.com> | 2019-04-24 17:04:16 -0700 |
---|---|---|
committer | Gabe Black <gabeblack@google.com> | 2019-04-25 21:34:32 +0000 |
commit | 50311fef27479cb502f3a76d10028f4f2f42d8c8 (patch) | |
tree | ebc029364265d2b08ecb37225ee2ae98f0a4e5f6 /src/arch/x86 | |
parent | ae3a00cd1fd8a0500a9d8be96c9b176a0326b133 (diff) | |
download | gem5-50311fef27479cb502f3a76d10028f4f2f42d8c8.tar.xz |
x86: Refactor the ProcessInfo constructor.
That function had a lot of repetition which is easily factored out
into its own function.
Change-Id: I3b7a522de2ba808856bb59df75b80efde6780e3f
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/18369
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Anthony Gutierrez <anthony.gutierrez@amd.com>
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Maintainer: Jason Lowe-Power <jason@lowepower.com>
Diffstat (limited to 'src/arch/x86')
-rw-r--r-- | src/arch/x86/stacktrace.cc | 49 |
1 files changed, 16 insertions, 33 deletions
diff --git a/src/arch/x86/stacktrace.cc b/src/arch/x86/stacktrace.cc index 70285e142..cdfd64b78 100644 --- a/src/arch/x86/stacktrace.cc +++ b/src/arch/x86/stacktrace.cc @@ -41,46 +41,29 @@ #include "mem/fs_translating_port_proxy.hh" #include "sim/system.hh" -using namespace std; namespace X86ISA { -ProcessInfo::ProcessInfo(ThreadContext *_tc) - : tc(_tc) +static int32_t +readSymbol(ThreadContext *tc, const std::string name) { - Addr addr = 0; - FSTranslatingPortProxy &vp = tc->getVirtProxy(); + SymbolTable *symtab = tc->getSystemPtr()->kernelSymtab; - if (!tc->getSystemPtr()->kernelSymtab->findAddress( - "thread_info_size", addr)) { - panic("thread info not compiled into kernel\n"); - } - thread_info_size = vp.readGtoH<int32_t>(addr); - - if (!tc->getSystemPtr()->kernelSymtab->findAddress( - "task_struct_size", addr)) { + Addr addr; + if (!symtab->findAddress(name, addr)) panic("thread info not compiled into kernel\n"); - } - task_struct_size = vp.readGtoH<int32_t>(addr); - if (!tc->getSystemPtr()->kernelSymtab->findAddress( - "thread_info_task", addr)) { - panic("thread info not compiled into kernel\n"); - } - task_off = vp.readGtoH<int32_t>(addr); - - if (!tc->getSystemPtr()->kernelSymtab->findAddress( - "task_struct_pid", addr)) { - panic("thread info not compiled into kernel\n"); - } - pid_off = vp.readGtoH<int32_t>(addr); + return vp.readGtoH<int32_t>(addr); +} - if (!tc->getSystemPtr()->kernelSymtab->findAddress( - "task_struct_comm", addr)) { - panic("thread info not compiled into kernel\n"); - } - name_off = vp.readGtoH<int32_t>(addr); +ProcessInfo::ProcessInfo(ThreadContext *_tc) : tc(_tc) +{ + thread_info_size = readSymbol(tc, "thread_info_size"); + task_struct_size = readSymbol(tc, "task_struct_size"); + task_off = readSymbol(tc, "thread_info_task"); + pid_off = readSymbol(tc, "task_struct_pid"); + name_off = readSymbol(tc, "task_struct_comm"); } Addr @@ -113,7 +96,7 @@ ProcessInfo::pid(Addr ksp) const return pd; } -string +std::string ProcessInfo::name(Addr ksp) const { Addr task = this->task(ksp); @@ -214,7 +197,7 @@ StackTrace::dump() DPRINTFN("------ Stack ------\n"); - string symbol; + std::string symbol; for (int i = 0, size = stack.size(); i < size; ++i) { Addr addr = stack[size - i - 1]; if (addr == user) |