trace: use addresses instead of offsets in memory tracepoints

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 <hollis_blanchard@mentor.com>
Message-id: 1454976185-30095-3-git-send-email-hollis_blanchard@mentor.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
Hollis Blanchard 2016-02-08 16:03:05 -08:00 committed by Stefan Hajnoczi
parent 23d92d68e7
commit 4779dc1d19
2 changed files with 34 additions and 14 deletions

View File

@ -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, static MemTxResult memory_region_oldmmio_read_accessor(MemoryRegion *mr,
hwaddr addr, hwaddr addr,
uint64_t *value, 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); tmp = mr->ops->old_mmio.read[ctz32(size)](mr->opaque, addr);
if (mr->subpage) { if (mr->subpage) {
trace_memory_region_subpage_read(mr, addr, tmp, size); trace_memory_region_subpage_read(mr, addr, tmp, size);
} else { } else if (TRACE_MEMORY_REGION_OPS_READ_ENABLED) {
trace_memory_region_ops_read(mr, addr, tmp, size); hwaddr abs_addr = memory_region_to_absolute_addr(mr, addr);
trace_memory_region_ops_read(mr, abs_addr, tmp, size);
} }
*value |= (tmp & mask) << shift; *value |= (tmp & mask) << shift;
return MEMTX_OK; return MEMTX_OK;
@ -405,8 +420,9 @@ static MemTxResult memory_region_read_accessor(MemoryRegion *mr,
tmp = mr->ops->read(mr->opaque, addr, size); tmp = mr->ops->read(mr->opaque, addr, size);
if (mr->subpage) { if (mr->subpage) {
trace_memory_region_subpage_read(mr, addr, tmp, size); trace_memory_region_subpage_read(mr, addr, tmp, size);
} else { } else if (TRACE_MEMORY_REGION_OPS_READ_ENABLED) {
trace_memory_region_ops_read(mr, addr, tmp, size); hwaddr abs_addr = memory_region_to_absolute_addr(mr, addr);
trace_memory_region_ops_read(mr, abs_addr, tmp, size);
} }
*value |= (tmp & mask) << shift; *value |= (tmp & mask) << shift;
return MEMTX_OK; 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); r = mr->ops->read_with_attrs(mr->opaque, addr, &tmp, size, attrs);
if (mr->subpage) { if (mr->subpage) {
trace_memory_region_subpage_read(mr, addr, tmp, size); trace_memory_region_subpage_read(mr, addr, tmp, size);
} else { } else if (TRACE_MEMORY_REGION_OPS_READ_ENABLED) {
trace_memory_region_ops_read(mr, addr, tmp, size); hwaddr abs_addr = memory_region_to_absolute_addr(mr, addr);
trace_memory_region_ops_read(mr, abs_addr, tmp, size);
} }
*value |= (tmp & mask) << shift; *value |= (tmp & mask) << shift;
return r; return r;
@ -446,8 +463,9 @@ static MemTxResult memory_region_oldmmio_write_accessor(MemoryRegion *mr,
tmp = (*value >> shift) & mask; tmp = (*value >> shift) & mask;
if (mr->subpage) { if (mr->subpage) {
trace_memory_region_subpage_write(mr, addr, tmp, size); trace_memory_region_subpage_write(mr, addr, tmp, size);
} else { } else if (TRACE_MEMORY_REGION_OPS_WRITE_ENABLED) {
trace_memory_region_ops_write(mr, addr, tmp, size); 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); mr->ops->old_mmio.write[ctz32(size)](mr->opaque, addr, tmp);
return MEMTX_OK; return MEMTX_OK;
@ -466,8 +484,9 @@ static MemTxResult memory_region_write_accessor(MemoryRegion *mr,
tmp = (*value >> shift) & mask; tmp = (*value >> shift) & mask;
if (mr->subpage) { if (mr->subpage) {
trace_memory_region_subpage_write(mr, addr, tmp, size); trace_memory_region_subpage_write(mr, addr, tmp, size);
} else { } else if (TRACE_MEMORY_REGION_OPS_WRITE_ENABLED) {
trace_memory_region_ops_write(mr, addr, tmp, size); 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); mr->ops->write(mr->opaque, addr, tmp, size);
return MEMTX_OK; return MEMTX_OK;
@ -486,8 +505,9 @@ static MemTxResult memory_region_write_with_attrs_accessor(MemoryRegion *mr,
tmp = (*value >> shift) & mask; tmp = (*value >> shift) & mask;
if (mr->subpage) { if (mr->subpage) {
trace_memory_region_subpage_write(mr, addr, tmp, size); trace_memory_region_subpage_write(mr, addr, tmp, size);
} else { } else if (TRACE_MEMORY_REGION_OPS_WRITE_ENABLED) {
trace_memory_region_ops_write(mr, addr, tmp, size); 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); return mr->ops->write_with_attrs(mr->opaque, addr, tmp, size, attrs);
} }

View File

@ -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" translate_block(void *tb, uintptr_t pc, uint8_t *tb_code) "tb:%p, pc:0x%"PRIxPTR", tb_code:%p"
# memory.c # 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_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 offset, uint64_t value, unsigned size) "mr %p offset %#"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_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" memory_region_subpage_write(void *mr, uint64_t offset, uint64_t value, unsigned size) "mr %p offset %#"PRIx64" value %#"PRIx64" size %u"