public inbox for insight@sourceware.org
 help / color / mirror / Atom feed
* looking for a way to enter in the file name and line # and display the source code on the screen
@ 2002-08-13 11:06 Benjamin Tze-Kit Lee
  2002-08-13 11:22 ` Keith Seitz
  0 siblings, 1 reply; 5+ messages in thread
From: Benjamin Tze-Kit Lee @ 2002-08-13 11:06 UTC (permalink / raw)
  To: insight

Hi all,

I would like to know which file or function it is to open up the source
code and display the source code line(s) on the user interface.

Thx a lot,
Ben



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

* Re: looking for a way to enter in the file name and line # and display the source code on the screen
  2002-08-13 11:06 looking for a way to enter in the file name and line # and display the source code on the screen Benjamin Tze-Kit Lee
@ 2002-08-13 11:22 ` Keith Seitz
  0 siblings, 0 replies; 5+ messages in thread
From: Keith Seitz @ 2002-08-13 11:22 UTC (permalink / raw)
  To: Benjamin Tze-Kit Lee; +Cc: insight

On Tue, 13 Aug 2002, Benjamin Tze-Kit Lee wrote:

> I would like to know which file or function it is to open up the source
> code and display the source code line(s) on the user interface.

You've three choices:

1) Use the "File Selector" (left-most combobox under the toolbar).
   If you hover the mouse it, it'll say "current file name". You can
   either select from the list or type something in. Insight will display
   the file.
2) Use the "Function Selector" (center combobox under the toolbar). If
   you hover the mouse over it, it'll say "current function name". Again
   either select from the list (of functions in the current file) or
   type in any function name and Insight will display it.
3) Use the Function Browser to search for the function you want to view.

Keith


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

* Re: looking for a way to enter in the file name and line # and display the source code on the screen
       [not found] <Pine.GSO.4.44.0208131448030.5593-100000@fraser.sfu.ca>
@ 2002-08-13 15:09 ` Keith Seitz
  0 siblings, 0 replies; 5+ messages in thread
From: Keith Seitz @ 2002-08-13 15:09 UTC (permalink / raw)
  To: Benjamin Tze-Kit Lee; +Cc: insight

On Tue, 13 Aug 2002, Benjamin Tze-Kit Lee wrote:

> That's not exactly what I want though.
> What I want to do is to create a function that would allow me to type in a
> linespec (ie. pc or file:line number or ...) on the prompt and the source
> code for that linespec would appear on the Source Window in Insight.

Ooooooooooooohhhhh. I see (I think). You want to be able to do something 
like:

[in Console Window]
(gdb) view foo.c:23

Then have foo.c:23 show up in the source window, right? That's easy 
enough...

There are two ways to do this:

1) Add something to Console::invoke to check for this new "view" command
   and run code like the one I showed in the last message
2) (preferred) Add a new gdb command in gdbtk.c (_initialize_gdbtk) or add
   _initialize_gdbtk_cmds in gdbtk-cmds.c. Something like:

   static void view_command (char *args, int from_tty);

   add_com ("view", class_obscure, view_command,
            "View a file/location in a source window.");
   -------------------------
   static void
   view_command (char *args, int from_tty)
   {
     char *script;
     xasprintf (&script, "[lindex [ManagedWin::find SrcWin] 0] location [gdb_loc %s]",
                args);
     Tcl_Eval (gdbtk_interp, script);
     xfree (script);
   }

I haven't tested this, but I think it should be close...
Keith

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

* Re: looking for a way to enter in the file name and line # and display the source code on the screen
  2002-08-13 12:17 ` Keith Seitz
@ 2002-08-13 12:19   ` Keith Seitz
  0 siblings, 0 replies; 5+ messages in thread
From: Keith Seitz @ 2002-08-13 12:19 UTC (permalink / raw)
  To: Benjamin Tze-Kit Lee; +Cc: insight

On Tue, 13 Aug 2002, Keith Seitz wrote:

> 	set srcwins [ManagedWin::find SrcWin]
> 	set firstSrcWin [lindex $srcwins 0]
> 	$firstSrcWin location BROWSE_TAG "foo.c:23"

Whoops. That last line should read:

	$firstSrcWin location BROWSE_TAG [gdb_loc foo.c:23]

Keith


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

* Re: looking for a way to enter in the file name and line # and display the source code on the screen
       [not found] <Pine.GSO.4.44.0208131210420.5593-100000@fraser.sfu.ca>
@ 2002-08-13 12:17 ` Keith Seitz
  2002-08-13 12:19   ` Keith Seitz
  0 siblings, 1 reply; 5+ messages in thread
From: Keith Seitz @ 2002-08-13 12:17 UTC (permalink / raw)
  To: Benjamin Tze-Kit Lee; +Cc: insight

On Tue, 13 Aug 2002, Benjamin Tze-Kit Lee wrote:

> How does it do that in the code though?  Where I can find that in the
> source code?

If you have a gdb linespec ("foo.c:23", "funcName", or "*0x1234"), then 
you can use the command "gdb_loc" in Tcl code to find out information 
about the location of this linespec.

If you want to just point the source window at some place 
programmatically, you can use SrcWin::location. It takes a linespec and a 
tag name to use, e.g.,

	set srcwins [ManagedWin::find SrcWin]
	set firstSrcWin [lindex $srcwins 0]
	$firstSrcWin location BROWSE_TAG "foo.c:23"

This will tell the first source window found in the window manager's list 
of windows to point itself at the file "foo.c", highlighting line "23" 
with the BROWSE_TAG (which is blue-ish by default).

Is this what you're after? If not, tell what you're attempting to do so I 
can provide more specific help.

Keith


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

end of thread, other threads:[~2002-08-13 22:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-13 11:06 looking for a way to enter in the file name and line # and display the source code on the screen Benjamin Tze-Kit Lee
2002-08-13 11:22 ` Keith Seitz
     [not found] <Pine.GSO.4.44.0208131210420.5593-100000@fraser.sfu.ca>
2002-08-13 12:17 ` Keith Seitz
2002-08-13 12:19   ` Keith Seitz
     [not found] <Pine.GSO.4.44.0208131448030.5593-100000@fraser.sfu.ca>
2002-08-13 15:09 ` 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).