Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Metzger, Markus T" <markus.t.metzger@intel.com>
To: "Wiederhake, Tim" <tim.wiederhake@intel.com>,
	"gdb-patches@sourceware.org"	<gdb-patches@sourceware.org>
Cc: "palves@redhat.com" <palves@redhat.com>
Subject: RE: [PATCH v3 5/8] python: Create Python bindings for record history.
Date: Tue, 29 Nov 2016 15:48:00 -0000	[thread overview]
Message-ID: <A78C989F6D9628469189715575E55B2340013181@IRSMSX104.ger.corp.intel.com> (raw)
In-Reply-To: <1479743318-24523-6-git-send-email-tim.wiederhake@intel.com>

> -----Original Message-----
> From: Wiederhake, Tim
> Sent: Monday, November 21, 2016 4:49 PM
> To: gdb-patches@sourceware.org
> Cc: palves@redhat.com; Metzger, Markus T <markus.t.metzger@intel.com>
> Subject: [PATCH v3 5/8] python: Create Python bindings for record history.
> 
> This patch adds three new functions to the gdb module in Python:
> 	- start_recording
> 	- stop_recording
> 	- current_recording
> start_recording and current_recording return an object of the new type
> gdb.Record, which can be used to access the recorded data.
> 
> 2016-11-21  Tim Wiederhake  <tim.wiederhake@intel.com>
> 
> gdb/ChangeLog
> 
> 	* Makefile.in (SUBDIR_PYTHON_OBS): Add python/py-record.o.
> 	(SUBDIR_PYTHON_SRCS): Add python/py-record.c.
> 	* python/py-record.c: New file.
> 	* python/py-record.h: New file.
> 	* python/python-internal.h (gdbpy_start_recording,
> 	gdbpy_current_recording, gdpy_stop_recording,
> 	gdbpy_initialize_record): New export.
> 	* python/python.c (_initialize_python): Add gdbpy_initialize_record.
> 	(python_GdbMethods): Add gdbpy_start_recording,
> 	gdbpy_current_recording and gdbpy_stop_recording.
> 	* target-debug.h (target_debug_print_struct_record_python_interface):
> 	New define.
> 	* target-delegates.c: Regenerate.
> 	* target.c (target_record_python_interface): New function.
> 	* target.h: Added struct record_python_interface forward declaration.
> 	Export target_record_python_interface.
> 	(struct target_ops): Add to_record_python_interface function.



> +/* Python Record object.  */
> +
> +typedef struct
> +{
> +  PyObject_HEAD
> +
> +  struct record_python_interface interface;

You may want to document every field.


> +static PyObject *
> +recpy_method (PyObject *self, void* closure)
> +{
> +  recpy_record_object *obj = (recpy_record_object *) self;
> +
> +  if (obj->interface.method == NULL)
> +    return PyString_FromString (_("unknown"));

Should this return None, instead?

> +
> +  return PyString_FromString (obj->interface.method);
> +}
> +
> +/* Implementation of record.format.  */
> +
> +static PyObject *
> +recpy_format (PyObject *self, void* closure)
> +{
> +  recpy_record_object *obj = (recpy_record_object *) self;
> +
> +  if (obj->interface.format == NULL)
> +    return PyString_FromString (_("unknown"));

Same here.


> +/* Implementation of gdb.current_recording (self) -> gdb.Record.  */
> +
> +PyObject *
> +gdbpy_current_recording (PyObject *self, PyObject *args)
> +{
> +  recpy_record_object* obj;
> +
> +  obj = PyObject_New (recpy_record_object, &recpy_record_type);
> +  if (obj == NULL)
> +    return NULL;
> +
> +  memset (&obj->interface, 0, sizeof (struct record_python_interface));

How about "sizeof (obj->interface)" instead?



> +/* Implementation of gdb.stop_recording (self) -> None.  */
> +
> +PyObject *
> +gdbpy_stop_recording (PyObject *self, PyObject *args)
> +{
> +  TRY
> +    {
> +      execute_command_to_string ("record stop", 0);
> +      Py_RETURN_NONE;
> +    }
> +  CATCH (except, RETURN_MASK_ALL)
> +    {
> +      gdbpy_convert_exception (except);
> +    }
> +  END_CATCH
> +
> +  return NULL;

We shouldn't really get here, should we? 


Thanks,
Markus.

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


  reply	other threads:[~2016-11-29 15:48 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-21 15:49 [PATCH v3 0/8] Python bindings for btrace recordings Tim Wiederhake
2016-11-21 15:49 ` [PATCH v3 3/8] btrace: Use binary search to find instruction Tim Wiederhake
2016-11-29 15:47   ` Metzger, Markus T
2016-11-21 15:49 ` [PATCH v3 5/8] python: Create Python bindings for record history Tim Wiederhake
2016-11-29 15:48   ` Metzger, Markus T [this message]
2016-11-21 15:49 ` [PATCH v3 1/8] btrace: Count gaps as one instruction explicitly Tim Wiederhake
2016-11-29 15:47   ` Metzger, Markus T
2016-11-21 15:49 ` [PATCH v3 7/8] python: Add tests for record Python bindings Tim Wiederhake
2016-11-29 15:48   ` Metzger, Markus T
2016-11-21 15:49 ` [PATCH v3 4/8] Add record_start function Tim Wiederhake
2016-11-29 15:47   ` Metzger, Markus T
2016-11-21 15:49 ` [PATCH v3 2/8] btrace: Export btrace_decode_error function Tim Wiederhake
2016-11-29 15:47   ` Metzger, Markus T
2016-11-21 15:49 ` [PATCH v3 6/8] python: Implement btrace Python bindings for record history Tim Wiederhake
2016-11-29 15:48   ` Metzger, Markus T
2016-11-21 15:49 ` [PATCH v3 8/8] Add documentation for new instruction record Python bindings Tim Wiederhake
2016-11-29 15:48   ` Metzger, Markus T
2016-11-29 17:32     ` Eli Zaretskii
2016-11-29 15:49 ` [PATCH v3 0/8] Python bindings for btrace recordings Metzger, Markus T
2016-12-01  0:15 [PATCH v3 5/8] python: Create Python bindings for record history 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=A78C989F6D9628469189715575E55B2340013181@IRSMSX104.ger.corp.intel.com \
    --to=markus.t.metzger@intel.com \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.com \
    --cc=tim.wiederhake@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