This is the mail archive of the insight@sources.redhat.com mailing list for the Insight project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] GDB view command


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)");
  }


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