[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 04/13] trace: use addresses instead of offsets in mem
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PULL 04/13] trace: use addresses instead of offsets in memory tracepoints |
Date: |
Tue, 1 Mar 2016 15:48:05 +0000 |
From: Hollis Blanchard <address@hidden>
When memory_region_ops tracepoints are enabled, calculate and record the
absolute address being accessed. Otherwise, we only get offsets into the
memory region instead of addresses.
[Fixed "offset" -> "addr" in trace event format strings.
--Stefan]
Signed-off-by: Hollis Blanchard <address@hidden>
Message-id: address@hidden
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
memory.c | 44 ++++++++++++++++++++++++++++++++------------
trace-events | 4 ++--
2 files changed, 34 insertions(+), 14 deletions(-)
diff --git a/memory.c b/memory.c
index 86ffd53..013c2ed 100644
--- a/memory.c
+++ b/memory.c
@@ -372,6 +372,20 @@ static void adjust_endianness(MemoryRegion *mr, uint64_t
*data, unsigned size)
}
}
+static hwaddr memory_region_to_absolute_addr(MemoryRegion *mr, hwaddr offset)
+{
+ MemoryRegion *root;
+ hwaddr abs_addr = offset;
+
+ abs_addr += mr->addr;
+ for (root = mr; root->container; ) {
+ root = root->container;
+ abs_addr += root->addr;
+ }
+
+ return abs_addr;
+}
+
static MemTxResult memory_region_oldmmio_read_accessor(MemoryRegion *mr,
hwaddr addr,
uint64_t *value,
@@ -385,8 +399,9 @@ static MemTxResult
memory_region_oldmmio_read_accessor(MemoryRegion *mr,
tmp = mr->ops->old_mmio.read[ctz32(size)](mr->opaque, addr);
if (mr->subpage) {
trace_memory_region_subpage_read(mr, addr, tmp, size);
- } else {
- trace_memory_region_ops_read(mr, addr, tmp, size);
+ } else if (TRACE_MEMORY_REGION_OPS_READ_ENABLED) {
+ hwaddr abs_addr = memory_region_to_absolute_addr(mr, addr);
+ trace_memory_region_ops_read(mr, abs_addr, tmp, size);
}
*value |= (tmp & mask) << shift;
return MEMTX_OK;
@@ -405,8 +420,9 @@ static MemTxResult
memory_region_read_accessor(MemoryRegion *mr,
tmp = mr->ops->read(mr->opaque, addr, size);
if (mr->subpage) {
trace_memory_region_subpage_read(mr, addr, tmp, size);
- } else {
- trace_memory_region_ops_read(mr, addr, tmp, size);
+ } else if (TRACE_MEMORY_REGION_OPS_READ_ENABLED) {
+ hwaddr abs_addr = memory_region_to_absolute_addr(mr, addr);
+ trace_memory_region_ops_read(mr, abs_addr, tmp, size);
}
*value |= (tmp & mask) << shift;
return MEMTX_OK;
@@ -426,8 +442,9 @@ static MemTxResult
memory_region_read_with_attrs_accessor(MemoryRegion *mr,
r = mr->ops->read_with_attrs(mr->opaque, addr, &tmp, size, attrs);
if (mr->subpage) {
trace_memory_region_subpage_read(mr, addr, tmp, size);
- } else {
- trace_memory_region_ops_read(mr, addr, tmp, size);
+ } else if (TRACE_MEMORY_REGION_OPS_READ_ENABLED) {
+ hwaddr abs_addr = memory_region_to_absolute_addr(mr, addr);
+ trace_memory_region_ops_read(mr, abs_addr, tmp, size);
}
*value |= (tmp & mask) << shift;
return r;
@@ -446,8 +463,9 @@ static MemTxResult
memory_region_oldmmio_write_accessor(MemoryRegion *mr,
tmp = (*value >> shift) & mask;
if (mr->subpage) {
trace_memory_region_subpage_write(mr, addr, tmp, size);
- } else {
- trace_memory_region_ops_write(mr, addr, tmp, size);
+ } else if (TRACE_MEMORY_REGION_OPS_WRITE_ENABLED) {
+ hwaddr abs_addr = memory_region_to_absolute_addr(mr, addr);
+ trace_memory_region_ops_write(mr, abs_addr, tmp, size);
}
mr->ops->old_mmio.write[ctz32(size)](mr->opaque, addr, tmp);
return MEMTX_OK;
@@ -466,8 +484,9 @@ static MemTxResult
memory_region_write_accessor(MemoryRegion *mr,
tmp = (*value >> shift) & mask;
if (mr->subpage) {
trace_memory_region_subpage_write(mr, addr, tmp, size);
- } else {
- trace_memory_region_ops_write(mr, addr, tmp, size);
+ } else if (TRACE_MEMORY_REGION_OPS_WRITE_ENABLED) {
+ hwaddr abs_addr = memory_region_to_absolute_addr(mr, addr);
+ trace_memory_region_ops_write(mr, abs_addr, tmp, size);
}
mr->ops->write(mr->opaque, addr, tmp, size);
return MEMTX_OK;
@@ -486,8 +505,9 @@ static MemTxResult
memory_region_write_with_attrs_accessor(MemoryRegion *mr,
tmp = (*value >> shift) & mask;
if (mr->subpage) {
trace_memory_region_subpage_write(mr, addr, tmp, size);
- } else {
- trace_memory_region_ops_write(mr, addr, tmp, size);
+ } else if (TRACE_MEMORY_REGION_OPS_WRITE_ENABLED) {
+ hwaddr abs_addr = memory_region_to_absolute_addr(mr, addr);
+ trace_memory_region_ops_write(mr, abs_addr, tmp, size);
}
return mr->ops->write_with_attrs(mr->opaque, addr, tmp, size, attrs);
}
diff --git a/trace-events b/trace-events
index 021211d..6fba6cc 100644
--- a/trace-events
+++ b/trace-events
@@ -1620,8 +1620,8 @@ disable exec_tb_exit(void *next_tb, unsigned int flags)
"tb:%p flags=%x"
translate_block(void *tb, uintptr_t pc, uint8_t *tb_code) "tb:%p,
pc:0x%"PRIxPTR", tb_code:%p"
# memory.c
-memory_region_ops_read(void *mr, uint64_t offset, uint64_t value, unsigned
size) "mr %p offset %#"PRIx64" value %#"PRIx64" size %u"
-memory_region_ops_write(void *mr, uint64_t offset, uint64_t value, unsigned
size) "mr %p offset %#"PRIx64" value %#"PRIx64" size %u"
+memory_region_ops_read(void *mr, uint64_t addr, uint64_t value, unsigned size)
"mr %p addr %#"PRIx64" value %#"PRIx64" size %u"
+memory_region_ops_write(void *mr, uint64_t addr, uint64_t value, unsigned
size) "mr %p addr %#"PRIx64" value %#"PRIx64" size %u"
memory_region_subpage_read(void *mr, uint64_t offset, uint64_t value, unsigned
size) "mr %p offset %#"PRIx64" value %#"PRIx64" size %u"
memory_region_subpage_write(void *mr, uint64_t offset, uint64_t value,
unsigned size) "mr %p offset %#"PRIx64" value %#"PRIx64" size %u"
--
2.5.0
- [Qemu-devel] [PULL 00/13] Tracing patches, Stefan Hajnoczi, 2016/03/01
- [Qemu-devel] [PULL 02/13] trace: docs: "simple" backend does support strings, Stefan Hajnoczi, 2016/03/01
- [Qemu-devel] [PULL 01/13] trace: drop trailing empty strings, Stefan Hajnoczi, 2016/03/01
- [Qemu-devel] [PULL 06/13] trace: Extend API to manage event arguments, Stefan Hajnoczi, 2016/03/01
- [Qemu-devel] [PULL 04/13] trace: use addresses instead of offsets in memory tracepoints,
Stefan Hajnoczi <=
- [Qemu-devel] [PULL 03/13] trace: split subpage MMIOs into their own trace events., Stefan Hajnoczi, 2016/03/01
- [Qemu-devel] [PULL 05/13] vl: fix tracing initialization, Stefan Hajnoczi, 2016/03/01
- [Qemu-devel] [PULL 07/13] trace: Remove unnecessary intermediate event copies, Stefan Hajnoczi, 2016/03/01
- [Qemu-devel] [PULL 08/13] tcg: Add type for vCPU pointers, Stefan Hajnoczi, 2016/03/01
- [Qemu-devel] [PULL 10/13] trace: Add helper function to cast event arguments, Stefan Hajnoczi, 2016/03/01
- [Qemu-devel] [PULL 11/13] typedefs: Add CPUState, Stefan Hajnoczi, 2016/03/01
- [Qemu-devel] [PULL 09/13] tcg: Move definition of type TCGv, Stefan Hajnoczi, 2016/03/01
- [Qemu-devel] [PULL 12/13] trace: Add 'vcpu' event property to trace guest vCPU, Stefan Hajnoczi, 2016/03/01
- [Qemu-devel] [PULL 13/13] trace: Add a proper API to manage auto-generated events from the 'tcg' property, Stefan Hajnoczi, 2016/03/01
- Re: [Qemu-devel] [PULL 00/13] Tracing patches, Peter Maydell, 2016/03/01