From: Simon Marchi <simark@simark.ca>
To: "Willgerodt, Felix" <felix.willgerodt@intel.com>,
"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: [PATCH v8 05/10] python: Introduce gdb.RecordAuxiliary class.
Date: Mon, 3 Apr 2023 15:06:22 -0400 [thread overview]
Message-ID: <526e6b42-9bfc-17c8-6a0b-8581bf527af7@simark.ca> (raw)
In-Reply-To: <MN2PR11MB4566DEA8D1594D470818F2BA8E8F9@MN2PR11MB4566.namprd11.prod.outlook.com>
On 3/31/23 06:58, Willgerodt, Felix wrote:
>> -----Original Message-----
>> From: Simon Marchi <simark@simark.ca>
>> Sent: Freitag, 24. März 2023 15:28
>> To: Willgerodt, Felix <felix.willgerodt@intel.com>; gdb-
>> patches@sourceware.org
>> Subject: Re: [PATCH v8 05/10] python: Introduce gdb.RecordAuxiliary class.
>>
>> On 3/21/23 11:46, Felix Willgerodt via Gdb-patches wrote:
>>> @@ -163,6 +165,14 @@ btpy_insn_or_gap_new (thread_info *tinfo,
>> Py_ssize_t number)
>>> return recpy_gap_new (err_code, err_string, number);
>>> }
>>>
>>> + const struct btrace_insn *insn = btrace_insn_get (&iter);
>>> + gdb_assert (insn != nullptr);
>>> +
>>> + if (insn->iclass == BTRACE_INSN_AUX)
>>> + return recpy_aux_new
>>> + (iter.btinfo->aux_data.at (insn->aux_data_index).c_str (), number);
>>
>> Not really important, but recpy_aux_new could take a
>> `const std::string &`, it would simplify callers a bit.
>
> Thanks, I will do that.
>
>>> +
>>> +
>>
>> Remove one newline.
>
> Done.
>
>>> +/* Implementation of Auxiliary.data [str]. */
>>> +
>>> +static PyObject *
>>> +recpy_aux_data (PyObject *self, void *closure)
>>> +{
>>> + const recpy_aux_object * const obj = (const recpy_aux_object *) self;
>>> +
>>> + return PyUnicode_FromString (obj->data);
>>> +}
>>
>> Nothing new with this patch, since this is the same pattern used for
>> other object, but just wondering: obj->data seems to be borrowed from
>> the btrace backend. Are there some lifetime issues if you do:
>>
>> 1. Create a gdb.RecordAuxiliary object "b"
>> 2. Issue a gdb command to clear the btrace data
>> 3. Access "b.data"
>>
>> ? It seems to me like obj->data might point to freed data.
>
> About the pattern:
> There is already "maint btrace clear" so I could test and debug this with
> master. On master GDB prints an error before accessing any of these objects,
> as we check if the trace is empty before accessing anything.
Then, maybe if you record something after clearing the data? Something
like:
1. Create a gdb.RecordAuxiliary object "b"
2. Issue "maint btrace clear"
3. Do one step (to make the trace non-empty again)
4. Access "b.data"
> With my patch I could however see a nullptr access. But not at this part of the code.
> I think I need to rethink the modelling of Auxiliary objects as new objects.
> We model them as a class of instruction in btrace.c.
> And the python lists we put them in are designed to be a list of a specific type of object.
Which list are you referring to?
Simon
next prev parent reply other threads:[~2023-04-03 19:06 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-21 15:46 [PATCH v8 00/10] Extensions for PTWRITE Felix Willgerodt
2023-03-21 15:46 ` [PATCH v8 01/10] btrace: Introduce auxiliary instructions Felix Willgerodt
2023-03-21 15:46 ` [PATCH v8 02/10] btrace: Enable auxiliary instructions in record instruction-history Felix Willgerodt
2023-03-21 15:46 ` [PATCH v8 03/10] btrace: Enable auxiliary instructions in record function-call-history Felix Willgerodt
2023-03-21 15:46 ` [PATCH v8 04/10] btrace: Handle stepping and goto for auxiliary instructions Felix Willgerodt
2023-03-24 14:09 ` Simon Marchi
2023-03-31 10:58 ` Willgerodt, Felix
2023-03-21 15:46 ` [PATCH v8 05/10] python: Introduce gdb.RecordAuxiliary class Felix Willgerodt
2023-03-24 14:27 ` Simon Marchi
2023-03-31 10:58 ` Willgerodt, Felix
2023-04-03 19:06 ` Simon Marchi [this message]
2023-04-04 6:57 ` Metzger, Markus T
2023-04-04 14:17 ` Simon Marchi
2023-04-04 14:26 ` Willgerodt, Felix
2023-03-21 15:46 ` [PATCH v8 06/10] python: Add clear() to gdb.Record Felix Willgerodt
2023-03-24 14:36 ` Simon Marchi
2023-03-31 10:58 ` Willgerodt, Felix
2023-03-21 15:46 ` [PATCH v8 07/10] btrace, gdbserver: Add ptwrite to btrace_config_pt Felix Willgerodt
2023-03-21 15:46 ` [PATCH v8 08/10] btrace, linux: Enable ptwrite packets Felix Willgerodt
2023-03-21 15:46 ` [PATCH v8 09/10] btrace, python: Enable ptwrite filter registration Felix Willgerodt
2023-03-24 15:23 ` Simon Marchi
2023-03-31 10:58 ` Willgerodt, Felix
2023-04-03 20:44 ` Simon Marchi
2023-04-04 14:42 ` Willgerodt, Felix
2023-04-04 15:06 ` Simon Marchi
2023-04-05 10:20 ` Willgerodt, Felix
2023-04-05 20:27 ` Simon Marchi
2023-04-06 9:44 ` Willgerodt, Felix
2023-03-21 15:46 ` [PATCH v8 10/10] btrace: Extend ptwrite event decoding Felix Willgerodt
2023-03-24 15:40 ` Simon Marchi
2023-03-31 10:58 ` Willgerodt, Felix
2023-04-04 14:23 ` Simon Marchi
2023-03-24 13:56 ` [PATCH v8 00/10] Extensions for PTWRITE Simon Marchi
2023-03-24 18:23 ` Tom Tromey
2023-03-24 18:28 ` Simon Marchi
2023-03-24 22:29 ` Tom Tromey
2023-03-31 10:57 ` Willgerodt, Felix
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=526e6b42-9bfc-17c8-6a0b-8581bf527af7@simark.ca \
--to=simark@simark.ca \
--cc=felix.willgerodt@intel.com \
--cc=gdb-patches@sourceware.org \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).