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
This commit is contained in:
Tobias Stumpf
2014-09-23 19:14:04 +02:00
parent d962a322ea
commit 744ae1b7d7

View File

@ -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);