void mi_execute_command (char *cmd, int from_tty) { struct mi_parse *command; struct captured_mi_execute_command_args args; struct ui_out *saved_uiout = uiout; /* This is to handle EOF (^D). We just quit gdb. */ /* FIXME: we should call some API function here. */ if (cmd == 0) quit_force (NULL, from_tty); command = mi_parse (cmd); if (command != NULL) { struct gdb_exception result; if (do_timings) { command->cmd_start = (struct mi_timestamp *) xmalloc (sizeof (struct mi_timestamp)); timestamp (command->cmd_start); } /* FIXME: cagney/1999-11-04: Can this use of catch_exceptions either be pushed even further down or even eliminated? */ args.command = command; result = catch_exception (uiout, captured_mi_execute_command, &args, RETURN_MASK_ALL); exception_print (gdb_stderr, result); if (args.action == EXECUTE_COMMAND_SUPRESS_PROMPT) { /* The command is executing synchronously. Bail out early suppressing the finished prompt. */ mi_parse_free (command); return; } if (result.reason < 0) { /* The command execution failed and error() was called somewhere. */ fputs_unfiltered (command->token, raw_stdout); fputs_unfiltered ("^error,msg=\"", raw_stdout); if (result.message == NULL) fputs_unfiltered ("unknown error", raw_stdout); else fputstr_unfiltered (result.message, '"', raw_stdout); fputs_unfiltered ("\"\n", raw_stdout); mi_out_rewind (uiout); } mi_parse_free (command); } fputs_unfiltered ("(gdb) \n", raw_stdout); gdb_flush (raw_stdout); /* Print any buffered hook code. */ /* ..... */ }
static struct gdb_exception safe_execute_command (struct ui_out *uiout, char *command, int from_tty) { struct gdb_exception e; struct captured_execute_command_args args; args.command = command; args.from_tty = from_tty; e = catch_exception (uiout, do_captured_execute_command, &args, RETURN_MASK_ALL); /* FIXME: cagney/2005-01-13: This shouldn't be needed. Instead the caller should print the exception. */ exception_print (gdb_stderr, e); return e; }
bool execute() { if(canceled()) return false; else { { stopwatch_event* x = this; cs().push(x); } bool r = false; int64_t diff = ms_timer() - lastms - waitms; if(diff >= 0) { lastms = ms_timer(); mark_before_callback(); catch_exception(d()); mark_after_callback(); r = false; } else r = true; cs().pop(); return r; } }
panic (char *format, ...) { u64 time; int count; va_list ap; ulong curstk; bool w = false; char *p, *pend; int cpunum = -1; static int panic_count = 0; static ulong panic_shell = 0; struct panic_pcpu_data_state *state, local_state; va_start (ap, format); if (currentcpu_available ()) cpunum = get_cpu_id (); if (cpunum >= 0) { spinlock_lock (&panic_lock); count = panic_count++; spinlock_unlock (&panic_lock); wait_for_other_cpu (cpunum); p = panicmsg_tmp; pend = panicmsg_tmp + sizeof panicmsg_tmp; if (panic_reboot) *p = '\0'; else snprintf (p, pend - p, "panic(CPU%d): ", cpunum); p += strlen (p); vsnprintf (p, pend - p, format, ap); if (*p != '\0') { printf ("%s\n", panicmsg_tmp); if (panicmsg[0] == '\0') snprintf (panicmsg, sizeof panicmsg, "%s", panicmsg_tmp); } asm_rdrsp (&curstk); if (count > 5 || curstk - (ulong)currentcpu->stackaddr < VMM_MINSTACKSIZE) { spinlock_lock (&panic_lock); paniccpu = -1; spinlock_unlock (&panic_lock); freeze (); } state = ¤tcpu->panic.state; } else { spinlock_lock (&panic_lock); count = panic_count++; printf ("panic: "); vprintf (format, ap); printf ("\n"); spinlock_unlock (&panic_lock); if (count) freeze (); state = &local_state; state->dump_vmm = false; state->backtrace = false; state->flag_dump_vm = false; } va_end (ap); if (!state->dump_vmm) { state->dump_vmm = true; catch_exception (cpunum, dump_vmm_control_regs); catch_exception (cpunum, dump_vmm_other_regs); state->dump_vmm = false; } if (!state->backtrace) { state->backtrace = true; catch_exception (cpunum, backtrace); state->backtrace = false; } if (cpunum >= 0 && current && !state->flag_dump_vm) { /* Guest state is printed only once. Because the * state will not change if panic will have been * called twice or more. */ state->flag_dump_vm = true; printf ("Guest state and registers of cpu %d ------------\n", cpunum); catch_exception (cpunum, dump_vm_general_regs); catch_exception (cpunum, dump_vm_control_regs); catch_exception (cpunum, dump_vm_sregs); catch_exception (cpunum, dump_vm_other_regs); printf ("------------------------------------------------\n"); } if (cpunum < 0) freeze (); if (do_wakeup) { do_wakeup = false; w = true; } spinlock_lock (&panic_lock); paniccpu = -1; spinlock_unlock (&panic_lock); if (w) { sleep_set_timer_counter (); panic_wakeup_all (); } call_initfunc ("panic"); if (cpunum == 0) { usleep (1000000); /* wait for dump of other processors */ #ifndef TTY_SERIAL setkbdled (LED_NUMLOCK_BIT | LED_SCROLLLOCK_BIT | LED_CAPSLOCK_BIT); if (!uefi_booted) { disable_apic (); if (bios_area_saved) copy_bios_area (bios_area_panic, bios_area_orig); callrealmode_setvideomode (VIDEOMODE_80x25TEXT_16COLORS); if (bios_area_saved) copy_bios_area (NULL, bios_area_panic); if (panic_reboot) printf ("%s\n", panicmsg); } keyboard_reset (); usleep (250000); setkbdled (LED_SCROLLLOCK_BIT | LED_CAPSLOCK_BIT); #endif } else { /* setvideomode is expected to be done in 3 seconds */ time = get_time (); while (get_time () - time < 3000000); } if (asm_lock_ulong_swap (&panic_shell, 1)) { for (;;) reboot_test (); clihlt (); } if (panic_reboot) do_panic_reboot (); printf ("%s\n", panicmsg); call_panic_shell (); }