This is the mail archive of the gdb-patches@sourceware.cygnus.com mailing list for the GDB project. See the GDB home page for more information.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Hello All, I use both gdb and the Digital Unix ladebug debugger. The one thing that kept me from switching compleatly to gdb was the w command the ladebug debugger had. The w command does a source listing in the current frame and marks the line which the debugger is about to execute. Its quite a simple idea, but once you get used to it, not having it is painful. It was fairly painless to add this command to gdb. Here is the patch and a changelog entry. I hope someone finds it useful. Thanks, Jim Tue Feb 2 11:30:00 1999 Jim Nance (jim_nance@yahoo.com) * Added the w command to gdb. This command produces an annotated listing of the source code in the current frame. diff -u gdb-4.17/gdb/source.c jimsgdb/gdb/source.c --- gdb-4.17/gdb/source.c Fri Jul 4 14:54:50 1997 +++ jimsgdb/gdb/source.c Thu Oct 1 07:15:17 1998 @@ -930,12 +930,13 @@ } /* Print source lines from the file of symtab S, - starting with line number LINE and stopping before line number STOPLINE. */ + starting with line number LINE and stopping before line number STOPLINE. + Line number MARKLINE is preceeded by a '>' */ void -print_source_lines (s, line, stopline, noerror) +print_source_annotated (s, line, stopline, markline, noerror) struct symtab *s; - int line, stopline; + int line, stopline, markline; int noerror; { register int c; @@ -982,8 +983,12 @@ { c = fgetc (stream); if (c == EOF) break; - last_line_listed = current_source_line; - printf_filtered ("%d\t", current_source_line++); + last_line_listed = current_source_line++; + if(last_line_listed!=markline) { + printf_filtered ("%d\t", last_line_listed); + } else { + printf_filtered ("%d >\t", last_line_listed); + } do { if (c < 040 && c != '\t' && c != '\n' && c != '\r') @@ -1002,6 +1007,15 @@ } fclose (stream); +} + +void +print_source_lines (s, line, stopline, noerror) + struct symtab *s; + int line, stopline; + int noerror; +{ + print_source_annotated(s, line, stopline, 0, noerror); } diff -u gdb-4.17/gdb/stack.c jimsgdb/gdb/stack.c --- gdb-4.17/gdb/stack.c Mon Nov 24 17:20:14 1997 +++ jimsgdb/gdb/stack.c Thu Oct 1 07:19:39 1998 @@ -57,6 +57,8 @@ static void frame_command PARAMS ((char *, int)); +static void w_command PARAMS ((char *, int)); + static void select_frame_command PARAMS ((char *, int)); static void print_frame_arg_vars PARAMS ((struct frame_info *, GDB_FILE *)); @@ -1243,6 +1245,33 @@ With arg, behaves like select_frame and then prints the selected frame. */ +static void printw(s, line, stopline, noerror) +struct symtab *s; +int line; +int stopline; +int noerror; +{ + int bline = line>4? line-4 : 1; + int eline = line+4; + print_source_annotated(s, bline, eline, line, noerror); +} + +static void +w_command(level_exp, from_tty) + char *level_exp; + int from_tty; +{ + extern void (*print_frame_info_listing_hook) + PARAMS ((struct symtab *s, int line, int stopline, int noerror)); + void (*savefn) + PARAMS ((struct symtab *s, int line, int stopline, int noerror)); + + savefn = print_frame_info_listing_hook; + print_frame_info_listing_hook = printw; + frame_command(NULL, 0); + print_frame_info_listing_hook = savefn; +} + static void frame_command (level_exp, from_tty) char *level_exp; @@ -1461,6 +1490,8 @@ "Same as the `down' command, but does not print anything.\n\ This is useful in command scripts."); + add_com ("w", class_stack, w_command, + "Print the selected stack frame and surrounding source code\n"); add_com ("frame", class_stack, frame_command, "Select and print a stack frame.\n\ With no argument, print the selected stack frame. (See also \"info frame\").\n\ Only in jimsgdb/gdb/: stamp-h Only in jimsgdb/gdb/: tags Only in jimsgdb/gdb/: testsuite Only in jimsgdb/gdb/: tm.h Only in jimsgdb/gdb/: vx-share Only in jimsgdb/gdb/: xm.h -- ---------------------------------------------------------------------------- Jim Nance Avant! Corporation (919) 941-6655 Do you have sweet iced tea? jim_nance@avanticorp.com No, but there's sugar on the table.