// Veto changes before the current input line void gdbModifyCB(Widget gdb_w, XtPointer, XtPointer call_data) { if (private_gdb_output) return; XmTextVerifyCallbackStruct *change = (XmTextVerifyCallbackStruct *)call_data; if (do_isearch(gdb_w, change)) return; clear_isearch(); if (change->startPos < promptPosition) { // Attempt to change text before prompt #if 0 // This only works in LessTif. // With Motif, this causes a core dump on Solaris. - AZ change->doit = false; #else // Make it a no-op XmTextPosition lastPos = XmTextGetLastPosition(gdb_w); XmTextPosition newPos = lastPos; if (change->text->length == 0) { // Deletion newPos = promptPosition; if (change->event != 0) XtCallActionProc(gdb_w, "beep", change->event, 0, 0); } else { // Some character XtAppAddTimeOut(XtWidgetToApplicationContext(gdb_w), 0, move_to_end_of_line, XtPointer(0)); } change->startPos = change->endPos = change->newInsert = change->currInsert = newPos; #endif return; } // Make sure newlines are always inserted at the end of the line if (change->startPos == change->endPos && (change->startPos < promptPosition || (change->text->length == 1 && change->text->ptr[0] == '\n'))) { // Add any text at end of text window XmTextPosition lastPos = XmTextGetLastPosition(gdb_w); change->newInsert = change->startPos = change->endPos = lastPos; XtAppAddTimeOut(XtWidgetToApplicationContext(gdb_w), 0, move_to_end_of_line, XtPointer(0)); } }
int cmd_isearch(char **arg) { static const struct { const char *name; int (*func)(const char *term, char **arg, struct isearch_query *q); } term_handlers[] = { {"opcode", isearch_opcode}, {"byte", isearch_bw}, {"word", isearch_bw}, {"aword", isearch_bw}, {"jump", isearch_type}, {"single", isearch_type}, {"double", isearch_type}, {"src", isearch_addr}, {"dst", isearch_addr}, {"srcreg", isearch_reg}, {"dstreg", isearch_reg}, {"srcmode", isearch_mode}, {"dstmode", isearch_mode} }; struct isearch_query q; const char *addr_text; const char *len_text; address_t addr; address_t len; addr_text = get_arg(arg); len_text = get_arg(arg); if (!(addr_text && len_text)) { printc_err("isearch: address and length expected\n"); return -1; } if (expr_eval(addr_text, &addr) < 0 || expr_eval(len_text, &len) < 0) return -1; q.flags = 0; for (;;) { const char *term = get_arg(arg); int i; if (!term) break; for (i = 0; i < ARRAY_LEN(term_handlers); i++) if (!strcasecmp(term_handlers[i].name, term)) { if (term_handlers[i].func(term, arg, &q) < 0) return -1; break; } } if (!q.flags) { printc_err("isearch: no query terms given " "(perhaps you mean \"dis\"?)\n"); return -1; } return do_isearch(addr, len, &q); }