[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2] memory: simple memory tree printer
From: |
Blue Swirl |
Subject: |
[Qemu-devel] [PATCH v2] memory: simple memory tree printer |
Date: |
Sat, 17 Sep 2011 19:27:46 +0000 |
Add a monitor command 'info mtree' to show the memory hierarchy
much like /proc/iomem in Linux.
Signed-off-by: Blue Swirl <address@hidden>
---
v1->v2: use /proc/iomem format.
---
memory.c | 27 +++++++++++++++++++++++++++
memory.h | 2 ++
monitor.c | 7 +++++++
3 files changed, 36 insertions(+), 0 deletions(-)
diff --git a/memory.c b/memory.c
index 101b67c..275f5cf 100644
--- a/memory.c
+++ b/memory.c
@@ -17,6 +17,7 @@
#include "bitops.h"
#include "kvm.h"
#include <assert.h>
+#include "monitor.h"
unsigned memory_region_transaction_depth = 0;
@@ -1253,3 +1254,29 @@ void set_system_io_map(MemoryRegion *mr)
address_space_io.root = mr;
memory_region_update_topology();
}
+
+static void mtree_print_mr(Monitor *mon, MemoryRegion *mr, unsigned int level)
+{
+ MemoryRegion *submr;
+ unsigned int i;
+
+ for (i = 0; i < level; i++) {
+ monitor_printf(mon, " ");
+ }
+ monitor_printf(mon, TARGET_FMT_plx "-" TARGET_FMT_plx " : %s\n",
+ mr->addr, mr->addr + (target_phys_addr_t)mr->size - 1,
+ mr->name);
+
+ QTAILQ_FOREACH(submr, &mr->subregions, subregions_link) {
+ mtree_print_mr(mon, submr, level + 1);
+ }
+}
+
+void mtree_info(Monitor *mon)
+{
+ monitor_printf(mon, "memory\n");
+ mtree_print_mr(mon, address_space_memory.root, 0);
+
+ monitor_printf(mon, "I/O\n");
+ mtree_print_mr(mon, address_space_io.root, 0);
+}
diff --git a/memory.h b/memory.h
index 06b83ae..09d8e29 100644
--- a/memory.h
+++ b/memory.h
@@ -500,6 +500,8 @@ void memory_region_transaction_begin(void);
*/
void memory_region_transaction_commit(void);
+void mtree_info(Monitor *mon);
+
#endif
#endif
diff --git a/monitor.c b/monitor.c
index 03ae997..0302446 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2968,6 +2968,13 @@ static const mon_cmd_t info_cmds[] = {
},
#endif
{
+ .name = "mtree",
+ .args_type = "",
+ .params = "",
+ .help = "show memory tree",
+ .mhandler.info = mtree_info,
+ },
+ {
.name = "jit",
.args_type = "",
.params = "",
--
1.6.2.4
- [Qemu-devel] [PATCH v2] memory: simple memory tree printer,
Blue Swirl <=