This is the mail archive of the gdb-patches@sourceware.cygnus.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: source listing change


Yes!  Please!

I think that this has been discussed in the past.  Do we really need to
make this a separate option to list?

cgf

On Mon, Apr 03, 2000 at 09:29:55PM -0400, Christopher Blizzard wrote:
>This was forwarded to me from James Nance.  He asked me to forward it on
>to the gdb-patches list.
>
>--Chris
>
>-------- Original Message --------
>Subject: gdb patches
>Date: Tue, 28 Mar 2000 06:26:02 -0500
>From: James Lewis Nance <jlnance@worldnet.att.net>
>To: blizzard@mozilla.org
>
>Chris,
>    As long as you are putting together patches for gdb, here is one I
>have
>been trying to get included for a while.  I got it approved by Cygnus
>about
>2 years ago, but then the person I was working up there quit.  I have
>not
>been able to find anyone really interested in it since then.  This patch
>adds a command like the "w" command in the Digital Unix ladebug debugger
>(though the Cygnus people had me call it "list -l").  What it does is
>when you type "list -l" it displays your souce code but it puts a '> '
>character in front of the current line so you can find out where you 
>are.  Its one of those things you dont appreciate until you have used
>it a few times.  Then you cant live with out it.
>    I am attaching my patch.  Please give it a try.
>
>Thanks,
>
>Jim
>
>PS: If you alias list -l to w in your .gdbinit, its much more
>convienient to
>    use.
>diff -ru gdb-4.18.orig/gdb/ChangeLog gdb-4.18.new/gdb/ChangeLog
>--- gdb-4.18.orig/gdb/ChangeLog	Wed Apr  7 17:34:27 1999
>+++ gdb-4.18.new/gdb/ChangeLog	Wed Jan 12 17:47:10 2000
>@@ -1,3 +1,9 @@
>+2000-01-12  Jim Nance   <jlnance@worldnet.att.net>
>+
>+	* source.c symtab.h: Added a -w option to the list command.  Allows
>+	the currently executing line of code in the current stack frame to
>+	be annotated.
>+
> 1999-04-07  Jim Blandy  <jimb@zwingli.cygnus.com>
> 
> 	* GDB 4.18 released.
>Only in gdb-4.18.new/gdb: ChangeLog.orig
>Only in gdb-4.18.new/gdb: linuxthreads.c.threads
>diff -ru gdb-4.18.orig/gdb/source.c gdb-4.18.new/gdb/source.c
>--- gdb-4.18.orig/gdb/source.c	Thu Dec 31 16:58:08 1998
>+++ gdb-4.18.new/gdb/source.c	Wed Jan 12 17:45:48 2000
>@@ -976,11 +976,11 @@
> /* Print source lines from the file of symtab S,
>    starting with line number LINE and stopping before line number STOPLINE. */
> 
>-static void
>-print_source_lines_base (s, line, stopline, noerror)
>+void
>+print_source_lines_base (s, line, stopline, noerror, markline)
>      struct symtab *s;
>      int line, stopline;
>-     int noerror;
>+     int noerror, markline;
> {
>   register int c;
>   register int desc;
>@@ -1046,8 +1046,11 @@
>     {
>       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')
>@@ -1081,7 +1084,7 @@
> #if defined(TUI)
>   if (!tui_version || 
>       m_winPtrIsNull(srcWin) || !srcWin->generic.isVisible )
>-    print_source_lines_base(s, line, stopline, noerror);
>+    print_source_lines_base(s, line, stopline, noerror, 0);
>   else
>     {
>       TuiGenWinInfoPtr locator = locatorWinInfoPtr();
>@@ -1101,7 +1104,7 @@
>     tuiDo((TuiOpaqueFuncPtr)tui_vUpdateLocatorFilename, s->filename);
>   }
> #else
>-  print_source_lines_base(s, line, stopline, noerror);
>+  print_source_lines_base(s, line, stopline, noerror, 0);
> #endif
> }
> 
>@@ -1123,6 +1126,18 @@
> 		    sals->sals[i].symtab->filename, sals->sals[i].line);
> }
> 
>+static void printw (s, line, stopline, noerror)
>+     struct symtab *s;
>+     int line;
>+     int stopline;
>+     int noerror;
>+{
>+  int nlines = lines_to_list / 2;
>+  int bline = line > nlines ? line - nlines : 1;
>+  int eline = line + nlines;
>+  print_source_lines_base (s, bline, eline, noerror, line);
>+}
>+
> static void
> list_command (arg, from_tty)
>      char *arg;
>@@ -1157,8 +1172,25 @@
>       return;
>     }
> 
>-  /* "l -" lists previous ten lines, the ones before the ten just listed.  */
>-  if (STREQ (arg, "-"))
>+  /* We check for 2 cases here:
>+   *    "l -" lists previous ten lines, the ones before the ten just listed.
>+   *    "l -w" gives a context listing showing the current position.
>+  */
>+  if (STREQN (arg, "-", 1))
>+    if (STREQ (arg, "-w"))
>+    {
>+      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;
>+      return;
>+    }
>+    else
>     {
>       if (current_source_symtab == 0)
> 	error ("No default source file yet.  Do \"help list\".");
>@@ -1500,7 +1532,7 @@
> 	/* Match! */
> 	fclose (stream);
> 	if (tui_version)
>-          print_source_lines_base (current_source_symtab, line, line+1, 0);
>+          print_source_lines_base (current_source_symtab, line, line+1, 0, 0);
> 	print_source_lines (current_source_symtab, line, line+1, 0);
> 	set_internalvar (lookup_internalvar ("_"),
> 			 value_from_longest (builtin_type_int,
>@@ -1598,7 +1630,7 @@
> 	  /* Match! */
> 	  fclose (stream);
>           if (tui_version)
>-            print_source_lines_base (current_source_symtab, line, line+1, 0);
>+            print_source_lines_base (current_source_symtab, line, line+1, 0, 0);
> 	  print_source_lines (current_source_symtab, line, line+1, 0);
> 	  set_internalvar (lookup_internalvar ("_"),
> 			   value_from_longest (builtin_type_int,
>@@ -1695,6 +1727,7 @@
>   add_com ("list", class_files, list_command,
> 	   concat ("List specified function or line.\n\
> With no argument, lists ten more lines after or around previous listing.\n\
>+\"list -w\" lists the currently executing line of souce code with context.\n\
> \"list -\" lists the ten lines before a previous ten-line listing.\n\
> One argument specifies a line, and ten lines are listed around that line.\n\
> Two arguments with comma between specify starting and ending lines to list.\n\
>diff -ru gdb-4.18.orig/gdb/symtab.h gdb-4.18.new/gdb/symtab.h
>--- gdb-4.18.orig/gdb/symtab.h	Wed Feb 10 19:24:40 1999
>+++ gdb-4.18.new/gdb/symtab.h	Wed Jan 12 17:42:58 2000
>@@ -1403,6 +1403,9 @@
> identify_source_line PARAMS ((struct symtab *, int, int, CORE_ADDR));
> 
> extern void
>+print_source_lines_base PARAMS ((struct symtab *, int, int, int, int));
>+
>+extern void
> print_source_lines PARAMS ((struct symtab *, int, int, int));
> 
> extern void
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]