This is the mail archive of the
insight@sources.redhat.com
mailing list for the Insight project.
Re: looking for a way to enter in the file name and line # anddisplay the source code on the screen
- From: Keith Seitz <keiths at redhat dot com>
- To: Benjamin Tze-Kit Lee <btlee at sfu dot ca>
- Cc: insight at sources dot redhat dot com
- Date: Tue, 13 Aug 2002 15:12:00 -0700 (PDT)
- Subject: Re: looking for a way to enter in the file name and line # anddisplay the source code on the screen
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