This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: [PATCH 6/8] Python: Move and rename gdb.BtraceInstruction


Hi Yao!

Thanks for reviewing!

> -----Original Message-----
> From: Yao Qi [mailto:qiyaoltc@gmail.com]
> Sent: Thursday, April 20, 2017 1:47 PM
> To: Wiederhake, Tim <tim.wiederhake@intel.com>
> Cc: gdb-patches@sourceware.org; Metzger, Markus T
> <markus.t.metzger@intel.com>; brobecker@adacore.com
> Subject: Re: [PATCH 6/8] Python: Move and rename gdb.BtraceInstruction
> 
> Tim Wiederhake <tim.wiederhake@intel.com> writes:
> 
> Hi Tim,
> 
> > -static PyObject *
> > -btpy_insn_sal (PyObject *self, void *closure)
> > +PyObject *
> > +recpy_bt_insn_sal (PyObject *self, void *closure)
> >  {
> > -  const btpy_object * const obj = (btpy_object *) self;
> > -  const struct btrace_insn *insn;
> > -  struct btrace_insn_iterator iter;
> > +  const btrace_insn * const insn = btrace_insn_from_recpy_insn (self);
> >    PyObject *result = NULL;
> >
> > -  BTPY_REQUIRE_VALID_INSN (obj, iter);
> > -
> > -  insn = btrace_insn_get (&iter);
> >    if (insn == NULL)
> > -    Py_RETURN_NONE;
> > +    return NULL;
> 
> IIUC, "return NULL" tells python to raise exception, but why do we
> change the function's behavior (Py_RETURN_NONE -> "return NULL")?  The
> change is out of the scope of "Move and rename gdb.BtraceInstruction".

This is an artifact of splitting up "BtraceInstruction" into "RecordInstruction" and "RecordGap".

This function used to handle instruction objects as well as gaps. In the case of a gap, btrace_insn_get would return NULL for a gap. For gaps we do not have symbol_and_line information, so we return NONE.

Now this function only handles instructions and cannot be called for RecordGap objects. If we end up with INSN equal to NULL, a python exception has been flagged by btrace_insn_from_recpy_insn and we return NULL accordingly.

> 
> --
> Yao (齐尧)

Tim
Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]