📄 gdb_parser.c
字号:
else unknown_output(output_string, command, flags); /* if PopupMode was true but GDB found an error in print statement (ie match() returned -1), PopupMode was never reset */ PopupMode = FALSE; XtFree(prtname); } break; case C_SYMBOL_FILE: case C_FILE: if (debug) { fprintf(stderr, "C_FILE or C_SYMBOL_FILE\n"); } debug_handler(); break; case C_SOURCE: /* WE SHOULD NEVER ARRIVE HERE */ if (debug) { fprintf(stderr, "C_SOURCE - WE SHOULD NEVER ARRIVE HERE\n"); } break; case C_EXEC_FILE: if (debug) { fprintf(stderr, "C_EXEC_FILE\n"); } break; case C_CORE_FILE: if (debug) { fprintf(stderr, "C_CORE_FILE\n"); } if (match(output_pattern, output_string, O_CORE_FILE) != -1) core_file_handler(); else unknown_output(output_string, command, flags); break; /* in case of 'info source', we do not call unknown_output() if the pattern is not matched, because we only test for the 'compilation directory' line. When there is no compilation directory, there is no match and there is no error... (PW)8JUN93 : we also test for current source and current source full pathname. */ case C_INFO_SOURCE: if (debug) { fprintf(stderr, "C_INFO_SOURCE\n"); } cdir[0] = 0; source_fullpath[0] = 0; source_path[0] = 0; if (match(output_pattern, output_string, O_INFO_SOURCE) != -1) info_source_handler(Token.mesg, Token.file, Token.func); break; default: if (debug) { fprintf(stderr, "C UNKNOWN\n"); } break; } XtFree(output_string);}#ifdef NEED_STRSTR/*--------------------------------------------------------------------------+| || Some systems DO NOT have the ANSI strstr function || |+--------------------------------------------------------------------------*/ char *strstr (source, substr) char *source; char *substr;{char *src;char *sub; if (!source || !substr) return NULL; while (*source) { for (src = source, sub = substr; (*src) && (*sub) && (*src == *sub); src++,sub++); if (!*sub) return source; source++; } return NULL;}#endif/*--------------------------------------------------------------------------+| || Function to filter all the display information in a string || || input : string pointer, || already_taken_care is number of char in string already || processed (eg, displayed). || || output : none. || || See O_EXEC_DISPLAY in gdb_regex.h for the display pattern. || || Take care when GDB send some message after '\032\032...\n' || which is not a display line. || || (gdb) finish || Run till exit from #0 foo (n=1) (pw.c line 9) || main () (pw.c line 41) || /usr1/gnu_sun4/xxgdb/pw.c:41:590:beg:0x232c || 1: i = 1 || Value returned is $1 = 1 || (gdb) || |+--------------------------------------------------------------------------*/void filter_display_info(output, already_taken_care)char *output;unsigned int already_taken_care;{ struct re_registers regs; int r; char *p; char *p1; char *p2; char *cp_output; int begin_struct; p = cp_output = XtNewString(output); p1 = strstr(p,"\032\032"); /* find beginning of special gdb line */ if ((p1 == 0) || ((p2 = strchr(p1+1,'\n')) == 0)) { AppendDialogText(p + already_taken_care); /* something wrong here */ XtFree(cp_output); return; } *p1 = 0; if (p1 > (p + already_taken_care)) { AppendDialogText(p + already_taken_care); /* print everything before that line */ } p = p2 + 1; /* end of that line + skip \n */ /* test for beginning of a display */ while (re_match(output_pattern[O_EXEC_DISPLAY].buf,p,strlen(p),0,®s) > 0) { /* we found a "X:....\n" pattern */ r = output_pattern[O_EXEC_DISPLAY].reg_token[TK_DISP]; p1= p+regs.start[r]; p2 = p+regs.end[r]; /* count number of { and } : if not equal, the next lines are part of this display */ begin_struct = 0; while (p1 < p2) { switch(*(p1++)) { case '{': begin_struct++; break; case '}': begin_struct--; break; } } p1=p+regs.start[r]; *p1 = 0; if (p != p1) { /* do not print anything already printed */ if (p < (cp_output + already_taken_care)) { p = cp_output + already_taken_care; } if (p < p1) { AppendDialogText(p); /* print what is before display */ } } p = p2; /* skip display text */ if (begin_struct) /* skip the whole data displayed */ { do /* find the last '}' */ { switch(*(p++)) { case '{': begin_struct++; break; case '}': begin_struct--; break; } } while (begin_struct); /* now skip until end of line */ while (*(p++) != '\n'); } } if (p < (cp_output + already_taken_care)) { p = cp_output + already_taken_care; /* do not print anything already printed */ } AppendDialogText(p); /* print what is after display */ XtFree(cp_output);}/*--------------------------------------------------------------------------+| || * This function edits the dbx output so that unnecessary information is || * not displayed on the dialog window. || * It filters away the some output returned by the execution commands; || * output from the search commands, and the display command. || * On Sun dbx, it also filters away part of the output returned by the || * up and down commands. || * |+--------------------------------------------------------------------------*/voidfilter (string, output, command)char *string, *output, *command;{ struct re_registers regs; char *p; char *p2; static Boolean deleteRest = False; static Boolean for_gdb_only = False; int command_type = -1; static unsigned int already_taken_care = 0; Boolean previous_for_gdb_only; if (output == NULL || strcmp(output, "") == 0) return;/* for GDB, the only things we want to filter are: - the line displayed because of the -fullname option : "\032\032/usr1/gnu_sun4/xdbx/pw.c:6:40:beg:0x22b0\n", - the displayed info which goes into the display window, - list and search outputs*/ if (!string) string = ""; if (command) command_type = match(command_pattern, command, C_ANY); if ((command_type == C_EXEC)||(command_type == C_FINISH)) { if ((re_match(output_pattern[O_EXEC_MESS_AFTER].buf,output,strlen(output),0,®s) > 0) || (re_match(output_pattern[O_EXEC_MESS_BEFORE].buf,output,strlen(output),0,®s) > 0) || (re_match(output_pattern[O_EXEC_GDB].buf,output,strlen(output),0,®s) > 0)) { /* Remove display messages from output and print what is not a display */ if (Prompt) { filter_display_info (output, already_taken_care); for_gdb_only = False; already_taken_care = 0; deleteRest = False; } else { deleteRest = True; } return; } else /* does not match exec pattern yet */ { if (deleteRest) /* if already matched before */ { /* Remove display messages from output and print what is not a display */ if (Prompt) { filter_display_info (output, already_taken_care); for_gdb_only = False; already_taken_care = 0; deleteRest = False; } return; } } } /* remember what was the output length was output was matched */ already_taken_care = strlen(output); /* filter any line starting with \032\032 */ /* (PW)18NOV94: we have a problem with some system where the \032\032 comes in several times. In that case we might end-up showing ^Z^Z in dialog window. SO now do no test for end of line, and note that all following outputs are for gdb, not for the user. Here we assume that at least the double ^Z^Z is read in one piece. */ previous_for_gdb_only = for_gdb_only; p = strchr(string,'\032'); if (p && (*(p+1) == '\032') && (p == string || *(p-1) == '\n') /* && (p2 = strchr(p,'\n'))*/) { if ((p2 = strchr(p,'\n'))) { while ((*(p++) = *(++p2))); } else { *p = 0; } for_gdb_only = True; } if ((command_type == C_EXEC)||(command_type == C_FINISH)) { if (!previous_for_gdb_only) { AppendDialogText(string); } if (Prompt) { for_gdb_only = False; already_taken_care = 0; deleteRest = False; } return; } if (Prompt) { char *s; for_gdb_only = False; already_taken_care = 0; deleteRest = False; s = XtNewString(output); switch (command_type) { case C_DISPLAY: if (match(output_pattern, s, O_DISPLAY) != -1) strcpy(s, ""); break; case C_DISPLAY_INFO: /* (PW)7MAY91 : display error messages */ if (match(output_pattern, s, O_DISPLAY_INFO) != -1) { if (Token.mesg && strcmp(Token.mesg, "")) { AppendDialogText(Token.mesg); bell(0); } strcpy(s, ""); } break; case C_SEARCH: if (match(output_pattern, s, O_SEARCH) != -1) strcpy(s, ""); break; case C_LIST: /* (PW)22MAY91 : display messages ") */ if (match(output_pattern, s, O_LIST) != -1) { if (Token.mesg && strcmp(Token.mesg, "")) { AppendDialogText(Token.mesg); if (strstr(Token.mesg,"Source file is more recent than executable.")) bell(0); /* Warn user WYSIWYG not true */ } strcpy(s, ""); } break; case C_PRINT: if (PopupMode && /* if print goes in a window, don't display here */ (match(output_pattern, s, O_PRINT) != -1)) strcpy(s, ""); break; default: XtFree(s); s = XtNewString(string); /* append 'string' only */ break; } AppendDialogText(s); XtFree(s); } else /* no prompt yet */ { switch (command_type) { case C_DISPLAY: case C_DISPLAY_INFO: case C_SEARCH: case C_LIST: case C_PRINT: break; default: if (!previous_for_gdb_only) { AppendDialogText(string); } break; } } return;}/*--------------------------------------------------------------------------+| || Function to filter 'source' command || || input : command (from .gdbinit or source command or keyboard), || echo is TRUE if source command must be echoed. || || output : TRUE if source command was recognized || || In case source command is recognized, it is executed here. || |+--------------------------------------------------------------------------*/int gdb_source_command(command,echo)char *command;int echo;{ if (command && (match(command_pattern, command, C_SOURCE) != -1)) { if (echo) AppendDialogText(command); source_handler(); return TRUE; } return FALSE;}/*--------------------------------------------------------------------------+| || Function to filter 'define' & 'document' commands || || input : command (from .gdbinit or source command), || fp = file pointer. || || output : TRUE if define or document command was recognized || || In case the command is recognized, it is executed here. || |+--------------------------------------------------------------------------*/static int command_sent = 0; /* flag gdb is busy : send no more command to gdb. */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -