Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@redhat.com>
To: Siva Chandra <sivachandra@google.com>
Cc: gdb-patches <gdb-patches@sourceware.org>
Subject: Re: [RFC] Debug Methods in GDB Python
Date: Mon, 22 Jul 2013 20:47:00 -0000	[thread overview]
Message-ID: <87ehaq5nkr.fsf@fleche.redhat.com> (raw)
In-Reply-To: <CAGyQ6gywGMDwmm9fHpPGhwE9vrki1VE8uDM2hRFEAvCZKaTyJg@mail.gmail.com>	(Siva Chandra's message of "Mon, 17 Jun 2013 11:59:44 -0700")

>>>>> "Siva" == Siva Chandra <sivachandra@google.com> writes:

Siva> Took me longer than I had expected I but could spend some time last
Siva> couple of weeks and address all of Tom's comments from last time. Like
Siva> before, I do not have docs or tests as the Python side API is largely
Siva> un-reviewed I guess. However, I have put in code comments in the
Siva> latest version. The patch is attached and the ChangeLog is as below:

Thanks.

I appreciate that you don't want to write all the docs and tests for a
moving target.  On the other hand, it's harder to review a patch that
doesn't have these.

A compromise would be if you wrote just the docs describing how it
works, say the Python API.  Then we could discuss this; and once ok, the
implementation would follow.

But, that is for future changes.  For this one, I think we're in general
agreement about the exposed API, and so polishing is a vital component.

Siva> +/* Registers an extension language with GDB.  */
Siva> +
Siva> +void
Siva> +register_ext_lang (struct ext_lang *lang)
Siva> +{
Siva> +  if (ext_lang_vec == NULL)
Siva> +    ext_lang_vec = VEC_alloc (ext_lang_p, 1);
Siva> +      
Siva> +  VEC_safe_push (ext_lang_p, ext_lang_vec, lang);

The "extension language" code here seems like a lot of work for no
real benefit.

It's fine for the functions themselves, since we'd like to keep the API
to the Python layer reasonably thin.  But for get_matching_ext_methods,
e.g., it is simple to follow the existing pattern: declare a function in
python.h and provide both with- and without-Python implementations.

Siva> +struct ext_lang
Siva> +  {
Siva> +    clone_ext_obj_ftype *clone_ext_object;
Siva> +    free_ext_obj_ftype *free_ext_obj;
Siva> +    get_matching_ext_methods_ftype *get_matching_ext_methods;
Siva> +    get_ext_fn_argtypes_ftype *get_ext_fn_argtypes;
Siva> +    invoke_method_ftype *invoke_method;
Siva> +  };

I think this struct should be given a different name.
Typical in gdb is "ops".

Siva> +extern struct ext_fn_descriptor *new_ext_function (struct ext_lang *lang,
Siva> +                                                   int is_method,
Siva> +                                                   void *ext_obj);

It seems like 'lang' should be const here.

Siva> +    and the method name.  It next get the argument types of these methods via

s/get/gets/

Siva> +    for old_method in existing_method_list:
Siva> +        objfile.debug_methods.remove(old_method)
Siva> +    objfile.debug_methods.extend(debug_methods)

I notice this patch adds "debug_methods" to the objfile but not the
program space.  Updating the latter, and also providing a global
debug_methods, is more in line with the other hooks we provide.

Siva> +py_free_ext_object (void *ext_object)
Siva> +{
Siva> +  struct py_ext_object *o = (struct py_ext_object *) ext_object;

You don't need casts to or from "void *".

Siva> +  enabled = PyObject_IsTrue (enabled_field);
Siva> +  if (enabled == -1)
Siva> +    {
Siva> +      PyErr_Clear ();
Siva> +      do_cleanups (cleanups);

Silently ignoring errors doesn't seem right.
There are a few instances of this.

I'm not really sure about the error-handling strategy in this function.

Siva> +static VEC (ext_fn_descriptor_p) *
Siva> +py_debugmethod_name_match (struct type *obj_type, const char *method_name)
[...]

Siva> +              if (method_vec == NULL)
Siva> +                method_vec = VEC_alloc (ext_fn_descriptor_p, 1);

You don't need to explicitly allocate a vec like this.
VEC_safe_push handles it.

Siva> +      self->debug_methods = PyList_New (0);
Siva> +      if (!self->debug_methods)

Now we write "== NULL".

Siva> +	  object->debug_methods = PyList_New (0);
Siva> +	  if (!object->debug_methods)

Ditto.

Siva> +int gdbpy_initialize_debugmethods (void)
Siva> +  CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;

I'm curious if you ran this through the checker.

It isn't a requirement; the checker gives enough false reports that it
is a bit of a pain.

Tom


  reply	other threads:[~2013-07-22 20:47 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-07 21:22 Siva Chandra
2013-01-29  1:51 ` Siva Chandra
2013-02-25 23:02   ` Siva Chandra
2013-05-10 19:33   ` Tom Tromey
2013-05-10 19:55     ` Siva Chandra
2013-05-14 19:33       ` Tom Tromey
2013-06-17 19:10         ` Siva Chandra
2013-07-22 20:47           ` Tom Tromey [this message]
2013-11-12  2:56             ` Siva Chandra
2013-11-15 22:28               ` Tom Tromey
2013-11-16  0:05                 ` Siva Chandra
2013-11-16  0:54                   ` Doug Evans
2013-11-16  1:03                     ` Siva Chandra
2013-11-16  2:48                       ` Siva Chandra
2013-11-20  0:03                         ` Doug Evans
2013-11-19 23:52                       ` Doug Evans
2013-11-20  0:39                         ` Siva Chandra
2013-11-20  2:48                         ` Doug Evans

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ehaq5nkr.fsf@fleche.redhat.com \
    --to=tromey@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=sivachandra@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox