mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 15:23:53 -06:00
Replace the VMSTOP macros with a proper state type
Today, when notifying a VM state change with vm_state_notify(), we pass a VMSTOP macro as the 'reason' argument. This is not ideal because the VMSTOP macros tell why qemu stopped and not exactly what the current VM state is. One example to demonstrate this problem is that vm_start() calls vm_state_notify() with reason=0, which turns out to be VMSTOP_USER. This commit fixes that by replacing the VMSTOP macros with a proper state type called RunState. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
This commit is contained in:
parent
bff046f86b
commit
1dfb4dd993
24 changed files with 91 additions and 76 deletions
30
gdbstub.c
30
gdbstub.c
|
@ -2373,7 +2373,7 @@ void gdb_set_stop_cpu(CPUState *env)
|
|||
}
|
||||
|
||||
#ifndef CONFIG_USER_ONLY
|
||||
static void gdb_vm_state_change(void *opaque, int running, int reason)
|
||||
static void gdb_vm_state_change(void *opaque, int running, RunState state)
|
||||
{
|
||||
GDBState *s = gdbserver_state;
|
||||
CPUState *env = s->c_cpu;
|
||||
|
@ -2384,8 +2384,8 @@ static void gdb_vm_state_change(void *opaque, int running, int reason)
|
|||
if (running || s->state == RS_INACTIVE || s->state == RS_SYSCALL) {
|
||||
return;
|
||||
}
|
||||
switch (reason) {
|
||||
case VMSTOP_DEBUG:
|
||||
switch (state) {
|
||||
case RSTATE_DEBUG:
|
||||
if (env->watchpoint_hit) {
|
||||
switch (env->watchpoint_hit->flags & BP_MEM_ACCESS) {
|
||||
case BP_MEM_READ:
|
||||
|
@ -2408,25 +2408,25 @@ static void gdb_vm_state_change(void *opaque, int running, int reason)
|
|||
tb_flush(env);
|
||||
ret = GDB_SIGNAL_TRAP;
|
||||
break;
|
||||
case VMSTOP_USER:
|
||||
case RSTATE_PAUSED:
|
||||
ret = GDB_SIGNAL_INT;
|
||||
break;
|
||||
case VMSTOP_SHUTDOWN:
|
||||
case RSTATE_SHUTDOWN:
|
||||
ret = GDB_SIGNAL_QUIT;
|
||||
break;
|
||||
case VMSTOP_DISKFULL:
|
||||
case RSTATE_IO_ERROR:
|
||||
ret = GDB_SIGNAL_IO;
|
||||
break;
|
||||
case VMSTOP_WATCHDOG:
|
||||
case RSTATE_WATCHDOG:
|
||||
ret = GDB_SIGNAL_ALRM;
|
||||
break;
|
||||
case VMSTOP_PANIC:
|
||||
case RSTATE_PANICKED:
|
||||
ret = GDB_SIGNAL_ABRT;
|
||||
break;
|
||||
case VMSTOP_SAVEVM:
|
||||
case VMSTOP_LOADVM:
|
||||
case RSTATE_SAVEVM:
|
||||
case RSTATE_RESTORE:
|
||||
return;
|
||||
case VMSTOP_MIGRATE:
|
||||
case RSTATE_PRE_MIGRATE:
|
||||
ret = GDB_SIGNAL_XCPU;
|
||||
break;
|
||||
default:
|
||||
|
@ -2463,7 +2463,7 @@ void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...)
|
|||
gdb_current_syscall_cb = cb;
|
||||
s->state = RS_SYSCALL;
|
||||
#ifndef CONFIG_USER_ONLY
|
||||
vm_stop(VMSTOP_DEBUG);
|
||||
vm_stop(RSTATE_DEBUG);
|
||||
#endif
|
||||
s->state = RS_IDLE;
|
||||
va_start(va, fmt);
|
||||
|
@ -2537,7 +2537,7 @@ static void gdb_read_byte(GDBState *s, int ch)
|
|||
if (vm_running) {
|
||||
/* when the CPU is running, we cannot do anything except stop
|
||||
it when receiving a char */
|
||||
vm_stop(VMSTOP_USER);
|
||||
vm_stop(RSTATE_PAUSED);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
|
@ -2799,7 +2799,7 @@ static void gdb_chr_event(void *opaque, int event)
|
|||
{
|
||||
switch (event) {
|
||||
case CHR_EVENT_OPENED:
|
||||
vm_stop(VMSTOP_USER);
|
||||
vm_stop(RSTATE_PAUSED);
|
||||
gdb_has_xml = 0;
|
||||
break;
|
||||
default:
|
||||
|
@ -2840,7 +2840,7 @@ static int gdb_monitor_write(CharDriverState *chr, const uint8_t *buf, int len)
|
|||
static void gdb_sigterm_handler(int signal)
|
||||
{
|
||||
if (vm_running) {
|
||||
vm_stop(VMSTOP_USER);
|
||||
vm_stop(RSTATE_PAUSED);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue