Gabe Black has submitted this change and it was merged. ( https://gem5-review.googlesource.com/c/public/gem5/+/18371 )

Change subject: arm: Factor some repetition out of the ProcessInfo constructor.
......................................................................

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 <noreply+kok...@google.com>
Reviewed-by: Anthony Gutierrez <anthony.gutier...@amd.com>
Reviewed-by: Jason Lowe-Power <ja...@lowepower.com>
Maintainer: Jason Lowe-Power <ja...@lowepower.com>
---
M src/arch/arm/stacktrace.cc
1 file changed, 14 insertions(+), 30 deletions(-)

Approvals:
  Jason Lowe-Power: Looks good to me, approved; Looks good to me, approved
  Anthony Gutierrez: Looks good to me, approved
  kokoro: Regressions pass



diff --git a/src/arch/arm/stacktrace.cc b/src/arch/arm/stacktrace.cc
index 0033876..de57775 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)) {
+    Addr addr;
+    if (!symtab->findAddress(name, 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)) {
-        panic("thread info not compiled into kernel\n");
-    }
-    task_struct_size = vp.readGtoH<int32_t>(addr);
+    return 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);
-
-    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

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/18371
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: I34f952d1097886704d37304478de125a915b2615
Gerrit-Change-Number: 18371
Gerrit-PatchSet: 3
Gerrit-Owner: Gabe Black <gabebl...@google.com>
Gerrit-Reviewer: Andreas Sandberg <andreas.sandb...@arm.com>
Gerrit-Reviewer: Anthony Gutierrez <anthony.gutier...@amd.com>
Gerrit-Reviewer: Gabe Black <gabebl...@google.com>
Gerrit-Reviewer: Jason Lowe-Power <ja...@lowepower.com>
Gerrit-Reviewer: kokoro <noreply+kok...@google.com>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to