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: Fri, 15 Nov 2013 22:28:00 -0000 [thread overview]
Message-ID: <87txfds4vf.fsf@fleche.redhat.com> (raw)
In-Reply-To: <CAGyQ6gwT5+Jmu4bqgakjCWmmZtWjbd83n0qq=B9ctfWjv7oS_w@mail.gmail.com> (Siva Chandra's message of "Mon, 11 Nov 2013 18:37:07 -0800")
>>>>> "Siva" == Siva Chandra <sivachandra@google.com> writes:
>> 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> I am not sure I understand what is being said here. Could you kindly
Siva> elaborate (pointing to an existing example)?
I think it's irrelevant now.
>> 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> They way I have looked at debug methods hook is as follows:
Siva> "If there exists a Python implementation or replacement which matches
Siva> better or is as good a match as the source implementation, then use
Siva> the Python implementation. If there is any error looking up Python
Siva> implementations, report the error but do not stop from executing an
Siva> operation; proceed to use the source implementation."
Siva> With that view, in the latest patch, I have modified to print the
Siva> errors instead of silently ignoring them. Let me know if this does not
Siva> seem to be a good strategy.
I think that's fine.
Swallowing exceptions is unfriendly for folks writing the Python code.
Ignoring them can be ok as long as they are printed at the point at
which they are dropped. Then one can at least see the stack trace and
fix the bug.
Siva> +optimized out. Lastly, one could define a debug method in @value{GDBN}
Siva> +Python which does not have an equivalent in the source language!
Very interesting. I was going to ask about that. I'd like to see it
done in the tests...
I think I'm ok with the overall approach.
I didn't read every single bit in detail. So I didn't go over the
error-checking and reference counting bits the way I normally would.
I can do that if you want; but meanwhile I think if you wrote the
tests...
Also I was curious if this supports operator overloading. Like can I
define an "operator+"?
Siva> + if (ext_fnp)
Siva> + {
Siva> + if (ext_fn_is_method (ext_fnp))
Siva> + {
Siva> + struct value *ret_val;
Siva> +
Siva> + ret_val = ext_fn_invoke_method (ext_fnp, arg2, argvec + 2,
Siva> + nargs - 1);
Siva> + if (ret_val == NULL)
Siva> + error (_("Error invoking debug method for method %s."),
Siva> + tstr);
Siva> +
Siva> + return ret_val;
Siva> + }
Siva> + }
What happens here if "ext_fnp && !ext_fn_is_method"?
It seems like a check is needed.
Siva> +struct py_ext_object
Siva> +{
Siva> + /* Holds an instance of the DebugMethod class. */
Siva> + PyObject *object;
Siva> +
Siva> + /* Holds the type of the 'this' object. */
Siva> + PyObject *match_py_obj_type;
Siva> +
Siva> + /* Holds the matching method name. */
Siva> + const char *match_method;
How "match_method" is allocated and how its lifetime is managed is
really unclear to me.
Tom
next prev parent reply other threads:[~2013-11-15 22:00 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
2013-11-12 2:56 ` Siva Chandra
2013-11-15 22:28 ` Tom Tromey [this message]
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=87txfds4vf.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