Re: Hack to get filename completion for the mod command
by Dave Anderson
----- "Bob Montgomery" <bob.montgomery(a)hp.com> wrote:
> On Mon, 2009-11-02 at 22:31 +0000, Dave Anderson wrote:
> > ----- "Bob Montgomery" <bob.montgomery(a)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
15 years, 1 month
Re: Hack to get filename completion for the mod command
by Dave Anderson
----- "Bob Montgomery" <bob.montgomery(a)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
15 years, 1 month
Hack to get filename completion for the mod command
by Bob Montgomery
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.
It does change the behavior of "crash> gdb help mod" and "crash> gdb
mod".
Bob Montgomery
15 years, 1 month