summaryrefslogtreecommitdiff
path: root/src/base/cprintf_formats.hh
diff options
context:
space:
mode:
authorGabe Black <gabeblack@google.com>2019-10-03 23:42:35 -0700
committerGabe Black <gabeblack@google.com>2019-10-08 17:45:53 +0000
commitcb1eb7e29d196cc4febca194b7d295e88c37c093 (patch)
treec50e9af05db17444417c39f0649b4563b16cd9af /src/base/cprintf_formats.hh
parent8329f4bb658e4681f4d39fbd5d053114504f1403 (diff)
downloadgem5-cb1eb7e29d196cc4febca194b7d295e88c37c093.tar.xz
base: Ensure %p format arguments are printed as pointers.
If the %p format is used, char * arguments should be printed as the hex value of their pointer, not as strings. Unfortunately blindly passing them to an ostream using << will not do that. This change adds some casting in that case to ensure that they're treated as numbers and not as strings. Change-Id: If02bae6d5e468b352266702fcba62b6beddffcbd Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/21459 Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Maintainer: Andreas Sandberg <andreas.sandberg@arm.com> Tested-by: kokoro <noreply+kokoro@google.com>
Diffstat (limited to 'src/base/cprintf_formats.hh')
-rw-r--r--src/base/cprintf_formats.hh6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/base/cprintf_formats.hh b/src/base/cprintf_formats.hh
index f55fb955e..cca41e98e 100644
--- a/src/base/cprintf_formats.hh
+++ b/src/base/cprintf_formats.hh
@@ -312,6 +312,12 @@ format_integer(std::ostream &out, unsigned char data, Format &fmt)
inline void
format_integer(std::ostream &out, signed char data, Format &fmt)
{ _format_integer(out, (int)data, fmt); }
+inline void
+format_integer(std::ostream &out, const unsigned char *data, Format &fmt)
+{ _format_integer(out, (uintptr_t)data, fmt); }
+inline void
+format_integer(std::ostream &out, const signed char *data, Format &fmt)
+{ _format_integer(out, (uintptr_t)data, fmt); }
//
// floating point formats