diff options
author | Gabe Black <gabeblack@google.com> | 2019-10-03 23:42:35 -0700 |
---|---|---|
committer | Gabe Black <gabeblack@google.com> | 2019-10-08 17:45:53 +0000 |
commit | cb1eb7e29d196cc4febca194b7d295e88c37c093 (patch) | |
tree | c50e9af05db17444417c39f0649b4563b16cd9af /src/base | |
parent | 8329f4bb658e4681f4d39fbd5d053114504f1403 (diff) | |
download | gem5-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')
-rw-r--r-- | src/base/cprintf_formats.hh | 6 |
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 |