static void handle_v_attach(GArray *params, void *user_ctx)
{
- GDBProcess *process;
- CPUState *cpu;
+ GDBProcess *process = NULL;
+ CPUState *cpu = NULL;
+ /* Default error reply */
g_string_assign(gdbserver_state.str_buf, "E22");
- if (!params->len) {
- goto cleanup;
- }
-
- process = gdb_get_process(gdb_get_cmd_param(params, 0)->val_ul);
- if (!process) {
- goto cleanup;
+ if (params->len) {
+ process = gdb_get_process(gdb_get_cmd_param(params, 0)->val_ul);
}
- cpu = gdb_get_first_cpu_in_process(process);
- if (!cpu) {
- goto cleanup;
+ if (process) {
+ cpu = gdb_get_first_cpu_in_process(process);
}
- process->attached = true;
- gdbserver_state.g_cpu = cpu;
- gdbserver_state.c_cpu = cpu;
+ if (cpu) {
+ process->attached = true;
+ gdbserver_state.g_cpu = cpu;
+ gdbserver_state.c_cpu = cpu;
- if (gdbserver_state.allow_stop_reply) {
- g_string_printf(gdbserver_state.str_buf, "T%02xthread:", GDB_SIGNAL_TRAP);
- gdb_append_thread_id(cpu, gdbserver_state.str_buf);
- g_string_append_c(gdbserver_state.str_buf, ';');
- gdbserver_state.allow_stop_reply = false;
-cleanup:
- gdb_put_strbuf();
+ if (gdbserver_state.allow_stop_reply) {
+ g_string_printf(gdbserver_state.str_buf, "T%02xthread:", GDB_SIGNAL_TRAP);
+ gdb_append_thread_id(cpu, gdbserver_state.str_buf);
+ g_string_append_c(gdbserver_state.str_buf, ';');
+ gdbserver_state.allow_stop_reply = false;
+ }
}
+
+ gdb_put_strbuf();
}
static void handle_v_kill(GArray *params, void *user_ctx)