From 744ae1b7d736b288d171e300896330ed4c0b0296 Mon Sep 17 00:00:00 2001 From: Tobias Stumpf Date: Tue, 23 Sep 2014 19:14:04 +0200 Subject: [PATCH] util: hex and octal number support for MemoryMap The import-trace tool supports a memorymap file as argument. Currently the import tool accepts only decimal values, but the hexadecimal system is more common to specify a memory address or range. To avoid a manual translation between hex and dec values the patch extends the import tool to handle both types according to the prefix of a value. Change-Id: I79d0bc03ecf296dfbced8fb33518e8f5a5790366 --- src/core/util/MemoryMap.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/core/util/MemoryMap.cc b/src/core/util/MemoryMap.cc index 4429cf1b..b0155e9d 100644 --- a/src/core/util/MemoryMap.cc +++ b/src/core/util/MemoryMap.cc @@ -19,11 +19,15 @@ bool MemoryMap::readFromFile(char const * const filename) unsigned count = 0; while (getline(file, buf)) { + std::string addr, len; std::stringstream ss(buf, std::ios::in); - ss >> guest_addr >> guest_len; + ss >> addr >> len; + guest_addr = strtoul(addr.c_str(), NULL, 0); + guest_len = strtoul(len.c_str(), NULL, 0); add(guest_addr, guest_len); count++; } + // assertion kept from original code; usually something's fishy if the file // contains no entries assert(count > 0);