From a5f06abe9821161930ee50e3a7d71d43937dbf6f Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Wed, 24 Apr 2019 17:13:37 -0700 Subject: [PATCH] arm: Factor some repetition out of the ProcessInfo constructor. Change-Id: I34f952d1097886704d37304478de125a915b2615 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/18371 Tested-by: kokoro Reviewed-by: Anthony Gutierrez Reviewed-by: Jason Lowe-Power Maintainer: Jason Lowe-Power --- src/arch/arm/stacktrace.cc | 44 ++++++++++++-------------------------- 1 file changed, 14 insertions(+), 30 deletions(-) diff --git a/src/arch/arm/stacktrace.cc b/src/arch/arm/stacktrace.cc index 0033876a0..de5777554 100644 --- a/src/arch/arm/stacktrace.cc +++ b/src/arch/arm/stacktrace.cc @@ -44,42 +44,26 @@ namespace ArmISA { -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(addr); - - if (!tc->getSystemPtr()->kernelSymtab->findAddress( - "task_struct_size", addr)) { - panic("thread info not compiled into kernel\n"); - } - task_struct_size = vp.readGtoH(addr); - - if (!tc->getSystemPtr()->kernelSymtab->findAddress( - "thread_info_task", addr)) { + Addr addr; + if (!symtab->findAddress(name, addr)) panic("thread info not compiled into kernel\n"); - } - task_off = vp.readGtoH(addr); - if (!tc->getSystemPtr()->kernelSymtab->findAddress( - "task_struct_pid", addr)) { - panic("thread info not compiled into kernel\n"); - } - pid_off = vp.readGtoH(addr); + return vp.readGtoH(addr); +} - if (!tc->getSystemPtr()->kernelSymtab->findAddress( - "task_struct_comm", addr)) { - panic("thread info not compiled into kernel\n"); - } - name_off = vp.readGtoH(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 -- 2.30.2