summaryrefslogtreecommitdiff
path: root/src/base/trie.hh
diff options
context:
space:
mode:
authorGabe Black <gabeblack@google.com>2017-12-03 01:51:53 -0800
committerGabe Black <gabeblack@google.com>2017-12-04 23:18:46 +0000
commit0778fbbd4b716d4f9ca71355bf686e76b4165c23 (patch)
tree191874fce9ccb914c16f103de9686c4bb5f0392c /src/base/trie.hh
parent1088f0c4ac3999fc3c363cc51daef4cfb360a2bd (diff)
downloadgem5-0778fbbd4b716d4f9ca71355bf686e76b4165c23.tar.xz
base: Rework the trie dump function to accept a different ostream.
It might often be useful to write output to cout when dumping a trie, but sometimes it might be useful to dump ot to something else like a string stream instead. Change-Id: Iaa4ae772c902b7dbc753f320d1a7eb5fcd4a3db3 Reviewed-on: https://gem5-review.googlesource.com/6266 Reviewed-by: Brandon Potter <Brandon.Potter@amd.com> Maintainer: Gabe Black <gabeblack@google.com>
Diffstat (limited to 'src/base/trie.hh')
-rw-r--r--src/base/trie.hh28
1 files changed, 15 insertions, 13 deletions
diff --git a/src/base/trie.hh b/src/base/trie.hh
index e256377c1..ac6045601 100644
--- a/src/base/trie.hh
+++ b/src/base/trie.hh
@@ -32,6 +32,7 @@
#define __BASE_TRIE_HH__
#include <cassert>
+#include <iostream>
#include "base/cprintf.hh"
#include "base/logging.hh"
@@ -82,20 +83,21 @@ class Trie
}
void
- dump(int level)
+ dump(std::ostream &os, int level)
{
for (int i = 1; i < level; i++) {
- cprintf("|");
+ ccprintf(os, "|");
}
if (level == 0)
- cprintf("Root ");
+ ccprintf(os, "Root ");
else
- cprintf("+ ");
- cprintf("(%p, %p, %#X, %#X, %p)\n", parent, this, key, mask, value);
+ ccprintf(os, "+ ");
+ ccprintf(os, "(%p, %p, %#X, %#X, %p)\n",
+ parent, this, key, mask, value);
if (kids[0])
- kids[0]->dump(level + 1);
+ kids[0]->dump(os, level + 1);
if (kids[1])
- kids[1]->dump(level + 1);
+ kids[1]->dump(os, level + 1);
}
};
@@ -351,13 +353,13 @@ class Trie
* @param title An identifying title to put in the dump header.
*/
void
- dump(const char *title)
+ dump(const char *title, std::ostream &os=std::cout)
{
- cprintf("**************************************************\n");
- cprintf("*** Start of Trie: %s\n", title);
- cprintf("*** (parent, me, key, mask, value pointer)\n");
- cprintf("**************************************************\n");
- head.dump(0);
+ ccprintf(os, "**************************************************\n");
+ ccprintf(os, "*** Start of Trie: %s\n", title);
+ ccprintf(os, "*** (parent, me, key, mask, value pointer)\n");
+ ccprintf(os, "**************************************************\n");
+ head.dump(os, 0);
}
};