aboutsummaryrefslogtreecommitdiff
path: root/gdb/python
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2023-02-08 15:36:23 -0500
committerSimon Marchi <simon.marchi@polymtl.ca>2023-02-08 15:46:02 -0500
commitc583a2520616c2736cffc389c89a48b159366e6c (patch)
treeb4925f26506fcee96c16119431c01760f05db95d /gdb/python
parentca7f92c2f15b86b09c4a8ad14806bef666308d31 (diff)
downloadfsf-binutils-gdb-users/simark/clang-format.zip
fsf-binutils-gdb-users/simark/clang-format.tar.gz
fsf-binutils-gdb-users/simark/clang-format.tar.bz2
Run clang-format.shusers/simark/clang-format
Change-Id: Ia948cc26d534b0dd02702244d52434b1a2093968
Diffstat (limited to 'gdb/python')
-rw-r--r--gdb/python/py-arch.c161
-rw-r--r--gdb/python/py-auto-load.c25
-rw-r--r--gdb/python/py-block.c234
-rw-r--r--gdb/python/py-bpevent.c11
-rw-r--r--gdb/python/py-breakpoint.c509
-rw-r--r--gdb/python/py-cmd.c228
-rw-r--r--gdb/python/py-connection.c268
-rw-r--r--gdb/python/py-dap.c26
-rw-r--r--gdb/python/py-disasm.c362
-rw-r--r--gdb/python/py-event.c98
-rw-r--r--gdb/python/py-event.h22
-rw-r--r--gdb/python/py-events.h6
-rw-r--r--gdb/python/py-evtregistry.c86
-rw-r--r--gdb/python/py-evts.c22
-rw-r--r--gdb/python/py-exitedevent.c10
-rw-r--r--gdb/python/py-finishbreakpoint.c160
-rw-r--r--gdb/python/py-frame.c190
-rw-r--r--gdb/python/py-framefilter.c190
-rw-r--r--gdb/python/py-function.c95
-rw-r--r--gdb/python/py-gdb-readline.c1
-rw-r--r--gdb/python/py-inferior.c211
-rw-r--r--gdb/python/py-infevents.c6
-rw-r--r--gdb/python/py-infthread.c180
-rw-r--r--gdb/python/py-instruction.c23
-rw-r--r--gdb/python/py-lazy-string.c94
-rw-r--r--gdb/python/py-linetable.c306
-rw-r--r--gdb/python/py-membuf.c99
-rw-r--r--gdb/python/py-micmd.c167
-rw-r--r--gdb/python/py-newobjfileevent.c18
-rw-r--r--gdb/python/py-objfile.c354
-rw-r--r--gdb/python/py-param.c410
-rw-r--r--gdb/python/py-prettyprint.c173
-rw-r--r--gdb/python/py-progspace.c194
-rw-r--r--gdb/python/py-record-btrace.c177
-rw-r--r--gdb/python/py-record-btrace.h3
-rw-r--r--gdb/python/py-record.c231
-rw-r--r--gdb/python/py-record.h16
-rw-r--r--gdb/python/py-ref.h16
-rw-r--r--gdb/python/py-registers.c349
-rw-r--r--gdb/python/py-signalevent.c6
-rw-r--r--gdb/python/py-stopevent.c13
-rw-r--r--gdb/python/py-stopevent.h3
-rw-r--r--gdb/python/py-symbol.c248
-rw-r--r--gdb/python/py-symtab.c249
-rw-r--r--gdb/python/py-threadevent.c8
-rw-r--r--gdb/python/py-tui.c186
-rw-r--r--gdb/python/py-type.c529
-rw-r--r--gdb/python/py-unwind.c291
-rw-r--r--gdb/python/py-utils.c61
-rw-r--r--gdb/python/py-value.c417
-rw-r--r--gdb/python/py-varobj.c22
-rw-r--r--gdb/python/py-xmethods.c72
-rw-r--r--gdb/python/python-internal.h355
-rw-r--r--gdb/python/python.c619
54 files changed, 4161 insertions, 4649 deletions
diff --git a/gdb/python/py-arch.c b/gdb/python/py-arch.c
index 51559ca..62e1e3a 100644
--- a/gdb/python/py-arch.c
+++ b/gdb/python/py-arch.c
@@ -23,28 +23,30 @@
#include "disasm.h"
#include "python-internal.h"
-struct arch_object {
- PyObject_HEAD
- struct gdbarch *gdbarch;
+struct arch_object
+{
+ PyObject_HEAD struct gdbarch *gdbarch;
};
static const registry<gdbarch>::key<PyObject, gdb::noop_deleter<PyObject>>
- arch_object_data;
+ arch_object_data;
/* Require a valid Architecture. */
-#define ARCHPY_REQUIRE_VALID(arch_obj, arch) \
- do { \
- arch = arch_object_to_gdbarch (arch_obj); \
- if (arch == NULL) \
- { \
- PyErr_SetString (PyExc_RuntimeError, \
- _("Architecture is invalid.")); \
- return NULL; \
- } \
- } while (0)
-
-extern PyTypeObject arch_object_type
- CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("arch_object");
+#define ARCHPY_REQUIRE_VALID(arch_obj, arch) \
+ do \
+ { \
+ arch = arch_object_to_gdbarch (arch_obj); \
+ if (arch == NULL) \
+ { \
+ PyErr_SetString (PyExc_RuntimeError, \
+ _ ("Architecture is invalid.")); \
+ return NULL; \
+ } \
+ } \
+ while (0)
+
+extern PyTypeObject
+ arch_object_type CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("arch_object");
/* Associates an arch_object with GDBARCH as gdbarch_data via the gdbarch
post init registration mechanism (gdbarch_data_register_post_init). */
@@ -135,9 +137,8 @@ archpy_disassemble (PyObject *self, PyObject *args, PyObject *kw)
ARCHPY_REQUIRE_VALID (self, gdbarch);
- if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "O|OO",
- keywords, &start_obj, &end_obj,
- &count_obj))
+ if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "O|OO", keywords, &start_obj,
+ &end_obj, &count_obj))
return NULL;
if (get_addr_from_python (start_obj, &start) < 0)
@@ -151,8 +152,8 @@ archpy_disassemble (PyObject *self, PyObject *args, PyObject *kw)
if (end < start)
{
PyErr_SetString (PyExc_ValueError,
- _("Argument 'end_pc' should be greater than or "
- "equal to the argument 'start_pc'."));
+ _ ("Argument 'end_pc' should be greater than or "
+ "equal to the argument 'start_pc'."));
return NULL;
}
@@ -163,8 +164,8 @@ archpy_disassemble (PyObject *self, PyObject *args, PyObject *kw)
if (PyErr_Occurred () || count < 0)
{
PyErr_SetString (PyExc_TypeError,
- _("Argument 'count' should be an non-negative "
- "integer."));
+ _ ("Argument 'count' should be an non-negative "
+ "integer."));
return NULL;
}
@@ -190,7 +191,7 @@ archpy_disassemble (PyObject *self, PyObject *args, PyObject *kw)
if (insn_dict == NULL)
return NULL;
if (PyList_Append (result_list.get (), insn_dict.get ()))
- return NULL; /* PyList_Append Sets the exception. */
+ return NULL; /* PyList_Append Sets the exception. */
string_file stb;
@@ -208,8 +209,8 @@ archpy_disassemble (PyObject *self, PyObject *args, PyObject *kw)
if (pc_obj == nullptr)
return nullptr;
- gdbpy_ref<> asm_obj
- (PyUnicode_FromString (!stb.empty () ? stb.c_str () : "<unknown>"));
+ gdbpy_ref<> asm_obj (PyUnicode_FromString (!stb.empty () ? stb.c_str ()
+ : "<unknown>"));
if (asm_obj == nullptr)
return nullptr;
@@ -241,8 +242,7 @@ archpy_registers (PyObject *self, PyObject *args, PyObject *kw)
const char *group_name = NULL;
/* Parse method arguments. */
- if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "|s", keywords,
- &group_name))
+ if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "|s", keywords, &group_name))
return NULL;
/* Extract the gdbarch from the self object. */
@@ -273,13 +273,13 @@ archpy_integer_type (PyObject *self, PyObject *args, PyObject *kw)
int size;
PyObject *is_signed_obj = nullptr;
- if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "i|O", keywords,
- &size, &is_signed_obj))
+ if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "i|O", keywords, &size,
+ &is_signed_obj))
return nullptr;
/* Assume signed by default. */
- bool is_signed = (is_signed_obj == nullptr
- || PyObject_IsTrue (is_signed_obj));
+ bool is_signed
+ = (is_signed_obj == nullptr || PyObject_IsTrue (is_signed_obj));
struct gdbarch *gdbarch;
ARCHPY_REQUIRE_VALID (self, gdbarch);
@@ -312,7 +312,7 @@ archpy_integer_type (PyObject *self, PyObject *args, PyObject *kw)
default:
PyErr_SetString (PyExc_ValueError,
- _("no integer type of that size is available"));
+ _ ("no integer type of that size is available"));
return nullptr;
}
@@ -332,14 +332,14 @@ gdbpy_all_architecture_names (PyObject *self, PyObject *args)
std::vector<const char *> name_list = gdbarch_printable_names ();
for (const char *name : name_list)
{
- gdbpy_ref <> py_name (PyUnicode_FromString (name));
+ gdbpy_ref<> py_name (PyUnicode_FromString (name));
if (py_name == nullptr)
return nullptr;
if (PyList_Append (list.get (), py_name.get ()) < 0)
return nullptr;
}
- return list.release ();
+ return list.release ();
}
/* Initializes the Architecture class in the gdb module. */
@@ -355,9 +355,8 @@ gdbpy_initialize_arch (void)
(PyObject *) &arch_object_type);
}
-static PyMethodDef arch_object_methods [] = {
- { "name", archpy_name, METH_NOARGS,
- "name () -> String.\n\
+static PyMethodDef arch_object_methods[] = {
+ { "name", archpy_name, METH_NOARGS, "name () -> String.\n\
Return the name of the architecture as a string value." },
{ "disassemble", (PyCFunction) archpy_disassemble,
METH_VARARGS | METH_KEYWORDS,
@@ -365,58 +364,54 @@ Return the name of the architecture as a string value." },
Return a list of at most COUNT disassembled instructions from START_PC to\n\
END_PC." },
{ "integer_type", (PyCFunction) archpy_integer_type,
- METH_VARARGS | METH_KEYWORDS,
- "integer_type (size [, signed]) -> type\n\
+ METH_VARARGS | METH_KEYWORDS, "integer_type (size [, signed]) -> type\n\
Return an integer Type corresponding to the given bitsize and signed-ness.\n\
If not specified, the type defaults to signed." },
- { "registers", (PyCFunction) archpy_registers,
- METH_VARARGS | METH_KEYWORDS,
+ { "registers", (PyCFunction) archpy_registers, METH_VARARGS | METH_KEYWORDS,
"registers ([ group-name ]) -> Iterator.\n\
Return an iterator of register descriptors for the registers in register\n\
group GROUP-NAME." },
- { "register_groups", archpy_register_groups,
- METH_NOARGS,
+ { "register_groups", archpy_register_groups, METH_NOARGS,
"register_groups () -> Iterator.\n\
Return an iterator over all of the register groups in this architecture." },
- {NULL} /* Sentinel */
+ { NULL } /* Sentinel */
};
PyTypeObject arch_object_type = {
- PyVarObject_HEAD_INIT (NULL, 0)
- "gdb.Architecture", /* tp_name */
- sizeof (arch_object), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_compare */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT, /* tp_flags */
- "GDB architecture object", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- arch_object_methods, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- 0, /* tp_init */
- 0, /* tp_alloc */
+ PyVarObject_HEAD_INIT (NULL, 0) "gdb.Architecture", /* tp_name */
+ sizeof (arch_object), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ 0, /* tp_dealloc */
+ 0, /* tp_print */
+ 0, /* tp_getattr */
+ 0, /* tp_setattr */
+ 0, /* tp_compare */
+ 0, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ 0, /* tp_str */
+ 0, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ "GDB architecture object", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ arch_object_methods, /* tp_methods */
+ 0, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
};
diff --git a/gdb/python/py-auto-load.c b/gdb/python/py-auto-load.c
index ed6202d..51c070a 100644
--- a/gdb/python/py-auto-load.c
+++ b/gdb/python/py-auto-load.c
@@ -37,7 +37,7 @@ static void
show_auto_load_python_scripts (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
{
- gdb_printf (file, _("Auto-loading of Python scripts is %s.\n"), value);
+ gdb_printf (file, _ ("Auto-loading of Python scripts is %s.\n"), value);
}
/* See python-internal.h. */
@@ -55,14 +55,16 @@ info_auto_load_python_scripts (const char *pattern, int from_tty)
{
auto_load_info_scripts (pattern, from_tty, &extension_language_python);
}
-
+
int
gdbpy_initialize_auto_load (void)
{
add_setshow_boolean_cmd ("python-scripts", class_support,
- &auto_load_python_scripts, _("\
-Set the debugger's behaviour regarding auto-loaded Python scripts."), _("\
-Show the debugger's behaviour regarding auto-loaded Python scripts."), _("\
+ &auto_load_python_scripts, _ ("\
+Set the debugger's behaviour regarding auto-loaded Python scripts."),
+ _ ("\
+Show the debugger's behaviour regarding auto-loaded Python scripts."),
+ _ ("\
If enabled, auto-loaded Python scripts are loaded when the debugger reads\n\
an executable or shared library.\n\
This options has security implications for untrusted inferiors."),
@@ -72,24 +74,25 @@ This options has security implications for untrusted inferiors."),
set_show_commands auto_load_scripts_cmds
= add_setshow_boolean_cmd ("auto-load-scripts", class_support,
- &auto_load_python_scripts, _("\
+ &auto_load_python_scripts,
+ _ ("\
Set the debugger's behaviour regarding auto-loaded Python scripts, "
- "deprecated."),
- _("\
+ "deprecated."),
+ _ ("\
Show the debugger's behaviour regarding auto-loaded Python scripts, "
- "deprecated."),
+ "deprecated."),
NULL, NULL, show_auto_load_python_scripts,
&setlist, &showlist);
deprecate_cmd (auto_load_scripts_cmds.set, "set auto-load python-scripts");
deprecate_cmd (auto_load_scripts_cmds.show, "show auto-load python-scripts");
add_cmd ("python-scripts", class_info, info_auto_load_python_scripts,
- _("Print the list of automatically loaded Python scripts.\n\
+ _ ("Print the list of automatically loaded Python scripts.\n\
Usage: info auto-load python-scripts [REGEXP]"),
auto_load_info_cmdlist_get ());
cmd_list_element *info_auto_load_scripts_cmd
- = add_info ("auto-load-scripts", info_auto_load_python_scripts, _("\
+ = add_info ("auto-load-scripts", info_auto_load_python_scripts, _ ("\
Print the list of automatically loaded Python scripts, deprecated."));
deprecate_cmd (info_auto_load_scripts_cmd, "info auto-load python-scripts");
diff --git a/gdb/python/py-block.c b/gdb/python/py-block.c
index c399a01..77db7a1 100644
--- a/gdb/python/py-block.c
+++ b/gdb/python/py-block.c
@@ -24,10 +24,11 @@
#include "python-internal.h"
#include "objfiles.h"
-struct block_object {
+struct block_object
+{
PyObject_HEAD
- /* The GDB block structure that represents a frame's code block. */
- const struct block *block;
+ /* The GDB block structure that represents a frame's code block. */
+ const struct block *block;
/* The backing object file. There is no direct relationship in GDB
between a block and an object file. When a block is created also
store a pointer to the object file for later use. */
@@ -38,10 +39,11 @@ struct block_object {
block_object *next;
};
-struct block_syms_iterator_object {
+struct block_syms_iterator_object
+{
PyObject_HEAD
- /* The block. */
- const struct block *block;
+ /* The block. */
+ const struct block *block;
/* The iterator for that block. */
struct block_iterator iter;
/* Has the iterator been initialized flag. */
@@ -54,28 +56,31 @@ struct block_syms_iterator_object {
/* Require a valid block. All access to block_object->block should be
gated by this call. */
-#define BLPY_REQUIRE_VALID(block_obj, block) \
- do { \
- block = block_object_to_block (block_obj); \
- if (block == NULL) \
- { \
- PyErr_SetString (PyExc_RuntimeError, \
- _("Block is invalid.")); \
- return NULL; \
- } \
- } while (0)
+#define BLPY_REQUIRE_VALID(block_obj, block) \
+ do \
+ { \
+ block = block_object_to_block (block_obj); \
+ if (block == NULL) \
+ { \
+ PyErr_SetString (PyExc_RuntimeError, _ ("Block is invalid.")); \
+ return NULL; \
+ } \
+ } \
+ while (0)
/* Require a valid block. This macro is called during block iterator
creation, and at each next call. */
-#define BLPY_ITER_REQUIRE_VALID(block_obj) \
- do { \
- if (block_obj->block == NULL) \
- { \
- PyErr_SetString (PyExc_RuntimeError, \
- _("Source block for iterator is invalid.")); \
- return NULL; \
- } \
- } while (0)
+#define BLPY_ITER_REQUIRE_VALID(block_obj) \
+ do \
+ { \
+ if (block_obj->block == NULL) \
+ { \
+ PyErr_SetString (PyExc_RuntimeError, \
+ _ ("Source block for iterator is invalid.")); \
+ return NULL; \
+ } \
+ } \
+ while (0)
/* This is called when an objfile is about to be freed.
Invalidate the block as further actions on the block would result
@@ -101,9 +106,9 @@ struct blpy_deleter
};
extern PyTypeObject block_syms_iterator_object_type
- CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("block_syms_iterator_object");
+ CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("block_syms_iterator_object");
static const registry<objfile>::key<block_object, blpy_deleter>
- blpy_objfile_data_key;
+ blpy_objfile_data_key;
static PyObject *
blpy_iter (PyObject *self)
@@ -116,7 +121,7 @@ blpy_iter (PyObject *self)
block_iter_obj = PyObject_New (block_syms_iterator_object,
&block_syms_iterator_object_type);
if (block_iter_obj == NULL)
- return NULL;
+ return NULL;
block_iter_obj->block = block;
block_iter_obj->initialized_p = 0;
@@ -166,7 +171,7 @@ blpy_get_superblock (PyObject *self, void *closure)
{
const struct block *block;
const struct block *super_block;
- block_object *self_obj = (block_object *) self;
+ block_object *self_obj = (block_object *) self;
BLPY_REQUIRE_VALID (self, block);
@@ -184,15 +189,13 @@ blpy_get_global_block (PyObject *self, void *closure)
{
const struct block *block;
const struct block *global_block;
- block_object *self_obj = (block_object *) self;
+ block_object *self_obj = (block_object *) self;
BLPY_REQUIRE_VALID (self, block);
global_block = block_global_block (block);
- return block_to_block_object (global_block,
- self_obj->objfile);
-
+ return block_to_block_object (global_block, self_obj->objfile);
}
/* Return the static block associated to this block. Return None
@@ -203,7 +206,7 @@ blpy_get_static_block (PyObject *self, void *closure)
{
const struct block *block;
const struct block *static_block;
- block_object *self_obj = (block_object *) self;
+ block_object *self_obj = (block_object *) self;
BLPY_REQUIRE_VALID (self, block);
@@ -242,7 +245,7 @@ blpy_is_static (PyObject *self, void *closure)
BLPY_REQUIRE_VALID (self, block);
if (block->superblock () != NULL
- && block->superblock ()->superblock () == NULL)
+ && block->superblock ()->superblock () == NULL)
Py_RETURN_TRUE;
Py_RETURN_FALSE;
@@ -263,7 +266,7 @@ blpy_getitem (PyObject *self, PyObject *key)
if (name == nullptr)
return nullptr;
- lookup_name_info lookup_name (name.get(), symbol_name_match_type::FULL);
+ lookup_name_info lookup_name (name.get (), symbol_name_match_type::FULL);
/* We use ALL_BLOCK_SYMBOLS_WITH_NAME instead of block_lookup_symbol so
that we can look up symbols irrespective of the domain, matching the
@@ -341,7 +344,7 @@ block_to_block_object (const struct block *block, struct objfile *objfile)
const struct block *
block_object_to_block (PyObject *obj)
{
- if (! PyObject_TypeCheck (obj, &block_object_type))
+ if (!PyObject_TypeCheck (obj, &block_object_type))
return NULL;
return ((block_object *) obj)->block;
}
@@ -370,7 +373,7 @@ blpy_block_syms_iternext (PyObject *self)
if (!iter_obj->initialized_p)
{
- sym = block_iterator_first (iter_obj->block, &(iter_obj->iter));
+ sym = block_iterator_first (iter_obj->block, &(iter_obj->iter));
iter_obj->initialized_p = 1;
}
else
@@ -378,7 +381,7 @@ blpy_block_syms_iternext (PyObject *self)
if (sym == NULL)
{
- PyErr_SetString (PyExc_StopIteration, _("Symbol is null."));
+ PyErr_SetString (PyExc_StopIteration, _ ("Symbol is null."));
return NULL;
}
@@ -415,8 +418,7 @@ blpy_is_valid (PyObject *self, PyObject *args)
static PyObject *
blpy_iter_is_valid (PyObject *self, PyObject *args)
{
- block_syms_iterator_object *iter_obj =
- (block_syms_iterator_object *) self;
+ block_syms_iterator_object *iter_obj = (block_syms_iterator_object *) self;
if (iter_obj->source->block == NULL)
Py_RETURN_FALSE;
@@ -436,20 +438,19 @@ gdbpy_initialize_blocks (void)
return -1;
if (gdb_pymodule_addobject (gdb_module, "Block",
- (PyObject *) &block_object_type) < 0)
+ (PyObject *) &block_object_type)
+ < 0)
return -1;
- return gdb_pymodule_addobject (gdb_module, "BlockIterator",
- (PyObject *) &block_syms_iterator_object_type);
+ return gdb_pymodule_addobject (
+ gdb_module, "BlockIterator",
+ (PyObject *) &block_syms_iterator_object_type);
}
-
-
static PyMethodDef block_object_methods[] = {
- { "is_valid", blpy_is_valid, METH_NOARGS,
- "is_valid () -> Boolean.\n\
+ { "is_valid", blpy_is_valid, METH_NOARGS, "is_valid () -> Boolean.\n\
Return true if this block is valid, false if not." },
- {NULL} /* Sentinel */
+ { NULL } /* Sentinel */
};
static gdb_PyGetSetDef block_object_getset[] = {
@@ -463,86 +464,79 @@ static gdb_PyGetSetDef block_object_getset[] = {
"Block containing the global block.", NULL },
{ "static_block", blpy_get_static_block, NULL,
"Block containing the static block.", NULL },
- { "is_static", blpy_is_static, NULL,
- "Whether this block is a static block.", NULL },
- { "is_global", blpy_is_global, NULL,
- "Whether this block is a global block.", NULL },
- { NULL } /* Sentinel */
+ { "is_static", blpy_is_static, NULL, "Whether this block is a static block.",
+ NULL },
+ { "is_global", blpy_is_global, NULL, "Whether this block is a global block.",
+ NULL },
+ { NULL } /* Sentinel */
};
-static PyMappingMethods block_object_as_mapping = {
- NULL,
- blpy_getitem,
- NULL
-};
+static PyMappingMethods block_object_as_mapping = { NULL, blpy_getitem, NULL };
PyTypeObject block_object_type = {
- PyVarObject_HEAD_INIT (NULL, 0)
- "gdb.Block", /*tp_name*/
- sizeof (block_object), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- blpy_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- &block_object_as_mapping, /*tp_as_mapping*/
- 0, /*tp_hash */
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- "GDB block object", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- blpy_iter, /* tp_iter */
- 0, /* tp_iternext */
- block_object_methods, /* tp_methods */
- 0, /* tp_members */
- block_object_getset /* tp_getset */
+ PyVarObject_HEAD_INIT (NULL, 0) "gdb.Block", /*tp_name*/
+ sizeof (block_object), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ blpy_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ &block_object_as_mapping, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT, /*tp_flags*/
+ "GDB block object", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ blpy_iter, /* tp_iter */
+ 0, /* tp_iternext */
+ block_object_methods, /* tp_methods */
+ 0, /* tp_members */
+ block_object_getset /* tp_getset */
};
static PyMethodDef block_iterator_object_methods[] = {
- { "is_valid", blpy_iter_is_valid, METH_NOARGS,
- "is_valid () -> Boolean.\n\
+ { "is_valid", blpy_iter_is_valid, METH_NOARGS, "is_valid () -> Boolean.\n\
Return true if this block iterator is valid, false if not." },
- {NULL} /* Sentinel */
+ { NULL } /* Sentinel */
};
PyTypeObject block_syms_iterator_object_type = {
- PyVarObject_HEAD_INIT (NULL, 0)
- "gdb.BlockIterator", /*tp_name*/
- sizeof (block_syms_iterator_object), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- blpy_block_syms_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- "GDB block syms iterator object", /*tp_doc */
- 0, /*tp_traverse */
- 0, /*tp_clear */
- 0, /*tp_richcompare */
- 0, /*tp_weaklistoffset */
- blpy_block_syms_iter, /*tp_iter */
- blpy_block_syms_iternext, /*tp_iternext */
- block_iterator_object_methods /*tp_methods */
+ PyVarObject_HEAD_INIT (NULL, 0) "gdb.BlockIterator", /*tp_name*/
+ sizeof (block_syms_iterator_object), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ blpy_block_syms_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT, /*tp_flags*/
+ "GDB block syms iterator object", /*tp_doc */
+ 0, /*tp_traverse */
+ 0, /*tp_clear */
+ 0, /*tp_richcompare */
+ 0, /*tp_weaklistoffset */
+ blpy_block_syms_iter, /*tp_iter */
+ blpy_block_syms_iternext, /*tp_iternext */
+ block_iterator_object_methods /*tp_methods */
};
diff --git a/gdb/python/py-bpevent.c b/gdb/python/py-bpevent.c
index 00fb625..d058192 100644
--- a/gdb/python/py-bpevent.c
+++ b/gdb/python/py-bpevent.c
@@ -32,13 +32,12 @@ create_breakpoint_event_object (PyObject *breakpoint_list, PyObject *first_bp)
if (breakpoint_event_obj == NULL)
return NULL;
- if (evpy_add_attribute (breakpoint_event_obj.get (),
- "breakpoint",
- first_bp) < 0)
+ if (evpy_add_attribute (breakpoint_event_obj.get (), "breakpoint", first_bp)
+ < 0)
return NULL;
- if (evpy_add_attribute (breakpoint_event_obj.get (),
- "breakpoints",
- breakpoint_list) < 0)
+ if (evpy_add_attribute (breakpoint_event_obj.get (), "breakpoints",
+ breakpoint_list)
+ < 0)
return NULL;
return breakpoint_event_obj;
diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c
index 1b10ccd..5c9e8bf 100644
--- a/gdb/python/py-breakpoint.c
+++ b/gdb/python/py-breakpoint.c
@@ -35,14 +35,14 @@
#include "linespec.h"
extern PyTypeObject breakpoint_location_object_type
- CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("breakpoint_location_object");
+ CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("breakpoint_location_object");
struct gdbpy_breakpoint_location_object
{
PyObject_HEAD
- /* An owning reference to the gdb breakpoint location object. */
- bp_location *bp_loc;
+ /* An owning reference to the gdb breakpoint location object. */
+ bp_location *bp_loc;
/* An owning reference to the location's breakpoint owner. */
gdbpy_breakpoint_object *owner;
@@ -50,24 +50,28 @@ struct gdbpy_breakpoint_location_object
/* Require that BREAKPOINT and LOCATION->OWNER are the same; throw a Python
exception if they are not. */
-#define BPLOCPY_REQUIRE_VALID(Breakpoint, Location) \
- do { \
- if ((Breakpoint)->bp != (Location)->bp_loc->owner) \
- return PyErr_Format (PyExc_RuntimeError, \
- _("Breakpoint location is invalid.")); \
- } while (0)
+#define BPLOCPY_REQUIRE_VALID(Breakpoint, Location) \
+ do \
+ { \
+ if ((Breakpoint)->bp != (Location)->bp_loc->owner) \
+ return PyErr_Format (PyExc_RuntimeError, \
+ _ ("Breakpoint location is invalid.")); \
+ } \
+ while (0)
/* Require that BREAKPOINT and LOCATION->OWNER are the same; throw a Python
exception if they are not. This macro is for use in setter functions. */
-#define BPLOCPY_SET_REQUIRE_VALID(Breakpoint, Location) \
- do { \
- if ((Breakpoint)->bp != (Location)->bp_loc->owner) \
- { \
- PyErr_Format (PyExc_RuntimeError, \
- _("Breakpoint location is invalid.")); \
- return -1; \
- } \
- } while (0)
+#define BPLOCPY_SET_REQUIRE_VALID(Breakpoint, Location) \
+ do \
+ { \
+ if ((Breakpoint)->bp != (Location)->bp_loc->owner) \
+ { \
+ PyErr_Format (PyExc_RuntimeError, \
+ _ ("Breakpoint location is invalid.")); \
+ return -1; \
+ } \
+ } \
+ while (0)
/* Debugging of Python breakpoints. */
@@ -79,7 +83,7 @@ static void
show_pybp_debug (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
{
- gdb_printf (file, _("Python breakpoint debugging is %s.\n"), value);
+ gdb_printf (file, _ ("Python breakpoint debugging is %s.\n"), value);
}
/* Print a "py-breakpoint" debug statement. */
@@ -112,26 +116,24 @@ struct pybp_code
};
/* Entries related to the type of user set breakpoints. */
-static struct pybp_code pybp_codes[] =
-{
- { "BP_NONE", bp_none},
- { "BP_BREAKPOINT", bp_breakpoint},
- { "BP_HARDWARE_BREAKPOINT", bp_hardware_breakpoint},
- { "BP_WATCHPOINT", bp_watchpoint},
- { "BP_HARDWARE_WATCHPOINT", bp_hardware_watchpoint},
- { "BP_READ_WATCHPOINT", bp_read_watchpoint},
- { "BP_ACCESS_WATCHPOINT", bp_access_watchpoint},
- { "BP_CATCHPOINT", bp_catchpoint},
- {NULL} /* Sentinel. */
+static struct pybp_code pybp_codes[] = {
+ { "BP_NONE", bp_none },
+ { "BP_BREAKPOINT", bp_breakpoint },
+ { "BP_HARDWARE_BREAKPOINT", bp_hardware_breakpoint },
+ { "BP_WATCHPOINT", bp_watchpoint },
+ { "BP_HARDWARE_WATCHPOINT", bp_hardware_watchpoint },
+ { "BP_READ_WATCHPOINT", bp_read_watchpoint },
+ { "BP_ACCESS_WATCHPOINT", bp_access_watchpoint },
+ { "BP_CATCHPOINT", bp_catchpoint },
+ { NULL } /* Sentinel. */
};
/* Entries related to the type of watchpoint. */
-static struct pybp_code pybp_watch_types[] =
-{
- { "WP_READ", hw_read},
- { "WP_WRITE", hw_write},
- { "WP_ACCESS", hw_access},
- {NULL} /* Sentinel. */
+static struct pybp_code pybp_watch_types[] = {
+ { "WP_READ", hw_read },
+ { "WP_WRITE", hw_write },
+ { "WP_ACCESS", hw_access },
+ { NULL } /* Sentinel. */
};
/* Python function which checks the validity of a breakpoint object. */
@@ -152,7 +154,7 @@ bppy_get_enabled (PyObject *self, void *closure)
gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self;
BPPY_REQUIRE_VALID (self_bp);
- if (! self_bp->bp)
+ if (!self_bp->bp)
Py_RETURN_FALSE;
if (self_bp->bp->enable_state == bp_enabled)
Py_RETURN_TRUE;
@@ -183,14 +185,14 @@ bppy_set_enabled (PyObject *self, PyObject *newvalue, void *closure)
if (newvalue == NULL)
{
PyErr_SetString (PyExc_TypeError,
- _("Cannot delete `enabled' attribute."));
+ _ ("Cannot delete `enabled' attribute."));
return -1;
}
- else if (! PyBool_Check (newvalue))
+ else if (!PyBool_Check (newvalue))
{
PyErr_SetString (PyExc_TypeError,
- _("The value of `enabled' must be a boolean."));
+ _ ("The value of `enabled' must be a boolean."));
return -1;
}
@@ -225,13 +227,13 @@ bppy_set_silent (PyObject *self, PyObject *newvalue, void *closure)
if (newvalue == NULL)
{
PyErr_SetString (PyExc_TypeError,
- _("Cannot delete `silent' attribute."));
+ _ ("Cannot delete `silent' attribute."));
return -1;
}
- else if (! PyBool_Check (newvalue))
+ else if (!PyBool_Check (newvalue))
{
PyErr_SetString (PyExc_TypeError,
- _("The value of `silent' must be a boolean."));
+ _ ("The value of `silent' must be a boolean."));
return -1;
}
@@ -256,18 +258,17 @@ bppy_set_thread (PyObject *self, PyObject *newvalue, void *closure)
if (newvalue == NULL)
{
PyErr_SetString (PyExc_TypeError,
- _("Cannot delete `thread' attribute."));
+ _ ("Cannot delete `thread' attribute."));
return -1;
}
else if (PyLong_Check (newvalue))
{
- if (! gdb_py_int_as_long (newvalue, &id))
+ if (!gdb_py_int_as_long (newvalue, &id))
return -1;
if (!valid_global_thread_id (id))
{
- PyErr_SetString (PyExc_RuntimeError,
- _("Invalid thread ID."));
+ PyErr_SetString (PyExc_RuntimeError, _ ("Invalid thread ID."));
return -1;
}
}
@@ -275,8 +276,9 @@ bppy_set_thread (PyObject *self, PyObject *newvalue, void *closure)
id = -1;
else
{
- PyErr_SetString (PyExc_TypeError,
- _("The value of `thread' must be an integer or None."));
+ PyErr_SetString (
+ PyExc_TypeError,
+ _ ("The value of `thread' must be an integer or None."));
return -1;
}
@@ -297,13 +299,12 @@ bppy_set_task (PyObject *self, PyObject *newvalue, void *closure)
if (newvalue == NULL)
{
- PyErr_SetString (PyExc_TypeError,
- _("Cannot delete `task' attribute."));
+ PyErr_SetString (PyExc_TypeError, _ ("Cannot delete `task' attribute."));
return -1;
}
else if (PyLong_Check (newvalue))
{
- if (! gdb_py_int_as_long (newvalue, &id))
+ if (!gdb_py_int_as_long (newvalue, &id))
return -1;
try
@@ -315,10 +316,9 @@ bppy_set_task (PyObject *self, PyObject *newvalue, void *closure)
GDB_PY_SET_HANDLE_EXCEPTION (except);
}
- if (! valid_id)
+ if (!valid_id)
{
- PyErr_SetString (PyExc_RuntimeError,
- _("Invalid task ID."));
+ PyErr_SetString (PyExc_RuntimeError, _ ("Invalid task ID."));
return -1;
}
}
@@ -327,7 +327,7 @@ bppy_set_task (PyObject *self, PyObject *newvalue, void *closure)
else
{
PyErr_SetString (PyExc_TypeError,
- _("The value of `task' must be an integer or None."));
+ _ ("The value of `task' must be an integer or None."));
return -1;
}
@@ -360,7 +360,6 @@ bppy_delete_breakpoint (PyObject *self, PyObject *args)
Py_RETURN_NONE;
}
-
/* Python function to set the ignore count of a breakpoint. */
static int
bppy_set_ignore_count (PyObject *self, PyObject *newvalue, void *closure)
@@ -373,17 +372,17 @@ bppy_set_ignore_count (PyObject *self, PyObject *newvalue, void *closure)
if (newvalue == NULL)
{
PyErr_SetString (PyExc_TypeError,
- _("Cannot delete `ignore_count' attribute."));
+ _ ("Cannot delete `ignore_count' attribute."));
return -1;
}
else if (!PyLong_Check (newvalue))
{
PyErr_SetString (PyExc_TypeError,
- _("The value of `ignore_count' must be an integer."));
+ _ ("The value of `ignore_count' must be an integer."));
return -1;
}
- if (! gdb_py_int_as_long (newvalue, &value))
+ if (!gdb_py_int_as_long (newvalue, &value))
return -1;
if (value < 0)
@@ -412,20 +411,20 @@ bppy_set_hit_count (PyObject *self, PyObject *newvalue, void *closure)
if (newvalue == NULL)
{
PyErr_SetString (PyExc_TypeError,
- _("Cannot delete `hit_count' attribute."));
+ _ ("Cannot delete `hit_count' attribute."));
return -1;
}
else
{
long value;
- if (! gdb_py_int_as_long (newvalue, &value))
+ if (!gdb_py_int_as_long (newvalue, &value))
return -1;
if (value != 0)
{
PyErr_SetString (PyExc_AttributeError,
- _("The value of `hit_count' must be zero."));
+ _ ("The value of `hit_count' must be zero."));
return -1;
}
}
@@ -469,7 +468,7 @@ bppy_get_expression (PyObject *self, void *closure)
wp = (struct watchpoint *) obj->bp;
str = wp->exp_string.get ();
- if (! str)
+ if (!str)
str = "";
return host_string_to_python_string (str).release ();
@@ -485,7 +484,7 @@ bppy_get_condition (PyObject *self, void *closure)
BPPY_REQUIRE_VALID (obj);
str = obj->bp->cond_string.get ();
- if (! str)
+ if (!str)
Py_RETURN_NONE;
return host_string_to_python_string (str).release ();
@@ -507,7 +506,7 @@ bppy_set_condition (PyObject *self, PyObject *newvalue, void *closure)
if (newvalue == NULL)
{
PyErr_SetString (PyExc_TypeError,
- _("Cannot delete `condition' attribute."));
+ _ ("Cannot delete `condition' attribute."));
return -1;
}
else if (newvalue == Py_None)
@@ -543,7 +542,7 @@ bppy_get_commands (PyObject *self, void *closure)
BPPY_REQUIRE_VALID (self_bp);
- if (! self_bp->bp->commands)
+ if (!self_bp->bp->commands)
Py_RETURN_NONE;
string_file stb;
@@ -572,8 +571,8 @@ bppy_set_commands (PyObject *self, PyObject *newvalue, void *closure)
BPPY_SET_REQUIRE_VALID (self_bp);
- gdb::unique_xmalloc_ptr<char> commands
- (python_string_to_host_string (newvalue));
+ gdb::unique_xmalloc_ptr<char> commands (
+ python_string_to_host_string (newvalue));
if (commands == nullptr)
return -1;
@@ -581,14 +580,12 @@ bppy_set_commands (PyObject *self, PyObject *newvalue, void *closure)
{
bool first = true;
char *save_ptr = nullptr;
- auto reader
- = [&] (std::string &buffer)
- {
- const char *result = strtok_r (first ? commands.get () : nullptr,
- "\n", &save_ptr);
- first = false;
- return result;
- };
+ auto reader = [&] (std::string &buffer) {
+ const char *result
+ = strtok_r (first ? commands.get () : nullptr, "\n", &save_ptr);
+ first = false;
+ return result;
+ };
counted_command_line lines = read_command_lines_1 (reader, 1, nullptr);
breakpoint_set_commands (self_bp->bp, std::move (lines));
@@ -740,8 +737,8 @@ bppy_get_locations (PyObject *self, void *closure)
for (bp_location *loc : self_bp->bp->locations ())
{
- gdbpy_ref<py_bploc_t> py_bploc
- (PyObject_New (py_bploc_t, &breakpoint_location_object_type));
+ gdbpy_ref<py_bploc_t> py_bploc (
+ PyObject_New (py_bploc_t, &breakpoint_location_object_type));
if (py_bploc == nullptr)
return nullptr;
@@ -761,9 +758,8 @@ bppy_get_locations (PyObject *self, void *closure)
provided to bppy_init. */
static int
-bppy_init_validate_args (const char *spec, char *source,
- char *function, char *label,
- char *line, enum bptype type)
+bppy_init_validate_args (const char *spec, char *source, char *function,
+ char *label, char *line, enum bptype type)
{
/* If spec is defined, ensure that none of the explicit location
keywords are also defined. */
@@ -771,9 +767,10 @@ bppy_init_validate_args (const char *spec, char *source,
{
if (source != NULL || function != NULL || label != NULL || line != NULL)
{
- PyErr_SetString (PyExc_RuntimeError,
- _("Breakpoints specified with spec cannot "
- "have source, function, label or line defined."));
+ PyErr_SetString (
+ PyExc_RuntimeError,
+ _ ("Breakpoints specified with spec cannot "
+ "have source, function, label or line defined."));
return -1;
}
}
@@ -784,8 +781,8 @@ bppy_init_validate_args (const char *spec, char *source,
if (type == bp_watchpoint)
{
PyErr_SetString (PyExc_RuntimeError,
- _("Watchpoints cannot be set by explicit "
- "location parameters."));
+ _ ("Watchpoints cannot be set by explicit "
+ "location parameters."));
return -1;
}
else
@@ -795,7 +792,7 @@ bppy_init_validate_args (const char *spec, char *source,
&& line == NULL)
{
PyErr_SetString (PyExc_RuntimeError,
- _("Neither spec nor explicit location set."));
+ _ ("Neither spec nor explicit location set."));
return -1;
}
/* Finally, if source is specified, ensure that line, label
@@ -804,8 +801,8 @@ bppy_init_validate_args (const char *spec, char *source,
&& line == NULL)
{
PyErr_SetString (PyExc_RuntimeError,
- _("Specifying a source must also include a "
- "line, label or function."));
+ _ ("Specifying a source must also include a "
+ "line, label or function."));
return -1;
}
}
@@ -817,32 +814,30 @@ bppy_init_validate_args (const char *spec, char *source,
static int
bppy_init (PyObject *self, PyObject *args, PyObject *kwargs)
{
- static const char *keywords[] = { "spec", "type", "wp_class", "internal",
- "temporary","source", "function",
- "label", "line", "qualified", NULL };
+ static const char *keywords[]
+ = { "spec", "type", "wp_class", "internal", "temporary", "source",
+ "function", "label", "line", "qualified", NULL };
const char *spec = NULL;
enum bptype type = bp_breakpoint;
int access_type = hw_write;
PyObject *internal = NULL;
PyObject *temporary = NULL;
- PyObject *lineobj = NULL;;
+ PyObject *lineobj = NULL;
+ ;
int internal_bp = 0;
int temporary_bp = 0;
gdb::unique_xmalloc_ptr<char> line;
char *label = NULL;
char *source = NULL;
char *function = NULL;
- PyObject * qualified = NULL;
+ PyObject *qualified = NULL;
if (!gdb_PyArg_ParseTupleAndKeywords (args, kwargs, "|siiOOsssOO", keywords,
- &spec, &type, &access_type,
- &internal,
- &temporary, &source,
- &function, &label, &lineobj,
- &qualified))
+ &spec, &type, &access_type, &internal,
+ &temporary, &source, &function, &label,
+ &lineobj, &qualified))
return -1;
-
if (lineobj != NULL)
{
if (PyLong_Check (lineobj))
@@ -851,8 +846,9 @@ bppy_init (PyObject *self, PyObject *args, PyObject *kwargs)
line = python_string_to_host_string (lineobj);
else
{
- PyErr_SetString (PyExc_RuntimeError,
- _("Line keyword should be an integer or a string. "));
+ PyErr_SetString (
+ PyExc_RuntimeError,
+ _ ("Line keyword should be an integer or a string. "));
return -1;
}
}
@@ -872,7 +868,8 @@ bppy_init (PyObject *self, PyObject *args, PyObject *kwargs)
}
if (bppy_init_validate_args (spec, source, function, label, line.get (),
- type) == -1)
+ type)
+ == -1)
return -1;
bppy_pending_object = (gdbpy_breakpoint_object *) self;
@@ -889,23 +886,22 @@ bppy_init (PyObject *self, PyObject *args, PyObject *kwargs)
location_spec_up locspec;
symbol_name_match_type func_name_match_type
= (qualified != NULL && PyObject_IsTrue (qualified)
- ? symbol_name_match_type::FULL
- : symbol_name_match_type::WILD);
+ ? symbol_name_match_type::FULL
+ : symbol_name_match_type::WILD);
if (spec != NULL)
{
- gdb::unique_xmalloc_ptr<char>
- copy_holder (xstrdup (skip_spaces (spec)));
+ gdb::unique_xmalloc_ptr<char> copy_holder (
+ xstrdup (skip_spaces (spec)));
const char *copy = copy_holder.get ();
- locspec = string_to_location_spec (&copy,
- current_language,
- func_name_match_type);
+ locspec = string_to_location_spec (&copy, current_language,
+ func_name_match_type);
}
else
{
- std::unique_ptr<explicit_location_spec> explicit_loc
- (new explicit_location_spec ());
+ std::unique_ptr<explicit_location_spec> explicit_loc (
+ new explicit_location_spec ());
explicit_loc->source_filename
= source != nullptr ? xstrdup (source) : nullptr;
@@ -926,14 +922,9 @@ bppy_init (PyObject *self, PyObject *args, PyObject *kwargs)
const struct breakpoint_ops *ops
= breakpoint_ops_for_location_spec (locspec.get (), false);
- create_breakpoint (gdbpy_enter::get_gdbarch (),
- locspec.get (), NULL, -1, NULL, false,
- 0,
- temporary_bp, type,
- 0,
- AUTO_BOOLEAN_TRUE,
- ops,
- 0, 1, internal_bp, 0);
+ create_breakpoint (gdbpy_enter::get_gdbarch (), locspec.get (),
+ NULL, -1, NULL, false, 0, temporary_bp, type, 0,
+ AUTO_BOOLEAN_TRUE, ops, 0, 1, internal_bp, 0);
break;
}
case bp_watchpoint:
@@ -947,13 +938,13 @@ bppy_init (PyObject *self, PyObject *args, PyObject *kwargs)
else if (access_type == hw_read)
rwatch_command_wrapper (spec, 0, internal_bp);
else
- error(_("Cannot understand watchpoint access type."));
+ error (_ ("Cannot understand watchpoint access type."));
break;
}
case bp_catchpoint:
- error (_("BP_CATCHPOINT not supported"));
+ error (_ ("BP_CATCHPOINT not supported"));
default:
- error(_("Do not understand breakpoint type to set."));
+ error (_ ("Do not understand breakpoint type to set."));
}
}
catch (const gdb_exception &except)
@@ -1065,7 +1056,7 @@ gdbpy_breakpoint_cond_says_stop (const struct extension_language_defn *extlang,
/* If the "stop" function returns False that means
the Python breakpoint wants GDB to continue. */
- if (! evaluate)
+ if (!evaluate)
stop = 0;
}
else
@@ -1099,8 +1090,6 @@ gdbpy_breakpoint_has_cond (const struct extension_language_defn *extlang,
return PyObject_HasAttrString (py_bp, stop_func);
}
-
-
/* Event callback functions. */
/* Callback that is used when a breakpoint is created. This function
@@ -1118,12 +1107,9 @@ gdbpy_breakpoint_created (struct breakpoint *bp)
return;
}
- if (bp->type != bp_breakpoint
- && bp->type != bp_hardware_breakpoint
- && bp->type != bp_watchpoint
- && bp->type != bp_hardware_watchpoint
- && bp->type != bp_read_watchpoint
- && bp->type != bp_access_watchpoint
+ if (bp->type != bp_breakpoint && bp->type != bp_hardware_breakpoint
+ && bp->type != bp_watchpoint && bp->type != bp_hardware_watchpoint
+ && bp->type != bp_read_watchpoint && bp->type != bp_access_watchpoint
&& bp->type != bp_catchpoint)
{
pybp_debug_printf ("is not a breakpoint or watchpoint");
@@ -1155,14 +1141,15 @@ gdbpy_breakpoint_created (struct breakpoint *bp)
else
{
PyErr_SetString (PyExc_RuntimeError,
- _("Error while creating breakpoint from GDB."));
+ _ ("Error while creating breakpoint from GDB."));
gdbpy_print_stack ();
}
if (!evregpy_no_listeners_p (gdb_py_events.breakpoint_created))
{
if (evpy_emit_event ((PyObject *) newbp,
- gdb_py_events.breakpoint_created) < 0)
+ gdb_py_events.breakpoint_created)
+ < 0)
gdbpy_print_stack ();
}
}
@@ -1188,7 +1175,8 @@ gdbpy_breakpoint_deleted (struct breakpoint *b)
if (!evregpy_no_listeners_p (gdb_py_events.breakpoint_deleted))
{
if (evpy_emit_event ((PyObject *) bp_obj.get (),
- gdb_py_events.breakpoint_deleted) < 0)
+ gdb_py_events.breakpoint_deleted)
+ < 0)
gdbpy_print_stack ();
}
@@ -1218,16 +1206,14 @@ gdbpy_breakpoint_modified (struct breakpoint *b)
{
if (!evregpy_no_listeners_p (gdb_py_events.breakpoint_modified))
{
- if (evpy_emit_event (bp_obj,
- gdb_py_events.breakpoint_modified) < 0)
+ if (evpy_emit_event (bp_obj, gdb_py_events.breakpoint_modified)
+ < 0)
gdbpy_print_stack ();
}
}
}
}
-
-
/* Initialize the Python breakpoint code. */
int
gdbpy_initialize_breakpoints (void)
@@ -1238,7 +1224,8 @@ gdbpy_initialize_breakpoints (void)
return -1;
if (gdb_pymodule_addobject (gdb_module, "Breakpoint",
- (PyObject *) &breakpoint_object_type) < 0)
+ (PyObject *) &breakpoint_object_type)
+ < 0)
return -1;
gdb::observers::breakpoint_created.attach (gdbpy_breakpoint_created,
@@ -1252,7 +1239,8 @@ gdbpy_initialize_breakpoints (void)
for (i = 0; pybp_codes[i].name; ++i)
{
if (PyModule_AddIntConstant (gdb_module, pybp_codes[i].name,
- pybp_codes[i].code) < 0)
+ pybp_codes[i].code)
+ < 0)
return -1;
}
@@ -1260,7 +1248,8 @@ gdbpy_initialize_breakpoints (void)
for (i = 0; pybp_watch_types[i].name; ++i)
{
if (PyModule_AddIntConstant (gdb_module, pybp_watch_types[i].name,
- pybp_watch_types[i].code) < 0)
+ pybp_watch_types[i].code)
+ < 0)
return -1;
}
@@ -1282,8 +1271,6 @@ gdbpy_initialize_breakpoint_locations ()
return 0;
}
-
-
/* Helper function that overrides this Python object's
PyObject_GenericSetAttr to allow extra validation of the attribute
being set. */
@@ -1311,9 +1298,9 @@ local_setattro (PyObject *self, PyObject *name, PyObject *v)
if (extlang != NULL)
{
std::string error_text
- = string_printf (_("Only one stop condition allowed. There is"
- " currently a %s stop condition defined for"
- " this breakpoint."),
+ = string_printf (_ ("Only one stop condition allowed. There is"
+ " currently a %s stop condition defined for"
+ " this breakpoint."),
ext_lang_capitalized_name (extlang));
PyErr_SetString (PyExc_RuntimeError, error_text.c_str ());
return -1;
@@ -1332,45 +1319,45 @@ static gdb_PyGetSetDef breakpoint_object_getset[] = {
"Thread ID for the breakpoint.\n\
If the value is a thread ID (integer), then this is a thread-specific breakpoint.\n\
If the value is None, then this breakpoint is not thread-specific.\n\
-No other type of value can be used.", NULL },
- { "task", bppy_get_task, bppy_set_task,
- "Thread ID for the breakpoint.\n\
+No other type of value can be used.",
+ NULL },
+ { "task", bppy_get_task, bppy_set_task, "Thread ID for the breakpoint.\n\
If the value is a task ID (integer), then this is an Ada task-specific breakpoint.\n\
If the value is None, then this breakpoint is not task-specific.\n\
-No other type of value can be used.", NULL },
+No other type of value can be used.",
+ NULL },
{ "ignore_count", bppy_get_ignore_count, bppy_set_ignore_count,
"Number of times this breakpoint should be automatically continued.",
NULL },
- { "number", bppy_get_number, NULL,
- "Breakpoint's number assigned by GDB.", NULL },
+ { "number", bppy_get_number, NULL, "Breakpoint's number assigned by GDB.",
+ NULL },
{ "hit_count", bppy_get_hit_count, bppy_set_hit_count,
"Number of times the breakpoint has been hit.\n\
Can be set to zero to clear the count. No other value is valid\n\
-when setting this property.", NULL },
+when setting this property.",
+ NULL },
{ "location", bppy_get_location, NULL,
- "Location of the breakpoint, as specified by the user.", NULL},
+ "Location of the breakpoint, as specified by the user.", NULL },
{ "expression", bppy_get_expression, NULL,
- "Expression of the breakpoint, as specified by the user.", NULL},
+ "Expression of the breakpoint, as specified by the user.", NULL },
{ "condition", bppy_get_condition, bppy_set_condition,
"Condition of the breakpoint, as specified by the user,\
-or None if no condition set."},
+or None if no condition set." },
{ "commands", bppy_get_commands, bppy_set_commands,
- "Commands of the breakpoint, as specified by the user."},
- { "type", bppy_get_type, NULL,
- "Type of breakpoint."},
+ "Commands of the breakpoint, as specified by the user." },
+ { "type", bppy_get_type, NULL, "Type of breakpoint." },
{ "visible", bppy_get_visibility, NULL,
- "Whether the breakpoint is visible to the user."},
+ "Whether the breakpoint is visible to the user." },
{ "temporary", bppy_get_temporary, NULL,
- "Whether this breakpoint is a temporary breakpoint."},
+ "Whether this breakpoint is a temporary breakpoint." },
{ "pending", bppy_get_pending, NULL,
- "Whether this breakpoint is a pending breakpoint."},
+ "Whether this breakpoint is a pending breakpoint." },
{ "locations", bppy_get_locations, NULL,
- "Get locations where this breakpoint was set"},
- { NULL } /* Sentinel. */
+ "Get locations where this breakpoint was set" },
+ { NULL } /* Sentinel. */
};
-static PyMethodDef breakpoint_object_methods[] =
-{
+static PyMethodDef breakpoint_object_methods[] = {
{ "is_valid", bppy_is_valid, METH_NOARGS,
"Return true if this breakpoint is valid, false if not." },
{ "delete", bppy_delete_breakpoint, METH_NOARGS,
@@ -1378,59 +1365,56 @@ static PyMethodDef breakpoint_object_methods[] =
{ NULL } /* Sentinel. */
};
-PyTypeObject breakpoint_object_type =
-{
- PyVarObject_HEAD_INIT (NULL, 0)
- "gdb.Breakpoint", /*tp_name*/
- sizeof (gdbpy_breakpoint_object), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- 0, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- (setattrofunc)local_setattro, /*tp_setattro */
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
- "GDB breakpoint object", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- breakpoint_object_methods, /* tp_methods */
- 0, /* tp_members */
- breakpoint_object_getset, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- bppy_init, /* tp_init */
- 0, /* tp_alloc */
+PyTypeObject breakpoint_object_type = {
+ PyVarObject_HEAD_INIT (NULL, 0) "gdb.Breakpoint", /*tp_name*/
+ sizeof (gdbpy_breakpoint_object), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ 0, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ (setattrofunc) local_setattro, /*tp_setattro */
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
+ "GDB breakpoint object", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ breakpoint_object_methods, /* tp_methods */
+ 0, /* tp_members */
+ breakpoint_object_getset, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ bppy_init, /* tp_init */
+ 0, /* tp_alloc */
};
void _initialize_py_breakpoint ();
+
void
_initialize_py_breakpoint ()
{
- add_setshow_boolean_cmd
- ("py-breakpoint", class_maintenance, &pybp_debug,
- _("Set Python breakpoint debugging."),
- _("Show Python breakpoint debugging."),
- _("When on, Python breakpoint debugging is enabled."),
- NULL,
- show_pybp_debug,
- &setdebuglist, &showdebuglist);
+ add_setshow_boolean_cmd (
+ "py-breakpoint", class_maintenance, &pybp_debug,
+ _ ("Set Python breakpoint debugging."),
+ _ ("Show Python breakpoint debugging."),
+ _ ("When on, Python breakpoint debugging is enabled."), NULL,
+ show_pybp_debug, &setdebuglist, &showdebuglist);
}
/* Python function to set the enabled state of a breakpoint location. */
@@ -1445,13 +1429,13 @@ bplocpy_set_enabled (PyObject *py_self, PyObject *newvalue, void *closure)
if (newvalue == nullptr)
{
PyErr_SetString (PyExc_TypeError,
- _("Cannot delete 'enabled' attribute."));
+ _ ("Cannot delete 'enabled' attribute."));
return -1;
}
else if (!PyBool_Check (newvalue))
{
PyErr_SetString (PyExc_TypeError,
- _("The value of 'enabled' must be a boolean."));
+ _ ("The value of 'enabled' must be a boolean."));
return -1;
}
@@ -1586,8 +1570,7 @@ bplocpy_get_fullname (PyObject *py_self, void *closure)
const auto symtab = self->bp_loc->symtab;
if (symtab != nullptr && symtab->fullname != nullptr)
{
- gdbpy_ref<> fullname
- = host_string_to_python_string (symtab->fullname);
+ gdbpy_ref<> fullname = host_string_to_python_string (symtab->fullname);
return fullname.release ();
}
Py_RETURN_NONE;
@@ -1599,7 +1582,7 @@ static void
bplocpy_dealloc (PyObject *py_self)
{
auto *self = (gdbpy_breakpoint_location_object *) py_self;
- bp_location_ref_ptr decrementing_ref {self->bp_loc};
+ bp_location_ref_ptr decrementing_ref { self->bp_loc };
Py_XDECREF (self->owner);
Py_TYPE (py_self)->tp_free (py_self);
}
@@ -1609,58 +1592,56 @@ bplocpy_dealloc (PyObject *py_self)
static gdb_PyGetSetDef bp_location_object_getset[] = {
{ "enabled", bplocpy_get_enabled, bplocpy_set_enabled,
"Boolean telling whether the breakpoint is enabled.", NULL },
- { "owner", bplocpy_get_owner, NULL,
- "Get the breakpoint owner object", NULL },
+ { "owner", bplocpy_get_owner, NULL, "Get the breakpoint owner object",
+ NULL },
{ "address", bplocpy_get_address, NULL,
- "Get address of where this location was set", NULL},
+ "Get address of where this location was set", NULL },
{ "source", bplocpy_get_source_location, NULL,
- "Get file and line number of where this location was set", NULL},
+ "Get file and line number of where this location was set", NULL },
{ "function", bplocpy_get_function, NULL,
"Get function of where this location was set", NULL },
{ "fullname", bplocpy_get_fullname, NULL,
"Get fullname of where this location was set", NULL },
{ "thread_groups", bplocpy_get_thread_groups, NULL,
"Get thread groups where this location is in", NULL },
- { NULL } /* Sentinel. */
+ { NULL } /* Sentinel. */
};
-PyTypeObject breakpoint_location_object_type =
-{
- PyVarObject_HEAD_INIT (NULL, 0)
- "gdb.BreakpointLocation", /*tp_name*/
- sizeof (gdbpy_breakpoint_location_object), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- bplocpy_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro */
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- "GDB breakpoint location object", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- bp_location_object_getset, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- 0, /* tp_init */
- 0, /* tp_alloc */
+PyTypeObject breakpoint_location_object_type = {
+ PyVarObject_HEAD_INIT (NULL, 0) "gdb.BreakpointLocation", /*tp_name*/
+ sizeof (gdbpy_breakpoint_location_object), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ bplocpy_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro */
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT, /*tp_flags*/
+ "GDB breakpoint location object", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ 0, /* tp_methods */
+ 0, /* tp_members */
+ bp_location_object_getset, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
};
diff --git a/gdb/python/py-cmd.c b/gdb/python/py-cmd.c
index f7fc79e..8984dbd 100644
--- a/gdb/python/py-cmd.c
+++ b/gdb/python/py-cmd.c
@@ -17,7 +17,6 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
#include "defs.h"
#include "arch-utils.h"
#include "value.h"
@@ -37,8 +36,7 @@ struct cmdpy_completer
completer_ftype *completer;
};
-static const struct cmdpy_completer completers[] =
-{
+static const struct cmdpy_completer completers[] = {
{ "COMPLETE_NONE", noop_completer },
{ "COMPLETE_FILENAME", filename_completer },
{ "COMPLETE_LOCATION", location_completer },
@@ -55,9 +53,9 @@ struct cmdpy_object
{
PyObject_HEAD
- /* The corresponding gdb command object, or NULL if the command is
+ /* The corresponding gdb command object, or NULL if the command is
no longer installed. */
- struct cmd_list_element *command;
+ struct cmd_list_element *command;
/* A prefix command requires storage for a list of its sub-commands.
A pointer to this is passed to add_prefix_command, and to add_cmd
@@ -66,15 +64,13 @@ struct cmdpy_object
struct cmd_list_element *sub_list;
};
-extern PyTypeObject cmdpy_object_type
- CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("cmdpy_object");
+extern PyTypeObject
+ cmdpy_object_type CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("cmdpy_object");
/* Constants used by this module. */
static PyObject *invoke_cst;
static PyObject *complete_cst;
-
-
/* Python function which wraps dont_repeat. */
static PyObject *
cmdpy_dont_repeat (PyObject *self, PyObject *args)
@@ -83,8 +79,6 @@ cmdpy_dont_repeat (PyObject *self, PyObject *args)
Py_RETURN_NONE;
}
-
-
/* Called if the gdb cmd_list_element is destroyed. */
static void
@@ -106,26 +100,26 @@ cmdpy_function (const char *args, int from_tty, cmd_list_element *command)
gdbpy_enter enter_py;
- if (! obj)
- error (_("Invalid invocation of Python command object."));
- if (! PyObject_HasAttr ((PyObject *) obj, invoke_cst))
+ if (!obj)
+ error (_ ("Invalid invocation of Python command object."));
+ if (!PyObject_HasAttr ((PyObject *) obj, invoke_cst))
{
if (obj->command->is_prefix ())
{
/* A prefix command does not need an invoke method. */
return;
}
- error (_("Python command object missing 'invoke' method."));
+ error (_ ("Python command object missing 'invoke' method."));
}
- if (! args)
+ if (!args)
args = "";
gdbpy_ref<> argobj (PyUnicode_Decode (args, strlen (args), host_charset (),
NULL));
if (argobj == NULL)
{
gdbpy_print_stack ();
- error (_("Could not convert arguments to Python string."));
+ error (_ ("Could not convert arguments to Python string."));
}
gdbpy_ref<> ttyobj (PyBool_FromLong (from_tty));
@@ -167,13 +161,13 @@ cmdpy_function (const char *args, int from_tty, cmd_list_element *command)
Python method call. */
static gdbpy_ref<>
-cmdpy_completer_helper (struct cmd_list_element *command,
- const char *text, const char *word)
+cmdpy_completer_helper (struct cmd_list_element *command, const char *text,
+ const char *word)
{
cmdpy_object *obj = (cmdpy_object *) command->context ();
if (obj == NULL)
- error (_("Invalid invocation of Python command object."));
+ error (_ ("Invalid invocation of Python command object."));
if (!PyObject_HasAttr ((PyObject *) obj, complete_cst))
{
/* If there is no complete method, don't error. */
@@ -183,7 +177,7 @@ cmdpy_completer_helper (struct cmd_list_element *command,
gdbpy_ref<> textobj (PyUnicode_Decode (text, strlen (text), host_charset (),
NULL));
if (textobj == NULL)
- error (_("Could not convert argument to Python string."));
+ error (_ ("Could not convert argument to Python string."));
gdbpy_ref<> wordobj;
if (word == NULL)
@@ -196,13 +190,11 @@ cmdpy_completer_helper (struct cmd_list_element *command,
wordobj.reset (PyUnicode_Decode (word, strlen (word), host_charset (),
NULL));
if (wordobj == NULL)
- error (_("Could not convert argument to Python string."));
+ error (_ ("Could not convert argument to Python string."));
}
- gdbpy_ref<> resultobj (PyObject_CallMethodObjArgs ((PyObject *) obj,
- complete_cst,
- textobj.get (),
- wordobj.get (), NULL));
+ gdbpy_ref<> resultobj (PyObject_CallMethodObjArgs (
+ (PyObject *) obj, complete_cst, textobj.get (), wordobj.get (), NULL));
if (resultobj == NULL)
{
/* Just swallow errors here. */
@@ -219,8 +211,8 @@ cmdpy_completer_helper (struct cmd_list_element *command,
static void
cmdpy_completer_handle_brkchars (struct cmd_list_element *command,
- completion_tracker &tracker,
- const char *text, const char *word)
+ completion_tracker &tracker, const char *text,
+ const char *word)
{
gdbpy_enter enter_py;
@@ -251,8 +243,8 @@ cmdpy_completer_handle_brkchars (struct cmd_list_element *command,
/* This is the core of this function. Depending on which
completer type the Python function returns, we have to
adjust the break characters accordingly. */
- brkchars_fn = (completer_handle_brkchars_func_for_completer
- (completers[value].completer));
+ brkchars_fn = (completer_handle_brkchars_func_for_completer (
+ completers[value].completer));
brkchars_fn (command, tracker, text, word);
}
}
@@ -261,8 +253,7 @@ cmdpy_completer_handle_brkchars (struct cmd_list_element *command,
/* Called by gdb for command completion. */
static void
-cmdpy_completer (struct cmd_list_element *command,
- completion_tracker &tracker,
+cmdpy_completer (struct cmd_list_element *command, completion_tracker &tracker,
const char *text, const char *word)
{
gdbpy_enter enter_py;
@@ -282,7 +273,7 @@ cmdpy_completer (struct cmd_list_element *command,
thus requesting that sort of completion. */
long value;
- if (! gdb_py_int_as_long (resultobj.get (), &value))
+ if (!gdb_py_int_as_long (resultobj.get (), &value))
{
/* Ignore. */
PyErr_Clear ();
@@ -304,13 +295,13 @@ cmdpy_completer (struct cmd_list_element *command,
if (elt == NULL)
break;
- if (! gdbpy_is_string (elt.get ()))
+ if (!gdbpy_is_string (elt.get ()))
{
/* Skip problem elements. */
continue;
}
- gdb::unique_xmalloc_ptr<char>
- item (python_string_to_host_string (elt.get ()));
+ gdb::unique_xmalloc_ptr<char> item (
+ python_string_to_host_string (elt.get ()));
if (item == NULL)
{
/* Skip problem elements. */
@@ -358,7 +349,7 @@ gdbpy_parse_command_name (const char *name,
;
if (i < 0)
{
- PyErr_SetString (PyExc_RuntimeError, _("No command name found."));
+ PyErr_SetString (PyExc_RuntimeError, _ ("No command name found."));
return NULL;
}
lastchar = i;
@@ -386,7 +377,8 @@ gdbpy_parse_command_name (const char *name,
elt = lookup_cmd_1 (&prefix_text2, *start_list, NULL, NULL, 1);
if (elt == NULL || elt == CMD_LIST_AMBIGUOUS)
{
- PyErr_Format (PyExc_RuntimeError, _("Could not find command prefix %s."),
+ PyErr_Format (PyExc_RuntimeError,
+ _ ("Could not find command prefix %s."),
prefix_text.c_str ());
return NULL;
}
@@ -397,7 +389,7 @@ gdbpy_parse_command_name (const char *name,
return result;
}
- PyErr_Format (PyExc_RuntimeError, _("'%s' is not a prefix command."),
+ PyErr_Format (PyExc_RuntimeError, _ ("'%s' is not a prefix command."),
prefix_text.c_str ());
return NULL;
}
@@ -430,8 +422,8 @@ cmdpy_init (PyObject *self, PyObject *args, PyObject *kw)
int cmdtype;
int completetype = -1;
struct cmd_list_element **cmd_list;
- static const char *keywords[] = { "name", "command_class", "completer_class",
- "prefix", NULL };
+ static const char *keywords[]
+ = { "name", "command_class", "completer_class", "prefix", NULL };
PyObject *is_prefix_obj = NULL;
bool is_prefix = false;
@@ -440,31 +432,30 @@ cmdpy_init (PyObject *self, PyObject *args, PyObject *kw)
/* Note: this is apparently not documented in Python. We return
0 for success, -1 for failure. */
PyErr_Format (PyExc_RuntimeError,
- _("Command object already initialized."));
+ _ ("Command object already initialized."));
return -1;
}
- if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "si|iO",
- keywords, &name, &cmdtype,
- &completetype, &is_prefix_obj))
+ if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "si|iO", keywords, &name,
+ &cmdtype, &completetype,
+ &is_prefix_obj))
return -1;
- if (cmdtype != no_class && cmdtype != class_run
- && cmdtype != class_vars && cmdtype != class_stack
- && cmdtype != class_files && cmdtype != class_support
- && cmdtype != class_info && cmdtype != class_breakpoint
- && cmdtype != class_trace && cmdtype != class_obscure
- && cmdtype != class_maintenance && cmdtype != class_user
- && cmdtype != class_tui)
+ if (cmdtype != no_class && cmdtype != class_run && cmdtype != class_vars
+ && cmdtype != class_stack && cmdtype != class_files
+ && cmdtype != class_support && cmdtype != class_info
+ && cmdtype != class_breakpoint && cmdtype != class_trace
+ && cmdtype != class_obscure && cmdtype != class_maintenance
+ && cmdtype != class_user && cmdtype != class_tui)
{
- PyErr_Format (PyExc_RuntimeError, _("Invalid command class argument."));
+ PyErr_Format (PyExc_RuntimeError, _ ("Invalid command class argument."));
return -1;
}
if (completetype < -1 || completetype >= (int) N_COMPLETERS)
{
PyErr_Format (PyExc_RuntimeError,
- _("Invalid completion type argument."));
+ _ ("Invalid completion type argument."));
return -1;
}
@@ -496,7 +487,7 @@ cmdpy_init (PyObject *self, PyObject *args, PyObject *kw)
}
}
if (docstring == nullptr)
- docstring = make_unique_xstrdup (_("This command is not documented."));
+ docstring = make_unique_xstrdup (_ ("This command is not documented."));
gdbpy_ref<> self_ref = gdbpy_ref<>::new_reference (self);
@@ -511,8 +502,7 @@ cmdpy_init (PyObject *self, PyObject *args, PyObject *kw)
/* If we have our own "invoke" method, then allow unknown
sub-commands. */
allow_unknown = PyObject_HasAttr (self, invoke_cst);
- cmd = add_prefix_cmd (cmd_name.get (),
- (enum command_class) cmdtype,
+ cmd = add_prefix_cmd (cmd_name.get (), (enum command_class) cmdtype,
NULL, docstring.release (), &obj->sub_list,
allow_unknown, cmd_list);
}
@@ -532,8 +522,9 @@ cmdpy_init (PyObject *self, PyObject *args, PyObject *kw)
obj->command = cmd;
cmd->set_context (self_ref.release ());
- set_cmd_completer (cmd, ((completetype == -1) ? cmdpy_completer
- : completers[completetype].completer));
+ set_cmd_completer (cmd, ((completetype == -1)
+ ? cmdpy_completer
+ : completers[completetype].completer));
if (completetype == -1)
set_cmd_completer_handle_brkchars (cmd,
cmdpy_completer_handle_brkchars);
@@ -547,8 +538,6 @@ cmdpy_init (PyObject *self, PyObject *args, PyObject *kw)
return 0;
}
-
-
/* Initialize the 'commands' code. */
int
@@ -566,17 +555,20 @@ gdbpy_initialize_commands (void)
|| PyModule_AddIntConstant (gdb_module, "COMMAND_DATA", class_vars) < 0
|| PyModule_AddIntConstant (gdb_module, "COMMAND_STACK", class_stack) < 0
|| PyModule_AddIntConstant (gdb_module, "COMMAND_FILES", class_files) < 0
- || PyModule_AddIntConstant (gdb_module, "COMMAND_SUPPORT",
- class_support) < 0
+ || PyModule_AddIntConstant (gdb_module, "COMMAND_SUPPORT", class_support)
+ < 0
|| PyModule_AddIntConstant (gdb_module, "COMMAND_STATUS", class_info) < 0
|| PyModule_AddIntConstant (gdb_module, "COMMAND_BREAKPOINTS",
- class_breakpoint) < 0
+ class_breakpoint)
+ < 0
|| PyModule_AddIntConstant (gdb_module, "COMMAND_TRACEPOINTS",
- class_trace) < 0
- || PyModule_AddIntConstant (gdb_module, "COMMAND_OBSCURE",
- class_obscure) < 0
+ class_trace)
+ < 0
+ || PyModule_AddIntConstant (gdb_module, "COMMAND_OBSCURE", class_obscure)
+ < 0
|| PyModule_AddIntConstant (gdb_module, "COMMAND_MAINTENANCE",
- class_maintenance) < 0
+ class_maintenance)
+ < 0
|| PyModule_AddIntConstant (gdb_module, "COMMAND_USER", class_user) < 0
|| PyModule_AddIntConstant (gdb_module, "COMMAND_TUI", class_tui) < 0)
return -1;
@@ -588,7 +580,8 @@ gdbpy_initialize_commands (void)
}
if (gdb_pymodule_addobject (gdb_module, "Command",
- (PyObject *) &cmdpy_object_type) < 0)
+ (PyObject *) &cmdpy_object_type)
+ < 0)
return -1;
invoke_cst = PyUnicode_FromString ("invoke");
@@ -601,59 +594,51 @@ gdbpy_initialize_commands (void)
return 0;
}
-
-
-static PyMethodDef cmdpy_object_methods[] =
-{
- { "dont_repeat", cmdpy_dont_repeat, METH_NOARGS,
- "Prevent command repetition when user enters empty line." },
-
- { 0 }
+static PyMethodDef cmdpy_object_methods[]
+ = { { "dont_repeat", cmdpy_dont_repeat, METH_NOARGS,
+ "Prevent command repetition when user enters empty line." },
+
+ { 0 } };
+
+PyTypeObject cmdpy_object_type = {
+ PyVarObject_HEAD_INIT (NULL, 0) "gdb.Command", /*tp_name*/
+ sizeof (cmdpy_object), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ 0, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
+ "GDB command object", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ cmdpy_object_methods, /* tp_methods */
+ 0, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ cmdpy_init, /* tp_init */
+ 0, /* tp_alloc */
};
-PyTypeObject cmdpy_object_type =
-{
- PyVarObject_HEAD_INIT (NULL, 0)
- "gdb.Command", /*tp_name*/
- sizeof (cmdpy_object), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- 0, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
- "GDB command object", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- cmdpy_object_methods, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- cmdpy_init, /* tp_init */
- 0, /* tp_alloc */
-};
-
-
-
/* Utility to build a buildargv-like result from ARGS.
This intentionally parses arguments the way libiberty/argv.c:buildargv
does. It splits up arguments in a reasonable way, and we want a standard
@@ -685,8 +670,7 @@ gdbpy_string_to_argv (PyObject *self, PyObject *args)
{
gdbpy_ref<> argp (PyUnicode_FromString (arg));
- if (argp == NULL
- || PyList_Append (py_argv.get (), argp.get ()) < 0)
+ if (argp == NULL || PyList_Append (py_argv.get (), argp.get ()) < 0)
return NULL;
}
}
diff --git a/gdb/python/py-connection.c b/gdb/python/py-connection.c
index 84435eb..0f5e332 100644
--- a/gdb/python/py-connection.c
+++ b/gdb/python/py-connection.c
@@ -37,13 +37,13 @@ struct connection_object
{
PyObject_HEAD
- /* The process target that represents this connection. When a
+ /* The process target that represents this connection. When a
connection_object is created this field will always point at a valid
target. Later, if GDB stops using this target (the target is popped
from all target stacks) then this field is set to nullptr, which
indicates that this Python object is now in the invalid state (see
the is_valid() method below). */
- struct process_stratum_target *target;
+ struct process_stratum_target *target;
};
extern PyTypeObject connection_object_type
@@ -53,21 +53,23 @@ extern PyTypeObject remote_connection_object_type
CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("remote_connection_object");
/* Require that CONNECTION be valid. */
-#define CONNPY_REQUIRE_VALID(connection) \
- do { \
- if (connection->target == nullptr) \
- { \
- PyErr_SetString (PyExc_RuntimeError, \
- _("Connection no longer exists.")); \
- return nullptr; \
- } \
- } while (0)
+#define CONNPY_REQUIRE_VALID(connection) \
+ do \
+ { \
+ if (connection->target == nullptr) \
+ { \
+ PyErr_SetString (PyExc_RuntimeError, \
+ _ ("Connection no longer exists.")); \
+ return nullptr; \
+ } \
+ } \
+ while (0)
/* A map between process_stratum targets and the Python object representing
them. We actually hold a gdbpy_ref around the Python object so that
reference counts are handled correctly when entries are deleted. */
-static std::map<process_stratum_target *,
- gdbpy_ref<connection_object>> all_connection_objects;
+static std::map<process_stratum_target *, gdbpy_ref<connection_object>>
+ all_connection_objects;
/* Return a reference to a gdb.TargetConnection object for TARGET. If
TARGET is nullptr then a reference to None is returned.
@@ -82,7 +84,7 @@ target_to_connection_object (process_stratum_target *target)
if (target == nullptr)
return gdbpy_ref<>::new_reference (Py_None);
- gdbpy_ref <connection_object> conn_obj;
+ gdbpy_ref<connection_object> conn_obj;
auto conn_obj_iter = all_connection_objects.find (target);
if (conn_obj_iter == all_connection_objects.end ())
{
@@ -141,8 +143,7 @@ static int
emit_connection_event (process_stratum_target *target,
eventregistry_object *registry)
{
- gdbpy_ref<> event_obj
- = create_event_object (&connection_event_object_type);
+ gdbpy_ref<> event_obj = create_event_object (&connection_event_object_type);
if (event_obj == nullptr)
return -1;
@@ -170,7 +171,7 @@ connpy_connection_removed (process_stratum_target *target)
auto conn_obj_iter = all_connection_objects.find (target);
if (conn_obj_iter != all_connection_objects.end ())
{
- gdbpy_ref <connection_object> conn_obj = conn_obj_iter->second;
+ gdbpy_ref<connection_object> conn_obj = conn_obj_iter->second;
conn_obj->target = nullptr;
all_connection_objects.erase (target);
}
@@ -206,10 +207,10 @@ connpy_repr (PyObject *obj)
if (target == nullptr)
return PyUnicode_FromFormat ("<%s (invalid)>", Py_TYPE (obj)->tp_name);
- return PyUnicode_FromFormat ("<%s num=%d, what=\"%s\">",
- Py_TYPE (obj)->tp_name,
- target->connection_number,
- make_target_connection_string (target).c_str ());
+ return PyUnicode_FromFormat (
+ "<%s num=%d, what=\"%s\">", Py_TYPE (obj)->tp_name,
+ target->connection_number,
+ make_target_connection_string (target).c_str ());
}
/* Implementation of gdb.TargetConnection.is_valid() -> Boolean. Returns
@@ -292,14 +293,16 @@ gdbpy_initialize_connection (void)
return -1;
if (gdb_pymodule_addobject (gdb_module, "TargetConnection",
- (PyObject *) &connection_object_type) < 0)
+ (PyObject *) &connection_object_type)
+ < 0)
return -1;
if (PyType_Ready (&remote_connection_object_type) < 0)
return -1;
if (gdb_pymodule_addobject (gdb_module, "RemoteTargetConnection",
- (PyObject *) &remote_connection_object_type) < 0)
+ (PyObject *) &remote_connection_object_type)
+ < 0)
return -1;
return 0;
@@ -315,12 +318,14 @@ struct py_send_packet_callbacks : public send_remote_packet_callbacks
py_send_packet_callbacks ()
: m_result (nullptr)
- { /* Nothing. */ }
+ { /* Nothing. */
+ }
/* There's nothing to do when the packet is sent. */
void sending (gdb::array_view<const char> &buf) override
- { /* Nothing. */ }
+ { /* Nothing. */
+ }
/* When the result is returned create a Python object and assign this
into M_RESULT. If for any reason we can't create a Python object to
@@ -353,10 +358,7 @@ struct py_send_packet_callbacks : public send_remote_packet_callbacks
Python functions that might clear the error state, or rely on an error
not being set will cause undefined behaviour. */
- gdbpy_ref<> result () const
- {
- return m_result;
- }
+ gdbpy_ref<> result () const { return m_result; }
private:
@@ -377,11 +379,10 @@ connpy_send_packet (PyObject *self, PyObject *args, PyObject *kw)
CONNPY_REQUIRE_VALID (conn);
- static const char *keywords[] = {"packet", nullptr};
+ static const char *keywords[] = { "packet", nullptr };
PyObject *packet_obj;
- if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "O", keywords,
- &packet_obj))
+ if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "O", keywords, &packet_obj))
return nullptr;
/* If the packet is a unicode string then convert it to a bytes object. */
@@ -397,21 +398,21 @@ connpy_send_packet (PyObject *self, PyObject *args, PyObject *kw)
/* Check the packet is now a bytes object. */
if (!PyBytes_Check (packet_obj))
{
- PyErr_SetString (PyExc_TypeError, _("Packet is not a bytes object"));
+ PyErr_SetString (PyExc_TypeError, _ ("Packet is not a bytes object"));
return nullptr;
}
Py_ssize_t packet_len = 0;
char *packet_str_nonconst = nullptr;
- if (PyBytes_AsStringAndSize (packet_obj, &packet_str_nonconst,
- &packet_len) < 0)
+ if (PyBytes_AsStringAndSize (packet_obj, &packet_str_nonconst, &packet_len)
+ < 0)
return nullptr;
const char *packet_str = packet_str_nonconst;
gdb_assert (packet_str != nullptr);
if (packet_len == 0)
{
- PyErr_SetString (PyExc_ValueError, _("Packet must not be empty"));
+ PyErr_SetString (PyExc_ValueError, _ ("Packet must not be empty"));
return nullptr;
}
@@ -440,6 +441,7 @@ connpy_send_packet (PyObject *self, PyObject *args, PyObject *kw)
/* Global initialization for this file. */
void _initialize_py_connection ();
+
void
_initialize_py_connection ()
{
@@ -449,122 +451,110 @@ _initialize_py_connection ()
/* Methods for the gdb.TargetConnection object type. */
-static PyMethodDef connection_object_methods[] =
-{
- { "is_valid", connpy_is_valid, METH_NOARGS,
- "is_valid () -> Boolean.\n\
+static PyMethodDef connection_object_methods[]
+ = { { "is_valid", connpy_is_valid, METH_NOARGS, "is_valid () -> Boolean.\n\
Return true if this TargetConnection is valid, false if not." },
- { NULL }
-};
+ { NULL } };
/* Methods for the gdb.RemoteTargetConnection object type. */
-static PyMethodDef remote_connection_object_methods[] =
-{
- { "send_packet", (PyCFunction) connpy_send_packet,
- METH_VARARGS | METH_KEYWORDS,
- "send_packet (PACKET) -> Bytes\n\
+static PyMethodDef remote_connection_object_methods[]
+ = { { "send_packet", (PyCFunction) connpy_send_packet,
+ METH_VARARGS | METH_KEYWORDS, "send_packet (PACKET) -> Bytes\n\
Send PACKET to a remote target, return the reply as a bytes array." },
- { NULL }
-};
+ { NULL } };
/* Attributes for the gdb.TargetConnection object type. */
-static gdb_PyGetSetDef connection_object_getset[] =
-{
- { "num", connpy_get_connection_num, NULL,
- "ID number of this connection, as assigned by GDB.", NULL },
- { "type", connpy_get_connection_type, NULL,
- "A short string that is the name for this connection type.", NULL },
- { "description", connpy_get_description, NULL,
- "A longer string describing this connection type.", NULL },
- { "details", connpy_get_connection_details, NULL,
- "A string containing additional connection details.", NULL },
- { NULL }
-};
+static gdb_PyGetSetDef connection_object_getset[]
+ = { { "num", connpy_get_connection_num, NULL,
+ "ID number of this connection, as assigned by GDB.", NULL },
+ { "type", connpy_get_connection_type, NULL,
+ "A short string that is the name for this connection type.", NULL },
+ { "description", connpy_get_description, NULL,
+ "A longer string describing this connection type.", NULL },
+ { "details", connpy_get_connection_details, NULL,
+ "A string containing additional connection details.", NULL },
+ { NULL } };
/* Define the gdb.TargetConnection object type. */
-PyTypeObject connection_object_type =
-{
- PyVarObject_HEAD_INIT (NULL, 0)
- "gdb.TargetConnection", /* tp_name */
- sizeof (connection_object), /* tp_basicsize */
- 0, /* tp_itemsize */
- connpy_connection_dealloc, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_compare */
- connpy_repr, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- "GDB target connection object", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- connection_object_methods, /* tp_methods */
- 0, /* tp_members */
- connection_object_getset, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- 0, /* tp_init */
- 0 /* tp_alloc */
+PyTypeObject connection_object_type = {
+ PyVarObject_HEAD_INIT (NULL, 0) "gdb.TargetConnection", /* tp_name */
+ sizeof (connection_object), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ connpy_connection_dealloc, /* tp_dealloc */
+ 0, /* tp_print */
+ 0, /* tp_getattr */
+ 0, /* tp_setattr */
+ 0, /* tp_compare */
+ connpy_repr, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ 0, /* tp_str */
+ 0, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ "GDB target connection object", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ connection_object_methods, /* tp_methods */
+ 0, /* tp_members */
+ connection_object_getset, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0 /* tp_alloc */
};
/* Define the gdb.RemoteTargetConnection object type. */
-PyTypeObject remote_connection_object_type =
-{
- PyVarObject_HEAD_INIT (NULL, 0)
- "gdb.RemoteTargetConnection", /* tp_name */
- sizeof (connection_object), /* tp_basicsize */
- 0, /* tp_itemsize */
- connpy_connection_dealloc, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_compare */
- connpy_repr, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT, /* tp_flags */
- "GDB remote target connection object", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- remote_connection_object_methods, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- &connection_object_type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- 0, /* tp_init */
- 0 /* tp_alloc */
+PyTypeObject remote_connection_object_type = {
+ PyVarObject_HEAD_INIT (NULL, 0) "gdb.RemoteTargetConnection", /* tp_name */
+ sizeof (connection_object), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ connpy_connection_dealloc, /* tp_dealloc */
+ 0, /* tp_print */
+ 0, /* tp_getattr */
+ 0, /* tp_setattr */
+ 0, /* tp_compare */
+ connpy_repr, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ 0, /* tp_str */
+ 0, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ "GDB remote target connection object", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ remote_connection_object_methods, /* tp_methods */
+ 0, /* tp_members */
+ 0, /* tp_getset */
+ &connection_object_type, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0 /* tp_alloc */
};
diff --git a/gdb/python/py-dap.c b/gdb/python/py-dap.c
index 32f9272..44b9e28 100644
--- a/gdb/python/py-dap.c
+++ b/gdb/python/py-dap.c
@@ -37,18 +37,11 @@ public:
void init (bool top_level) override;
- void suspend () override
- {
- }
+ void suspend () override {}
- void resume () override
- {
- }
+ void resume () override {}
- void exec (const char *command) override
- {
- /* Just ignore it. */
- }
+ void exec (const char *command) override { /* Just ignore it. */ }
void set_logging (ui_file_up logfile, bool logging_redirect,
bool debug_redirect) override
@@ -56,10 +49,7 @@ public:
/* Just ignore it. */
}
- ui_out *interp_ui_out () override
- {
- return m_ui_out.get ();
- }
+ ui_out *interp_ui_out () override { return m_ui_out.get (); }
private:
@@ -88,11 +78,11 @@ dap_interp::init (bool top_level)
}
void _initialize_py_interp ();
+
void
_initialize_py_interp ()
{
- interp_factory_register ("dap", [] (const char *name) -> interp *
- {
- return new dap_interp (name);
- });
+ interp_factory_register ("dap", [] (const char *name) -> interp * {
+ return new dap_interp (name);
+ });
}
diff --git a/gdb/python/py-disasm.c b/gdb/python/py-disasm.c
index c3d8d8a..8743727 100644
--- a/gdb/python/py-disasm.c
+++ b/gdb/python/py-disasm.c
@@ -33,8 +33,8 @@ struct disasm_info_object
{
PyObject_HEAD
- /* The architecture in which we are disassembling. */
- struct gdbarch *gdbarch;
+ /* The architecture in which we are disassembling. */
+ struct gdbarch *gdbarch;
/* The program_space in which we are disassembling. */
struct program_space *program_space;
@@ -54,7 +54,7 @@ struct disasm_info_object
};
extern PyTypeObject disasm_info_object_type
- CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("disasm_info_object");
+ CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("disasm_info_object");
/* Implement gdb.disassembler.DisassemblerResult type, an object that holds
the result of calling the disassembler. This is mostly the length of
@@ -65,8 +65,8 @@ struct disasm_result_object
{
PyObject_HEAD
- /* The length of the disassembled instruction in bytes. */
- int length;
+ /* The length of the disassembled instruction in bytes. */
+ int length;
/* A buffer which, when allocated, holds the disassembled content of an
instruction. */
@@ -74,7 +74,7 @@ struct disasm_result_object
};
extern PyTypeObject disasm_result_object_type
- CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("disasm_result_object");
+ CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("disasm_result_object");
/* When this is false we fast path out of gdbpy_print_insn, which should
keep the performance impact of the Python disassembler down. This is
@@ -94,11 +94,7 @@ struct gdbpy_disassembler : public gdb_printing_disassembler
gdbpy_disassembler (disasm_info_object *obj, PyObject *memory_source);
/* Get the DisassembleInfo object pointer. */
- disasm_info_object *
- py_disasm_info () const
- {
- return m_disasm_info_object;
- }
+ disasm_info_object *py_disasm_info () const { return m_disasm_info_object; }
/* Callbacks used by disassemble_info. */
static void memory_error_func (int status, bfd_vma memaddr,
@@ -113,15 +109,14 @@ struct gdbpy_disassembler : public gdb_printing_disassembler
memory error occurred. The optional will only have a value if a
memory error actually occurred. */
const gdb::optional<CORE_ADDR> &memory_error_address () const
- { return m_memory_error_address; }
+ {
+ return m_memory_error_address;
+ }
/* Return the content of the disassembler as a string. The contents are
moved out of the disassembler, so after this call the disassembler
contents have been reset back to empty. */
- std::string release ()
- {
- return m_string_file.release ();
- }
+ std::string release () { return m_string_file.release (); }
/* If there is a Python exception stored in this disassembler then
restore it (i.e. set the PyErr_* state), clear the exception within
@@ -215,14 +210,13 @@ disasm_info_init (PyObject *self, PyObject *args, PyObject *kwargs)
static const char *keywords[] = { "info", NULL };
PyObject *info_obj;
if (!gdb_PyArg_ParseTupleAndKeywords (args, kwargs, "O!", keywords,
- &disasm_info_object_type,
- &info_obj))
+ &disasm_info_object_type, &info_obj))
return -1;
disasm_info_object *other = (disasm_info_object *) info_obj;
disasm_info_object *info = (disasm_info_object *) self;
- disasm_info_fill (info, other->gdbarch, other->program_space,
- other->address, other->gdb_info, other->next);
+ disasm_info_fill (info, other->gdbarch, other->program_space, other->address,
+ other->gdb_info, other->next);
other->next = info;
/* As the OTHER object now holds a pointer to INFO we inc the ref count
@@ -273,15 +267,17 @@ disasmpy_set_memory_error_for_address (CORE_ADDR address)
/* Ensure that a gdb.disassembler.DisassembleInfo is valid. */
-#define DISASMPY_DISASM_INFO_REQUIRE_VALID(Info) \
- do { \
- if (!disasm_info_object_is_valid (Info)) \
- { \
- PyErr_SetString (PyExc_RuntimeError, \
- _("DisassembleInfo is no longer valid.")); \
- return nullptr; \
- } \
- } while (0)
+#define DISASMPY_DISASM_INFO_REQUIRE_VALID(Info) \
+ do \
+ { \
+ if (!disasm_info_object_is_valid (Info)) \
+ { \
+ PyErr_SetString (PyExc_RuntimeError, \
+ _ ("DisassembleInfo is no longer valid.")); \
+ return nullptr; \
+ } \
+ } \
+ while (0)
/* Initialise OBJ, a DisassemblerResult object with LENGTH and CONTENT.
OBJ might already have been initialised, in which case any existing
@@ -342,7 +338,6 @@ disasmpy_builtin_disassemble (PyObject *self, PyObject *args, PyObject *kw)
if (length == -1)
{
-
/* In an ideal world, every disassembler should always call the
memory error function before returning a status of -1 as the only
error a disassembler should encounter is a failure to read
@@ -365,7 +360,7 @@ disasmpy_builtin_disassemble (PyObject *self, PyObject *args, PyObject *kw)
PyErr_SetString (gdbpy_gdberror_exc, content.c_str ());
else
PyErr_SetString (gdbpy_gdberror_exc,
- _("Unknown disassembly error."));
+ _ ("Unknown disassembly error."));
}
return nullptr;
}
@@ -380,8 +375,8 @@ disasmpy_builtin_disassemble (PyObject *self, PyObject *args, PyObject *kw)
/* Create a DisassemblerResult containing the results. */
std::string content = disassembler.release ();
PyTypeObject *type = &disasm_result_object_type;
- gdbpy_ref<disasm_result_object> res
- ((disasm_result_object *) type->tp_alloc (type, 0));
+ gdbpy_ref<disasm_result_object> res ((disasm_result_object *)
+ type->tp_alloc (type, 0));
disasmpy_init_disassembler_result (res.get (), length, std::move (content));
return reinterpret_cast<PyObject *> (res.release ());
}
@@ -403,14 +398,14 @@ disasmpy_set_enabled (PyObject *self, PyObject *args, PyObject *kw)
{
PyObject *newstate;
static const char *keywords[] = { "state", nullptr };
- if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "O", keywords,
- &newstate))
+ if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "O", keywords, &newstate))
return nullptr;
if (!PyBool_Check (newstate))
{
- PyErr_SetString (PyExc_TypeError,
- _("The value passed to `_set_enabled' must be a boolean."));
+ PyErr_SetString (
+ PyExc_TypeError,
+ _ ("The value passed to `_set_enabled' must be a boolean."));
return nullptr;
}
@@ -435,8 +430,8 @@ disasmpy_info_read_memory (PyObject *self, PyObject *args, PyObject *kw)
gdb::unique_xmalloc_ptr<gdb_byte> buffer;
static const char *keywords[] = { "length", "offset", nullptr };
- if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "L|L", keywords,
- &length, &offset))
+ if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "L|L", keywords, &length,
+ &offset))
return nullptr;
/* The apparent address from which we are reading memory. Note that in
@@ -454,7 +449,8 @@ disasmpy_info_read_memory (PyObject *self, PyObject *args, PyObject *kw)
it to the user. */
disassemble_info *info = obj->gdb_info;
if (info->read_memory_func ((bfd_vma) address, buffer.get (),
- (unsigned int) length, info) != 0)
+ (unsigned int) length, info)
+ != 0)
{
disasmpy_set_memory_error_for_address (address);
return nullptr;
@@ -535,8 +531,7 @@ gdbpy_disassembler::read_memory_func (bfd_vma memaddr, gdb_byte *buff,
/* Now call the DisassembleInfo.read_memory method. This might have been
overridden by the user. */
- gdbpy_ref<> result_obj (PyObject_CallMethod ((PyObject *) obj,
- "read_memory",
+ gdbpy_ref<> result_obj (PyObject_CallMethod ((PyObject *) obj, "read_memory",
"KL", len, offset));
/* Handle any exceptions. */
@@ -565,10 +560,10 @@ gdbpy_disassembler::read_memory_func (bfd_vma memaddr, gdb_byte *buff,
/* Convert the result to a buffer. */
Py_buffer py_buff;
if (!PyObject_CheckBuffer (result_obj.get ())
- || PyObject_GetBuffer (result_obj.get(), &py_buff, PyBUF_CONTIG_RO) < 0)
+ || PyObject_GetBuffer (result_obj.get (), &py_buff, PyBUF_CONTIG_RO) < 0)
{
PyErr_Format (PyExc_TypeError,
- _("Result from read_memory is not a buffer"));
+ _ ("Result from read_memory is not a buffer"));
dis->store_exception (gdbpy_err_fetch ());
return -1;
}
@@ -581,7 +576,8 @@ gdbpy_disassembler::read_memory_func (bfd_vma memaddr, gdb_byte *buff,
if (py_buff.len != len)
{
PyErr_Format (PyExc_ValueError,
- _("Buffer returned from read_memory is sized %d instead of the expected %d"),
+ _ ("Buffer returned from read_memory is sized %d instead "
+ "of the expected %d"),
py_buff.len, len);
dis->store_exception (gdbpy_err_fetch ());
return -1;
@@ -614,8 +610,7 @@ disasmpy_result_string (PyObject *self, void *closure)
gdb_assert (obj->content != nullptr);
gdb_assert (strlen (obj->content->c_str ()) > 0);
gdb_assert (obj->length > 0);
- return PyUnicode_Decode (obj->content->c_str (),
- obj->content->size (),
+ return PyUnicode_Decode (obj->content->c_str (), obj->content->size (),
host_charset (), nullptr);
}
@@ -629,21 +624,19 @@ disasmpy_result_init (PyObject *self, PyObject *args, PyObject *kwargs)
static const char *keywords[] = { "length", "string", NULL };
int length;
const char *string;
- if (!gdb_PyArg_ParseTupleAndKeywords (args, kwargs, "is", keywords,
- &length, &string))
+ if (!gdb_PyArg_ParseTupleAndKeywords (args, kwargs, "is", keywords, &length,
+ &string))
return -1;
if (length <= 0)
{
- PyErr_SetString (PyExc_ValueError,
- _("Length must be greater than 0."));
+ PyErr_SetString (PyExc_ValueError, _ ("Length must be greater than 0."));
return -1;
}
if (strlen (string) == 0)
{
- PyErr_SetString (PyExc_ValueError,
- _("String must not be empty."));
+ PyErr_SetString (PyExc_ValueError, _ ("String must not be empty."));
return -1;
}
@@ -681,12 +674,12 @@ gdbpy_disassembler::print_address_func (bfd_vma addr,
gdbpy_disassembler::gdbpy_disassembler (disasm_info_object *obj,
PyObject *memory_source)
- : gdb_printing_disassembler (obj->gdbarch, &m_string_file,
- read_memory_func, memory_error_func,
- print_address_func),
+ : gdb_printing_disassembler (obj->gdbarch, &m_string_file, read_memory_func,
+ memory_error_func, print_address_func),
m_disasm_info_object (obj),
m_memory_source (memory_source)
-{ /* Nothing. */ }
+{ /* Nothing. */
+}
/* A wrapper around a reference to a Python DisassembleInfo object, which
ensures that the object is marked as invalid when we leave the enclosing
@@ -717,26 +710,20 @@ struct scoped_disasm_info_object
{
/* Invalidate the original DisassembleInfo object as well as any copies
that the user might have made. */
- for (disasm_info_object *obj = m_disasm_info.get ();
- obj != nullptr;
+ for (disasm_info_object *obj = m_disasm_info.get (); obj != nullptr;
obj = obj->next)
obj->gdb_info = nullptr;
}
/* Return a pointer to the underlying disasm_info_object instance. */
- disasm_info_object *
- get () const
- {
- return m_disasm_info.get ();
- }
+ disasm_info_object *get () const { return m_disasm_info.get (); }
private:
/* Wrapper around the call to PyObject_New, this wrapper function can be
called from the constructor initialization list, while PyObject_New, a
macro, can't. */
- static disasm_info_object *
- allocate_disasm_info_object ()
+ static disasm_info_object *allocate_disasm_info_object ()
{
return (disasm_info_object *) PyObject_New (disasm_info_object,
&disasm_info_object_type);
@@ -768,8 +755,8 @@ gdbpy_print_insn (struct gdbarch *gdbarch, CORE_ADDR memaddr,
gdbpy_enter enter_py (get_current_arch (), current_language);
/* Import the gdb.disassembler module. */
- gdbpy_ref<> gdb_python_disassembler_module
- (PyImport_ImportModule ("gdb.disassembler"));
+ gdbpy_ref<> gdb_python_disassembler_module (
+ PyImport_ImportModule ("gdb.disassembler"));
if (gdb_python_disassembler_module == nullptr)
{
gdbpy_print_stack ();
@@ -778,9 +765,8 @@ gdbpy_print_insn (struct gdbarch *gdbarch, CORE_ADDR memaddr,
/* Get the _print_insn attribute from the module, this should be the
function we are going to call to actually perform the disassembly. */
- gdbpy_ref<> hook
- (PyObject_GetAttrString (gdb_python_disassembler_module.get (),
- "_print_insn"));
+ gdbpy_ref<> hook (PyObject_GetAttrString (
+ gdb_python_disassembler_module.get (), "_print_insn"));
if (hook == nullptr)
{
gdbpy_print_stack ();
@@ -796,8 +782,7 @@ gdbpy_print_insn (struct gdbarch *gdbarch, CORE_ADDR memaddr,
disassembly. */
PyObject *insn_disas_obj = (PyObject *) disasm_info;
gdbpy_ref<> result (PyObject_CallFunctionObjArgs (hook.get (),
- insn_disas_obj,
- nullptr));
+ insn_disas_obj, nullptr));
if (result == nullptr)
{
@@ -846,7 +831,6 @@ gdbpy_print_insn (struct gdbarch *gdbarch, CORE_ADDR memaddr,
gdbpy_print_stack ();
return gdb::optional<int> (-1);
}
-
}
else if (result == Py_None)
{
@@ -861,7 +845,7 @@ gdbpy_print_insn (struct gdbarch *gdbarch, CORE_ADDR memaddr,
(PyObject *) &disasm_result_object_type))
{
PyErr_SetString (PyExc_TypeError,
- _("Result is not a DisassemblerResult."));
+ _ ("Result is not a DisassemblerResult."));
gdbpy_print_stack ();
return gdb::optional<int> (-1);
}
@@ -883,7 +867,8 @@ gdbpy_print_insn (struct gdbarch *gdbarch, CORE_ADDR memaddr,
}
if (!gdbpy_is_string (string_obj.get ()))
{
- PyErr_SetString (PyExc_TypeError, _("String attribute is not a string."));
+ PyErr_SetString (PyExc_TypeError,
+ _ ("String attribute is not a string."));
gdbpy_print_stack ();
return gdb::optional<int> (-1);
}
@@ -903,22 +888,23 @@ gdbpy_print_insn (struct gdbarch *gdbarch, CORE_ADDR memaddr,
return gdb::optional<int> (-1);
}
- long max_insn_length = (gdbarch_max_insn_length_p (gdbarch) ?
- gdbarch_max_insn_length (gdbarch) : INT_MAX);
+ long max_insn_length
+ = (gdbarch_max_insn_length_p (gdbarch) ? gdbarch_max_insn_length (gdbarch)
+ : INT_MAX);
if (length <= 0)
{
- PyErr_SetString
- (PyExc_ValueError,
- _("Invalid length attribute: length must be greater than 0."));
+ PyErr_SetString (
+ PyExc_ValueError,
+ _ ("Invalid length attribute: length must be greater than 0."));
gdbpy_print_stack ();
return gdb::optional<int> (-1);
}
if (length > max_insn_length)
{
- PyErr_Format
- (PyExc_ValueError,
- _("Invalid length attribute: length %d greater than architecture maximum of %d"),
- length, max_insn_length);
+ PyErr_Format (PyExc_ValueError,
+ _ ("Invalid length attribute: length %d greater than "
+ "architecture maximum of %d"),
+ length, max_insn_length);
gdbpy_print_stack ();
return gdb::optional<int> (-1);
}
@@ -926,7 +912,7 @@ gdbpy_print_insn (struct gdbarch *gdbarch, CORE_ADDR memaddr,
if (strlen (string.get ()) == 0)
{
PyErr_SetString (PyExc_ValueError,
- _("String attribute must not be empty."));
+ _ ("String attribute must not be empty."));
gdbpy_print_stack ();
return gdb::optional<int> (-1);
}
@@ -957,20 +943,19 @@ static gdb_PyGetSetDef disasm_info_object_getset[] = {
"Architecture to disassemble in", nullptr },
{ "progspace", disasmpy_info_progspace, nullptr,
"Program space to disassemble in", nullptr },
- { nullptr } /* Sentinel */
+ { nullptr } /* Sentinel */
};
/* The methods of the gdb.disassembler.DisassembleInfo type. */
static PyMethodDef disasm_info_object_methods[] = {
{ "read_memory", (PyCFunction) disasmpy_info_read_memory,
- METH_VARARGS | METH_KEYWORDS,
- "read_memory (LEN, OFFSET = 0) -> Octets[]\n\
+ METH_VARARGS | METH_KEYWORDS, "read_memory (LEN, OFFSET = 0) -> Octets[]\n\
Read LEN octets for the instruction to disassemble." },
{ "is_valid", disasmpy_info_is_valid, METH_NOARGS,
"is_valid () -> Boolean.\n\
Return true if this DisassembleInfo is valid, false if not." },
- {nullptr} /* Sentinel */
+ { nullptr } /* Sentinel */
};
/* The get/set attributes of the gdb.disassembler.DisassemblerResult type. */
@@ -980,42 +965,37 @@ static gdb_PyGetSetDef disasm_result_object_getset[] = {
"Length of the disassembled instruction.", nullptr },
{ "string", disasmpy_result_string, nullptr,
"String representing the disassembled instruction.", nullptr },
- { nullptr } /* Sentinel */
+ { nullptr } /* Sentinel */
};
/* These are the methods we add into the _gdb.disassembler module, which
are then imported into the gdb.disassembler module. These are global
functions that support performing disassembly. */
-PyMethodDef python_disassembler_methods[] =
-{
- { "builtin_disassemble", (PyCFunction) disasmpy_builtin_disassemble,
- METH_VARARGS | METH_KEYWORDS,
- "builtin_disassemble (INFO, MEMORY_SOURCE = None) -> None\n\
+PyMethodDef python_disassembler_methods[]
+ = { { "builtin_disassemble", (PyCFunction) disasmpy_builtin_disassemble,
+ METH_VARARGS | METH_KEYWORDS,
+ "builtin_disassemble (INFO, MEMORY_SOURCE = None) -> None\n\
Disassemble using GDB's builtin disassembler. INFO is an instance of\n\
gdb.disassembler.DisassembleInfo. The MEMORY_SOURCE, if not None, should\n\
be an object with the read_memory method." },
- { "_set_enabled", (PyCFunction) disasmpy_set_enabled,
- METH_VARARGS | METH_KEYWORDS,
- "_set_enabled (STATE) -> None\n\
+ { "_set_enabled", (PyCFunction) disasmpy_set_enabled,
+ METH_VARARGS | METH_KEYWORDS, "_set_enabled (STATE) -> None\n\
Set whether GDB should call into the Python _print_insn code or not." },
- {nullptr, nullptr, 0, nullptr}
-};
+ { nullptr, nullptr, 0, nullptr } };
/* Structure to define the _gdb.disassembler module. */
-static struct PyModuleDef python_disassembler_module_def =
-{
- PyModuleDef_HEAD_INIT,
- "_gdb.disassembler",
- nullptr,
- -1,
- python_disassembler_methods,
- nullptr,
- nullptr,
- nullptr,
- nullptr
-};
+static struct PyModuleDef python_disassembler_module_def
+ = { PyModuleDef_HEAD_INIT,
+ "_gdb.disassembler",
+ nullptr,
+ -1,
+ python_disassembler_methods,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr };
/* Called to initialize the Python structures in this file. */
@@ -1028,7 +1008,7 @@ gdbpy_initialize_disasm ()
gdb_disassembler_module = PyModule_Create (&python_disassembler_module_def);
if (gdb_disassembler_module == nullptr)
return -1;
- PyModule_AddObject(gdb_module, "disassembler", gdb_disassembler_module);
+ PyModule_AddObject (gdb_module, "disassembler", gdb_disassembler_module);
/* This is needed so that 'import _gdb.disassembler' will work. */
PyObject *dict = PyImport_GetModuleDict ();
@@ -1039,7 +1019,8 @@ gdbpy_initialize_disasm ()
return -1;
if (gdb_pymodule_addobject (gdb_disassembler_module, "DisassembleInfo",
- (PyObject *) &disasm_info_object_type) < 0)
+ (PyObject *) &disasm_info_object_type)
+ < 0)
return -1;
disasm_result_object_type.tp_new = PyType_GenericNew;
@@ -1047,7 +1028,8 @@ gdbpy_initialize_disasm ()
return -1;
if (gdb_pymodule_addobject (gdb_disassembler_module, "DisassemblerResult",
- (PyObject *) &disasm_result_object_type) < 0)
+ (PyObject *) &disasm_result_object_type)
+ < 0)
return -1;
return 0;
@@ -1056,83 +1038,83 @@ gdbpy_initialize_disasm ()
/* Describe the gdb.disassembler.DisassembleInfo type. */
PyTypeObject disasm_info_object_type = {
- PyVarObject_HEAD_INIT (nullptr, 0)
- "gdb.disassembler.DisassembleInfo", /*tp_name*/
- sizeof (disasm_info_object), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- disasm_info_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
- "GDB instruction disassembler object", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- disasm_info_object_methods, /* tp_methods */
- 0, /* tp_members */
- disasm_info_object_getset, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- disasm_info_init, /* tp_init */
- 0, /* tp_alloc */
+ PyVarObject_HEAD_INIT (nullptr,
+ 0) "gdb.disassembler.DisassembleInfo", /*tp_name*/
+ sizeof (disasm_info_object), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ disasm_info_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
+ "GDB instruction disassembler object", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ disasm_info_object_methods, /* tp_methods */
+ 0, /* tp_members */
+ disasm_info_object_getset, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ disasm_info_init, /* tp_init */
+ 0, /* tp_alloc */
};
/* Describe the gdb.disassembler.DisassemblerResult type. */
PyTypeObject disasm_result_object_type = {
- PyVarObject_HEAD_INIT (nullptr, 0)
- "gdb.disassembler.DisassemblerResult", /*tp_name*/
- sizeof (disasm_result_object), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- disasmpy_dealloc_result, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
- "GDB object, representing a disassembler result", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- disasm_result_object_getset, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- disasmpy_result_init, /* tp_init */
- 0, /* tp_alloc */
+ PyVarObject_HEAD_INIT (nullptr,
+ 0) "gdb.disassembler.DisassemblerResult", /*tp_name*/
+ sizeof (disasm_result_object), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ disasmpy_dealloc_result, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
+ "GDB object, representing a disassembler result", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ 0, /* tp_methods */
+ 0, /* tp_members */
+ disasm_result_object_getset, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ disasmpy_result_init, /* tp_init */
+ 0, /* tp_alloc */
};
diff --git a/gdb/python/py-event.c b/gdb/python/py-event.c
index 3ff31ac..b1db186 100644
--- a/gdb/python/py-event.c
+++ b/gdb/python/py-event.c
@@ -57,8 +57,7 @@ evpy_add_attribute (PyObject *event, const char *name, PyObject *attr)
int
gdbpy_initialize_event (void)
{
- return gdbpy_initialize_event_generic (&event_object_type,
- "Event");
+ return gdbpy_initialize_event_generic (&event_object_type, "Event");
}
/* Initialize the given event type. If BASE is not NULL it will
@@ -66,8 +65,7 @@ gdbpy_initialize_event (void)
Returns 0 if initialization was successful -1 otherwise. */
int
-gdbpy_initialize_event_generic (PyTypeObject *type,
- const char *name)
+gdbpy_initialize_event_generic (PyTypeObject *type, const char *name)
{
if (PyType_Ready (type) < 0)
return -1;
@@ -75,13 +73,11 @@ gdbpy_initialize_event_generic (PyTypeObject *type,
return gdb_pymodule_addobject (gdb_module, name, (PyObject *) type);
}
-
/* Notify the list of listens that the given EVENT has occurred.
returns 0 if emit is successful -1 otherwise. */
int
-evpy_emit_event (PyObject *event,
- eventregistry_object *registry)
+evpy_emit_event (PyObject *event, eventregistry_object *registry)
{
Py_ssize_t i;
@@ -114,50 +110,46 @@ evpy_emit_event (PyObject *event,
return 0;
}
-static gdb_PyGetSetDef event_object_getset[] =
-{
- { "__dict__", gdb_py_generic_dict, NULL,
- "The __dict__ for this event.", &event_object_type },
- { NULL }
-};
-
-PyTypeObject event_object_type =
-{
- PyVarObject_HEAD_INIT (NULL, 0)
- "gdb.Event", /* tp_name */
- sizeof (event_object), /* tp_basicsize */
- 0, /* tp_itemsize */
- evpy_dealloc, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_compare */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- "GDB event object", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- event_object_getset, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- offsetof (event_object, dict), /* tp_dictoffset */
- 0, /* tp_init */
- 0 /* tp_alloc */
+static gdb_PyGetSetDef event_object_getset[]
+ = { { "__dict__", gdb_py_generic_dict, NULL, "The __dict__ for this event.",
+ &event_object_type },
+ { NULL } };
+
+PyTypeObject event_object_type = {
+ PyVarObject_HEAD_INIT (NULL, 0) "gdb.Event", /* tp_name */
+ sizeof (event_object), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ evpy_dealloc, /* tp_dealloc */
+ 0, /* tp_print */
+ 0, /* tp_getattr */
+ 0, /* tp_setattr */
+ 0, /* tp_compare */
+ 0, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ 0, /* tp_str */
+ 0, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ "GDB event object", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ 0, /* tp_methods */
+ 0, /* tp_members */
+ event_object_getset, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ offsetof (event_object, dict), /* tp_dictoffset */
+ 0, /* tp_init */
+ 0 /* tp_alloc */
};
diff --git a/gdb/python/py-event.h b/gdb/python/py-event.h
index 0a7d31d..e213f4e0 100644
--- a/gdb/python/py-event.h
+++ b/gdb/python/py-event.h
@@ -27,8 +27,8 @@
/* Declare all event types. */
#define GDB_PY_DEFINE_EVENT_TYPE(name, py_name, doc, base) \
- extern PyTypeObject name##_event_object_type \
- CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("event_object");
+ extern PyTypeObject name##_event_object_type \
+ CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("event_object");
#include "py-event-types.def"
#undef GDB_PY_DEFINE_EVENT_TYPE
@@ -36,7 +36,7 @@ struct event_object
{
PyObject_HEAD
- PyObject *dict;
+ PyObject *dict;
};
extern int emit_continue_event (ptid_t ptid);
@@ -53,13 +53,11 @@ enum inferior_call_kind
INFERIOR_CALL_POST,
};
-extern int emit_inferior_call_event (inferior_call_kind kind,
- ptid_t thread, CORE_ADDR addr);
-extern int emit_register_changed_event (frame_info_ptr frame,
- int regnum);
+extern int emit_inferior_call_event (inferior_call_kind kind, ptid_t thread,
+ CORE_ADDR addr);
+extern int emit_register_changed_event (frame_info_ptr frame, int regnum);
extern int emit_memory_changed_event (CORE_ADDR addr, ssize_t len);
-extern int evpy_emit_event (PyObject *event,
- eventregistry_object *registry);
+extern int evpy_emit_event (PyObject *event, eventregistry_object *registry);
extern gdbpy_ref<> create_event_object (PyTypeObject *py_type);
@@ -78,9 +76,9 @@ extern int emit_free_objfile_event (struct objfile *objfile);
extern int emit_clear_objfiles_event (void);
extern void evpy_dealloc (PyObject *self);
-extern int evpy_add_attribute (PyObject *event,
- const char *name, PyObject *attr)
- CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
+extern int
+evpy_add_attribute (PyObject *event, const char *name,
+ PyObject *attr) CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
int gdbpy_initialize_event_generic (PyTypeObject *type, const char *name)
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
diff --git a/gdb/python/py-events.h b/gdb/python/py-events.h
index 89fd99b..bcfd47e 100644
--- a/gdb/python/py-events.h
+++ b/gdb/python/py-events.h
@@ -31,7 +31,7 @@ struct eventregistry_object
{
PyObject_HEAD
- PyObject *callbacks;
+ PyObject *callbacks;
};
/* Struct holding references to event registries both in python and c.
@@ -39,13 +39,11 @@ struct eventregistry_object
struct events_object
{
-#define GDB_PY_DEFINE_EVENT(name) \
- eventregistry_object *name;
+#define GDB_PY_DEFINE_EVENT(name) eventregistry_object *name;
#include "py-all-events.def"
#undef GDB_PY_DEFINE_EVENT
PyObject *module;
-
};
/* Python events singleton. */
diff --git a/gdb/python/py-evtregistry.c b/gdb/python/py-evtregistry.c
index 49c4359..374b366 100644
--- a/gdb/python/py-evtregistry.c
+++ b/gdb/python/py-evtregistry.c
@@ -24,7 +24,7 @@
events_object gdb_py_events;
extern PyTypeObject eventregistry_object_type
- CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("eventregistry_object");
+ CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("eventregistry_object");
/* Implementation of EventRegistry.connect () -> NULL.
Add FUNCTION to the list of listeners. */
@@ -79,9 +79,8 @@ evregpy_disconnect (PyObject *self, PyObject *function)
eventregistry_object *
create_eventregistry_object (void)
{
- gdbpy_ref<eventregistry_object>
- eventregistry_obj (PyObject_New (eventregistry_object,
- &eventregistry_object_type));
+ gdbpy_ref<eventregistry_object> eventregistry_obj (
+ PyObject_New (eventregistry_object, &eventregistry_object_type));
if (eventregistry_obj == NULL)
return NULL;
@@ -123,50 +122,47 @@ evregpy_no_listeners_p (eventregistry_object *registry)
return registry == nullptr || PyList_Size (registry->callbacks) == 0;
}
-static PyMethodDef eventregistry_object_methods[] =
-{
+static PyMethodDef eventregistry_object_methods[] = {
{ "connect", evregpy_connect, METH_VARARGS, "Add function" },
{ "disconnect", evregpy_disconnect, METH_VARARGS, "Remove function" },
{ NULL } /* Sentinel. */
};
-PyTypeObject eventregistry_object_type =
-{
- PyVarObject_HEAD_INIT (NULL, 0)
- "gdb.EventRegistry", /* tp_name */
- sizeof (eventregistry_object), /* tp_basicsize */
- 0, /* tp_itemsize */
- evregpy_dealloc, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_compare */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT, /* tp_flags */
- "GDB event registry object", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- eventregistry_object_methods, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- 0, /* tp_init */
- 0 /* tp_alloc */
+PyTypeObject eventregistry_object_type = {
+ PyVarObject_HEAD_INIT (NULL, 0) "gdb.EventRegistry", /* tp_name */
+ sizeof (eventregistry_object), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ evregpy_dealloc, /* tp_dealloc */
+ 0, /* tp_print */
+ 0, /* tp_getattr */
+ 0, /* tp_setattr */
+ 0, /* tp_compare */
+ 0, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ 0, /* tp_str */
+ 0, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ "GDB event registry object", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ eventregistry_object_methods, /* tp_methods */
+ 0, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0 /* tp_alloc */
};
diff --git a/gdb/python/py-evts.c b/gdb/python/py-evts.c
index 5f9e00d..85c35d1 100644
--- a/gdb/python/py-evts.c
+++ b/gdb/python/py-evts.c
@@ -20,17 +20,8 @@
#include "defs.h"
#include "py-events.h"
-static struct PyModuleDef EventModuleDef =
-{
- PyModuleDef_HEAD_INIT,
- "_gdbevents",
- NULL,
- -1,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL
+static struct PyModuleDef EventModuleDef = {
+ PyModuleDef_HEAD_INIT, "_gdbevents", NULL, -1, NULL, NULL, NULL, NULL, NULL
};
/* Helper function to add a single event registry to the events
@@ -44,9 +35,8 @@ add_new_registry (eventregistry_object **registryp, const char *name)
if (*registryp == NULL)
return -1;
- return gdb_pymodule_addobject (gdb_py_events.module,
- name,
- (PyObject *)(*registryp));
+ return gdb_pymodule_addobject (gdb_py_events.module, name,
+ (PyObject *) (*registryp));
}
/* Create and populate the _gdbevents module. Note that this is
@@ -59,8 +49,8 @@ gdbpy_events_mod_func ()
if (gdb_py_events.module == nullptr)
return nullptr;
-#define GDB_PY_DEFINE_EVENT(name) \
- if (add_new_registry (&gdb_py_events.name, #name) < 0) \
+#define GDB_PY_DEFINE_EVENT(name) \
+ if (add_new_registry (&gdb_py_events.name, #name) < 0) \
return nullptr;
#include "py-all-events.def"
#undef GDB_PY_DEFINE_EVENT
diff --git a/gdb/python/py-exitedevent.c b/gdb/python/py-exitedevent.c
index 7506f4b..1cf977e 100644
--- a/gdb/python/py-exitedevent.c
+++ b/gdb/python/py-exitedevent.c
@@ -35,14 +35,16 @@ create_exited_event_object (const LONGEST *exit_code, struct inferior *inf)
if (exit_code_obj == NULL)
return NULL;
if (evpy_add_attribute (exited_event.get (), "exit_code",
- exit_code_obj.get ()) < 0)
+ exit_code_obj.get ())
+ < 0)
return NULL;
}
gdbpy_ref<inferior_object> inf_obj = inferior_to_inferior_object (inf);
- if (inf_obj == NULL || evpy_add_attribute (exited_event.get (),
- "inferior",
- (PyObject *) inf_obj.get ()) < 0)
+ if (inf_obj == NULL
+ || evpy_add_attribute (exited_event.get (), "inferior",
+ (PyObject *) inf_obj.get ())
+ < 0)
return NULL;
return exited_event;
diff --git a/gdb/python/py-finishbreakpoint.c b/gdb/python/py-finishbreakpoint.c
index d4d1291..1d5ba48 100644
--- a/gdb/python/py-finishbreakpoint.c
+++ b/gdb/python/py-finishbreakpoint.c
@@ -17,8 +17,6 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-
#include "defs.h"
#include "python-internal.h"
#include "breakpoint.h"
@@ -62,7 +60,7 @@ struct finish_breakpoint_object
};
extern PyTypeObject finish_breakpoint_object_type
- CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("finish_breakpoint_object");
+ CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("finish_breakpoint_object");
/* Python function to get the 'return_value' attribute of
FinishBreakpoint. */
@@ -70,8 +68,8 @@ extern PyTypeObject finish_breakpoint_object_type
static PyObject *
bpfinishpy_get_returnvalue (PyObject *self, void *closure)
{
- struct finish_breakpoint_object *self_finishbp =
- (struct finish_breakpoint_object *) self;
+ struct finish_breakpoint_object *self_finishbp
+ = (struct finish_breakpoint_object *) self;
if (!self_finishbp->return_value)
Py_RETURN_NONE;
@@ -85,8 +83,8 @@ bpfinishpy_get_returnvalue (PyObject *self, void *closure)
static void
bpfinishpy_dealloc (PyObject *self)
{
- struct finish_breakpoint_object *self_bpfinish =
- (struct finish_breakpoint_object *) self;
+ struct finish_breakpoint_object *self_bpfinish
+ = (struct finish_breakpoint_object *) self;
Py_XDECREF (self_bpfinish->func_symbol);
Py_XDECREF (self_bpfinish->function_value);
@@ -101,8 +99,8 @@ bpfinishpy_dealloc (PyObject *self)
void
bpfinishpy_pre_stop_hook (struct gdbpy_breakpoint_object *bp_obj)
{
- struct finish_breakpoint_object *self_finishbp =
- (struct finish_breakpoint_object *) bp_obj;
+ struct finish_breakpoint_object *self_finishbp
+ = (struct finish_breakpoint_object *) bp_obj;
/* Can compute return_value only once. */
gdb_assert (!self_finishbp->return_value);
@@ -112,18 +110,17 @@ bpfinishpy_pre_stop_hook (struct gdbpy_breakpoint_object *bp_obj)
try
{
- struct symbol *func_symbol =
- symbol_object_to_symbol (self_finishbp->func_symbol);
- struct value *function =
- value_object_to_value (self_finishbp->function_value);
- struct value *ret =
- get_return_value (func_symbol, function);
+ struct symbol *func_symbol
+ = symbol_object_to_symbol (self_finishbp->func_symbol);
+ struct value *function
+ = value_object_to_value (self_finishbp->function_value);
+ struct value *ret = get_return_value (func_symbol, function);
if (ret)
{
self_finishbp->return_value = value_to_value_object (ret);
if (!self_finishbp->return_value)
- gdbpy_print_stack ();
+ gdbpy_print_stack ();
}
else
{
@@ -144,7 +141,6 @@ bpfinishpy_pre_stop_hook (struct gdbpy_breakpoint_object *bp_obj)
void
bpfinishpy_post_stop_hook (struct gdbpy_breakpoint_object *bp_obj)
{
-
try
{
/* Can't delete it here, but it will be removed at the next stop. */
@@ -164,8 +160,8 @@ static int
bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs)
{
static const char *keywords[] = { "frame", "internal", NULL };
- struct finish_breakpoint_object *self_bpfinish =
- (struct finish_breakpoint_object *) self;
+ struct finish_breakpoint_object *self_bpfinish
+ = (struct finish_breakpoint_object *) self;
PyObject *frame_obj = NULL;
int thread;
frame_info_ptr frame = NULL; /* init for gcc -Wall */
@@ -190,7 +186,7 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs)
if (frame == NULL)
{
PyErr_SetString (PyExc_ValueError,
- _("Invalid ID for the `frame' object."));
+ _ ("Invalid ID for the `frame' object."));
}
else
{
@@ -198,15 +194,15 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs)
if (prev_frame == 0)
{
PyErr_SetString (PyExc_ValueError,
- _("\"FinishBreakpoint\" not "
- "meaningful in the outermost "
- "frame."));
+ _ ("\"FinishBreakpoint\" not "
+ "meaningful in the outermost "
+ "frame."));
}
else if (get_frame_type (prev_frame) == DUMMY_FRAME)
{
PyErr_SetString (PyExc_ValueError,
- _("\"FinishBreakpoint\" cannot "
- "be set on a dummy frame."));
+ _ ("\"FinishBreakpoint\" cannot "
+ "be set on a dummy frame."));
}
else
frame_id = get_frame_id (prev_frame);
@@ -223,8 +219,7 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs)
if (inferior_ptid == null_ptid)
{
- PyErr_SetString (PyExc_ValueError,
- _("No thread currently selected."));
+ PyErr_SetString (PyExc_ValueError, _ ("No thread currently selected."));
return -1;
}
@@ -236,7 +231,7 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs)
if (internal_bp == -1)
{
PyErr_SetString (PyExc_ValueError,
- _("The value of `internal' must be a boolean."));
+ _ ("The value of `internal' must be a boolean."));
return -1;
}
}
@@ -252,8 +247,8 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs)
struct symbol *function = find_pc_function (pc);
if (function != nullptr)
{
- struct type *ret_type =
- check_typedef (function->type ()->target_type ());
+ struct type *ret_type
+ = check_typedef (function->type ()->target_type ());
/* Remember only non-void return types. */
if (ret_type->code () != TYPE_CODE_VOID)
@@ -297,15 +292,10 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs)
/* Set a breakpoint on the return address. */
location_spec_up locspec
= new_address_location_spec (get_frame_pc (prev_frame), NULL, 0);
- create_breakpoint (gdbpy_enter::get_gdbarch (),
- locspec.get (), NULL, thread, NULL, false,
- 0,
- 1 /*temp_flag*/,
- bp_breakpoint,
- 0,
- AUTO_BOOLEAN_TRUE,
- &code_breakpoint_ops,
- 0, 1, internal_bp, 0);
+ create_breakpoint (gdbpy_enter::get_gdbarch (), locspec.get (), NULL,
+ thread, NULL, false, 0, 1 /*temp_flag*/,
+ bp_breakpoint, 0, AUTO_BOOLEAN_TRUE,
+ &code_breakpoint_ops, 0, 1, internal_bp, 0);
}
catch (const gdb_exception &except)
{
@@ -357,8 +347,8 @@ bpfinishpy_detect_out_scope_cb (struct breakpoint *b,
not anymore in the current callstack. */
if (py_bp != NULL && b->py_bp_object->is_finish_bp)
{
- struct finish_breakpoint_object *finish_bp =
- (struct finish_breakpoint_object *) py_bp;
+ struct finish_breakpoint_object *finish_bp
+ = (struct finish_breakpoint_object *) py_bp;
/* Check scope if not currently stopped at the FinishBreakpoint. */
if (b != bp_stopped)
@@ -417,7 +407,8 @@ gdbpy_initialize_finishbreakpoints (void)
return -1;
if (gdb_pymodule_addobject (gdb_module, "FinishBreakpoint",
- (PyObject *) &finish_breakpoint_object_type) < 0)
+ (PyObject *) &finish_breakpoint_object_type)
+ < 0)
return -1;
gdb::observers::normal_stop.attach (bpfinishpy_handle_stop,
@@ -430,49 +421,48 @@ gdbpy_initialize_finishbreakpoints (void)
static gdb_PyGetSetDef finish_breakpoint_object_getset[] = {
{ "return_value", bpfinishpy_get_returnvalue, NULL,
- "gdb.Value object representing the return value, if any. \
-None otherwise.", NULL },
- { NULL } /* Sentinel. */
+ "gdb.Value object representing the return value, if any. \
+None otherwise.",
+ NULL },
+ { NULL } /* Sentinel. */
};
-PyTypeObject finish_breakpoint_object_type =
-{
- PyVarObject_HEAD_INIT (NULL, 0)
- "gdb.FinishBreakpoint", /*tp_name*/
- sizeof (struct finish_breakpoint_object), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- bpfinishpy_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro */
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
- "GDB finish breakpoint object", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- finish_breakpoint_object_getset,/* tp_getset */
- &breakpoint_object_type, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- bpfinishpy_init, /* tp_init */
- 0, /* tp_alloc */
- 0 /* tp_new */
+PyTypeObject finish_breakpoint_object_type = {
+ PyVarObject_HEAD_INIT (NULL, 0) "gdb.FinishBreakpoint", /*tp_name*/
+ sizeof (struct finish_breakpoint_object), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ bpfinishpy_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro */
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
+ "GDB finish breakpoint object", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ 0, /* tp_methods */
+ 0, /* tp_members */
+ finish_breakpoint_object_getset, /* tp_getset */
+ &breakpoint_object_type, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ bpfinishpy_init, /* tp_init */
+ 0, /* tp_alloc */
+ 0 /* tp_new */
};
diff --git a/gdb/python/py-frame.c b/gdb/python/py-frame.c
index f66d22b..328c37f 100644
--- a/gdb/python/py-frame.c
+++ b/gdb/python/py-frame.c
@@ -29,9 +29,9 @@
#include "symfile.h"
#include "objfiles.h"
-struct frame_object {
- PyObject_HEAD
- struct frame_id frame_id;
+struct frame_object
+{
+ PyObject_HEAD struct frame_id frame_id;
struct gdbarch *gdbarch;
/* Marks that the FRAME_ID member actually holds the ID of the frame next
@@ -47,12 +47,14 @@ struct frame_object {
/* Require a valid frame. This must be called inside a TRY_CATCH, or
another context in which a gdb exception is allowed. */
-#define FRAPY_REQUIRE_VALID(frame_obj, frame) \
- do { \
- frame = frame_object_to_frame_info (frame_obj); \
- if (frame == NULL) \
- error (_("Frame is invalid.")); \
- } while (0)
+#define FRAPY_REQUIRE_VALID(frame_obj, frame) \
+ do \
+ { \
+ frame = frame_object_to_frame_info (frame_obj); \
+ if (frame == NULL) \
+ error (_ ("Frame is invalid.")); \
+ } \
+ while (0)
/* Returns the frame_info object corresponding to the given Python Frame
object. If the frame doesn't exist anymore (the frame id doesn't
@@ -151,7 +153,8 @@ static PyObject *
frapy_type (PyObject *self, PyObject *args)
{
frame_info_ptr frame;
- enum frame_type type = NORMAL_FRAME;/* Initialize to appease gcc warning. */
+ enum frame_type type
+ = NORMAL_FRAME; /* Initialize to appease gcc warning. */
try
{
@@ -173,7 +176,7 @@ frapy_type (PyObject *self, PyObject *args)
static PyObject *
frapy_arch (PyObject *self, PyObject *args)
{
- frame_info_ptr frame = NULL; /* Initialize to appease gcc warning. */
+ frame_info_ptr frame = NULL; /* Initialize to appease gcc warning. */
frame_object *obj = (frame_object *) self;
try
@@ -194,7 +197,7 @@ frapy_arch (PyObject *self, PyObject *args)
static PyObject *
frapy_unwind_stop_reason (PyObject *self, PyObject *args)
{
- frame_info_ptr frame = NULL; /* Initialize to appease gcc warning. */
+ frame_info_ptr frame = NULL; /* Initialize to appease gcc warning. */
enum unwind_stop_reason stop_reason;
try
@@ -217,7 +220,7 @@ frapy_unwind_stop_reason (PyObject *self, PyObject *args)
static PyObject *
frapy_pc (PyObject *self, PyObject *args)
{
- CORE_ADDR pc = 0; /* Initialize to appease gcc warning. */
+ CORE_ADDR pc = 0; /* Initialize to appease gcc warning. */
frame_info_ptr frame;
try
@@ -260,7 +263,7 @@ frapy_read_register (PyObject *self, PyObject *args)
val = value_of_register (regnum, frame);
if (val == NULL)
- PyErr_SetString (PyExc_ValueError, _("Can't read register."));
+ PyErr_SetString (PyExc_ValueError, _ ("Can't read register."));
}
catch (const gdb_exception &except)
{
@@ -289,28 +292,25 @@ frapy_block (PyObject *self, PyObject *args)
GDB_PY_HANDLE_EXCEPTION (except);
}
- for (fn_block = block;
- fn_block != NULL && fn_block->function () == NULL;
+ for (fn_block = block; fn_block != NULL && fn_block->function () == NULL;
fn_block = fn_block->superblock ())
;
if (block == NULL || fn_block == NULL || fn_block->function () == NULL)
{
PyErr_SetString (PyExc_RuntimeError,
- _("Cannot locate block for frame."));
+ _ ("Cannot locate block for frame."));
return NULL;
}
if (block)
{
- return block_to_block_object
- (block, fn_block->function ()->objfile ());
+ return block_to_block_object (block, fn_block->function ()->objfile ());
}
Py_RETURN_NONE;
}
-
/* Implementation of gdb.Frame.function (self) -> gdb.Symbol.
Returns the symbol for the function corresponding to this frame. */
@@ -353,7 +353,6 @@ frame_info_to_frame_object (frame_info_ptr frame)
try
{
-
/* Try to get the previous frame, to determine if this is the last frame
in a corrupt stack. If so, we need to store the frame_id of the next
frame and not of this one (which is possibly invalid). */
@@ -388,7 +387,7 @@ static PyObject *
frapy_older (PyObject *self, PyObject *args)
{
frame_info_ptr frame, prev = NULL;
- PyObject *prev_obj = NULL; /* Initialize to appease gcc warning. */
+ PyObject *prev_obj = NULL; /* Initialize to appease gcc warning. */
try
{
@@ -420,7 +419,7 @@ static PyObject *
frapy_newer (PyObject *self, PyObject *args)
{
frame_info_ptr frame, next = NULL;
- PyObject *next_obj = NULL; /* Initialize to appease gcc warning. */
+ PyObject *next_obj = NULL; /* Initialize to appease gcc warning. */
try
{
@@ -451,7 +450,7 @@ static PyObject *
frapy_find_sal (PyObject *self, PyObject *args)
{
frame_info_ptr frame;
- PyObject *sal_obj = NULL; /* Initialize to appease gcc warning. */
+ PyObject *sal_obj = NULL; /* Initialize to appease gcc warning. */
try
{
@@ -480,7 +479,7 @@ frapy_read_var (PyObject *self, PyObject *args)
{
frame_info_ptr frame;
PyObject *sym_obj, *block_obj = NULL;
- struct symbol *var = NULL; /* gcc-4.3.2 false warning. */
+ struct symbol *var = NULL; /* gcc-4.3.2 false warning. */
const struct block *block = NULL;
struct value *val = NULL;
@@ -491,8 +490,8 @@ frapy_read_var (PyObject *self, PyObject *args)
var = symbol_object_to_symbol (sym_obj);
else if (gdbpy_is_string (sym_obj))
{
- gdb::unique_xmalloc_ptr<char>
- var_name (python_string_to_target_string (sym_obj));
+ gdb::unique_xmalloc_ptr<char> var_name (
+ python_string_to_target_string (sym_obj));
if (!var_name)
return NULL;
@@ -503,7 +502,7 @@ frapy_read_var (PyObject *self, PyObject *args)
if (!block)
{
PyErr_SetString (PyExc_RuntimeError,
- _("Second argument must be block."));
+ _ ("Second argument must be block."));
return NULL;
}
}
@@ -515,7 +514,8 @@ frapy_read_var (PyObject *self, PyObject *args)
if (!block)
block = get_frame_block (frame, NULL);
- lookup_sym = lookup_symbol (var_name.get (), block, VAR_DOMAIN, NULL);
+ lookup_sym
+ = lookup_symbol (var_name.get (), block, VAR_DOMAIN, NULL);
var = lookup_sym.symbol;
block = lookup_sym.block;
}
@@ -527,8 +527,8 @@ frapy_read_var (PyObject *self, PyObject *args)
if (!var)
{
- PyErr_Format (PyExc_ValueError,
- _("Variable '%s' not found."), var_name.get ());
+ PyErr_Format (PyExc_ValueError, _ ("Variable '%s' not found."),
+ var_name.get ());
return NULL;
}
@@ -536,7 +536,7 @@ frapy_read_var (PyObject *self, PyObject *args)
else
{
PyErr_SetString (PyExc_TypeError,
- _("Argument must be a symbol or string."));
+ _ ("Argument must be a symbol or string."));
return NULL;
}
@@ -673,8 +673,7 @@ gdbpy_frame_stop_reason_string (PyObject *self, PyObject *args)
if (reason < UNWIND_FIRST || reason > UNWIND_LAST)
{
- PyErr_SetString (PyExc_ValueError,
- _("Invalid frame stop reason."));
+ PyErr_SetString (PyExc_ValueError, _ ("Invalid frame stop reason."));
return NULL;
}
@@ -727,17 +726,17 @@ gdbpy_initialize_frames (void)
if (PyModule_AddIntConstant (gdb_module, "NORMAL_FRAME", NORMAL_FRAME) < 0
|| PyModule_AddIntConstant (gdb_module, "DUMMY_FRAME", DUMMY_FRAME) < 0
|| PyModule_AddIntConstant (gdb_module, "INLINE_FRAME", INLINE_FRAME) < 0
- || PyModule_AddIntConstant (gdb_module, "TAILCALL_FRAME",
- TAILCALL_FRAME) < 0
- || PyModule_AddIntConstant (gdb_module, "SIGTRAMP_FRAME",
- SIGTRAMP_FRAME) < 0
+ || PyModule_AddIntConstant (gdb_module, "TAILCALL_FRAME", TAILCALL_FRAME)
+ < 0
+ || PyModule_AddIntConstant (gdb_module, "SIGTRAMP_FRAME", SIGTRAMP_FRAME)
+ < 0
|| PyModule_AddIntConstant (gdb_module, "ARCH_FRAME", ARCH_FRAME) < 0
- || PyModule_AddIntConstant (gdb_module, "SENTINEL_FRAME",
- SENTINEL_FRAME) < 0)
+ || PyModule_AddIntConstant (gdb_module, "SENTINEL_FRAME", SENTINEL_FRAME)
+ < 0)
return -1;
-#define SET(name, description) \
- if (PyModule_AddIntConstant (gdb_module, "FRAME_"#name, name) < 0) \
+#define SET(name, description) \
+ if (PyModule_AddIntConstant (gdb_module, "FRAME_" #name, name) < 0) \
return -1;
#include "unwind_stop_reasons.def"
#undef SET
@@ -746,17 +745,12 @@ gdbpy_initialize_frames (void)
(PyObject *) &frame_object_type);
}
-
-
static PyMethodDef frame_object_methods[] = {
- { "is_valid", frapy_is_valid, METH_NOARGS,
- "is_valid () -> Boolean.\n\
+ { "is_valid", frapy_is_valid, METH_NOARGS, "is_valid () -> Boolean.\n\
Return true if this frame is valid, false if not." },
- { "name", frapy_name, METH_NOARGS,
- "name () -> String.\n\
+ { "name", frapy_name, METH_NOARGS, "name () -> String.\n\
Return the function name of the frame, or None if it can't be determined." },
- { "type", frapy_type, METH_NOARGS,
- "type () -> Integer.\n\
+ { "type", frapy_type, METH_NOARGS, "type () -> Integer.\n\
Return the type of the frame." },
{ "architecture", frapy_arch, METH_NOARGS,
"architecture () -> gdb.Architecture.\n\
@@ -764,23 +758,18 @@ Return the architecture of the frame." },
{ "unwind_stop_reason", frapy_unwind_stop_reason, METH_NOARGS,
"unwind_stop_reason () -> Integer.\n\
Return the reason why it's not possible to find frames older than this." },
- { "pc", frapy_pc, METH_NOARGS,
- "pc () -> Long.\n\
+ { "pc", frapy_pc, METH_NOARGS, "pc () -> Long.\n\
Return the frame's resume address." },
{ "read_register", frapy_read_register, METH_VARARGS,
"read_register (register_name) -> gdb.Value\n\
Return the value of the register in the frame." },
- { "block", frapy_block, METH_NOARGS,
- "block () -> gdb.Block.\n\
+ { "block", frapy_block, METH_NOARGS, "block () -> gdb.Block.\n\
Return the frame's code block." },
- { "function", frapy_function, METH_NOARGS,
- "function () -> gdb.Symbol.\n\
+ { "function", frapy_function, METH_NOARGS, "function () -> gdb.Symbol.\n\
Returns the symbol for the function corresponding to this frame." },
- { "older", frapy_older, METH_NOARGS,
- "older () -> gdb.Frame.\n\
+ { "older", frapy_older, METH_NOARGS, "older () -> gdb.Frame.\n\
Return the frame that called this frame." },
- { "newer", frapy_newer, METH_NOARGS,
- "newer () -> gdb.Frame.\n\
+ { "newer", frapy_newer, METH_NOARGS, "newer () -> gdb.Frame.\n\
Return the frame called by this frame." },
{ "find_sal", frapy_find_sal, METH_NOARGS,
"find_sal () -> gdb.Symtab_and_line.\n\
@@ -790,49 +779,46 @@ Return the frame's symtab and line." },
Return the value of the variable in this frame." },
{ "select", frapy_select, METH_NOARGS,
"Select this frame as the user's current frame." },
- { "level", frapy_level, METH_NOARGS,
- "The stack level of this frame." },
- { "language", frapy_language, METH_NOARGS,
- "The language of this frame." },
- {NULL} /* Sentinel */
+ { "level", frapy_level, METH_NOARGS, "The stack level of this frame." },
+ { "language", frapy_language, METH_NOARGS, "The language of this frame." },
+ { NULL } /* Sentinel */
};
PyTypeObject frame_object_type = {
- PyVarObject_HEAD_INIT (NULL, 0)
- "gdb.Frame", /* tp_name */
- sizeof (frame_object), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_compare */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- frapy_str, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT, /* tp_flags */
- "GDB frame object", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- frapy_richcompare, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- frame_object_methods, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- 0, /* tp_init */
- 0, /* tp_alloc */
+ PyVarObject_HEAD_INIT (NULL, 0) "gdb.Frame", /* tp_name */
+ sizeof (frame_object), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ 0, /* tp_dealloc */
+ 0, /* tp_print */
+ 0, /* tp_getattr */
+ 0, /* tp_setattr */
+ 0, /* tp_compare */
+ 0, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ frapy_str, /* tp_str */
+ 0, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ "GDB frame object", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ frapy_richcompare, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ frame_object_methods, /* tp_methods */
+ 0, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
};
diff --git a/gdb/python/py-framefilter.c b/gdb/python/py-framefilter.c
index 10a3ada..7a10ba5 100644
--- a/gdb/python/py-framefilter.c
+++ b/gdb/python/py-framefilter.c
@@ -96,8 +96,8 @@ extract_sym (PyObject *obj, gdb::unique_xmalloc_ptr<char> *name,
if (*sym == NULL)
{
PyErr_SetString (PyExc_RuntimeError,
- _("Unexpected value. Expecting a "
- "gdb.Symbol or a Python string."));
+ _ ("Unexpected value. Expecting a "
+ "gdb.Symbol or a Python string."));
return EXT_LANG_BT_ERROR;
}
@@ -172,26 +172,26 @@ mi_should_print (struct symbol *sym, enum mi_print_types type)
switch (sym->aclass ())
{
default:
- case LOC_UNDEF: /* catches errors */
- case LOC_CONST: /* constant */
- case LOC_TYPEDEF: /* local typedef */
- case LOC_LABEL: /* local label */
- case LOC_BLOCK: /* local function */
- case LOC_CONST_BYTES: /* loc. byte seq. */
- case LOC_UNRESOLVED: /* unresolved static */
- case LOC_OPTIMIZED_OUT: /* optimized out */
+ case LOC_UNDEF: /* catches errors */
+ case LOC_CONST: /* constant */
+ case LOC_TYPEDEF: /* local typedef */
+ case LOC_LABEL: /* local label */
+ case LOC_BLOCK: /* local function */
+ case LOC_CONST_BYTES: /* loc. byte seq. */
+ case LOC_UNRESOLVED: /* unresolved static */
+ case LOC_OPTIMIZED_OUT: /* optimized out */
print_me = 0;
break;
- case LOC_ARG: /* argument */
- case LOC_REF_ARG: /* reference arg */
- case LOC_REGPARM_ADDR: /* indirect register arg */
- case LOC_LOCAL: /* stack local */
- case LOC_STATIC: /* static */
- case LOC_REGISTER: /* register */
- case LOC_COMPUTED: /* computed location */
+ case LOC_ARG: /* argument */
+ case LOC_REF_ARG: /* reference arg */
+ case LOC_REGPARM_ADDR: /* indirect register arg */
+ case LOC_LOCAL: /* stack local */
+ case LOC_STATIC: /* static */
+ case LOC_REGISTER: /* register */
+ case LOC_COMPUTED: /* computed location */
if (type == MI_PRINT_LOCALS)
- print_me = ! sym->is_argument ();
+ print_me = !sym->is_argument ();
else
print_me = sym->is_argument ();
}
@@ -222,8 +222,7 @@ py_print_type (struct ui_out *out, struct value *val)
static void
py_print_value (struct ui_out *out, struct value *val,
- const struct value_print_options *opts,
- int indent,
+ const struct value_print_options *opts, int indent,
enum ext_lang_frame_args args_type,
const struct language_defn *language)
{
@@ -232,8 +231,7 @@ py_print_value (struct ui_out *out, struct value *val,
/* MI does not print certain values, differentiated by type,
depending on what ARGS_TYPE indicates. Test type against option.
For CLI print all values. */
- if (args_type == MI_PRINT_SIMPLE_VALUES
- || args_type == MI_PRINT_ALL_VALUES)
+ if (args_type == MI_PRINT_SIMPLE_VALUES || args_type == MI_PRINT_ALL_VALUES)
{
struct type *type = check_typedef (value_type (val));
@@ -305,13 +303,10 @@ get_py_iter_from_func (PyObject *filter, const char *func)
printed. */
static void
-py_print_single_arg (struct ui_out *out,
- const char *sym_name,
- struct frame_arg *fa,
- struct value *fv,
+py_print_single_arg (struct ui_out *out, const char *sym_name,
+ struct frame_arg *fa, struct value *fv,
const struct value_print_options *opts,
- enum ext_lang_frame_args args_type,
- int print_args_field,
+ enum ext_lang_frame_args args_type, int print_args_field,
const struct language_defn *language)
{
struct value *val;
@@ -382,7 +377,7 @@ py_print_single_arg (struct ui_out *out,
/* If the output is to the CLI, and the user option "set print
frame-arguments" is set to none, just output "...". */
- if (! out->is_mi_like_p () && args_type == NO_VALUES)
+ if (!out->is_mi_like_p () && args_type == NO_VALUES)
out->field_string ("value", "...");
else
{
@@ -394,7 +389,7 @@ py_print_single_arg (struct ui_out *out,
{
gdb_assert (fa != NULL && fa->error != NULL);
out->field_fmt ("value", metadata_style.style (),
- _("<error reading variable: %s>"),
+ _ ("<error reading variable: %s>"),
fa->error.get ());
}
else
@@ -415,10 +410,8 @@ py_print_single_arg (struct ui_out *out,
success. */
static enum ext_lang_bt_status
-enumerate_args (PyObject *iter,
- struct ui_out *out,
- enum ext_lang_frame_args args_type,
- int print_args_field,
+enumerate_args (PyObject *iter, struct ui_out *out,
+ enum ext_lang_frame_args args_type, int print_args_field,
frame_info_ptr frame)
{
struct value_print_options opts;
@@ -452,8 +445,8 @@ enumerate_args (PyObject *iter,
struct value *val;
enum ext_lang_bt_status success = EXT_LANG_BT_ERROR;
- success = extract_sym (item.get (), &sym_name, &sym, &sym_block,
- &language);
+ success
+ = extract_sym (item.get (), &sym_name, &sym, &sym_block, &language);
if (success == EXT_LANG_BT_ERROR)
return EXT_LANG_BT_ERROR;
@@ -461,8 +454,7 @@ enumerate_args (PyObject *iter,
if (success == EXT_LANG_BT_ERROR)
return EXT_LANG_BT_ERROR;
- if (sym && out->is_mi_like_p ()
- && ! mi_should_print (sym, MI_PRINT_ARGS))
+ if (sym && out->is_mi_like_p () && !mi_should_print (sym, MI_PRINT_ARGS))
continue;
/* If the object did not provide a value, read it using
@@ -476,12 +468,12 @@ enumerate_args (PyObject *iter,
if (sym == NULL)
{
PyErr_SetString (PyExc_RuntimeError,
- _("No symbol or value provided."));
+ _ ("No symbol or value provided."));
return EXT_LANG_BT_ERROR;
}
- read_frame_arg (user_frame_print_options,
- sym, frame, &arg, &entryarg);
+ read_frame_arg (user_frame_print_options, sym, frame, &arg,
+ &entryarg);
/* The object has not provided a value, so this is a frame
argument to be read by GDB. In this case we have to
@@ -489,11 +481,8 @@ enumerate_args (PyObject *iter,
if (arg.entry_kind != print_entry_values_only)
{
- py_print_single_arg (out, NULL, &arg,
- NULL, &opts,
- args_type,
- print_args_field,
- NULL);
+ py_print_single_arg (out, NULL, &arg, NULL, &opts, args_type,
+ print_args_field, NULL);
}
if (entryarg.entry_kind != print_entry_values_no)
@@ -513,8 +502,7 @@ enumerate_args (PyObject *iter,
/* If the object has provided a value, we just print that. */
if (val != NULL)
py_print_single_arg (out, sym_name.get (), NULL, val, &opts,
- args_type, print_args_field,
- language);
+ args_type, print_args_field, language);
}
/* Collect the next item from the iterator. If
@@ -532,7 +520,6 @@ enumerate_args (PyObject *iter,
return EXT_LANG_BT_OK;
}
-
/* Helper function to loop over variables provided by the
"frame_locals" Python API. Elements in the iterable must conform
to the "Symbol Value" interface. ITER is the Python iterable
@@ -545,11 +532,8 @@ enumerate_args (PyObject *iter,
exception, or EXT_LANG_BT_OK on success. */
static enum ext_lang_bt_status
-enumerate_locals (PyObject *iter,
- struct ui_out *out,
- int indent,
- enum ext_lang_frame_args args_type,
- int print_args_field,
+enumerate_locals (PyObject *iter, struct ui_out *out, int indent,
+ enum ext_lang_frame_args args_type, int print_args_field,
frame_info_ptr frame)
{
struct value_print_options opts;
@@ -572,8 +556,8 @@ enumerate_locals (PyObject *iter,
if (item == NULL)
break;
- success = extract_sym (item.get (), &sym_name, &sym, &sym_block,
- &language);
+ success
+ = extract_sym (item.get (), &sym_name, &sym, &sym_block, &language);
if (success == EXT_LANG_BT_ERROR)
return EXT_LANG_BT_ERROR;
@@ -582,7 +566,7 @@ enumerate_locals (PyObject *iter,
return EXT_LANG_BT_ERROR;
if (sym != NULL && out->is_mi_like_p ()
- && ! mi_should_print (sym, MI_PRINT_LOCALS))
+ && !mi_should_print (sym, MI_PRINT_LOCALS))
continue;
/* If the object did not provide a value, read it. */
@@ -608,18 +592,16 @@ enumerate_locals (PyObject *iter,
/* CLI always prints values for locals. MI uses the
simple/no/all system. */
- if (! out->is_mi_like_p ())
+ if (!out->is_mi_like_p ())
{
int val_indent = (indent + 1) * 4;
- py_print_value (out, val, &opts, val_indent, args_type,
- language);
+ py_print_value (out, val, &opts, val_indent, args_type, language);
}
else
{
if (args_type != NO_VALUES)
- py_print_value (out, val, &opts, 0, args_type,
- language);
+ py_print_value (out, val, &opts, 0, args_type, language);
}
out->text ("\n");
@@ -668,10 +650,8 @@ py_mi_print_variables (PyObject *filter, struct ui_out *out,
EXT_LANG_BT_ERROR on error, or EXT_LANG_BT_OK on success. */
static enum ext_lang_bt_status
-py_print_locals (PyObject *filter,
- struct ui_out *out,
- enum ext_lang_frame_args args_type,
- int indent,
+py_print_locals (PyObject *filter, struct ui_out *out,
+ enum ext_lang_frame_args args_type, int indent,
frame_info_ptr frame)
{
gdbpy_ref<> locals_iter (get_py_iter_from_func (filter, "frame_locals"));
@@ -681,8 +661,9 @@ py_print_locals (PyObject *filter,
ui_out_emit_list list_emitter (out, "locals");
if (locals_iter != Py_None
- && (enumerate_locals (locals_iter.get (), out, indent, args_type,
- 0, frame) == EXT_LANG_BT_ERROR))
+ && (enumerate_locals (locals_iter.get (), out, indent, args_type, 0,
+ frame)
+ == EXT_LANG_BT_ERROR))
return EXT_LANG_BT_ERROR;
return EXT_LANG_BT_OK;
@@ -694,10 +675,8 @@ py_print_locals (PyObject *filter,
a Python exception, or EXT_LANG_BT_OK on success. */
static enum ext_lang_bt_status
-py_print_args (PyObject *filter,
- struct ui_out *out,
- enum ext_lang_frame_args args_type,
- frame_info_ptr frame)
+py_print_args (PyObject *filter, struct ui_out *out,
+ enum ext_lang_frame_args args_type, frame_info_ptr frame)
{
gdbpy_ref<> args_iter (get_py_iter_from_func (filter, "frame_args"));
if (args_iter == NULL)
@@ -748,8 +727,8 @@ py_print_args (PyObject *filter,
static enum ext_lang_bt_status
py_print_frame (PyObject *filter, frame_filter_flags flags,
- enum ext_lang_frame_args args_type,
- struct ui_out *out, int indent, htab_t levels_printed)
+ enum ext_lang_frame_args args_type, struct ui_out *out,
+ int indent, htab_t levels_printed)
{
int has_addr = 0;
CORE_ADDR address = 0;
@@ -804,10 +783,10 @@ py_print_frame (PyObject *filter, frame_filter_flags flags,
gdbarch = get_frame_arch (frame);
/* stack-list-variables. */
- if (print_locals && print_args && ! print_frame_info)
+ if (print_locals && print_args && !print_frame_info)
{
- if (py_mi_print_variables (filter, out, &opts,
- args_type, frame) == EXT_LANG_BT_ERROR)
+ if (py_mi_print_variables (filter, out, &opts, args_type, frame)
+ == EXT_LANG_BT_ERROR)
return EXT_LANG_BT_ERROR;
return EXT_LANG_BT_OK;
}
@@ -816,7 +795,7 @@ py_print_frame (PyObject *filter, frame_filter_flags flags,
/* -stack-list-locals does not require a
wrapping frame attribute. */
- if (print_frame_info || (print_args && ! print_locals))
+ if (print_frame_info || (print_args && !print_locals))
tuple.emplace (out, "frame");
if (print_frame_info)
@@ -846,12 +825,10 @@ py_print_frame (PyObject *filter, frame_filter_flags flags,
}
/* For MI, each piece is controlled individually. */
- bool location_print = (print_frame_info
- && !out->is_mi_like_p ()
- && (print_what == LOCATION
- || print_what == SRC_AND_LOC
- || print_what == LOC_AND_ADDRESS
- || print_what == SHORT_LOCATION));
+ bool location_print
+ = (print_frame_info && !out->is_mi_like_p ()
+ && (print_what == LOCATION || print_what == SRC_AND_LOC
+ || print_what == LOC_AND_ADDRESS || print_what == SHORT_LOCATION));
/* Print frame level. MI does not require the level if
locals/variables only are being printed. */
@@ -862,8 +839,8 @@ py_print_frame (PyObject *filter, frame_filter_flags flags,
struct frame_info **slot;
int level;
- slot = (frame_info **) htab_find_slot (levels_printed,
- frame.get(), INSERT);
+ slot = (frame_info **) htab_find_slot (levels_printed, frame.get (),
+ INSERT);
level = frame_relative_level (frame);
@@ -876,8 +853,7 @@ py_print_frame (PyObject *filter, frame_filter_flags flags,
else
{
*slot = frame.get ();
- annotate_frame_begin (print_level ? level : 0,
- gdbarch, address);
+ annotate_frame_begin (print_level ? level : 0, gdbarch, address);
out->text ("#");
out->field_fmt_signed (2, ui_left, "level", level);
}
@@ -889,8 +865,7 @@ py_print_frame (PyObject *filter, frame_filter_flags flags,
print nothing. */
if (opts.addressprint && has_addr)
{
- if (!sal.symtab
- || frame_show_address (frame, sal)
+ if (!sal.symtab || frame_show_address (frame, sal)
|| print_what == LOC_AND_ADDRESS)
{
annotate_frame_address ();
@@ -935,8 +910,8 @@ py_print_frame (PyObject *filter, frame_filter_flags flags,
else if (py_func != Py_None)
{
PyErr_SetString (PyExc_RuntimeError,
- _("FrameDecorator.function: expecting a " \
- "String, integer or None."));
+ _ ("FrameDecorator.function: expecting a "
+ "String, integer or None."));
return EXT_LANG_BT_ERROR;
}
@@ -948,7 +923,6 @@ py_print_frame (PyObject *filter, frame_filter_flags flags,
}
}
-
/* Frame arguments. Check the result, and error if something went
wrong. */
if (print_args && (location_print || out->is_mi_like_p ()))
@@ -974,8 +948,8 @@ py_print_frame (PyObject *filter, frame_filter_flags flags,
if (py_fn != Py_None)
{
- gdb::unique_xmalloc_ptr<char>
- filename (python_string_to_host_string (py_fn.get ()));
+ gdb::unique_xmalloc_ptr<char> filename (
+ python_string_to_host_string (py_fn.get ()));
if (filename == NULL)
return EXT_LANG_BT_ERROR;
@@ -1014,7 +988,7 @@ py_print_frame (PyObject *filter, frame_filter_flags flags,
}
bool source_print
- = (! out->is_mi_like_p ()
+ = (!out->is_mi_like_p ()
&& (print_what == SRC_LINE || print_what == SRC_AND_LOC));
if (source_print)
{
@@ -1025,7 +999,7 @@ py_print_frame (PyObject *filter, frame_filter_flags flags,
/* For MI we need to deal with the "children" list population of
elided frames, so if MI output detected do not send newline. */
- if (! out->is_mi_like_p ())
+ if (!out->is_mi_like_p ())
{
annotate_frame_end ();
/* print_source_lines has already printed a newline. */
@@ -1035,8 +1009,8 @@ py_print_frame (PyObject *filter, frame_filter_flags flags,
if (print_locals)
{
- if (py_print_locals (filter, out, args_type, indent,
- frame) == EXT_LANG_BT_ERROR)
+ if (py_print_locals (filter, out, args_type, indent, frame)
+ == EXT_LANG_BT_ERROR)
return EXT_LANG_BT_ERROR;
}
@@ -1078,8 +1052,8 @@ py_print_frame (PyObject *filter, frame_filter_flags flags,
frame FRAME. */
static PyObject *
-bootstrap_python_frame_filters (frame_info_ptr frame,
- int frame_low, int frame_high)
+bootstrap_python_frame_filters (frame_info_ptr frame, int frame_low,
+ int frame_high)
{
gdbpy_ref<> frame_obj (frame_info_to_frame_object (frame));
if (frame_obj == NULL)
@@ -1102,11 +1076,9 @@ bootstrap_python_frame_filters (frame_info_ptr frame,
if (py_frame_high == NULL)
return NULL;
- gdbpy_ref<> iterable (PyObject_CallFunctionObjArgs (sort_func.get (),
- frame_obj.get (),
- py_frame_low.get (),
- py_frame_high.get (),
- NULL));
+ gdbpy_ref<> iterable (PyObject_CallFunctionObjArgs (
+ sort_func.get (), frame_obj.get (), py_frame_low.get (),
+ py_frame_high.get (), NULL));
if (iterable == NULL)
return NULL;
@@ -1195,9 +1167,7 @@ gdbpy_apply_frame_filter (const struct extension_language_defn *extlang,
if (iterable == Py_None)
return EXT_LANG_BT_NO_FILTERS;
- htab_up levels_printed (htab_create (20,
- htab_hash_pointer,
- htab_eq_pointer,
+ htab_up levels_printed (htab_create (20, htab_hash_pointer, htab_eq_pointer,
NULL));
while (true)
@@ -1222,7 +1192,7 @@ gdbpy_apply_frame_filter (const struct extension_language_defn *extlang,
{
/* We've printed all the frames we were asked to
print, but more frames existed. */
- gdb_printf (_("(More stack frames follow...)\n"));
+ gdb_printf (_ ("(More stack frames follow...)\n"));
break;
}
}
diff --git a/gdb/python/py-function.c b/gdb/python/py-function.c
index e13f7b0..cae977f 100644
--- a/gdb/python/py-function.c
+++ b/gdb/python/py-function.c
@@ -17,7 +17,6 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
#include "defs.h"
#include "value.h"
#include "python-internal.h"
@@ -28,10 +27,8 @@
#include "expression.h"
#include "language.h"
-extern PyTypeObject fnpy_object_type
- CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("PyObject");
-
-
+extern PyTypeObject
+ fnpy_object_type CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("PyObject");
/* Return a reference to a tuple ARGC elements long. Each element of the
tuple is a PyObject converted from the corresponding element of ARGV. */
@@ -79,7 +76,7 @@ fnpy_call (struct gdbarch *gdbarch, const struct language_defn *language,
gdbpy_ref<> callable (PyObject_GetAttrString ((PyObject *) cookie,
"invoke"));
if (callable == NULL)
- error (_("No method named 'invoke' in object."));
+ error (_ ("No method named 'invoke' in object."));
result.reset (PyObject_Call (callable.get (), args.get (), NULL));
}
@@ -91,7 +88,7 @@ fnpy_call (struct gdbarch *gdbarch, const struct language_defn *language,
if (value == NULL)
{
gdbpy_print_stack ();
- error (_("Error while executing Python code."));
+ error (_ ("Error while executing Python code."));
}
return value;
@@ -106,7 +103,7 @@ fnpy_init (PyObject *self, PyObject *args, PyObject *kwds)
const char *name;
gdb::unique_xmalloc_ptr<char> docstring;
- if (! PyArg_ParseTuple (args, "s", &name))
+ if (!PyArg_ParseTuple (args, "s", &name))
return -1;
gdbpy_ref<> self_ref = gdbpy_ref<>::new_reference (self);
@@ -124,8 +121,8 @@ fnpy_init (PyObject *self, PyObject *args, PyObject *kwds)
}
}
}
- if (! docstring)
- docstring.reset (xstrdup (_("This function is not documented.")));
+ if (!docstring)
+ docstring.reset (xstrdup (_ ("This function is not documented.")));
add_internal_function (make_unique_xstrdup (name), std::move (docstring),
fnpy_call, self_ref.release ());
@@ -145,45 +142,41 @@ gdbpy_initialize_functions (void)
(PyObject *) &fnpy_object_type);
}
-
-
-PyTypeObject fnpy_object_type =
-{
- PyVarObject_HEAD_INIT (NULL, 0)
- "gdb.Function", /*tp_name*/
- sizeof (PyObject), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- 0, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
- "GDB function object", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- fnpy_init, /* tp_init */
- 0, /* tp_alloc */
+PyTypeObject fnpy_object_type = {
+ PyVarObject_HEAD_INIT (NULL, 0) "gdb.Function", /*tp_name*/
+ sizeof (PyObject), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ 0, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
+ "GDB function object", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ 0, /* tp_methods */
+ 0, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ fnpy_init, /* tp_init */
+ 0, /* tp_alloc */
};
diff --git a/gdb/python/py-gdb-readline.c b/gdb/python/py-gdb-readline.c
index ea0f78c..91a45e4 100644
--- a/gdb/python/py-gdb-readline.c
+++ b/gdb/python/py-gdb-readline.c
@@ -111,4 +111,3 @@ sys.meta_path.append(GdbRemoveReadlineFinder())\n\
") == 0)
PyOS_ReadlineFunctionPointer = gdbpy_readline_wrapper;
}
-
diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c
index 9b3385c..0cd8fe4 100644
--- a/gdb/python/py-inferior.c
+++ b/gdb/python/py-inferior.c
@@ -39,16 +39,16 @@ struct inferior_object
{
PyObject_HEAD
- /* The inferior we represent. */
- struct inferior *inferior;
+ /* The inferior we represent. */
+ struct inferior *inferior;
/* thread_object instances under this inferior. This owns a
reference to each object it contains. */
thread_map_t *threads;
};
-extern PyTypeObject inferior_object_type
- CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("inferior_object");
+extern PyTypeObject
+ inferior_object_type CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("inferior_object");
/* Deleter to clean up when an inferior is removed. */
struct infpy_deleter
@@ -68,18 +68,20 @@ struct infpy_deleter
};
static const registry<inferior>::key<inferior_object, infpy_deleter>
- infpy_inf_data_key;
+ infpy_inf_data_key;
/* Require that INFERIOR be a valid inferior ID. */
-#define INFPY_REQUIRE_VALID(Inferior) \
- do { \
- if (!Inferior->inferior) \
- { \
- PyErr_SetString (PyExc_RuntimeError, \
- _("Inferior no longer exists.")); \
- return NULL; \
- } \
- } while (0)
+#define INFPY_REQUIRE_VALID(Inferior) \
+ do \
+ { \
+ if (!Inferior->inferior) \
+ { \
+ PyErr_SetString (PyExc_RuntimeError, \
+ _ ("Inferior no longer exists.")); \
+ return NULL; \
+ } \
+ } \
+ while (0)
static void
python_on_normal_stop (struct bpstat *bs, int print_frame)
@@ -141,7 +143,8 @@ python_on_inferior_call_post (ptid_t thread, CORE_ADDR address)
'set' command). */
static void
-python_on_memory_change (struct inferior *inferior, CORE_ADDR addr, ssize_t len, const bfd_byte *data)
+python_on_memory_change (struct inferior *inferior, CORE_ADDR addr,
+ ssize_t len, const bfd_byte *data)
{
gdbpy_enter enter_py (target_gdbarch ());
@@ -189,9 +192,8 @@ python_new_objfile (struct objfile *objfile)
if (!gdb_python_initialized)
return;
- gdbpy_enter enter_py (objfile != NULL
- ? objfile->arch ()
- : target_gdbarch ());
+ gdbpy_enter enter_py (objfile != NULL ? objfile->arch ()
+ : target_gdbarch ());
if (objfile == NULL)
{
@@ -272,7 +274,8 @@ python_new_inferior (struct inferior *inf)
gdbpy_ref<> event = create_event_object (&new_inferior_event_object_type);
if (event == NULL
|| evpy_add_attribute (event.get (), "inferior",
- (PyObject *) inf_obj.get ()) < 0
+ (PyObject *) inf_obj.get ())
+ < 0
|| evpy_emit_event (event.get (), gdb_py_events.new_inferior) < 0)
gdbpy_print_stack ();
}
@@ -297,10 +300,12 @@ python_inferior_deleted (struct inferior *inf)
return;
}
- gdbpy_ref<> event = create_event_object (&inferior_deleted_event_object_type);
+ gdbpy_ref<> event
+ = create_event_object (&inferior_deleted_event_object_type);
if (event == NULL
|| evpy_add_attribute (event.get (), "inferior",
- (PyObject *) inf_obj.get ()) < 0
+ (PyObject *) inf_obj.get ())
+ < 0
|| evpy_emit_event (event.get (), gdb_py_events.inferior_deleted) < 0)
gdbpy_print_stack ();
}
@@ -314,11 +319,10 @@ thread_to_thread_object (thread_info *thr)
auto thread_it = inf_obj->threads->find (thr);
if (thread_it != inf_obj->threads->end ())
- return gdbpy_ref<>::new_reference
- ((PyObject *) (thread_it->second.get ()));
+ return gdbpy_ref<>::new_reference (
+ (PyObject *) (thread_it->second.get ()));
- PyErr_SetString (PyExc_SystemError,
- _("could not find gdb thread object"));
+ PyErr_SetString (PyExc_SystemError, _ ("could not find gdb thread object"));
return NULL;
}
@@ -341,8 +345,8 @@ add_thread_object (struct thread_info *tp)
inf_obj = (inferior_object *) thread_obj->inf_obj;
- auto ins_result = inf_obj->threads->emplace
- (thread_map_t::value_type (tp, std::move (thread_obj)));
+ auto ins_result = inf_obj->threads->emplace (
+ thread_map_t::value_type (tp, std::move (thread_obj)));
if (!ins_result.second)
return;
@@ -350,9 +354,9 @@ add_thread_object (struct thread_info *tp)
if (evregpy_no_listeners_p (gdb_py_events.new_thread))
return;
- gdbpy_ref<> event = create_thread_event_object
- (&new_thread_event_object_type,
- (PyObject *) ins_result.first->second.get ());
+ gdbpy_ref<> event = create_thread_event_object (
+ &new_thread_event_object_type,
+ (PyObject *) ins_result.first->second.get ());
if (event == NULL
|| evpy_emit_event (event.get (), gdb_py_events.new_thread) < 0)
@@ -530,8 +534,8 @@ infpy_read_memory (PyObject *self, PyObject *args, PyObject *kw)
PyObject *addr_obj, *length_obj;
static const char *keywords[] = { "address", "length", NULL };
- if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "OO", keywords,
- &addr_obj, &length_obj))
+ if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "OO", keywords, &addr_obj,
+ &length_obj))
return NULL;
if (get_addr_from_python (addr_obj, &addr) < 0
@@ -549,7 +553,6 @@ infpy_read_memory (PyObject *self, PyObject *args, PyObject *kw)
GDB_PY_HANDLE_EXCEPTION (except);
}
-
return gdbpy_buffer_to_membuf (std::move (buffer), addr, length);
}
@@ -570,8 +573,8 @@ infpy_write_memory (PyObject *self, PyObject *args, PyObject *kw)
static const char *keywords[] = { "address", "buffer", "length", NULL };
Py_buffer pybuf;
- if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "Os*|O", keywords,
- &addr_obj, &pybuf, &length_obj))
+ if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "Os*|O", keywords, &addr_obj,
+ &pybuf, &length_obj))
return NULL;
Py_buffer_up buffer_up (&pybuf);
@@ -622,8 +625,7 @@ infpy_search_memory (PyObject *self, PyObject *args, PyObject *kw)
Py_buffer pybuf;
if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "OOs*", keywords,
- &start_addr_obj, &length_obj,
- &pybuf))
+ &start_addr_obj, &length_obj, &pybuf))
return NULL;
Py_buffer_up buffer_up (&pybuf);
@@ -638,23 +640,19 @@ infpy_search_memory (PyObject *self, PyObject *args, PyObject *kw)
if (!length)
{
- PyErr_SetString (PyExc_ValueError,
- _("Search range is empty."));
+ PyErr_SetString (PyExc_ValueError, _ ("Search range is empty."));
return nullptr;
}
/* Watch for overflows. */
- else if (length > CORE_ADDR_MAX
- || (start_addr + length - 1) < start_addr)
+ else if (length > CORE_ADDR_MAX || (start_addr + length - 1) < start_addr)
{
- PyErr_SetString (PyExc_ValueError,
- _("The search range is too large."));
+ PyErr_SetString (PyExc_ValueError, _ ("The search range is too large."));
return nullptr;
}
try
{
- found = target_search_memory (start_addr, length,
- buffer, pattern_size,
+ found = target_search_memory (start_addr, length, buffer, pattern_size,
&found_addr);
}
catch (gdb_exception &ex)
@@ -678,7 +676,7 @@ infpy_is_valid (PyObject *self, PyObject *args)
{
inferior_object *inf = (inferior_object *) self;
- if (! inf->inferior)
+ if (!inf->inferior)
Py_RETURN_FALSE;
Py_RETURN_TRUE;
@@ -696,7 +694,7 @@ infpy_thread_from_thread_handle (PyObject *self, PyObject *args, PyObject *kw)
INFPY_REQUIRE_VALID (inf_obj);
- if (! gdb_PyArg_ParseTupleAndKeywords (args, kw, "O", keywords, &handle_obj))
+ if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "O", keywords, &handle_obj))
return NULL;
const gdb_byte *bytes;
@@ -719,8 +717,9 @@ infpy_thread_from_thread_handle (PyObject *self, PyObject *args, PyObject *kw)
}
else
{
- PyErr_SetString (PyExc_TypeError,
- _("Argument 'handle' must be a thread handle object."));
+ PyErr_SetString (
+ PyExc_TypeError,
+ _ ("Argument 'handle' must be a thread handle object."));
return NULL;
}
@@ -729,9 +728,8 @@ infpy_thread_from_thread_handle (PyObject *self, PyObject *args, PyObject *kw)
{
struct thread_info *thread_info;
- thread_info = find_thread_by_handle
- (gdb::array_view<const gdb_byte> (bytes, bytes_len),
- inf_obj->inferior);
+ thread_info = find_thread_by_handle (
+ gdb::array_view<const gdb_byte> (bytes, bytes_len), inf_obj->inferior);
if (thread_info != NULL)
return thread_to_thread_object (thread_info).release ();
}
@@ -766,11 +764,10 @@ infpy_repr (PyObject *obj)
if (inf == nullptr)
return PyUnicode_FromString ("<gdb.Inferior (invalid)>");
- return PyUnicode_FromFormat ("<gdb.Inferior num=%d, pid=%d>",
- inf->num, inf->pid);
+ return PyUnicode_FromFormat ("<gdb.Inferior num=%d, pid=%d>", inf->num,
+ inf->pid);
}
-
static void
infpy_dealloc (PyObject *obj)
{
@@ -798,8 +795,8 @@ infpy_dealloc (PyObject *obj)
PyObject *
gdbpy_selected_inferior (PyObject *self, PyObject *args)
{
- return ((PyObject *)
- inferior_to_inferior_object (current_inferior ()).release ());
+ return (
+ (PyObject *) inferior_to_inferior_object (current_inferior ()).release ());
}
int
@@ -809,7 +806,8 @@ gdbpy_initialize_inferior (void)
return -1;
if (gdb_pymodule_addobject (gdb_module, "Inferior",
- (PyObject *) &inferior_object_type) < 0)
+ (PyObject *) &inferior_object_type)
+ < 0)
return -1;
gdb::observers::new_thread.attach (add_thread_object, "py-inferior");
@@ -827,9 +825,9 @@ gdbpy_initialize_inferior (void)
gdb::observers::inferior_exit.attach (python_inferior_exit, "py-inferior");
/* Need to run after auto-load's new_objfile observer, so that
auto-loaded pretty-printers are available. */
- gdb::observers::new_objfile.attach
- (python_new_objfile, "py-inferior",
- { &auto_load_new_objfile_observer_token });
+ gdb::observers::new_objfile.attach (
+ python_new_objfile, "py-inferior",
+ { &auto_load_new_objfile_observer_token });
gdb::observers::free_objfile.attach (python_free_objfile, "py-inferior");
gdb::observers::inferior_added.attach (python_new_inferior, "py-inferior");
gdb::observers::inferior_removed.attach (python_inferior_deleted,
@@ -838,8 +836,7 @@ gdbpy_initialize_inferior (void)
return 0;
}
-static gdb_PyGetSetDef inferior_object_getset[] =
-{
+static gdb_PyGetSetDef inferior_object_getset[] = {
{ "num", infpy_get_num, NULL, "ID of inferior, as assigned by GDB.", NULL },
{ "connection", infpy_get_connection, NULL,
"The gdb.TargetConnection for this inferior.", NULL },
@@ -853,20 +850,16 @@ static gdb_PyGetSetDef inferior_object_getset[] =
{ NULL }
};
-static PyMethodDef inferior_object_methods[] =
-{
- { "is_valid", infpy_is_valid, METH_NOARGS,
- "is_valid () -> Boolean.\n\
+static PyMethodDef inferior_object_methods[] = {
+ { "is_valid", infpy_is_valid, METH_NOARGS, "is_valid () -> Boolean.\n\
Return true if this inferior is valid, false if not." },
{ "threads", infpy_threads, METH_NOARGS,
"Return all the threads of this inferior." },
{ "read_memory", (PyCFunction) infpy_read_memory,
- METH_VARARGS | METH_KEYWORDS,
- "read_memory (address, length) -> buffer\n\
+ METH_VARARGS | METH_KEYWORDS, "read_memory (address, length) -> buffer\n\
Return a buffer object for reading from the inferior's memory." },
{ "write_memory", (PyCFunction) infpy_write_memory,
- METH_VARARGS | METH_KEYWORDS,
- "write_memory (address, buffer [, length])\n\
+ METH_VARARGS | METH_KEYWORDS, "write_memory (address, buffer [, length])\n\
Write the given buffer object to the inferior's memory." },
{ "search_memory", (PyCFunction) infpy_search_memory,
METH_VARARGS | METH_KEYWORDS,
@@ -888,43 +881,41 @@ Return architecture of this inferior." },
{ NULL }
};
-PyTypeObject inferior_object_type =
-{
- PyVarObject_HEAD_INIT (NULL, 0)
- "gdb.Inferior", /* tp_name */
- sizeof (inferior_object), /* tp_basicsize */
- 0, /* tp_itemsize */
- infpy_dealloc, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_compare */
- infpy_repr, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT, /* tp_flags */
- "GDB inferior object", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- inferior_object_methods, /* tp_methods */
- 0, /* tp_members */
- inferior_object_getset, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- 0, /* tp_init */
- 0 /* tp_alloc */
+PyTypeObject inferior_object_type = {
+ PyVarObject_HEAD_INIT (NULL, 0) "gdb.Inferior", /* tp_name */
+ sizeof (inferior_object), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ infpy_dealloc, /* tp_dealloc */
+ 0, /* tp_print */
+ 0, /* tp_getattr */
+ 0, /* tp_setattr */
+ 0, /* tp_compare */
+ infpy_repr, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ 0, /* tp_str */
+ 0, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ "GDB inferior object", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ inferior_object_methods, /* tp_methods */
+ 0, /* tp_members */
+ inferior_object_getset, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0 /* tp_alloc */
};
diff --git a/gdb/python/py-infevents.c b/gdb/python/py-infevents.c
index 1af836b..61ac1aa 100644
--- a/gdb/python/py-infevents.c
+++ b/gdb/python/py-infevents.c
@@ -62,10 +62,10 @@ create_inferior_call_event_object (inferior_call_kind flag, ptid_t ptid,
register number. */
static gdbpy_ref<>
-create_register_changed_event_object (frame_info_ptr frame,
- int regnum)
+create_register_changed_event_object (frame_info_ptr frame, int regnum)
{
- gdbpy_ref<> event = create_event_object (&register_changed_event_object_type);
+ gdbpy_ref<> event
+ = create_event_object (&register_changed_event_object_type);
if (event == NULL)
return NULL;
diff --git a/gdb/python/py-infthread.c b/gdb/python/py-infthread.c
index 9343c8b..c79eb57 100644
--- a/gdb/python/py-infthread.c
+++ b/gdb/python/py-infthread.c
@@ -22,19 +22,21 @@
#include "inferior.h"
#include "python-internal.h"
-extern PyTypeObject thread_object_type
- CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("thread_object");
+extern PyTypeObject
+ thread_object_type CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("thread_object");
/* Require that INFERIOR be a valid inferior ID. */
-#define THPY_REQUIRE_VALID(Thread) \
- do { \
- if (!Thread->thread) \
- { \
- PyErr_SetString (PyExc_RuntimeError, \
- _("Thread no longer exists.")); \
- return NULL; \
- } \
- } while (0)
+#define THPY_REQUIRE_VALID(Thread) \
+ do \
+ { \
+ if (!Thread->thread) \
+ { \
+ PyErr_SetString (PyExc_RuntimeError, \
+ _ ("Thread no longer exists.")); \
+ return NULL; \
+ } \
+ } \
+ while (0)
gdbpy_ref<thread_object>
create_thread_object (struct thread_info *tp)
@@ -110,32 +112,31 @@ thpy_set_name (PyObject *self, PyObject *newvalue, void *ignore)
thread_object *thread_obj = (thread_object *) self;
gdb::unique_xmalloc_ptr<char> name;
- if (! thread_obj->thread)
+ if (!thread_obj->thread)
{
- PyErr_SetString (PyExc_RuntimeError, _("Thread no longer exists."));
+ PyErr_SetString (PyExc_RuntimeError, _ ("Thread no longer exists."));
return -1;
}
if (newvalue == NULL)
{
- PyErr_SetString (PyExc_TypeError,
- _("Cannot delete `name' attribute."));
+ PyErr_SetString (PyExc_TypeError, _ ("Cannot delete `name' attribute."));
return -1;
}
else if (newvalue == Py_None)
{
/* Nothing. */
}
- else if (! gdbpy_is_string (newvalue))
+ else if (!gdbpy_is_string (newvalue))
{
PyErr_SetString (PyExc_TypeError,
- _("The value of `name' must be a string."));
+ _ ("The value of `name' must be a string."));
return -1;
}
else
{
name = python_string_to_host_string (newvalue);
- if (! name)
+ if (!name)
return -1;
}
@@ -277,7 +278,7 @@ thpy_is_valid (PyObject *self, PyObject *args)
{
thread_object *thread_obj = (thread_object *) self;
- if (! thread_obj->thread)
+ if (!thread_obj->thread)
Py_RETURN_FALSE;
Py_RETURN_TRUE;
@@ -292,7 +293,7 @@ thpy_thread_handle (PyObject *self, PyObject *args)
THPY_REQUIRE_VALID (thread_obj);
gdb::byte_vector hv;
-
+
try
{
hv = target_thread_info_to_thread_handle (thread_obj->thread);
@@ -304,12 +305,12 @@ thpy_thread_handle (PyObject *self, PyObject *args)
if (hv.size () == 0)
{
- PyErr_SetString (PyExc_RuntimeError, _("Thread handle not found."));
+ PyErr_SetString (PyExc_RuntimeError, _ ("Thread handle not found."));
return NULL;
}
- PyObject *object = PyBytes_FromStringAndSize ((const char *) hv.data (),
- hv.size());
+ PyObject *object
+ = PyBytes_FromStringAndSize ((const char *) hv.data (), hv.size ());
return object;
}
@@ -371,86 +372,75 @@ gdbpy_initialize_thread (void)
(PyObject *) &thread_object_type);
}
-static gdb_PyGetSetDef thread_object_getset[] =
-{
- { "name", thpy_get_name, thpy_set_name,
- "The name of the thread, as set by the user or the OS.", NULL },
- { "details", thpy_get_details, NULL,
- "A target specific string containing extra thread state details.",
- NULL },
- { "num", thpy_get_num, NULL,
- "Per-inferior number of the thread, as assigned by GDB.", NULL },
- { "global_num", thpy_get_global_num, NULL,
- "Global number of the thread, as assigned by GDB.", NULL },
- { "ptid", thpy_get_ptid, NULL, "ID of the thread, as assigned by the OS.",
- NULL },
- { "inferior", thpy_get_inferior, NULL,
- "The Inferior object this thread belongs to.", NULL },
-
- { NULL }
-};
-
-static PyMethodDef thread_object_methods[] =
-{
- { "is_valid", thpy_is_valid, METH_NOARGS,
- "is_valid () -> Boolean.\n\
+static gdb_PyGetSetDef thread_object_getset[]
+ = { { "name", thpy_get_name, thpy_set_name,
+ "The name of the thread, as set by the user or the OS.", NULL },
+ { "details", thpy_get_details, NULL,
+ "A target specific string containing extra thread state details.",
+ NULL },
+ { "num", thpy_get_num, NULL,
+ "Per-inferior number of the thread, as assigned by GDB.", NULL },
+ { "global_num", thpy_get_global_num, NULL,
+ "Global number of the thread, as assigned by GDB.", NULL },
+ { "ptid", thpy_get_ptid, NULL,
+ "ID of the thread, as assigned by the OS.", NULL },
+ { "inferior", thpy_get_inferior, NULL,
+ "The Inferior object this thread belongs to.", NULL },
+
+ { NULL } };
+
+static PyMethodDef thread_object_methods[] = {
+ { "is_valid", thpy_is_valid, METH_NOARGS, "is_valid () -> Boolean.\n\
Return true if this inferior thread is valid, false if not." },
- { "switch", thpy_switch, METH_NOARGS,
- "switch ()\n\
+ { "switch", thpy_switch, METH_NOARGS, "switch ()\n\
Makes this the GDB selected thread." },
- { "is_stopped", thpy_is_stopped, METH_NOARGS,
- "is_stopped () -> Boolean\n\
+ { "is_stopped", thpy_is_stopped, METH_NOARGS, "is_stopped () -> Boolean\n\
Return whether the thread is stopped." },
- { "is_running", thpy_is_running, METH_NOARGS,
- "is_running () -> Boolean\n\
+ { "is_running", thpy_is_running, METH_NOARGS, "is_running () -> Boolean\n\
Return whether the thread is running." },
- { "is_exited", thpy_is_exited, METH_NOARGS,
- "is_exited () -> Boolean\n\
+ { "is_exited", thpy_is_exited, METH_NOARGS, "is_exited () -> Boolean\n\
Return whether the thread is exited." },
- { "handle", thpy_thread_handle, METH_NOARGS,
- "handle () -> handle\n\
+ { "handle", thpy_thread_handle, METH_NOARGS, "handle () -> handle\n\
Return thread library specific handle for thread." },
{ NULL }
};
-PyTypeObject thread_object_type =
-{
- PyVarObject_HEAD_INIT (NULL, 0)
- "gdb.InferiorThread", /*tp_name*/
- sizeof (thread_object), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- thpy_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- "GDB thread object", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- thread_object_methods, /* tp_methods */
- 0, /* tp_members */
- thread_object_getset, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- 0, /* tp_init */
- 0 /* tp_alloc */
+PyTypeObject thread_object_type = {
+ PyVarObject_HEAD_INIT (NULL, 0) "gdb.InferiorThread", /*tp_name*/
+ sizeof (thread_object), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ thpy_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT, /*tp_flags*/
+ "GDB thread object", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ thread_object_methods, /* tp_methods */
+ 0, /* tp_members */
+ thread_object_getset, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0 /* tp_alloc */
};
diff --git a/gdb/python/py-instruction.c b/gdb/python/py-instruction.c
index ba85a50..91401d7 100644
--- a/gdb/python/py-instruction.c
+++ b/gdb/python/py-instruction.c
@@ -24,13 +24,12 @@
contains getters for four elements: "pc" (int), "data" (buffer), "decode"
(str) and "size" (int) that must be overridden by sub classes. */
-PyTypeObject py_insn_type = {
- PyVarObject_HEAD_INIT (NULL, 0)
-};
+PyTypeObject py_insn_type = { PyVarObject_HEAD_INIT (NULL, 0) };
/* Python instruction object. */
-struct py_insn_obj {
+struct py_insn_obj
+{
PyObject_HEAD
};
@@ -39,19 +38,17 @@ struct py_insn_obj {
static PyObject *
py_insn_getter (PyObject *self, void *closure)
{
- return PyErr_Format (PyExc_NotImplementedError, _("Not implemented."));
+ return PyErr_Format (PyExc_NotImplementedError, _ ("Not implemented."));
}
/* Instruction members. */
-static gdb_PyGetSetDef py_insn_getset[] =
-{
- { "pc", py_insn_getter, NULL, "instruction address", NULL},
- { "data", py_insn_getter, NULL, "instruction memory", NULL},
- { "decoded", py_insn_getter, NULL, "decoded instruction", NULL},
- { "size", py_insn_getter, NULL, "instruction size in bytes", NULL},
- {NULL}
-};
+static gdb_PyGetSetDef py_insn_getset[]
+ = { { "pc", py_insn_getter, NULL, "instruction address", NULL },
+ { "data", py_insn_getter, NULL, "instruction memory", NULL },
+ { "decoded", py_insn_getter, NULL, "decoded instruction", NULL },
+ { "size", py_insn_getter, NULL, "instruction size in bytes", NULL },
+ { NULL } };
/* See py-instruction.h. */
diff --git a/gdb/python/py-lazy-string.c b/gdb/python/py-lazy-string.c
index 7177d74..427f5d6 100644
--- a/gdb/python/py-lazy-string.c
+++ b/gdb/python/py-lazy-string.c
@@ -24,11 +24,12 @@
#include "valprint.h"
#include "language.h"
-struct lazy_string_object {
+struct lazy_string_object
+{
PyObject_HEAD
- /* Holds the address of the lazy string. */
- CORE_ADDR address;
+ /* Holds the address of the lazy string. */
+ CORE_ADDR address;
/* Holds the encoding that will be applied to the string
when the string is printed by GDB. If the encoding is set
@@ -54,7 +55,7 @@ struct lazy_string_object {
};
extern PyTypeObject lazy_string_object_type
- CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("lazy_string_object");
+ CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("lazy_string_object");
static PyObject *
stpy_get_address (PyObject *self, void *closure)
@@ -109,7 +110,7 @@ stpy_convert_to_value (PyObject *self, PyObject *args)
if (self_string->address == 0)
{
PyErr_SetString (gdbpy_gdb_memory_error,
- _("Cannot create a value from NULL."));
+ _ ("Cannot create a value from NULL."));
return NULL;
}
@@ -130,8 +131,8 @@ stpy_convert_to_value (PyObject *self, PyObject *args)
/* PR 20786: There's no way to specify an array of length zero.
Record a length of [0,-1] which is how Ada does it. Anything
we do is broken, but this is one possible solution. */
- type = lookup_array_range_type (realtype->target_type (),
- 0, self_string->length - 1);
+ type = lookup_array_range_type (realtype->target_type (), 0,
+ self_string->length - 1);
val = value_at_lazy (type, self_string->address);
}
else
@@ -174,22 +175,22 @@ gdbpy_create_lazy_string_object (CORE_ADDR address, long length,
if (length < -1)
{
- PyErr_SetString (PyExc_ValueError, _("Invalid length."));
+ PyErr_SetString (PyExc_ValueError, _ ("Invalid length."));
return NULL;
}
if (address == 0 && length != 0)
{
PyErr_SetString (gdbpy_gdb_memory_error,
- _("Cannot create a lazy string with address 0x0, " \
- "and a non-zero length."));
+ _ ("Cannot create a lazy string with address 0x0, "
+ "and a non-zero length."));
return NULL;
}
if (!type)
{
PyErr_SetString (PyExc_RuntimeError,
- _("A lazy string's type cannot be NULL."));
+ _ ("A lazy string's type cannot be NULL."));
return NULL;
}
@@ -207,7 +208,7 @@ gdbpy_create_lazy_string_object (CORE_ADDR address, long length,
length = array_length;
else if (length != array_length)
{
- PyErr_SetString (PyExc_ValueError, _("Invalid length."));
+ PyErr_SetString (PyExc_ValueError, _ ("Invalid length."));
return NULL;
}
break;
@@ -275,8 +276,7 @@ stpy_lazy_string_elt_type (lazy_string_object *lazy)
void
gdbpy_extract_lazy_string (PyObject *string, CORE_ADDR *addr,
- struct type **str_elt_type,
- long *length,
+ struct type **str_elt_type, long *length,
gdb::unique_xmalloc_ptr<char> *encoding)
{
lazy_string_object *lazy;
@@ -291,52 +291,48 @@ gdbpy_extract_lazy_string (PyObject *string, CORE_ADDR *addr,
encoding->reset (lazy->encoding ? xstrdup (lazy->encoding) : NULL);
}
-
-
static PyMethodDef lazy_string_object_methods[] = {
{ "value", stpy_convert_to_value, METH_NOARGS,
"Create a (lazy) value that contains a pointer to the string." },
- {NULL} /* Sentinel */
+ { NULL } /* Sentinel */
};
-
static gdb_PyGetSetDef lazy_string_object_getset[] = {
{ "address", stpy_get_address, NULL, "Address of the string.", NULL },
{ "encoding", stpy_get_encoding, NULL, "Encoding of the string.", NULL },
{ "length", stpy_get_length, NULL, "Length of the string.", NULL },
{ "type", stpy_get_type, NULL, "Type associated with the string.", NULL },
- { NULL } /* Sentinel */
+ { NULL } /* Sentinel */
};
PyTypeObject lazy_string_object_type = {
- PyVarObject_HEAD_INIT (NULL, 0)
- "gdb.LazyString", /*tp_name*/
- sizeof (lazy_string_object), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- stpy_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- "GDB lazy string object", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- lazy_string_object_methods, /* tp_methods */
- 0, /* tp_members */
- lazy_string_object_getset /* tp_getset */
+ PyVarObject_HEAD_INIT (NULL, 0) "gdb.LazyString", /*tp_name*/
+ sizeof (lazy_string_object), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ stpy_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT, /*tp_flags*/
+ "GDB lazy string object", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ lazy_string_object_methods, /* tp_methods */
+ 0, /* tp_members */
+ lazy_string_object_getset /* tp_getset */
};
diff --git a/gdb/python/py-linetable.c b/gdb/python/py-linetable.c
index 7e5a653..bb10ab8 100644
--- a/gdb/python/py-linetable.c
+++ b/gdb/python/py-linetable.c
@@ -20,32 +20,35 @@
#include "defs.h"
#include "python-internal.h"
-struct linetable_entry_object {
+struct linetable_entry_object
+{
PyObject_HEAD
- /* The line table source line. */
- int line;
+ /* The line table source line. */
+ int line;
/* The pc associated with the source line. */
CORE_ADDR pc;
};
extern PyTypeObject linetable_entry_object_type
- CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("linetable_entry_object");
+ CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("linetable_entry_object");
-struct linetable_object {
+struct linetable_object
+{
PyObject_HEAD
- /* The symtab python object. We store the Python object here as the
+ /* The symtab python object. We store the Python object here as the
underlying symtab can become invalid, and we have to run validity
checks on it. */
- PyObject *symtab;
+ PyObject *symtab;
};
extern PyTypeObject linetable_object_type
- CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("linetable_object");
+ CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("linetable_object");
-struct ltpy_iterator_object {
+struct ltpy_iterator_object
+{
PyObject_HEAD
- /* The current entry in the line table for the iterator */
- int current_index;
+ /* The current entry in the line table for the iterator */
+ int current_index;
/* Pointer back to the original source line table object. Needed to
check if the line table is still valid, and has not been invalidated
when an object file has been freed. */
@@ -53,7 +56,7 @@ struct ltpy_iterator_object {
};
extern PyTypeObject ltpy_iterator_object_type
- CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("ltpy_iterator_object");
+ CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("ltpy_iterator_object");
/* Internal helper function to extract gdb.Symtab from a gdb.LineTable
object. */
@@ -66,17 +69,18 @@ get_symtab (PyObject *linetable)
return lt->symtab;
}
-#define LTPY_REQUIRE_VALID(lt_obj, symtab) \
- do { \
- symtab = symtab_object_to_symtab (get_symtab (lt_obj)); \
- if (symtab == NULL) \
- { \
- PyErr_SetString (PyExc_RuntimeError, \
- _("Symbol Table in line table is invalid."));\
- return NULL; \
- } \
- } while (0)
-
+#define LTPY_REQUIRE_VALID(lt_obj, symtab) \
+ do \
+ { \
+ symtab = symtab_object_to_symtab (get_symtab (lt_obj)); \
+ if (symtab == NULL) \
+ { \
+ PyErr_SetString (PyExc_RuntimeError, \
+ _ ("Symbol Table in line table is invalid.")); \
+ return NULL; \
+ } \
+ } \
+ while (0)
/* Helper function to create a line table object that wraps a
gdb.Symtab object. */
@@ -103,8 +107,7 @@ build_linetable_entry (int line, CORE_ADDR address)
{
linetable_entry_object *obj;
- obj = PyObject_New (linetable_entry_object,
- &linetable_entry_object_type);
+ obj = PyObject_New (linetable_entry_object, &linetable_entry_object_type);
if (obj != NULL)
{
obj->line = line;
@@ -161,7 +164,7 @@ ltpy_get_pcs_for_line (PyObject *self, PyObject *args)
LTPY_REQUIRE_VALID (self, symtab);
- if (! PyArg_ParseTuple (args, GDB_PY_LL_ARG, &py_line))
+ if (!PyArg_ParseTuple (args, GDB_PY_LL_ARG, &py_line))
return NULL;
try
@@ -189,13 +192,13 @@ ltpy_has_line (PyObject *self, PyObject *args)
LTPY_REQUIRE_VALID (self, symtab);
- if (! PyArg_ParseTuple (args, GDB_PY_LL_ARG, &py_line))
+ if (!PyArg_ParseTuple (args, GDB_PY_LL_ARG, &py_line))
return NULL;
if (symtab->linetable () == NULL)
{
PyErr_SetString (PyExc_RuntimeError,
- _("Linetable information not found in symbol table"));
+ _ ("Linetable information not found in symbol table"));
return NULL;
}
@@ -203,7 +206,7 @@ ltpy_has_line (PyObject *self, PyObject *args)
{
struct linetable_entry *item = &(symtab->linetable ()->item[index]);
if (item->line == py_line)
- Py_RETURN_TRUE;
+ Py_RETURN_TRUE;
}
Py_RETURN_FALSE;
@@ -226,7 +229,7 @@ ltpy_get_all_source_lines (PyObject *self, PyObject *args)
if (symtab->linetable () == NULL)
{
PyErr_SetString (PyExc_RuntimeError,
- _("Linetable information not found in symbol table"));
+ _ ("Linetable information not found in symbol table"));
return NULL;
}
@@ -301,15 +304,18 @@ gdbpy_initialize_linetable (void)
Py_INCREF (&ltpy_iterator_object_type);
if (gdb_pymodule_addobject (gdb_module, "LineTable",
- (PyObject *) &linetable_object_type) < 0)
+ (PyObject *) &linetable_object_type)
+ < 0)
return -1;
if (gdb_pymodule_addobject (gdb_module, "LineTableEntry",
- (PyObject *) &linetable_entry_object_type) < 0)
+ (PyObject *) &linetable_entry_object_type)
+ < 0)
return -1;
if (gdb_pymodule_addobject (gdb_module, "LineTableIterator",
- (PyObject *) &ltpy_iterator_object_type) < 0)
+ (PyObject *) &ltpy_iterator_object_type)
+ < 0)
return -1;
return 0;
@@ -351,8 +357,8 @@ ltpy_iter (PyObject *self)
LTPY_REQUIRE_VALID (self, symtab);
- ltpy_iter_obj = PyObject_New (ltpy_iterator_object,
- &ltpy_iterator_object_type);
+ ltpy_iter_obj
+ = PyObject_New (ltpy_iterator_object, &ltpy_iterator_object_type);
if (ltpy_iter_obj == NULL)
return NULL;
@@ -446,147 +452,137 @@ ltpy_iter_is_valid (PyObject *self, PyObject *args)
Py_RETURN_TRUE;
}
-
-
static PyMethodDef linetable_object_methods[] = {
- { "line", ltpy_get_pcs_for_line, METH_VARARGS,
- "line (lineno) -> Tuple\n\
+ { "line", ltpy_get_pcs_for_line, METH_VARARGS, "line (lineno) -> Tuple\n\
Return executable locations for a given source line." },
- { "has_line", ltpy_has_line, METH_VARARGS,
- "has_line (lineno) -> Boolean\n\
+ { "has_line", ltpy_has_line, METH_VARARGS, "has_line (lineno) -> Boolean\n\
Return TRUE if this line has executable information, FALSE if not." },
{ "source_lines", ltpy_get_all_source_lines, METH_NOARGS,
"source_lines () -> List\n\
Return a list of all executable source lines." },
- { "is_valid", ltpy_is_valid, METH_NOARGS,
- "is_valid () -> Boolean.\n\
+ { "is_valid", ltpy_is_valid, METH_NOARGS, "is_valid () -> Boolean.\n\
Return True if this LineTable is valid, False if not." },
- {NULL} /* Sentinel */
+ { NULL } /* Sentinel */
};
PyTypeObject linetable_object_type = {
- PyVarObject_HEAD_INIT (NULL, 0)
- "gdb.LineTable", /*tp_name*/
- sizeof (linetable_object), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- ltpy_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- "GDB line table object", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- ltpy_iter, /* tp_iter */
- 0, /* tp_iternext */
- linetable_object_methods, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- 0, /* tp_init */
- 0, /* tp_alloc */
+ PyVarObject_HEAD_INIT (NULL, 0) "gdb.LineTable", /*tp_name*/
+ sizeof (linetable_object), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ ltpy_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT, /*tp_flags*/
+ "GDB line table object", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ ltpy_iter, /* tp_iter */
+ 0, /* tp_iternext */
+ linetable_object_methods, /* tp_methods */
+ 0, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
};
static PyMethodDef ltpy_iterator_methods[] = {
- { "is_valid", ltpy_iter_is_valid, METH_NOARGS,
- "is_valid () -> Boolean.\n\
+ { "is_valid", ltpy_iter_is_valid, METH_NOARGS, "is_valid () -> Boolean.\n\
Return True if this LineTable iterator is valid, False if not." },
- {NULL} /* Sentinel */
+ { NULL } /* Sentinel */
};
PyTypeObject ltpy_iterator_object_type = {
- PyVarObject_HEAD_INIT (NULL, 0)
- "gdb.LineTableIterator", /*tp_name*/
- sizeof (ltpy_iterator_object), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- ltpy_iterator_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- "GDB line table iterator object", /*tp_doc */
- 0, /*tp_traverse */
- 0, /*tp_clear */
- 0, /*tp_richcompare */
- 0, /*tp_weaklistoffset */
- ltpy_iterator, /*tp_iter */
- ltpy_iternext, /*tp_iternext */
- ltpy_iterator_methods /*tp_methods */
+ PyVarObject_HEAD_INIT (NULL, 0) "gdb.LineTableIterator", /*tp_name*/
+ sizeof (ltpy_iterator_object), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ ltpy_iterator_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT, /*tp_flags*/
+ "GDB line table iterator object", /*tp_doc */
+ 0, /*tp_traverse */
+ 0, /*tp_clear */
+ 0, /*tp_richcompare */
+ 0, /*tp_weaklistoffset */
+ ltpy_iterator, /*tp_iter */
+ ltpy_iternext, /*tp_iternext */
+ ltpy_iterator_methods /*tp_methods */
};
-
static gdb_PyGetSetDef linetable_entry_object_getset[] = {
- { "line", ltpy_entry_get_line, NULL,
- "The line number in the source file.", NULL },
- { "pc", ltpy_entry_get_pc, NULL,
- "The memory address for this line number.", NULL },
- { NULL } /* Sentinel */
+ { "line", ltpy_entry_get_line, NULL, "The line number in the source file.",
+ NULL },
+ { "pc", ltpy_entry_get_pc, NULL, "The memory address for this line number.",
+ NULL },
+ { NULL } /* Sentinel */
};
PyTypeObject linetable_entry_object_type = {
- PyVarObject_HEAD_INIT (NULL, 0)
- "gdb.LineTableEntry", /*tp_name*/
- sizeof (linetable_entry_object), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- 0, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- "GDB line table entry object", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- linetable_entry_object_getset, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- 0, /* tp_init */
- 0, /* tp_alloc */
+ PyVarObject_HEAD_INIT (NULL, 0) "gdb.LineTableEntry", /*tp_name*/
+ sizeof (linetable_entry_object), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ 0, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT, /*tp_flags*/
+ "GDB line table entry object", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ 0, /* tp_methods */
+ 0, /* tp_members */
+ linetable_entry_object_getset, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
};
diff --git a/gdb/python/py-membuf.c b/gdb/python/py-membuf.c
index 9390bcf..bc4eb7b 100644
--- a/gdb/python/py-membuf.c
+++ b/gdb/python/py-membuf.c
@@ -20,11 +20,12 @@
#include "defs.h"
#include "python-internal.h"
-struct membuf_object {
+struct membuf_object
+{
PyObject_HEAD
- /* Pointer to the raw data, and array of gdb_bytes. */
- void *buffer;
+ /* Pointer to the raw data, and array of gdb_bytes. */
+ void *buffer;
/* The address from where the data was read, held for mbpy_str. */
CORE_ADDR addr;
@@ -33,8 +34,8 @@ struct membuf_object {
CORE_ADDR length;
};
-extern PyTypeObject membuf_object_type
- CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("membuf_object");
+extern PyTypeObject
+ membuf_object_type CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("membuf_object");
/* Wrap BUFFER, ADDRESS, and LENGTH into a gdb.Membuf object. ADDRESS is
the address within the inferior that the contents of BUFFER were read,
@@ -42,8 +43,7 @@ extern PyTypeObject membuf_object_type
PyObject *
gdbpy_buffer_to_membuf (gdb::unique_xmalloc_ptr<gdb_byte> buffer,
- CORE_ADDR address,
- ULONGEST length)
+ CORE_ADDR address, ULONGEST length)
{
gdbpy_ref<membuf_object> membuf_obj (PyObject_New (membuf_object,
&membuf_object_type));
@@ -73,7 +73,7 @@ mbpy_str (PyObject *self)
{
membuf_object *membuf_obj = (membuf_object *) self;
- return PyUnicode_FromFormat (_("Memory buffer for address %s, \
+ return PyUnicode_FromFormat (_ ("Memory buffer for address %s, \
which is %s bytes long."),
paddress (gdbpy_enter::get_gdbarch (),
membuf_obj->addr),
@@ -86,9 +86,8 @@ get_buffer (PyObject *self, Py_buffer *buf, int flags)
membuf_object *membuf_obj = (membuf_object *) self;
int ret;
- ret = PyBuffer_FillInfo (buf, self, membuf_obj->buffer,
- membuf_obj->length, 0,
- PyBUF_CONTIG);
+ ret = PyBuffer_FillInfo (buf, self, membuf_obj->buffer, membuf_obj->length,
+ 0, PyBUF_CONTIG);
/* Despite the documentation saying this field is a "const char *",
in Python 3.4 at least, it's really a "char *". */
@@ -110,47 +109,43 @@ gdbpy_initialize_membuf (void)
(PyObject *) &membuf_object_type);
}
-static PyBufferProcs buffer_procs =
-{
- get_buffer
-};
+static PyBufferProcs buffer_procs = { get_buffer };
PyTypeObject membuf_object_type = {
- PyVarObject_HEAD_INIT (nullptr, 0)
- "gdb.Membuf", /*tp_name*/
- sizeof (membuf_object), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- mbpy_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
- 0, /*tp_call*/
- mbpy_str, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- &buffer_procs, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- "GDB memory buffer object", /*tp_doc*/
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- 0, /* tp_init */
- 0, /* tp_alloc */
+ PyVarObject_HEAD_INIT (nullptr, 0) "gdb.Membuf", /*tp_name*/
+ sizeof (membuf_object), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ mbpy_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ mbpy_str, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ &buffer_procs, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT, /*tp_flags*/
+ "GDB memory buffer object", /*tp_doc*/
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ 0, /* tp_methods */
+ 0, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
};
diff --git a/gdb/python/py-micmd.c b/gdb/python/py-micmd.c
index ef87b9c..b703fdc 100644
--- a/gdb/python/py-micmd.c
+++ b/gdb/python/py-micmd.c
@@ -39,7 +39,7 @@ static void
show_pymicmd_debug (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
{
- gdb_printf (file, _("Python MI command debugging is %s.\n"), value);
+ gdb_printf (file, _ ("Python MI command debugging is %s.\n"), value);
}
/* Print a "py-micmd" debug statement. */
@@ -60,10 +60,10 @@ struct micmdpy_object
{
PyObject_HEAD
- /* The object representing this command in the MI command table. This
+ /* The object representing this command in the MI command table. This
pointer can be nullptr if the command is not currently installed into
the MI command table (see gdb.MICommand.installed property). */
- struct mi_command_py *mi_command;
+ struct mi_command_py *mi_command;
/* The string representing the name of this command, without the leading
dash. This string is never nullptr once the Python object has been
@@ -147,8 +147,8 @@ struct mi_command_py : public mi_command
than changing the value of mi_command::m_name (which is not accessible
from here) to point to the name owned by the new object, swap the names
of the two objects, since we know they are identical strings. */
- gdb_assert (strcmp (new_pyobj->mi_command_name,
- m_pyobj->mi_command_name) == 0);
+ gdb_assert (strcmp (new_pyobj->mi_command_name, m_pyobj->mi_command_name)
+ == 0);
std::swap (new_pyobj->mi_command_name, m_pyobj->mi_command_name);
/* Take a reference to the new object, drop the reference to the current
@@ -157,17 +157,18 @@ struct mi_command_py : public mi_command
}
/* Called when the MI command is invoked. */
- virtual void invoke(struct mi_parse *parse) const override;
+ virtual void invoke (struct mi_parse *parse) const override;
private:
+
/* The Python object representing this MI command. */
gdbpy_ref<micmdpy_object> m_pyobj;
};
using mi_command_py_up = std::unique_ptr<mi_command_py>;
-extern PyTypeObject micmdpy_object_type
- CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("micmdpy_object");
+extern PyTypeObject
+ micmdpy_object_type CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("micmdpy_object");
/* Holds a Python object containing the string 'invoke'. */
@@ -194,7 +195,7 @@ py_object_to_mi_key (PyObject *key_obj)
if (key_repr_string == nullptr)
gdbpy_handle_exception ();
- gdbpy_error (_("non-string object used as key: %s"),
+ gdbpy_error (_ ("non-string object used as key: %s"),
key_repr_string.get ());
}
@@ -205,8 +206,7 @@ py_object_to_mi_key (PyObject *key_obj)
/* Predicate function, returns true if NAME is a valid field name for use
in MI result output, otherwise, returns false. */
- auto is_valid_key_name = [] (const char *name) -> bool
- {
+ auto is_valid_key_name = [] (const char *name) -> bool {
gdb_assert (name != nullptr);
if (*name == '\0' || !isalpha (*name))
@@ -222,9 +222,9 @@ py_object_to_mi_key (PyObject *key_obj)
if (!is_valid_key_name (key_string.get ()))
{
if (*key_string.get () == '\0')
- gdbpy_error (_("Invalid empty key in MI result"));
+ gdbpy_error (_ ("Invalid empty key in MI result"));
else
- gdbpy_error (_("Invalid key in MI result: %s"), key_string.get ());
+ gdbpy_error (_ ("Invalid key in MI result: %s"), key_string.get ());
}
return key_string;
@@ -256,8 +256,7 @@ serialize_mi_result_1 (PyObject *result, const char *field_name)
ui_out_emit_tuple tuple_emitter (uiout, field_name);
while (PyDict_Next (result, &pos, &key, &value))
{
- gdb::unique_xmalloc_ptr<char> key_string
- (py_object_to_mi_key (key));
+ gdb::unique_xmalloc_ptr<char> key_string (py_object_to_mi_key (key));
serialize_mi_result_1 (value, key_string.get ());
}
}
@@ -269,7 +268,7 @@ serialize_mi_result_1 (PyObject *result, const char *field_name)
gdbpy_handle_exception ();
for (Py_ssize_t i = 0; i < len; ++i)
{
- gdbpy_ref<> item (PySequence_ITEM (result, i));
+ gdbpy_ref<> item (PySequence_ITEM (result, i));
if (item == nullptr)
gdbpy_handle_exception ();
serialize_mi_result_1 (item.get (), nullptr);
@@ -318,14 +317,13 @@ serialize_mi_result (PyObject *result)
/* At the top-level, the result must be a dictionary. */
if (!PyDict_Check (result))
- gdbpy_error (_("Result from invoke must be a dictionary"));
+ gdbpy_error (_ ("Result from invoke must be a dictionary"));
PyObject *key, *value;
Py_ssize_t pos = 0;
while (PyDict_Next (result, &pos, &key, &value))
{
- gdb::unique_xmalloc_ptr<char> key_string
- (py_object_to_mi_key (key));
+ gdb::unique_xmalloc_ptr<char> key_string (py_object_to_mi_key (key));
serialize_mi_result_1 (value, key_string.get ());
}
}
@@ -343,8 +341,8 @@ mi_command_py::invoke (struct mi_parse *parse) const
mi_parse_argv (parse->args, parse);
if (parse->argv == nullptr)
- error (_("Problem parsing arguments: %s %s"), parse->command, parse->args);
-
+ error (_ ("Problem parsing arguments: %s %s"), parse->command,
+ parse->args);
gdbpy_enter enter_py;
@@ -365,9 +363,8 @@ mi_command_py::invoke (struct mi_parse *parse) const
gdb_assert (this->m_pyobj != nullptr);
gdb_assert (PyErr_Occurred () == nullptr);
- gdbpy_ref<> result
- (PyObject_CallMethodObjArgs ((PyObject *) this->m_pyobj.get (), invoke_cst,
- argobj.get (), nullptr));
+ gdbpy_ref<> result (PyObject_CallMethodObjArgs (
+ (PyObject *) this->m_pyobj.get (), invoke_cst, argobj.get (), nullptr));
if (result == nullptr)
gdbpy_handle_exception ();
@@ -454,7 +451,7 @@ micmdpy_install_command (micmdpy_object *obj)
/* There is already an MI command registered with that name, and it's not
a Python one. Forbid replacing a non-Python MI command. */
PyErr_SetString (PyExc_RuntimeError,
- _("unable to add command, name is already in use"));
+ _ ("unable to add command, name is already in use"));
return -1;
}
@@ -491,22 +488,21 @@ micmdpy_init (PyObject *self, PyObject *args, PyObject *kwargs)
static const char *keywords[] = { "name", nullptr };
const char *name;
- if (!gdb_PyArg_ParseTupleAndKeywords (args, kwargs, "s", keywords,
- &name))
+ if (!gdb_PyArg_ParseTupleAndKeywords (args, kwargs, "s", keywords, &name))
return -1;
/* Validate command name */
const int name_len = strlen (name);
if (name_len == 0)
{
- PyErr_SetString (PyExc_ValueError, _("MI command name is empty."));
+ PyErr_SetString (PyExc_ValueError, _ ("MI command name is empty."));
return -1;
}
else if ((name_len < 2) || (name[0] != '-') || !isalnum (name[1]))
{
PyErr_SetString (PyExc_ValueError,
- _("MI command name does not start with '-'"
- " followed by at least one letter or digit."));
+ _ ("MI command name does not start with '-'"
+ " followed by at least one letter or digit."));
return -1;
}
else
@@ -515,10 +511,10 @@ micmdpy_init (PyObject *self, PyObject *args, PyObject *kwargs)
{
if (!isalnum (name[i]) && name[i] != '-')
{
- PyErr_Format
- (PyExc_ValueError,
- _("MI command name contains invalid character: %c."),
- name[i]);
+ PyErr_Format (
+ PyExc_ValueError,
+ _ ("MI command name contains invalid character: %c."),
+ name[i]);
return -1;
}
}
@@ -542,9 +538,9 @@ micmdpy_init (PyObject *self, PyObject *args, PyObject *kwargs)
an excessive restriction. */
if (strcmp (cmd->mi_command_name, name) != 0)
{
- PyErr_SetString
- (PyExc_ValueError,
- _("can't reinitialize object with a different command name"));
+ PyErr_SetString (
+ PyExc_ValueError,
+ _ ("can't reinitialize object with a different command name"));
return -1;
}
@@ -577,7 +573,8 @@ micmdpy_dealloc (PyObject *obj)
be nullptr. */
pymicmd_debug_printf ("obj = %p, name = %s", cmd,
(cmd->mi_command_name == nullptr
- ? "(null)" : cmd->mi_command_name));
+ ? "(null)"
+ : cmd->mi_command_name));
/* As the mi_command_py object holds a reference to the micmdpy_object,
the only way the dealloc function can be called is if the mi_command_py
@@ -620,10 +617,9 @@ gdbpy_finalize_micommands ()
/* mi_command_py objects hold references to micmdpy_object objects. They must
be dropped before the Python interpreter is finalized. Do so by removing
those MI command entries, thus deleting the mi_command_py objects. */
- remove_mi_cmd_entries ([] (mi_command *cmd)
- {
- return as_mi_command_py (cmd) != nullptr;
- });
+ remove_mi_cmd_entries ([] (mi_command *cmd) {
+ return as_mi_command_py (cmd) != nullptr;
+ });
}
/* Get the gdb.MICommand.name attribute, returns a string, the name of this
@@ -680,60 +676,59 @@ static gdb_PyGetSetDef micmdpy_object_getset[] = {
{ "name", micmdpy_get_name, nullptr, "The command's name.", nullptr },
{ "installed", micmdpy_get_installed, micmdpy_set_installed,
"Is this command installed for use.", nullptr },
- { nullptr } /* Sentinel. */
+ { nullptr } /* Sentinel. */
};
/* The gdb.MICommand descriptor. */
PyTypeObject micmdpy_object_type = {
PyVarObject_HEAD_INIT (nullptr, 0) "gdb.MICommand", /*tp_name */
- sizeof (micmdpy_object), /*tp_basicsize */
- 0, /*tp_itemsize */
- micmdpy_dealloc, /*tp_dealloc */
- 0, /*tp_print */
- 0, /*tp_getattr */
- 0, /*tp_setattr */
- 0, /*tp_compare */
- 0, /*tp_repr */
- 0, /*tp_as_number */
- 0, /*tp_as_sequence */
- 0, /*tp_as_mapping */
- 0, /*tp_hash */
- 0, /*tp_call */
- 0, /*tp_str */
- 0, /*tp_getattro */
- 0, /*tp_setattro */
- 0, /*tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags */
- "GDB mi-command object", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- micmdpy_object_getset, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- micmdpy_init, /* tp_init */
- 0, /* tp_alloc */
+ sizeof (micmdpy_object), /*tp_basicsize */
+ 0, /*tp_itemsize */
+ micmdpy_dealloc, /*tp_dealloc */
+ 0, /*tp_print */
+ 0, /*tp_getattr */
+ 0, /*tp_setattr */
+ 0, /*tp_compare */
+ 0, /*tp_repr */
+ 0, /*tp_as_number */
+ 0, /*tp_as_sequence */
+ 0, /*tp_as_mapping */
+ 0, /*tp_hash */
+ 0, /*tp_call */
+ 0, /*tp_str */
+ 0, /*tp_getattro */
+ 0, /*tp_setattro */
+ 0, /*tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags */
+ "GDB mi-command object", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ 0, /* tp_methods */
+ 0, /* tp_members */
+ micmdpy_object_getset, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ micmdpy_init, /* tp_init */
+ 0, /* tp_alloc */
};
void _initialize_py_micmd ();
+
void
_initialize_py_micmd ()
{
- add_setshow_boolean_cmd
- ("py-micmd", class_maintenance, &pymicmd_debug,
- _("Set Python micmd debugging."),
- _("Show Python micmd debugging."),
- _("When on, Python micmd debugging is enabled."),
- nullptr,
- show_pymicmd_debug,
- &setdebuglist, &showdebuglist);
+ add_setshow_boolean_cmd ("py-micmd", class_maintenance, &pymicmd_debug,
+ _ ("Set Python micmd debugging."),
+ _ ("Show Python micmd debugging."),
+ _ ("When on, Python micmd debugging is enabled."),
+ nullptr, show_pymicmd_debug, &setdebuglist,
+ &showdebuglist);
}
diff --git a/gdb/python/py-newobjfileevent.c b/gdb/python/py-newobjfileevent.c
index 34e8e49..27fa5f2 100644
--- a/gdb/python/py-newobjfileevent.c
+++ b/gdb/python/py-newobjfileevent.c
@@ -29,9 +29,10 @@ create_new_objfile_event_object (struct objfile *objfile)
return NULL;
gdbpy_ref<> py_objfile = objfile_to_objfile_object (objfile);
- if (py_objfile == NULL || evpy_add_attribute (objfile_event.get (),
- "new_objfile",
- py_objfile.get ()) < 0)
+ if (py_objfile == NULL
+ || evpy_add_attribute (objfile_event.get (), "new_objfile",
+ py_objfile.get ())
+ < 0)
return NULL;
return objfile_event;
@@ -67,7 +68,8 @@ create_free_objfile_event_object (struct objfile *objfile)
gdbpy_ref<> py_objfile = objfile_to_objfile_object (objfile);
if (py_objfile == nullptr
|| evpy_add_attribute (objfile_event.get (), "objfile",
- py_objfile.get ()) < 0)
+ py_objfile.get ())
+ < 0)
return nullptr;
return objfile_event;
@@ -89,7 +91,6 @@ emit_free_objfile_event (struct objfile *objfile)
return evpy_emit_event (event.get (), gdb_py_events.free_objfile);
}
-
/* Subroutine of emit_clear_objfiles_event to simplify it. */
static gdbpy_ref<>
@@ -101,9 +102,10 @@ create_clear_objfiles_event_object (void)
return NULL;
gdbpy_ref<> py_progspace = pspace_to_pspace_object (current_program_space);
- if (py_progspace == NULL || evpy_add_attribute (objfile_event.get (),
- "progspace",
- py_progspace.get ()) < 0)
+ if (py_progspace == NULL
+ || evpy_add_attribute (objfile_event.get (), "progspace",
+ py_progspace.get ())
+ < 0)
return NULL;
return objfile_event;
diff --git a/gdb/python/py-objfile.c b/gdb/python/py-objfile.c
index b15a3fe..da76fb3 100644
--- a/gdb/python/py-objfile.c
+++ b/gdb/python/py-objfile.c
@@ -30,8 +30,8 @@ struct objfile_object
{
PyObject_HEAD
- /* The corresponding objfile. */
- struct objfile *objfile;
+ /* The corresponding objfile. */
+ struct objfile *objfile;
/* Dictionary holding user-added attributes.
This is the __dict__ attribute of the object. */
@@ -53,8 +53,8 @@ struct objfile_object
PyObject *xmethods;
};
-extern PyTypeObject objfile_object_type
- CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("objfile_object");
+extern PyTypeObject
+ objfile_object_type CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("objfile_object");
/* Clear the OBJFILE pointer in an Objfile object and remove the
reference. */
@@ -69,20 +69,20 @@ struct objfpy_deleter
};
static const registry<objfile>::key<objfile_object, objfpy_deleter>
- objfpy_objfile_data_key;
+ objfpy_objfile_data_key;
/* Require that OBJF be a valid objfile. */
-#define OBJFPY_REQUIRE_VALID(obj) \
- do { \
- if (!(obj)->objfile) \
- { \
- PyErr_SetString (PyExc_RuntimeError, \
- _("Objfile no longer exists.")); \
- return NULL; \
- } \
- } while (0)
-
-
+#define OBJFPY_REQUIRE_VALID(obj) \
+ do \
+ { \
+ if (!(obj)->objfile) \
+ { \
+ PyErr_SetString (PyExc_RuntimeError, \
+ _ ("Objfile no longer exists.")); \
+ return NULL; \
+ } \
+ } \
+ while (0)
/* An Objfile method which returns the objfile's file name, or None. */
@@ -92,8 +92,8 @@ objfpy_get_filename (PyObject *self, void *closure)
objfile_object *obj = (objfile_object *) self;
if (obj->objfile)
- return (host_string_to_python_string (objfile_name (obj->objfile))
- .release ());
+ return (
+ host_string_to_python_string (objfile_name (obj->objfile)).release ());
Py_RETURN_NONE;
}
@@ -265,17 +265,17 @@ objfpy_set_printers (PyObject *o, PyObject *value, void *ignore)
{
objfile_object *self = (objfile_object *) o;
- if (! value)
+ if (!value)
{
PyErr_SetString (PyExc_TypeError,
- _("Cannot delete the pretty_printers attribute."));
+ _ ("Cannot delete the pretty_printers attribute."));
return -1;
}
- if (! PyList_Check (value))
+ if (!PyList_Check (value))
{
PyErr_SetString (PyExc_TypeError,
- _("The pretty_printers attribute must be a list."));
+ _ ("The pretty_printers attribute must be a list."));
return -1;
}
@@ -304,17 +304,18 @@ objfpy_set_frame_filters (PyObject *o, PyObject *filters, void *ignore)
{
objfile_object *self = (objfile_object *) o;
- if (! filters)
+ if (!filters)
{
PyErr_SetString (PyExc_TypeError,
- _("Cannot delete the frame filters attribute."));
+ _ ("Cannot delete the frame filters attribute."));
return -1;
}
- if (! PyDict_Check (filters))
+ if (!PyDict_Check (filters))
{
- PyErr_SetString (PyExc_TypeError,
- _("The frame_filters attribute must be a dictionary."));
+ PyErr_SetString (
+ PyExc_TypeError,
+ _ ("The frame_filters attribute must be a dictionary."));
return -1;
}
@@ -347,14 +348,14 @@ objfpy_set_frame_unwinders (PyObject *o, PyObject *unwinders, void *ignore)
if (!unwinders)
{
PyErr_SetString (PyExc_TypeError,
- _("Cannot delete the frame unwinders attribute."));
+ _ ("Cannot delete the frame unwinders attribute."));
return -1;
}
if (!PyList_Check (unwinders))
{
PyErr_SetString (PyExc_TypeError,
- _("The frame_unwinders attribute must be a list."));
+ _ ("The frame_unwinders attribute must be a list."));
return -1;
}
@@ -395,17 +396,17 @@ objfpy_set_type_printers (PyObject *o, PyObject *value, void *ignore)
{
objfile_object *self = (objfile_object *) o;
- if (! value)
+ if (!value)
{
PyErr_SetString (PyExc_TypeError,
- _("Cannot delete the type_printers attribute."));
+ _ ("Cannot delete the type_printers attribute."));
return -1;
}
- if (! PyList_Check (value))
+ if (!PyList_Check (value))
{
PyErr_SetString (PyExc_TypeError,
- _("The type_printers attribute must be a list."));
+ _ ("The type_printers attribute must be a list."));
return -1;
}
@@ -425,7 +426,7 @@ objfpy_is_valid (PyObject *self, PyObject *args)
{
objfile_object *obj = (objfile_object *) self;
- if (! obj->objfile)
+ if (!obj->objfile)
Py_RETURN_FALSE;
Py_RETURN_TRUE;
@@ -472,14 +473,16 @@ objfpy_lookup_global_symbol (PyObject *self, PyObject *args, PyObject *kw)
OBJFPY_REQUIRE_VALID (obj);
- if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "s|i", keywords, &symbol_name,
- &domain))
+ if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "s|i", keywords,
+ &symbol_name, &domain))
return nullptr;
try
{
- struct symbol *sym = lookup_global_symbol_from_objfile
- (obj->objfile, GLOBAL_BLOCK, symbol_name, (domain_enum) domain).symbol;
+ struct symbol *sym
+ = lookup_global_symbol_from_objfile (obj->objfile, GLOBAL_BLOCK,
+ symbol_name, (domain_enum) domain)
+ .symbol;
if (sym == nullptr)
Py_RETURN_NONE;
@@ -506,14 +509,16 @@ objfpy_lookup_static_symbol (PyObject *self, PyObject *args, PyObject *kw)
OBJFPY_REQUIRE_VALID (obj);
- if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "s|i", keywords, &symbol_name,
- &domain))
+ if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "s|i", keywords,
+ &symbol_name, &domain))
return nullptr;
try
{
- struct symbol *sym = lookup_global_symbol_from_objfile
- (obj->objfile, STATIC_BLOCK, symbol_name, (domain_enum) domain).symbol;
+ struct symbol *sym
+ = lookup_global_symbol_from_objfile (obj->objfile, STATIC_BLOCK,
+ symbol_name, (domain_enum) domain)
+ .symbol;
if (sym == nullptr)
Py_RETURN_NONE;
@@ -595,8 +600,8 @@ gdbpy_lookup_objfile (PyObject *self, PyObject *args, PyObject *kw)
PyObject *by_build_id_obj = NULL;
int by_build_id;
- if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "s|O!", keywords,
- &name, &PyBool_Type, &by_build_id_obj))
+ if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "s|O!", keywords, &name,
+ &PyBool_Type, &by_build_id_obj))
return NULL;
by_build_id = 0;
@@ -611,72 +616,69 @@ gdbpy_lookup_objfile (PyObject *self, PyObject *args, PyObject *kw)
if (by_build_id && !objfpy_build_id_ok (name))
{
- PyErr_SetString (PyExc_TypeError, _("Not a valid build id."));
+ PyErr_SetString (PyExc_TypeError, _ ("Not a valid build id."));
return NULL;
}
struct objfile *objfile = nullptr;
if (by_build_id)
- gdbarch_iterate_over_objfiles_in_search_order
- (target_gdbarch (),
- [&objfile, name] (struct objfile *obj)
- {
- /* Don't return separate debug files. */
- if (obj->separate_debug_objfile_backlink != nullptr)
- return 0;
-
- bfd *obfd = obj->obfd.get ();
- if (obfd == nullptr)
- return 0;
-
- const bfd_build_id *obfd_build_id = build_id_bfd_get (obfd);
- if (obfd_build_id == nullptr)
- return 0;
-
- if (!objfpy_build_id_matches (obfd_build_id, name))
- return 0;
-
- objfile = obj;
- return 1;
- }, gdbpy_current_objfile);
+ gdbarch_iterate_over_objfiles_in_search_order (
+ target_gdbarch (),
+ [&objfile, name] (struct objfile *obj) {
+ /* Don't return separate debug files. */
+ if (obj->separate_debug_objfile_backlink != nullptr)
+ return 0;
+
+ bfd *obfd = obj->obfd.get ();
+ if (obfd == nullptr)
+ return 0;
+
+ const bfd_build_id *obfd_build_id = build_id_bfd_get (obfd);
+ if (obfd_build_id == nullptr)
+ return 0;
+
+ if (!objfpy_build_id_matches (obfd_build_id, name))
+ return 0;
+
+ objfile = obj;
+ return 1;
+ },
+ gdbpy_current_objfile);
else
- gdbarch_iterate_over_objfiles_in_search_order
- (target_gdbarch (),
- [&objfile, name] (struct objfile *obj)
- {
- /* Don't return separate debug files. */
- if (obj->separate_debug_objfile_backlink != nullptr)
- return 0;
-
- if ((obj->flags & OBJF_NOT_FILENAME) != 0)
- return 0;
-
- const char *filename = objfile_filename (obj);
- if (filename != NULL
- && compare_filenames_for_search (filename, name))
- {
- objfile = obj;
- return 1;
- }
-
- if (compare_filenames_for_search (obj->original_name, name))
- {
- objfile = obj;
- return 1;
- }
-
- return 0;
- }, gdbpy_current_objfile);
+ gdbarch_iterate_over_objfiles_in_search_order (
+ target_gdbarch (),
+ [&objfile, name] (struct objfile *obj) {
+ /* Don't return separate debug files. */
+ if (obj->separate_debug_objfile_backlink != nullptr)
+ return 0;
+
+ if ((obj->flags & OBJF_NOT_FILENAME) != 0)
+ return 0;
+
+ const char *filename = objfile_filename (obj);
+ if (filename != NULL && compare_filenames_for_search (filename, name))
+ {
+ objfile = obj;
+ return 1;
+ }
+
+ if (compare_filenames_for_search (obj->original_name, name))
+ {
+ objfile = obj;
+ return 1;
+ }
+
+ return 0;
+ },
+ gdbpy_current_objfile);
if (objfile != NULL)
return objfile_to_objfile_object (objfile).release ();
- PyErr_SetString (PyExc_ValueError, _("Objfile not found."));
+ PyErr_SetString (PyExc_ValueError, _ ("Objfile not found."));
return NULL;
}
-
-
/* Return a new reference to the Python object of type Objfile
representing OBJFILE. If the object has already been created,
return it. Otherwise, create it. Return NULL and set the Python
@@ -685,12 +687,11 @@ gdbpy_lookup_objfile (PyObject *self, PyObject *args, PyObject *kw)
gdbpy_ref<>
objfile_to_objfile_object (struct objfile *objfile)
{
- PyObject *result
- = (PyObject *) objfpy_objfile_data_key.get (objfile);
+ PyObject *result = (PyObject *) objfpy_objfile_data_key.get (objfile);
if (result == NULL)
{
- gdbpy_ref<objfile_object> object
- ((objfile_object *) PyObject_New (objfile_object, &objfile_object_type));
+ gdbpy_ref<objfile_object> object ((objfile_object *) PyObject_New (
+ objfile_object, &objfile_object_type));
if (object == NULL)
return NULL;
if (!objfpy_initialize (object.get ()))
@@ -714,100 +715,87 @@ gdbpy_initialize_objfile (void)
(PyObject *) &objfile_object_type);
}
-
-
-static PyMethodDef objfile_object_methods[] =
-{
- { "is_valid", objfpy_is_valid, METH_NOARGS,
- "is_valid () -> Boolean.\n\
+static PyMethodDef objfile_object_methods[] = {
+ { "is_valid", objfpy_is_valid, METH_NOARGS, "is_valid () -> Boolean.\n\
Return true if this object file is valid, false if not." },
{ "add_separate_debug_file", (PyCFunction) objfpy_add_separate_debug_file,
- METH_VARARGS | METH_KEYWORDS,
- "add_separate_debug_file (file_name).\n\
+ METH_VARARGS | METH_KEYWORDS, "add_separate_debug_file (file_name).\n\
Add FILE_NAME to the list of files containing debug info for the objfile." },
{ "lookup_global_symbol", (PyCFunction) objfpy_lookup_global_symbol,
- METH_VARARGS | METH_KEYWORDS,
- "lookup_global_symbol (name [, domain]).\n\
+ METH_VARARGS | METH_KEYWORDS, "lookup_global_symbol (name [, domain]).\n\
Look up a global symbol in this objfile and return it." },
{ "lookup_static_symbol", (PyCFunction) objfpy_lookup_static_symbol,
- METH_VARARGS | METH_KEYWORDS,
- "lookup_static_symbol (name [, domain]).\n\
+ METH_VARARGS | METH_KEYWORDS, "lookup_static_symbol (name [, domain]).\n\
Look up a static-linkage global symbol in this objfile and return it." },
{ NULL }
};
-static gdb_PyGetSetDef objfile_getset[] =
-{
- { "__dict__", gdb_py_generic_dict, NULL,
- "The __dict__ for this objfile.", &objfile_object_type },
- { "filename", objfpy_get_filename, NULL,
- "The objfile's filename, or None.", NULL },
- { "username", objfpy_get_username, NULL,
- "The name of the objfile as provided by the user, or None.", NULL },
- { "owner", objfpy_get_owner, NULL,
- "The objfile owner of separate debug info objfiles, or None.",
- NULL },
- { "build_id", objfpy_get_build_id, NULL,
- "The objfile's build id, or None.", NULL },
- { "progspace", objfpy_get_progspace, NULL,
- "The objfile's progspace, or None.", NULL },
- { "pretty_printers", objfpy_get_printers, objfpy_set_printers,
- "Pretty printers.", NULL },
- { "frame_filters", objfpy_get_frame_filters,
- objfpy_set_frame_filters, "Frame Filters.", NULL },
- { "frame_unwinders", objfpy_get_frame_unwinders,
- objfpy_set_frame_unwinders, "Frame Unwinders", NULL },
- { "type_printers", objfpy_get_type_printers, objfpy_set_type_printers,
- "Type printers.", NULL },
- { "xmethods", objfpy_get_xmethods, NULL,
- "Debug methods.", NULL },
- { "is_file", objfpy_get_is_file, nullptr,
- "Whether this objfile came from a file.", nullptr },
- { NULL }
-};
-
-PyTypeObject objfile_object_type =
-{
- PyVarObject_HEAD_INIT (NULL, 0)
- "gdb.Objfile", /*tp_name*/
- sizeof (objfile_object), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- objfpy_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- objfpy_repr, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- "GDB objfile object", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- objfile_object_methods, /* tp_methods */
- 0, /* tp_members */
- objfile_getset, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- offsetof (objfile_object, dict), /* tp_dictoffset */
- 0, /* tp_init */
- 0, /* tp_alloc */
- objfpy_new, /* tp_new */
+static gdb_PyGetSetDef objfile_getset[]
+ = { { "__dict__", gdb_py_generic_dict, NULL,
+ "The __dict__ for this objfile.", &objfile_object_type },
+ { "filename", objfpy_get_filename, NULL,
+ "The objfile's filename, or None.", NULL },
+ { "username", objfpy_get_username, NULL,
+ "The name of the objfile as provided by the user, or None.", NULL },
+ { "owner", objfpy_get_owner, NULL,
+ "The objfile owner of separate debug info objfiles, or None.", NULL },
+ { "build_id", objfpy_get_build_id, NULL,
+ "The objfile's build id, or None.", NULL },
+ { "progspace", objfpy_get_progspace, NULL,
+ "The objfile's progspace, or None.", NULL },
+ { "pretty_printers", objfpy_get_printers, objfpy_set_printers,
+ "Pretty printers.", NULL },
+ { "frame_filters", objfpy_get_frame_filters, objfpy_set_frame_filters,
+ "Frame Filters.", NULL },
+ { "frame_unwinders", objfpy_get_frame_unwinders,
+ objfpy_set_frame_unwinders, "Frame Unwinders", NULL },
+ { "type_printers", objfpy_get_type_printers, objfpy_set_type_printers,
+ "Type printers.", NULL },
+ { "xmethods", objfpy_get_xmethods, NULL, "Debug methods.", NULL },
+ { "is_file", objfpy_get_is_file, nullptr,
+ "Whether this objfile came from a file.", nullptr },
+ { NULL } };
+
+PyTypeObject objfile_object_type = {
+ PyVarObject_HEAD_INIT (NULL, 0) "gdb.Objfile", /*tp_name*/
+ sizeof (objfile_object), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ objfpy_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ objfpy_repr, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT, /*tp_flags*/
+ "GDB objfile object", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ objfile_object_methods, /* tp_methods */
+ 0, /* tp_members */
+ objfile_getset, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ offsetof (objfile_object, dict), /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ objfpy_new, /* tp_new */
};
diff --git a/gdb/python/py-param.c b/gdb/python/py-param.c
index a1bd4e0..935612b 100644
--- a/gdb/python/py-param.c
+++ b/gdb/python/py-param.c
@@ -17,7 +17,6 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
#include "defs.h"
#include "value.h"
#include "python-internal.h"
@@ -44,8 +43,7 @@ enum param_types
param_zuinteger,
param_zuinteger_unlimited,
param_enum,
-}
-param_types;
+} param_types;
/* Translation from Python parameters to GDB variable types. Keep in the
same order as PARAM_TYPES due to C++'s lack of designated initializers. */
@@ -57,43 +55,38 @@ static const struct
/* Extra literals, such as `unlimited', accepted in lieu of a number. */
const literal_def *extra_literals;
-}
-param_to_var[] =
-{
- { var_boolean },
- { var_auto_boolean },
- { var_uinteger, uinteger_unlimited_literals },
- { var_integer, integer_unlimited_literals },
- { var_string },
- { var_string_noescape },
- { var_optional_filename },
- { var_filename },
- { var_integer },
- { var_uinteger },
- { var_pinteger, pinteger_unlimited_literals },
- { var_enum }
-};
+} param_to_var[] = { { var_boolean },
+ { var_auto_boolean },
+ { var_uinteger, uinteger_unlimited_literals },
+ { var_integer, integer_unlimited_literals },
+ { var_string },
+ { var_string_noescape },
+ { var_optional_filename },
+ { var_filename },
+ { var_integer },
+ { var_uinteger },
+ { var_pinteger, pinteger_unlimited_literals },
+ { var_enum } };
/* Parameter constants and their values. */
-static struct {
+static struct
+{
const char *name;
int value;
-} parm_constants[] =
-{
- { "PARAM_BOOLEAN", param_boolean }, /* ARI: param_boolean */
- { "PARAM_AUTO_BOOLEAN", param_auto_boolean },
- { "PARAM_UINTEGER", param_uinteger },
- { "PARAM_INTEGER", param_integer },
- { "PARAM_STRING", param_string },
- { "PARAM_STRING_NOESCAPE", param_string_noescape },
- { "PARAM_OPTIONAL_FILENAME", param_optional_filename },
- { "PARAM_FILENAME", param_filename },
- { "PARAM_ZINTEGER", param_zinteger },
- { "PARAM_ZUINTEGER", param_zuinteger },
- { "PARAM_ZUINTEGER_UNLIMITED", param_zuinteger_unlimited },
- { "PARAM_ENUM", param_enum },
- { NULL, 0 }
-};
+} parm_constants[]
+ = { { "PARAM_BOOLEAN", param_boolean }, /* ARI: param_boolean */
+ { "PARAM_AUTO_BOOLEAN", param_auto_boolean },
+ { "PARAM_UINTEGER", param_uinteger },
+ { "PARAM_INTEGER", param_integer },
+ { "PARAM_STRING", param_string },
+ { "PARAM_STRING_NOESCAPE", param_string_noescape },
+ { "PARAM_OPTIONAL_FILENAME", param_optional_filename },
+ { "PARAM_FILENAME", param_filename },
+ { "PARAM_ZINTEGER", param_zinteger },
+ { "PARAM_ZUINTEGER", param_zuinteger },
+ { "PARAM_ZUINTEGER_UNLIMITED", param_zuinteger_unlimited },
+ { "PARAM_ENUM", param_enum },
+ { NULL, 0 } };
/* A union that can hold anything described by enum var_types. */
union parmpy_variable
@@ -123,8 +116,8 @@ struct parmpy_object
{
PyObject_HEAD
- /* The type of the parameter. */
- enum var_types type;
+ /* The type of the parameter. */
+ enum var_types type;
/* Extra literals, such as `unlimited', accepted in lieu of a number. */
const literal_def *extra_literals;
@@ -163,21 +156,19 @@ make_setting (parmpy_object *s)
gdb_assert_not_reached ("unhandled var type");
}
-extern PyTypeObject parmpy_object_type
- CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("parmpy_object");
+extern PyTypeObject
+ parmpy_object_type CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("parmpy_object");
/* Some handy string constants. */
static PyObject *set_doc_cst;
static PyObject *show_doc_cst;
-
-
/* Get an attribute. */
static PyObject *
get_attr (PyObject *obj, PyObject *attr_name)
{
if (PyUnicode_Check (attr_name)
- && ! PyUnicode_CompareWithASCIIString (attr_name, "value"))
+ && !PyUnicode_CompareWithASCIIString (attr_name, "value"))
{
parmpy_object *self = (parmpy_object *) obj;
@@ -200,12 +191,11 @@ set_parameter_value (parmpy_object *self, PyObject *value)
case var_string_noescape:
case var_optional_filename:
case var_filename:
- if (! gdbpy_is_string (value)
- && (self->type == var_filename
- || value != Py_None))
+ if (!gdbpy_is_string (value)
+ && (self->type == var_filename || value != Py_None))
{
PyErr_SetString (PyExc_RuntimeError,
- _("String required for filename."));
+ _ ("String required for filename."));
return -1;
}
@@ -213,8 +203,8 @@ set_parameter_value (parmpy_object *self, PyObject *value)
self->value.stringval->clear ();
else
{
- gdb::unique_xmalloc_ptr<char>
- string (python_string_to_host_string (value));
+ gdb::unique_xmalloc_ptr<char> string (
+ python_string_to_host_string (value));
if (string == NULL)
return -1;
@@ -226,24 +216,25 @@ set_parameter_value (parmpy_object *self, PyObject *value)
{
int i;
- if (! gdbpy_is_string (value))
+ if (!gdbpy_is_string (value))
{
PyErr_SetString (PyExc_RuntimeError,
- _("ENUM arguments must be a string."));
+ _ ("ENUM arguments must be a string."));
return -1;
}
- gdb::unique_xmalloc_ptr<char>
- str (python_string_to_host_string (value));
+ gdb::unique_xmalloc_ptr<char> str (
+ python_string_to_host_string (value));
if (str == NULL)
return -1;
for (i = 0; self->enumeration[i]; ++i)
- if (! strcmp (self->enumeration[i], str.get ()))
+ if (!strcmp (self->enumeration[i], str.get ()))
break;
- if (! self->enumeration[i])
+ if (!self->enumeration[i])
{
- PyErr_SetString (PyExc_RuntimeError,
- _("The value must be member of an enumeration."));
+ PyErr_SetString (
+ PyExc_RuntimeError,
+ _ ("The value must be member of an enumeration."));
return -1;
}
self->value.cstringval = self->enumeration[i];
@@ -251,23 +242,23 @@ set_parameter_value (parmpy_object *self, PyObject *value)
}
case var_boolean:
- if (! PyBool_Check (value))
+ if (!PyBool_Check (value))
{
PyErr_SetString (PyExc_RuntimeError,
- _("A boolean argument is required."));
+ _ ("A boolean argument is required."));
return -1;
}
cmp = PyObject_IsTrue (value);
if (cmp < 0)
- return -1;
+ return -1;
self->value.boolval = cmp;
break;
case var_auto_boolean:
- if (! PyBool_Check (value) && value != Py_None)
+ if (!PyBool_Check (value) && value != Py_None)
{
PyErr_SetString (PyExc_RuntimeError,
- _("A boolean or None is required"));
+ _ ("A boolean or None is required"));
return -1;
}
@@ -276,8 +267,8 @@ set_parameter_value (parmpy_object *self, PyObject *value)
else
{
cmp = PyObject_IsTrue (value);
- if (cmp < 0 )
- return -1;
+ if (cmp < 0)
+ return -1;
if (cmp == 1)
self->value.autoboolval = AUTO_BOOLEAN_TRUE;
else
@@ -298,13 +289,12 @@ set_parameter_value (parmpy_object *self, PyObject *value)
if (extra_literals != nullptr)
{
- gdb::unique_xmalloc_ptr<char>
- str (python_string_to_host_string (value));
+ gdb::unique_xmalloc_ptr<char> str (
+ python_string_to_host_string (value));
const char *s = str != nullptr ? str.get () : nullptr;
PyErr_Clear ();
- for (const literal_def *l = extra_literals;
- l->literal != nullptr;
+ for (const literal_def *l = extra_literals; l->literal != nullptr;
l++, count++)
{
if (count != 0)
@@ -328,23 +318,23 @@ set_parameter_value (parmpy_object *self, PyObject *value)
{
if (extra_literals == nullptr)
PyErr_SetString (PyExc_RuntimeError,
- _("The value must be integer."));
+ _ ("The value must be integer."));
else if (count > 1)
PyErr_SetString (PyExc_RuntimeError,
- string_printf (_("integer or one of: %s"),
- buffer.c_str ()).c_str ());
+ string_printf (_ ("integer or one of: %s"),
+ buffer.c_str ())
+ .c_str ());
else
PyErr_SetString (PyExc_RuntimeError,
- string_printf (_("integer or %s"),
- buffer.c_str ()).c_str ());
+ string_printf (_ ("integer or %s"),
+ buffer.c_str ())
+ .c_str ());
return -1;
}
-
if (extra_literals != nullptr)
for (const literal_def *l = extra_literals;
- l->literal != nullptr;
- l++)
+ l->literal != nullptr; l++)
{
if (l->val.has_value () && val == *l->val)
{
@@ -355,7 +345,7 @@ set_parameter_value (parmpy_object *self, PyObject *value)
else if (val == l->use)
allowed = TRIBOOL_FALSE;
}
- }
+ }
if (allowed == TRIBOOL_UNKNOWN)
{
@@ -368,8 +358,7 @@ set_parameter_value (parmpy_object *self, PyObject *value)
}
if (allowed == TRIBOOL_FALSE)
{
- PyErr_SetString (PyExc_RuntimeError,
- _("Range exceeded."));
+ PyErr_SetString (PyExc_RuntimeError, _ ("Range exceeded."));
return -1;
}
@@ -382,7 +371,7 @@ set_parameter_value (parmpy_object *self, PyObject *value)
default:
PyErr_SetString (PyExc_RuntimeError,
- _("Unhandled type in parameter value."));
+ _ ("Unhandled type in parameter value."));
return -1;
}
@@ -394,12 +383,12 @@ static int
set_attr (PyObject *obj, PyObject *attr_name, PyObject *val)
{
if (PyUnicode_Check (attr_name)
- && ! PyUnicode_CompareWithASCIIString (attr_name, "value"))
+ && !PyUnicode_CompareWithASCIIString (attr_name, "value"))
{
if (!val)
{
PyErr_SetString (PyExc_RuntimeError,
- _("Cannot delete a parameter's value."));
+ _ ("Cannot delete a parameter's value."));
return -1;
}
return set_parameter_value ((parmpy_object *) obj, val);
@@ -419,8 +408,7 @@ set_attr (PyObject *obj, PyObject *attr_name, PyObject *val)
static std::string
full_cmd_name_without_first_prefix (struct cmd_list_element *c)
{
- std::vector<std::string> components
- = c->command_components ();
+ std::vector<std::string> components = c->command_components ();
gdb_assert (components.size () > 1);
std::string result = components[1];
for (int i = 2; i < components.size (); ++i)
@@ -478,15 +466,15 @@ get_doc_string (PyObject *object, enum doc_string_type doc_type,
if (result == nullptr)
{
if (doc_type == doc_string_description)
- result.reset (xstrdup (_("This command is not documented.")));
+ result.reset (xstrdup (_ ("This command is not documented.")));
else
{
if (doc_type == doc_string_show)
- result = xstrprintf (_("Show the current value of '%s'."),
- cmd_name);
+ result
+ = xstrprintf (_ ("Show the current value of '%s'."), cmd_name);
else
- result = xstrprintf (_("Set the current value of '%s'."),
- cmd_name);
+ result
+ = xstrprintf (_ ("Set the current value of '%s'."), cmd_name);
}
}
return result;
@@ -508,13 +496,13 @@ call_doc_function (PyObject *obj, PyObject *method, PyObject *arg)
if (gdbpy_is_string (result.get ()))
{
data = python_string_to_host_string (result.get ());
- if (! data)
+ if (!data)
return NULL;
}
else
{
PyErr_SetString (PyExc_RuntimeError,
- _("Parameter must return a string value."));
+ _ ("Parameter must return a string value."));
return NULL;
}
@@ -527,8 +515,7 @@ call_doc_function (PyObject *obj, PyObject *method, PyObject *arg)
is then printed. If "get_set_string" does not exist, or returns an
empty string, then nothing is printed. */
static void
-get_set_value (const char *args, int from_tty,
- struct cmd_list_element *c)
+get_set_value (const char *args, int from_tty, struct cmd_list_element *c)
{
PyObject *obj = (PyObject *) c->context ();
gdb::unique_xmalloc_ptr<char> set_doc_string;
@@ -545,7 +532,7 @@ get_set_value (const char *args, int from_tty,
if (PyObject_HasAttr (obj, set_doc_func.get ()))
{
set_doc_string = call_doc_function (obj, set_doc_func.get (), NULL);
- if (! set_doc_string)
+ if (!set_doc_string)
gdbpy_handle_exception ();
}
@@ -561,8 +548,7 @@ get_set_value (const char *args, int from_tty,
neither exist, insert a string indicating the Parameter is not
documented. */
static void
-get_show_value (struct ui_file *file, int from_tty,
- struct cmd_list_element *c,
+get_show_value (struct ui_file *file, int from_tty, struct cmd_list_element *c,
const char *value)
{
PyObject *obj = (PyObject *) c->context ();
@@ -587,9 +573,9 @@ get_show_value (struct ui_file *file, int from_tty,
return;
}
- show_doc_string = call_doc_function (obj, show_doc_func.get (),
- val_obj.get ());
- if (! show_doc_string)
+ show_doc_string
+ = call_doc_function (obj, show_doc_func.get (), val_obj.get ());
+ if (!show_doc_string)
{
gdbpy_print_stack ();
return;
@@ -606,11 +592,10 @@ get_show_value (struct ui_file *file, int from_tty,
show_doc adjustment is not i18n friendly, so, instead, we just
print this generic string. */
std::string cmd_path = full_cmd_name_without_first_prefix (c);
- gdb_printf (file, _("The current value of '%s' is \"%s\".\n"),
+ gdb_printf (file, _ ("The current value of '%s' is \"%s\".\n"),
cmd_path.c_str (), value);
}
}
-
/* A helper function that dispatches to the appropriate add_setshow
function. */
@@ -618,9 +603,8 @@ static void
add_setshow_generic (enum var_types type, const literal_def *extra_literals,
enum command_class cmdclass,
gdb::unique_xmalloc_ptr<char> cmd_name,
- parmpy_object *self,
- const char *set_doc, const char *show_doc,
- const char *help_doc,
+ parmpy_object *self, const char *set_doc,
+ const char *show_doc, const char *help_doc,
struct cmd_list_element **set_list,
struct cmd_list_element **show_list)
{
@@ -637,35 +621,35 @@ add_setshow_generic (enum var_types type, const literal_def *extra_literals,
break;
case var_auto_boolean:
- commands = add_setshow_auto_boolean_cmd (cmd_name.get (), cmdclass,
- &self->value.autoboolval,
- set_doc, show_doc, help_doc,
- get_set_value, get_show_value,
- set_list, show_list);
+ commands
+ = add_setshow_auto_boolean_cmd (cmd_name.get (), cmdclass,
+ &self->value.autoboolval, set_doc,
+ show_doc, help_doc, get_set_value,
+ get_show_value, set_list, show_list);
break;
case var_uinteger:
- commands = add_setshow_uinteger_cmd (cmd_name.get (), cmdclass,
- &self->value.uintval,
- extra_literals, set_doc,
- show_doc, help_doc, get_set_value,
- get_show_value, set_list, show_list);
+ commands
+ = add_setshow_uinteger_cmd (cmd_name.get (), cmdclass,
+ &self->value.uintval, extra_literals,
+ set_doc, show_doc, help_doc, get_set_value,
+ get_show_value, set_list, show_list);
break;
case var_integer:
- commands = add_setshow_integer_cmd (cmd_name.get (), cmdclass,
- &self->value.intval,
- extra_literals, set_doc,
- show_doc, help_doc, get_set_value,
- get_show_value, set_list, show_list);
+ commands
+ = add_setshow_integer_cmd (cmd_name.get (), cmdclass,
+ &self->value.intval, extra_literals,
+ set_doc, show_doc, help_doc, get_set_value,
+ get_show_value, set_list, show_list);
break;
case var_pinteger:
- commands = add_setshow_pinteger_cmd (cmd_name.get (), cmdclass,
- &self->value.intval,
- extra_literals, set_doc,
- show_doc, help_doc, get_set_value,
- get_show_value, set_list, show_list);
+ commands
+ = add_setshow_pinteger_cmd (cmd_name.get (), cmdclass,
+ &self->value.intval, extra_literals,
+ set_doc, show_doc, help_doc, get_set_value,
+ get_show_value, set_list, show_list);
break;
case var_string:
@@ -676,37 +660,33 @@ add_setshow_generic (enum var_types type, const literal_def *extra_literals,
break;
case var_string_noescape:
- commands = add_setshow_string_noescape_cmd (cmd_name.get (), cmdclass,
- self->value.stringval,
- set_doc, show_doc, help_doc,
- get_set_value, get_show_value,
- set_list, show_list);
+ commands = add_setshow_string_noescape_cmd (
+ cmd_name.get (), cmdclass, self->value.stringval, set_doc, show_doc,
+ help_doc, get_set_value, get_show_value, set_list, show_list);
break;
case var_optional_filename:
- commands = add_setshow_optional_filename_cmd (cmd_name.get (), cmdclass,
- self->value.stringval,
- set_doc, show_doc, help_doc,
- get_set_value,
- get_show_value, set_list,
- show_list);
+ commands = add_setshow_optional_filename_cmd (
+ cmd_name.get (), cmdclass, self->value.stringval, set_doc, show_doc,
+ help_doc, get_set_value, get_show_value, set_list, show_list);
break;
case var_filename:
- commands = add_setshow_filename_cmd (cmd_name.get (), cmdclass,
- self->value.stringval, set_doc,
- show_doc, help_doc, get_set_value,
- get_show_value, set_list, show_list);
+ commands
+ = add_setshow_filename_cmd (cmd_name.get (), cmdclass,
+ self->value.stringval, set_doc, show_doc,
+ help_doc, get_set_value, get_show_value,
+ set_list, show_list);
break;
case var_enum:
/* Initialize the value, just in case. */
self->value.cstringval = self->enumeration[0];
- commands = add_setshow_enum_cmd (cmd_name.get (), cmdclass,
- self->enumeration,
- &self->value.cstringval, set_doc,
- show_doc, help_doc, get_set_value,
- get_show_value, set_list, show_list);
+ commands
+ = add_setshow_enum_cmd (cmd_name.get (), cmdclass, self->enumeration,
+ &self->value.cstringval, set_doc, show_doc,
+ help_doc, get_set_value, get_show_value,
+ set_list, show_list);
break;
default:
@@ -728,17 +708,17 @@ compute_enum_values (parmpy_object *self, PyObject *enum_values)
{
Py_ssize_t size, i;
- if (! enum_values)
+ if (!enum_values)
{
PyErr_SetString (PyExc_RuntimeError,
- _("An enumeration is required for PARAM_ENUM."));
+ _ ("An enumeration is required for PARAM_ENUM."));
return 0;
}
- if (! PySequence_Check (enum_values))
+ if (!PySequence_Check (enum_values))
{
PyErr_SetString (PyExc_RuntimeError,
- _("The enumeration is not a sequence."));
+ _ ("The enumeration is not a sequence."));
return 0;
}
@@ -747,8 +727,7 @@ compute_enum_values (parmpy_object *self, PyObject *enum_values)
return 0;
if (size == 0)
{
- PyErr_SetString (PyExc_RuntimeError,
- _("The enumeration is empty."));
+ PyErr_SetString (PyExc_RuntimeError, _ ("The enumeration is empty."));
return 0;
}
@@ -761,10 +740,10 @@ compute_enum_values (parmpy_object *self, PyObject *enum_values)
if (item == NULL)
return 0;
- if (! gdbpy_is_string (item.get ()))
+ if (!gdbpy_is_string (item.get ()))
{
PyErr_SetString (PyExc_RuntimeError,
- _("The enumeration item not a string."));
+ _ ("The enumeration item not a string."));
return 0;
}
enumeration[i] = python_string_to_host_string (item.get ()).release ();
@@ -772,7 +751,7 @@ compute_enum_values (parmpy_object *self, PyObject *enum_values)
return 0;
}
- self->enumeration = const_cast<const char**> (holder.release ());
+ self->enumeration = const_cast<const char **> (holder.release ());
return 1;
}
@@ -811,43 +790,42 @@ parmpy_init (PyObject *self, PyObject *args, PyObject *kwds)
const literal_def *extra_literals;
enum var_types type;
- if (! PyArg_ParseTuple (args, "sii|O", &name, &cmdtype, &parmclass,
- &enum_values))
+ if (!PyArg_ParseTuple (args, "sii|O", &name, &cmdtype, &parmclass,
+ &enum_values))
return -1;
- if (cmdtype != no_class && cmdtype != class_run
- && cmdtype != class_vars && cmdtype != class_stack
- && cmdtype != class_files && cmdtype != class_support
- && cmdtype != class_info && cmdtype != class_breakpoint
- && cmdtype != class_trace && cmdtype != class_obscure
- && cmdtype != class_maintenance)
+ if (cmdtype != no_class && cmdtype != class_run && cmdtype != class_vars
+ && cmdtype != class_stack && cmdtype != class_files
+ && cmdtype != class_support && cmdtype != class_info
+ && cmdtype != class_breakpoint && cmdtype != class_trace
+ && cmdtype != class_obscure && cmdtype != class_maintenance)
{
- PyErr_Format (PyExc_RuntimeError, _("Invalid command class argument."));
+ PyErr_Format (PyExc_RuntimeError, _ ("Invalid command class argument."));
return -1;
}
if (parmclass != param_boolean /* ARI: param_boolean */
- && parmclass != param_auto_boolean
- && parmclass != param_uinteger && parmclass != param_integer
- && parmclass != param_string && parmclass != param_string_noescape
+ && parmclass != param_auto_boolean && parmclass != param_uinteger
+ && parmclass != param_integer && parmclass != param_string
+ && parmclass != param_string_noescape
&& parmclass != param_optional_filename && parmclass != param_filename
&& parmclass != param_zinteger && parmclass != param_zuinteger
&& parmclass != param_zuinteger_unlimited && parmclass != param_enum)
{
PyErr_SetString (PyExc_RuntimeError,
- _("Invalid parameter class argument."));
+ _ ("Invalid parameter class argument."));
return -1;
}
if (enum_values && parmclass != param_enum)
{
PyErr_SetString (PyExc_RuntimeError,
- _("Only PARAM_ENUM accepts a fourth argument."));
+ _ ("Only PARAM_ENUM accepts a fourth argument."));
return -1;
}
if (parmclass == param_enum)
{
- if (! compute_enum_values (obj, enum_values))
+ if (!compute_enum_values (obj, enum_values))
return -1;
}
else
@@ -878,11 +856,9 @@ parmpy_init (PyObject *self, PyObject *args, PyObject *kwds)
try
{
- add_setshow_generic (type, extra_literals,
- (enum command_class) cmdtype,
- std::move (cmd_name), obj,
- set_doc.get (), show_doc.get (),
- doc.get (), set_list, show_list);
+ add_setshow_generic (type, extra_literals, (enum command_class) cmdtype,
+ std::move (cmd_name), obj, set_doc.get (),
+ show_doc.get (), doc.get (), set_list, show_list);
}
catch (const gdb_exception &except)
{
@@ -916,17 +892,17 @@ gdbpy_initialize_parameters (void)
return -1;
set_doc_cst = PyUnicode_FromString ("set_doc");
- if (! set_doc_cst)
+ if (!set_doc_cst)
return -1;
show_doc_cst = PyUnicode_FromString ("show_doc");
- if (! show_doc_cst)
+ if (!show_doc_cst)
return -1;
for (i = 0; parm_constants[i].name; ++i)
{
- if (PyModule_AddIntConstant (gdb_module,
- parm_constants[i].name,
- parm_constants[i].value) < 0)
+ if (PyModule_AddIntConstant (gdb_module, parm_constants[i].name,
+ parm_constants[i].value)
+ < 0)
return -1;
}
@@ -934,45 +910,41 @@ gdbpy_initialize_parameters (void)
(PyObject *) &parmpy_object_type);
}
-
-
-PyTypeObject parmpy_object_type =
-{
- PyVarObject_HEAD_INIT (NULL, 0)
- "gdb.Parameter", /*tp_name*/
- sizeof (parmpy_object), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- parmpy_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
- 0, /*tp_call*/
- 0, /*tp_str*/
- get_attr, /*tp_getattro*/
- set_attr, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
- "GDB parameter object", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- parmpy_init, /* tp_init */
- 0, /* tp_alloc */
+PyTypeObject parmpy_object_type = {
+ PyVarObject_HEAD_INIT (NULL, 0) "gdb.Parameter", /*tp_name*/
+ sizeof (parmpy_object), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ parmpy_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ get_attr, /*tp_getattro*/
+ set_attr, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
+ "GDB parameter object", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ 0, /* tp_methods */
+ 0, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ parmpy_init, /* tp_init */
+ 0, /* tp_alloc */
};
diff --git a/gdb/python/py-prettyprint.c b/gdb/python/py-prettyprint.c
index 1a5ce08..c369b97 100644
--- a/gdb/python/py-prettyprint.c
+++ b/gdb/python/py-prettyprint.c
@@ -30,14 +30,14 @@
/* Return type of print_string_repr. */
enum gdbpy_string_repr_result
- {
- /* The string method returned None. */
- string_repr_none,
- /* The string method had an error. */
- string_repr_error,
- /* Everything ok. */
- string_repr_ok
- };
+{
+ /* The string method returned None. */
+ string_repr_none,
+ /* The string method had an error. */
+ string_repr_error,
+ /* Everything ok. */
+ string_repr_ok
+};
/* If non-null, points to options that are in effect while
printing. */
@@ -58,7 +58,7 @@ search_pp_list (PyObject *list, PyObject *value)
for (list_index = 0; list_index < pp_list_size; list_index++)
{
PyObject *function = PyList_GetItem (list, list_index);
- if (! function)
+ if (!function)
return NULL;
/* Skip if disabled. */
@@ -149,11 +149,11 @@ find_pretty_printer_from_gdb (PyObject *value)
{
/* Fetch the global pretty printer list. */
if (gdb_python_module == NULL
- || ! PyObject_HasAttrString (gdb_python_module, "pretty_printers"))
+ || !PyObject_HasAttrString (gdb_python_module, "pretty_printers"))
return gdbpy_ref<>::new_reference (Py_None);
gdbpy_ref<> pp_list (PyObject_GetAttrString (gdb_python_module,
"pretty_printers"));
- if (pp_list == NULL || ! PyList_Check (pp_list.get ()))
+ if (pp_list == NULL || !PyList_Check (pp_list.get ()))
return gdbpy_ref<>::new_reference (Py_None);
return search_pp_list (pp_list.get (), value);
@@ -201,12 +201,13 @@ pretty_print_one_value (PyObject *printer, struct value **out_value)
result = gdbpy_ref<>::new_reference (Py_None);
else
{
- result.reset (PyObject_CallMethodObjArgs (printer, gdbpy_to_string_cst,
+ result.reset (PyObject_CallMethodObjArgs (printer,
+ gdbpy_to_string_cst,
NULL));
if (result != NULL)
{
- if (! gdbpy_is_string (result.get ())
- && ! gdbpy_is_lazy_string (result.get ())
+ if (!gdbpy_is_string (result.get ())
+ && !gdbpy_is_lazy_string (result.get ())
&& result != Py_None)
{
*out_value = convert_value_from_python (result.get ());
@@ -233,11 +234,11 @@ gdbpy_get_display_hint (PyObject *printer)
{
gdb::unique_xmalloc_ptr<char> result;
- if (! PyObject_HasAttr (printer, gdbpy_display_hint_cst))
+ if (!PyObject_HasAttr (printer, gdbpy_display_hint_cst))
return NULL;
- gdbpy_ref<> hint (PyObject_CallMethodObjArgs (printer, gdbpy_display_hint_cst,
- NULL));
+ gdbpy_ref<> hint (PyObject_CallMethodObjArgs (printer,
+ gdbpy_display_hint_cst, NULL));
if (hint != NULL)
{
if (gdbpy_is_string (hint.get ()))
@@ -265,10 +266,10 @@ print_stack_unless_memory_error (struct ui_file *stream)
if (msg == NULL || *msg == '\0')
fprintf_styled (stream, metadata_style.style (),
- _("<error reading variable>"));
+ _ ("<error reading variable>"));
else
fprintf_styled (stream, metadata_style.style (),
- _("<error reading variable: %s>"), msg.get ());
+ _ ("<error reading variable: %s>"), msg.get ());
}
else
gdbpy_print_stack ();
@@ -278,9 +279,8 @@ print_stack_unless_memory_error (struct ui_file *stream)
formats the result. */
static enum gdbpy_string_repr_result
-print_string_repr (PyObject *printer, const char *hint,
- struct ui_file *stream, int recurse,
- const struct value_print_options *options,
+print_string_repr (PyObject *printer, const char *hint, struct ui_file *stream,
+ int recurse, const struct value_print_options *options,
const struct language_defn *language,
struct gdbarch *gdbarch)
{
@@ -300,12 +300,12 @@ print_string_repr (PyObject *printer, const char *hint,
gdb::unique_xmalloc_ptr<char> encoding;
struct value_print_options local_opts = *options;
- gdbpy_extract_lazy_string (py_str.get (), &addr, &type,
- &length, &encoding);
+ gdbpy_extract_lazy_string (py_str.get (), &addr, &type, &length,
+ &encoding);
local_opts.addressprint = false;
- val_print_string (type, encoding.get (), addr, (int) length,
- stream, &local_opts);
+ val_print_string (type, encoding.get (), addr, (int) length, stream,
+ &local_opts);
}
else
{
@@ -322,8 +322,8 @@ print_string_repr (PyObject *printer, const char *hint,
type = builtin_type (gdbarch)->builtin_char;
if (hint && !strcmp (hint, "string"))
- language->printstr (stream, type, (gdb_byte *) output,
- length, NULL, 0, options);
+ language->printstr (stream, type, (gdb_byte *) output, length,
+ NULL, 0, options);
else
gdb_puts (output, stream);
}
@@ -354,25 +354,23 @@ print_string_repr (PyObject *printer, const char *hint,
printer, if any exist. If is_py_none is true, then nothing has
been printed by to_string, and format output accordingly. */
static void
-print_children (PyObject *printer, const char *hint,
- struct ui_file *stream, int recurse,
- const struct value_print_options *options,
- const struct language_defn *language,
- int is_py_none)
+print_children (PyObject *printer, const char *hint, struct ui_file *stream,
+ int recurse, const struct value_print_options *options,
+ const struct language_defn *language, int is_py_none)
{
int is_map, is_array, done_flag, pretty;
unsigned int i;
- if (! PyObject_HasAttr (printer, gdbpy_children_cst))
+ if (!PyObject_HasAttr (printer, gdbpy_children_cst))
return;
/* If we are printing a map or an array, we want some special
formatting. */
- is_map = hint && ! strcmp (hint, "map");
- is_array = hint && ! strcmp (hint, "array");
+ is_map = hint && !strcmp (hint, "map");
+ is_array = hint && !strcmp (hint, "array");
- gdbpy_ref<> children (PyObject_CallMethodObjArgs (printer, gdbpy_children_cst,
- NULL));
+ gdbpy_ref<> children (PyObject_CallMethodObjArgs (printer,
+ gdbpy_children_cst, NULL));
if (children == NULL)
{
print_stack_unless_memory_error (stream);
@@ -411,26 +409,26 @@ print_children (PyObject *printer, const char *hint,
print_stack_unless_memory_error (stream);
/* Set a flag so we can know whether we printed all the
available elements. */
- else
+ else
done_flag = 1;
break;
}
- if (! PyTuple_Check (item.get ()) || PyTuple_Size (item.get ()) != 2)
+ if (!PyTuple_Check (item.get ()) || PyTuple_Size (item.get ()) != 2)
{
PyErr_SetString (PyExc_TypeError,
- _("Result of children iterator not a tuple"
- " of two elements."));
+ _ ("Result of children iterator not a tuple"
+ " of two elements."));
gdbpy_print_stack ();
continue;
}
- if (! PyArg_ParseTuple (item.get (), "sO", &name, &py_v))
+ if (!PyArg_ParseTuple (item.get (), "sO", &name, &py_v))
{
/* The user won't necessarily get a stack trace here, so provide
more context. */
if (gdbpy_print_python_errors_p ())
gdb_printf (gdb_stderr,
- _("Bad result from children iterator.\n"));
+ _ ("Bad result from children iterator.\n"));
gdbpy_print_stack ();
continue;
}
@@ -445,7 +443,7 @@ print_children (PyObject *printer, const char *hint,
if (!is_py_none)
gdb_puts (" = ", stream);
}
- else if (! is_map || i % 2 == 0)
+ else if (!is_map || i % 2 == 0)
gdb_puts (pretty ? "," : ", ", stream);
/* Skip printing children if max_depth has been reached. This check
@@ -470,7 +468,7 @@ print_children (PyObject *printer, const char *hint,
break;
}
- if (! is_map || i % 2 == 0)
+ if (!is_map || i % 2 == 0)
{
if (pretty)
{
@@ -478,7 +476,7 @@ print_children (PyObject *printer, const char *hint,
print_spaces (2 + 2 * recurse, stream);
}
else
- stream->wrap_here (2 + 2 *recurse);
+ stream->wrap_here (2 + 2 * recurse);
}
if (is_map && i % 2 == 0)
@@ -490,7 +488,7 @@ print_children (PyObject *printer, const char *hint,
if (options->print_array_indexes)
gdb_printf (stream, "[%d] = ", i);
}
- else if (! is_map)
+ else if (!is_map)
{
gdb_puts (name, stream);
gdb_puts (" = ", stream);
@@ -527,7 +525,7 @@ print_children (PyObject *printer, const char *hint,
if (value == NULL)
{
gdbpy_print_stack ();
- error (_("Error while executing Python code."));
+ error (_ ("Error while executing Python code."));
}
else
{
@@ -535,8 +533,7 @@ print_children (PyObject *printer, const char *hint,
level of depth. This means the key will print before the
value does. */
struct value_print_options opt = *options;
- if (is_map && i % 2 == 0
- && opt.max_depth != -1
+ if (is_map && i % 2 == 0 && opt.max_depth != -1
&& opt.max_depth < INT_MAX)
++opt.max_depth;
common_val_print (value, stream, recurse + 1, &opt, language);
@@ -569,8 +566,8 @@ print_children (PyObject *printer, const char *hint,
enum ext_lang_rc
gdbpy_apply_val_pretty_printer (const struct extension_language_defn *extlang,
- struct value *value,
- struct ui_file *stream, int recurse,
+ struct value *value, struct ui_file *stream,
+ int recurse,
const struct value_print_options *options,
const struct language_defn *language)
{
@@ -608,8 +605,8 @@ gdbpy_apply_val_pretty_printer (const struct extension_language_defn *extlang,
if (printer == Py_None)
return EXT_LANG_RC_NOP;
- scoped_restore set_options = make_scoped_restore (&gdbpy_current_print_options,
- options);
+ scoped_restore set_options
+ = make_scoped_restore (&gdbpy_current_print_options, options);
/* If we are printing a map, we want some special formatting. */
gdb::unique_xmalloc_ptr<char> hint (gdbpy_get_display_hint (printer.get ()));
@@ -626,7 +623,6 @@ gdbpy_apply_val_pretty_printer (const struct extension_language_defn *extlang,
return EXT_LANG_RC_OK;
}
-
/* Apply a pretty-printer for the varobj code. PRINTER_OBJ is the
print object. It must have a 'to_string' method (but this is
checked by varobj, not here) which takes no arguments and
@@ -637,13 +633,12 @@ gdbpy_apply_val_pretty_printer (const struct extension_language_defn *extlang,
error, *REPLACEMENT is set to NULL and this function also returns
NULL. */
gdbpy_ref<>
-apply_varobj_pretty_printer (PyObject *printer_obj,
- struct value **replacement,
+apply_varobj_pretty_printer (PyObject *printer_obj, struct value **replacement,
struct ui_file *stream,
const value_print_options *opts)
{
- scoped_restore set_options = make_scoped_restore (&gdbpy_current_print_options,
- opts);
+ scoped_restore set_options
+ = make_scoped_restore (&gdbpy_current_print_options, opts);
*replacement = NULL;
gdbpy_ref<> py_str = pretty_print_one_value (printer_obj, replacement);
@@ -687,13 +682,12 @@ gdbpy_default_visualizer (PyObject *self, PyObject *args)
PyObject *val_obj;
struct value *value;
- if (! PyArg_ParseTuple (args, "O", &val_obj))
+ if (!PyArg_ParseTuple (args, "O", &val_obj))
return NULL;
value = value_object_to_value (val_obj);
- if (! value)
+ if (!value)
{
- PyErr_SetString (PyExc_TypeError,
- _("Argument must be a gdb.Value."));
+ PyErr_SetString (PyExc_TypeError, _ ("Argument must be a gdb.Value."));
return NULL;
}
@@ -731,38 +725,29 @@ gdbpy_print_options (PyObject *unused1, PyObject *unused2)
value_print_options opts;
gdbpy_get_print_options (&opts);
- if (set_boolean (result.get (), "raw",
- opts.raw) < 0
- || set_boolean (result.get (), "pretty_arrays",
- opts.prettyformat_arrays) < 0
+ if (set_boolean (result.get (), "raw", opts.raw) < 0
+ || set_boolean (result.get (), "pretty_arrays", opts.prettyformat_arrays)
+ < 0
|| set_boolean (result.get (), "pretty_structs",
- opts.prettyformat_structs) < 0
- || set_boolean (result.get (), "array_indexes",
- opts.print_array_indexes) < 0
- || set_boolean (result.get (), "symbols",
- opts.symbol_print) < 0
- || set_boolean (result.get (), "unions",
- opts.unionprint) < 0
- || set_boolean (result.get (), "address",
- opts.addressprint) < 0
- || set_boolean (result.get (), "deref_refs",
- opts.deref_ref) < 0
- || set_boolean (result.get (), "actual_objects",
- opts.objectprint) < 0
- || set_boolean (result.get (), "static_members",
- opts.static_field_print) < 0
- || set_boolean (result.get (), "deref_refs",
- opts.deref_ref) < 0
- || set_boolean (result.get (), "nibbles",
- opts.nibblesprint) < 0
- || set_boolean (result.get (), "summary",
- opts.summary) < 0
- || set_unsigned (result.get (), "max_elements",
- opts.print_max) < 0
- || set_unsigned (result.get (), "max_depth",
- opts.max_depth) < 0
+ opts.prettyformat_structs)
+ < 0
+ || set_boolean (result.get (), "array_indexes", opts.print_array_indexes)
+ < 0
+ || set_boolean (result.get (), "symbols", opts.symbol_print) < 0
+ || set_boolean (result.get (), "unions", opts.unionprint) < 0
+ || set_boolean (result.get (), "address", opts.addressprint) < 0
+ || set_boolean (result.get (), "deref_refs", opts.deref_ref) < 0
+ || set_boolean (result.get (), "actual_objects", opts.objectprint) < 0
+ || set_boolean (result.get (), "static_members", opts.static_field_print)
+ < 0
+ || set_boolean (result.get (), "deref_refs", opts.deref_ref) < 0
+ || set_boolean (result.get (), "nibbles", opts.nibblesprint) < 0
+ || set_boolean (result.get (), "summary", opts.summary) < 0
+ || set_unsigned (result.get (), "max_elements", opts.print_max) < 0
+ || set_unsigned (result.get (), "max_depth", opts.max_depth) < 0
|| set_unsigned (result.get (), "repeat_threshold",
- opts.repeat_count_threshold) < 0)
+ opts.repeat_count_threshold)
+ < 0)
return nullptr;
if (opts.format != 0)
diff --git a/gdb/python/py-progspace.c b/gdb/python/py-progspace.c
index 571a104..4fa6ea3 100644
--- a/gdb/python/py-progspace.c
+++ b/gdb/python/py-progspace.c
@@ -31,8 +31,8 @@ struct pspace_object
{
PyObject_HEAD
- /* The corresponding pspace. */
- struct program_space *pspace;
+ /* The corresponding pspace. */
+ struct program_space *pspace;
/* Dictionary holding user-added attributes.
This is the __dict__ attribute of the object. */
@@ -54,8 +54,8 @@ struct pspace_object
PyObject *xmethods;
};
-extern PyTypeObject pspace_object_type
- CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("pspace_object");
+extern PyTypeObject
+ pspace_object_type CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("pspace_object");
/* Clear the PSPACE pointer in a Pspace object and remove the reference. */
struct pspace_deleter
@@ -80,18 +80,20 @@ struct pspace_deleter
};
static const registry<program_space>::key<pspace_object, pspace_deleter>
- pspy_pspace_data_key;
+ pspy_pspace_data_key;
/* Require that PSPACE_OBJ be a valid program space ID. */
-#define PSPY_REQUIRE_VALID(pspace_obj) \
- do { \
- if (pspace_obj->pspace == nullptr) \
- { \
- PyErr_SetString (PyExc_RuntimeError, \
- _("Program space no longer exists.")); \
- return NULL; \
- } \
- } while (0)
+#define PSPY_REQUIRE_VALID(pspace_obj) \
+ do \
+ { \
+ if (pspace_obj->pspace == nullptr) \
+ { \
+ PyErr_SetString (PyExc_RuntimeError, \
+ _ ("Program space no longer exists.")); \
+ return NULL; \
+ } \
+ } \
+ while (0)
/* An Objfile method which returns the objfile's file name, or None. */
@@ -105,8 +107,8 @@ pspy_get_filename (PyObject *self, void *closure)
struct objfile *objfile = obj->pspace->symfile_object_file;
if (objfile)
- return (host_string_to_python_string (objfile_name (objfile))
- .release ());
+ return (
+ host_string_to_python_string (objfile_name (objfile)).release ());
}
Py_RETURN_NONE;
}
@@ -188,14 +190,14 @@ pspy_set_printers (PyObject *o, PyObject *value, void *ignore)
{
pspace_object *self = (pspace_object *) o;
- if (! value)
+ if (!value)
{
PyErr_SetString (PyExc_TypeError,
"cannot delete the pretty_printers attribute");
return -1;
}
- if (! PyList_Check (value))
+ if (!PyList_Check (value))
{
PyErr_SetString (PyExc_TypeError,
"the pretty_printers attribute must be a list");
@@ -227,14 +229,14 @@ pspy_set_frame_filters (PyObject *o, PyObject *frame, void *ignore)
{
pspace_object *self = (pspace_object *) o;
- if (! frame)
+ if (!frame)
{
PyErr_SetString (PyExc_TypeError,
"cannot delete the frame filter attribute");
return -1;
}
- if (! PyDict_Check (frame))
+ if (!PyDict_Check (frame))
{
PyErr_SetString (PyExc_TypeError,
"the frame filter attribute must be a dictionary");
@@ -318,14 +320,14 @@ pspy_set_type_printers (PyObject *o, PyObject *value, void *ignore)
{
pspace_object *self = (pspace_object *) o;
- if (! value)
+ if (!value)
{
PyErr_SetString (PyExc_TypeError,
"cannot delete the type_printers attribute");
return -1;
}
- if (! PyList_Check (value))
+ if (!PyList_Check (value))
{
PyErr_SetString (PyExc_TypeError,
"the type_printers attribute must be a list");
@@ -484,8 +486,6 @@ pspy_is_valid (PyObject *o, PyObject *args)
Py_RETURN_TRUE;
}
-
-
/* Return a new reference to the Python object of type Pspace
representing PSPACE. If the object has already been created,
return it. Otherwise, create it. Return NULL and set the Python
@@ -497,8 +497,8 @@ pspace_to_pspace_object (struct program_space *pspace)
PyObject *result = (PyObject *) pspy_pspace_data_key.get (pspace);
if (result == NULL)
{
- gdbpy_ref<pspace_object> object
- ((pspace_object *) PyObject_New (pspace_object, &pspace_object_type));
+ gdbpy_ref<pspace_object> object (
+ (pspace_object *) PyObject_New (pspace_object, &pspace_object_type));
if (object == NULL)
return NULL;
if (!pspy_initialize (object.get ()))
@@ -539,83 +539,73 @@ gdbpy_initialize_pspace (void)
(PyObject *) &pspace_object_type);
}
-
-
-static gdb_PyGetSetDef pspace_getset[] =
-{
- { "__dict__", gdb_py_generic_dict, NULL,
- "The __dict__ for this progspace.", &pspace_object_type },
- { "filename", pspy_get_filename, NULL,
- "The progspace's main filename, or None.", NULL },
- { "pretty_printers", pspy_get_printers, pspy_set_printers,
- "Pretty printers.", NULL },
- { "frame_filters", pspy_get_frame_filters, pspy_set_frame_filters,
- "Frame filters.", NULL },
- { "frame_unwinders", pspy_get_frame_unwinders, pspy_set_frame_unwinders,
- "Frame unwinders.", NULL },
- { "type_printers", pspy_get_type_printers, pspy_set_type_printers,
- "Type printers.", NULL },
- { "xmethods", pspy_get_xmethods, NULL,
- "Debug methods.", NULL },
- { NULL }
-};
-
-static PyMethodDef progspace_object_methods[] =
-{
- { "objfiles", pspy_get_objfiles, METH_NOARGS,
- "Return a sequence of objfiles associated to this program space." },
- { "solib_name", pspy_solib_name, METH_VARARGS,
- "solib_name (Long) -> String.\n\
+static gdb_PyGetSetDef pspace_getset[]
+ = { { "__dict__", gdb_py_generic_dict, NULL,
+ "The __dict__ for this progspace.", &pspace_object_type },
+ { "filename", pspy_get_filename, NULL,
+ "The progspace's main filename, or None.", NULL },
+ { "pretty_printers", pspy_get_printers, pspy_set_printers,
+ "Pretty printers.", NULL },
+ { "frame_filters", pspy_get_frame_filters, pspy_set_frame_filters,
+ "Frame filters.", NULL },
+ { "frame_unwinders", pspy_get_frame_unwinders, pspy_set_frame_unwinders,
+ "Frame unwinders.", NULL },
+ { "type_printers", pspy_get_type_printers, pspy_set_type_printers,
+ "Type printers.", NULL },
+ { "xmethods", pspy_get_xmethods, NULL, "Debug methods.", NULL },
+ { NULL } };
+
+static PyMethodDef progspace_object_methods[]
+ = { { "objfiles", pspy_get_objfiles, METH_NOARGS,
+ "Return a sequence of objfiles associated to this program space." },
+ { "solib_name", pspy_solib_name, METH_VARARGS,
+ "solib_name (Long) -> String.\n\
Return the name of the shared library holding a given address, or None." },
- { "block_for_pc", pspy_block_for_pc, METH_VARARGS,
- "Return the block containing the given pc value, or None." },
- { "find_pc_line", pspy_find_pc_line, METH_VARARGS,
- "find_pc_line (pc) -> Symtab_and_line.\n\
+ { "block_for_pc", pspy_block_for_pc, METH_VARARGS,
+ "Return the block containing the given pc value, or None." },
+ { "find_pc_line", pspy_find_pc_line, METH_VARARGS,
+ "find_pc_line (pc) -> Symtab_and_line.\n\
Return the gdb.Symtab_and_line object corresponding to the pc value." },
- { "is_valid", pspy_is_valid, METH_NOARGS,
- "is_valid () -> Boolean.\n\
+ { "is_valid", pspy_is_valid, METH_NOARGS, "is_valid () -> Boolean.\n\
Return true if this program space is valid, false if not." },
- { NULL }
-};
-
-PyTypeObject pspace_object_type =
-{
- PyVarObject_HEAD_INIT (NULL, 0)
- "gdb.Progspace", /*tp_name*/
- sizeof (pspace_object), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- pspy_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- "GDB progspace object", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- progspace_object_methods, /* tp_methods */
- 0, /* tp_members */
- pspace_getset, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- offsetof (pspace_object, dict), /* tp_dictoffset */
- 0, /* tp_init */
- 0, /* tp_alloc */
- pspy_new, /* tp_new */
+ { NULL } };
+
+PyTypeObject pspace_object_type = {
+ PyVarObject_HEAD_INIT (NULL, 0) "gdb.Progspace", /*tp_name*/
+ sizeof (pspace_object), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ pspy_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT, /*tp_flags*/
+ "GDB progspace object", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ progspace_object_methods, /* tp_methods */
+ 0, /* tp_members */
+ pspace_getset, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ offsetof (pspace_object, dict), /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ pspy_new, /* tp_new */
};
diff --git a/gdb/python/py-record-btrace.c b/gdb/python/py-record-btrace.c
index 4af8667..37106cf 100644
--- a/gdb/python/py-record-btrace.c
+++ b/gdb/python/py-record-btrace.c
@@ -30,11 +30,12 @@
/* Python object for btrace record lists. */
-struct btpy_list_object {
+struct btpy_list_object
+{
PyObject_HEAD
- /* The thread this list belongs to. */
- thread_info *thread;
+ /* The thread this list belongs to. */
+ thread_info *thread;
/* The first index being part of this list. */
Py_ssize_t first;
@@ -46,20 +47,18 @@ struct btpy_list_object {
Py_ssize_t step;
/* Either &BTPY_CALL_TYPE or &RECPY_INSN_TYPE. */
- PyTypeObject* element_type;
+ PyTypeObject *element_type;
};
/* Python type for btrace lists. */
-static PyTypeObject btpy_list_type = {
- PyVarObject_HEAD_INIT (NULL, 0)
-};
+static PyTypeObject btpy_list_type = { PyVarObject_HEAD_INIT (NULL, 0) };
/* Returns either a btrace_insn for the given Python gdb.RecordInstruction
object or sets an appropriate Python exception and returns NULL. */
static const btrace_insn *
-btrace_insn_from_recpy_insn (const PyObject * const pyobject)
+btrace_insn_from_recpy_insn (const PyObject *const pyobject)
{
const btrace_insn *insn;
const recpy_element_object *obj;
@@ -68,7 +67,7 @@ btrace_insn_from_recpy_insn (const PyObject * const pyobject)
if (Py_TYPE (pyobject) != &recpy_insn_type)
{
- PyErr_Format (gdbpy_gdb_error, _("Must be gdb.RecordInstruction"));
+ PyErr_Format (gdbpy_gdb_error, _ ("Must be gdb.RecordInstruction"));
return NULL;
}
@@ -77,20 +76,20 @@ btrace_insn_from_recpy_insn (const PyObject * const pyobject)
if (tinfo == NULL || btrace_is_empty (tinfo))
{
- PyErr_Format (gdbpy_gdb_error, _("No such instruction."));
+ PyErr_Format (gdbpy_gdb_error, _ ("No such instruction."));
return NULL;
}
if (btrace_find_insn_by_number (&iter, &tinfo->btrace, obj->number) == 0)
{
- PyErr_Format (gdbpy_gdb_error, _("No such instruction."));
+ PyErr_Format (gdbpy_gdb_error, _ ("No such instruction."));
return NULL;
}
insn = btrace_insn_get (&iter);
if (insn == NULL)
{
- PyErr_Format (gdbpy_gdb_error, _("Not a valid instruction."));
+ PyErr_Format (gdbpy_gdb_error, _ ("Not a valid instruction."));
return NULL;
}
@@ -102,7 +101,7 @@ btrace_insn_from_recpy_insn (const PyObject * const pyobject)
returns NULL. */
static const btrace_function *
-btrace_func_from_recpy_func (const PyObject * const pyobject)
+btrace_func_from_recpy_func (const PyObject *const pyobject)
{
const btrace_function *func;
const recpy_element_object *obj;
@@ -111,7 +110,7 @@ btrace_func_from_recpy_func (const PyObject * const pyobject)
if (Py_TYPE (pyobject) != &recpy_func_type)
{
- PyErr_Format (gdbpy_gdb_error, _("Must be gdb.RecordFunctionSegment"));
+ PyErr_Format (gdbpy_gdb_error, _ ("Must be gdb.RecordFunctionSegment"));
return NULL;
}
@@ -120,20 +119,20 @@ btrace_func_from_recpy_func (const PyObject * const pyobject)
if (tinfo == NULL || btrace_is_empty (tinfo))
{
- PyErr_Format (gdbpy_gdb_error, _("No such function segment."));
+ PyErr_Format (gdbpy_gdb_error, _ ("No such function segment."));
return NULL;
}
if (btrace_find_call_by_number (&iter, &tinfo->btrace, obj->number) == 0)
{
- PyErr_Format (gdbpy_gdb_error, _("No such function segment."));
+ PyErr_Format (gdbpy_gdb_error, _ ("No such function segment."));
return NULL;
}
func = btrace_call_get (&iter);
if (func == NULL)
{
- PyErr_Format (gdbpy_gdb_error, _("Not a valid function segment."));
+ PyErr_Format (gdbpy_gdb_error, _ ("Not a valid function segment."));
return NULL;
}
@@ -169,11 +168,11 @@ btpy_insn_or_gap_new (thread_info *tinfo, Py_ssize_t number)
/* Create a new gdb.BtraceList object. */
static PyObject *
-btpy_list_new (thread_info *thread, Py_ssize_t first, Py_ssize_t last, Py_ssize_t step,
- PyTypeObject *element_type)
+btpy_list_new (thread_info *thread, Py_ssize_t first, Py_ssize_t last,
+ Py_ssize_t step, PyTypeObject *element_type)
{
- btpy_list_object * const obj = PyObject_New (btpy_list_object,
- &btpy_list_type);
+ btpy_list_object *const obj
+ = PyObject_New (btpy_list_object, &btpy_list_type);
if (obj == NULL)
return NULL;
@@ -193,7 +192,7 @@ btpy_list_new (thread_info *thread, Py_ssize_t first, Py_ssize_t last, Py_ssize_
PyObject *
recpy_bt_insn_sal (PyObject *self, void *closure)
{
- const btrace_insn * const insn = btrace_insn_from_recpy_insn (self);
+ const btrace_insn *const insn = btrace_insn_from_recpy_insn (self);
PyObject *result = NULL;
if (insn == NULL)
@@ -217,7 +216,7 @@ recpy_bt_insn_sal (PyObject *self, void *closure)
PyObject *
recpy_bt_insn_pc (PyObject *self, void *closure)
{
- const btrace_insn * const insn = btrace_insn_from_recpy_insn (self);
+ const btrace_insn *const insn = btrace_insn_from_recpy_insn (self);
if (insn == NULL)
return NULL;
@@ -231,7 +230,7 @@ recpy_bt_insn_pc (PyObject *self, void *closure)
PyObject *
recpy_bt_insn_size (PyObject *self, void *closure)
{
- const btrace_insn * const insn = btrace_insn_from_recpy_insn (self);
+ const btrace_insn *const insn = btrace_insn_from_recpy_insn (self);
if (insn == NULL)
return NULL;
@@ -245,7 +244,7 @@ recpy_bt_insn_size (PyObject *self, void *closure)
PyObject *
recpy_bt_insn_is_speculative (PyObject *self, void *closure)
{
- const btrace_insn * const insn = btrace_insn_from_recpy_insn (self);
+ const btrace_insn *const insn = btrace_insn_from_recpy_insn (self);
if (insn == NULL)
return NULL;
@@ -262,7 +261,7 @@ recpy_bt_insn_is_speculative (PyObject *self, void *closure)
PyObject *
recpy_bt_insn_data (PyObject *self, void *closure)
{
- const btrace_insn * const insn = btrace_insn_from_recpy_insn (self);
+ const btrace_insn *const insn = btrace_insn_from_recpy_insn (self);
gdb::byte_vector buffer;
PyObject *object;
@@ -279,8 +278,8 @@ recpy_bt_insn_data (PyObject *self, void *closure)
GDB_PY_HANDLE_EXCEPTION (except);
}
- object = PyBytes_FromStringAndSize ((const char *) buffer.data (),
- insn->size);
+ object
+ = PyBytes_FromStringAndSize ((const char *) buffer.data (), insn->size);
if (object == NULL)
return NULL;
@@ -294,7 +293,7 @@ recpy_bt_insn_data (PyObject *self, void *closure)
PyObject *
recpy_bt_insn_decoded (PyObject *self, void *closure)
{
- const btrace_insn * const insn = btrace_insn_from_recpy_insn (self);
+ const btrace_insn *const insn = btrace_insn_from_recpy_insn (self);
string_file strfile;
if (insn == NULL)
@@ -310,7 +309,6 @@ recpy_bt_insn_decoded (PyObject *self, void *closure)
return NULL;
}
-
return PyBytes_FromString (strfile.string ().c_str ());
}
@@ -320,15 +318,15 @@ recpy_bt_insn_decoded (PyObject *self, void *closure)
PyObject *
recpy_bt_func_level (PyObject *self, void *closure)
{
- const btrace_function * const func = btrace_func_from_recpy_func (self);
+ const btrace_function *const func = btrace_func_from_recpy_func (self);
thread_info *tinfo;
if (func == NULL)
return NULL;
tinfo = ((recpy_element_object *) self)->thread;
- return gdb_py_object_from_longest (tinfo->btrace.level
- + func->level).release ();
+ return gdb_py_object_from_longest (tinfo->btrace.level + func->level)
+ .release ();
}
/* Implementation of RecordFunctionSegment.symbol [gdb.Symbol] for btrace.
@@ -337,7 +335,7 @@ recpy_bt_func_level (PyObject *self, void *closure)
PyObject *
recpy_bt_func_symbol (PyObject *self, void *closure)
{
- const btrace_function * const func = btrace_func_from_recpy_func (self);
+ const btrace_function *const func = btrace_func_from_recpy_func (self);
if (func == NULL)
return NULL;
@@ -354,7 +352,7 @@ recpy_bt_func_symbol (PyObject *self, void *closure)
PyObject *
recpy_bt_func_instructions (PyObject *self, void *closure)
{
- const btrace_function * const func = btrace_func_from_recpy_func (self);
+ const btrace_function *const func = btrace_func_from_recpy_func (self);
unsigned int len;
if (func == NULL)
@@ -377,7 +375,7 @@ recpy_bt_func_instructions (PyObject *self, void *closure)
PyObject *
recpy_bt_func_up (PyObject *self, void *closure)
{
- const btrace_function * const func = btrace_func_from_recpy_func (self);
+ const btrace_function *const func = btrace_func_from_recpy_func (self);
if (func == NULL)
return NULL;
@@ -395,7 +393,7 @@ recpy_bt_func_up (PyObject *self, void *closure)
PyObject *
recpy_bt_func_prev (PyObject *self, void *closure)
{
- const btrace_function * const func = btrace_func_from_recpy_func (self);
+ const btrace_function *const func = btrace_func_from_recpy_func (self);
if (func == NULL)
return NULL;
@@ -413,7 +411,7 @@ recpy_bt_func_prev (PyObject *self, void *closure)
PyObject *
recpy_bt_func_next (PyObject *self, void *closure)
{
- const btrace_function * const func = btrace_func_from_recpy_func (self);
+ const btrace_function *const func = btrace_func_from_recpy_func (self);
if (func == NULL)
return NULL;
@@ -430,7 +428,7 @@ recpy_bt_func_next (PyObject *self, void *closure)
static Py_ssize_t
btpy_list_length (PyObject *self)
{
- const btpy_list_object * const obj = (btpy_list_object *) self;
+ const btpy_list_object *const obj = (btpy_list_object *) self;
const Py_ssize_t distance = obj->last - obj->first;
const Py_ssize_t result = distance / obj->step;
@@ -447,11 +445,11 @@ btpy_list_length (PyObject *self)
static PyObject *
btpy_list_item (PyObject *self, Py_ssize_t index)
{
- const btpy_list_object * const obj = (btpy_list_object *) self;
+ const btpy_list_object *const obj = (btpy_list_object *) self;
Py_ssize_t number;
if (index < 0 || index >= btpy_list_length (self))
- return PyErr_Format (PyExc_IndexError, _("Index out of range: %zd."),
+ return PyErr_Format (PyExc_IndexError, _ ("Index out of range: %zd."),
index);
number = obj->first + (obj->step * index);
@@ -467,7 +465,7 @@ btpy_list_item (PyObject *self, Py_ssize_t index)
static PyObject *
btpy_list_slice (PyObject *self, PyObject *value)
{
- const btpy_list_object * const obj = (btpy_list_object *) self;
+ const btpy_list_object *const obj = (btpy_list_object *) self;
const Py_ssize_t length = btpy_list_length (self);
Py_ssize_t start, stop, step, slicelength;
@@ -483,10 +481,11 @@ btpy_list_slice (PyObject *self, PyObject *value)
}
if (!PySlice_Check (value))
- return PyErr_Format (PyExc_TypeError, _("Index must be int or slice."));
+ return PyErr_Format (PyExc_TypeError, _ ("Index must be int or slice."));
- if (0 != PySlice_GetIndicesEx (value, length, &start, &stop,
- &step, &slicelength))
+ if (0
+ != PySlice_GetIndicesEx (value, length, &start, &stop, &step,
+ &slicelength))
return NULL;
return btpy_list_new (obj->thread, obj->first + obj->step * start,
@@ -500,8 +499,8 @@ btpy_list_slice (PyObject *self, PyObject *value)
static LONGEST
btpy_list_position (PyObject *self, PyObject *value)
{
- const btpy_list_object * const list_obj = (btpy_list_object *) self;
- const recpy_element_object * const obj = (const recpy_element_object *) value;
+ const btpy_list_object *const list_obj = (btpy_list_object *) self;
+ const recpy_element_object *const obj = (const recpy_element_object *) value;
Py_ssize_t index = obj->number;
if (list_obj->element_type != Py_TYPE (value))
@@ -540,7 +539,7 @@ btpy_list_index (PyObject *self, PyObject *value)
const LONGEST index = btpy_list_position (self, value);
if (index < 0)
- return PyErr_Format (PyExc_ValueError, _("Not in list."));
+ return PyErr_Format (PyExc_ValueError, _ ("Not in list."));
return gdb_py_object_from_longest (index).release ();
}
@@ -552,8 +551,8 @@ btpy_list_count (PyObject *self, PyObject *value)
{
/* We know that if an element is in the list, it is so exactly one time,
enabling us to reuse the "is element of" check. */
- return gdb_py_object_from_longest (btpy_list_contains (self,
- value)).release ();
+ return gdb_py_object_from_longest (btpy_list_contains (self, value))
+ .release ();
}
/* Python rich compare function to allow for equality and inequality checks
@@ -562,8 +561,8 @@ btpy_list_count (PyObject *self, PyObject *value)
static PyObject *
btpy_list_richcompare (PyObject *self, PyObject *other, int op)
{
- const btpy_list_object * const obj1 = (btpy_list_object *) self;
- const btpy_list_object * const obj2 = (btpy_list_object *) other;
+ const btpy_list_object *const obj1 = (btpy_list_object *) self;
+ const btpy_list_object *const obj2 = (btpy_list_object *) other;
if (Py_TYPE (self) != Py_TYPE (other))
{
@@ -572,12 +571,11 @@ btpy_list_richcompare (PyObject *self, PyObject *other, int op)
}
switch (op)
- {
+ {
case Py_EQ:
if (obj1->thread == obj2->thread
&& obj1->element_type == obj2->element_type
- && obj1->first == obj2->first
- && obj1->last == obj2->last
+ && obj1->first == obj2->first && obj1->last == obj2->last
&& obj1->step == obj2->step)
Py_RETURN_TRUE;
else
@@ -586,8 +584,7 @@ btpy_list_richcompare (PyObject *self, PyObject *other, int op)
case Py_NE:
if (obj1->thread != obj2->thread
|| obj1->element_type != obj2->element_type
- || obj1->first != obj2->first
- || obj1->last != obj2->last
+ || obj1->first != obj2->first || obj1->last != obj2->last
|| obj1->step != obj2->step)
Py_RETURN_TRUE;
else
@@ -595,7 +592,7 @@ btpy_list_richcompare (PyObject *self, PyObject *other, int op)
default:
break;
- }
+ }
Py_INCREF (Py_NotImplemented);
return Py_NotImplemented;
@@ -616,9 +613,9 @@ recpy_bt_method (PyObject *self, void *closure)
PyObject *
recpy_bt_format (PyObject *self, void *closure)
{
- const recpy_record_object * const record = (recpy_record_object *) self;
- const struct thread_info * const tinfo = record->thread;
- const struct btrace_config * config;
+ const recpy_record_object *const record = (recpy_record_object *) self;
+ const struct thread_info *const tinfo = record->thread;
+ const struct btrace_config *config;
if (tinfo == NULL)
Py_RETURN_NONE;
@@ -637,8 +634,8 @@ recpy_bt_format (PyObject *self, void *closure)
PyObject *
recpy_bt_replay_position (PyObject *self, void *closure)
{
- const recpy_record_object * const record = (recpy_record_object *) self;
- thread_info * tinfo = record->thread;
+ const recpy_record_object *const record = (recpy_record_object *) self;
+ thread_info *tinfo = record->thread;
if (tinfo == NULL)
Py_RETURN_NONE;
@@ -656,7 +653,7 @@ recpy_bt_replay_position (PyObject *self, void *closure)
PyObject *
recpy_bt_begin (PyObject *self, void *closure)
{
- const recpy_record_object * const record = (recpy_record_object *) self;
+ const recpy_record_object *const record = (recpy_record_object *) self;
thread_info *const tinfo = record->thread;
struct btrace_insn_iterator iterator;
@@ -678,7 +675,7 @@ recpy_bt_begin (PyObject *self, void *closure)
PyObject *
recpy_bt_end (PyObject *self, void *closure)
{
- const recpy_record_object * const record = (recpy_record_object *) self;
+ const recpy_record_object *const record = (recpy_record_object *) self;
thread_info *const tinfo = record->thread;
struct btrace_insn_iterator iterator;
@@ -700,27 +697,27 @@ recpy_bt_end (PyObject *self, void *closure)
PyObject *
recpy_bt_instruction_history (PyObject *self, void *closure)
{
- const recpy_record_object * const record = (recpy_record_object *) self;
+ const recpy_record_object *const record = (recpy_record_object *) self;
thread_info *const tinfo = record->thread;
struct btrace_insn_iterator iterator;
unsigned long first = 0;
unsigned long last = 0;
- if (tinfo == NULL)
- Py_RETURN_NONE;
+ if (tinfo == NULL)
+ Py_RETURN_NONE;
- btrace_fetch (tinfo, record_btrace_get_cpu ());
+ btrace_fetch (tinfo, record_btrace_get_cpu ());
- if (btrace_is_empty (tinfo))
- Py_RETURN_NONE;
+ if (btrace_is_empty (tinfo))
+ Py_RETURN_NONE;
- btrace_insn_begin (&iterator, &tinfo->btrace);
- first = btrace_insn_number (&iterator);
+ btrace_insn_begin (&iterator, &tinfo->btrace);
+ first = btrace_insn_number (&iterator);
- btrace_insn_end (&iterator, &tinfo->btrace);
- last = btrace_insn_number (&iterator);
+ btrace_insn_end (&iterator, &tinfo->btrace);
+ last = btrace_insn_number (&iterator);
- return btpy_list_new (tinfo, first, last, 1, &recpy_insn_type);
+ return btpy_list_new (tinfo, first, last, 1, &recpy_insn_type);
}
/* Implementation of
@@ -729,7 +726,7 @@ recpy_bt_instruction_history (PyObject *self, void *closure)
PyObject *
recpy_bt_function_call_history (PyObject *self, void *closure)
{
- const recpy_record_object * const record = (recpy_record_object *) self;
+ const recpy_record_object *const record = (recpy_record_object *) self;
thread_info *const tinfo = record->thread;
struct btrace_call_iterator iterator;
unsigned long first = 0;
@@ -757,19 +754,19 @@ recpy_bt_function_call_history (PyObject *self, void *closure)
PyObject *
recpy_bt_goto (PyObject *self, PyObject *args)
{
- const recpy_record_object * const record = (recpy_record_object *) self;
+ const recpy_record_object *const record = (recpy_record_object *) self;
thread_info *const tinfo = record->thread;
const recpy_element_object *obj;
PyObject *parse_obj;
if (tinfo == NULL || btrace_is_empty (tinfo))
- return PyErr_Format (gdbpy_gdb_error, _("Empty branch trace."));
+ return PyErr_Format (gdbpy_gdb_error, _ ("Empty branch trace."));
if (!PyArg_ParseTuple (args, "O", &parse_obj))
return NULL;
if (Py_TYPE (parse_obj) != &recpy_insn_type)
- return PyErr_Format (PyExc_TypeError, _("Argument must be instruction."));
+ return PyErr_Format (PyExc_TypeError, _ ("Argument must be instruction."));
obj = (const recpy_element_object *) parse_obj;
try
@@ -793,26 +790,18 @@ recpy_bt_goto (PyObject *self, PyObject *args)
/* BtraceList methods. */
-static PyMethodDef btpy_list_methods[] =
-{
- { "count", btpy_list_count, METH_O, "count number of occurrences"},
- { "index", btpy_list_index, METH_O, "index of entry"},
- {NULL}
-};
+static PyMethodDef btpy_list_methods[]
+ = { { "count", btpy_list_count, METH_O, "count number of occurrences" },
+ { "index", btpy_list_index, METH_O, "index of entry" },
+ { NULL } };
/* BtraceList sequence methods. */
-static PySequenceMethods btpy_list_sequence_methods =
-{
- NULL
-};
+static PySequenceMethods btpy_list_sequence_methods = { NULL };
/* BtraceList mapping methods. Necessary for slicing. */
-static PyMappingMethods btpy_list_mapping_methods =
-{
- NULL
-};
+static PyMappingMethods btpy_list_mapping_methods = { NULL };
/* Sets up the btrace record API. */
diff --git a/gdb/python/py-record-btrace.h b/gdb/python/py-record-btrace.h
index 0af8153..e8f47a1 100644
--- a/gdb/python/py-record-btrace.h
+++ b/gdb/python/py-record-btrace.h
@@ -35,7 +35,8 @@ extern PyObject *recpy_bt_goto (PyObject *self, PyObject *value);
extern PyObject *recpy_bt_instruction_history (PyObject *self, void *closure);
/* Implementation of record.function_call_history [list]. */
-extern PyObject *recpy_bt_function_call_history (PyObject *self, void *closure);
+extern PyObject *recpy_bt_function_call_history (PyObject *self,
+ void *closure);
/* Implementation of record.replay_position [instruction]. */
extern PyObject *recpy_bt_replay_position (PyObject *self, void *closure);
diff --git a/gdb/python/py-record.c b/gdb/python/py-record.c
index 1e40f2c..0abade7 100644
--- a/gdb/python/py-record.c
+++ b/gdb/python/py-record.c
@@ -27,35 +27,27 @@
/* Python Record type. */
-static PyTypeObject recpy_record_type = {
- PyVarObject_HEAD_INIT (NULL, 0)
-};
+static PyTypeObject recpy_record_type = { PyVarObject_HEAD_INIT (NULL, 0) };
/* Python RecordInstruction type. */
-PyTypeObject recpy_insn_type = {
- PyVarObject_HEAD_INIT (NULL, 0)
-};
+PyTypeObject recpy_insn_type = { PyVarObject_HEAD_INIT (NULL, 0) };
/* Python RecordFunctionSegment type. */
-PyTypeObject recpy_func_type = {
- PyVarObject_HEAD_INIT (NULL, 0)
-};
+PyTypeObject recpy_func_type = { PyVarObject_HEAD_INIT (NULL, 0) };
/* Python RecordGap type. */
-static PyTypeObject recpy_gap_type = {
- PyVarObject_HEAD_INIT (NULL, 0)
-};
+static PyTypeObject recpy_gap_type = { PyVarObject_HEAD_INIT (NULL, 0) };
/* Python RecordGap object. */
struct recpy_gap_object
{
PyObject_HEAD
- /* Reason code. */
- int reason_code;
+ /* Reason code. */
+ int reason_code;
/* Reason message. */
const char *reason_string;
@@ -67,9 +59,9 @@ struct recpy_gap_object
/* Implementation of record.method. */
static PyObject *
-recpy_method (PyObject *self, void* closure)
+recpy_method (PyObject *self, void *closure)
{
- const recpy_record_object * const obj = (recpy_record_object *) self;
+ const recpy_record_object *const obj = (recpy_record_object *) self;
if (obj->method == RECORD_METHOD_FULL)
return recpy_full_method (self, closure);
@@ -77,15 +69,15 @@ recpy_method (PyObject *self, void* closure)
if (obj->method == RECORD_METHOD_BTRACE)
return recpy_bt_method (self, closure);
- return PyErr_Format (PyExc_NotImplementedError, _("Not implemented."));
+ return PyErr_Format (PyExc_NotImplementedError, _ ("Not implemented."));
}
/* Implementation of record.format. */
static PyObject *
-recpy_format (PyObject *self, void* closure)
+recpy_format (PyObject *self, void *closure)
{
- const recpy_record_object * const obj = (recpy_record_object *) self;
+ const recpy_record_object *const obj = (recpy_record_object *) self;
if (obj->method == RECORD_METHOD_FULL)
return recpy_full_format (self, closure);
@@ -93,7 +85,7 @@ recpy_format (PyObject *self, void* closure)
if (obj->method == RECORD_METHOD_BTRACE)
return recpy_bt_format (self, closure);
- return PyErr_Format (PyExc_NotImplementedError, _("Not implemented."));
+ return PyErr_Format (PyExc_NotImplementedError, _ ("Not implemented."));
}
/* Implementation of record.goto (instruction) -> None. */
@@ -101,12 +93,12 @@ recpy_format (PyObject *self, void* closure)
static PyObject *
recpy_goto (PyObject *self, PyObject *value)
{
- const recpy_record_object * const obj = (recpy_record_object *) self;
+ const recpy_record_object *const obj = (recpy_record_object *) self;
if (obj->method == RECORD_METHOD_BTRACE)
return recpy_bt_goto (self, value);
- return PyErr_Format (PyExc_NotImplementedError, _("Not implemented."));
+ return PyErr_Format (PyExc_NotImplementedError, _ ("Not implemented."));
}
/* Implementation of record.replay_position [instruction] */
@@ -114,76 +106,77 @@ recpy_goto (PyObject *self, PyObject *value)
static PyObject *
recpy_replay_position (PyObject *self, void *closure)
{
- const recpy_record_object * const obj = (recpy_record_object *) self;
+ const recpy_record_object *const obj = (recpy_record_object *) self;
if (obj->method == RECORD_METHOD_BTRACE)
return recpy_bt_replay_position (self, closure);
- return PyErr_Format (PyExc_NotImplementedError, _("Not implemented."));
+ return PyErr_Format (PyExc_NotImplementedError, _ ("Not implemented."));
}
/* Implementation of record.instruction_history [list]. */
static PyObject *
-recpy_instruction_history (PyObject *self, void* closure)
+recpy_instruction_history (PyObject *self, void *closure)
{
- const recpy_record_object * const obj = (recpy_record_object *) self;
+ const recpy_record_object *const obj = (recpy_record_object *) self;
if (obj->method == RECORD_METHOD_BTRACE)
return recpy_bt_instruction_history (self, closure);
- return PyErr_Format (PyExc_NotImplementedError, _("Not implemented."));
+ return PyErr_Format (PyExc_NotImplementedError, _ ("Not implemented."));
}
/* Implementation of record.function_call_history [list]. */
static PyObject *
-recpy_function_call_history (PyObject *self, void* closure)
+recpy_function_call_history (PyObject *self, void *closure)
{
- const recpy_record_object * const obj = (recpy_record_object *) self;
+ const recpy_record_object *const obj = (recpy_record_object *) self;
if (obj->method == RECORD_METHOD_BTRACE)
return recpy_bt_function_call_history (self, closure);
- return PyErr_Format (PyExc_NotImplementedError, _("Not implemented."));
+ return PyErr_Format (PyExc_NotImplementedError, _ ("Not implemented."));
}
/* Implementation of record.begin [instruction]. */
static PyObject *
-recpy_begin (PyObject *self, void* closure)
+recpy_begin (PyObject *self, void *closure)
{
- const recpy_record_object * const obj = (recpy_record_object *) self;
+ const recpy_record_object *const obj = (recpy_record_object *) self;
if (obj->method == RECORD_METHOD_BTRACE)
return recpy_bt_begin (self, closure);
- return PyErr_Format (PyExc_NotImplementedError, _("Not implemented."));
+ return PyErr_Format (PyExc_NotImplementedError, _ ("Not implemented."));
}
/* Implementation of record.end [instruction]. */
static PyObject *
-recpy_end (PyObject *self, void* closure)
+recpy_end (PyObject *self, void *closure)
{
- const recpy_record_object * const obj = (recpy_record_object *) self;
+ const recpy_record_object *const obj = (recpy_record_object *) self;
if (obj->method == RECORD_METHOD_BTRACE)
return recpy_bt_end (self, closure);
- return PyErr_Format (PyExc_NotImplementedError, _("Not implemented."));
+ return PyErr_Format (PyExc_NotImplementedError, _ ("Not implemented."));
}
/* Create a new gdb.RecordInstruction object. */
PyObject *
-recpy_insn_new (thread_info *thread, enum record_method method, Py_ssize_t number)
+recpy_insn_new (thread_info *thread, enum record_method method,
+ Py_ssize_t number)
{
- recpy_element_object * const obj = PyObject_New (recpy_element_object,
- &recpy_insn_type);
+ recpy_element_object *const obj
+ = PyObject_New (recpy_element_object, &recpy_insn_type);
if (obj == NULL)
- return NULL;
+ return NULL;
obj->thread = thread;
obj->method = method;
@@ -197,12 +190,12 @@ recpy_insn_new (thread_info *thread, enum record_method method, Py_ssize_t numbe
static PyObject *
recpy_insn_sal (PyObject *self, void *closure)
{
- const recpy_element_object * const obj = (recpy_element_object *) self;
+ const recpy_element_object *const obj = (recpy_element_object *) self;
if (obj->method == RECORD_METHOD_BTRACE)
return recpy_bt_insn_sal (self, closure);
- return PyErr_Format (PyExc_NotImplementedError, _("Not implemented."));
+ return PyErr_Format (PyExc_NotImplementedError, _ ("Not implemented."));
}
/* Implementation of RecordInstruction.pc [int]. */
@@ -210,12 +203,12 @@ recpy_insn_sal (PyObject *self, void *closure)
static PyObject *
recpy_insn_pc (PyObject *self, void *closure)
{
- const recpy_element_object * const obj = (recpy_element_object *) self;
+ const recpy_element_object *const obj = (recpy_element_object *) self;
if (obj->method == RECORD_METHOD_BTRACE)
return recpy_bt_insn_pc (self, closure);
- return PyErr_Format (PyExc_NotImplementedError, _("Not implemented."));
+ return PyErr_Format (PyExc_NotImplementedError, _ ("Not implemented."));
}
/* Implementation of RecordInstruction.data [buffer]. */
@@ -223,12 +216,12 @@ recpy_insn_pc (PyObject *self, void *closure)
static PyObject *
recpy_insn_data (PyObject *self, void *closure)
{
- const recpy_element_object * const obj = (recpy_element_object *) self;
+ const recpy_element_object *const obj = (recpy_element_object *) self;
if (obj->method == RECORD_METHOD_BTRACE)
return recpy_bt_insn_data (self, closure);
- return PyErr_Format (PyExc_NotImplementedError, _("Not implemented."));
+ return PyErr_Format (PyExc_NotImplementedError, _ ("Not implemented."));
}
/* Implementation of RecordInstruction.decoded [str]. */
@@ -236,12 +229,12 @@ recpy_insn_data (PyObject *self, void *closure)
static PyObject *
recpy_insn_decoded (PyObject *self, void *closure)
{
- const recpy_element_object * const obj = (recpy_element_object *) self;
+ const recpy_element_object *const obj = (recpy_element_object *) self;
if (obj->method == RECORD_METHOD_BTRACE)
return recpy_bt_insn_decoded (self, closure);
- return PyErr_Format (PyExc_NotImplementedError, _("Not implemented."));
+ return PyErr_Format (PyExc_NotImplementedError, _ ("Not implemented."));
}
/* Implementation of RecordInstruction.size [int]. */
@@ -249,12 +242,12 @@ recpy_insn_decoded (PyObject *self, void *closure)
static PyObject *
recpy_insn_size (PyObject *self, void *closure)
{
- const recpy_element_object * const obj = (recpy_element_object *) self;
+ const recpy_element_object *const obj = (recpy_element_object *) self;
if (obj->method == RECORD_METHOD_BTRACE)
return recpy_bt_insn_size (self, closure);
- return PyErr_Format (PyExc_NotImplementedError, _("Not implemented."));
+ return PyErr_Format (PyExc_NotImplementedError, _ ("Not implemented."));
}
/* Implementation of RecordInstruction.is_speculative [bool]. */
@@ -262,24 +255,25 @@ recpy_insn_size (PyObject *self, void *closure)
static PyObject *
recpy_insn_is_speculative (PyObject *self, void *closure)
{
- const recpy_element_object * const obj = (recpy_element_object *) self;
+ const recpy_element_object *const obj = (recpy_element_object *) self;
if (obj->method == RECORD_METHOD_BTRACE)
return recpy_bt_insn_is_speculative (self, closure);
- return PyErr_Format (PyExc_NotImplementedError, _("Not implemented."));
+ return PyErr_Format (PyExc_NotImplementedError, _ ("Not implemented."));
}
/* Create a new gdb.RecordFunctionSegment object. */
PyObject *
-recpy_func_new (thread_info *thread, enum record_method method, Py_ssize_t number)
+recpy_func_new (thread_info *thread, enum record_method method,
+ Py_ssize_t number)
{
- recpy_element_object * const obj = PyObject_New (recpy_element_object,
- &recpy_func_type);
+ recpy_element_object *const obj
+ = PyObject_New (recpy_element_object, &recpy_func_type);
if (obj == NULL)
- return NULL;
+ return NULL;
obj->thread = thread;
obj->method = method;
@@ -293,12 +287,12 @@ recpy_func_new (thread_info *thread, enum record_method method, Py_ssize_t numbe
static PyObject *
recpy_func_level (PyObject *self, void *closure)
{
- const recpy_element_object * const obj = (recpy_element_object *) self;
+ const recpy_element_object *const obj = (recpy_element_object *) self;
if (obj->method == RECORD_METHOD_BTRACE)
return recpy_bt_func_level (self, closure);
- return PyErr_Format (PyExc_NotImplementedError, _("Not implemented."));
+ return PyErr_Format (PyExc_NotImplementedError, _ ("Not implemented."));
}
/* Implementation of RecordFunctionSegment.symbol [gdb.Symbol]. */
@@ -306,12 +300,12 @@ recpy_func_level (PyObject *self, void *closure)
static PyObject *
recpy_func_symbol (PyObject *self, void *closure)
{
- const recpy_element_object * const obj = (recpy_element_object *) self;
+ const recpy_element_object *const obj = (recpy_element_object *) self;
if (obj->method == RECORD_METHOD_BTRACE)
return recpy_bt_func_symbol (self, closure);
- return PyErr_Format (PyExc_NotImplementedError, _("Not implemented."));
+ return PyErr_Format (PyExc_NotImplementedError, _ ("Not implemented."));
}
/* Implementation of RecordFunctionSegment.instructions [list]. */
@@ -319,12 +313,12 @@ recpy_func_symbol (PyObject *self, void *closure)
static PyObject *
recpy_func_instructions (PyObject *self, void *closure)
{
- const recpy_element_object * const obj = (recpy_element_object *) self;
+ const recpy_element_object *const obj = (recpy_element_object *) self;
if (obj->method == RECORD_METHOD_BTRACE)
return recpy_bt_func_instructions (self, closure);
- return PyErr_Format (PyExc_NotImplementedError, _("Not implemented."));
+ return PyErr_Format (PyExc_NotImplementedError, _ ("Not implemented."));
}
/* Implementation of RecordFunctionSegment.up [RecordFunctionSegment]. */
@@ -332,12 +326,12 @@ recpy_func_instructions (PyObject *self, void *closure)
static PyObject *
recpy_func_up (PyObject *self, void *closure)
{
- const recpy_element_object * const obj = (recpy_element_object *) self;
+ const recpy_element_object *const obj = (recpy_element_object *) self;
if (obj->method == RECORD_METHOD_BTRACE)
return recpy_bt_func_up (self, closure);
- return PyErr_Format (PyExc_NotImplementedError, _("Not implemented."));
+ return PyErr_Format (PyExc_NotImplementedError, _ ("Not implemented."));
}
/* Implementation of RecordFunctionSegment.prev [RecordFunctionSegment]. */
@@ -345,12 +339,12 @@ recpy_func_up (PyObject *self, void *closure)
static PyObject *
recpy_func_prev (PyObject *self, void *closure)
{
- const recpy_element_object * const obj = (recpy_element_object *) self;
+ const recpy_element_object *const obj = (recpy_element_object *) self;
if (obj->method == RECORD_METHOD_BTRACE)
return recpy_bt_func_prev (self, closure);
- return PyErr_Format (PyExc_NotImplementedError, _("Not implemented."));
+ return PyErr_Format (PyExc_NotImplementedError, _ ("Not implemented."));
}
/* Implementation of RecordFunctionSegment.next [RecordFunctionSegment]. */
@@ -358,21 +352,21 @@ recpy_func_prev (PyObject *self, void *closure)
static PyObject *
recpy_func_next (PyObject *self, void *closure)
{
- const recpy_element_object * const obj = (recpy_element_object *) self;
+ const recpy_element_object *const obj = (recpy_element_object *) self;
if (obj->method == RECORD_METHOD_BTRACE)
return recpy_bt_func_next (self, closure);
- return PyErr_Format (PyExc_NotImplementedError, _("Not implemented."));
+ return PyErr_Format (PyExc_NotImplementedError, _ ("Not implemented."));
}
/* Implementation of RecordInstruction.number [int] and
RecordFunctionSegment.number [int]. */
static PyObject *
-recpy_element_number (PyObject *self, void* closure)
+recpy_element_number (PyObject *self, void *closure)
{
- const recpy_element_object * const obj = (recpy_element_object *) self;
+ const recpy_element_object *const obj = (recpy_element_object *) self;
return gdb_py_object_from_longest (obj->number).release ();
}
@@ -383,7 +377,7 @@ recpy_element_number (PyObject *self, void* closure)
static Py_hash_t
recpy_element_hash (PyObject *self)
{
- const recpy_element_object * const obj = (recpy_element_object *) self;
+ const recpy_element_object *const obj = (recpy_element_object *) self;
return obj->number;
}
@@ -394,8 +388,8 @@ recpy_element_hash (PyObject *self)
static PyObject *
recpy_element_richcompare (PyObject *self, PyObject *other, int op)
{
- const recpy_element_object * const obj1 = (recpy_element_object *) self;
- const recpy_element_object * const obj2 = (recpy_element_object *) other;
+ const recpy_element_object *const obj1 = (recpy_element_object *) self;
+ const recpy_element_object *const obj2 = (recpy_element_object *) other;
if (Py_TYPE (self) != Py_TYPE (other))
{
@@ -404,18 +398,16 @@ recpy_element_richcompare (PyObject *self, PyObject *other, int op)
}
switch (op)
- {
+ {
case Py_EQ:
- if (obj1->thread == obj2->thread
- && obj1->method == obj2->method
+ if (obj1->thread == obj2->thread && obj1->method == obj2->method
&& obj1->number == obj2->number)
Py_RETURN_TRUE;
else
Py_RETURN_FALSE;
case Py_NE:
- if (obj1->thread != obj2->thread
- || obj1->method != obj2->method
+ if (obj1->thread != obj2->thread || obj1->method != obj2->method
|| obj1->number != obj2->number)
Py_RETURN_TRUE;
else
@@ -423,7 +415,7 @@ recpy_element_richcompare (PyObject *self, PyObject *other, int op)
default:
break;
- }
+ }
Py_INCREF (Py_NotImplemented);
return Py_NotImplemented;
@@ -434,11 +426,11 @@ recpy_element_richcompare (PyObject *self, PyObject *other, int op)
PyObject *
recpy_gap_new (int reason_code, const char *reason_string, Py_ssize_t number)
{
- recpy_gap_object * const obj = PyObject_New (recpy_gap_object,
- &recpy_gap_type);
+ recpy_gap_object *const obj
+ = PyObject_New (recpy_gap_object, &recpy_gap_type);
if (obj == NULL)
- return NULL;
+ return NULL;
obj->reason_code = reason_code;
obj->reason_string = reason_string;
@@ -452,7 +444,7 @@ recpy_gap_new (int reason_code, const char *reason_string, Py_ssize_t number)
static PyObject *
recpy_gap_number (PyObject *self, void *closure)
{
- const recpy_gap_object * const obj = (const recpy_gap_object *) self;
+ const recpy_gap_object *const obj = (const recpy_gap_object *) self;
return gdb_py_object_from_longest (obj->number).release ();
}
@@ -462,7 +454,7 @@ recpy_gap_number (PyObject *self, void *closure)
static PyObject *
recpy_gap_reason_code (PyObject *self, void *closure)
{
- const recpy_gap_object * const obj = (const recpy_gap_object *) self;
+ const recpy_gap_object *const obj = (const recpy_gap_object *) self;
return gdb_py_object_from_longest (obj->reason_code).release ();
}
@@ -472,19 +464,18 @@ recpy_gap_reason_code (PyObject *self, void *closure)
static PyObject *
recpy_gap_reason_string (PyObject *self, void *closure)
{
- const recpy_gap_object * const obj = (const recpy_gap_object *) self;
+ const recpy_gap_object *const obj = (const recpy_gap_object *) self;
return PyUnicode_FromString (obj->reason_string);
}
/* Record method list. */
-static PyMethodDef recpy_record_methods[] = {
- { "goto", recpy_goto, METH_VARARGS,
- "goto (instruction|function_call) -> None.\n\
-Rewind to given location."},
- { NULL }
-};
+static PyMethodDef recpy_record_methods[]
+ = { { "goto", recpy_goto, METH_VARARGS,
+ "goto (instruction|function_call) -> None.\n\
+Rewind to given location." },
+ { NULL } };
/* Record member list. */
@@ -497,50 +488,54 @@ static gdb_PyGetSetDef recpy_record_getset[] = {
"List of instructions in current recording.", NULL },
{ "function_call_history", recpy_function_call_history, NULL,
"List of function calls in current recording.", NULL },
- { "begin", recpy_begin, NULL,
- "First instruction in current recording.", NULL },
+ { "begin", recpy_begin, NULL, "First instruction in current recording.",
+ NULL },
{ "end", recpy_end, NULL,
"One past the last instruction in current recording. This is typically \
-the current instruction and is used for e.g. record.goto (record.end).", NULL },
+the current instruction and is used for e.g. record.goto (record.end).",
+ NULL },
{ NULL }
};
/* RecordInstruction member list. */
-static gdb_PyGetSetDef recpy_insn_getset[] = {
- { "number", recpy_element_number, NULL, "instruction number", NULL},
- { "sal", recpy_insn_sal, NULL, "associated symbol and line", NULL},
- { "pc", recpy_insn_pc, NULL, "instruction address", NULL},
- { "data", recpy_insn_data, NULL, "raw instruction data", NULL},
- { "decoded", recpy_insn_decoded, NULL, "decoded instruction", NULL},
- { "size", recpy_insn_size, NULL, "instruction size in byte", NULL},
- { "is_speculative", recpy_insn_is_speculative, NULL, "if the instruction was \
- executed speculatively", NULL},
- { NULL }
-};
+static gdb_PyGetSetDef recpy_insn_getset[]
+ = { { "number", recpy_element_number, NULL, "instruction number", NULL },
+ { "sal", recpy_insn_sal, NULL, "associated symbol and line", NULL },
+ { "pc", recpy_insn_pc, NULL, "instruction address", NULL },
+ { "data", recpy_insn_data, NULL, "raw instruction data", NULL },
+ { "decoded", recpy_insn_decoded, NULL, "decoded instruction", NULL },
+ { "size", recpy_insn_size, NULL, "instruction size in byte", NULL },
+ { "is_speculative", recpy_insn_is_speculative, NULL,
+ "if the instruction was \
+ executed speculatively",
+ NULL },
+ { NULL } };
/* RecordFunctionSegment member list. */
static gdb_PyGetSetDef recpy_func_getset[] = {
- { "number", recpy_element_number, NULL, "function segment number", NULL},
- { "level", recpy_func_level, NULL, "call stack level", NULL},
- { "symbol", recpy_func_symbol, NULL, "associated line and symbol", NULL},
+ { "number", recpy_element_number, NULL, "function segment number", NULL },
+ { "level", recpy_func_level, NULL, "call stack level", NULL },
+ { "symbol", recpy_func_symbol, NULL, "associated line and symbol", NULL },
{ "instructions", recpy_func_instructions, NULL, "list of instructions in \
-this function segment", NULL},
- { "up", recpy_func_up, NULL, "caller or returned-to function segment", NULL},
- { "prev", recpy_func_prev, NULL, "previous segment of this function", NULL},
- { "next", recpy_func_next, NULL, "next segment of this function", NULL},
+this function segment",
+ NULL },
+ { "up", recpy_func_up, NULL, "caller or returned-to function segment",
+ NULL },
+ { "prev", recpy_func_prev, NULL, "previous segment of this function", NULL },
+ { "next", recpy_func_next, NULL, "next segment of this function", NULL },
{ NULL }
};
/* RecordGap member list. */
-static gdb_PyGetSetDef recpy_gap_getset[] = {
- { "number", recpy_gap_number, NULL, "element number", NULL},
- { "reason_code", recpy_gap_reason_code, NULL, "reason code", NULL},
- { "reason_string", recpy_gap_reason_string, NULL, "reason string", NULL},
- { NULL }
-};
+static gdb_PyGetSetDef recpy_gap_getset[]
+ = { { "number", recpy_gap_number, NULL, "element number", NULL },
+ { "reason_code", recpy_gap_reason_code, NULL, "reason code", NULL },
+ { "reason_string", recpy_gap_reason_string, NULL, "reason string",
+ NULL },
+ { NULL } };
/* Sets up the record API in the gdb module. */
diff --git a/gdb/python/py-record.h b/gdb/python/py-record.h
index 6eec71e..21ebabb 100644
--- a/gdb/python/py-record.h
+++ b/gdb/python/py-record.h
@@ -29,8 +29,8 @@ struct recpy_record_object
{
PyObject_HEAD
- /* The thread this object refers to. */
- thread_info *thread;
+ /* The thread this object refers to. */
+ thread_info *thread;
/* The current recording method. */
enum record_method method;
@@ -43,8 +43,8 @@ struct recpy_element_object
{
PyObject_HEAD
- /* The thread this object refers to. */
- thread_info *thread;
+ /* The thread this object refers to. */
+ thread_info *thread;
/* The current recording method. */
enum record_method method;
@@ -60,12 +60,12 @@ extern PyTypeObject recpy_insn_type;
extern PyTypeObject recpy_func_type;
/* Create a new gdb.RecordInstruction object. */
-extern PyObject *recpy_insn_new (thread_info *thread, enum record_method method,
- Py_ssize_t number);
+extern PyObject *recpy_insn_new (thread_info *thread,
+ enum record_method method, Py_ssize_t number);
/* Create a new gdb.RecordFunctionSegment object. */
-extern PyObject *recpy_func_new (thread_info *thread, enum record_method method,
- Py_ssize_t number);
+extern PyObject *recpy_func_new (thread_info *thread,
+ enum record_method method, Py_ssize_t number);
/* Create a new gdb.RecordGap object. */
extern PyObject *recpy_gap_new (int reason_code, const char *reason_string,
diff --git a/gdb/python/py-ref.h b/gdb/python/py-ref.h
index 6283af7..46e527c 100644
--- a/gdb/python/py-ref.h
+++ b/gdb/python/py-ref.h
@@ -26,20 +26,14 @@
template<typename T>
struct gdbpy_ref_policy
{
- static void incref (T *ptr)
- {
- Py_INCREF (ptr);
- }
-
- static void decref (T *ptr)
- {
- Py_DECREF (ptr);
- }
+ static void incref (T *ptr) { Py_INCREF (ptr); }
+
+ static void decref (T *ptr) { Py_DECREF (ptr); }
};
/* A gdb::ref_ptr that has been specialized for Python objects or
their "subclasses". */
-template<typename T = PyObject> using gdbpy_ref
- = gdb::ref_ptr<T, gdbpy_ref_policy<T>>;
+template<typename T = PyObject>
+using gdbpy_ref = gdb::ref_ptr<T, gdbpy_ref_policy<T>>;
#endif /* PYTHON_PY_REF_H */
diff --git a/gdb/python/py-registers.c b/gdb/python/py-registers.c
index 9531cf7..9ac002f 100644
--- a/gdb/python/py-registers.c
+++ b/gdb/python/py-registers.c
@@ -30,15 +30,16 @@ typedef std::vector<gdbpy_ref<>> gdbpy_register_type;
/* Token to access per-gdbarch data related to register descriptors. */
static const registry<gdbarch>::key<gdbpy_register_type>
- gdbpy_register_object_data;
+ gdbpy_register_object_data;
/* Structure for iterator over register descriptors. */
-struct register_descriptor_iterator_object {
+struct register_descriptor_iterator_object
+{
PyObject_HEAD
- /* The register group that the user is iterating over. This will never
+ /* The register group that the user is iterating over. This will never
be NULL. */
- const struct reggroup *reggroup;
+ const struct reggroup *reggroup;
/* The next register number to lookup. Starts at 0 and counts up. */
int regnum;
@@ -48,46 +49,49 @@ struct register_descriptor_iterator_object {
};
extern PyTypeObject register_descriptor_iterator_object_type
- CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("register_descriptor_iterator_object");
+ CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("register_descriptor_iterator_object");
/* A register descriptor. */
-struct register_descriptor_object {
+struct register_descriptor_object
+{
PyObject_HEAD
- /* The register this is a descriptor for. */
- int regnum;
+ /* The register this is a descriptor for. */
+ int regnum;
/* The architecture this is a register for. */
struct gdbarch *gdbarch;
};
extern PyTypeObject register_descriptor_object_type
- CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("register_descriptor_object");
+ CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("register_descriptor_object");
/* Structure for iterator over register groups. */
-struct reggroup_iterator_object {
+struct reggroup_iterator_object
+{
PyObject_HEAD
- /* The index into GROUPS for the next group to return. */
- std::vector<const reggroup *>::size_type index;
+ /* The index into GROUPS for the next group to return. */
+ std::vector<const reggroup *>::size_type index;
/* Pointer back to the architecture we're finding registers for. */
struct gdbarch *gdbarch;
};
extern PyTypeObject reggroup_iterator_object_type
- CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("reggroup_iterator_object");
+ CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("reggroup_iterator_object");
/* A register group object. */
-struct reggroup_object {
+struct reggroup_object
+{
PyObject_HEAD
- /* The register group being described. */
- const struct reggroup *reggroup;
+ /* The register group being described. */
+ const struct reggroup *reggroup;
};
-extern PyTypeObject reggroup_object_type
- CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("reggroup_object");
+extern PyTypeObject
+ reggroup_object_type CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("reggroup_object");
/* Return a gdb.RegisterGroup object wrapping REGGROUP. The register
group objects are cached, and the same Python object will always be
@@ -99,7 +103,7 @@ gdbpy_get_reggroup (const reggroup *reggroup)
/* Map from GDB's internal reggroup objects to the Python representation.
GDB's reggroups are global, and are never deleted, so using a map like
this is safe. */
- static std::unordered_map<const struct reggroup *,gdbpy_ref<>>
+ static std::unordered_map<const struct reggroup *, gdbpy_ref<>>
gdbpy_reggroup_object_map;
/* If there is not already a suitable Python object in the map then
@@ -107,8 +111,8 @@ gdbpy_get_reggroup (const reggroup *reggroup)
if (gdbpy_reggroup_object_map[reggroup] == nullptr)
{
/* Create a new object and fill in its details. */
- gdbpy_ref<reggroup_object> group
- (PyObject_New (reggroup_object, &reggroup_object_type));
+ gdbpy_ref<reggroup_object> group (PyObject_New (reggroup_object,
+ &reggroup_object_type));
if (group == NULL)
return NULL;
group->reggroup = reggroup;
@@ -147,8 +151,7 @@ gdbpy_reggroup_name (PyObject *self, void *closure)
then cached on the GDBARCH. */
static gdbpy_ref<>
-gdbpy_get_register_descriptor (struct gdbarch *gdbarch,
- int regnum)
+gdbpy_get_register_descriptor (struct gdbarch *gdbarch, int regnum)
{
gdbpy_register_type *vecp = gdbpy_register_object_data.get (gdbarch);
if (vecp == nullptr)
@@ -163,9 +166,8 @@ gdbpy_get_register_descriptor (struct gdbarch *gdbarch,
create one now. */
if (vec[regnum] == nullptr)
{
- gdbpy_ref <register_descriptor_object> reg
- (PyObject_New (register_descriptor_object,
- &register_descriptor_object_type));
+ gdbpy_ref<register_descriptor_object> reg (PyObject_New (
+ register_descriptor_object, &register_descriptor_object_type));
if (reg == NULL)
return NULL;
reg->regnum = regnum;
@@ -183,8 +185,7 @@ gdbpy_get_register_descriptor (struct gdbarch *gdbarch,
static PyObject *
gdbpy_register_descriptor_to_string (PyObject *self)
{
- register_descriptor_object *reg
- = (register_descriptor_object *) self;
+ register_descriptor_object *reg = (register_descriptor_object *) self;
struct gdbarch *gdbarch = reg->gdbarch;
int regnum = reg->regnum;
@@ -216,14 +217,13 @@ gdbpy_reggroup_iter (PyObject *self)
static PyObject *
gdbpy_reggroup_iter_next (PyObject *self)
{
- reggroup_iterator_object *iter_obj
- = (reggroup_iterator_object *) self;
+ reggroup_iterator_object *iter_obj = (reggroup_iterator_object *) self;
const std::vector<const reggroup *> &groups
= gdbarch_reggroups (iter_obj->gdbarch);
if (iter_obj->index >= groups.size ())
{
- PyErr_SetString (PyExc_StopIteration, _("No more groups"));
+ PyErr_SetString (PyExc_StopIteration, _ ("No more groups"));
return NULL;
}
@@ -242,8 +242,7 @@ gdbpy_new_reggroup_iterator (struct gdbarch *gdbarch)
/* Create a new object and fill in its internal state. */
reggroup_iterator_object *iter
- = PyObject_New (reggroup_iterator_object,
- &reggroup_iterator_object_type);
+ = PyObject_New (reggroup_iterator_object, &reggroup_iterator_object_type);
if (iter == NULL)
return NULL;
iter->index = 0;
@@ -274,7 +273,7 @@ gdbpy_new_register_descriptor_iterator (struct gdbarch *gdbarch,
if (grp == NULL)
{
PyErr_SetString (PyExc_ValueError,
- _("Unknown register group name."));
+ _ ("Unknown register group name."));
return NULL;
}
}
@@ -315,14 +314,13 @@ gdbpy_register_descriptor_iter_next (PyObject *self)
{
if (iter_obj->regnum >= gdbarch_num_cooked_regs (gdbarch))
{
- PyErr_SetString (PyExc_StopIteration, _("No more registers"));
+ PyErr_SetString (PyExc_StopIteration, _ ("No more registers"));
return NULL;
}
const char *name = nullptr;
int regnum = iter_obj->regnum;
- if (gdbarch_register_reggroup_p (gdbarch, regnum,
- iter_obj->reggroup))
+ if (gdbarch_register_reggroup_p (gdbarch, regnum, iter_obj->reggroup))
name = gdbarch_register_name (gdbarch, regnum);
iter_obj->regnum++;
@@ -375,7 +373,8 @@ gdbpy_parse_register_id (struct gdbarch *gdbarch, PyObject *pyo_reg_id,
/* The register could be a string, its name. */
if (gdbpy_is_string (pyo_reg_id))
{
- gdb::unique_xmalloc_ptr<char> reg_name (gdbpy_obj_to_string (pyo_reg_id));
+ gdb::unique_xmalloc_ptr<char> reg_name (
+ gdbpy_obj_to_string (pyo_reg_id));
if (reg_name != NULL)
{
@@ -405,7 +404,7 @@ gdbpy_parse_register_id (struct gdbarch *gdbarch, PyObject *pyo_reg_id,
}
/* The register could be a gdb.RegisterDescriptor object. */
else if (PyObject_IsInstance (pyo_reg_id,
- (PyObject *) &register_descriptor_object_type))
+ (PyObject *) &register_descriptor_object_type))
{
register_descriptor_object *reg
= (register_descriptor_object *) pyo_reg_id;
@@ -416,10 +415,10 @@ gdbpy_parse_register_id (struct gdbarch *gdbarch, PyObject *pyo_reg_id,
}
else
PyErr_SetString (PyExc_ValueError,
- _("Invalid Architecture in RegisterDescriptor"));
+ _ ("Invalid Architecture in RegisterDescriptor"));
}
else
- PyErr_SetString (PyExc_TypeError, _("Invalid type for register"));
+ PyErr_SetString (PyExc_TypeError, _ ("Invalid type for register"));
gdb_assert (PyErr_Occurred ());
return false;
@@ -433,180 +432,176 @@ gdbpy_initialize_registers ()
register_descriptor_object_type.tp_new = PyType_GenericNew;
if (PyType_Ready (&register_descriptor_object_type) < 0)
return -1;
- if (gdb_pymodule_addobject
- (gdb_module, "RegisterDescriptor",
- (PyObject *) &register_descriptor_object_type) < 0)
+ if (gdb_pymodule_addobject (gdb_module, "RegisterDescriptor",
+ (PyObject *) &register_descriptor_object_type)
+ < 0)
return -1;
reggroup_iterator_object_type.tp_new = PyType_GenericNew;
if (PyType_Ready (&reggroup_iterator_object_type) < 0)
return -1;
- if (gdb_pymodule_addobject
- (gdb_module, "RegisterGroupsIterator",
- (PyObject *) &reggroup_iterator_object_type) < 0)
+ if (gdb_pymodule_addobject (gdb_module, "RegisterGroupsIterator",
+ (PyObject *) &reggroup_iterator_object_type)
+ < 0)
return -1;
reggroup_object_type.tp_new = PyType_GenericNew;
if (PyType_Ready (&reggroup_object_type) < 0)
return -1;
- if (gdb_pymodule_addobject
- (gdb_module, "RegisterGroup",
- (PyObject *) &reggroup_object_type) < 0)
+ if (gdb_pymodule_addobject (gdb_module, "RegisterGroup",
+ (PyObject *) &reggroup_object_type)
+ < 0)
return -1;
register_descriptor_iterator_object_type.tp_new = PyType_GenericNew;
if (PyType_Ready (&register_descriptor_iterator_object_type) < 0)
return -1;
- return (gdb_pymodule_addobject
- (gdb_module, "RegisterDescriptorIterator",
- (PyObject *) &register_descriptor_iterator_object_type));
+ return (gdb_pymodule_addobject (
+ gdb_module, "RegisterDescriptorIterator",
+ (PyObject *) &register_descriptor_iterator_object_type));
}
-static PyMethodDef register_descriptor_iterator_object_methods [] = {
+static PyMethodDef register_descriptor_iterator_object_methods[] = {
{ "find", (PyCFunction) register_descriptor_iter_find,
METH_VARARGS | METH_KEYWORDS,
"registers (name) -> gdb.RegisterDescriptor.\n\
Return a register descriptor for the register NAME, or None if no register\n\
with that name exists in this iterator." },
- {NULL} /* Sentinel */
+ { NULL } /* Sentinel */
};
PyTypeObject register_descriptor_iterator_object_type = {
- PyVarObject_HEAD_INIT (NULL, 0)
- "gdb.RegisterDescriptorIterator", /*tp_name*/
- sizeof (register_descriptor_iterator_object), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- 0, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- "GDB architecture register descriptor iterator object", /*tp_doc */
- 0, /*tp_traverse */
- 0, /*tp_clear */
- 0, /*tp_richcompare */
- 0, /*tp_weaklistoffset */
- gdbpy_register_descriptor_iter, /*tp_iter */
- gdbpy_register_descriptor_iter_next, /*tp_iternext */
- register_descriptor_iterator_object_methods /*tp_methods */
+ PyVarObject_HEAD_INIT (NULL, 0) "gdb.RegisterDescriptorIterator", /*tp_name*/
+ sizeof (register_descriptor_iterator_object), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ 0, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT, /*tp_flags*/
+ "GDB architecture register descriptor iterator object", /*tp_doc */
+ 0, /*tp_traverse */
+ 0, /*tp_clear */
+ 0, /*tp_richcompare */
+ 0, /*tp_weaklistoffset */
+ gdbpy_register_descriptor_iter, /*tp_iter */
+ gdbpy_register_descriptor_iter_next, /*tp_iternext */
+ register_descriptor_iterator_object_methods /*tp_methods */
};
static gdb_PyGetSetDef gdbpy_register_descriptor_getset[] = {
- { "name", gdbpy_register_descriptor_name, NULL,
- "The name of this register.", NULL },
- { NULL } /* Sentinel */
+ { "name", gdbpy_register_descriptor_name, NULL, "The name of this register.",
+ NULL },
+ { NULL } /* Sentinel */
};
PyTypeObject register_descriptor_object_type = {
- PyVarObject_HEAD_INIT (NULL, 0)
- "gdb.RegisterDescriptor", /*tp_name*/
- sizeof (register_descriptor_object), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- 0, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
- 0, /*tp_call*/
- gdbpy_register_descriptor_to_string, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- "GDB architecture register descriptor object", /*tp_doc */
- 0, /*tp_traverse */
- 0, /*tp_clear */
- 0, /*tp_richcompare */
- 0, /*tp_weaklistoffset */
- 0, /*tp_iter */
- 0, /*tp_iternext */
- 0, /*tp_methods */
- 0, /*tp_members */
- gdbpy_register_descriptor_getset /*tp_getset */
+ PyVarObject_HEAD_INIT (NULL, 0) "gdb.RegisterDescriptor", /*tp_name*/
+ sizeof (register_descriptor_object), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ 0, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ gdbpy_register_descriptor_to_string, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT, /*tp_flags*/
+ "GDB architecture register descriptor object", /*tp_doc */
+ 0, /*tp_traverse */
+ 0, /*tp_clear */
+ 0, /*tp_richcompare */
+ 0, /*tp_weaklistoffset */
+ 0, /*tp_iter */
+ 0, /*tp_iternext */
+ 0, /*tp_methods */
+ 0, /*tp_members */
+ gdbpy_register_descriptor_getset /*tp_getset */
};
PyTypeObject reggroup_iterator_object_type = {
- PyVarObject_HEAD_INIT (NULL, 0)
- "gdb.RegisterGroupsIterator", /*tp_name*/
- sizeof (reggroup_iterator_object), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- 0, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- "GDB register groups iterator object", /*tp_doc */
- 0, /*tp_traverse */
- 0, /*tp_clear */
- 0, /*tp_richcompare */
- 0, /*tp_weaklistoffset */
- gdbpy_reggroup_iter, /*tp_iter */
- gdbpy_reggroup_iter_next, /*tp_iternext */
- 0 /*tp_methods */
+ PyVarObject_HEAD_INIT (NULL, 0) "gdb.RegisterGroupsIterator", /*tp_name*/
+ sizeof (reggroup_iterator_object), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ 0, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT, /*tp_flags*/
+ "GDB register groups iterator object", /*tp_doc */
+ 0, /*tp_traverse */
+ 0, /*tp_clear */
+ 0, /*tp_richcompare */
+ 0, /*tp_weaklistoffset */
+ gdbpy_reggroup_iter, /*tp_iter */
+ gdbpy_reggroup_iter_next, /*tp_iternext */
+ 0 /*tp_methods */
};
static gdb_PyGetSetDef gdbpy_reggroup_getset[] = {
- { "name", gdbpy_reggroup_name, NULL,
- "The name of this register group.", NULL },
- { NULL } /* Sentinel */
+ { "name", gdbpy_reggroup_name, NULL, "The name of this register group.",
+ NULL },
+ { NULL } /* Sentinel */
};
PyTypeObject reggroup_object_type = {
- PyVarObject_HEAD_INIT (NULL, 0)
- "gdb.RegisterGroup", /*tp_name*/
- sizeof (reggroup_object), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- 0, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
- 0, /*tp_call*/
- gdbpy_reggroup_to_string, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- "GDB register group object", /*tp_doc */
- 0, /*tp_traverse */
- 0, /*tp_clear */
- 0, /*tp_richcompare */
- 0, /*tp_weaklistoffset */
- 0, /*tp_iter */
- 0, /*tp_iternext */
- 0, /*tp_methods */
- 0, /*tp_members */
- gdbpy_reggroup_getset /*tp_getset */
+ PyVarObject_HEAD_INIT (NULL, 0) "gdb.RegisterGroup", /*tp_name*/
+ sizeof (reggroup_object), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ 0, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ gdbpy_reggroup_to_string, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT, /*tp_flags*/
+ "GDB register group object", /*tp_doc */
+ 0, /*tp_traverse */
+ 0, /*tp_clear */
+ 0, /*tp_richcompare */
+ 0, /*tp_weaklistoffset */
+ 0, /*tp_iter */
+ 0, /*tp_iternext */
+ 0, /*tp_methods */
+ 0, /*tp_members */
+ gdbpy_reggroup_getset /*tp_getset */
};
diff --git a/gdb/python/py-signalevent.c b/gdb/python/py-signalevent.c
index 93d0670..457ec3e 100644
--- a/gdb/python/py-signalevent.c
+++ b/gdb/python/py-signalevent.c
@@ -34,9 +34,9 @@ create_signal_event_object (enum gdb_signal stop_signal)
gdbpy_ref<> signal_name_obj (PyUnicode_FromString (signal_name));
if (signal_name_obj == NULL)
return NULL;
- if (evpy_add_attribute (signal_event_obj.get (),
- "stop_signal",
- signal_name_obj.get ()) < 0)
+ if (evpy_add_attribute (signal_event_obj.get (), "stop_signal",
+ signal_name_obj.get ())
+ < 0)
return NULL;
return signal_event_obj;
diff --git a/gdb/python/py-stopevent.c b/gdb/python/py-stopevent.c
index 0aa9d53..c4f1dbe 100644
--- a/gdb/python/py-stopevent.c
+++ b/gdb/python/py-stopevent.c
@@ -48,11 +48,10 @@ emit_stop_event (struct bpstat *bs, enum gdb_signal stop_signal)
/* Add any breakpoint set at this location to the list. */
for (current_bs = bs; current_bs != NULL; current_bs = current_bs->next)
{
- if (current_bs->breakpoint_at
- && current_bs->breakpoint_at->py_bp_object)
+ if (current_bs->breakpoint_at && current_bs->breakpoint_at->py_bp_object)
{
- PyObject *current_py_bp =
- (PyObject *) current_bs->breakpoint_at->py_bp_object;
+ PyObject *current_py_bp
+ = (PyObject *) current_bs->breakpoint_at->py_bp_object;
if (list == NULL)
{
@@ -71,15 +70,13 @@ emit_stop_event (struct bpstat *bs, enum gdb_signal stop_signal)
if (list != NULL)
{
- stop_event_obj = create_breakpoint_event_object (list.get (),
- first_bp);
+ stop_event_obj = create_breakpoint_event_object (list.get (), first_bp);
if (stop_event_obj == NULL)
return -1;
}
/* Check if the signal is "Signal 0" or "Trace/breakpoint trap". */
- if (stop_signal != GDB_SIGNAL_0
- && stop_signal != GDB_SIGNAL_TRAP)
+ if (stop_signal != GDB_SIGNAL_0 && stop_signal != GDB_SIGNAL_TRAP)
{
stop_event_obj = create_signal_event_object (stop_signal);
if (stop_event_obj == NULL)
diff --git a/gdb/python/py-stopevent.h b/gdb/python/py-stopevent.h
index 023459f..4188263 100644
--- a/gdb/python/py-stopevent.h
+++ b/gdb/python/py-stopevent.h
@@ -25,8 +25,7 @@
extern gdbpy_ref<> create_stop_event_object (PyTypeObject *py_type);
extern void stop_evpy_dealloc (PyObject *self);
-extern int emit_stop_event (struct bpstat *bs,
- enum gdb_signal stop_signal);
+extern int emit_stop_event (struct bpstat *bs, enum gdb_signal stop_signal);
extern gdbpy_ref<> create_breakpoint_event_object (PyObject *breakpoint_list,
PyObject *first_bp);
diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c
index b877796..5f8c2db 100644
--- a/gdb/python/py-symbol.c
+++ b/gdb/python/py-symbol.c
@@ -25,10 +25,11 @@
#include "objfiles.h"
#include "symfile.h"
-struct symbol_object {
+struct symbol_object
+{
PyObject_HEAD
- /* The GDB symbol structure this object is wrapping. */
- struct symbol *symbol;
+ /* The GDB symbol structure this object is wrapping. */
+ struct symbol *symbol;
/* A symbol object is associated with an objfile, so keep track with
doubly-linked list, rooted in the objfile. This lets us
invalidate the underlying struct symbol when the objfile is
@@ -39,16 +40,17 @@ struct symbol_object {
/* Require a valid symbol. All access to symbol_object->symbol should be
gated by this call. */
-#define SYMPY_REQUIRE_VALID(symbol_obj, symbol) \
- do { \
- symbol = symbol_object_to_symbol (symbol_obj); \
- if (symbol == NULL) \
- { \
- PyErr_SetString (PyExc_RuntimeError, \
- _("Symbol is invalid.")); \
- return NULL; \
- } \
- } while (0)
+#define SYMPY_REQUIRE_VALID(symbol_obj, symbol) \
+ do \
+ { \
+ symbol = symbol_object_to_symbol (symbol_obj); \
+ if (symbol == NULL) \
+ { \
+ PyErr_SetString (PyExc_RuntimeError, _ ("Symbol is invalid.")); \
+ return NULL; \
+ } \
+ } \
+ while (0)
/* A deleter that is used when an objfile is about to be freed. */
struct symbol_object_deleter
@@ -69,7 +71,7 @@ struct symbol_object_deleter
};
static const registry<objfile>::key<symbol_object, symbol_object_deleter>
- sympy_objfile_data_key;
+ sympy_objfile_data_key;
static PyObject *
sympy_str (PyObject *self)
@@ -173,7 +175,8 @@ sympy_is_constant (PyObject *self, void *closure)
theclass = symbol->aclass ();
- return PyBool_FromLong (theclass == LOC_CONST || theclass == LOC_CONST_BYTES);
+ return PyBool_FromLong (theclass == LOC_CONST
+ || theclass == LOC_CONST_BYTES);
}
static PyObject *
@@ -201,7 +204,8 @@ sympy_is_variable (PyObject *self, void *closure)
return PyBool_FromLong (!symbol->is_argument ()
&& (theclass == LOC_LOCAL || theclass == LOC_REGISTER
- || theclass == LOC_STATIC || theclass == LOC_COMPUTED
+ || theclass == LOC_STATIC
+ || theclass == LOC_COMPUTED
|| theclass == LOC_OPTIMIZED_OUT));
}
@@ -291,11 +295,11 @@ sympy_value (PyObject *self, PyObject *args)
{
frame_info = frame_object_to_frame_info (frame_obj);
if (frame_info == NULL)
- error (_("invalid frame"));
+ error (_ ("invalid frame"));
}
if (symbol_read_needs_frame (symbol) && frame_info == NULL)
- error (_("symbol requires a frame to compute its value"));
+ error (_ ("symbol requires a frame to compute its value"));
/* TODO: currently, we have no way to recover the block in which SYMBOL
was found, so we have no block to pass to read_var_value. This will
@@ -321,8 +325,7 @@ set_symbol (symbol_object *obj, struct symbol *symbol)
{
obj->symbol = symbol;
obj->prev = NULL;
- if (symbol->is_objfile_owned ()
- && symbol->symtab () != NULL)
+ if (symbol->is_objfile_owned () && symbol->symtab () != NULL)
{
struct objfile *objfile = symbol->objfile ();
@@ -353,7 +356,7 @@ symbol_to_symbol_object (struct symbol *sym)
struct symbol *
symbol_object_to_symbol (PyObject *obj)
{
- if (! PyObject_TypeCheck (obj, &symbol_object_type))
+ if (!PyObject_TypeCheck (obj, &symbol_object_type))
return NULL;
return ((symbol_object *) obj)->symbol;
}
@@ -365,8 +368,7 @@ sympy_dealloc (PyObject *obj)
if (sym_obj->prev)
sym_obj->prev->next = sym_obj->next;
- else if (sym_obj->symbol != NULL
- && sym_obj->symbol->is_objfile_owned ()
+ else if (sym_obj->symbol != NULL && sym_obj->symbol->is_objfile_owned ()
&& sym_obj->symbol->symtab () != NULL)
sympy_objfile_data_key.set (sym_obj->symbol->objfile (), sym_obj->next);
if (sym_obj->next)
@@ -405,7 +407,7 @@ gdbpy_lookup_symbol (PyObject *self, PyObject *args, PyObject *kw)
try
{
- selected_frame = get_selected_frame (_("No frame selected."));
+ selected_frame = get_selected_frame (_ ("No frame selected."));
block = get_frame_block (selected_frame, NULL);
}
catch (const gdb_exception &except)
@@ -417,7 +419,8 @@ gdbpy_lookup_symbol (PyObject *self, PyObject *args, PyObject *kw)
try
{
symbol = lookup_symbol (name, block, (domain_enum) domain,
- &is_a_field_of_this).symbol;
+ &is_a_field_of_this)
+ .symbol;
}
catch (const gdb_exception &except)
{
@@ -512,7 +515,7 @@ gdbpy_lookup_static_symbol (PyObject *self, PyObject *args, PyObject *kw)
try
{
frame_info_ptr selected_frame
- = get_selected_frame (_("No frame selected."));
+ = get_selected_frame (_ ("No frame selected."));
block = get_frame_block (selected_frame, NULL);
}
catch (const gdb_exception &except)
@@ -524,8 +527,8 @@ gdbpy_lookup_static_symbol (PyObject *self, PyObject *args, PyObject *kw)
{
if (block != nullptr)
symbol
- = lookup_symbol_in_static_block (name, block,
- (domain_enum) domain).symbol;
+ = lookup_symbol_in_static_block (name, block, (domain_enum) domain)
+ .symbol;
if (symbol == nullptr)
symbol = lookup_static_symbol (name, (domain_enum) domain).symbol;
@@ -589,13 +592,14 @@ gdbpy_lookup_static_symbols (PyObject *self, PyObject *args, PyObject *kw)
if (block != nullptr)
{
- symbol *symbol = lookup_symbol_in_static_block
- (name, block, (domain_enum) domain).symbol;
+ symbol *symbol
+ = lookup_symbol_in_static_block (name, block,
+ (domain_enum) domain)
+ .symbol;
if (symbol != nullptr)
{
- PyObject *sym_obj
- = symbol_to_symbol_object (symbol);
+ PyObject *sym_obj = symbol_to_symbol_object (symbol);
if (PyList_Append (return_list.get (), sym_obj) == -1)
return NULL;
}
@@ -617,49 +621,57 @@ gdbpy_initialize_symbols (void)
if (PyType_Ready (&symbol_object_type) < 0)
return -1;
- if (PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_UNDEF", LOC_UNDEF) < 0
- || PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_CONST",
- LOC_CONST) < 0
- || PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_STATIC",
- LOC_STATIC) < 0
- || PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_REGISTER",
- LOC_REGISTER) < 0
- || PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_ARG",
- LOC_ARG) < 0
- || PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_REF_ARG",
- LOC_REF_ARG) < 0
- || PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_LOCAL",
- LOC_LOCAL) < 0
- || PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_TYPEDEF",
- LOC_TYPEDEF) < 0
- || PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_LABEL",
- LOC_LABEL) < 0
- || PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_BLOCK",
- LOC_BLOCK) < 0
- || PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_CONST_BYTES",
- LOC_CONST_BYTES) < 0
- || PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_UNRESOLVED",
- LOC_UNRESOLVED) < 0
- || PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_OPTIMIZED_OUT",
- LOC_OPTIMIZED_OUT) < 0
- || PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_COMPUTED",
- LOC_COMPUTED) < 0
- || PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_COMMON_BLOCK",
- LOC_COMMON_BLOCK) < 0
- || PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_REGPARM_ADDR",
- LOC_REGPARM_ADDR) < 0
- || PyModule_AddIntConstant (gdb_module, "SYMBOL_UNDEF_DOMAIN",
- UNDEF_DOMAIN) < 0
- || PyModule_AddIntConstant (gdb_module, "SYMBOL_VAR_DOMAIN",
- VAR_DOMAIN) < 0
- || PyModule_AddIntConstant (gdb_module, "SYMBOL_STRUCT_DOMAIN",
- STRUCT_DOMAIN) < 0
- || PyModule_AddIntConstant (gdb_module, "SYMBOL_LABEL_DOMAIN",
- LABEL_DOMAIN) < 0
- || PyModule_AddIntConstant (gdb_module, "SYMBOL_MODULE_DOMAIN",
- MODULE_DOMAIN) < 0
- || PyModule_AddIntConstant (gdb_module, "SYMBOL_COMMON_BLOCK_DOMAIN",
- COMMON_BLOCK_DOMAIN) < 0)
+ if (
+ PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_UNDEF", LOC_UNDEF) < 0
+ || PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_CONST", LOC_CONST) < 0
+ || PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_STATIC", LOC_STATIC)
+ < 0
+ || PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_REGISTER",
+ LOC_REGISTER)
+ < 0
+ || PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_ARG", LOC_ARG) < 0
+ || PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_REF_ARG", LOC_REF_ARG)
+ < 0
+ || PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_LOCAL", LOC_LOCAL) < 0
+ || PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_TYPEDEF", LOC_TYPEDEF)
+ < 0
+ || PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_LABEL", LOC_LABEL) < 0
+ || PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_BLOCK", LOC_BLOCK) < 0
+ || PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_CONST_BYTES",
+ LOC_CONST_BYTES)
+ < 0
+ || PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_UNRESOLVED",
+ LOC_UNRESOLVED)
+ < 0
+ || PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_OPTIMIZED_OUT",
+ LOC_OPTIMIZED_OUT)
+ < 0
+ || PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_COMPUTED",
+ LOC_COMPUTED)
+ < 0
+ || PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_COMMON_BLOCK",
+ LOC_COMMON_BLOCK)
+ < 0
+ || PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_REGPARM_ADDR",
+ LOC_REGPARM_ADDR)
+ < 0
+ || PyModule_AddIntConstant (gdb_module, "SYMBOL_UNDEF_DOMAIN",
+ UNDEF_DOMAIN)
+ < 0
+ || PyModule_AddIntConstant (gdb_module, "SYMBOL_VAR_DOMAIN", VAR_DOMAIN)
+ < 0
+ || PyModule_AddIntConstant (gdb_module, "SYMBOL_STRUCT_DOMAIN",
+ STRUCT_DOMAIN)
+ < 0
+ || PyModule_AddIntConstant (gdb_module, "SYMBOL_LABEL_DOMAIN",
+ LABEL_DOMAIN)
+ < 0
+ || PyModule_AddIntConstant (gdb_module, "SYMBOL_MODULE_DOMAIN",
+ MODULE_DOMAIN)
+ < 0
+ || PyModule_AddIntConstant (gdb_module, "SYMBOL_COMMON_BLOCK_DOMAIN",
+ COMMON_BLOCK_DOMAIN)
+ < 0)
return -1;
/* These remain defined for compatibility, but as they were never
@@ -669,22 +681,22 @@ gdbpy_initialize_symbols (void)
used differently. Here we try to give them values that will make
sense if they are passed to gdb.lookup_symbol. */
if (PyModule_AddIntConstant (gdb_module, "SYMBOL_VARIABLES_DOMAIN",
- VAR_DOMAIN) < 0
+ VAR_DOMAIN)
+ < 0
|| PyModule_AddIntConstant (gdb_module, "SYMBOL_FUNCTIONS_DOMAIN",
- VAR_DOMAIN) < 0
+ VAR_DOMAIN)
+ < 0
|| PyModule_AddIntConstant (gdb_module, "SYMBOL_TYPES_DOMAIN",
- VAR_DOMAIN) < 0)
+ VAR_DOMAIN)
+ < 0)
return -1;
return gdb_pymodule_addobject (gdb_module, "Symbol",
(PyObject *) &symbol_object_type);
}
-
-
static gdb_PyGetSetDef symbol_object_getset[] = {
- { "type", sympy_get_type, NULL,
- "Type of the symbol.", NULL },
+ { "type", sympy_get_type, NULL, "Type of the symbol.", NULL },
{ "symtab", sympy_get_symtab, NULL,
"Symbol table in which the symbol appears.", NULL },
{ "name", sympy_get_name, NULL,
@@ -695,7 +707,8 @@ static gdb_PyGetSetDef symbol_object_getset[] = {
{ "print_name", sympy_get_print_name, NULL,
"Name of the symbol in a form suitable for output.\n\
This is either name or linkage_name, depending on whether the user asked GDB\n\
-to display demangled or mangled names.", NULL },
+to display demangled or mangled names.",
+ NULL },
{ "addr_class", sympy_get_addr_class, NULL, "Address class of the symbol." },
{ "is_argument", sympy_is_argument, NULL,
"True if the symbol is an argument of a function." },
@@ -709,48 +722,45 @@ to display demangled or mangled names.", NULL },
"True if the symbol requires a frame for evaluation." },
{ "line", sympy_line, NULL,
"The source line number at which the symbol was defined." },
- { NULL } /* Sentinel */
+ { NULL } /* Sentinel */
};
static PyMethodDef symbol_object_methods[] = {
- { "is_valid", sympy_is_valid, METH_NOARGS,
- "is_valid () -> Boolean.\n\
+ { "is_valid", sympy_is_valid, METH_NOARGS, "is_valid () -> Boolean.\n\
Return true if this symbol is valid, false if not." },
- { "value", sympy_value, METH_VARARGS,
- "value ([frame]) -> gdb.Value\n\
+ { "value", sympy_value, METH_VARARGS, "value ([frame]) -> gdb.Value\n\
Return the value of the symbol." },
- {NULL} /* Sentinel */
+ { NULL } /* Sentinel */
};
PyTypeObject symbol_object_type = {
- PyVarObject_HEAD_INIT (NULL, 0)
- "gdb.Symbol", /*tp_name*/
- sizeof (symbol_object), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- sympy_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
- 0, /*tp_call*/
- sympy_str, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- "GDB symbol object", /*tp_doc */
- 0, /*tp_traverse */
- 0, /*tp_clear */
- 0, /*tp_richcompare */
- 0, /*tp_weaklistoffset */
- 0, /*tp_iter */
- 0, /*tp_iternext */
- symbol_object_methods, /*tp_methods */
- 0, /*tp_members */
- symbol_object_getset /*tp_getset */
+ PyVarObject_HEAD_INIT (NULL, 0) "gdb.Symbol", /*tp_name*/
+ sizeof (symbol_object), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ sympy_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ sympy_str, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT, /*tp_flags*/
+ "GDB symbol object", /*tp_doc */
+ 0, /*tp_traverse */
+ 0, /*tp_clear */
+ 0, /*tp_richcompare */
+ 0, /*tp_weaklistoffset */
+ 0, /*tp_iter */
+ 0, /*tp_iternext */
+ symbol_object_methods, /*tp_methods */
+ 0, /*tp_members */
+ symbol_object_getset /*tp_getset */
};
diff --git a/gdb/python/py-symtab.c b/gdb/python/py-symtab.c
index 86ef725..7e82ac6 100644
--- a/gdb/python/py-symtab.c
+++ b/gdb/python/py-symtab.c
@@ -25,10 +25,11 @@
#include "objfiles.h"
#include "block.h"
-struct symtab_object {
+struct symtab_object
+{
PyObject_HEAD
- /* The GDB Symbol table structure. */
- struct symtab *symtab;
+ /* The GDB Symbol table structure. */
+ struct symtab *symtab;
/* A symtab object is associated with an objfile, so keep track with
a doubly-linked list, rooted in the objfile. This allows
invalidation of the underlying struct symtab when the objfile is
@@ -58,28 +59,31 @@ struct stpy_deleter
}
};
-extern PyTypeObject symtab_object_type
- CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("symtab_object");
+extern PyTypeObject
+ symtab_object_type CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("symtab_object");
static const registry<objfile>::key<symtab_object, stpy_deleter>
- stpy_objfile_data_key;
+ stpy_objfile_data_key;
/* Require a valid symbol table. All access to symtab_object->symtab
should be gated by this call. */
-#define STPY_REQUIRE_VALID(symtab_obj, symtab) \
- do { \
- symtab = symtab_object_to_symtab (symtab_obj); \
- if (symtab == NULL) \
- { \
- PyErr_SetString (PyExc_RuntimeError, \
- _("Symbol Table is invalid.")); \
- return NULL; \
- } \
- } while (0)
-
-struct sal_object {
+#define STPY_REQUIRE_VALID(symtab_obj, symtab) \
+ do \
+ { \
+ symtab = symtab_object_to_symtab (symtab_obj); \
+ if (symtab == NULL) \
+ { \
+ PyErr_SetString (PyExc_RuntimeError, \
+ _ ("Symbol Table is invalid.")); \
+ return NULL; \
+ } \
+ } \
+ while (0)
+
+struct sal_object
+{
PyObject_HEAD
- /* The GDB Symbol table structure. */
- PyObject *symtab;
+ /* The GDB Symbol table structure. */
+ PyObject *symtab;
/* The GDB Symbol table and line structure. */
struct symtab_and_line *sal;
/* A Symtab and line object is associated with an objfile, so keep
@@ -119,23 +123,25 @@ struct salpy_deleter
}
};
-extern PyTypeObject sal_object_type
- CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("sal_object");
+extern PyTypeObject
+ sal_object_type CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("sal_object");
static const registry<objfile>::key<sal_object, salpy_deleter>
- salpy_objfile_data_key;
+ salpy_objfile_data_key;
/* Require a valid symbol table and line object. All access to
sal_object->sal should be gated by this call. */
-#define SALPY_REQUIRE_VALID(sal_obj, sal) \
- do { \
- sal = sal_object_to_symtab_and_line (sal_obj); \
- if (sal == NULL) \
- { \
- PyErr_SetString (PyExc_RuntimeError, \
- _("Symbol Table and Line is invalid.")); \
- return NULL; \
- } \
- } while (0)
+#define SALPY_REQUIRE_VALID(sal_obj, sal) \
+ do \
+ { \
+ sal = sal_object_to_symtab_and_line (sal_obj); \
+ if (sal == NULL) \
+ { \
+ PyErr_SetString (PyExc_RuntimeError, \
+ _ ("Symbol Table and Line is invalid.")); \
+ return NULL; \
+ } \
+ } \
+ while (0)
static PyObject *
stpy_str (PyObject *self)
@@ -171,7 +177,8 @@ stpy_get_objfile (PyObject *self, void *closure)
STPY_REQUIRE_VALID (self, symtab);
- return objfile_to_objfile_object (symtab->compunit ()->objfile ()).release ();
+ return objfile_to_objfile_object (symtab->compunit ()->objfile ())
+ .release ();
}
/* Getter function for symtab.producer. */
@@ -306,7 +313,6 @@ stpy_dealloc (PyObject *obj)
Py_TYPE (obj)->tp_free (obj);
}
-
static PyObject *
salpy_get_pc (PyObject *self, void *closure)
{
@@ -379,9 +385,9 @@ salpy_dealloc (PyObject *self)
if (self_sal->prev)
self_sal->prev->next = self_sal->next;
else if (self_sal->symtab != Py_None)
- salpy_objfile_data_key.set
- (symtab_object_to_symtab (self_sal->symtab)->compunit ()->objfile (),
- self_sal->next);
+ salpy_objfile_data_key.set (
+ symtab_object_to_symtab (self_sal->symtab)->compunit ()->objfile (),
+ self_sal->next);
if (self_sal->next)
self_sal->next->prev = self_sal->prev;
@@ -403,7 +409,7 @@ set_sal (sal_object *sal_obj, struct symtab_and_line sal)
if (sal.symtab)
{
- symtab_obj = symtab_to_symtab_object (sal.symtab);
+ symtab_obj = symtab_to_symtab_object (sal.symtab);
/* If a symtab existed in the sal, but it cannot be duplicated,
we exit. */
if (symtab_obj == NULL)
@@ -415,9 +421,10 @@ set_sal (sal_object *sal_obj, struct symtab_and_line sal)
Py_INCREF (Py_None);
}
- sal_obj->sal = ((struct symtab_and_line *)
- xmemdup (&sal, sizeof (struct symtab_and_line),
- sizeof (struct symtab_and_line)));
+ sal_obj->sal
+ = ((struct symtab_and_line *) xmemdup (&sal,
+ sizeof (struct symtab_and_line),
+ sizeof (struct symtab_and_line)));
sal_obj->symtab = symtab_obj;
sal_obj->prev = NULL;
@@ -495,7 +502,7 @@ symtab_and_line_to_sal_object (struct symtab_and_line sal)
struct symtab_and_line *
sal_object_to_symtab_and_line (PyObject *obj)
{
- if (! PyObject_TypeCheck (obj, &sal_object_type))
+ if (!PyObject_TypeCheck (obj, &sal_object_type))
return NULL;
return ((sal_object *) obj)->sal;
}
@@ -504,7 +511,7 @@ sal_object_to_symtab_and_line (PyObject *obj)
struct symtab *
symtab_object_to_symtab (PyObject *obj)
{
- if (! PyObject_TypeCheck (obj, &symtab_object_type))
+ if (!PyObject_TypeCheck (obj, &symtab_object_type))
return NULL;
return ((symtab_object *) obj)->symtab;
}
@@ -521,31 +528,27 @@ gdbpy_initialize_symtabs (void)
return -1;
if (gdb_pymodule_addobject (gdb_module, "Symtab",
- (PyObject *) &symtab_object_type) < 0)
+ (PyObject *) &symtab_object_type)
+ < 0)
return -1;
return gdb_pymodule_addobject (gdb_module, "Symtab_and_line",
(PyObject *) &sal_object_type);
}
-
-
static gdb_PyGetSetDef symtab_object_getset[] = {
- { "filename", stpy_get_filename, NULL,
- "The symbol table's source filename.", NULL },
- { "objfile", stpy_get_objfile, NULL, "The symtab's objfile.",
+ { "filename", stpy_get_filename, NULL, "The symbol table's source filename.",
NULL },
+ { "objfile", stpy_get_objfile, NULL, "The symtab's objfile.", NULL },
{ "producer", stpy_get_producer, NULL,
"The name/version of the program that compiled this symtab.", NULL },
- {NULL} /* Sentinel */
+ { NULL } /* Sentinel */
};
static PyMethodDef symtab_object_methods[] = {
- { "is_valid", stpy_is_valid, METH_NOARGS,
- "is_valid () -> Boolean.\n\
+ { "is_valid", stpy_is_valid, METH_NOARGS, "is_valid () -> Boolean.\n\
Return true if this symbol table is valid, false if not." },
- { "fullname", stpy_fullname, METH_NOARGS,
- "fullname () -> String.\n\
+ { "fullname", stpy_fullname, METH_NOARGS, "fullname () -> String.\n\
Return the symtab's full source filename." },
{ "global_block", stpy_global_block, METH_NOARGS,
"global_block () -> gdb.Block.\n\
@@ -553,91 +556,87 @@ Return the global block of the symbol table." },
{ "static_block", stpy_static_block, METH_NOARGS,
"static_block () -> gdb.Block.\n\
Return the static block of the symbol table." },
- { "linetable", stpy_get_linetable, METH_NOARGS,
+ { "linetable", stpy_get_linetable, METH_NOARGS,
"linetable () -> gdb.LineTable.\n\
Return the LineTable associated with this symbol table" },
- {NULL} /* Sentinel */
+ { NULL } /* Sentinel */
};
PyTypeObject symtab_object_type = {
- PyVarObject_HEAD_INIT (NULL, 0)
- "gdb.Symtab", /*tp_name*/
- sizeof (symtab_object), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- stpy_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
- 0, /*tp_call*/
- stpy_str, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- "GDB symtab object", /*tp_doc */
- 0, /*tp_traverse */
- 0, /*tp_clear */
- 0, /*tp_richcompare */
- 0, /*tp_weaklistoffset */
- 0, /*tp_iter */
- 0, /*tp_iternext */
- symtab_object_methods, /*tp_methods */
- 0, /*tp_members */
- symtab_object_getset /*tp_getset */
+ PyVarObject_HEAD_INIT (NULL, 0) "gdb.Symtab", /*tp_name*/
+ sizeof (symtab_object), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ stpy_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ stpy_str, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT, /*tp_flags*/
+ "GDB symtab object", /*tp_doc */
+ 0, /*tp_traverse */
+ 0, /*tp_clear */
+ 0, /*tp_richcompare */
+ 0, /*tp_weaklistoffset */
+ 0, /*tp_iter */
+ 0, /*tp_iternext */
+ symtab_object_methods, /*tp_methods */
+ 0, /*tp_members */
+ symtab_object_getset /*tp_getset */
};
static gdb_PyGetSetDef sal_object_getset[] = {
{ "symtab", salpy_get_symtab, NULL, "Symtab object.", NULL },
{ "pc", salpy_get_pc, NULL, "Return the symtab_and_line's pc.", NULL },
- { "last", salpy_get_last, NULL,
- "Return the symtab_and_line's last address.", NULL },
- { "line", salpy_get_line, NULL,
- "Return the symtab_and_line's line.", NULL },
- {NULL} /* Sentinel */
+ { "last", salpy_get_last, NULL, "Return the symtab_and_line's last address.",
+ NULL },
+ { "line", salpy_get_line, NULL, "Return the symtab_and_line's line.", NULL },
+ { NULL } /* Sentinel */
};
static PyMethodDef sal_object_methods[] = {
- { "is_valid", salpy_is_valid, METH_NOARGS,
- "is_valid () -> Boolean.\n\
+ { "is_valid", salpy_is_valid, METH_NOARGS, "is_valid () -> Boolean.\n\
Return true if this symbol table and line is valid, false if not." },
- {NULL} /* Sentinel */
+ { NULL } /* Sentinel */
};
PyTypeObject sal_object_type = {
- PyVarObject_HEAD_INIT (NULL, 0)
- "gdb.Symtab_and_line", /*tp_name*/
- sizeof (sal_object), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- salpy_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
- 0, /*tp_call*/
- salpy_str, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- "GDB symtab_and_line object", /*tp_doc */
- 0, /*tp_traverse */
- 0, /*tp_clear */
- 0, /*tp_richcompare */
- 0, /*tp_weaklistoffset */
- 0, /*tp_iter */
- 0, /*tp_iternext */
- sal_object_methods, /*tp_methods */
- 0, /*tp_members */
- sal_object_getset /*tp_getset */
+ PyVarObject_HEAD_INIT (NULL, 0) "gdb.Symtab_and_line", /*tp_name*/
+ sizeof (sal_object), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ salpy_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ salpy_str, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT, /*tp_flags*/
+ "GDB symtab_and_line object", /*tp_doc */
+ 0, /*tp_traverse */
+ 0, /*tp_clear */
+ 0, /*tp_richcompare */
+ 0, /*tp_weaklistoffset */
+ 0, /*tp_iter */
+ 0, /*tp_iternext */
+ sal_object_methods, /*tp_methods */
+ 0, /*tp_members */
+ sal_object_getset /*tp_getset */
};
diff --git a/gdb/python/py-threadevent.c b/gdb/python/py-threadevent.c
index b29f69a..d7dae07 100644
--- a/gdb/python/py-threadevent.c
+++ b/gdb/python/py-threadevent.c
@@ -28,8 +28,7 @@ py_get_event_thread (ptid_t ptid)
if (non_stop)
{
thread_info *thread
- = find_thread_ptid (current_inferior ()->process_target (),
- ptid);
+ = find_thread_ptid (current_inferior ()->process_target (), ptid);
if (thread != nullptr)
return thread_to_thread_object (thread);
PyErr_SetString (PyExc_RuntimeError, "Could not find event thread");
@@ -47,9 +46,8 @@ create_thread_event_object (PyTypeObject *py_type, PyObject *thread)
if (thread_event_obj == NULL)
return NULL;
- if (evpy_add_attribute (thread_event_obj.get (),
- "inferior_thread",
- thread) < 0)
+ if (evpy_add_attribute (thread_event_obj.get (), "inferior_thread", thread)
+ < 0)
return NULL;
return thread_event_obj;
diff --git a/gdb/python/py-tui.c b/gdb/python/py-tui.c
index e9c9101..6df0cdd 100644
--- a/gdb/python/py-tui.c
+++ b/gdb/python/py-tui.c
@@ -17,7 +17,6 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
#include "defs.h"
#include "arch-utils.h"
#include "python-internal.h"
@@ -45,15 +44,15 @@ struct gdbpy_tui_window
{
PyObject_HEAD
- /* The TUI window, or nullptr if the window has been deleted. */
- tui_py_window *window;
+ /* The TUI window, or nullptr if the window has been deleted. */
+ tui_py_window *window;
/* Return true if this object is valid. */
bool is_valid () const;
};
extern PyTypeObject gdbpy_tui_window_object_type
- CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("gdbpy_tui_window");
+ CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("gdbpy_tui_window");
/* A TUI window written in Python. */
@@ -80,10 +79,7 @@ public:
m_window = std::move (user_window);
}
- const char *name () const override
- {
- return m_name.c_str ();
- }
+ const char *name () const override { return m_name.c_str (); }
void rerender () override;
void do_scroll_vertical (int num_to_scroll) override;
@@ -118,16 +114,10 @@ public:
void output (const char *str, bool full_window);
/* A helper function to compute the viewport width. */
- int viewport_width () const
- {
- return std::max (0, width - 2);
- }
+ int viewport_width () const { return std::max (0, width - 2); }
/* A helper function to compute the viewport height. */
- int viewport_height () const
- {
- return std::max (0, height - 2);
- }
+ int viewport_height () const { return std::max (0, height - 2); }
private:
@@ -159,8 +149,7 @@ tui_py_window::~tui_py_window ()
/* This can be null if the user-provided Python construction
function failed. */
- if (m_window != nullptr
- && PyObject_HasAttrString (m_window.get (), "close"))
+ if (m_window != nullptr && PyObject_HasAttrString (m_window.get (), "close"))
{
gdbpy_ref<> result (PyObject_CallMethod (m_window.get (), "close",
nullptr));
@@ -210,8 +199,8 @@ tui_py_window::do_scroll_horizontal (int num_to_scroll)
if (PyObject_HasAttrString (m_window.get (), "hscroll"))
{
- gdbpy_ref<> result (PyObject_CallMethod (m_window.get(), "hscroll",
- "i", num_to_scroll, nullptr));
+ gdbpy_ref<> result (PyObject_CallMethod (m_window.get (), "hscroll", "i",
+ num_to_scroll, nullptr));
if (result == nullptr)
gdbpy_print_stack ();
}
@@ -224,8 +213,8 @@ tui_py_window::do_scroll_vertical (int num_to_scroll)
if (PyObject_HasAttrString (m_window.get (), "vscroll"))
{
- gdbpy_ref<> result (PyObject_CallMethod (m_window.get (), "vscroll",
- "i", num_to_scroll, nullptr));
+ gdbpy_ref<> result (PyObject_CallMethod (m_window.get (), "vscroll", "i",
+ num_to_scroll, nullptr));
if (result == nullptr)
gdbpy_print_stack ();
}
@@ -238,8 +227,8 @@ tui_py_window::click (int mouse_x, int mouse_y, int mouse_button)
if (PyObject_HasAttrString (m_window.get (), "click"))
{
- gdbpy_ref<> result (PyObject_CallMethod (m_window.get (), "click",
- "iii", mouse_x, mouse_y,
+ gdbpy_ref<> result (PyObject_CallMethod (m_window.get (), "click", "iii",
+ mouse_x, mouse_y,
mouse_button));
if (result == nullptr)
gdbpy_print_stack ();
@@ -262,8 +251,6 @@ tui_py_window::output (const char *text, bool full_window)
}
}
-
-
/* A callable that is used to create a TUI window. It wraps the
user-supplied window constructor. */
@@ -321,21 +308,19 @@ gdbpy_tui_window_maker::operator() (const char *win_name)
{
gdbpy_enter enter_py;
- gdbpy_ref<gdbpy_tui_window> wrapper
- (PyObject_New (gdbpy_tui_window, &gdbpy_tui_window_object_type));
+ gdbpy_ref<gdbpy_tui_window> wrapper (
+ PyObject_New (gdbpy_tui_window, &gdbpy_tui_window_object_type));
if (wrapper == nullptr)
{
gdbpy_print_stack ();
return nullptr;
}
- std::unique_ptr<tui_py_window> window
- (new tui_py_window (win_name, wrapper));
+ std::unique_ptr<tui_py_window> window (new tui_py_window (win_name,
+ wrapper));
- gdbpy_ref<> user_window
- (PyObject_CallFunctionObjArgs (m_constr.get (),
- (PyObject *) wrapper.get (),
- nullptr));
+ gdbpy_ref<> user_window (PyObject_CallFunctionObjArgs (
+ m_constr.get (), (PyObject *) wrapper.get (), nullptr));
if (user_window == nullptr)
{
gdbpy_print_stack ();
@@ -357,8 +342,8 @@ gdbpy_register_tui_window (PyObject *self, PyObject *args, PyObject *kw)
const char *name;
PyObject *cons_obj;
- if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "sO", keywords,
- &name, &cons_obj))
+ if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "sO", keywords, &name,
+ &cons_obj))
return nullptr;
try
@@ -375,28 +360,29 @@ gdbpy_register_tui_window (PyObject *self, PyObject *args, PyObject *kw)
Py_RETURN_NONE;
}
-
-
/* Require that "Window" be a valid window. */
-#define REQUIRE_WINDOW(Window) \
- do { \
- if (!(Window)->is_valid ()) \
- return PyErr_Format (PyExc_RuntimeError, \
- _("TUI window is invalid.")); \
- } while (0)
+#define REQUIRE_WINDOW(Window) \
+ do \
+ { \
+ if (!(Window)->is_valid ()) \
+ return PyErr_Format (PyExc_RuntimeError, \
+ _ ("TUI window is invalid.")); \
+ } \
+ while (0)
/* Require that "Window" be a valid window. */
-#define REQUIRE_WINDOW_FOR_SETTER(Window) \
- do { \
- if (!(Window)->is_valid ()) \
- { \
- PyErr_Format (PyExc_RuntimeError, \
- _("TUI window is invalid.")); \
- return -1; \
- } \
- } while (0)
+#define REQUIRE_WINDOW_FOR_SETTER(Window) \
+ do \
+ { \
+ if (!(Window)->is_valid ()) \
+ { \
+ PyErr_Format (PyExc_RuntimeError, _ ("TUI window is invalid.")); \
+ return -1; \
+ } \
+ } \
+ while (0)
/* Python function which checks the validity of a TUI window
object. */
@@ -482,7 +468,7 @@ gdbpy_tui_set_title (PyObject *self, PyObject *newvalue, void *closure)
if (newvalue == nullptr)
{
- PyErr_Format (PyExc_TypeError, _("Cannot delete \"title\" attribute."));
+ PyErr_Format (PyExc_TypeError, _ ("Cannot delete \"title\" attribute."));
return -1;
}
@@ -495,66 +481,60 @@ gdbpy_tui_set_title (PyObject *self, PyObject *newvalue, void *closure)
return 0;
}
-static gdb_PyGetSetDef tui_object_getset[] =
-{
+static gdb_PyGetSetDef tui_object_getset[] = {
{ "width", gdbpy_tui_width, NULL, "Width of the window.", NULL },
{ "height", gdbpy_tui_height, NULL, "Height of the window.", NULL },
{ "title", gdbpy_tui_title, gdbpy_tui_set_title, "Title of the window.",
NULL },
- { NULL } /* Sentinel */
+ { NULL } /* Sentinel */
};
-static PyMethodDef tui_object_methods[] =
-{
- { "is_valid", gdbpy_tui_is_valid, METH_NOARGS,
- "is_valid () -> Boolean\n\
+static PyMethodDef tui_object_methods[] = {
+ { "is_valid", gdbpy_tui_is_valid, METH_NOARGS, "is_valid () -> Boolean\n\
Return true if this TUI window is valid, false if not." },
- { "erase", gdbpy_tui_erase, METH_NOARGS,
- "Erase the TUI window." },
+ { "erase", gdbpy_tui_erase, METH_NOARGS, "Erase the TUI window." },
{ "write", (PyCFunction) gdbpy_tui_write, METH_VARARGS,
"Append a string to the TUI window." },
{ NULL } /* Sentinel. */
};
-PyTypeObject gdbpy_tui_window_object_type =
-{
- PyVarObject_HEAD_INIT (NULL, 0)
- "gdb.TuiWindow", /*tp_name*/
- sizeof (gdbpy_tui_window), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- 0, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro */
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
- "GDB TUI window object", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- tui_object_methods, /* tp_methods */
- 0, /* tp_members */
- tui_object_getset, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- 0, /* tp_init */
- 0, /* tp_alloc */
+PyTypeObject gdbpy_tui_window_object_type = {
+ PyVarObject_HEAD_INIT (NULL, 0) "gdb.TuiWindow", /*tp_name*/
+ sizeof (gdbpy_tui_window), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ 0, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro */
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
+ "GDB TUI window object", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ tui_object_methods, /* tp_methods */
+ 0, /* tp_members */
+ tui_object_getset, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
};
#endif /* TUI */
@@ -568,7 +548,7 @@ gdbpy_initialize_tui ()
gdbpy_tui_window_object_type.tp_new = PyType_GenericNew;
if (PyType_Ready (&gdbpy_tui_window_object_type) < 0)
return -1;
-#endif /* TUI */
+#endif /* TUI */
return 0;
}
diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c
index 81b5951..2a28cbd 100644
--- a/gdb/python/py-type.c
+++ b/gdb/python/py-type.c
@@ -31,8 +31,7 @@
struct type_object
{
- PyObject_HEAD
- struct type *type;
+ PyObject_HEAD struct type *type;
/* If a Type object is associated with an objfile, it is kept on a
doubly-linked list, rooted in the objfile. This lets us copy the
@@ -41,26 +40,27 @@ struct type_object
struct type_object *next;
};
-extern PyTypeObject type_object_type
- CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("type_object");
+extern PyTypeObject
+ type_object_type CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("type_object");
/* A Field object. */
struct field_object
{
PyObject_HEAD
- /* Dictionary holding our attributes. */
- PyObject *dict;
+ /* Dictionary holding our attributes. */
+ PyObject *dict;
};
-extern PyTypeObject field_object_type
- CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("field_object");
+extern PyTypeObject
+ field_object_type CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("field_object");
/* A type iterator object. */
-struct typy_iterator_object {
+struct typy_iterator_object
+{
PyObject_HEAD
- /* The current field index. */
- int field;
+ /* The current field index. */
+ int field;
/* What to return. */
enum gdbpy_iter_kind kind;
/* Pointer back to the original source type object. */
@@ -68,7 +68,7 @@ struct typy_iterator_object {
};
extern PyTypeObject type_iterator_object_type
- CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("typy_iterator_object");
+ CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("typy_iterator_object");
/* This is used to initialize various gdb.TYPE_ constants. */
struct pyty_code
@@ -82,8 +82,7 @@ struct pyty_code
/* Forward declarations. */
static PyObject *typy_make_iter (PyObject *self, enum gdbpy_iter_kind kind);
-static struct pyty_code pyty_codes[] =
-{
+static struct pyty_code pyty_codes[] = {
/* This is kept for backward compatibility. */
{ -1, "TYPE_CODE_BITSTRING" },
@@ -92,8 +91,6 @@ static struct pyty_code pyty_codes[] =
#undef OP
};
-
-
static void
field_dealloc (PyObject *obj)
{
@@ -118,8 +115,6 @@ field_new (void)
return (PyObject *) result.release ();
}
-
-
/* Return true if OBJ is of type gdb.Field, false otherwise. */
int
@@ -160,7 +155,8 @@ convert_field (struct type *type, int field)
if (type->code () == TYPE_CODE_ENUM)
{
- arg = gdb_py_object_from_longest (type->field (field).loc_enumval ());
+ arg
+ = gdb_py_object_from_longest (type->field (field).loc_enumval ());
attrstring = "enumval";
}
else
@@ -168,7 +164,8 @@ convert_field (struct type *type, int field)
if (type->field (field).loc_kind () == FIELD_LOC_KIND_DWARF_BLOCK)
arg = gdbpy_ref<>::new_reference (Py_None);
else
- arg = gdb_py_object_from_longest (type->field (field).loc_bitpos ());
+ arg
+ = gdb_py_object_from_longest (type->field (field).loc_bitpos ());
attrstring = "bitpos";
}
@@ -386,8 +383,7 @@ typy_get_tag (PyObject *self, void *closure)
struct type *type = ((type_object *) self)->type;
const char *tagname = nullptr;
- if (type->code () == TYPE_CODE_STRUCT
- || type->code () == TYPE_CODE_UNION
+ if (type->code () == TYPE_CODE_STRUCT || type->code () == TYPE_CODE_UNION
|| type->code () == TYPE_CODE_ENUM)
tagname = type->name ();
@@ -431,8 +427,7 @@ typy_is_signed (PyObject *self, void *closure)
if (!is_scalar_type (type))
{
- PyErr_SetString (PyExc_ValueError,
- _("Type must be a scalar type"));
+ PyErr_SetString (PyExc_ValueError, _ ("Type must be a scalar type"));
return nullptr;
}
@@ -466,7 +461,6 @@ typy_strip_typedefs (PyObject *self, PyObject *args)
static struct type *
typy_get_composite (struct type *type)
{
-
for (;;)
{
try
@@ -485,14 +479,13 @@ typy_get_composite (struct type *type)
/* If this is not a struct, union, or enum type, raise TypeError
exception. */
- if (type->code () != TYPE_CODE_STRUCT
- && type->code () != TYPE_CODE_UNION
- && type->code () != TYPE_CODE_ENUM
- && type->code () != TYPE_CODE_METHOD
+ if (type->code () != TYPE_CODE_STRUCT && type->code () != TYPE_CODE_UNION
+ && type->code () != TYPE_CODE_ENUM && type->code () != TYPE_CODE_METHOD
&& type->code () != TYPE_CODE_FUNC)
{
- PyErr_SetString (PyExc_TypeError,
- "Type is not a structure, union, enum, or function type.");
+ PyErr_SetString (
+ PyExc_TypeError,
+ "Type is not a structure, union, enum, or function type.");
return NULL;
}
@@ -509,7 +502,7 @@ typy_array_1 (PyObject *self, PyObject *args, int is_vector)
struct type *array = NULL;
struct type *type = ((type_object *) self)->type;
- if (! PyArg_ParseTuple (args, "l|O", &n1, &n2_obj))
+ if (!PyArg_ParseTuple (args, "l|O", &n1, &n2_obj))
return NULL;
if (n2_obj)
@@ -517,11 +510,11 @@ typy_array_1 (PyObject *self, PyObject *args, int is_vector)
if (!PyLong_Check (n2_obj))
{
PyErr_SetString (PyExc_RuntimeError,
- _("Array bound must be an integer"));
+ _ ("Array bound must be an integer"));
return NULL;
}
- if (! gdb_py_int_as_long (n2_obj, &n2))
+ if (!gdb_py_int_as_long (n2_obj, &n2))
return NULL;
}
else
@@ -533,7 +526,7 @@ typy_array_1 (PyObject *self, PyObject *args, int is_vector)
if (n2 < n1 - 1) /* Note: An empty array has n2 == n1 - 1. */
{
PyErr_SetString (PyExc_ValueError,
- _("Array length must not be negative"));
+ _ ("Array length must not be negative"));
return NULL;
}
@@ -595,12 +588,11 @@ typy_range (PyObject *self, PyObject *args)
/* Initialize these to appease GCC warnings. */
LONGEST low = 0, high = 0;
- if (type->code () != TYPE_CODE_ARRAY
- && type->code () != TYPE_CODE_STRING
+ if (type->code () != TYPE_CODE_ARRAY && type->code () != TYPE_CODE_STRING
&& type->code () != TYPE_CODE_RANGE)
{
PyErr_SetString (PyExc_RuntimeError,
- _("This type does not have a range."));
+ _ ("This type does not have a range."));
return NULL;
}
@@ -665,8 +657,7 @@ typy_target (PyObject *self, PyObject *args)
if (!type->target_type ())
{
- PyErr_SetString (PyExc_RuntimeError,
- _("Type does not have a target."));
+ PyErr_SetString (PyExc_RuntimeError, _ ("Type does not have a target."));
return NULL;
}
@@ -807,8 +798,7 @@ typy_lookup_typename (const char *type_name, const struct block *block)
else if (startswith (type_name, "enum "))
type = lookup_enum (type_name + 5, NULL);
else
- type = lookup_typename (current_language,
- type_name, block, 0);
+ type = lookup_typename (current_language, type_name, block, 0);
}
catch (const gdb_exception &except)
{
@@ -836,7 +826,7 @@ typy_lookup_type (struct demangle_component *demangled,
|| demangled_type == DEMANGLE_COMPONENT_VOLATILE)
{
type = typy_lookup_type (demangled->u.s_binary.left, block);
- if (! type)
+ if (!type)
return NULL;
try
@@ -897,7 +887,7 @@ typy_legacy_template_argument (struct type *type, const struct block *block,
if (type->name () == NULL)
{
- PyErr_SetString (PyExc_RuntimeError, _("Null type name."));
+ PyErr_SetString (PyExc_RuntimeError, _ ("Null type name."));
return NULL;
}
@@ -911,7 +901,7 @@ typy_legacy_template_argument (struct type *type, const struct block *block,
GDB_PY_HANDLE_EXCEPTION (except);
}
- if (! info)
+ if (!info)
{
PyErr_SetString (PyExc_RuntimeError, err.c_str ());
return NULL;
@@ -925,7 +915,7 @@ typy_legacy_template_argument (struct type *type, const struct block *block,
if (demangled->type != DEMANGLE_COMPONENT_TEMPLATE)
{
- PyErr_SetString (PyExc_RuntimeError, _("Type is not a template."));
+ PyErr_SetString (PyExc_RuntimeError, _ ("Type is not a template."));
return NULL;
}
@@ -935,15 +925,15 @@ typy_legacy_template_argument (struct type *type, const struct block *block,
for (i = 0; demangled && i < argno; ++i)
demangled = demangled->u.s_binary.right;
- if (! demangled)
+ if (!demangled)
{
- PyErr_Format (PyExc_RuntimeError, _("No argument %d in template."),
+ PyErr_Format (PyExc_RuntimeError, _ ("No argument %d in template."),
argno);
return NULL;
}
argtype = typy_lookup_type (demangled->u.s_binary.left, block);
- if (! argtype)
+ if (!argtype)
return NULL;
return type_to_type_object (argtype);
@@ -959,23 +949,23 @@ typy_template_argument (PyObject *self, PyObject *args)
struct symbol *sym;
struct value *val = NULL;
- if (! PyArg_ParseTuple (args, "i|O", &argno, &block_obj))
+ if (!PyArg_ParseTuple (args, "i|O", &argno, &block_obj))
return NULL;
if (argno < 0)
{
PyErr_SetString (PyExc_RuntimeError,
- _("Template argument number must be non-negative"));
+ _ ("Template argument number must be non-negative"));
return NULL;
}
if (block_obj)
{
block = block_object_to_block (block_obj);
- if (! block)
+ if (!block)
{
PyErr_SetString (PyExc_RuntimeError,
- _("Second argument must be block."));
+ _ ("Second argument must be block."));
return NULL;
}
}
@@ -994,12 +984,12 @@ typy_template_argument (PyObject *self, PyObject *args)
/* We might not have DW_TAG_template_*, so try to parse the type's
name. This is inefficient if we do not have a template type --
but that is going to wind up as an error anyhow. */
- if (! TYPE_N_TEMPLATE_ARGUMENTS (type))
+ if (!TYPE_N_TEMPLATE_ARGUMENTS (type))
return typy_legacy_template_argument (type, block, argno);
if (argno >= TYPE_N_TEMPLATE_ARGUMENTS (type))
{
- PyErr_Format (PyExc_RuntimeError, _("No argument %d in template."),
+ PyErr_Format (PyExc_RuntimeError, _ ("No argument %d in template."),
argno);
return NULL;
}
@@ -1010,7 +1000,7 @@ typy_template_argument (PyObject *self, PyObject *args)
else if (sym->aclass () == LOC_OPTIMIZED_OUT)
{
PyErr_Format (PyExc_RuntimeError,
- _("Template argument is optimized out"));
+ _ ("Template argument is optimized out"));
return NULL;
}
@@ -1033,17 +1023,16 @@ typy_str (PyObject *self)
try
{
- current_language->print_type (type_object_to_type (self), "",
- &thetype, -1, 0,
- &type_print_raw_options);
+ current_language->print_type (type_object_to_type (self), "", &thetype,
+ -1, 0, &type_print_raw_options);
}
catch (const gdb_exception &except)
{
GDB_PY_HANDLE_EXCEPTION (except);
}
- return PyUnicode_Decode (thetype.c_str (), thetype.size (),
- host_charset (), NULL);
+ return PyUnicode_Decode (thetype.c_str (), thetype.size (), host_charset (),
+ NULL);
}
/* Implement the richcompare method. */
@@ -1084,8 +1073,6 @@ typy_richcompare (PyObject *self, PyObject *other, int op)
Py_RETURN_FALSE;
}
-
-
/* Deleter that saves types when an objfile is being destroyed. */
struct typy_deleter
{
@@ -1117,7 +1104,7 @@ struct typy_deleter
};
static const registry<objfile>::key<type_object, typy_deleter>
- typy_objfile_data_key;
+ typy_objfile_data_key;
static void
set_type (type_object *obj, struct type *type)
@@ -1291,10 +1278,10 @@ typy_make_iter (PyObject *self, enum gdbpy_iter_kind kind)
if (typy_get_composite (((type_object *) self)->type) == NULL)
return NULL;
- typy_iter_obj = PyObject_New (typy_iterator_object,
- &type_iterator_object_type);
+ typy_iter_obj
+ = PyObject_New (typy_iterator_object, &type_iterator_object_type);
if (typy_iter_obj == NULL)
- return NULL;
+ return NULL;
typy_iter_obj->field = 0;
typy_iter_obj->kind = kind;
@@ -1357,8 +1344,8 @@ typy_iterator_iternext (PyObject *self)
if (iter_obj->field < type->num_fields ())
{
- gdbpy_ref<> result = make_fielditem (type, iter_obj->field,
- iter_obj->kind);
+ gdbpy_ref<> result
+ = make_fielditem (type, iter_obj->field, iter_obj->kind);
if (result != NULL)
iter_obj->field++;
return result.release ();
@@ -1403,13 +1390,11 @@ type_to_type_object (struct type *type)
struct type *
type_object_to_type (PyObject *obj)
{
- if (! PyObject_TypeCheck (obj, &type_object_type))
+ if (!PyObject_TypeCheck (obj, &type_object_type))
return NULL;
return ((type_object *) obj)->type;
}
-
-
/* Implementation of gdb.lookup_type. */
PyObject *
gdbpy_lookup_type (PyObject *self, PyObject *args, PyObject *kw)
@@ -1420,23 +1405,23 @@ gdbpy_lookup_type (PyObject *self, PyObject *args, PyObject *kw)
PyObject *block_obj = NULL;
const struct block *block = NULL;
- if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "s|O", keywords,
- &type_name, &block_obj))
+ if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "s|O", keywords, &type_name,
+ &block_obj))
return NULL;
if (block_obj)
{
block = block_object_to_block (block_obj);
- if (! block)
+ if (!block)
{
PyErr_SetString (PyExc_RuntimeError,
- _("'block' argument must be a Block."));
+ _ ("'block' argument must be a Block."));
return NULL;
}
}
type = typy_lookup_typename (type_name, block);
- if (! type)
+ if (!type)
return NULL;
return type_to_type_object (type);
@@ -1459,266 +1444,238 @@ gdbpy_initialize_types (void)
}
if (gdb_pymodule_addobject (gdb_module, "Type",
- (PyObject *) &type_object_type) < 0)
+ (PyObject *) &type_object_type)
+ < 0)
return -1;
if (gdb_pymodule_addobject (gdb_module, "TypeIterator",
- (PyObject *) &type_iterator_object_type) < 0)
+ (PyObject *) &type_iterator_object_type)
+ < 0)
return -1;
return gdb_pymodule_addobject (gdb_module, "Field",
(PyObject *) &field_object_type);
}
-
-
-static gdb_PyGetSetDef type_object_getset[] =
-{
- { "alignof", typy_get_alignof, NULL,
- "The alignment of this type, in bytes.", NULL },
- { "code", typy_get_code, NULL,
- "The code for this type.", NULL },
- { "dynamic", typy_get_dynamic, NULL,
- "Whether this type is dynamic.", NULL },
- { "name", typy_get_name, NULL,
- "The name for this type, or None.", NULL },
- { "sizeof", typy_get_sizeof, NULL,
- "The size of this type, in bytes.", NULL },
- { "tag", typy_get_tag, NULL,
- "The tag name for this type, or None.", NULL },
+static gdb_PyGetSetDef type_object_getset[] = {
+ { "alignof", typy_get_alignof, NULL, "The alignment of this type, in bytes.",
+ NULL },
+ { "code", typy_get_code, NULL, "The code for this type.", NULL },
+ { "dynamic", typy_get_dynamic, NULL, "Whether this type is dynamic.", NULL },
+ { "name", typy_get_name, NULL, "The name for this type, or None.", NULL },
+ { "sizeof", typy_get_sizeof, NULL, "The size of this type, in bytes.",
+ NULL },
+ { "tag", typy_get_tag, NULL, "The tag name for this type, or None.", NULL },
{ "objfile", typy_get_objfile, NULL,
"The objfile this type was defined in, or None.", NULL },
- { "is_scalar", typy_is_scalar, nullptr,
- "Is this a scalar type?", nullptr },
- { "is_signed", typy_is_signed, nullptr,
- "Is this an signed type?", nullptr },
+ { "is_scalar", typy_is_scalar, nullptr, "Is this a scalar type?", nullptr },
+ { "is_signed", typy_is_signed, nullptr, "Is this an signed type?", nullptr },
{ NULL }
};
-static PyMethodDef type_object_methods[] =
-{
- { "array", typy_array, METH_VARARGS,
- "array ([LOW_BOUND,] HIGH_BOUND) -> Type\n\
+static PyMethodDef type_object_methods[]
+ = { { "array", typy_array, METH_VARARGS,
+ "array ([LOW_BOUND,] HIGH_BOUND) -> Type\n\
Return a type which represents an array of objects of this type.\n\
The bounds of the array are [LOW_BOUND, HIGH_BOUND] inclusive.\n\
If LOW_BOUND is omitted, a value of zero is used." },
- { "vector", typy_vector, METH_VARARGS,
- "vector ([LOW_BOUND,] HIGH_BOUND) -> Type\n\
+ { "vector", typy_vector, METH_VARARGS,
+ "vector ([LOW_BOUND,] HIGH_BOUND) -> Type\n\
Return a type which represents a vector of objects of this type.\n\
The bounds of the array are [LOW_BOUND, HIGH_BOUND] inclusive.\n\
If LOW_BOUND is omitted, a value of zero is used.\n\
Vectors differ from arrays in that if the current language has C-style\n\
arrays, vectors don't decay to a pointer to the first element.\n\
They are first class values." },
- { "__contains__", typy_has_key, METH_VARARGS,
- "T.__contains__(k) -> True if T has a field named k, else False" },
- { "const", typy_const, METH_NOARGS,
- "const () -> Type\n\
+ { "__contains__", typy_has_key, METH_VARARGS,
+ "T.__contains__(k) -> True if T has a field named k, else False" },
+ { "const", typy_const, METH_NOARGS, "const () -> Type\n\
Return a const variant of this type." },
- { "optimized_out", typy_optimized_out, METH_NOARGS,
- "optimized_out() -> Value\n\
+ { "optimized_out", typy_optimized_out, METH_NOARGS,
+ "optimized_out() -> Value\n\
Return optimized out value of this type." },
- { "fields", typy_fields, METH_NOARGS,
- "fields () -> list\n\
+ { "fields", typy_fields, METH_NOARGS, "fields () -> list\n\
Return a list holding all the fields of this type.\n\
Each field is a gdb.Field object." },
- { "get", typy_get, METH_VARARGS,
- "T.get(k[,default]) -> returns field named k in T, if it exists;\n\
+ { "get", typy_get, METH_VARARGS,
+ "T.get(k[,default]) -> returns field named k in T, if it exists;\n\
otherwise returns default, if supplied, or None if not." },
- { "has_key", typy_has_key, METH_VARARGS,
- "T.has_key(k) -> True if T has a field named k, else False" },
- { "items", typy_items, METH_NOARGS,
- "items () -> list\n\
+ { "has_key", typy_has_key, METH_VARARGS,
+ "T.has_key(k) -> True if T has a field named k, else False" },
+ { "items", typy_items, METH_NOARGS, "items () -> list\n\
Return a list of (name, field) pairs of this type.\n\
Each field is a gdb.Field object." },
- { "iteritems", typy_iteritems, METH_NOARGS,
- "iteritems () -> an iterator over the (name, field)\n\
+ { "iteritems", typy_iteritems, METH_NOARGS,
+ "iteritems () -> an iterator over the (name, field)\n\
pairs of this type. Each field is a gdb.Field object." },
- { "iterkeys", typy_iterkeys, METH_NOARGS,
- "iterkeys () -> an iterator over the field names of this type." },
- { "itervalues", typy_itervalues, METH_NOARGS,
- "itervalues () -> an iterator over the fields of this type.\n\
+ { "iterkeys", typy_iterkeys, METH_NOARGS,
+ "iterkeys () -> an iterator over the field names of this type." },
+ { "itervalues", typy_itervalues, METH_NOARGS,
+ "itervalues () -> an iterator over the fields of this type.\n\
Each field is a gdb.Field object." },
- { "keys", typy_field_names, METH_NOARGS,
- "keys () -> list\n\
+ { "keys", typy_field_names, METH_NOARGS, "keys () -> list\n\
Return a list holding all the fields names of this type." },
- { "pointer", typy_pointer, METH_NOARGS,
- "pointer () -> Type\n\
+ { "pointer", typy_pointer, METH_NOARGS, "pointer () -> Type\n\
Return a type of pointer to this type." },
- { "range", typy_range, METH_NOARGS,
- "range () -> tuple\n\
-Return a tuple containing the lower and upper range for this type."},
- { "reference", typy_reference, METH_NOARGS,
- "reference () -> Type\n\
+ { "range", typy_range, METH_NOARGS, "range () -> tuple\n\
+Return a tuple containing the lower and upper range for this type." },
+ { "reference", typy_reference, METH_NOARGS, "reference () -> Type\n\
Return a type of reference to this type." },
- { "strip_typedefs", typy_strip_typedefs, METH_NOARGS,
- "strip_typedefs () -> Type\n\
-Return a type formed by stripping this type of all typedefs."},
- { "target", typy_target, METH_NOARGS,
- "target () -> Type\n\
+ { "strip_typedefs", typy_strip_typedefs, METH_NOARGS,
+ "strip_typedefs () -> Type\n\
+Return a type formed by stripping this type of all typedefs." },
+ { "target", typy_target, METH_NOARGS, "target () -> Type\n\
Return the target type of this type." },
- { "template_argument", typy_template_argument, METH_VARARGS,
- "template_argument (arg, [block]) -> Type\n\
+ { "template_argument", typy_template_argument, METH_VARARGS,
+ "template_argument (arg, [block]) -> Type\n\
Return the type of a template argument." },
- { "unqualified", typy_unqualified, METH_NOARGS,
- "unqualified () -> Type\n\
+ { "unqualified", typy_unqualified, METH_NOARGS,
+ "unqualified () -> Type\n\
Return a variant of this type without const or volatile attributes." },
- { "values", typy_values, METH_NOARGS,
- "values () -> list\n\
+ { "values", typy_values, METH_NOARGS, "values () -> list\n\
Return a list holding all the fields of this type.\n\
Each field is a gdb.Field object." },
- { "volatile", typy_volatile, METH_NOARGS,
- "volatile () -> Type\n\
+ { "volatile", typy_volatile, METH_NOARGS, "volatile () -> Type\n\
Return a volatile variant of this type" },
- { NULL }
-};
+ { NULL } };
static PyNumberMethods type_object_as_number = {
- NULL, /* nb_add */
- NULL, /* nb_subtract */
- NULL, /* nb_multiply */
- NULL, /* nb_remainder */
- NULL, /* nb_divmod */
- NULL, /* nb_power */
- NULL, /* nb_negative */
- NULL, /* nb_positive */
- NULL, /* nb_absolute */
- typy_nonzero, /* nb_nonzero */
- NULL, /* nb_invert */
- NULL, /* nb_lshift */
- NULL, /* nb_rshift */
- NULL, /* nb_and */
- NULL, /* nb_xor */
- NULL, /* nb_or */
- NULL, /* nb_int */
- NULL, /* reserved */
- NULL, /* nb_float */
+ NULL, /* nb_add */
+ NULL, /* nb_subtract */
+ NULL, /* nb_multiply */
+ NULL, /* nb_remainder */
+ NULL, /* nb_divmod */
+ NULL, /* nb_power */
+ NULL, /* nb_negative */
+ NULL, /* nb_positive */
+ NULL, /* nb_absolute */
+ typy_nonzero, /* nb_nonzero */
+ NULL, /* nb_invert */
+ NULL, /* nb_lshift */
+ NULL, /* nb_rshift */
+ NULL, /* nb_and */
+ NULL, /* nb_xor */
+ NULL, /* nb_or */
+ NULL, /* nb_int */
+ NULL, /* reserved */
+ NULL, /* nb_float */
};
static PyMappingMethods typy_mapping = {
- typy_length,
- typy_getitem,
- NULL /* no "set" method */
+ typy_length, typy_getitem, NULL /* no "set" method */
};
-PyTypeObject type_object_type =
-{
- PyVarObject_HEAD_INIT (NULL, 0)
- "gdb.Type", /*tp_name*/
- sizeof (type_object), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- typy_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- &type_object_as_number, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- &typy_mapping, /*tp_as_mapping*/
- 0, /*tp_hash */
- 0, /*tp_call*/
- typy_str, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- "GDB type object", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- typy_richcompare, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- typy_iter, /* tp_iter */
- 0, /* tp_iternext */
- type_object_methods, /* tp_methods */
- 0, /* tp_members */
- type_object_getset, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- 0, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+PyTypeObject type_object_type = {
+ PyVarObject_HEAD_INIT (NULL, 0) "gdb.Type", /*tp_name*/
+ sizeof (type_object), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ typy_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ &type_object_as_number, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ &typy_mapping, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ typy_str, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT, /*tp_flags*/
+ "GDB type object", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ typy_richcompare, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ typy_iter, /* tp_iter */
+ 0, /* tp_iternext */
+ type_object_methods, /* tp_methods */
+ 0, /* tp_members */
+ type_object_getset, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ 0, /* tp_new */
};
-static gdb_PyGetSetDef field_object_getset[] =
-{
- { "__dict__", gdb_py_generic_dict, NULL,
- "The __dict__ for this field.", &field_object_type },
- { NULL }
-};
-
-PyTypeObject field_object_type =
-{
- PyVarObject_HEAD_INIT (NULL, 0)
- "gdb.Field", /*tp_name*/
- sizeof (field_object), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- field_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- "GDB field object", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- field_object_getset, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- offsetof (field_object, dict), /* tp_dictoffset */
- 0, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
+static gdb_PyGetSetDef field_object_getset[]
+ = { { "__dict__", gdb_py_generic_dict, NULL, "The __dict__ for this field.",
+ &field_object_type },
+ { NULL } };
+
+PyTypeObject field_object_type = {
+ PyVarObject_HEAD_INIT (NULL, 0) "gdb.Field", /*tp_name*/
+ sizeof (field_object), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ field_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT, /*tp_flags*/
+ "GDB field object", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ 0, /* tp_methods */
+ 0, /* tp_members */
+ field_object_getset, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ offsetof (field_object, dict), /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ 0, /* tp_new */
};
PyTypeObject type_iterator_object_type = {
- PyVarObject_HEAD_INIT (NULL, 0)
- "gdb.TypeIterator", /*tp_name*/
- sizeof (typy_iterator_object), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- typy_iterator_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- "GDB type iterator object", /*tp_doc */
- 0, /*tp_traverse */
- 0, /*tp_clear */
- 0, /*tp_richcompare */
- 0, /*tp_weaklistoffset */
- typy_iterator_iter, /*tp_iter */
- typy_iterator_iternext, /*tp_iternext */
- 0 /*tp_methods */
+ PyVarObject_HEAD_INIT (NULL, 0) "gdb.TypeIterator", /*tp_name*/
+ sizeof (typy_iterator_object), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ typy_iterator_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT, /*tp_flags*/
+ "GDB type iterator object", /*tp_doc */
+ 0, /*tp_traverse */
+ 0, /*tp_clear */
+ 0, /*tp_richcompare */
+ 0, /*tp_weaklistoffset */
+ typy_iterator_iter, /*tp_iter */
+ typy_iterator_iternext, /*tp_iternext */
+ 0 /*tp_methods */
};
diff --git a/gdb/python/py-unwind.c b/gdb/python/py-unwind.c
index e7ec660..e4578a9 100644
--- a/gdb/python/py-unwind.c
+++ b/gdb/python/py-unwind.c
@@ -39,7 +39,7 @@ static void
show_pyuw_debug (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
{
- gdb_printf (file, _("Python unwinder debugging is %s.\n"), value);
+ gdb_printf (file, _ ("Python unwinder debugging is %s.\n"), value);
}
/* Print a "py-unwind" debug statement. */
@@ -56,8 +56,8 @@ struct pending_frame_object
{
PyObject_HEAD
- /* Frame we are unwinding. */
- frame_info_ptr frame_info;
+ /* Frame we are unwinding. */
+ frame_info_ptr frame_info;
/* Its architecture, passed by the sniffer caller. */
struct gdbarch *gdbarch;
@@ -84,8 +84,8 @@ struct unwind_info_object
{
PyObject_HEAD
- /* gdb.PendingFrame for the frame we are unwinding. */
- PyObject *pending_frame;
+ /* gdb.PendingFrame for the frame we are unwinding. */
+ PyObject *pending_frame;
/* Its ID. */
struct frame_id frame_id;
@@ -112,10 +112,10 @@ struct cached_frame_info
};
extern PyTypeObject pending_frame_object_type
- CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("pending_frame_object");
+ CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("pending_frame_object");
extern PyTypeObject unwind_info_object_type
- CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("unwind_info_object");
+ CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("unwind_info_object");
/* Convert gdb.Value instance to inferior's pointer. Return 1 on success,
0 on failure. */
@@ -163,9 +163,9 @@ pyuw_object_attribute_to_pointer (PyObject *pyo, const char *attr_name,
rc = pyuw_value_obj_to_pointer (pyo_value.get (), addr);
if (!rc)
PyErr_Format (
- PyExc_ValueError,
- _("The value of the '%s' attribute is not a pointer."),
- attr_name);
+ PyExc_ValueError,
+ _ ("The value of the '%s' attribute is not a pointer."),
+ attr_name);
}
}
return rc;
@@ -218,11 +218,10 @@ unwind_infopy_str (PyObject *self)
Sets Python error and returns NULL on error. */
static PyObject *
-pyuw_create_unwind_info (PyObject *pyo_pending_frame,
- struct frame_id frame_id)
+pyuw_create_unwind_info (PyObject *pyo_pending_frame, struct frame_id frame_id)
{
unwind_info_object *unwind_info
- = PyObject_New (unwind_info_object, &unwind_info_object_type);
+ = PyObject_New (unwind_info_object, &unwind_info_object_type);
if (((pending_frame_object *) pyo_pending_frame)->frame_info == NULL)
{
@@ -245,7 +244,7 @@ unwind_infopy_add_saved_register (PyObject *self, PyObject *args)
{
unwind_info_object *unwind_info = (unwind_info_object *) self;
pending_frame_object *pending_frame
- = (pending_frame_object *) (unwind_info->pending_frame);
+ = (pending_frame_object *) (unwind_info->pending_frame);
PyObject *pyo_reg_id;
PyObject *pyo_reg_value;
int regnum;
@@ -256,8 +255,8 @@ unwind_infopy_add_saved_register (PyObject *self, PyObject *args)
"UnwindInfo instance refers to a stale PendingFrame");
return NULL;
}
- if (!PyArg_UnpackTuple (args, "previous_frame_register", 2, 2,
- &pyo_reg_id, &pyo_reg_value))
+ if (!PyArg_UnpackTuple (args, "previous_frame_register", 2, 2, &pyo_reg_id,
+ &pyo_reg_value))
return NULL;
if (!gdbpy_parse_register_id (pending_frame->gdbarch, pyo_reg_id, &regnum))
return nullptr;
@@ -286,7 +285,7 @@ unwind_infopy_add_saved_register (PyObject *self, PyObject *args)
size_t data_size;
if (pyo_reg_value == NULL
- || (value = value_object_to_value (pyo_reg_value)) == NULL)
+ || (value = value_object_to_value (pyo_reg_value)) == NULL)
{
PyErr_SetString (PyExc_ValueError, "Bad register value");
return NULL;
@@ -294,12 +293,11 @@ unwind_infopy_add_saved_register (PyObject *self, PyObject *args)
data_size = register_size (pending_frame->gdbarch, regnum);
if (data_size != value_type (value)->length ())
{
- PyErr_Format (
- PyExc_ValueError,
- "The value of the register returned by the Python "
- "sniffer has unexpected size: %u instead of %u.",
- (unsigned) value_type (value)->length (),
- (unsigned) data_size);
+ PyErr_Format (PyExc_ValueError,
+ "The value of the register returned by the Python "
+ "sniffer has unexpected size: %u instead of %u.",
+ (unsigned) value_type (value)->length (),
+ (unsigned) data_size);
return NULL;
}
}
@@ -389,8 +387,7 @@ pending_framepy_read_register (PyObject *self, PyObject *args)
handle the user register case. */
val = value_of_register (regnum, pending_frame->frame_info);
if (val == NULL)
- PyErr_Format (PyExc_ValueError,
- "Cannot read register %d from frame.",
+ PyErr_Format (PyExc_ValueError, "Cannot read register %d from frame.",
regnum);
}
catch (const gdb_exception &except)
@@ -413,11 +410,11 @@ pending_framepy_create_unwind_info (PyObject *self, PyObject *args)
CORE_ADDR special;
if (!PyArg_ParseTuple (args, "O:create_unwind_info", &pyo_frame_id))
- return NULL;
+ return NULL;
if (!pyuw_object_attribute_to_pointer (pyo_frame_id, "sp", &sp))
{
PyErr_SetString (PyExc_ValueError,
- _("frame_id should have 'sp' attribute."));
+ _ ("frame_id should have 'sp' attribute."));
return NULL;
}
@@ -464,8 +461,9 @@ pending_framepy_level (PyObject *self, PyObject *args)
if (pending_frame->frame_info == NULL)
{
- PyErr_SetString (PyExc_ValueError,
- "Attempting to read stack level from stale PendingFrame");
+ PyErr_SetString (
+ PyExc_ValueError,
+ "Attempting to read stack level from stale PendingFrame");
return NULL;
}
int level = frame_relative_level (pending_frame->frame_info);
@@ -485,8 +483,7 @@ pyuw_this_id (frame_info_ptr this_frame, void **cache_ptr,
/* frame_unwind.prev_register. */
static struct value *
-pyuw_prev_register (frame_info_ptr this_frame, void **cache_ptr,
- int regnum)
+pyuw_prev_register (frame_info_ptr this_frame, void **cache_ptr, int regnum)
{
PYUW_SCOPED_DEBUG_ENTER_EXIT;
@@ -494,8 +491,8 @@ pyuw_prev_register (frame_info_ptr this_frame, void **cache_ptr,
cached_reg_t *reg_info = cached_frame->reg;
cached_reg_t *reg_info_end = reg_info + cached_frame->reg_count;
- pyuw_debug_printf ("frame=%d, reg=%d",
- frame_relative_level (this_frame), regnum);
+ pyuw_debug_printf ("frame=%d, reg=%d", frame_relative_level (this_frame),
+ regnum);
for (; reg_info < reg_info_end; ++reg_info)
{
if (regnum == reg_info->num)
@@ -524,8 +521,8 @@ pyuw_sniffer (const struct frame_unwind *self, frame_info_ptr this_frame,
paddress (gdbarch, get_frame_pc (this_frame)));
/* Create PendingFrame instance to pass to sniffers. */
- pending_frame_object *pfo = PyObject_New (pending_frame_object,
- &pending_frame_object_type);
+ pending_frame_object *pfo
+ = PyObject_New (pending_frame_object, &pending_frame_object_type);
gdbpy_ref<> pyo_pending_frame ((PyObject *) pfo);
if (pyo_pending_frame == NULL)
{
@@ -533,12 +530,12 @@ pyuw_sniffer (const struct frame_unwind *self, frame_info_ptr this_frame,
return 0;
}
pfo->gdbarch = gdbarch;
- scoped_restore invalidate_frame = make_scoped_restore (&pfo->frame_info,
- this_frame);
+ scoped_restore invalidate_frame
+ = make_scoped_restore (&pfo->frame_info, this_frame);
/* Run unwinders. */
if (gdb_python_module == NULL
- || ! PyObject_HasAttrString (gdb_python_module, "_execute_unwinders"))
+ || !PyObject_HasAttrString (gdb_python_module, "_execute_unwinders"))
{
PyErr_SetString (PyExc_NameError,
"Installation error: gdb._execute_unwinders function "
@@ -555,9 +552,8 @@ pyuw_sniffer (const struct frame_unwind *self, frame_info_ptr this_frame,
}
/* A (gdb.UnwindInfo, str) tuple, or None. */
- gdbpy_ref<> pyo_execute_ret
- (PyObject_CallFunctionObjArgs (pyo_execute.get (),
- pyo_pending_frame.get (), NULL));
+ gdbpy_ref<> pyo_execute_ret (PyObject_CallFunctionObjArgs (
+ pyo_execute.get (), pyo_pending_frame.get (), NULL));
if (pyo_execute_ret == nullptr)
{
/* If the unwinder is cancelled due to a Ctrl-C, then propagate
@@ -574,7 +570,8 @@ pyuw_sniffer (const struct frame_unwind *self, frame_info_ptr this_frame,
if (pyuw_debug)
{
- PyObject *pyo_unwinder_name = PyTuple_GET_ITEM (pyo_execute_ret.get (), 1);
+ PyObject *pyo_unwinder_name
+ = PyTuple_GET_ITEM (pyo_execute_ret.get (), 1);
gdb::unique_xmalloc_ptr<char> name
= python_string_to_host_string (pyo_unwinder_name);
@@ -592,18 +589,16 @@ pyuw_sniffer (const struct frame_unwind *self, frame_info_ptr this_frame,
/* Received UnwindInfo, cache data. */
PyObject *pyo_unwind_info = PyTuple_GET_ITEM (pyo_execute_ret.get (), 0);
if (PyObject_IsInstance (pyo_unwind_info,
- (PyObject *) &unwind_info_object_type) <= 0)
- error (_("A Unwinder should return gdb.UnwindInfo instance."));
+ (PyObject *) &unwind_info_object_type)
+ <= 0)
+ error (_ ("A Unwinder should return gdb.UnwindInfo instance."));
{
- unwind_info_object *unwind_info =
- (unwind_info_object *) pyo_unwind_info;
+ unwind_info_object *unwind_info = (unwind_info_object *) pyo_unwind_info;
int reg_count = unwind_info->saved_regs->size ();
- cached_frame
- = ((cached_frame_info *)
- xmalloc (sizeof (*cached_frame)
- + reg_count * sizeof (cached_frame->reg[0])));
+ cached_frame = ((cached_frame_info *) xmalloc (
+ sizeof (*cached_frame) + reg_count * sizeof (cached_frame->reg[0])));
cached_frame->gdbarch = gdbarch;
cached_frame->frame_id = unwind_info->frame_id;
cached_frame->reg_count = reg_count;
@@ -623,8 +618,8 @@ pyuw_sniffer (const struct frame_unwind *self, frame_info_ptr this_frame,
gdb_assert (data_size == value_type (value)->length ());
cached_frame->reg[i].data = (gdb_byte *) xmalloc (data_size);
- memcpy (cached_frame->reg[i].data,
- value_contents (value).data (), data_size);
+ memcpy (cached_frame->reg[i].data, value_contents (value).data (),
+ data_size);
}
}
@@ -662,12 +657,12 @@ pyuw_on_new_gdbarch (struct gdbarch *newarch)
{
struct pyuw_gdbarch_data_type *data = pyuw_gdbarch_data.get (newarch);
if (data == nullptr)
- data= pyuw_gdbarch_data.emplace (newarch);
+ data = pyuw_gdbarch_data.emplace (newarch);
if (!data->unwinder_registered)
{
struct frame_unwind *unwinder
- = GDBARCH_OBSTACK_ZALLOC (newarch, struct frame_unwind);
+ = GDBARCH_OBSTACK_ZALLOC (newarch, struct frame_unwind);
unwinder->name = "python";
unwinder->type = NORMAL_FRAME;
@@ -683,17 +678,16 @@ pyuw_on_new_gdbarch (struct gdbarch *newarch)
}
void _initialize_py_unwind ();
+
void
_initialize_py_unwind ()
{
- add_setshow_boolean_cmd
- ("py-unwind", class_maintenance, &pyuw_debug,
- _("Set Python unwinder debugging."),
- _("Show Python unwinder debugging."),
- _("When on, Python unwinder debugging is enabled."),
- NULL,
- show_pyuw_debug,
- &setdebuglist, &showdebuglist);
+ add_setshow_boolean_cmd (
+ "py-unwind", class_maintenance, &pyuw_debug,
+ _ ("Set Python unwinder debugging."),
+ _ ("Show Python unwinder debugging."),
+ _ ("When on, Python unwinder debugging is enabled."), NULL,
+ show_pyuw_debug, &setdebuglist, &showdebuglist);
}
/* Initialize unwind machinery. */
@@ -714,115 +708,106 @@ gdbpy_initialize_unwind (void)
if (PyType_Ready (&unwind_info_object_type) < 0)
return -1;
return gdb_pymodule_addobject (gdb_module, "UnwindInfo",
- (PyObject *) &unwind_info_object_type);
+ (PyObject *) &unwind_info_object_type);
}
-static PyMethodDef pending_frame_object_methods[] =
-{
+static PyMethodDef pending_frame_object_methods[] = {
{ "read_register", pending_framepy_read_register, METH_VARARGS,
"read_register (REG) -> gdb.Value\n"
"Return the value of the REG in the frame." },
- { "create_unwind_info",
- pending_framepy_create_unwind_info, METH_VARARGS,
+ { "create_unwind_info", pending_framepy_create_unwind_info, METH_VARARGS,
"create_unwind_info (FRAME_ID) -> gdb.UnwindInfo\n"
"Construct UnwindInfo for this PendingFrame, using FRAME_ID\n"
"to identify it." },
- { "architecture",
- pending_framepy_architecture, METH_NOARGS,
+ { "architecture", pending_framepy_architecture, METH_NOARGS,
"architecture () -> gdb.Architecture\n"
"The architecture for this PendingFrame." },
{ "level", pending_framepy_level, METH_NOARGS,
"The stack level of this frame." },
- {NULL} /* Sentinel */
+ { NULL } /* Sentinel */
};
-PyTypeObject pending_frame_object_type =
-{
- PyVarObject_HEAD_INIT (NULL, 0)
- "gdb.PendingFrame", /* tp_name */
- sizeof (pending_frame_object), /* tp_basicsize */
- 0, /* tp_itemsize */
- 0, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_compare */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- pending_framepy_str, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT, /* tp_flags */
- "GDB PendingFrame object", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- pending_frame_object_methods, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- 0, /* tp_init */
- 0, /* tp_alloc */
+PyTypeObject pending_frame_object_type = {
+ PyVarObject_HEAD_INIT (NULL, 0) "gdb.PendingFrame", /* tp_name */
+ sizeof (pending_frame_object), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ 0, /* tp_dealloc */
+ 0, /* tp_print */
+ 0, /* tp_getattr */
+ 0, /* tp_setattr */
+ 0, /* tp_compare */
+ 0, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ pending_framepy_str, /* tp_str */
+ 0, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ "GDB PendingFrame object", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ pending_frame_object_methods, /* tp_methods */
+ 0, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
};
-static PyMethodDef unwind_info_object_methods[] =
-{
- { "add_saved_register",
- unwind_infopy_add_saved_register, METH_VARARGS,
+static PyMethodDef unwind_info_object_methods[] = {
+ { "add_saved_register", unwind_infopy_add_saved_register, METH_VARARGS,
"add_saved_register (REG, VALUE) -> None\n"
"Set the value of the REG in the previous frame to VALUE." },
- { NULL } /* Sentinel */
+ { NULL } /* Sentinel */
};
-PyTypeObject unwind_info_object_type =
-{
- PyVarObject_HEAD_INIT (NULL, 0)
- "gdb.UnwindInfo", /* tp_name */
- sizeof (unwind_info_object), /* tp_basicsize */
- 0, /* tp_itemsize */
- unwind_infopy_dealloc, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_compare */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- unwind_infopy_str, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- "GDB UnwindInfo object", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- unwind_info_object_methods, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- 0, /* tp_init */
- 0, /* tp_alloc */
+PyTypeObject unwind_info_object_type = {
+ PyVarObject_HEAD_INIT (NULL, 0) "gdb.UnwindInfo", /* tp_name */
+ sizeof (unwind_info_object), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ unwind_infopy_dealloc, /* tp_dealloc */
+ 0, /* tp_print */
+ 0, /* tp_getattr */
+ 0, /* tp_setattr */
+ 0, /* tp_compare */
+ 0, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ unwind_infopy_str, /* tp_str */
+ 0, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ "GDB UnwindInfo object", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ unwind_info_object_methods, /* tp_methods */
+ 0, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
};
diff --git a/gdb/python/py-utils.c b/gdb/python/py-utils.c
index 624b90a..a65cf3c 100644
--- a/gdb/python/py-utils.c
+++ b/gdb/python/py-utils.c
@@ -47,8 +47,7 @@ python_string_to_unicode (PyObject *obj)
}
else
{
- PyErr_SetString (PyExc_TypeError,
- _("Expected a string object."));
+ PyErr_SetString (PyExc_TypeError, _ ("Expected a string object."));
unicode_str = NULL;
}
@@ -67,8 +66,8 @@ unicode_to_encoded_string (PyObject *unicode_str, const char *charset)
if (string == NULL)
return NULL;
- return gdb::unique_xmalloc_ptr<char>
- (xstrdup (PyBytes_AsString (string.get ())));
+ return gdb::unique_xmalloc_ptr<char> (
+ xstrdup (PyBytes_AsString (string.get ())));
}
/* Returns a PyObject with the contents of the given unicode string
@@ -89,9 +88,8 @@ unicode_to_encoded_python_string (PyObject *unicode_str, const char *charset)
gdb::unique_xmalloc_ptr<char>
unicode_to_target_string (PyObject *unicode_str)
{
- return (unicode_to_encoded_string
- (unicode_str,
- target_charset (gdbpy_enter::get_gdbarch ())));
+ return (unicode_to_encoded_string (
+ unicode_str, target_charset (gdbpy_enter::get_gdbarch ())));
}
/* Returns a PyObject with the contents of the given unicode string
@@ -101,9 +99,8 @@ unicode_to_target_string (PyObject *unicode_str)
static gdbpy_ref<>
unicode_to_target_python_string (PyObject *unicode_str)
{
- return (unicode_to_encoded_python_string
- (unicode_str,
- target_charset (gdbpy_enter::get_gdbarch ())));
+ return (unicode_to_encoded_python_string (
+ unicode_str, target_charset (gdbpy_enter::get_gdbarch ())));
}
/* Converts a python string (8-bit or unicode) to a target string in
@@ -237,7 +234,6 @@ get_addr_from_python (PyObject *obj, CORE_ADDR *addr)
{
if (gdbpy_is_value_object (obj))
{
-
try
{
*addr = value_as_address (value_object_to_value (obj));
@@ -262,7 +258,7 @@ get_addr_from_python (PyObject *obj, CORE_ADDR *addr)
if (sizeof (val) > sizeof (CORE_ADDR) && ((CORE_ADDR) val) != val)
{
PyErr_SetString (PyExc_ValueError,
- _("Overflow converting to address."));
+ _ ("Overflow converting to address."));
return -1;
}
@@ -301,11 +297,9 @@ int
gdb_py_int_as_long (PyObject *obj, long *result)
{
*result = PyLong_AsLong (obj);
- return ! (*result == -1 && PyErr_Occurred ());
+ return !(*result == -1 && PyErr_Occurred ());
}
-
-
/* Generic implementation of the __dict__ attribute for objects that
have a dictionary. The CLOSURE argument should be the type object.
This only handles positive values for tp_dictoffset. */
@@ -318,7 +312,7 @@ gdb_py_generic_dict (PyObject *self, void *closure)
char *raw_ptr;
raw_ptr = (char *) self + type_obj->tp_dictoffset;
- result = * (PyObject **) raw_ptr;
+ result = *(PyObject **) raw_ptr;
Py_INCREF (result);
return result;
@@ -351,9 +345,9 @@ gdbpy_error (const char *fmt, ...)
const char *msg = str.c_str ();
if (msg != nullptr && *msg != '\0')
- error (_("Error occurred in Python: %s"), msg);
+ error (_ ("Error occurred in Python: %s"), msg);
else
- error (_("Error occurred in Python."));
+ error (_ ("Error occurred in Python."));
}
/* Handle a Python exception when the special gdb.GdbError treatment
@@ -372,9 +366,9 @@ gdbpy_handle_exception ()
{
/* An error occurred computing the string representation of the
error message. This is rare, but we should inform the user. */
- gdb_printf (_("An error occurred in Python "
- "and then another occurred computing the "
- "error message.\n"));
+ gdb_printf (_ ("An error occurred in Python "
+ "and then another occurred computing the "
+ "error message.\n"));
gdbpy_print_stack ();
}
@@ -387,15 +381,15 @@ gdbpy_handle_exception ()
if (fetched_error.type_matches (PyExc_KeyboardInterrupt))
throw_quit ("Quit");
- else if (! fetched_error.type_matches (gdbpy_gdberror_exc)
- || msg == NULL || *msg == '\0')
+ else if (!fetched_error.type_matches (gdbpy_gdberror_exc) || msg == NULL
+ || *msg == '\0')
{
fetched_error.restore ();
gdbpy_print_stack ();
if (msg != NULL && *msg != '\0')
- error (_("Error occurred in Python: %s"), msg.get ());
+ error (_ ("Error occurred in Python: %s"), msg.get ());
else
- error (_("Error occurred in Python."));
+ error (_ ("Error occurred in Python."));
}
else
error ("%s", msg.get ());
@@ -415,17 +409,17 @@ gdbpy_fix_doc_string_indentation (gdb::unique_xmalloc_ptr<char> doc)
line_whitespace (size_t offset, int ws_count)
: m_offset (offset),
m_ws_count (ws_count)
- { /* Nothing. */ }
+ { /* Nothing. */
+ }
/* The offset from the start of DOC. */
- size_t offset () const
- { return m_offset; }
+ size_t offset () const { return m_offset; }
/* The number of white-space characters at the start of this line. */
- int ws () const
- { return m_ws_count; }
+ int ws () const { return m_ws_count; }
private:
+
/* The offset from the start of DOC to the first character of this
line. */
size_t m_offset;
@@ -438,8 +432,7 @@ gdbpy_fix_doc_string_indentation (gdb::unique_xmalloc_ptr<char> doc)
/* Count the number of white-space character starting at TXT. We
currently only count true single space characters, things like tabs,
newlines, etc are not counted. */
- auto count_whitespace = [] (const char *txt) -> int
- {
+ auto count_whitespace = [] (const char *txt) -> int {
int count = 0;
while (*txt == ' ')
@@ -559,8 +552,8 @@ gdbpy_fix_doc_string_indentation (gdb::unique_xmalloc_ptr<char> doc)
|| src[src_offset + ws_info[ws_info_offset].ws ()] == '\0')
src_offset += ws_info[ws_info_offset].ws ();
else
- src_offset += std::min (*min_whitespace,
- ws_info[ws_info_offset].ws ());
+ src_offset
+ += std::min (*min_whitespace, ws_info[ws_info_offset].ws ());
/* If we skipped white-space, and are now at the end of the
input, then we're done. */
diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c
index da25650..1578df1 100644
--- a/gdb/python/py-value.c
+++ b/gdb/python/py-value.c
@@ -47,8 +47,8 @@
builtin_type (gdbpy_enter::get_gdbarch ())->builtin_long_long
/* Python's long type corresponds to C's long long type. Unsigned version. */
-#define builtin_type_upylong builtin_type \
- (gdbpy_enter::get_gdbarch ())->builtin_unsigned_long_long
+#define builtin_type_upylong \
+ builtin_type (gdbpy_enter::get_gdbarch ())->builtin_unsigned_long_long
#define builtin_type_pybool \
language_bool_type (current_language, gdbpy_enter::get_gdbarch ())
@@ -56,9 +56,9 @@
#define builtin_type_pychar \
language_string_char_type (current_language, gdbpy_enter::get_gdbarch ())
-struct value_object {
- PyObject_HEAD
- struct value_object *next;
+struct value_object
+{
+ PyObject_HEAD struct value_object *next;
struct value_object *prev;
struct value *value;
PyObject *address;
@@ -144,7 +144,7 @@ convert_buffer_and_type_to_value (PyObject *obj, struct type *type)
Py_buffer_up buffer_up;
Py_buffer py_buf;
- if (PyObject_CheckBuffer (obj)
+ if (PyObject_CheckBuffer (obj)
&& PyObject_GetBuffer (obj, &py_buf, PyBUF_SIMPLE) == 0)
{
/* Got a buffer, py_buf, out of obj. Cause it to be released
@@ -154,14 +154,15 @@ convert_buffer_and_type_to_value (PyObject *obj, struct type *type)
else
{
PyErr_SetString (PyExc_TypeError,
- _("Object must support the python buffer protocol."));
+ _ ("Object must support the python buffer protocol."));
return nullptr;
}
if (type->length () > py_buf.len)
{
- PyErr_SetString (PyExc_ValueError,
- _("Size of type is larger than that of buffer object."));
+ PyErr_SetString (
+ PyExc_ValueError,
+ _ ("Size of type is larger than that of buffer object."));
return nullptr;
}
@@ -177,8 +178,8 @@ valpy_init (PyObject *self, PyObject *args, PyObject *kwds)
PyObject *val_obj = nullptr;
PyObject *type_obj = nullptr;
- if (!gdb_PyArg_ParseTupleAndKeywords (args, kwds, "O|O", keywords,
- &val_obj, &type_obj))
+ if (!gdb_PyArg_ParseTupleAndKeywords (args, kwds, "O|O", keywords, &val_obj,
+ &type_obj))
return -1;
struct type *type = nullptr;
@@ -188,7 +189,7 @@ valpy_init (PyObject *self, PyObject *args, PyObject *kwds)
if (type == nullptr)
{
PyErr_SetString (PyExc_TypeError,
- _("type argument must be a gdb.Type."));
+ _ ("type argument must be a gdb.Type."));
return -1;
}
}
@@ -282,8 +283,8 @@ valpy_referenced_value (PyObject *self, PyObject *args)
res_val = coerce_ref (self_val);
break;
default:
- error(_("Trying to get the referenced value from a value which is "
- "neither a pointer nor a reference."));
+ error (_ ("Trying to get the referenced value from a value which is "
+ "neither a pointer nor a reference."));
}
result = value_to_value_object (res_val);
@@ -490,13 +491,13 @@ valpy_lazy_string (PyObject *self, PyObject *args, PyObject *kw)
static const char *keywords[] = { "encoding", "length", NULL };
PyObject *str_obj = NULL;
- if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "|s" GDB_PY_LL_ARG,
- keywords, &user_encoding, &length))
+ if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "|s" GDB_PY_LL_ARG, keywords,
+ &user_encoding, &length))
return NULL;
if (length < -1)
{
- PyErr_SetString (PyExc_ValueError, _("Invalid length."));
+ PyErr_SetString (PyExc_ValueError, _ ("Invalid length."));
return NULL;
}
@@ -525,15 +526,15 @@ valpy_lazy_string (PyObject *self, PyObject *args, PyObject *kw)
length = array_length;
else if (array_length == -1)
{
- type = lookup_array_range_type (realtype->target_type (),
- 0, length - 1);
+ type = lookup_array_range_type (realtype->target_type (), 0,
+ length - 1);
}
else if (length != array_length)
{
/* We need to create a new array type with the
specified length. */
if (length > array_length)
- error (_("Length is larger than array size."));
+ error (_ ("Length is larger than array size."));
type = lookup_array_range_type (realtype->target_type (),
low_bound,
low_bound + length - 1);
@@ -552,8 +553,8 @@ valpy_lazy_string (PyObject *self, PyObject *args, PyObject *kw)
break;
}
- str_obj = gdbpy_create_lazy_string_object (addr, length, user_encoding,
- type);
+ str_obj
+ = gdbpy_create_lazy_string_object (addr, length, user_encoding, type);
}
catch (const gdb_exception &except)
{
@@ -597,8 +598,7 @@ valpy_string (PyObject *self, PyObject *args, PyObject *kw)
encoding = (user_encoding && *user_encoding) ? user_encoding : la_encoding;
return PyUnicode_Decode ((const char *) buffer.get (),
- length * char_type->length (),
- encoding, errors);
+ length * char_type->length (), encoding, errors);
}
/* Given a Python object, copy its truth value to a C bool (the value
@@ -629,31 +629,30 @@ copy_py_bool_obj (bool *dest, PyObject *src_obj)
static PyObject *
valpy_format_string (PyObject *self, PyObject *args, PyObject *kw)
{
- static const char *keywords[] =
- {
- /* Basic C/C++ options. */
- "raw", /* See the /r option to print. */
- "pretty_arrays", /* See set print array on|off. */
- "pretty_structs", /* See set print pretty on|off. */
- "array_indexes", /* See set print array-indexes on|off. */
- "symbols", /* See set print symbol on|off. */
- "unions", /* See set print union on|off. */
- "address", /* See set print address on|off. */
- "styling", /* Should we apply styling. */
- "nibbles", /* See set print nibbles on|off. */
- "summary", /* Summary mode for non-scalars. */
- /* C++ options. */
- "deref_refs", /* No corresponding setting. */
- "actual_objects", /* See set print object on|off. */
- "static_members", /* See set print static-members on|off. */
- /* C non-bool options. */
- "max_characters", /* See set print characters N. */
- "max_elements", /* See set print elements N. */
- "max_depth", /* See set print max-depth N. */
- "repeat_threshold", /* See set print repeats. */
- "format", /* The format passed to the print command. */
- NULL
- };
+ static const char *keywords[]
+ = { /* Basic C/C++ options. */
+ "raw", /* See the /r option to print. */
+ "pretty_arrays", /* See set print array on|off. */
+ "pretty_structs", /* See set print pretty on|off. */
+ "array_indexes", /* See set print array-indexes on|off. */
+ "symbols", /* See set print symbol on|off. */
+ "unions", /* See set print union on|off. */
+ "address", /* See set print address on|off. */
+ "styling", /* Should we apply styling. */
+ "nibbles", /* See set print nibbles on|off. */
+ "summary", /* Summary mode for non-scalars. */
+ /* C++ options. */
+ "deref_refs", /* No corresponding setting. */
+ "actual_objects", /* See set print object on|off. */
+ "static_members", /* See set print static-members on|off. */
+ /* C non-bool options. */
+ "max_characters", /* See set print characters N. */
+ "max_elements", /* See set print elements N. */
+ "max_depth", /* See set print max-depth N. */
+ "repeat_threshold", /* See set print repeats. */
+ "format", /* The format passed to the print command. */
+ NULL
+ };
/* This function has too many arguments to be useful as positionals, so
the user should specify them all as keyword arguments.
@@ -668,9 +667,10 @@ valpy_format_string (PyObject *self, PyObject *args, PyObject *kw)
/* This matches the error message that Python 3.3 raises when
passing positionals to functions expecting keyword-only
arguments. */
- PyErr_Format (PyExc_TypeError,
- "format_string() takes 0 positional arguments but %zu were given",
- positional_count);
+ PyErr_Format (
+ PyExc_TypeError,
+ "format_string() takes 0 positional arguments but %zu were given",
+ positional_count);
return NULL;
}
@@ -694,28 +694,16 @@ valpy_format_string (PyObject *self, PyObject *args, PyObject *kw)
PyObject *static_members_obj = NULL;
PyObject *summary_obj = NULL;
char *format = NULL;
- if (!gdb_PyArg_ParseTupleAndKeywords (args,
- kw,
- "|O!O!O!O!O!O!O!O!O!O!O!O!O!IIIIs",
- keywords,
- &PyBool_Type, &raw_obj,
- &PyBool_Type, &pretty_arrays_obj,
- &PyBool_Type, &pretty_structs_obj,
- &PyBool_Type, &array_indexes_obj,
- &PyBool_Type, &symbols_obj,
- &PyBool_Type, &unions_obj,
- &PyBool_Type, &address_obj,
- &PyBool_Type, &styling_obj,
- &PyBool_Type, &nibbles_obj,
- &PyBool_Type, &summary_obj,
- &PyBool_Type, &deref_refs_obj,
- &PyBool_Type, &actual_objects_obj,
- &PyBool_Type, &static_members_obj,
- &opts.print_max_chars,
- &opts.print_max,
- &opts.max_depth,
- &opts.repeat_count_threshold,
- &format))
+ if (!gdb_PyArg_ParseTupleAndKeywords (
+ args, kw, "|O!O!O!O!O!O!O!O!O!O!O!O!O!IIIIs", keywords, &PyBool_Type,
+ &raw_obj, &PyBool_Type, &pretty_arrays_obj, &PyBool_Type,
+ &pretty_structs_obj, &PyBool_Type, &array_indexes_obj, &PyBool_Type,
+ &symbols_obj, &PyBool_Type, &unions_obj, &PyBool_Type, &address_obj,
+ &PyBool_Type, &styling_obj, &PyBool_Type, &nibbles_obj, &PyBool_Type,
+ &summary_obj, &PyBool_Type, &deref_refs_obj, &PyBool_Type,
+ &actual_objects_obj, &PyBool_Type, &static_members_obj,
+ &opts.print_max_chars, &opts.print_max, &opts.max_depth,
+ &opts.repeat_count_threshold, &format))
return NULL;
/* Set boolean arguments. */
@@ -761,8 +749,7 @@ valpy_format_string (PyObject *self, PyObject *args, PyObject *kw)
{
/* Mimic the message on standard Python ones for similar
errors. */
- PyErr_SetString (PyExc_ValueError,
- "a single character is required");
+ PyErr_SetString (PyExc_ValueError, "a single character is required");
return NULL;
}
}
@@ -771,8 +758,8 @@ valpy_format_string (PyObject *self, PyObject *args, PyObject *kw)
try
{
- common_val_print (((value_object *) self)->value, &stb, 0,
- &opts, current_language);
+ common_val_print (((value_object *) self)->value, &stb, 0, &opts,
+ current_language);
}
catch (const gdb_exception &except)
{
@@ -790,14 +777,13 @@ valpy_do_cast (PyObject *self, PyObject *args, enum exp_opcode op)
PyObject *type_obj, *result = NULL;
struct type *type;
- if (! PyArg_ParseTuple (args, "O", &type_obj))
+ if (!PyArg_ParseTuple (args, "O", &type_obj))
return NULL;
type = type_object_to_type (type_obj);
- if (! type)
+ if (!type)
{
- PyErr_SetString (PyExc_RuntimeError,
- _("Argument must be a type."));
+ PyErr_SetString (PyExc_RuntimeError, _ ("Argument must be a type."));
return NULL;
}
@@ -856,7 +842,7 @@ valpy_length (PyObject *self)
{
/* We don't support getting the number of elements in a struct / class. */
PyErr_SetString (PyExc_NotImplementedError,
- _("Invalid operation on gdb.Value."));
+ _ ("Invalid operation on gdb.Value."));
return -1;
}
@@ -877,9 +863,10 @@ value_has_field (struct value *v, PyObject *field)
parent_type = type_object_to_type (type_object.get ());
if (parent_type == NULL)
{
- PyErr_SetString (PyExc_TypeError,
- _("'parent_type' attribute of gdb.Field object is not a"
- "gdb.Type object."));
+ PyErr_SetString (
+ PyExc_TypeError,
+ _ ("'parent_type' attribute of gdb.Field object is not a"
+ "gdb.Type object."));
return -1;
}
@@ -934,8 +921,8 @@ get_field_type (PyObject *field)
ftype = type_object_to_type (ftype_obj.get ());
if (ftype == NULL)
PyErr_SetString (PyExc_TypeError,
- _("'type' attribute of gdb.Field object is not a "
- "gdb.Type object."));
+ _ ("'type' attribute of gdb.Field object is not a "
+ "gdb.Type object."));
return ftype;
}
@@ -970,8 +957,8 @@ valpy_getitem (PyObject *self, PyObject *key)
else if (valid_field == 0)
{
PyErr_SetString (PyExc_TypeError,
- _("Invalid lookup for a field not contained in "
- "the value."));
+ _ ("Invalid lookup for a field not contained in "
+ "the value."));
return NULL;
}
@@ -1003,8 +990,8 @@ valpy_getitem (PyObject *self, PyObject *key)
if (!PyObject_HasAttrString (key, "bitpos"))
{
PyErr_SetString (PyExc_AttributeError,
- _("gdb.Field object has no name and no "
- "'bitpos' attribute."));
+ _ ("gdb.Field object has no name and no "
+ "'bitpos' attribute."));
return NULL;
}
@@ -1041,11 +1028,13 @@ valpy_getitem (PyObject *self, PyObject *key)
if (val_type->code () == TYPE_CODE_PTR)
res_val = value_cast (lookup_pointer_type (base_class_type), tmp);
else if (val_type->code () == TYPE_CODE_REF)
- res_val = value_cast (lookup_lvalue_reference_type (base_class_type),
- tmp);
+ res_val
+ = value_cast (lookup_lvalue_reference_type (base_class_type),
+ tmp);
else if (val_type->code () == TYPE_CODE_RVALUE_REF)
- res_val = value_cast (lookup_rvalue_reference_type (base_class_type),
- tmp);
+ res_val
+ = value_cast (lookup_rvalue_reference_type (base_class_type),
+ tmp);
else
res_val = value_cast (base_class_type, tmp);
}
@@ -1066,7 +1055,7 @@ valpy_getitem (PyObject *self, PyObject *key)
type = check_typedef (value_type (tmp));
if (type->code () != TYPE_CODE_ARRAY
&& type->code () != TYPE_CODE_PTR)
- error (_("Cannot subscript requested type."));
+ error (_ ("Cannot subscript requested type."));
else
res_val = value_subscript (tmp, value_as_long (idx));
}
@@ -1089,7 +1078,7 @@ static int
valpy_setitem (PyObject *self, PyObject *key, PyObject *value)
{
PyErr_Format (PyExc_NotImplementedError,
- _("Setting of struct elements is not currently supported."));
+ _ ("Setting of struct elements is not currently supported."));
return -1;
}
@@ -1116,14 +1105,14 @@ valpy_call (PyObject *self, PyObject *args, PyObject *keywords)
if (ftype->code () != TYPE_CODE_FUNC)
{
PyErr_SetString (PyExc_RuntimeError,
- _("Value is not callable (not TYPE_CODE_FUNC)."));
+ _ ("Value is not callable (not TYPE_CODE_FUNC)."));
return NULL;
}
- if (! PyTuple_Check (args))
+ if (!PyTuple_Check (args))
{
PyErr_SetString (PyExc_TypeError,
- _("Inferior arguments must be provided in a tuple."));
+ _ ("Inferior arguments must be provided in a tuple."));
return NULL;
}
@@ -1177,8 +1166,8 @@ valpy_str (PyObject *self)
try
{
- common_val_print (((value_object *) self)->value, &stb, 0,
- &opts, current_language);
+ common_val_print (((value_object *) self)->value, &stb, 0, &opts,
+ current_language);
}
catch (const gdb_exception &except)
{
@@ -1320,11 +1309,9 @@ valpy_binop_throw (enum valpy_opcode opcode, PyObject *self, PyObject *other)
rtype = STRIP_REFERENCE (rtype);
handled = 1;
- if (ltype->code () == TYPE_CODE_PTR
- && is_integral_type (rtype))
+ if (ltype->code () == TYPE_CODE_PTR && is_integral_type (rtype))
res_val = value_ptradd (arg1, value_as_long (arg2));
- else if (rtype->code () == TYPE_CODE_PTR
- && is_integral_type (ltype))
+ else if (rtype->code () == TYPE_CODE_PTR && is_integral_type (ltype))
res_val = value_ptradd (arg2, value_as_long (arg1));
else
{
@@ -1344,14 +1331,12 @@ valpy_binop_throw (enum valpy_opcode opcode, PyObject *self, PyObject *other)
rtype = STRIP_REFERENCE (rtype);
handled = 1;
- if (ltype->code () == TYPE_CODE_PTR
- && rtype->code () == TYPE_CODE_PTR)
+ if (ltype->code () == TYPE_CODE_PTR && rtype->code () == TYPE_CODE_PTR)
/* A ptrdiff_t for the target would be preferable here. */
res_val = value_from_longest (builtin_type_pyint,
value_ptrdiff (arg1, arg2));
- else if (ltype->code () == TYPE_CODE_PTR
- && is_integral_type (rtype))
- res_val = value_ptradd (arg1, - value_as_long (arg2));
+ else if (ltype->code () == TYPE_CODE_PTR && is_integral_type (rtype))
+ res_val = value_ptradd (arg1, -value_as_long (arg2));
else
{
handled = 0;
@@ -1536,8 +1521,9 @@ valpy_nonzero (PyObject *self)
if (is_integral_type (type) || type->code () == TYPE_CODE_PTR)
nonzero = !!value_as_long (self_value->value);
else if (is_floating_value (self_value->value))
- nonzero = !target_float_is_zero
- (value_contents (self_value->value).data (), type);
+ nonzero
+ = !target_float_is_zero (value_contents (self_value->value).data (),
+ type);
else
/* All other values are True. */
nonzero = 1;
@@ -1635,7 +1621,7 @@ valpy_richcompare_throw (PyObject *self, PyObject *other, int op)
break;
case Py_LE:
result = value_less (value_self, value_other)
- || value_equal (value_self, value_other);
+ || value_equal (value_self, value_other);
break;
case Py_EQ:
result = value_equal (value_self, value_other);
@@ -1653,7 +1639,7 @@ valpy_richcompare_throw (PyObject *self, PyObject *other, int op)
default:
/* Can't happen. */
PyErr_SetString (PyExc_NotImplementedError,
- _("Invalid operation on gdb.Value."));
+ _ ("Invalid operation on gdb.Value."));
result = -1;
break;
}
@@ -1661,7 +1647,6 @@ valpy_richcompare_throw (PyObject *self, PyObject *other, int op)
return result;
}
-
/* Implements comparison operations for value objects. Returns NULL on error,
with a python exception set. */
static PyObject *
@@ -1672,7 +1657,8 @@ valpy_richcompare (PyObject *self, PyObject *other, int op)
if (other == Py_None)
/* Comparing with None is special. From what I can tell, in Python
None is smaller than anything else. */
- switch (op) {
+ switch (op)
+ {
case Py_LT:
case Py_LE:
case Py_EQ:
@@ -1684,9 +1670,9 @@ valpy_richcompare (PyObject *self, PyObject *other, int op)
default:
/* Can't happen. */
PyErr_SetString (PyExc_NotImplementedError,
- _("Invalid operation on gdb.Value."));
+ _ ("Invalid operation on gdb.Value."));
return NULL;
- }
+ }
try
{
@@ -1725,9 +1711,8 @@ valpy_long (PyObject *self)
type = check_typedef (type);
- if (!is_integral_type (type)
- && type->code () != TYPE_CODE_PTR)
- error (_("Cannot convert value to long."));
+ if (!is_integral_type (type) && type->code () != TYPE_CODE_PTR)
+ error (_ ("Cannot convert value to long."));
l = value_as_long (value);
}
@@ -1764,7 +1749,7 @@ valpy_float (PyObject *self)
d = value_as_long (value);
}
else
- error (_("Cannot convert value to float."));
+ error (_ ("Cannot convert value to float."));
}
catch (const gdb_exception &except)
{
@@ -1826,7 +1811,7 @@ value_object_to_value (PyObject *self)
{
value_object *real;
- if (! PyObject_TypeCheck (self, &value_object_type))
+ if (!PyObject_TypeCheck (self, &value_object_type))
return NULL;
real = (value_object *) self;
return real->value;
@@ -1871,7 +1856,7 @@ convert_value_from_python (PyObject *obj)
ULONGEST ul;
ul = PyLong_AsUnsignedLongLong (obj);
- if (! PyErr_Occurred ())
+ if (!PyErr_Occurred ())
value = value_from_ulongest (builtin_type_upylong, ul);
}
else
@@ -1888,7 +1873,7 @@ convert_value_from_python (PyObject *obj)
{
double d = PyFloat_AsDouble (obj);
- if (! PyErr_Occurred ())
+ if (!PyErr_Occurred ())
value = value_from_host_double (builtin_type_pyfloat, d);
}
else if (gdbpy_is_string (obj))
@@ -1905,12 +1890,12 @@ convert_value_from_python (PyObject *obj)
{
PyObject *result;
- result = PyObject_CallMethodObjArgs (obj, gdbpy_value_cst, NULL);
+ result = PyObject_CallMethodObjArgs (obj, gdbpy_value_cst, NULL);
value = value_copy (((value_object *) result)->value);
}
else
PyErr_Format (PyExc_TypeError,
- _("Could not convert Python object: %S."), obj);
+ _ ("Could not convert Python object: %S."), obj);
}
catch (const gdb_exception &except)
{
@@ -1926,7 +1911,7 @@ PyObject *
gdbpy_history (PyObject *self, PyObject *args)
{
int i;
- struct value *res_val = NULL; /* Initialize to appease gcc warning. */
+ struct value *res_val = NULL; /* Initialize to appease gcc warning. */
if (!PyArg_ParseTuple (args, "i", &i))
return NULL;
@@ -2071,36 +2056,32 @@ gdbpy_initialize_values (void)
(PyObject *) &value_object_type);
}
-
-
static gdb_PyGetSetDef value_object_getset[] = {
- { "address", valpy_get_address, NULL, "The address of the value.",
- NULL },
+ { "address", valpy_get_address, NULL, "The address of the value.", NULL },
{ "is_optimized_out", valpy_get_is_optimized_out, NULL,
"Boolean telling whether the value is optimized "
"out (i.e., not available).",
NULL },
{ "type", valpy_get_type, NULL, "Type of the value.", NULL },
- { "dynamic_type", valpy_get_dynamic_type, NULL,
- "Dynamic type of the value.", NULL },
+ { "dynamic_type", valpy_get_dynamic_type, NULL, "Dynamic type of the value.",
+ NULL },
{ "is_lazy", valpy_get_is_lazy, NULL,
"Boolean telling whether the value is lazy (not fetched yet\n\
from the inferior). A lazy value is fetched when needed, or when\n\
-the \"fetch_lazy()\" method is called.", NULL },
- {NULL} /* Sentinel */
+the \"fetch_lazy()\" method is called.",
+ NULL },
+ { NULL } /* Sentinel */
};
static PyMethodDef value_object_methods[] = {
{ "cast", valpy_cast, METH_VARARGS, "Cast the value to the supplied type." },
{ "dynamic_cast", valpy_dynamic_cast, METH_VARARGS,
"dynamic_cast (gdb.Type) -> gdb.Value\n\
-Cast the value to the supplied type, as if by the C++ dynamic_cast operator."
- },
+Cast the value to the supplied type, as if by the C++ dynamic_cast operator." },
{ "reinterpret_cast", valpy_reinterpret_cast, METH_VARARGS,
"reinterpret_cast (gdb.Type) -> gdb.Value\n\
Cast the value to the supplied type, as if by the C++\n\
-reinterpret_cast operator."
- },
+reinterpret_cast operator." },
{ "dereference", valpy_dereference, METH_NOARGS, "Dereferences the value." },
{ "referenced_value", valpy_referenced_value, METH_NOARGS,
"Return the value referenced by a TYPE_CODE_REF or TYPE_CODE_PTR value." },
@@ -2120,94 +2101,86 @@ Return Unicode string representation of the value." },
{ "fetch_lazy", valpy_fetch_lazy, METH_NOARGS,
"Fetches the value from the inferior, if it was lazy." },
{ "format_string", (PyCFunction) valpy_format_string,
- METH_VARARGS | METH_KEYWORDS,
- "format_string (...) -> string\n\
+ METH_VARARGS | METH_KEYWORDS, "format_string (...) -> string\n\
Return a string representation of the value using the specified\n\
formatting options" },
- {NULL} /* Sentinel */
+ { NULL } /* Sentinel */
};
static PyNumberMethods value_object_as_number = {
- valpy_add,
- valpy_subtract,
- valpy_multiply,
- valpy_remainder,
- NULL, /* nb_divmod */
- valpy_power, /* nb_power */
- valpy_negative, /* nb_negative */
- valpy_positive, /* nb_positive */
- valpy_absolute, /* nb_absolute */
- valpy_nonzero, /* nb_nonzero */
- valpy_invert, /* nb_invert */
- valpy_lsh, /* nb_lshift */
- valpy_rsh, /* nb_rshift */
- valpy_and, /* nb_and */
- valpy_xor, /* nb_xor */
- valpy_or, /* nb_or */
- valpy_long, /* nb_int */
- NULL, /* reserved */
- valpy_float, /* nb_float */
- NULL, /* nb_inplace_add */
- NULL, /* nb_inplace_subtract */
- NULL, /* nb_inplace_multiply */
- NULL, /* nb_inplace_remainder */
- NULL, /* nb_inplace_power */
- NULL, /* nb_inplace_lshift */
- NULL, /* nb_inplace_rshift */
- NULL, /* nb_inplace_and */
- NULL, /* nb_inplace_xor */
- NULL, /* nb_inplace_or */
- NULL, /* nb_floor_divide */
- valpy_divide, /* nb_true_divide */
- NULL, /* nb_inplace_floor_divide */
- NULL, /* nb_inplace_true_divide */
- valpy_long, /* nb_index */
+ valpy_add, valpy_subtract, valpy_multiply, valpy_remainder,
+ NULL, /* nb_divmod */
+ valpy_power, /* nb_power */
+ valpy_negative, /* nb_negative */
+ valpy_positive, /* nb_positive */
+ valpy_absolute, /* nb_absolute */
+ valpy_nonzero, /* nb_nonzero */
+ valpy_invert, /* nb_invert */
+ valpy_lsh, /* nb_lshift */
+ valpy_rsh, /* nb_rshift */
+ valpy_and, /* nb_and */
+ valpy_xor, /* nb_xor */
+ valpy_or, /* nb_or */
+ valpy_long, /* nb_int */
+ NULL, /* reserved */
+ valpy_float, /* nb_float */
+ NULL, /* nb_inplace_add */
+ NULL, /* nb_inplace_subtract */
+ NULL, /* nb_inplace_multiply */
+ NULL, /* nb_inplace_remainder */
+ NULL, /* nb_inplace_power */
+ NULL, /* nb_inplace_lshift */
+ NULL, /* nb_inplace_rshift */
+ NULL, /* nb_inplace_and */
+ NULL, /* nb_inplace_xor */
+ NULL, /* nb_inplace_or */
+ NULL, /* nb_floor_divide */
+ valpy_divide, /* nb_true_divide */
+ NULL, /* nb_inplace_floor_divide */
+ NULL, /* nb_inplace_true_divide */
+ valpy_long, /* nb_index */
};
-static PyMappingMethods value_object_as_mapping = {
- valpy_length,
- valpy_getitem,
- valpy_setitem
-};
+static PyMappingMethods value_object_as_mapping
+ = { valpy_length, valpy_getitem, valpy_setitem };
PyTypeObject value_object_type = {
- PyVarObject_HEAD_INIT (NULL, 0)
- "gdb.Value", /*tp_name*/
- sizeof (value_object), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- valpy_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- &value_object_as_number, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- &value_object_as_mapping, /*tp_as_mapping*/
- valpy_hash, /*tp_hash*/
- valpy_call, /*tp_call*/
- valpy_str, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
+ PyVarObject_HEAD_INIT (NULL, 0) "gdb.Value", /*tp_name*/
+ sizeof (value_object), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ valpy_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ &value_object_as_number, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ &value_object_as_mapping, /*tp_as_mapping*/
+ valpy_hash, /*tp_hash*/
+ valpy_call, /*tp_call*/
+ valpy_str, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES
- | Py_TPFLAGS_BASETYPE, /*tp_flags*/
- "GDB value object", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- valpy_richcompare, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- value_object_methods, /* tp_methods */
- 0, /* tp_members */
- value_object_getset, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- valpy_init, /* tp_init */
- 0, /* tp_alloc */
- PyType_GenericNew, /* tp_new */
+ | Py_TPFLAGS_BASETYPE, /*tp_flags*/
+ "GDB value object", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ valpy_richcompare, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ value_object_methods, /* tp_methods */
+ 0, /* tp_members */
+ value_object_getset, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ valpy_init, /* tp_init */
+ 0, /* tp_alloc */
+ PyType_GenericNew, /* tp_new */
};
diff --git a/gdb/python/py-varobj.c b/gdb/python/py-varobj.c
index 08e790b..1ec41a9 100644
--- a/gdb/python/py-varobj.c
+++ b/gdb/python/py-varobj.c
@@ -72,8 +72,8 @@ py_varobj_iter::next ()
gdbpy_enter_varobj enter_py (m_var);
- scoped_restore set_options = make_scoped_restore (&gdbpy_current_print_options,
- &m_opts);
+ scoped_restore set_options
+ = make_scoped_restore (&gdbpy_current_print_options, &m_opts);
gdbpy_ref<> item (PyIter_Next (m_iter));
@@ -94,8 +94,8 @@ py_varobj_iter::next ()
return NULL;
}
- std::string name_str = string_printf ("<error at %d>",
- m_next_raw_index++);
+ std::string name_str
+ = string_printf ("<error at %d>", m_next_raw_index++);
item.reset (Py_BuildValue ("(ss)", name_str.c_str (),
value_str.get ()));
if (item == NULL)
@@ -115,7 +115,7 @@ py_varobj_iter::next ()
if (!PyArg_ParseTuple (item.get (), "sO", &name, &py_v))
{
gdbpy_print_stack ();
- error (_("Invalid item from the child list"));
+ error (_ ("Invalid item from the child list"));
}
vitem = new varobj_item ();
@@ -152,22 +152,22 @@ py_varobj_get_iterator (struct varobj *var, PyObject *printer,
if (!PyObject_HasAttr (printer, gdbpy_children_cst))
return NULL;
- scoped_restore set_options = make_scoped_restore (&gdbpy_current_print_options,
- opts);
+ scoped_restore set_options
+ = make_scoped_restore (&gdbpy_current_print_options, opts);
- gdbpy_ref<> children (PyObject_CallMethodObjArgs (printer, gdbpy_children_cst,
- NULL));
+ gdbpy_ref<> children (PyObject_CallMethodObjArgs (printer,
+ gdbpy_children_cst, NULL));
if (children == NULL)
{
gdbpy_print_stack ();
- error (_("Null value returned for children"));
+ error (_ ("Null value returned for children"));
}
gdbpy_ref<> iter (PyObject_GetIter (children.get ()));
if (iter == NULL)
{
gdbpy_print_stack ();
- error (_("Could not get children iterator"));
+ error (_ ("Could not get children iterator"));
}
return std::unique_ptr<varobj_iter> (new py_varobj_iter (var,
diff --git a/gdb/python/py-xmethods.c b/gdb/python/py-xmethods.c
index d6d607d..88c1ced 100644
--- a/gdb/python/py-xmethods.c
+++ b/gdb/python/py-xmethods.c
@@ -115,10 +115,9 @@ invoke_match_method (PyObject *matcher, PyObject *py_obj_type,
/* Implementation of get_matching_xmethod_workers for Python. */
enum ext_lang_rc
-gdbpy_get_matching_xmethod_workers
- (const struct extension_language_defn *extlang,
- struct type *obj_type, const char *method_name,
- std::vector<xmethod_worker_up> *dm_vec)
+gdbpy_get_matching_xmethod_workers (
+ const struct extension_language_defn *extlang, struct type *obj_type,
+ const char *method_name, std::vector<xmethod_worker_up> *dm_vec)
{
gdb_assert (obj_type != NULL && method_name != NULL);
@@ -268,8 +267,8 @@ gdbpy_get_matching_xmethod_workers
break;
}
- worker = new python_xmethod_worker (py_worker.get (),
- py_type.get ());
+ worker
+ = new python_xmethod_worker (py_worker.get (), py_type.get ());
dm_vec->emplace_back (worker);
}
@@ -278,8 +277,8 @@ gdbpy_get_matching_xmethod_workers
{
struct xmethod_worker *worker;
- worker = new python_xmethod_worker (match_result.get (),
- py_type.get ());
+ worker
+ = new python_xmethod_worker (match_result.get (), py_type.get ());
dm_vec->emplace_back (worker);
}
}
@@ -299,17 +298,16 @@ python_xmethod_worker::do_get_arg_types (std::vector<type *> *arg_types)
int i = 1, arg_count;
gdbpy_ref<> list_iter;
- gdbpy_ref<> get_arg_types_method
- (PyObject_GetAttrString (m_py_worker, get_arg_types_method_name));
+ gdbpy_ref<> get_arg_types_method (
+ PyObject_GetAttrString (m_py_worker, get_arg_types_method_name));
if (get_arg_types_method == NULL)
{
gdbpy_print_stack ();
return EXT_LANG_RC_ERROR;
}
- gdbpy_ref<> py_argtype_list
- (PyObject_CallMethodObjArgs (m_py_worker, py_get_arg_types_method_name,
- NULL));
+ gdbpy_ref<> py_argtype_list (PyObject_CallMethodObjArgs (
+ m_py_worker, py_get_arg_types_method_name, NULL));
if (py_argtype_list == NULL)
{
gdbpy_print_stack ();
@@ -359,9 +357,9 @@ python_xmethod_worker::do_get_arg_types (std::vector<type *> *arg_types)
if (arg_type == NULL)
{
PyErr_SetString (PyExc_TypeError,
- _("Arg type returned by the get_arg_types "
- "method of a debug method worker object is "
- "not a gdb.Type object."));
+ _ ("Arg type returned by the get_arg_types "
+ "method of a debug method worker object is "
+ "not a gdb.Type object."));
return EXT_LANG_RC_ERROR;
}
@@ -378,9 +376,9 @@ python_xmethod_worker::do_get_arg_types (std::vector<type *> *arg_types)
if (arg_type == NULL)
{
PyErr_SetString (PyExc_TypeError,
- _("Arg type returned by the get_arg_types method "
- "of an xmethod worker object is not a gdb.Type "
- "object."));
+ _ ("Arg type returned by the get_arg_types method "
+ "of an xmethod worker object is not a gdb.Type "
+ "object."));
return EXT_LANG_RC_ERROR;
}
else
@@ -394,8 +392,7 @@ python_xmethod_worker::do_get_arg_types (std::vector<type *> *arg_types)
be a 'const' value. Hence, create a 'const' variant of the 'this' pointer
type. */
obj_type = type_object_to_type (m_this_type);
- (*arg_types)[0] = make_cv_type (1, 0, lookup_pointer_type (obj_type),
- NULL);
+ (*arg_types)[0] = make_cv_type (1, 0, lookup_pointer_type (obj_type), NULL);
return EXT_LANG_RC_OK;
}
@@ -414,8 +411,8 @@ python_xmethod_worker::do_get_result_type (value *obj,
/* First see if there is a get_result_type method.
If not this could be an old xmethod (pre 7.9.1). */
- gdbpy_ref<> get_result_type_method
- (PyObject_GetAttrString (m_py_worker, get_result_type_method_name));
+ gdbpy_ref<> get_result_type_method (
+ PyObject_GetAttrString (m_py_worker, get_result_type_method_name));
if (get_result_type_method == NULL)
{
PyErr_Clear ();
@@ -475,8 +472,8 @@ python_xmethod_worker::do_get_result_type (value *obj,
PyTuple_SET_ITEM (py_arg_tuple.get (), i + 1, py_value_arg);
}
- gdbpy_ref<> py_result_type
- (PyObject_CallObject (get_result_type_method.get (), py_arg_tuple.get ()));
+ gdbpy_ref<> py_result_type (
+ PyObject_CallObject (get_result_type_method.get (), py_arg_tuple.get ()));
if (py_result_type == NULL)
{
gdbpy_print_stack ();
@@ -487,8 +484,8 @@ python_xmethod_worker::do_get_result_type (value *obj,
if (*result_type_ptr == NULL)
{
PyErr_SetString (PyExc_TypeError,
- _("Type returned by the get_result_type method of an"
- " xmethod worker object is not a gdb.Type object."));
+ _ ("Type returned by the get_result_type method of an"
+ " xmethod worker object is not a gdb.Type object."));
gdbpy_print_stack ();
return EXT_LANG_RC_ERROR;
}
@@ -534,14 +531,14 @@ python_xmethod_worker::invoke (struct value *obj,
if (py_value_obj == NULL)
{
gdbpy_print_stack ();
- error (_("Error while executing Python code."));
+ error (_ ("Error while executing Python code."));
}
gdbpy_ref<> py_arg_tuple (PyTuple_New (args.size () + 1));
if (py_arg_tuple == NULL)
{
gdbpy_print_stack ();
- error (_("Error while executing Python code."));
+ error (_ ("Error while executing Python code."));
}
/* PyTuple_SET_ITEM steals the reference of the element, hence the
@@ -555,7 +552,7 @@ python_xmethod_worker::invoke (struct value *obj,
if (py_value_arg == NULL)
{
gdbpy_print_stack ();
- error (_("Error while executing Python code."));
+ error (_ ("Error while executing Python code."));
}
PyTuple_SET_ITEM (py_arg_tuple.get (), i + 1, py_value_arg);
@@ -566,7 +563,7 @@ python_xmethod_worker::invoke (struct value *obj,
if (py_result == NULL)
{
gdbpy_print_stack ();
- error (_("Error while executing Python code."));
+ error (_ ("Error while executing Python code."));
}
if (py_result != Py_None)
@@ -575,22 +572,23 @@ python_xmethod_worker::invoke (struct value *obj,
if (res == NULL)
{
gdbpy_print_stack ();
- error (_("Error while executing Python code."));
+ error (_ ("Error while executing Python code."));
}
}
else
{
- res = allocate_value (lookup_typename (current_language,
- "void", NULL, 0));
+ res
+ = allocate_value (lookup_typename (current_language, "void", NULL, 0));
}
return res;
}
python_xmethod_worker::python_xmethod_worker (PyObject *py_worker,
- PyObject *this_type)
-: xmethod_worker (&extension_language_python),
- m_py_worker (py_worker), m_this_type (this_type)
+ PyObject *this_type)
+ : xmethod_worker (&extension_language_python),
+ m_py_worker (py_worker),
+ m_this_type (this_type)
{
gdb_assert (m_py_worker != NULL && m_this_type != NULL);
diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h
index c41a43b..f9b7f18 100644
--- a/gdb/python/python-internal.h
+++ b/gdb/python/python-internal.h
@@ -32,7 +32,7 @@
gdb. */
#ifdef WITH_CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF_ATTRIBUTE
-#define CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF(ARG) \
+#define CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF(ARG) \
__attribute__ ((cpychecker_type_object_for_typedef (ARG)))
#else
#define CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF(ARG)
@@ -45,7 +45,7 @@
#endif
#ifdef WITH_CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION_ATTRIBUTE
-#define CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION \
+#define CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION \
__attribute__ ((cpychecker_negative_result_sets_exception))
#else
#define CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION
@@ -74,7 +74,7 @@
/* Another kludge to avoid compilation errors because MinGW defines
'hypot' to '_hypot', but the C++ headers says "using ::hypot". */
#ifdef __MINGW32__
-# define _hypot hypot
+#define _hypot hypot
#endif
/* Request clean size types from Python. */
@@ -94,9 +94,9 @@
PyGILState_STATE will be. */
#ifndef WITH_THREAD
#define PyGILState_Ensure() ((PyGILState_STATE) 0)
-#define PyGILState_Release(ARG) ((void)(ARG))
+#define PyGILState_Release(ARG) ((void) (ARG))
#define PyEval_InitThreads()
-#define PyThreadState_Swap(ARG) ((void)(ARG))
+#define PyThreadState_Swap(ARG) ((void) (ARG))
#define PyEval_ReleaseLock()
#endif
@@ -144,10 +144,8 @@ static inline PyObject *
gdb_PyObject_CallMethod (PyObject *o, const char *method, const char *format,
Args... args) /* ARI: editCase function */
{
- return PyObject_CallMethod (o,
- const_cast<char *> (method),
- const_cast<char *> (format),
- args...);
+ return PyObject_CallMethod (o, const_cast<char *> (method),
+ const_cast<char *> (format), args...);
}
#undef PyObject_CallMethod
@@ -157,7 +155,7 @@ gdb_PyObject_CallMethod (PyObject *o, const char *method, const char *format,
qualifier in Python <= 3.4. Hence, we wrap it in a function to
avoid errors when compiled with -Werror. */
-static inline PyObject*
+static inline PyObject *
gdb_PyErr_NewException (const char *name, PyObject *base, PyObject *dict)
{
return PyErr_NewException (const_cast<char *> (name), base, dict);
@@ -185,7 +183,7 @@ gdb_PySys_GetObject (const char *name)
before Python 3.6. Hence, we wrap it in a function to avoid errors
when compiled with -Werror. */
-# define GDB_PYSYS_SETPATH_CHAR wchar_t
+#define GDB_PYSYS_SETPATH_CHAR wchar_t
static inline void
gdb_PySys_SetPath (const GDB_PYSYS_SETPATH_CHAR *path)
@@ -209,21 +207,24 @@ struct gdb_PyGetSetDef : PyGetSetDef
{
constexpr gdb_PyGetSetDef (const char *name_, getter get_, setter set_,
const char *doc_, void *closure_)
- : PyGetSetDef {const_cast<char *> (name_), get_, set_,
- const_cast<char *> (doc_), closure_}
- {}
+ : PyGetSetDef { const_cast<char *> (name_), get_, set_,
+ const_cast<char *> (doc_), closure_ }
+ {
+ }
/* Alternative constructor that allows omitting the closure in list
initialization. */
constexpr gdb_PyGetSetDef (const char *name_, getter get_, setter set_,
const char *doc_)
- : gdb_PyGetSetDef {name_, get_, set_, doc_, NULL}
- {}
+ : gdb_PyGetSetDef { name_, get_, set_, doc_, NULL }
+ {
+ }
/* Constructor for the sentinel entries. */
constexpr gdb_PyGetSetDef (std::nullptr_t)
- : gdb_PyGetSetDef {NULL, NULL, NULL, NULL, NULL}
- {}
+ : gdb_PyGetSetDef { NULL, NULL, NULL, NULL, NULL }
+ {
+ }
};
/* The 'keywords' parameter of PyArg_ParseTupleAndKeywords has type
@@ -240,15 +241,15 @@ struct gdb_PyGetSetDef : PyGetSetDef
static inline int
gdb_PyArg_ParseTupleAndKeywords (PyObject *args, PyObject *kw,
- const char *format, const char **keywords, ...)
+ const char *format, const char **keywords,
+ ...)
{
va_list ap;
int res;
va_start (ap, keywords);
res = PyArg_VaParseTupleAndKeywords (args, kw, format,
- const_cast<char **> (keywords),
- ap);
+ const_cast<char **> (keywords), ap);
va_end (ap);
return res;
@@ -262,7 +263,12 @@ gdb_PyArg_ParseTupleAndKeywords (PyObject *args, PyObject *kw,
#include "command.h"
#include "breakpoint.h"
-enum gdbpy_iter_kind { iter_keys, iter_values, iter_items };
+enum gdbpy_iter_kind
+{
+ iter_keys,
+ iter_values,
+ iter_items
+};
struct block;
struct value;
@@ -275,20 +281,20 @@ extern int gdb_python_initialized;
extern PyObject *gdb_module;
extern PyObject *gdb_python_module;
-extern PyTypeObject value_object_type
- CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("value_object");
-extern PyTypeObject block_object_type
- CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF("block_object");
-extern PyTypeObject symbol_object_type
- CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("symbol_object");
-extern PyTypeObject event_object_type
- CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("event_object");
+extern PyTypeObject
+ value_object_type CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("value_object");
+extern PyTypeObject
+ block_object_type CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("block_object");
+extern PyTypeObject
+ symbol_object_type CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("symbol_object");
+extern PyTypeObject
+ event_object_type CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("event_object");
extern PyTypeObject breakpoint_object_type
- CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("breakpoint_object");
-extern PyTypeObject frame_object_type
- CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("frame_object");
-extern PyTypeObject thread_object_type
- CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("thread_object");
+ CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("breakpoint_object");
+extern PyTypeObject
+ frame_object_type CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("frame_object");
+extern PyTypeObject
+ thread_object_type CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("thread_object");
/* Ensure that breakpoint_object_type is initialized and return true. If
breakpoint_object_type can't be initialized then set a suitable Python
@@ -306,8 +312,8 @@ struct gdbpy_breakpoint_object
{
PyObject_HEAD
- /* The breakpoint number according to gdb. */
- int number;
+ /* The breakpoint number according to gdb. */
+ int number;
/* The gdb breakpoint object, or NULL if the breakpoint has been
deleted. */
@@ -319,38 +325,40 @@ struct gdbpy_breakpoint_object
/* Require that BREAKPOINT be a valid breakpoint ID; throw a Python
exception if it is invalid. */
-#define BPPY_REQUIRE_VALID(Breakpoint) \
- do { \
- if ((Breakpoint)->bp == NULL) \
- return PyErr_Format (PyExc_RuntimeError, \
- _("Breakpoint %d is invalid."), \
- (Breakpoint)->number); \
- } while (0)
+#define BPPY_REQUIRE_VALID(Breakpoint) \
+ do \
+ { \
+ if ((Breakpoint)->bp == NULL) \
+ return PyErr_Format (PyExc_RuntimeError, \
+ _ ("Breakpoint %d is invalid."), \
+ (Breakpoint)->number); \
+ } \
+ while (0)
/* Require that BREAKPOINT be a valid breakpoint ID; throw a Python
exception if it is invalid. This macro is for use in setter functions. */
-#define BPPY_SET_REQUIRE_VALID(Breakpoint) \
- do { \
- if ((Breakpoint)->bp == NULL) \
- { \
- PyErr_Format (PyExc_RuntimeError, _("Breakpoint %d is invalid."), \
- (Breakpoint)->number); \
- return -1; \
- } \
- } while (0)
-
+#define BPPY_SET_REQUIRE_VALID(Breakpoint) \
+ do \
+ { \
+ if ((Breakpoint)->bp == NULL) \
+ { \
+ PyErr_Format (PyExc_RuntimeError, _ ("Breakpoint %d is invalid."), \
+ (Breakpoint)->number); \
+ return -1; \
+ } \
+ } \
+ while (0)
/* Variables used to pass information between the Breakpoint
constructor and the breakpoint-created hook function. */
extern gdbpy_breakpoint_object *bppy_pending_object;
-
struct thread_object
{
PyObject_HEAD
- /* The thread we represent. */
- struct thread_info *thread;
+ /* The thread we represent. */
+ struct thread_info *thread;
/* The Inferior object to which this thread belongs. */
PyObject *inf_obj;
@@ -360,7 +368,7 @@ struct inferior_object;
extern struct cmd_list_element *set_python_list;
extern struct cmd_list_element *show_python_list;
-
+
/* extension_language_script_ops "methods". */
/* Return true if auto-loading Python scripts is enabled.
@@ -370,31 +378,30 @@ extern bool gdbpy_auto_load_enabled (const struct extension_language_defn *);
/* extension_language_ops "methods". */
-extern enum ext_lang_rc gdbpy_apply_val_pretty_printer
- (const struct extension_language_defn *,
- struct value *value,
- struct ui_file *stream, int recurse,
- const struct value_print_options *options,
- const struct language_defn *language);
-extern enum ext_lang_bt_status gdbpy_apply_frame_filter
- (const struct extension_language_defn *,
- frame_info_ptr frame, frame_filter_flags flags,
- enum ext_lang_frame_args args_type,
- struct ui_out *out, int frame_low, int frame_high);
+extern enum ext_lang_rc
+gdbpy_apply_val_pretty_printer (const struct extension_language_defn *,
+ struct value *value, struct ui_file *stream,
+ int recurse,
+ const struct value_print_options *options,
+ const struct language_defn *language);
+extern enum ext_lang_bt_status
+gdbpy_apply_frame_filter (const struct extension_language_defn *,
+ frame_info_ptr frame, frame_filter_flags flags,
+ enum ext_lang_frame_args args_type,
+ struct ui_out *out, int frame_low, int frame_high);
extern void gdbpy_preserve_values (const struct extension_language_defn *,
struct objfile *objfile,
htab_t copied_types);
-extern enum ext_lang_bp_stop gdbpy_breakpoint_cond_says_stop
- (const struct extension_language_defn *, struct breakpoint *);
+extern enum ext_lang_bp_stop
+gdbpy_breakpoint_cond_says_stop (const struct extension_language_defn *,
+ struct breakpoint *);
extern int gdbpy_breakpoint_has_cond (const struct extension_language_defn *,
struct breakpoint *b);
-extern enum ext_lang_rc gdbpy_get_matching_xmethod_workers
- (const struct extension_language_defn *extlang,
- struct type *obj_type, const char *method_name,
- std::vector<xmethod_worker_up> *dm_vec);
+extern enum ext_lang_rc gdbpy_get_matching_xmethod_workers (
+ const struct extension_language_defn *extlang, struct type *obj_type,
+ const char *method_name, std::vector<xmethod_worker_up> *dm_vec);
-
PyObject *gdbpy_history (PyObject *self, PyObject *args);
PyObject *gdbpy_add_history (PyObject *self, PyObject *args);
extern PyObject *gdbpy_history_count (PyObject *self, PyObject *args);
@@ -408,7 +415,7 @@ PyObject *gdbpy_lookup_global_symbol (PyObject *self, PyObject *args,
PyObject *gdbpy_lookup_static_symbol (PyObject *self, PyObject *args,
PyObject *kw);
PyObject *gdbpy_lookup_static_symbols (PyObject *self, PyObject *args,
- PyObject *kw);
+ PyObject *kw);
PyObject *gdbpy_start_recording (PyObject *self, PyObject *args);
PyObject *gdbpy_current_recording (PyObject *self, PyObject *args);
PyObject *gdbpy_stop_recording (PyObject *self, PyObject *args);
@@ -425,9 +432,10 @@ 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_value (const setting &var);
-gdb::unique_xmalloc_ptr<char> gdbpy_parse_command_name
- (const char *name, struct cmd_list_element ***base_list,
- struct cmd_list_element **start_list);
+gdb::unique_xmalloc_ptr<char>
+gdbpy_parse_command_name (const char *name,
+ struct cmd_list_element ***base_list,
+ struct cmd_list_element **start_list);
PyObject *gdbpy_register_tui_window (PyObject *self, PyObject *args,
PyObject *kw);
@@ -462,7 +470,8 @@ PyObject *gdbpy_new_register_descriptor_iterator (struct gdbarch *gdbarch,
PyObject *gdbpy_new_reggroup_iterator (struct gdbarch *gdbarch);
gdbpy_ref<thread_object> create_thread_object (struct thread_info *tp);
-gdbpy_ref<> thread_to_thread_object (thread_info *thr);;
+gdbpy_ref<> thread_to_thread_object (thread_info *thr);
+;
gdbpy_ref<inferior_object> inferior_to_inferior_object (inferior *inf);
PyObject *gdbpy_buffer_to_membuf (gdb::unique_xmalloc_ptr<gdb_byte> buffer,
@@ -490,75 +499,52 @@ struct gdbarch *arch_object_to_gdbarch (PyObject *obj);
extern struct program_space *progspace_object_to_program_space (PyObject *obj);
void gdbpy_initialize_gdb_readline (void);
-int gdbpy_initialize_auto_load (void)
- CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
-int gdbpy_initialize_values (void)
- CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
-int gdbpy_initialize_frames (void)
- CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
-int gdbpy_initialize_instruction (void)
- CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
-int gdbpy_initialize_btrace (void)
- CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
-int gdbpy_initialize_record (void)
- CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
-int gdbpy_initialize_symtabs (void)
- CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
-int gdbpy_initialize_commands (void)
- CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
-int gdbpy_initialize_symbols (void)
- CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
-int gdbpy_initialize_symtabs (void)
- CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
-int gdbpy_initialize_blocks (void)
- CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
-int gdbpy_initialize_types (void)
- CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
-int gdbpy_initialize_functions (void)
- CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
-int gdbpy_initialize_pspace (void)
- CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
-int gdbpy_initialize_objfile (void)
- CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
-int gdbpy_initialize_breakpoints (void)
- CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
+int
+gdbpy_initialize_auto_load (void) CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
+int gdbpy_initialize_values (void) CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
+int gdbpy_initialize_frames (void) CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
+int
+gdbpy_initialize_instruction (void) CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
+int gdbpy_initialize_btrace (void) CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
+int gdbpy_initialize_record (void) CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
+int gdbpy_initialize_symtabs (void) CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
+int gdbpy_initialize_commands (void) CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
+int gdbpy_initialize_symbols (void) CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
+int gdbpy_initialize_symtabs (void) CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
+int gdbpy_initialize_blocks (void) CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
+int gdbpy_initialize_types (void) CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
+int
+gdbpy_initialize_functions (void) CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
+int gdbpy_initialize_pspace (void) CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
+int gdbpy_initialize_objfile (void) CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
+int
+gdbpy_initialize_breakpoints (void) CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
int gdbpy_initialize_breakpoint_locations ()
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
int gdbpy_initialize_finishbreakpoints (void)
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
-int gdbpy_initialize_lazy_string (void)
- CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
-int gdbpy_initialize_linetable (void)
- CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
-int gdbpy_initialize_parameters (void)
- CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
-int gdbpy_initialize_thread (void)
- CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
-int gdbpy_initialize_inferior (void)
- CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
+int
+gdbpy_initialize_lazy_string (void) CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
+int
+gdbpy_initialize_linetable (void) CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
+int
+gdbpy_initialize_parameters (void) CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
+int gdbpy_initialize_thread (void) CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
+int gdbpy_initialize_inferior (void) CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
int gdbpy_initialize_eventregistry (void)
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
-int gdbpy_initialize_event (void)
- CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
-int gdbpy_initialize_arch (void)
- CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
-int gdbpy_initialize_registers ()
- CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
-int gdbpy_initialize_xmethods (void)
- CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
-int gdbpy_initialize_unwind (void)
- CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
-int gdbpy_initialize_tui ()
- CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
-int gdbpy_initialize_membuf ()
- CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
-int gdbpy_initialize_connection ()
- CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
-int gdbpy_initialize_micommands (void)
- CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
+int gdbpy_initialize_event (void) CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
+int gdbpy_initialize_arch (void) CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
+int gdbpy_initialize_registers () CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
+int gdbpy_initialize_xmethods (void) CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
+int gdbpy_initialize_unwind (void) CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
+int gdbpy_initialize_tui () CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
+int gdbpy_initialize_membuf () CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
+int gdbpy_initialize_connection () CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
+int
+gdbpy_initialize_micommands (void) CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
void gdbpy_finalize_micommands ();
-int gdbpy_initialize_disasm ()
- CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
+int gdbpy_initialize_disasm () CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
PyMODINIT_FUNC gdbpy_events_mod_func ();
@@ -584,8 +570,7 @@ public:
void restore ()
{
- PyErr_Restore (m_error_type.release (),
- m_error_value.release (),
+ PyErr_Restore (m_error_type.release (), m_error_value.release (),
m_error_traceback.release ());
}
@@ -610,10 +595,7 @@ public:
/* Return a new reference to the exception value object. */
- gdbpy_ref<> value ()
- {
- return m_error_value;
- }
+ gdbpy_ref<> value () { return m_error_value; }
private:
@@ -627,7 +609,7 @@ private:
handler. */
class gdbpy_enter
{
- public:
+public:
/* Set the ambient Python architecture to GDBARCH and the language
to LANGUAGE. If GDBARCH is nullptr, then the architecture will
@@ -653,7 +635,7 @@ class gdbpy_enter
acceptable value. */
static void finalize ();
- private:
+private:
/* The current gdbarch, according to Python. This can be
nullptr. */
@@ -673,12 +655,11 @@ class gdbpy_enter
make constructor delegation a little nicer. */
class gdbpy_enter_varobj : public gdbpy_enter
{
- public:
+public:
/* This is defined in varobj.c, where it can access varobj
internals. */
gdbpy_enter_varobj (const struct varobj *var);
-
};
/* The opposite of gdb_enter: this releases the GIL around a region,
@@ -694,10 +675,7 @@ public:
gdb_assert (m_save != nullptr);
}
- ~gdbpy_allow_threads ()
- {
- PyEval_RestoreThread (m_save);
- }
+ ~gdbpy_allow_threads () { PyEval_RestoreThread (m_save); }
DISABLE_COPY_AND_ASSIGN (gdbpy_allow_threads);
@@ -708,25 +686,29 @@ private:
/* Use this after a TRY_EXCEPT to throw the appropriate Python
exception. */
-#define GDB_PY_HANDLE_EXCEPTION(Exception) \
- do { \
- if (Exception.reason < 0) \
- { \
- gdbpy_convert_exception (Exception); \
- return NULL; \
- } \
- } while (0)
+#define GDB_PY_HANDLE_EXCEPTION(Exception) \
+ do \
+ { \
+ if (Exception.reason < 0) \
+ { \
+ gdbpy_convert_exception (Exception); \
+ return NULL; \
+ } \
+ } \
+ while (0)
/* Use this after a TRY_EXCEPT to throw the appropriate Python
exception. This macro is for use inside setter functions. */
-#define GDB_PY_SET_HANDLE_EXCEPTION(Exception) \
- do { \
- if (Exception.reason < 0) \
- { \
- gdbpy_convert_exception (Exception); \
- return -1; \
- } \
- } while (0)
+#define GDB_PY_SET_HANDLE_EXCEPTION(Exception) \
+ do \
+ { \
+ if (Exception.reason < 0) \
+ { \
+ gdbpy_convert_exception (Exception); \
+ return -1; \
+ } \
+ } \
+ while (0)
int gdbpy_print_python_errors_p (void);
void gdbpy_print_stack (void);
@@ -741,8 +723,8 @@ void gdbpy_handle_exception () ATTRIBUTE_NORETURN;
This always calls error, and never returns. */
-void gdbpy_error (const char *fmt, ...)
- ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (1, 2);
+void gdbpy_error (const char *fmt, ...) ATTRIBUTE_NORETURN
+ ATTRIBUTE_PRINTF (1, 2);
gdbpy_ref<> python_string_to_unicode (PyObject *obj);
gdb::unique_xmalloc_ptr<char> unicode_to_target_string (PyObject *unicode_str);
@@ -755,8 +737,7 @@ gdb::unique_xmalloc_ptr<char> gdbpy_obj_to_string (PyObject *obj);
int gdbpy_is_lazy_string (PyObject *result);
void gdbpy_extract_lazy_string (PyObject *string, CORE_ADDR *addr,
- struct type **str_type,
- long *length,
+ struct type **str_type, long *length,
gdb::unique_xmalloc_ptr<char> *encoding);
int gdbpy_is_value_object (PyObject *obj);
@@ -791,10 +772,10 @@ extern PyObject *gdbpy_gdb_memory_error;
extern PyObject *gdbpy_gdberror_exc;
extern void gdbpy_convert_exception (const struct gdb_exception &)
- CPYCHECKER_SETS_EXCEPTION;
+ CPYCHECKER_SETS_EXCEPTION;
int get_addr_from_python (PyObject *obj, CORE_ADDR *addr)
- CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
+ CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
gdbpy_ref<> gdb_py_object_from_longest (LONGEST l);
gdbpy_ref<> gdb_py_object_from_ulongest (ULONGEST l);
@@ -808,19 +789,15 @@ int gdb_pymodule_addobject (PyObject *module, const char *name,
struct varobj_iter;
struct varobj;
-std::unique_ptr<varobj_iter> py_varobj_get_iterator
- (struct varobj *var,
- PyObject *printer,
- const value_print_options *opts);
+std::unique_ptr<varobj_iter>
+py_varobj_get_iterator (struct varobj *var, PyObject *printer,
+ const value_print_options *opts);
/* Deleter for Py_buffer unique_ptr specialization. */
struct Py_buffer_deleter
{
- void operator() (Py_buffer *b) const
- {
- PyBuffer_Release (b);
- }
+ void operator() (Py_buffer *b) const { PyBuffer_Release (b); }
};
/* A unique_ptr specialization for Py_buffer. */
@@ -873,8 +850,8 @@ extern bool gdbpy_is_progspace (PyObject *obj);
If the analysis of DOC fails then DOC will be returned unmodified. */
-extern gdb::unique_xmalloc_ptr<char> gdbpy_fix_doc_string_indentation
- (gdb::unique_xmalloc_ptr<char> doc);
+extern gdb::unique_xmalloc_ptr<char>
+gdbpy_fix_doc_string_indentation (gdb::unique_xmalloc_ptr<char> doc);
/* Implement the 'print_insn' hook for Python. Disassemble an instruction
whose address is ADDRESS for architecture GDBARCH. The bytes of the
diff --git a/gdb/python/python.c b/gdb/python/python.c
index 54623f4..66b0f26 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -44,13 +44,8 @@ static const char python_excp_full[] = "full";
static const char python_excp_message[] = "message";
/* "set python print-stack" choices. */
-static const char *const python_excp_enums[] =
- {
- python_excp_none,
- python_excp_full,
- python_excp_message,
- NULL
- };
+static const char *const python_excp_enums[]
+ = { python_excp_none, python_excp_full, python_excp_message, NULL };
/* The exception printing variable. 'full' if we want to print the
error message and stack, 'none' if we want to print nothing, and
@@ -58,7 +53,6 @@ static const char *const python_excp_enums[] =
the default. */
static const char *gdbpy_should_print_stack = python_excp_message;
-
#ifdef HAVE_PYTHON
#include "cli/cli-decode.h"
@@ -106,38 +100,36 @@ static objfile_script_sourcer_func gdbpy_source_objfile_script;
static objfile_script_executor_func gdbpy_execute_objfile_script;
static void gdbpy_initialize (const struct extension_language_defn *);
static int gdbpy_initialized (const struct extension_language_defn *);
-static void gdbpy_eval_from_control_command
- (const struct extension_language_defn *, struct command_line *cmd);
+static void
+gdbpy_eval_from_control_command (const struct extension_language_defn *,
+ struct command_line *cmd);
static void gdbpy_start_type_printers (const struct extension_language_defn *,
struct ext_lang_type_printers *);
-static enum ext_lang_rc gdbpy_apply_type_printers
- (const struct extension_language_defn *,
- const struct ext_lang_type_printers *, struct type *, char **);
+static enum ext_lang_rc
+gdbpy_apply_type_printers (const struct extension_language_defn *,
+ const struct ext_lang_type_printers *,
+ struct type *, char **);
static void gdbpy_free_type_printers (const struct extension_language_defn *,
struct ext_lang_type_printers *);
static void gdbpy_set_quit_flag (const struct extension_language_defn *);
static int gdbpy_check_quit_flag (const struct extension_language_defn *);
-static enum ext_lang_rc gdbpy_before_prompt_hook
- (const struct extension_language_defn *, const char *current_gdb_prompt);
-static gdb::optional<std::string> gdbpy_colorize
- (const std::string &filename, const std::string &contents);
-static gdb::optional<std::string> gdbpy_colorize_disasm
- (const std::string &content, gdbarch *gdbarch);
+static enum ext_lang_rc
+gdbpy_before_prompt_hook (const struct extension_language_defn *,
+ const char *current_gdb_prompt);
+static gdb::optional<std::string> gdbpy_colorize (const std::string &filename,
+ const std::string &contents);
+static gdb::optional<std::string>
+gdbpy_colorize_disasm (const std::string &content, gdbarch *gdbarch);
/* The interface between gdb proper and loading of python scripts. */
-static const struct extension_language_script_ops python_extension_script_ops =
-{
- gdbpy_source_script,
- gdbpy_source_objfile_script,
- gdbpy_execute_objfile_script,
- gdbpy_auto_load_enabled
-};
+static const struct extension_language_script_ops python_extension_script_ops
+ = { gdbpy_source_script, gdbpy_source_objfile_script,
+ gdbpy_execute_objfile_script, gdbpy_auto_load_enabled };
/* The interface between gdb proper and python extensions. */
-static const struct extension_language_ops python_extension_ops =
-{
+static const struct extension_language_ops python_extension_ops = {
gdbpy_initialize,
gdbpy_initialized,
@@ -174,25 +166,24 @@ static const struct extension_language_ops python_extension_ops =
/* The main struct describing GDB's interface to the Python
extension language. */
-const struct extension_language_defn extension_language_python =
-{
- EXT_LANG_PYTHON,
- "python",
- "Python",
+const struct extension_language_defn extension_language_python
+ = { EXT_LANG_PYTHON,
+ "python",
+ "Python",
- ".py",
- "-gdb.py",
+ ".py",
+ "-gdb.py",
- python_control,
+ python_control,
#ifdef HAVE_PYTHON
- &python_extension_script_ops,
- &python_extension_ops
+ &python_extension_script_ops,
+ &python_extension_ops
#else
- NULL,
- NULL
+ NULL,
+ NULL
#endif
-};
+ };
#ifdef HAVE_PYTHON
@@ -200,14 +191,14 @@ const struct extension_language_defn extension_language_python =
the Python interpreter. */
struct gdbarch *gdbpy_enter::python_gdbarch;
-gdbpy_enter::gdbpy_enter (struct gdbarch *gdbarch,
- const struct language_defn *language)
-: m_gdbarch (python_gdbarch),
- m_language (language == nullptr ? nullptr : current_language)
+gdbpy_enter::gdbpy_enter (struct gdbarch *gdbarch,
+ const struct language_defn *language)
+ : m_gdbarch (python_gdbarch),
+ m_language (language == nullptr ? nullptr : current_language)
{
/* We should not ever enter Python unless initialized. */
if (!gdb_python_initialized)
- error (_("Python not initialized"));
+ error (_ ("Python not initialized"));
m_previous_active = set_active_ext_lang (&extension_language_python);
@@ -228,7 +219,7 @@ gdbpy_enter::~gdbpy_enter ()
{
/* This order is similar to the one calling error afterwards. */
gdbpy_print_stack ();
- warning (_("internal error: Unhandled Python exception"));
+ warning (_ ("internal error: Unhandled Python exception"));
}
m_error->restore ();
@@ -267,10 +258,7 @@ public:
{
}
- ~gdbpy_gil ()
- {
- PyGILState_Release (m_state);
- }
+ ~gdbpy_gil () { PyGILState_Release (m_state); }
DISABLE_COPY_AND_ASSIGN (gdbpy_gil);
@@ -350,7 +338,7 @@ python_interactive_command (const char *arg, int from_tty)
if (err)
{
gdbpy_print_stack ();
- error (_("Error while executing Python code."));
+ error (_ ("Error while executing Python code."));
}
}
@@ -383,17 +371,17 @@ python_run_simple_file (FILE *file, const char *filename)
gdb::unique_xmalloc_ptr<char> full_path (tilde_expand (filename));
if (gdb_python_module == nullptr
- || ! PyObject_HasAttrString (gdb_python_module, "_execute_file"))
- error (_("Installation error: gdb._execute_file function is missing"));
+ || !PyObject_HasAttrString (gdb_python_module, "_execute_file"))
+ error (_ ("Installation error: gdb._execute_file function is missing"));
- gdbpy_ref<> return_value
- (PyObject_CallMethod (gdb_python_module, "_execute_file", "s",
- full_path.get ()));
+ gdbpy_ref<> return_value (PyObject_CallMethod (gdb_python_module,
+ "_execute_file", "s",
+ full_path.get ()));
if (return_value == nullptr)
{
/* Use PyErr_PrintEx instead of gdbpy_print_stack to better match the
behavior of the non-Windows codepath. */
- PyErr_PrintEx(0);
+ PyErr_PrintEx (0);
}
#endif /* _WIN32 */
@@ -426,14 +414,14 @@ gdbpy_eval_from_control_command (const struct extension_language_defn *extlang,
int ret;
if (cmd->body_list_1 != nullptr)
- error (_("Invalid \"python\" block structure."));
+ error (_ ("Invalid \"python\" block structure."));
gdbpy_enter enter_py;
std::string script = compute_python_string (cmd->body_list_0.get ());
ret = PyRun_SimpleString (script.c_str ());
if (ret)
- error (_("Error while executing Python code."));
+ error (_ ("Error while executing Python code."));
}
/* Implementation of the gdb "python" command. */
@@ -449,7 +437,7 @@ python_command (const char *arg, int from_tty)
if (arg && *arg)
{
if (PyRun_SimpleString (arg))
- error (_("Error while executing Python code."));
+ error (_ ("Error while executing Python code."));
}
else
{
@@ -459,8 +447,6 @@ python_command (const char *arg, int from_tty)
}
}
-
-
/* Transform a gdb parameters's value into a Python value. May return
NULL (and set a Python exception) on error. Helper function for
get_parameter. */
@@ -508,22 +494,19 @@ gdbpy_parameter_value (const setting &var)
case var_integer:
case var_pinteger:
{
- LONGEST value
- = (var.type () == var_uinteger
- ? static_cast<LONGEST> (var.get<unsigned int> ())
- : static_cast<LONGEST> (var.get<int> ()));
+ LONGEST value = (var.type () == var_uinteger
+ ? static_cast<LONGEST> (var.get<unsigned int> ())
+ : static_cast<LONGEST> (var.get<int> ()));
if (var.extra_literals () != nullptr)
for (const literal_def *l = var.extra_literals ();
- l->literal != nullptr;
- l++)
+ l->literal != nullptr; l++)
if (value == l->use)
{
if (strcmp (l->literal, "unlimited") == 0)
{
/* Compatibility hack for API brokenness. */
- if (var.type () == var_pinteger
- && l->val.has_value ()
+ if (var.type () == var_pinteger && l->val.has_value ()
&& *l->val == -1)
value = -1;
else
@@ -536,18 +519,17 @@ gdbpy_parameter_value (const setting &var)
}
if (var.type () == var_uinteger)
- return
- gdb_py_object_from_ulongest
- (static_cast<unsigned int> (value)).release ();
+ return gdb_py_object_from_ulongest (
+ static_cast<unsigned int> (value))
+ .release ();
else
- return
- gdb_py_object_from_longest
- (static_cast<int> (value)).release ();
+ return gdb_py_object_from_longest (static_cast<int> (value))
+ .release ();
}
}
return PyErr_Format (PyExc_RuntimeError,
- _("Programmer error: unhandled type."));
+ _ ("Programmer error: unhandled type."));
}
/* A Python function which returns a gdb parameter's value as a Python
@@ -560,7 +542,7 @@ gdbpy_parameter (PyObject *self, PyObject *args)
const char *arg;
int found = -1;
- if (! PyArg_ParseTuple (args, "s", &arg))
+ if (!PyArg_ParseTuple (args, "s", &arg))
return NULL;
std::string newarg = std::string ("show ") + arg;
@@ -576,11 +558,11 @@ gdbpy_parameter (PyObject *self, PyObject *args)
if (!found)
return PyErr_Format (PyExc_RuntimeError,
- _("Could not find parameter `%s'."), arg);
+ _ ("Could not find parameter `%s'."), arg);
if (!cmd->var.has_value ())
- return PyErr_Format (PyExc_RuntimeError,
- _("`%s' is not a parameter."), arg);
+ return PyErr_Format (PyExc_RuntimeError, _ ("`%s' is not a parameter."),
+ arg);
return gdbpy_parameter_value (*cmd->var);
}
@@ -661,20 +643,18 @@ execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw)
std::string arg_copy = arg;
bool first = true;
char *save_ptr = nullptr;
- auto reader
- = [&] (std::string &buffer)
- {
- const char *result = strtok_r (first ? &arg_copy[0] : nullptr,
- "\n", &save_ptr);
- first = false;
- return result;
- };
+ auto reader = [&] (std::string &buffer) {
+ const char *result
+ = strtok_r (first ? &arg_copy[0] : nullptr, "\n", &save_ptr);
+ first = false;
+ return result;
+ };
counted_command_line lines = read_command_lines_1 (reader, 1, nullptr);
{
- scoped_restore save_async = make_scoped_restore (&current_ui->async,
- 0);
+ scoped_restore save_async
+ = make_scoped_restore (&current_ui->async, 0);
scoped_restore save_uiout = make_scoped_restore (&current_uiout);
@@ -684,8 +664,8 @@ execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw)
current_uiout = interp->interp_ui_out ();
if (to_string)
- to_string_res = execute_control_commands_to_string (lines.get (),
- from_tty);
+ to_string_res
+ = execute_control_commands_to_string (lines.get (), from_tty);
else
execute_control_commands (lines.get (), from_tty);
}
@@ -732,13 +712,12 @@ gdbpy_rbreak (PyObject *self, PyObject *args, PyObject *kw)
PyObject *minsyms_p_obj = NULL;
int minsyms_p = 0;
unsigned int throttle = 0;
- static const char *keywords[] = {"regex","minsyms", "throttle",
- "symtabs", NULL};
+ static const char *keywords[]
+ = { "regex", "minsyms", "throttle", "symtabs", NULL };
- if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "s|O!IO", keywords,
- &regex, &PyBool_Type,
- &minsyms_p_obj, &throttle,
- &symtab_list))
+ if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "s|O!IO", keywords, &regex,
+ &PyBool_Type, &minsyms_p_obj,
+ &throttle, &symtab_list))
return NULL;
/* Parse minsyms keyword. */
@@ -751,7 +730,8 @@ gdbpy_rbreak (PyObject *self, PyObject *args, PyObject *kw)
}
global_symbol_searcher spec (FUNCTIONS_DOMAIN, regex);
- SCOPE_EXIT {
+ SCOPE_EXIT
+ {
for (const char *elem : spec.filenames)
xfree ((void *) elem);
};
@@ -793,8 +773,8 @@ gdbpy_rbreak (PyObject *self, PyObject *args, PyObject *kw)
if (obj_name == Py_None)
continue;
- gdb::unique_xmalloc_ptr<char> filename =
- python_string_to_target_string (obj_name.get ());
+ gdb::unique_xmalloc_ptr<char> filename
+ = python_string_to_target_string (obj_name.get ());
if (filename == NULL)
return NULL;
@@ -828,7 +808,7 @@ gdbpy_rbreak (PyObject *self, PyObject *args, PyObject *kw)
if (throttle != 0 && count > throttle)
{
PyErr_SetString (PyExc_RuntimeError,
- _("Number of breakpoints exceeds throttled maximum."));
+ _ ("Number of breakpoints exceeds throttled maximum."));
return NULL;
}
@@ -855,16 +835,15 @@ gdbpy_rbreak (PyObject *self, PyObject *args, PyObject *kw)
const char *fullname = symtab_to_fullname (symtab);
symbol_name = fullname;
- symbol_name += ":";
- symbol_name += p.symbol->linkage_name ();
+ symbol_name += ":";
+ symbol_name += p.symbol->linkage_name ();
}
else
symbol_name = p.msymbol.minsym->linkage_name ();
- gdbpy_ref<> argList (Py_BuildValue("(s)", symbol_name.c_str ()));
- gdbpy_ref<> obj (PyObject_CallObject ((PyObject *)
- &breakpoint_object_type,
- argList.get ()));
+ gdbpy_ref<> argList (Py_BuildValue ("(s)", symbol_name.c_str ()));
+ gdbpy_ref<> obj (PyObject_CallObject (
+ (PyObject *) &breakpoint_object_type, argList.get ()));
/* Tolerate individual breakpoint failures. */
if (obj == NULL)
@@ -888,7 +867,7 @@ gdbpy_decode_line (PyObject *self, PyObject *args)
gdbpy_ref<> unparsed;
location_spec_up locspec;
- if (! PyArg_ParseTuple (args, "|s", &arg))
+ if (!PyArg_ParseTuple (args, "|s", &arg))
return NULL;
/* Treat a string consisting of just whitespace the same as
@@ -1003,15 +982,13 @@ gdbpy_invalidate_cached_frames (PyObject *self, PyObject *args)
the traceback and clear the error indicator. */
static void
-gdbpy_source_script (const struct extension_language_defn *extlang,
- FILE *file, const char *filename)
+gdbpy_source_script (const struct extension_language_defn *extlang, FILE *file,
+ const char *filename)
{
gdbpy_enter enter_py;
python_run_simple_file (file, filename);
}
-
-
/* Posting and handling events. */
/* A single event. */
@@ -1071,8 +1048,7 @@ gdbpy_post_event (PyObject *self, PyObject *args)
if (!PyCallable_Check (func))
{
- PyErr_SetString (PyExc_RuntimeError,
- _("Posted event is not callable"));
+ PyErr_SetString (PyExc_RuntimeError, _ ("Posted event is not callable"));
return NULL;
}
@@ -1083,8 +1059,6 @@ gdbpy_post_event (PyObject *self, PyObject *args)
Py_RETURN_NONE;
}
-
-
/* This is the extension_language_ops.before_prompt "method". */
static enum ext_lang_rc
@@ -1113,16 +1087,16 @@ gdbpy_before_prompt_hook (const struct extension_language_defn *extlang,
if (PyCallable_Check (hook.get ()))
{
- gdbpy_ref<> current_prompt (PyUnicode_FromString (current_gdb_prompt));
+ gdbpy_ref<> current_prompt (
+ PyUnicode_FromString (current_gdb_prompt));
if (current_prompt == NULL)
{
gdbpy_print_stack ();
return EXT_LANG_RC_ERROR;
}
- gdbpy_ref<> result
- (PyObject_CallFunctionObjArgs (hook.get (), current_prompt.get (),
- NULL));
+ gdbpy_ref<> result (PyObject_CallFunctionObjArgs (
+ hook.get (), current_prompt.get (), NULL));
if (result == NULL)
{
gdbpy_print_stack ();
@@ -1135,16 +1109,16 @@ gdbpy_before_prompt_hook (const struct extension_language_defn *extlang,
if (result != Py_None && !PyUnicode_Check (result.get ()))
{
PyErr_Format (PyExc_RuntimeError,
- _("Return from prompt_hook must " \
- "be either a Python string, or None"));
+ _ ("Return from prompt_hook must "
+ "be either a Python string, or None"));
gdbpy_print_stack ();
return EXT_LANG_RC_ERROR;
}
if (result != Py_None)
{
- gdb::unique_xmalloc_ptr<char>
- prompt (python_string_to_host_string (result.get ()));
+ gdb::unique_xmalloc_ptr<char> prompt (
+ python_string_to_host_string (result.get ()));
if (prompt == NULL)
{
@@ -1215,10 +1189,8 @@ gdbpy_colorize (const std::string &filename, const std::string &contents)
contents (a bytes object). This function should return either a bytes
object, the same contents with styling applied, or None to indicate
that no styling should be performed. */
- gdbpy_ref<> result (PyObject_CallFunctionObjArgs (hook.get (),
- fname_arg.get (),
- contents_arg.get (),
- nullptr));
+ gdbpy_ref<> result (PyObject_CallFunctionObjArgs (
+ hook.get (), fname_arg.get (), contents_arg.get (), nullptr));
if (result == nullptr)
{
gdbpy_print_stack ();
@@ -1229,8 +1201,10 @@ gdbpy_colorize (const std::string &filename, const std::string &contents)
return {};
else if (!PyBytes_Check (result.get ()))
{
- PyErr_SetString (PyExc_TypeError,
- _("Return value from gdb.colorize should be a bytes object or None."));
+ PyErr_SetString (
+ PyExc_TypeError,
+ _ (
+ "Return value from gdb.colorize should be a bytes object or None."));
gdbpy_print_stack ();
return {};
}
@@ -1258,8 +1232,7 @@ gdbpy_colorize_disasm (const std::string &content, gdbarch *gdbarch)
if (!PyObject_HasAttrString (module.get (), "colorize_disasm"))
return {};
- gdbpy_ref<> hook (PyObject_GetAttrString (module.get (),
- "colorize_disasm"));
+ gdbpy_ref<> hook (PyObject_GetAttrString (module.get (), "colorize_disasm"));
if (hook == nullptr)
{
gdbpy_print_stack ();
@@ -1283,10 +1256,8 @@ gdbpy_colorize_disasm (const std::string &content, gdbarch *gdbarch)
return {};
}
- gdbpy_ref<> result (PyObject_CallFunctionObjArgs (hook.get (),
- content_arg.get (),
- gdbarch_arg.get (),
- nullptr));
+ gdbpy_ref<> result (PyObject_CallFunctionObjArgs (
+ hook.get (), content_arg.get (), gdbarch_arg.get (), nullptr));
if (result == nullptr)
{
gdbpy_print_stack ();
@@ -1299,7 +1270,8 @@ gdbpy_colorize_disasm (const std::string &content, gdbarch *gdbarch)
if (!PyBytes_Check (result.get ()))
{
PyErr_SetString (PyExc_TypeError,
- _("Return value from gdb.colorize_disasm should be a bytes object or None."));
+ _ ("Return value from gdb.colorize_disasm should be a "
+ "bytes object or None."));
gdbpy_print_stack ();
return {};
}
@@ -1307,8 +1279,6 @@ gdbpy_colorize_disasm (const std::string &content, gdbarch *gdbarch)
return std::string (PyBytes_AsString (result.get ()));
}
-
-
/* Implement gdb.format_address(ADDR,P_SPACE,ARCH). Provide access to
GDB's print_address function from Python. The returned address will
have the format '0x..... <symbol+offset>'. */
@@ -1316,17 +1286,15 @@ gdbpy_colorize_disasm (const std::string &content, gdbarch *gdbarch)
static PyObject *
gdbpy_format_address (PyObject *self, PyObject *args, PyObject *kw)
{
- static const char *keywords[] =
- {
- "address", "progspace", "architecture", nullptr
- };
+ static const char *keywords[]
+ = { "address", "progspace", "architecture", nullptr };
PyObject *addr_obj = nullptr, *pspace_obj = nullptr, *arch_obj = nullptr;
CORE_ADDR addr;
struct gdbarch *gdbarch = nullptr;
struct program_space *pspace = nullptr;
- if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "O|OO", keywords,
- &addr_obj, &pspace_obj, &arch_obj))
+ if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "O|OO", keywords, &addr_obj,
+ &pspace_obj, &arch_obj))
return nullptr;
if (get_addr_from_python (addr_obj, &addr) < 0)
@@ -1356,8 +1324,9 @@ gdbpy_format_address (PyObject *self, PyObject *args, PyObject *kw)
default, but it feels like there's too much scope of mistakes in
this case, so better to require the user to provide both
arguments. */
- PyErr_SetString (PyExc_ValueError,
- _("The architecture and progspace arguments must both be supplied"));
+ PyErr_SetString (
+ PyExc_ValueError,
+ _ ("The architecture and progspace arguments must both be supplied"));
return nullptr;
}
else
@@ -1366,8 +1335,9 @@ gdbpy_format_address (PyObject *self, PyObject *args, PyObject *kw)
Just check that these objects are valid. */
if (!gdbpy_is_progspace (pspace_obj))
{
- PyErr_SetString (PyExc_TypeError,
- _("The progspace argument is not a gdb.Progspace object"));
+ PyErr_SetString (
+ PyExc_TypeError,
+ _ ("The progspace argument is not a gdb.Progspace object"));
return nullptr;
}
@@ -1375,14 +1345,15 @@ gdbpy_format_address (PyObject *self, PyObject *args, PyObject *kw)
if (pspace == nullptr)
{
PyErr_SetString (PyExc_ValueError,
- _("The progspace argument is not valid"));
+ _ ("The progspace argument is not valid"));
return nullptr;
}
if (!gdbpy_is_architecture (arch_obj))
{
- PyErr_SetString (PyExc_TypeError,
- _("The architecture argument is not a gdb.Architecture object"));
+ PyErr_SetString (
+ PyExc_TypeError,
+ _ ("The architecture argument is not a gdb.Architecture object"));
return nullptr;
}
@@ -1408,8 +1379,6 @@ gdbpy_format_address (PyObject *self, PyObject *args, PyObject *kw)
return PyUnicode_FromString (buf.c_str ());
}
-
-
/* Printing. */
/* A python function to write a single string using gdb's filtered
@@ -1501,7 +1470,6 @@ gdbpy_print_python_errors_p (void)
void
gdbpy_print_stack (void)
{
-
/* Print "none", just clear exception. */
if (gdbpy_should_print_stack == python_excp_none)
{
@@ -1541,13 +1509,13 @@ gdbpy_print_stack (void)
/* An error occurred computing the string representation of the
error message. */
gdb_printf (gdb_stderr,
- _("Error occurred computing Python error" \
- "message.\n"));
+ _ ("Error occurred computing Python error"
+ "message.\n"));
PyErr_Clear ();
}
else
- gdb_printf (gdb_stderr, "Python Exception %s: %s\n",
- type.get (), msg.get ());
+ gdb_printf (gdb_stderr, "Python Exception %s: %s\n", type.get (),
+ msg.get ());
}
catch (const gdb_exception &except)
{
@@ -1569,8 +1537,6 @@ gdbpy_print_stack_or_quit ()
gdbpy_print_stack ();
}
-
-
/* Return a sequence holding all the Progspaces. */
static PyObject *
@@ -1599,8 +1565,6 @@ gdbpy_current_language (PyObject *unused1, PyObject *unused2)
return host_string_to_python_string (current_language->name ()).release ();
}
-
-
/* See python.h. */
struct objfile *gdbpy_current_objfile;
@@ -1651,7 +1615,7 @@ gdbpy_execute_objfile_script (const struct extension_language_defn *extlang,
static PyObject *
gdbpy_get_current_objfile (PyObject *unused1, PyObject *unused2)
{
- if (! gdbpy_current_objfile)
+ if (!gdbpy_current_objfile)
Py_RETURN_NONE;
return objfile_to_objfile_object (gdbpy_current_objfile).release ();
@@ -1740,10 +1704,8 @@ gdbpy_apply_type_printers (const struct extension_language_defn *extlang,
return EXT_LANG_RC_ERROR;
}
- gdbpy_ref<> result_obj (PyObject_CallFunctionObjArgs (func.get (),
- printers_obj,
- type_obj.get (),
- (char *) NULL));
+ gdbpy_ref<> result_obj (PyObject_CallFunctionObjArgs (
+ func.get (), printers_obj, type_obj.get (), (char *) NULL));
if (result_obj == NULL)
{
gdbpy_print_stack ();
@@ -1793,7 +1755,7 @@ python_interactive_command (const char *arg, int from_tty)
{
arg = skip_spaces (arg);
if (arg && *arg)
- error (_("Python scripting is not supported in this copy of GDB."));
+ error (_ ("Python scripting is not supported in this copy of GDB."));
else
{
counted_command_line l = get_command_line (python_control, "");
@@ -1821,8 +1783,7 @@ static void
show_python_ignore_environment (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
{
- gdb_printf (file, _("Python's ignore-environment setting is %s.\n"),
- value);
+ gdb_printf (file, _ ("Python's ignore-environment setting is %s.\n"), value);
}
/* Implement 'set python ignore-environment'. This sets Python's internal
@@ -1859,14 +1820,17 @@ show_python_dont_write_bytecode (struct ui_file *file, int from_tty,
{
const char *auto_string
= (python_ignore_environment
- || getenv ("PYTHONDONTWRITEBYTECODE") == nullptr) ? "off" : "on";
+ || getenv ("PYTHONDONTWRITEBYTECODE") == nullptr)
+ ? "off"
+ : "on";
- gdb_printf (file,
- _("Python's dont-write-bytecode setting is %s (currently %s).\n"),
- value, auto_string);
+ gdb_printf (
+ file,
+ _ ("Python's dont-write-bytecode setting is %s (currently %s).\n"),
+ value, auto_string);
}
else
- gdb_printf (file, _("Python's dont-write-bytecode setting is %s.\n"),
+ gdb_printf (file, _ ("Python's dont-write-bytecode setting is %s.\n"),
value);
}
@@ -1917,8 +1881,6 @@ set_python_dont_write_bytecode (const char *args, int from_tty,
#endif /* HAVE_PYTHON */
}
-
-
/* Lists for 'set python' commands. */
static struct cmd_list_element *user_set_python_list;
@@ -1957,23 +1919,21 @@ finalize_python (void *ignore)
restore_active_ext_lang (previous_active);
}
-static struct PyModuleDef python_GdbModuleDef =
-{
- PyModuleDef_HEAD_INIT,
- "_gdb",
- NULL,
- -1,
- python_GdbMethods,
- NULL,
- NULL,
- NULL,
- NULL
-};
+static struct PyModuleDef python_GdbModuleDef = { PyModuleDef_HEAD_INIT,
+ "_gdb",
+ NULL,
+ -1,
+ python_GdbMethods,
+ NULL,
+ NULL,
+ NULL,
+ NULL };
/* This is called via the PyImport_AppendInittab mechanism called
during initialization, to make the built-in _gdb module known to
Python. */
PyMODINIT_FUNC init__gdb_module (void);
+
PyMODINIT_FUNC
init__gdb_module (void)
{
@@ -2020,12 +1980,9 @@ do_start_initialization ()
{
/* Define all internal modules. These are all imported (and thus
created) during initialization. */
- struct _inittab mods[] =
- {
- { "_gdb", init__gdb_module },
- { "_gdbevents", gdbpy_events_mod_func },
- { nullptr, nullptr }
- };
+ struct _inittab mods[] = { { "_gdb", init__gdb_module },
+ { "_gdbevents", gdbpy_events_mod_func },
+ { nullptr, nullptr } };
if (PyImport_ExtendInittab (mods) < 0)
return false;
@@ -2037,9 +1994,9 @@ do_start_initialization ()
/foo/bin/python
/foo/lib/pythonX.Y/...
This must be done before calling Py_Initialize. */
- gdb::unique_xmalloc_ptr<char> progname
- (concat (ldirname (python_libdir.c_str ()).c_str (), SLASH_STRING, "bin",
- SLASH_STRING, "python", (char *) NULL));
+ gdb::unique_xmalloc_ptr<char> progname (
+ concat (ldirname (python_libdir.c_str ()).c_str (), SLASH_STRING, "bin",
+ SLASH_STRING, "python", (char *) NULL));
/* Python documentation indicates that the memory given
to Py_SetProgramName cannot be freed. However, it seems that
at least Python 3.7.4 Py_SetProgramName takes a copy of the
@@ -2073,8 +2030,8 @@ do_start_initialization ()
PyConfig config;
PyConfig_InitPythonConfig (&config);
- PyStatus status = PyConfig_SetString (&config, &config.program_name,
- progname_copy);
+ PyStatus status
+ = PyConfig_SetString (&config, &config.program_name, progname_copy);
if (PyStatus_Exception (status))
goto init_done;
@@ -2109,8 +2066,8 @@ init_done:
if (PyModule_AddStringConstant (gdb_module, "VERSION", version) < 0
|| PyModule_AddStringConstant (gdb_module, "HOST_CONFIG", host_name) < 0
- || PyModule_AddStringConstant (gdb_module, "TARGET_CONFIG",
- target_name) < 0)
+ || PyModule_AddStringConstant (gdb_module, "TARGET_CONFIG", target_name)
+ < 0)
return false;
/* Add stream constants. */
@@ -2124,58 +2081,47 @@ init_done:
|| gdb_pymodule_addobject (gdb_module, "error", gdbpy_gdb_error) < 0)
return false;
- gdbpy_gdb_memory_error = PyErr_NewException ("gdb.MemoryError",
- gdbpy_gdb_error, NULL);
+ gdbpy_gdb_memory_error
+ = PyErr_NewException ("gdb.MemoryError", gdbpy_gdb_error, NULL);
if (gdbpy_gdb_memory_error == NULL
|| gdb_pymodule_addobject (gdb_module, "MemoryError",
- gdbpy_gdb_memory_error) < 0)
+ gdbpy_gdb_memory_error)
+ < 0)
return false;
gdbpy_gdberror_exc = PyErr_NewException ("gdb.GdbError", NULL, NULL);
if (gdbpy_gdberror_exc == NULL
- || gdb_pymodule_addobject (gdb_module, "GdbError",
- gdbpy_gdberror_exc) < 0)
+ || gdb_pymodule_addobject (gdb_module, "GdbError", gdbpy_gdberror_exc)
+ < 0)
return false;
gdbpy_initialize_gdb_readline ();
- if (gdbpy_initialize_auto_load () < 0
- || gdbpy_initialize_values () < 0
- || gdbpy_initialize_disasm () < 0
- || gdbpy_initialize_frames () < 0
+ if (gdbpy_initialize_auto_load () < 0 || gdbpy_initialize_values () < 0
+ || gdbpy_initialize_disasm () < 0 || gdbpy_initialize_frames () < 0
|| gdbpy_initialize_commands () < 0
- || gdbpy_initialize_instruction () < 0
- || gdbpy_initialize_record () < 0
- || gdbpy_initialize_btrace () < 0
- || gdbpy_initialize_symbols () < 0
- || gdbpy_initialize_symtabs () < 0
- || gdbpy_initialize_blocks () < 0
+ || gdbpy_initialize_instruction () < 0 || gdbpy_initialize_record () < 0
+ || gdbpy_initialize_btrace () < 0 || gdbpy_initialize_symbols () < 0
+ || gdbpy_initialize_symtabs () < 0 || gdbpy_initialize_blocks () < 0
|| gdbpy_initialize_functions () < 0
- || gdbpy_initialize_parameters () < 0
- || gdbpy_initialize_types () < 0
- || gdbpy_initialize_pspace () < 0
- || gdbpy_initialize_objfile () < 0
+ || gdbpy_initialize_parameters () < 0 || gdbpy_initialize_types () < 0
+ || gdbpy_initialize_pspace () < 0 || gdbpy_initialize_objfile () < 0
|| gdbpy_initialize_breakpoints () < 0
|| gdbpy_initialize_breakpoint_locations () < 0
|| gdbpy_initialize_finishbreakpoints () < 0
|| gdbpy_initialize_lazy_string () < 0
- || gdbpy_initialize_linetable () < 0
- || gdbpy_initialize_thread () < 0
+ || gdbpy_initialize_linetable () < 0 || gdbpy_initialize_thread () < 0
|| gdbpy_initialize_inferior () < 0
- || gdbpy_initialize_eventregistry () < 0
- || gdbpy_initialize_event () < 0
- || gdbpy_initialize_arch () < 0
- || gdbpy_initialize_registers () < 0
- || gdbpy_initialize_xmethods () < 0
- || gdbpy_initialize_unwind () < 0
- || gdbpy_initialize_membuf () < 0
- || gdbpy_initialize_connection () < 0
- || gdbpy_initialize_tui () < 0
- || gdbpy_initialize_micommands () < 0)
+ || gdbpy_initialize_eventregistry () < 0 || gdbpy_initialize_event () < 0
+ || gdbpy_initialize_arch () < 0 || gdbpy_initialize_registers () < 0
+ || gdbpy_initialize_xmethods () < 0 || gdbpy_initialize_unwind () < 0
+ || gdbpy_initialize_membuf () < 0 || gdbpy_initialize_connection () < 0
+ || gdbpy_initialize_tui () < 0 || gdbpy_initialize_micommands () < 0)
return false;
-#define GDB_PY_DEFINE_EVENT_TYPE(name, py_name, doc, base) \
- if (gdbpy_initialize_event_generic (&name##_event_object_type, py_name) < 0) \
+#define GDB_PY_DEFINE_EVENT_TYPE(name, py_name, doc, base) \
+ if (gdbpy_initialize_event_generic (&name##_event_object_type, py_name) \
+ < 0) \
return false;
#include "py-event-types.def"
#undef GDB_PY_DEFINE_EVENT_TYPE
@@ -2212,7 +2158,8 @@ init_done:
}
#if GDB_SELF_TEST
-namespace selftests {
+namespace selftests
+{
/* Entry point for python unit tests. */
@@ -2248,9 +2195,8 @@ test_python ()
saw_exception = false;
{
- scoped_restore save_hook
- = make_scoped_restore (&hook_set_active_ext_lang,
- []() { raise (SIGINT); });
+ scoped_restore save_hook = make_scoped_restore (&hook_set_active_ext_lang,
+ [] () { raise (SIGINT); });
try
{
CMD (output);
@@ -2286,14 +2232,14 @@ test_python ()
cmd_list_element *python_cmd_element = nullptr;
void _initialize_python ();
+
void
_initialize_python ()
{
cmd_list_element *python_interactive_cmd
- = add_com ("python-interactive", class_obscure,
- python_interactive_command,
+ = add_com ("python-interactive", class_obscure, python_interactive_command,
#ifdef HAVE_PYTHON
- _("\
+ _ ("\
Start an interactive Python prompt.\n\
\n\
To return to GDB, type the EOF character (e.g., Ctrl-D on an empty\n\
@@ -2305,19 +2251,19 @@ printed. For example:\n\
\n\
(gdb) python-interactive 2 + 3\n\
5")
-#else /* HAVE_PYTHON */
- _("\
+#else /* HAVE_PYTHON */
+ _ ("\
Start a Python interactive prompt.\n\
\n\
Python scripting is not supported in this copy of GDB.\n\
This command is only a placeholder.")
#endif /* HAVE_PYTHON */
- );
+ );
add_com_alias ("pi", python_interactive_cmd, class_obscure, 1);
python_cmd_element = add_com ("python", class_obscure, python_command,
#ifdef HAVE_PYTHON
- _("\
+ _ ("\
Evaluate a Python command.\n\
\n\
The command can be given as an argument, for instance:\n\
@@ -2327,50 +2273,54 @@ The command can be given as an argument, for instance:\n\
If no argument is given, the following lines are read and used\n\
as the Python commands. Type a line containing \"end\" to indicate\n\
the end of the command.")
-#else /* HAVE_PYTHON */
- _("\
+#else /* HAVE_PYTHON */
+ _ ("\
Evaluate a Python command.\n\
\n\
Python scripting is not supported in this copy of GDB.\n\
This command is only a placeholder.")
#endif /* HAVE_PYTHON */
- );
+ );
add_com_alias ("py", python_cmd_element, class_obscure, 1);
/* Add set/show python print-stack. */
add_setshow_prefix_cmd ("python", no_class,
- _("Prefix command for python preference settings."),
- _("Prefix command for python preference settings."),
+ _ ("Prefix command for python preference settings."),
+ _ ("Prefix command for python preference settings."),
&user_set_python_list, &user_show_python_list,
&setlist, &showlist);
add_setshow_enum_cmd ("print-stack", no_class, python_excp_enums,
- &gdbpy_should_print_stack, _("\
-Set mode for Python stack dump on error."), _("\
-Show the mode of Python stack printing on error."), _("\
+ &gdbpy_should_print_stack, _ ("\
+Set mode for Python stack dump on error."),
+ _ ("\
+Show the mode of Python stack printing on error."),
+ _ ("\
none == no stack or message will be printed.\n\
full == a message and a stack will be printed.\n\
message == an error message without a stack will be printed."),
- NULL, NULL,
- &user_set_python_list,
+ NULL, NULL, &user_set_python_list,
&user_show_python_list);
add_setshow_boolean_cmd ("ignore-environment", no_class,
- &python_ignore_environment, _("\
-Set whether the Python interpreter should ignore environment variables."), _(" \
-Show whether the Python interpreter showlist ignore environment variables."), _(" \
+ &python_ignore_environment, _ ("\
+Set whether the Python interpreter should ignore environment variables."),
+ _ (" \
+Show whether the Python interpreter showlist ignore environment variables."),
+ _ (" \
When enabled GDB's Python interpreter will ignore any Python related\n \
flags in the environment. This is equivalent to passing `-E' to a\n \
python executable."),
set_python_ignore_environment,
show_python_ignore_environment,
- &user_set_python_list,
- &user_show_python_list);
+ &user_set_python_list, &user_show_python_list);
add_setshow_auto_boolean_cmd ("dont-write-bytecode", no_class,
- &python_dont_write_bytecode, _("\
-Set whether the Python interpreter should avoid byte-compiling python modules."), _("\
-Show whether the Python interpreter should avoid byte-compiling python modules."), _("\
+ &python_dont_write_bytecode, _ ("\
+Set whether the Python interpreter should avoid byte-compiling python modules."),
+ _ ("\
+Show whether the Python interpreter should avoid byte-compiling python modules."),
+ _ ("\
When enabled, GDB's embedded Python interpreter won't byte-compile python\n\
modules. In order to take effect, this setting must be enabled in an early\n\
initialization file, i.e. those run via the --early-init-eval-command or\n\
@@ -2387,8 +2337,7 @@ environment variable doesn't exist. All other settings, including those\n\
which don't seem to make sense, indicate that it's on/enabled."),
set_python_dont_write_bytecode,
show_python_dont_write_bytecode,
- &user_set_python_list,
- &user_show_python_list);
+ &user_set_python_list, &user_show_python_list);
#ifdef HAVE_PYTHON
#if GDB_SELF_TEST
@@ -2411,8 +2360,8 @@ do_initialize (const struct extension_language_defn *extlang)
/* Add the initial data-directory to sys.path. */
- std::string gdb_pythondir = (std::string (gdb_datadir) + SLASH_STRING
- + "python");
+ std::string gdb_pythondir
+ = (std::string (gdb_datadir) + SLASH_STRING + "python");
sys_path = PySys_GetObject ("path");
@@ -2456,11 +2405,12 @@ do_initialize (const struct extension_language_defn *extlang)
gdbpy_print_stack ();
/* This is passed in one call to warning so that blank lines aren't
inserted between each line of text. */
- warning (_("\n"
- "Could not load the Python gdb module from `%s'.\n"
- "Limited Python support is available from the _gdb module.\n"
- "Suggest passing --data-directory=/path/to/gdb/data-directory."),
- gdb_pythondir.c_str ());
+ warning (
+ _ ("\n"
+ "Could not load the Python gdb module from `%s'.\n"
+ "Limited Python support is available from the _gdb module.\n"
+ "Suggest passing --data-directory=/path/to/gdb/data-directory."),
+ gdb_pythondir.c_str ());
/* We return "success" here as we've already emitted the
warning. */
return true;
@@ -2484,7 +2434,7 @@ gdbpy_initialize (const struct extension_language_defn *extlang)
if (!do_initialize (extlang))
{
gdbpy_print_stack ();
- warning (_("internal error: Unhandled Python exception"));
+ warning (_ ("internal error: Unhandled Python exception"));
}
}
@@ -2497,10 +2447,8 @@ gdbpy_initialized (const struct extension_language_defn *extlang)
return gdb_python_initialized;
}
-PyMethodDef python_GdbMethods[] =
-{
- { "history", gdbpy_history, METH_VARARGS,
- "Get a value from history" },
+PyMethodDef python_GdbMethods[] = {
+ { "history", gdbpy_history, METH_VARARGS, "Get a value from history" },
{ "add_history", gdbpy_add_history, METH_VARARGS,
"Add a value to the value history list" },
{ "history_count", gdbpy_history_count, METH_NOARGS,
@@ -2539,7 +2487,7 @@ Return a string explaining unwind stop reason." },
"start_recording ([method] [, format]) -> gdb.Record.\n\
Start recording with the given method. If no method is given, will fall back\n\
to the system default method. If no format is given, will fall back to the\n\
-default format for the given method."},
+default format for the given method." },
{ "current_recording", gdbpy_current_recording, METH_NOARGS,
"current_recording () -> gdb.Record.\n\
Return current recording object." },
@@ -2548,8 +2496,7 @@ Return current recording object." },
Stop current recording." },
{ "lookup_type", (PyCFunction) gdbpy_lookup_type,
- METH_VARARGS | METH_KEYWORDS,
- "lookup_type (name [, block]) -> type\n\
+ METH_VARARGS | METH_KEYWORDS, "lookup_type (name [, block]) -> type\n\
Return a Type corresponding to the given name." },
{ "lookup_symbol", (PyCFunction) gdbpy_lookup_symbol,
METH_VARARGS | METH_KEYWORDS,
@@ -2583,11 +2530,10 @@ that 'break' or 'edit' does. Return a tuple containing two elements.\n\
The first element contains any unparsed portion of the String parameter\n\
(or None if the string was fully parsed). The second element contains\n\
a tuple that contains all the locations that match, represented as\n\
-gdb.Symtab_and_line objects (or None)."},
+gdb.Symtab_and_line objects (or None)." },
{ "parse_and_eval", gdbpy_parse_and_eval, METH_VARARGS,
"parse_and_eval (String) -> Value.\n\
-Parse String as an expression, evaluate it, and return the result as a Value."
- },
+Parse String as an expression, evaluate it, and return the result as a Value." },
{ "post_event", gdbpy_post_event, METH_VARARGS,
"Post an event into gdb's event loop." },
@@ -2607,11 +2553,10 @@ Return a Tuple containing gdb.Breakpoint objects that match the given Regex." },
{ "string_to_argv", gdbpy_string_to_argv, METH_VARARGS,
"string_to_argv (String) -> Array.\n\
Parse String and return an argv-like array.\n\
-Arguments are separate by spaces and may be quoted."
- },
- { "write", (PyCFunction)gdbpy_write, METH_VARARGS | METH_KEYWORDS,
+Arguments are separate by spaces and may be quoted." },
+ { "write", (PyCFunction) gdbpy_write, METH_VARARGS | METH_KEYWORDS,
"Write a string using gdb's filtered stream." },
- { "flush", (PyCFunction)gdbpy_flush, METH_VARARGS | METH_KEYWORDS,
+ { "flush", (PyCFunction) gdbpy_flush, METH_VARARGS | METH_KEYWORDS,
"Flush gdb's filtered stdout stream." },
{ "selected_thread", gdbpy_selected_thread, METH_NOARGS,
"selected_thread () -> gdb.InferiorThread.\n\
@@ -2641,14 +2586,13 @@ Set the value of the convenience variable $NAME." },
METH_VARARGS | METH_KEYWORDS,
"register_window_type (NAME, CONSTRUCSTOR) -> None\n\
Register a TUI window constructor." },
-#endif /* TUI */
+#endif /* TUI */
{ "architecture_names", gdbpy_all_architecture_names, METH_NOARGS,
"architecture_names () -> List.\n\
Return a list of all the architecture names GDB understands." },
- { "connections", gdbpy_connections, METH_NOARGS,
- "connections () -> List.\n\
+ { "connections", gdbpy_connections, METH_NOARGS, "connections () -> List.\n\
Return a list of gdb.TargetConnection objects." },
{ "format_address", (PyCFunction) gdbpy_format_address,
@@ -2666,52 +2610,51 @@ Return the name of the currently selected language." },
"print_options () -> dict\n\
Return the current print options." },
- {NULL, NULL, 0, NULL}
+ { NULL, NULL, 0, NULL }
};
/* Define all the event objects. */
-#define GDB_PY_DEFINE_EVENT_TYPE(name, py_name, doc, base) \
- PyTypeObject name##_event_object_type \
- CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("event_object") \
- = { \
- PyVarObject_HEAD_INIT (NULL, 0) \
- "gdb." py_name, /* tp_name */ \
- sizeof (event_object), /* tp_basicsize */ \
- 0, /* tp_itemsize */ \
- evpy_dealloc, /* tp_dealloc */ \
- 0, /* tp_print */ \
- 0, /* tp_getattr */ \
- 0, /* tp_setattr */ \
- 0, /* tp_compare */ \
- 0, /* tp_repr */ \
- 0, /* tp_as_number */ \
- 0, /* tp_as_sequence */ \
- 0, /* tp_as_mapping */ \
- 0, /* tp_hash */ \
- 0, /* tp_call */ \
- 0, /* tp_str */ \
- 0, /* tp_getattro */ \
- 0, /* tp_setattro */ \
- 0, /* tp_as_buffer */ \
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ \
- doc, /* tp_doc */ \
- 0, /* tp_traverse */ \
- 0, /* tp_clear */ \
- 0, /* tp_richcompare */ \
- 0, /* tp_weaklistoffset */ \
- 0, /* tp_iter */ \
- 0, /* tp_iternext */ \
- 0, /* tp_methods */ \
- 0, /* tp_members */ \
- 0, /* tp_getset */ \
- &base, /* tp_base */ \
- 0, /* tp_dict */ \
- 0, /* tp_descr_get */ \
- 0, /* tp_descr_set */ \
- 0, /* tp_dictoffset */ \
- 0, /* tp_init */ \
- 0 /* tp_alloc */ \
- };
+#define GDB_PY_DEFINE_EVENT_TYPE(name, py_name, doc, base) \
+ PyTypeObject name##_event_object_type CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ( \
+ "event_object") \
+ = { \
+ PyVarObject_HEAD_INIT (NULL, 0) "gdb." py_name, /* tp_name */ \
+ sizeof (event_object), /* tp_basicsize */ \
+ 0, /* tp_itemsize */ \
+ evpy_dealloc, /* tp_dealloc */ \
+ 0, /* tp_print */ \
+ 0, /* tp_getattr */ \
+ 0, /* tp_setattr */ \
+ 0, /* tp_compare */ \
+ 0, /* tp_repr */ \
+ 0, /* tp_as_number */ \
+ 0, /* tp_as_sequence */ \
+ 0, /* tp_as_mapping */ \
+ 0, /* tp_hash */ \
+ 0, /* tp_call */ \
+ 0, /* tp_str */ \
+ 0, /* tp_getattro */ \
+ 0, /* tp_setattro */ \
+ 0, /* tp_as_buffer */ \
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ \
+ doc, /* tp_doc */ \
+ 0, /* tp_traverse */ \
+ 0, /* tp_clear */ \
+ 0, /* tp_richcompare */ \
+ 0, /* tp_weaklistoffset */ \
+ 0, /* tp_iter */ \
+ 0, /* tp_iternext */ \
+ 0, /* tp_methods */ \
+ 0, /* tp_members */ \
+ 0, /* tp_getset */ \
+ &base, /* tp_base */ \
+ 0, /* tp_dict */ \
+ 0, /* tp_descr_get */ \
+ 0, /* tp_descr_set */ \
+ 0, /* tp_dictoffset */ \
+ 0, /* tp_init */ \
+ 0 /* tp_alloc */ \
+ };
#include "py-event-types.def"
#undef GDB_PY_DEFINE_EVENT_TYPE