Discussion:
archer/tromey patches left to merge
Phil Muldoon
2013-10-14 11:26:34 UTC
Permalink
Currently we still have some patches in the archer tromey/python
branch. I want to finally close this branch, so I decided to write an
email about what is left, and try to decide what we should do about
those patches. Here is what we have left:

* The -P, --python command line switch

This feature changes interpretation of the command line so that the
argument immediately following this switch is taken to be the name
of a Python script file. This option stops option processing;
subsequent options are passed to Python as sys.argv.

* gdb.cli() command.

This invokes a GDB command-line from a Python script. Usage of this
command (AFAIK) is exclusively with the -P switch. (You cannot run
this command from the gdb command line -- it generates an error
about recursive instantiatiations.)

I understand why this exists (to invoke an interactive GDB
command-line from a Python script), but I feel a little dubious
about it. Can we can construct a solid-use case for it?

* maint set python auto-load.

Enable/disable the auto-loading of Python scripts when an object
file is opened.

I think this patch is dead. It has been superseded by a the more
generic and powerful gdb auto-load commands.

* require command.

This command loads on demand a Python script that registers a gdb
command and which has not been auto-loaded at start-up. This makes
it easier to load GDB commands written in Python.

* ignore_errors command.

A wrapper which executes a single command, ignoring and suppressing
all errors.

I think this patch is dead. Users can deal with these exceptions
independently.

* pahole command.

Show the holes in a structure. Takes a type. Comment on those areas
where it thinks it detects a hole.

I think this command is generally useful. I think I remember some
comments about some problems with it. I am hoping the discussion
regarding the problems can be rewritten and posted here.

* caller_is convenience function.

This function determines if the calling function's name is equal to
a string that is passed to it. It takes an optional argument to
traverse n stack frames to find the function.

I think this a useful convenience function. It returns Boolean
values, so is useful in GDB via the $ convenience variable
functionality. An additional option that would be useful would be
the ability to tell the function to traverse the entire stack.

* caller_matches convenience function.

Same as above, but use re.match for the comparison. I think this
functionality should be rolled into caller_is.

* in_scope convenience function.

Return true if all the given variables and macros provided to it are
in scope. This function takes a variable amount of arguments, and
will only Return true if all the arguments are in scope.

There are a few other bits and pieces in there. Most, as far as I can
determine, are just some orphaned bits of code.

So, lets decide what we want to port to upstream and what we can get
rid of.

Cheers,

Phil
Tom Tromey
2013-10-14 14:37:57 UTC
Permalink
Phil> * gdb.cli() command.
[...]
Phil> I understand why this exists (to invoke an interactive GDB
Phil> command-line from a Python script), but I feel a little dubious
Phil> about it. Can we can construct a solid-use case for it?

The idea is to be able to write a "mostly invisible" invocation of gdb.
That is, start gdb on some program and run it; perhaps setting
breakpoints or whatever in a script; and have this gdb not print
anything and otherwise be as invisible as possible. Then, if something
"interesting" happens, start up the gdb CLI.

Phil> * maint set python auto-load.
Phil> I think this patch is dead. It has been superseded by a the more
Phil> generic and powerful gdb auto-load commands.

Yes.

Phil> * require command.
Phil> This command loads on demand a Python script that registers a gdb
Phil> command and which has not been auto-loaded at start-up. This makes
Phil> it easier to load GDB commands written in Python.

This is obsolete. We automatically load these things now.

Phil> * ignore_errors command.
Phil> A wrapper which executes a single command, ignoring and suppressing
Phil> all errors.
Phil> I think this patch is dead. Users can deal with these exceptions
Phil> independently.

No, not dead, this comes up pretty regularly.
There was some upstream discussion about whether we want this or the old
"try-catch" patch that is in bugzilla.

Phil> * pahole command.

Phil> Show the holes in a structure. Takes a type. Comment on those areas
Phil> where it thinks it detects a hole.

Phil> I think this command is generally useful. I think I remember some
Phil> comments about some problems with it. I am hoping the discussion
Phil> regarding the problems can be rewritten and posted here.

I think there are bugs with virtual bases; and it only prints in C
syntax.

One alternative idea would be to simply make this an option to ptype.
That's probably better most of the time.

Phil> * caller_is convenience function.

Definitely upstream.

Phil> * caller_matches convenience function.

Phil> Same as above, but use re.match for the comparison. I think this
Phil> functionality should be rolled into caller_is.

I don't see how to roll it in, but definitely worth having upstream.

Phil> * in_scope convenience function.

Phil> Return true if all the given variables and macros provided to it are
Phil> in scope. This function takes a variable amount of arguments, and
Phil> will only Return true if all the arguments are in scope.

I don't know whether this one is useful or not.
There was a "bad" patch for this functionality upstream, so I wrote this
function to show how it could be done.

Tom
Phil Muldoon
2013-10-14 19:27:00 UTC
Permalink
Post by Tom Tromey
Phil> * gdb.cli() command.
[...]
Thanks for the reply Tom. Here is my plan, pending other comments.

* Merge caller_is and caller_matches functions.

I will keep them as two separate functions. My first thought was to
achieve the results of both with optional keyword arguments, but
after investigating a little this would probably end up with a
function heavily loaded with conditional keyword arguments. It
removes simplicity and adds complexity, so going with how it stands
now. I will add the option to search the entire stack. I will need
to write tests and documentation for both.

* Merge -P and gdb.cli()

These two patches will be merged as one submission as they seem to
be complimentary in a use-case sense. I will need to write tests
and documentation for both. The -P tests and the gdb.cli() tests
seem to be non-trivial in the GDB test suite.

* Merge ignore_errors command.

Tom provided a case that it is needed. Needs tests and
documentation.

* Merge in_scope function.

I think this is useful, so I will port it. Needs test and
documentation. (As an aside, I am not sure where we should document
these python only functions. Will discuss.)

* Merge pahole command.

I am not sure how to make this language agnostic, or even how to
make it complimentary with ptype. (We will discuss this more when
the time-slot arrives in my schedule to consider the effort of
porting it).

That's the order I intend to work on them as time allows. Lastly, I
will delete the defunct code orphans and remove the obsoleted commands
from the branch.

Cheers,

Phil
Tom Tromey
2013-10-14 19:31:32 UTC
Permalink
Phil> * Merge pahole command.

Phil> I am not sure how to make this language agnostic, or even how to
Phil> make it complimentary with ptype. (We will discuss this more when
Phil> the time-slot arrives in my schedule to consider the effort of
Phil> porting it).

The idea would be to put it in the C code.

A separate commands, as it is now, is definitely simpler.
I think it is just a bit odd from a UI perspective.

Tom

Loading...