// OK pressed in `Open Process' static void openProcessDone(Widget w, XtPointer client_data, XtPointer call_data) { int pid = get_pid(w, client_data, call_data); if (pid <= 0) { gdbUpdateProcessesCB(w, client_data, call_data); return; } XtUnmanageChild(w); ProgramInfo info; if (pid == info.pid) { set_status("Already attached to process " + itostring(pid) + "."); return; } if (info.file == NO_GDB_ANSWER || info.file.empty()) { post_error("No program.", "no_program", w); return; } // GDB does not always detach processes upon opening new // files, so we do it explicitly if (info.attached) gdb_command(gdb->detach_command(info.pid)); // Attach to new process gdb_command(gdb->attach_command(pid, info.file)); }
void gdbPrintCB(Widget w, XtPointer, XtPointer) { string arg = current_arg(); if (arg != "" && !arg.matches(rxwhite)) gdb_command(gdb->print_command(arg, false), w); }
void gdbDispRefCB(Widget w, XtPointer, XtPointer) { string arg = current_arg(); if (arg != "" && !arg.matches(rxwhite)) gdb_command("graph display " + deref(arg), w); }
void gdbWhatisCB(Widget w, XtPointer, XtPointer) { string arg = current_arg(); if (arg != "" && !arg.matches(rxwhite)) gdb_command(gdb->whatis_command(arg), w); }
void gdbWatchRefCB(Widget w, XtPointer, XtPointer) { string arg = current_arg(); if (arg != "" && !arg.matches(rxwhite)) gdb_command(gdb->watch_command(deref(arg)), w); }
static void RestartAndRunCB(Widget w, XtPointer client_data, XtPointer call_data) { RestartDebuggerCB(w, client_data, call_data); const string& cmd = *((const string *)client_data); gdb_command(cmd, w); }
// Make program with given arguments static void gdbMakeDCB(Widget, XtPointer, XtPointer) { Widget text = XmSelectionBoxGetChild(make_dialog, XmDIALOG_TEXT); String _args = XmTextGetString(text); string args(_args); XtFree(_args); gdb_command(gdb->make_command(args)); }
// ChangeDirectory program with given arguments static void gdbChangeDirectoryDCB(Widget, XtPointer, XtPointer) { Widget text = XmSelectionBoxGetChild(cd_dialog, XmDIALOG_TEXT); String _args = XmTextGetString(text); string args(_args); XtFree(_args); string path = source_view->full_path(args); switch (gdb->type()) { case PERL: gdb_command("chdir " + quote(path, '\'')); break; case BASH: gdb_command("eval cd " + path); break; default: gdb_command("cd " + path); } }
static void open_file(const string& filename) { open_file_reply = filename; if (gdb->type() == GDB) { // GDB does not always detach processes upon opening new // files, so we do it explicitly ProgramInfo info; if (info.attached) gdb_command("detach"); } if (gdb_initialized) { string cmd = gdb->debug_command(filename); if (gdb->type() == PERL) cmd.gsub("perl", string(app_data.debugger_command)); gdb_command(cmd); } }
void interruptAct(Widget w, XEvent*, String *, Cardinal *) { if (isearch_state != ISEARCH_NONE) { clear_isearch(); } else { gdb_keyboard_command = true; gdb_command("\003", w); gdb_keyboard_command = true; } }
// OK pressed in `Open Class' static void openClassDone(Widget w, XtPointer client_data, XtPointer call_data) { string cls = get_item(w, client_data, call_data); if (cls.empty()) { gdbUpdateClassesCB(w, client_data, call_data); return; } XtUnmanageChild(w); gdb_command(gdb->debug_command(cls)); }
void gdb_button_command(const string& command, Widget origin) { if (command.contains("...")) { set_current_line(command.before("...") + " "); } else { string c = command; c.gsub("()", source_arg->get_string()); if (add_running_arguments(c, origin)) gdb_command(c, origin); } }
void controlAct(Widget w, XEvent *ev, String *params, Cardinal *num_params) { clear_isearch(); if (*num_params != 1) { std::cerr << "gdb-control: usage: gdb-control(CONTROL-CHARACTER)\n"; return; } gdb_keyboard_command = from_keyboard(ev); gdb_command(ctrl(params[0]), w); gdb_keyboard_command = from_keyboard(ev); }
// OK pressed in `Open Core' static void openCoreDone(Widget w, XtPointer client_data, XtPointer call_data) { string corefile = get_file(w, client_data, call_data); if (corefile.empty()) return; ProgramInfo info; XtUnmanageChild(w); if (corefile != NO_GDB_ANSWER) { switch(gdb->type()) { case GDB: gdb_command("core-file " + gdb->quote_file(corefile)); break; case DBX: if (info.file != NO_GDB_ANSWER && !info.file.empty()) gdb_command(gdb->debug_command(info.file) + " " + gdb->quote_file(info.core)); else post_error("No program.", "no_program", w); break; case BASH: case DBG: case JDB: case PERL: case PYDB: case XDB: break; // FIXME } } }
void gdbWatchCB(Widget w, XtPointer client_data, XtPointer call_data) { (void) call_data; // Use it string arg = current_arg(); #if 0 // We may have different kinds of watchpoints! if (have_watchpoint_at_arg()) { // Don't place multiple watchpoints on one expression gdbUnwatchCB(w, client_data, call_data); } #endif if (arg != "" && !arg.matches(rxwhite)) gdb_command(gdb->watch_command(arg, WatchMode((int)(long)client_data)), w); }
// OK pressed in `Open Source' static void openSourceDone(Widget w, XtPointer client_data, XtPointer call_data) { string filename = get_file(w, client_data, call_data); if (filename.empty()) return; XtUnmanageChild(w); set_status(""); // For PYDB, issue a 'file filename' command if (gdb->type() == PYDB) gdb_command(gdb->debug_command(filename)); if (filename != NO_GDB_ANSWER) source_view->read_file(filename); }
// Run program with given arguments static void gdbRunDCB(Widget, XtPointer, XtPointer) { Widget text = XmSelectionBoxGetChild(run_dialog, XmDIALOG_TEXT); String _args = XmTextGetString(text); string args(_args); XtFree(_args); string cmd = gdb->run_command(args); while (!cmd.empty()) { string c; if (cmd.contains('\n')) c = cmd.before('\n'); else c = cmd; cmd = cmd.after('\n'); gdb_command(c, run_dialog); } }
static void DisplayExaminedCB(Widget w, XtPointer, XtPointer) { gdb_command("graph display `" + examine_command() + "`", w); }
bool UndoBuffer::process_command(UndoBufferEntry& entry) { // Process command string commands; if (entry.has(UB_EXEC_COMMAND)) commands = entry[UB_EXEC_COMMAND]; else if (entry.has(UB_COMMAND)) commands = entry[UB_COMMAND]; else return true; // Nothing to do entry.remove(UB_COMMAND); entry.remove(UB_EXEC_COMMAND); //string original_commands = commands; int bp_count = 0; undoing = true; bool confirm = false; if (!commands.empty() && gdb->type() == GDB) { gdb_command("show confirm", 0, get_confirm, &confirm); syncCommandQueue(); } if (confirm) { // Turn confirmation off during undo/redo. gdb_question("set confirm off"); } while (!commands.empty()) { string cmd; if (commands.contains('\n')) cmd = commands.before('\n'); else cmd = commands; commands = commands.after('\n'); // Handle breakpoint remappings if (cmd.contains(REMAP_COMMAND, 0)) { int old_bp_nr = atoi(cmd.chars() + strlen(REMAP_COMMAND "@")); int new_bp_nr = source_view->next_breakpoint_number() + bp_count++; remap_breakpoint(old_bp_nr, new_bp_nr); remap_breakpoint(commands, old_bp_nr, new_bp_nr); continue; } // Replace all occurrences of `@N@' by N #if RUNTIME_REGEX static regex rxnum("@[0-9]+@"); #endif int i; while ((i = index(cmd, rxnum, "@")) >= 0) { int num = atoi(cmd.chars() + i + 1); int j = cmd.index('@', i + 1); cmd.at(i, j - i + 1) = itostring(num); } if (cmd.contains("set confirm", 0)) confirm = false; // Don't overwrite // Execute command. This will result in new redo command(s) // being passed to add_command(). Command c(cmd); c.priority = COMMAND_PRIORITY_SYSTEM; gdb_command(c); // Wait until this command is processed syncCommandQueue(); } if (confirm) gdb_question("set confirm on"); if (!entry.has(UB_COMMAND) && !entry.has(UB_EXEC_COMMAND)) { // We had an error during execution return false; } undoing = false; return true; }
// Send completed lines to GDB void gdbChangeCB(Widget w, XtPointer, XtPointer) { if (private_gdb_output) return; string input = current_line(); bool at_prompt = gdb_input_at_prompt; if (at_prompt) input.gsub("\\\n", ""); int newlines = input.freq('\n'); string *lines = new string[newlines + 1]; split(input, lines, newlines, '\n'); private_gdb_input = true; if (newlines == 0 || (gdb_input_at_prompt && input.contains('\\', -1))) { // No newline found - line is still incomplete set_history_from_line(input, true); } else { // Process entered lines clear_isearch(); promptPosition = XmTextGetLastPosition(w); for (int i = 0; i < newlines; i++) { string cmd = lines[i]; tty_out(cmd + "\n"); if (gdb_input_at_prompt) { if (cmd.matches(rxwhite) || cmd.empty()) { // Empty line: repeat last command cmd = last_command_from_history(); } else { // Add new command to history add_to_history(cmd); } } if (at_prompt) { // We're typing at the GDB prompt: place CMD in command queue gdb_command(cmd, w); } else { // Pass anything else right to GDB, clearing the command queue. clearCommandQueue(); gdb->send_user_ctrl_cmd(cmd + "\n"); } } } private_gdb_input = false; delete[] lines; }
void gdbRegexBreakAtCB(Widget w, XtPointer, XtPointer) { gdb_command("rbreak " + source_arg->get_string(), w); }
static void PrintExaminedCB(Widget w, XtPointer, XtPointer) { gdb_command(examine_command(), w); }
void gdbMakeAgainCB(Widget, XtPointer, XtPointer) { gdb_command(gdb->make_command(last_make_argument)); }