From 2aa483373c8e7abf69bbc074a17bf708a1a5eaff Mon Sep 17 00:00:00 2001 From: Kevin Pouget Date: Thu, 15 Sep 2011 12:42:30 +0000 Subject: 2011-09-15 Kevin Pouget PR Python/12692 Add gdb.selected_inferior() to Python interface. * python/py-inferior.c (GdbMethods): New Python method definition. doc: PR Python/12692 Add gdb.selected_inferior() to Python interface. * gdb.texinfo (Inferiors In Python): Describe new gdb.selected_inferior() function. testsuite: PR Python/12692 Add gdb.selected_inferior() to Python interface. * gdb.python/py-inferior.exp: Add testcase for gdb.selected_inferior(). --- gdb/python/py-inferior.c | 14 ++++++++++++++ gdb/python/python-internal.h | 1 + gdb/python/python.c | 3 +++ 3 files changed, 18 insertions(+) (limited to 'gdb/python') diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c index 6add681..8ed3ea5 100644 --- a/gdb/python/py-inferior.c +++ b/gdb/python/py-inferior.c @@ -683,6 +683,20 @@ py_free_inferior (struct inferior *inf, void *datum) do_cleanups (cleanup); } +/* Implementation of gdb.selected_inferior() -> gdb.Inferior. + Returns the current inferior object. */ + +PyObject * +gdbpy_selected_inferior (PyObject *self, PyObject *args) +{ + PyObject *inf_obj; + + inf_obj = inferior_to_inferior_object (current_inferior ()); + Py_INCREF (inf_obj); + + return inf_obj; +} + void gdbpy_initialize_inferior (void) { diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h index 4209c28..11f1efd 100644 --- a/gdb/python/python-internal.h +++ b/gdb/python/python-internal.h @@ -151,6 +151,7 @@ PyObject *gdbpy_create_lazy_string_object (CORE_ADDR address, long length, struct type *type); PyObject *gdbpy_inferiors (PyObject *unused, PyObject *unused2); PyObject *gdbpy_selected_thread (PyObject *self, PyObject *args); +PyObject *gdbpy_selected_inferior (PyObject *self, PyObject *args); PyObject *gdbpy_string_to_argv (PyObject *self, PyObject *args); PyObject *gdbpy_parameter (PyObject *self, PyObject *args); PyObject *gdbpy_parameter_value (enum var_types type, void *var); diff --git a/gdb/python/python.c b/gdb/python/python.c index 0f702a2..67649c3 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -1423,6 +1423,9 @@ Arguments are separate by spaces and may be quoted." { "selected_thread", gdbpy_selected_thread, METH_NOARGS, "selected_thread () -> gdb.InferiorThread.\n\ Return the selected thread object." }, + { "selected_inferior", gdbpy_selected_inferior, METH_NOARGS, + "selected_inferior () -> gdb.Inferior.\n\ +Return the selected inferior object." }, { "inferiors", gdbpy_inferiors, METH_NOARGS, "inferiors () -> (gdb.Inferior, ...).\n\ Return a tuple containing all inferiors." }, -- cgit v1.1