Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jim Nance <jlnance@avanticorp.com>
To: gdb-patches@cygnus.com
Cc: jim_nance@yahoo.com
Subject: ladebug like w command for gdb
Date: Tue, 02 Feb 1999 08:39:00 -0000	[thread overview]
Message-ID: <19990202113854.A8536@avanticorp.com> (raw)

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 @@
 }
 \f
 /* 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);
 }
 \f
 
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.


WARNING: multiple messages have this Message-ID
From: Jim Nance <jlnance@avanticorp.com>
To: gdb-patches@cygnus.com
Cc: jim_nance@yahoo.com
Subject: ladebug like w command for gdb
Date: Thu, 01 Apr 1999 00:00:00 -0000	[thread overview]
Message-ID: <19990202113854.A8536@avanticorp.com> (raw)
Message-ID: <19990401000000.Jdvo8ODe8Y6g21c8nMX2eKSWLVh11w7cAglQj9bV710@z> (raw)

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 @@
 }
 \f
 /* 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);
 }
 \f
 
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.


             reply	other threads:[~1999-02-02  8:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-02-02  8:39 Jim Nance [this message]
1999-04-01  0:00 ` Jim Nance

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=19990202113854.A8536@avanticorp.com \
    --to=jlnance@avanticorp.com \
    --cc=gdb-patches@cygnus.com \
    --cc=jim_nance@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox