This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH V3 1/9] Adapt `info probes' to support printing probes of different types.
- From: Sergio Durigan Junior <sergiodj at redhat dot com>
- To: Pedro Alves <palves at redhat dot com>
- Cc: "Jose E. Marchesi" <jose dot marchesi at oracle dot com>, gdb-patches at sourceware dot org
- Date: Mon, 17 Nov 2014 12:45:29 -0500
- Subject: Re: [PATCH V3 1/9] Adapt `info probes' to support printing probes of different types.
- Authentication-results: sourceware.org; auth=none
- References: <1414504218-31204-1-git-send-email-jose dot marchesi at oracle dot com> <1414504218-31204-2-git-send-email-jose dot marchesi at oracle dot com> <87oass6pbc dot fsf at redhat dot com> <5465F7A5 dot 8040207 at redhat dot com> <87lhnd754a dot fsf at redhat dot com> <546A23F8 dot 2030007 at redhat dot com>
On Monday, November 17 2014, Pedro Alves wrote:
> On 11/14/2014 11:08 PM, Sergio Durigan Junior wrote:
>> On Friday, November 14 2014, Pedro Alves wrote:
>>
>>> On 10/31/2014 06:56 PM, Sergio Durigan Junior wrote:
>>>> Also, any particular reason why you did not create a field "type" inside
>>>> "struct probe", instead of making a function that returns the string? I
>>>> consider the field would be simpler (i.e., not pollute the probe_ops
>>>> structure), and it could be set when creating the probes.
>>>
>>> Not sure I understood it (and probably doesn't matter much), seems like
>>> that'd waste memory storing the same info over and over?
>>
>> We would be wasting sizeof (char *) for each probe created, indeed, but
>> I think this is clearer (also for debugging purposes) than having all
>> the necessary machinery to call a function that will return the same
>> info...
>
> IMO, that's not cleaner, because the type name is a property of
> the type, not of the instance, so it makes sense to get it from the
> type (thus through an ops method). Writing the equivalent C++ may
> make it clearer. Something like:
Fair enough, looking from this perspective I am convinced.
> struct probe
> {
> ...
> virtual const char *type_name () = 0;
> };
>
> struct stap_probe : public probe
> {
> ...
> virtual const char *type_name () { return "stap"; }
> };
>
> struct dtrace_probe : public probe
> {
> ...
> virtual const char *type_name () { return "dtrace"; }
> };
>
>
> And then in info_probes_for_ops:
>
> const char *probe_type = probe->probe->type_name ();
>
>>
>> Anyway, I won't oppose the current approach too, I was just curious :-P.
>
>
> Thanks,
> Pedro Alves
--
Sergio
GPG key ID: 0x65FC5E36
Please send encrypted e-mail if possible
http://sergiodj.net/