From 9980bbb9965ee2df42f94aafa817e91835dad406 Mon Sep 17 00:00:00 2001 From: Jack Veenstra Date: Tue, 5 May 2009 10:35:03 -0700 Subject: Add support for tracing Java method entry/exit to qemu. This is part of a larger change to add support for tracing Java methods. There is also a kernel change and a small change to the Dalvik interpreter that will be checked in separately. There used to be support for tracing Java methods but it relied on trapping every store and checking if the store address matched a special "magic" region (and that stopped working because we can no longer trap on loads and stores). The new approach uses a memory-mapped page to catch stores to just that page. --- hw/goldfish_trace.c | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) (limited to 'hw/goldfish_trace.c') diff --git a/hw/goldfish_trace.c b/hw/goldfish_trace.c index ad0eba5..a9f6437 100644 --- a/hw/goldfish_trace.c +++ b/hw/goldfish_trace.c @@ -42,7 +42,7 @@ static void trace_dev_write(void *opaque, target_phys_addr_t offset, uint32_t va { trace_dev_state *s = (trace_dev_state *)opaque; - offset -= s->base; + offset -= s->dev.base; switch (offset >> 2) { case TRACE_DEV_REG_SWITCH: // context switch, switch to pid trace_switch(value); @@ -202,8 +202,19 @@ static void trace_dev_write(void *opaque, target_phys_addr_t offset, uint32_t va trace_munmap(unmap_start, value); break; + case TRACE_DEV_REG_METHOD_ENTRY: + case TRACE_DEV_REG_METHOD_EXIT: + case TRACE_DEV_REG_METHOD_EXCEPTION: + if (tracing) { + int call_type = (offset - 4096) >> 2; + trace_interpreted_method(value, call_type); + } + break; + default: - cpu_abort(cpu_single_env, "trace_dev_write: Bad offset %x\n", offset); + if (offset < 4096) { + cpu_abort(cpu_single_env, "trace_dev_write: Bad offset %x\n", offset); + } break; } } @@ -213,12 +224,14 @@ static uint32_t trace_dev_read(void *opaque, target_phys_addr_t offset) { trace_dev_state *s = (trace_dev_state *)opaque; - offset -= s->base; + offset -= s->dev.base; switch (offset >> 2) { case TRACE_DEV_REG_ENABLE: // tracing enable return tracing; default: - cpu_abort(cpu_single_env, "trace_dev_read: Bad offset %x\n", offset); + if (offset < 4096) { + cpu_abort(cpu_single_env, "trace_dev_read: Bad offset %x\n", offset); + } return 0; } return 0; @@ -237,15 +250,20 @@ static CPUWriteMemoryFunc *trace_dev_writefn[] = { }; /* initialize the trace device */ -void trace_dev_init(uint32_t base) +void trace_dev_init() { int iomemtype; trace_dev_state *s; s = (trace_dev_state *)qemu_mallocz(sizeof(trace_dev_state)); - iomemtype = cpu_register_io_memory(0, trace_dev_readfn, trace_dev_writefn, s); - cpu_register_physical_memory(base, 0x00000fff, iomemtype); - s->base = base; + s->dev.name = "qemu_trace"; + s->dev.id = -1; + s->dev.base = 0; // will be allocated dynamically + s->dev.size = 0x2000; + s->dev.irq = 0; + s->dev.irq_count = 0; + + goldfish_device_add(&s->dev, trace_dev_readfn, trace_dev_writefn, s); path[0] = arg[0] = '\0'; } -- cgit v1.1