FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Crash Utility

 
 
LinkBack Thread Tools
 
Old 11-02-2009, 09:31 PM
Dave Anderson
 
Default Hack to get filename completion for the mod command

----- "Bob Montgomery" <bob.montgomery@hp.com> wrote:

> The mod command won't do filename completion.
> Sometimes I set up a big ugly directory path for mod -S by starting with
> the dir command, using its filename completion to get the modules
> directory, and then command-line editing the dir command into a mod -S
> command before executing it. Ahem.
>
> This hacky patch allows crash to tell gdb that "mod" is a command that
> should get filename completion. It's pretty un-smart filename
> completion, e.g. doesn't know that sometimes it should be selecting from
> a list of modules instead of filenames, etc. And it messes with the
> separation of crash and gdb.
>
> But mod -S <tab><tab> seems to work.

By any chance, does the "non-standard module directory option" that went
into 4.0-8.10 work for you, i.e., letting the bash command line do the
command line completion work:

# crash vmlinux [vmcore] --mod <directory>

Then "mod -S" works by searching from the specified <directory> on down.

http://people.redhat.com/anderson/crash.changelog.html#4_0_8_10

> It does change the behavior of "crash> gdb help mod" and "crash> gdb
> mod".

Huh?

Dave

--
Crash-utility mailing list
Crash-utility@redhat.com
https://www.redhat.com/mailman/listinfo/crash-utility
 
Old 11-03-2009, 05:30 PM
Bob Montgomery
 
Default Hack to get filename completion for the mod command

On Mon, 2009-11-02 at 22:31 +0000, Dave Anderson wrote:
> ----- "Bob Montgomery" <bob.montgomery@hp.com> wrote:

> > This hacky patch allows crash to tell gdb that "mod" is a command that
> > should get filename completion.

>
> By any chance, does the "non-standard module directory option" that went
> into 4.0-8.10 work for you, i.e., letting the bash command line do the
> command line completion work:
>
> # crash vmlinux [vmcore] --mod <directory>
>
> Then "mod -S" works by searching from the specified <directory> on down.

> http://people.redhat.com/anderson/crash.changelog.html#4_0_8_10

I'll take a look at this. I was mostly curious why some crash commands
had filename completion and some (like mod) did not.
>
> > It does change the behavior of "crash> gdb help mod" and "crash> gdb
> > mod".

> Huh?

I was trying to point out that by adding "mod" to gdb's list of
commands, so that I could tell gdb to use filename completion when
working on the command line of a "mod" command, I also made it appear to
gdb that "mod" was one of its commands (with a dummy do-nothing
execution function). Normally crash grabs mod, so gdb never gets a
chance to try to execute it. With this patch, if you send "mod" to gdb
(with "gdb mod"), gdb will execute it. So the behavior goes from:

crash-4.1.0> gdb mod
Undefined command: "mod". Try "help".

to this with the patch:
crash> gdb mod
crash>

(Just trying to be thorough :-)

This technique would allow you to add filename completion to any non-gdb
command that might need it. For instance, you can add filename
completion to "ls" and "less" (or any of the other "external" commands)
in addition to "mod" with:
crashcmd_filename_completion("mod");
crashcmd_filename_completion("ls");
crashcmd_filename_completion("less");


Bob Montgomery



--
Crash-utility mailing list
Crash-utility@redhat.com
https://www.redhat.com/mailman/listinfo/crash-utility
 
Old 11-03-2009, 06:00 PM
Dave Anderson
 
Default Hack to get filename completion for the mod command

----- "Bob Montgomery" <bob.montgomery@hp.com> wrote:

> On Mon, 2009-11-02 at 22:31 +0000, Dave Anderson wrote:
> > ----- "Bob Montgomery" <bob.montgomery@hp.com> wrote:
>
> > > This hacky patch allows crash to tell gdb that "mod" is a command that
> > > should get filename completion.
>
> >
> > By any chance, does the "non-standard module directory option" that went
> > into 4.0-8.10 work for you, i.e., letting the bash command line do the
> > command line completion work:
> >
> > # crash vmlinux [vmcore] --mod <directory>
> >
> > Then "mod -S" works by searching from the specified <directory> on down.
>
> > http://people.redhat.com/anderson/crash.changelog.html#4_0_8_10
>
> I'll take a look at this. I was mostly curious why some crash commands
> had filename completion and some (like mod) did not.

I'm sure I don't know why some crasg commands would and some wouldn't?
I've never tried it, but it must have something to do with the setting
up of the readline interface, right?

> >
> > > It does change the behavior of "crash> gdb help mod" and "crash> gdb mod".
>
> > Huh?
>
> I was trying to point out that by adding "mod" to gdb's list of
> commands, so that I could tell gdb to use filename completion when
> working on the command line of a "mod" command, I also made it appear to
> gdb that "mod" was one of its commands (with a dummy do-nothing
> execution function). Normally crash grabs mod, so gdb never gets a
> chance to try to execute it. With this patch, if you send "mod" to gdb
> (with "gdb mod"), gdb will execute it. So the behavior goes from:
>
> crash-4.1.0> gdb mod
> Undefined command: "mod". Try "help".
>
> to this with the patch:
> crash> gdb mod
> crash>
>
> (Just trying to be thorough :-)
>
> This technique would allow you to add filename completion to any non-gdb
> command that might need it. For instance, you can add filename completion
> to "ls" and "less" (or any of the other "external" commands)
> in addition to "mod" with:
> crashcmd_filename_completion("mod");
> crashcmd_filename_completion("ls");
> crashcmd_filename_completion("less");

What would worry me about that is the error/exception handling, because
it would take it out of the crash code and put it in the gdb code.
Especially in the case of the "mod" command. It's all set up in the
upper-level crash sources, so by somehow having gdb take over the "mod"
command, and then have gdb call back to the upper-level crash function,
and then having some part of that piece fail, the error handling and
exception thow-backs get a bit murky. I suppose it could be done, but
I would prefer that crash commands stay as crash commands and gdb commands
stay as gdb commands, and I would hate to intermingle them. If you follow
the filename completion code in gdb (I haven't looked at it), I wonder if it
just tinkers with readline settings?

Dave






--
Crash-utility mailing list
Crash-utility@redhat.com
https://www.redhat.com/mailman/listinfo/crash-utility
 
Old 11-03-2009, 06:41 PM
Bob Montgomery
 
Default Hack to get filename completion for the mod command

On Tue, 2009-11-03 at 19:00 +0000, Dave Anderson wrote:
> ----- "Bob Montgomery" <bob.montgomery@hp.com> wrote:

> I'm sure I don't know why some crasg commands would and some wouldn't?
> I've never tried it, but it must have something to do with the setting
> up of the readline interface, right?

No crash commands do right now, only gdb commands.


> What would worry me about that is the error/exception handling, because
> it would take it out of the crash code and put it in the gdb code.
> Especially in the case of the "mod" command. It's all set up in the
> upper-level crash sources, so by somehow having gdb take over the "mod"
> command, and then have gdb call back to the upper-level crash function,
> and then having some part of that piece fail, the error handling and
> exception thow-backs get a bit murky. I suppose it could be done, but
> I would prefer that crash commands stay as crash commands and gdb commands
> stay as gdb commands, and I would hate to intermingle them. If you follow
> the filename completion code in gdb (I haven't looked at it), I wonder if it
> just tinkers with readline settings?

There is no issue with error handling because gdb is not executing
crash's mod function. gdb is only doing the readline like it always
has, and sending back the completed command line to crash. Then crash
executes the command line with exec_command like it always has. The
only thing I've changed is to modify gdb's readline settings to include
allowing filename completion for any command line that starts with "mod"
(or "less", or "ls"...). The reason I pointed out what happens when you
do "gdb mod", was to show that I was *not* having gdb do a callback to
crash to execute mod, since what gdb executes when it thinks it's doing
mod is a no-op function. The "mod" command still works the same as
always, except that the first step using gdb's readline function is now
able to allow filename completion for any command that you set up with
my crashcmd_filename_completion() call.
I just didn't see how to change the readline settings without also
putting an entry for "mod" into gdb's command table, since it appears to
use the same entries for both readline features and actual command
stuff. But I made that entry a dummy, just in case some smart alec
decides to force gdb to execute "mod" by doing "gdb mod" instead of just
"mod".

Bob Montgomery


--
Crash-utility mailing list
Crash-utility@redhat.com
https://www.redhat.com/mailman/listinfo/crash-utility
 
Old 11-03-2009, 07:11 PM
Dave Anderson
 
Default Hack to get filename completion for the mod command

----- "Bob Montgomery" <bob.montgomery@hp.com> wrote:

> On Tue, 2009-11-03 at 19:00 +0000, Dave Anderson wrote:
> > ----- "Bob Montgomery" <bob.montgomery@hp.com> wrote:
>
> > I'm sure I don't know why some crasg commands would and some wouldn't?
> > I've never tried it, but it must have something to do with the setting
> > up of the readline interface, right?
>
> No crash commands do right now, only gdb commands.

(at least one of them does -- see below...)

> > What would worry me about that is the error/exception handling, because
> > it would take it out of the crash code and put it in the gdb code.
> > Especially in the case of the "mod" command. It's all set up in the
> > upper-level crash sources, so by somehow having gdb take over the "mod"
> > command, and then have gdb call back to the upper-level crash function,
> > and then having some part of that piece fail, the error handling and
> > exception thow-backs get a bit murky. I suppose it could be done, but
> > I would prefer that crash commands stay as crash commands and gdb commands
> > stay as gdb commands, and I would hate to intermingle them. If you follow
> > the filename completion code in gdb (I haven't looked at it), I wonder if it
> > just tinkers with readline settings?
>
> There is no issue with error handling because gdb is not executing
> crash's mod function. gdb is only doing the readline like it always
> has, and sending back the completed command line to crash. Then crash
> executes the command line with exec_command like it always has. The
> only thing I've changed is to modify gdb's readline settings to include
> allowing filename completion for any command line that starts with "mod"
> (or "less", or "ls"...). The reason I pointed out what happens when you
> do "gdb mod", was to show that I was *not* having gdb do a callback to
> crash to execute mod, since what gdb executes when it thinks it's doing
> mod is a no-op function. The "mod" command still works the same as
> always, except that the first step using gdb's readline function is now
> able to allow filename completion for any command that you set up with
> my crashcmd_filename_completion() call.
> I just didn't see how to change the readline settings without also
> putting an entry for "mod" into gdb's command table, since it appears to
> use the same entries for both readline features and actual command
> stuff. But I made that entry a dummy, just in case some smart alec
> decides to force gdb to execute "mod" by doing "gdb mod" instead of
> just "mod".

Interesting. If you use the crash "whatis" command, it *does* seem
to have filename-completion tendencies. And that's probably because
gdb has its own "whatis" command which has set the appropriate
readline parameters. So I'm still convinced it's all readline magic,
so that if you really wanted this kind of feature, it could be done
directly without mucking with the gdb code?

In any case, right now I can't wrap my head around this because I just
started working on the transition to gdb-7.0...

In any case, achieving the "mod -S" filename completion works for me
by just using "--mod" on the bash command line during invocation.

Dave

--
Crash-utility mailing list
Crash-utility@redhat.com
https://www.redhat.com/mailman/listinfo/crash-utility
 

Thread Tools




All times are GMT. The time now is 06:17 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org