[Crash-utility] Re: Hack to get filename completion for the mod command

Dave Anderson anderson at redhat.com
Tue Nov 3 19:00:37 UTC 2009


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

> On Mon, 2009-11-02 at 22:31 +0000, Dave Anderson wrote:
> > ----- "Bob Montgomery" <bob.montgomery at 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




 




More information about the Crash-utility mailing list