public inbox for insight@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] GDB view command
@ 2002-08-14  8:44 Keith Seitz
  0 siblings, 0 replies; 3+ messages in thread
From: Keith Seitz @ 2002-08-14  8:44 UTC (permalink / raw)
  To: insight

Hi,

I've committed the following patch, which adds a new GDB command called 
"view" which will display the given linespec in the source window, e.g.,

(gdb) help view

(gdb) view myFunction
[the function "myFunction" will be displayed in the source window]

Keith

ChangeLog
2002-08-14  Keith Seitz  <keiths@redhat.com>

        * generic/gdbtk.c (view_command): New function to display
        location in source window.
        (gdbtk_init): Add new gdb "view" command.

Patch
Index: generic/gdbtk.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/generic/gdbtk.c,v
retrieving revision 1.28
diff -p -r1.28 gdbtk.c
*** generic/gdbtk.c	17 Apr 2002 18:13:04 -0000	1.28
--- generic/gdbtk.c	14 Aug 2002 15:43:59 -0000
*************** int target_is_native (struct target_ops 
*** 98,103 ****
--- 98,105 ----
  
  int gdbtk_test (char *);
  
+ static void view_command (char *, int);
+ 
  /* Handle for TCL interpreter */
  Tcl_Interp *gdbtk_interp = NULL;
  
*************** gdbtk_init (char *argv0)
*** 568,573 ****
--- 570,578 ----
    add_com ("tk", class_obscure, tk_command,
  	   "Send a command directly into tk.");
  
+   add_com ("view", class_obscure, view_command,
+ 	   "View a location in the source window.");
+ 
    /*
     * Set the variable for external editor:
     */
*************** tk_command (char *cmd, int from_tty)
*** 740,743 ****
--- 745,772 ----
    printf_unfiltered ("%s\n", result);
  
    do_cleanups (old_chain);
+ }
+ 
+ static void
+ view_command (char *args, int from_tty)
+ {
+   char *script;
+   struct cleanup *old_chain;
+ 
+   if (args != NULL)
+     {
+       xasprintf (&script,
+ 		 "[lindex [ManagedWin::find SrcWin] 0] location BROWSE_TAG [gdb_loc %s]",
+ 		 args);
+       old_chain = make_cleanup (xfree, script);
+       if (Tcl_Eval (gdbtk_interp, script) != TCL_OK)
+ 	{
+ 	  Tcl_Obj *obj = Tcl_GetObjResult (gdbtk_interp);
+ 	  error (Tcl_GetStringFromObj (obj, NULL));
+ 	}
+ 
+       do_cleanups (old_chain);
+     }
+   else
+     error ("Argument required (location to view)");
  }

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] GDB view command
  2002-08-19  9:31 Dave Roberts
@ 2002-08-19  9:43 ` Keith Seitz
  0 siblings, 0 replies; 3+ messages in thread
From: Keith Seitz @ 2002-08-19  9:43 UTC (permalink / raw)
  To: Dave Roberts; +Cc: insight

On Mon, 19 Aug 2002, Dave Roberts wrote:

> So you could double click on the function name, hit the right mouse, and
> have a menu option to "view function name" or "jump to function name",
> within the same window.

Ahh. That would probably be pretty easy, I think... If I find a minute 
I'll have a go.

Keith

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] GDB view command
@ 2002-08-19  9:31 Dave Roberts
  2002-08-19  9:43 ` Keith Seitz
  0 siblings, 1 reply; 3+ messages in thread
From: Dave Roberts @ 2002-08-19  9:31 UTC (permalink / raw)
  To: insight

Keith Seitz wrote:

> I've committed the following patch, which adds a new GDB command called 
> "view" which will display the given linespec in the source window

Excellent patch - that will be so useful.

One mod that would really enhance this would be to add that that on the
context sensitive menu within the source viewer. 

So you could double click on the function name, hit the right mouse, and
have a menu option to "view function name" or "jump to function name",
within the same window.

I'd have a go myself, but I've done zero Tcl/tk stuff.

- Dave.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-08-19 16:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-14  8:44 [PATCH] GDB view command Keith Seitz
2002-08-19  9:31 Dave Roberts
2002-08-19  9:43 ` Keith Seitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).