summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabe Black <gabeblack@google.com>2019-10-29 15:52:09 -0700
committerGabe Black <gabeblack@google.com>2019-10-30 22:29:23 +0000
commit4444e88e5b4af1f49b501f13bd13133c6422374e (patch)
treefcf8a07f2cf4004f4d2b21dbff6465ef3f244f2b
parent75d496c6b2c65ada974be3f9445ae7fb94ccef10 (diff)
downloadgem5-4444e88e5b4af1f49b501f13bd13133c6422374e.tar.xz
kern: When dumping dmesg, detect the byte order dynamically.
The dmesg dumper has access to the system object and so has access to the getGuestByteOrder accessor. Use that instead of TheISA to determine the byte order. Change-Id: I4df7b1bcd807aaced1d7dc8d2030123e2d4d1d2b Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/22365 Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Maintainer: Andreas Sandberg <andreas.sandberg@arm.com> Tested-by: kokoro <noreply+kokoro@google.com>
-rw-r--r--src/kern/linux/helpers.cc12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/kern/linux/helpers.cc b/src/kern/linux/helpers.cc
index e514ef8b3..1973a41a6 100644
--- a/src/kern/linux/helpers.cc
+++ b/src/kern/linux/helpers.cc
@@ -56,7 +56,8 @@ struct DmesgEntry {
} M5_ATTR_PACKED;
static int
-dumpDmesgEntry(const uint8_t *base, const uint8_t *end, std::ostream &os)
+dumpDmesgEntry(const uint8_t *base, const uint8_t *end, const ByteOrder bo,
+ std::ostream &os)
{
const size_t max_length = end - base;
DmesgEntry de;
@@ -67,9 +68,9 @@ dumpDmesgEntry(const uint8_t *base, const uint8_t *end, std::ostream &os)
}
memcpy(&de, base, sizeof(de));
- de.ts_nsec = TheISA::gtoh(de.ts_nsec);
- de.len = TheISA::gtoh(de.len);
- de.text_len = TheISA::gtoh(de.text_len);
+ de.ts_nsec = gtoh(de.ts_nsec, bo);
+ de.len = gtoh(de.len, bo);
+ de.text_len = gtoh(de.text_len, bo);
if (de.len < sizeof(de) ||
max_length < de.len ||
@@ -93,6 +94,7 @@ void
Linux::dumpDmesg(ThreadContext *tc, std::ostream &os)
{
System *system = tc->getSystemPtr();
+ const ByteOrder bo = system->getGuestByteOrder();
const SymbolTable *symtab = system->kernelSymtab;
PortProxy &proxy = tc->getVirtProxy();
@@ -144,7 +146,7 @@ Linux::dumpDmesg(ThreadContext *tc, std::ostream &os)
// Print dmesg buffer content
const uint8_t *cur = log_buf.data(), *end = log_buf.data() + length;
while (cur < end) {
- int ret = dumpDmesgEntry(cur, end, os);
+ int ret = dumpDmesgEntry(cur, end, bo, os);
if (ret < 0)
return;
cur += ret;