Skip to contentSkip to conversation

Inserting Memory Watch points

Qemu-devel Taimoor Mirza 2 participants 2 messages Apr 19, 2010

lore
Share & tools
lore
#0 lore raw

Hi all,

I've developed an application for ARM intergrator and it is running find under QEMU. I am trying to redirect my serial data to my custom emulated device. For that I've inserted memory watch point at Pl011 UART controllers Data Register so that whenever some access is made to this register my registered function gets invoked which will redirect request to my custom emulated device.

I've few questions:
cpu_watchpoint_insert needs a CPU_State parameter. From where can I get this CPU state.I tried putting code in vl.c and called my custom_init function from main before main_loop(). Below is source code of my custom_init function:
static void custom_init()

{
    CPUState *env;
    int err = 0;

    for (env = first_cpu; env != NULL; env = env->next_cpu) {
    err = cpu_watchpoint_insert(env,369098752,8,BP_MEM_WRITE,NULL);
    if (err)
           printf("\n Got an error while inserting watchpoint");
    }
    qemu_add_vm_change_state_handler(myfunc,NULL);

}

This function gets called and does not return error, but when I run my application it gives me following error of segmentation fault:

VNC server running on `127.0.0.1:5900'

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1208740160 (LWP 1912)]
gdb_set_stop_cpu (env=0x9ef36a0) at /usr/QEMU_Learning/QEMU_Src/qemu-0.12.3/gdbstub.c:2114
2114 gdbserver_state->c_cpu = env;
(gdb) p env
$1 = (struct CPUARMState *) 0x9ef36a0
(gdb) p gdbserver_state->c_cpu
Cannot access memory at address 0x0

Can anybody tell me whats wrong with this?

Thanks,
Taimoor

_________________________________________________________________
Hotmail: Trusted email with Microsoft’s powerful SPAM protection.
https://signup.live.com/signup.aspx?id=60969

#1 lore raw
Quoted 10 lines · Taimoor Mirza

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1208740160 (LWP 1912)]
gdb_set_stop_cpu (env=0x9ef36a0) at /usr/QEMU_Learning/QEMU_Src/qemu-0.12.3/gdbstub.c:2114
2114 gdbserver_state->c_cpu = env;
(gdb) p env
$1 = (struct CPUARMState *) 0x9ef36a0
(gdb) p gdbserver_state->c_cpu
Cannot access memory at address 0x0

Can anybody tell me whats wrong with this?

gdbserver_state is NULL. You need to start QEMU with the -gdb switch and connect to it via GDB for cpu_watchpoint_insert to work.

-Nathan