public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: "Willgerodt, Felix" <felix.willgerodt@intel.com>
To: "Metzger, Markus T" <markus.t.metzger@intel.com>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: RE: [PATCH v10 05/10] python: Introduce gdb.RecordAuxiliary class.
Date: Wed, 30 Aug 2023 08:39:44 +0000	[thread overview]
Message-ID: <MN2PR11MB456661F08C3C0CC722BDB2068EE6A@MN2PR11MB4566.namprd11.prod.outlook.com> (raw)
In-Reply-To: <BN0PR11MB5757202DAC8826C130BED093DE12A@BN0PR11MB5757.namprd11.prod.outlook.com>

> -----Original Message-----
> From: Metzger, Markus T <markus.t.metzger@intel.com>
> Sent: Mittwoch, 9. August 2023 12:01
> To: Willgerodt, Felix <felix.willgerodt@intel.com>
> Cc: gdb-patches@sourceware.org; simark@simark.ca
> Subject: RE: [PATCH v10 05/10] python: Introduce gdb.RecordAuxiliary class.
> 
> Hello Felix,
> 
> >> >> >@@ -455,10 +511,10 @@ btpy_list_item (PyObject *self, Py_ssize_t
> index)
> >> >> >
> >> >> >   number = obj->first + (obj->step * index);
> >> >> >
> >> >> >-  if (obj->element_type == &recpy_insn_type)
> >> >> >-    return recpy_insn_new (obj->thread, RECORD_METHOD_BTRACE,
> >> number);
> >> >> >-  else
> >> >> >+  if (obj->element_type == &recpy_func_type)
> >> >> >     return recpy_func_new (obj->thread, RECORD_METHOD_BTRACE,
> >> number);
> >> >> >+  else
> >> >> >+    return btpy_item_new (obj->thread, number);
> >> >> > }
> >> >>
> >> >> Why do we need to change the order?
> >> >
> >> >Because we no longer call recpy_insn_new only for recpy_insn_type but also
> for
> >> >recpy_aux_type.
> >>
> >> I think it would be clearer if we checked each type separately and errored
> >> out by default.  Like a switch.
> >
> >I can put something like this:
> >
> >  if (obj->element_type == &recpy_func_type)
> >    return recpy_func_new (obj->thread, RECORD_METHOD_BTRACE, number);
> >  else if (obj->element_type == &recpy_insn_type
> >	   || obj->element_type == &recpy_aux_type)
> >    return btpy_item_new (obj->thread, number);
> >  else
> >    return PyErr_Format (gdbpy_gdb_error, _("Not a valid BtraceList object."));
> >
> >I don't think we can reach the error case right now though.
> 
> We will reach the error case when we add a new element type and forget to
> update this function.
> 
> LGTM.
> 
> Maybe it makes sense to split btpy_item_new() again so we do not accidentally
> create an insn object with a recpy_aux_type or vice versa.
> 
> How about aux objects in the function call history?  This is supported on CLI if
> I read patch 3 correctly.

Yes, it is showing in CLI. In Python it is a bit more hidden, but also accessible.
The function call history is a list of RecoredFunctionSegment objects. No aux
objects there. But, the RecordFunctionSegment objects all have the instructions
listed as a member:

>>> r = gdb.current_recording()
>>> h = r.function_call_history
>>> h[1]
<gdb.RecordFunctionSegment object at 0x7f76b4587210>
>>> h[1].instructions
<gdb.BtraceObjectList object at 0x7f76ac0abb30>
>>> h[1].instructions[7]
<gdb.RecordInstruction object at 0x7f769c257a50>
>>> h[1].instructions[8]
<gdb.RecordAuxiliary object at 0x7f76b455c8d0>

So a user can still access all the same information. In GDB code, we basically do
the same, just that in the CLI variant of record function-call-history GDB also
searches the insn list for aux objects, and prints them. In Python the user has to
do that himself right now.

I don't think putting aux objects also in the function_call_history would be a
good idea. That would duplicate things.

Anyway, I will change it as we agreed on above.

Felix
Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva  
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928

  reply	other threads:[~2023-08-30  8:39 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-18 11:56 [PATCH v10 00/10] Extensions for PTWRITE Felix Willgerodt
2023-07-18 11:56 ` [PATCH v10 01/10] btrace: Introduce auxiliary instructions Felix Willgerodt
2023-07-18 11:56 ` [PATCH v10 02/10] btrace: Enable auxiliary instructions in record instruction-history Felix Willgerodt
2023-07-18 11:56 ` [PATCH v10 03/10] btrace: Enable auxiliary instructions in record function-call-history Felix Willgerodt
2023-07-18 11:56 ` [PATCH v10 04/10] btrace: Handle stepping and goto for auxiliary instructions Felix Willgerodt
2023-07-18 11:56 ` [PATCH v10 05/10] python: Introduce gdb.RecordAuxiliary class Felix Willgerodt
2023-07-25 13:30   ` Metzger, Markus T
2023-08-07  9:08     ` Willgerodt, Felix
2023-08-08  9:37       ` Metzger, Markus T
2023-08-09  9:32         ` Willgerodt, Felix
2023-08-09 10:00           ` Metzger, Markus T
2023-08-30  8:39             ` Willgerodt, Felix [this message]
2023-07-18 11:56 ` [PATCH v10 06/10] python: Add clear() to gdb.Record Felix Willgerodt
2023-07-18 13:00   ` Eli Zaretskii
2023-07-18 11:56 ` [PATCH v10 07/10] btrace, gdbserver: Add ptwrite to btrace_config_pt Felix Willgerodt
2023-07-18 11:56 ` [PATCH v10 08/10] btrace, linux: Enable ptwrite packets Felix Willgerodt
2023-07-25 13:30   ` Metzger, Markus T
2023-08-07  9:10     ` Willgerodt, Felix
2023-08-08 10:13       ` Metzger, Markus T
2023-08-09  9:31         ` Willgerodt, Felix
2023-08-09  9:48           ` Metzger, Markus T
2023-08-30  8:42             ` Willgerodt, Felix
2023-09-06 14:07               ` Metzger, Markus T
2023-07-18 11:56 ` [PATCH v10 09/10] btrace, python: Enable ptwrite filter registration Felix Willgerodt
2023-07-18 11:56 ` [PATCH v10 10/10] btrace: Extend ptwrite event decoding Felix Willgerodt
2023-07-18 13:01   ` Eli Zaretskii

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=MN2PR11MB456661F08C3C0CC722BDB2068EE6A@MN2PR11MB4566.namprd11.prod.outlook.com \
    --to=felix.willgerodt@intel.com \
    --cc=gdb-patches@sourceware.org \
    --cc=markus.t.metzger@intel.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).