aboutsummaryrefslogtreecommitdiff
path: root/gdb/python
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2013-05-20 20:28:52 +0000
committerTom Tromey <tromey@redhat.com>2013-05-20 20:28:52 +0000
commit999633ede794b0241c4fde66903f341890037200 (patch)
treed5ace278370535bf61062d029ba7b2eb48c6daca /gdb/python
parent1886886089ccce6186d63a155c9e84544d241789 (diff)
downloadgdb-999633ede794b0241c4fde66903f341890037200.zip
gdb-999633ede794b0241c4fde66903f341890037200.tar.gz
gdb-999633ede794b0241c4fde66903f341890037200.tar.bz2
* python/py-arch.c (gdbpy_initialize_arch): Return 'int'.
Check errors. * python/py-auto-load.c (gdbpy_initialize_auto_load): Return 'int'. * python/py-block.c (gdbpy_initialize_blocks): Return 'int'. Check errors. * python/py-breakpoint.c (gdbpy_initialize_breakpoints): Return 'int'. Check errors. * python/py-cmd.c (gdbpy_initialize_commands): Return 'int'. Check errors. * python/py-event.c (gdbpy_initialize_event): Return 'int'. Check errors. * python/py-event.h (GDBPY_NEW_EVENT_TYPE): Change generated init function to return 'int'. * python/py-evtregistry.c (gdbpy_initialize_eventregistry): Return 'int'. Check errors. * python/py-evts.c (gdbpy_initialize_py_events): Return 'int'. Check errors. * python/py-finishbreakpoint.c (gdbpy_initialize_finishbreakpoints): Return 'int'. Check errors. * python/py-frame.c (gdbpy_initialize_frames): Return 'int'. Check errors. * python/py-function.c (gdbpy_initialize_functions): Return 'int'. Check errors. * python/py-gdb-readline.c (gdbpy_initialize_gdb_readline): Check errors. * python/py-inferior.c (gdbpy_initialize_inferior): Return 'int'. Check errors. * python/py-infthread.c (gdbpy_initialize_thread): Return 'int'. Check errors. * python/py-lazy-string.c (gdbpy_initialize_lazy_string): Return 'int'. Check errors. * python/py-objfile.c (gdbpy_initialize_objfile): Return 'int'. Check errors. * python/py-param.c (gdbpy_initialize_parameters): Return 'int'. Check errors. * python/py-progspace.c (gdbpy_initialize_pspace): Return 'int'. Check errors. * python/py-symbol.c (gdbpy_initialize_symbols): Return 'int'. Check errors. * python/py-symtab.c (gdbpy_initialize_symtabs): Return 'int'. Check errors. * python/py-type.c (gdbpy_initialize_types): Return 'int'. Check errors. * python/py-value.c (gdbpy_initialize_values): Return 'int'. Check errors. * python/python-internal.h (gdbpy_initialize_auto_load, gdbpy_initialize_values, gdbpy_initialize_frames, gdbpy_initialize_symtabs, gdbpy_initialize_commands, gdbpy_initialize_symbols, gdbpy_initialize_symtabs, gdbpy_initialize_blocks, gdbpy_initialize_types, gdbpy_initialize_functions, gdbpy_initialize_pspace, gdbpy_initialize_objfile, gdbpy_initialize_breakpoints, gdbpy_initialize_finishbreakpoints, gdbpy_initialize_lazy_string, gdbpy_initialize_parameters, gdbpy_initialize_thread, gdbpy_initialize_inferior, gdbpy_initialize_eventregistry, gdbpy_initialize_event, gdbpy_initialize_py_events, gdbpy_initialize_stop_event, gdbpy_initialize_signal_event, gdbpy_initialize_breakpoint_event, gdbpy_initialize_continue_event, gdbpy_initialize_exited_event, gdbpy_initialize_thread_event, gdbpy_initialize_new_objfile_event, gdbpy_initialize_arch): Update. Use CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION. * python/python.c (gdb_python_initialized): New global. (gdbpy_initialize_events): Return 'int'. Check errors. (_initialize_python): Check errors. Set gdb_python_initialized.
Diffstat (limited to 'gdb/python')
-rw-r--r--gdb/python/py-arch.c8
-rw-r--r--gdb/python/py-auto-load.c4
-rw-r--r--gdb/python/py-block.c14
-rw-r--r--gdb/python/py-breakpoint.c14
-rw-r--r--gdb/python/py-cmd.c19
-rw-r--r--gdb/python/py-event.c6
-rw-r--r--gdb/python/py-event.h6
-rw-r--r--gdb/python/py-evtregistry.c8
-rw-r--r--gdb/python/py-evts.c19
-rw-r--r--gdb/python/py-finishbreakpoint.c11
-rw-r--r--gdb/python/py-frame.c32
-rw-r--r--gdb/python/py-function.c7
-rw-r--r--gdb/python/py-gdb-readline.c7
-rw-r--r--gdb/python/py-inferior.c15
-rw-r--r--gdb/python/py-infthread.c8
-rw-r--r--gdb/python/py-lazy-string.c5
-rw-r--r--gdb/python/py-objfile.c8
-rw-r--r--gdb/python/py-param.c14
-rw-r--r--gdb/python/py-progspace.c8
-rw-r--r--gdb/python/py-symbol.c79
-rw-r--r--gdb/python/py-symtab.c15
-rw-r--r--gdb/python/py-type.c22
-rw-r--r--gdb/python/py-value.c9
-rw-r--r--gdb/python/python-internal.h87
-rw-r--r--gdb/python/python.c123
25 files changed, 331 insertions, 217 deletions
diff --git a/gdb/python/py-arch.c b/gdb/python/py-arch.c
index 146a642..7920fbb 100644
--- a/gdb/python/py-arch.c
+++ b/gdb/python/py-arch.c
@@ -231,17 +231,17 @@ archpy_disassemble (PyObject *self, PyObject *args, PyObject *kw)
/* Initializes the Architecture class in the gdb module. */
-void
+int
gdbpy_initialize_arch (void)
{
arch_object_data = gdbarch_data_register_post_init (arch_object_data_init);
arch_object_type.tp_new = PyType_GenericNew;
if (PyType_Ready (&arch_object_type) < 0)
- return;
+ return -1;
Py_INCREF (&arch_object_type);
- PyModule_AddObject (gdb_module, "Architecture",
- (PyObject *) &arch_object_type);
+ return PyModule_AddObject (gdb_module, "Architecture",
+ (PyObject *) &arch_object_type);
}
static PyMethodDef arch_object_methods [] = {
diff --git a/gdb/python/py-auto-load.c b/gdb/python/py-auto-load.c
index 53a8eb5e..fa07432 100644
--- a/gdb/python/py-auto-load.c
+++ b/gdb/python/py-auto-load.c
@@ -238,7 +238,7 @@ info_auto_load_python_scripts (char *pattern, int from_tty)
auto_load_info_scripts (pattern, from_tty, &script_language_python);
}
-void
+int
gdbpy_initialize_auto_load (void)
{
struct cmd_list_element *cmd;
@@ -281,6 +281,8 @@ Usage: info auto-load python-scripts [REGEXP]"),
cmd = add_info ("auto-load-scripts", info_auto_load_python_scripts, _("\
Print the list of automatically loaded Python scripts, deprecated."));
deprecate_cmd (cmd, "info auto-load python-scripts");
+
+ return 0;
}
#else /* ! HAVE_PYTHON */
diff --git a/gdb/python/py-block.c b/gdb/python/py-block.c
index afc8959..f2d9000 100644
--- a/gdb/python/py-block.c
+++ b/gdb/python/py-block.c
@@ -425,16 +425,16 @@ del_objfile_blocks (struct objfile *objfile, void *datum)
}
}
-void
+int
gdbpy_initialize_blocks (void)
{
block_object_type.tp_new = PyType_GenericNew;
if (PyType_Ready (&block_object_type) < 0)
- return;
+ return -1;
block_syms_iterator_object_type.tp_new = PyType_GenericNew;
if (PyType_Ready (&block_syms_iterator_object_type) < 0)
- return;
+ return -1;
/* Register an objfile "free" callback so we can properly
invalidate blocks when an object file is about to be
@@ -443,11 +443,13 @@ gdbpy_initialize_blocks (void)
= register_objfile_data_with_cleanup (NULL, del_objfile_blocks);
Py_INCREF (&block_object_type);
- PyModule_AddObject (gdb_module, "Block", (PyObject *) &block_object_type);
+ if (PyModule_AddObject (gdb_module, "Block",
+ (PyObject *) &block_object_type) < 0)
+ return -1;
Py_INCREF (&block_syms_iterator_object_type);
- PyModule_AddObject (gdb_module, "BlockIterator",
- (PyObject *) &block_syms_iterator_object_type);
+ return PyModule_AddObject (gdb_module, "BlockIterator",
+ (PyObject *) &block_syms_iterator_object_type);
}
diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c
index 5e5f9b3..b1b6e93 100644
--- a/gdb/python/py-breakpoint.c
+++ b/gdb/python/py-breakpoint.c
@@ -859,18 +859,19 @@ gdbpy_breakpoint_deleted (struct breakpoint *b)
/* Initialize the Python breakpoint code. */
-void
+int
gdbpy_initialize_breakpoints (void)
{
int i;
breakpoint_object_type.tp_new = PyType_GenericNew;
if (PyType_Ready (&breakpoint_object_type) < 0)
- return;
+ return -1;
Py_INCREF (&breakpoint_object_type);
- PyModule_AddObject (gdb_module, "Breakpoint",
- (PyObject *) &breakpoint_object_type);
+ if (PyModule_AddObject (gdb_module, "Breakpoint",
+ (PyObject *) &breakpoint_object_type) < 0)
+ return -1;
observer_attach_breakpoint_created (gdbpy_breakpoint_created);
observer_attach_breakpoint_deleted (gdbpy_breakpoint_deleted);
@@ -882,7 +883,7 @@ gdbpy_initialize_breakpoints (void)
/* Cast needed for Python 2.4. */
(char *) pybp_codes[i].name,
pybp_codes[i].code) < 0)
- return;
+ return -1;
}
/* Add watchpoint types constants. */
@@ -892,9 +893,10 @@ gdbpy_initialize_breakpoints (void)
/* Cast needed for Python 2.4. */
(char *) pybp_watch_types[i].name,
pybp_watch_types[i].code) < 0)
- return;
+ return -1;
}
+ return 0;
}
diff --git a/gdb/python/py-cmd.c b/gdb/python/py-cmd.c
index 26823c7..ba765e0 100644
--- a/gdb/python/py-cmd.c
+++ b/gdb/python/py-cmd.c
@@ -564,14 +564,14 @@ cmdpy_init (PyObject *self, PyObject *args, PyObject *kw)
/* Initialize the 'commands' code. */
-void
+int
gdbpy_initialize_commands (void)
{
int i;
cmdpy_object_type.tp_new = PyType_GenericNew;
if (PyType_Ready (&cmdpy_object_type) < 0)
- return;
+ return -1;
/* Note: alias and user are special; pseudo appears to be unused,
and there is no reason to expose tui or xdb, I think. */
@@ -592,20 +592,27 @@ gdbpy_initialize_commands (void)
|| PyModule_AddIntConstant (gdb_module, "COMMAND_MAINTENANCE",
class_maintenance) < 0
|| PyModule_AddIntConstant (gdb_module, "COMMAND_USER", class_user) < 0)
- return;
+ return -1;
for (i = 0; i < N_COMPLETERS; ++i)
{
if (PyModule_AddIntConstant (gdb_module, completers[i].name, i) < 0)
- return;
+ return -1;
}
Py_INCREF (&cmdpy_object_type);
- PyModule_AddObject (gdb_module, "Command",
- (PyObject *) &cmdpy_object_type);
+ if (PyModule_AddObject (gdb_module, "Command",
+ (PyObject *) &cmdpy_object_type) < 0)
+ return -1;
invoke_cst = PyString_FromString ("invoke");
+ if (invoke_cst == NULL)
+ return -1;
complete_cst = PyString_FromString ("complete");
+ if (complete_cst == NULL)
+ return -1;
+
+ return 0;
}
diff --git a/gdb/python/py-event.c b/gdb/python/py-event.c
index 72d57cb..04f33ab 100644
--- a/gdb/python/py-event.c
+++ b/gdb/python/py-event.c
@@ -60,11 +60,11 @@ evpy_add_attribute (PyObject *event, char *name, PyObject *attr)
/* Initialize the Python event code. */
-void
+int
gdbpy_initialize_event (void)
{
- 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
diff --git a/gdb/python/py-event.h b/gdb/python/py-event.h
index 4850f1a..f0ff629 100644
--- a/gdb/python/py-event.h
+++ b/gdb/python/py-event.h
@@ -88,11 +88,11 @@
0 /* tp_alloc */ \
}; \
\
-void \
+int \
gdbpy_initialize_##name##_event (void) \
{ \
- gdbpy_initialize_event_generic (&name##_event_object_type, \
- py_name); \
+ return gdbpy_initialize_event_generic (&name##_event_object_type, \
+ py_name); \
}
typedef struct
diff --git a/gdb/python/py-evtregistry.c b/gdb/python/py-evtregistry.c
index 05c8586..d7cbe64 100644
--- a/gdb/python/py-evtregistry.c
+++ b/gdb/python/py-evtregistry.c
@@ -106,15 +106,15 @@ evregpy_dealloc (PyObject *self)
/* Initialize the Python event registry code. */
-void
+int
gdbpy_initialize_eventregistry (void)
{
if (PyType_Ready (&eventregistry_object_type) < 0)
- return;
+ return -1;
Py_INCREF (&eventregistry_object_type);
- PyModule_AddObject (gdb_module, "EventRegistry",
- (PyObject *) &eventregistry_object_type);
+ return PyModule_AddObject (gdb_module, "EventRegistry",
+ (PyObject *) &eventregistry_object_type);
}
/* Retern the number of listeners currently connected to this
diff --git a/gdb/python/py-evts.c b/gdb/python/py-evts.c
index 427b6d5..bb384e3 100644
--- a/gdb/python/py-evts.c
+++ b/gdb/python/py-evts.c
@@ -57,7 +57,7 @@ add_new_registry (eventregistry_object **registryp, char *name)
return -1;
}
-void
+int
gdbpy_initialize_py_events (void)
{
#ifdef IS_PY3K
@@ -67,19 +67,19 @@ gdbpy_initialize_py_events (void)
#endif
if (!gdb_py_events.module)
- goto fail;
+ return -1;
if (add_new_registry (&gdb_py_events.stop, "stop") < 0)
- goto fail;
+ return -1;
if (add_new_registry (&gdb_py_events.cont, "cont") < 0)
- goto fail;
+ return -1;
if (add_new_registry (&gdb_py_events.exited, "exited") < 0)
- goto fail;
+ return -1;
if (add_new_registry (&gdb_py_events.new_objfile, "new_objfile") < 0)
- goto fail;
+ return -1;
#ifndef IS_PY3K
Py_INCREF (gdb_py_events.module);
@@ -87,10 +87,7 @@ gdbpy_initialize_py_events (void)
if (PyModule_AddObject (gdb_module,
"events",
(PyObject *) gdb_py_events.module) < 0)
- goto fail;
-
- return;
+ return -1;
- fail:
- gdbpy_print_stack ();
+ return 0;
}
diff --git a/gdb/python/py-finishbreakpoint.c b/gdb/python/py-finishbreakpoint.c
index f65e026..5fd1f4b 100644
--- a/gdb/python/py-finishbreakpoint.c
+++ b/gdb/python/py-finishbreakpoint.c
@@ -407,18 +407,21 @@ bpfinishpy_handle_exit (struct inferior *inf)
/* Initialize the Python finish breakpoint code. */
-void
+int
gdbpy_initialize_finishbreakpoints (void)
{
if (PyType_Ready (&finish_breakpoint_object_type) < 0)
- return;
+ return -1;
Py_INCREF (&finish_breakpoint_object_type);
- PyModule_AddObject (gdb_module, "FinishBreakpoint",
- (PyObject *) &finish_breakpoint_object_type);
+ if (PyModule_AddObject (gdb_module, "FinishBreakpoint",
+ (PyObject *) &finish_breakpoint_object_type) < 0)
+ return -1;
observer_attach_normal_stop (bpfinishpy_handle_stop);
observer_attach_inferior_exit (bpfinishpy_handle_exit);
+
+ return 0;
}
static PyGetSetDef finish_breakpoint_object_getset[] = {
diff --git a/gdb/python/py-frame.c b/gdb/python/py-frame.c
index 9342f45..5d3a8c2 100644
--- a/gdb/python/py-frame.c
+++ b/gdb/python/py-frame.c
@@ -606,33 +606,41 @@ frapy_richcompare (PyObject *self, PyObject *other, int op)
/* Sets up the Frame API in the gdb module. */
-void
+int
gdbpy_initialize_frames (void)
{
frame_object_type.tp_new = PyType_GenericNew;
if (PyType_Ready (&frame_object_type) < 0)
- return;
+ return -1;
/* Note: These would probably be best exposed as class attributes of
Frame, but I don't know how to do it except by messing with the
type's dictionary. That seems too messy. */
- PyModule_AddIntConstant (gdb_module, "NORMAL_FRAME", NORMAL_FRAME);
- PyModule_AddIntConstant (gdb_module, "DUMMY_FRAME", DUMMY_FRAME);
- PyModule_AddIntConstant (gdb_module, "INLINE_FRAME", INLINE_FRAME);
- PyModule_AddIntConstant (gdb_module, "TAILCALL_FRAME", TAILCALL_FRAME);
- PyModule_AddIntConstant (gdb_module, "SIGTRAMP_FRAME", SIGTRAMP_FRAME);
- PyModule_AddIntConstant (gdb_module, "ARCH_FRAME", ARCH_FRAME);
- PyModule_AddIntConstant (gdb_module, "SENTINEL_FRAME", SENTINEL_FRAME);
+ 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, "ARCH_FRAME", ARCH_FRAME) < 0
+ || PyModule_AddIntConstant (gdb_module, "SENTINEL_FRAME",
+ SENTINEL_FRAME) < 0)
+ return -1;
#define SET(name, description) \
- PyModule_AddIntConstant (gdb_module, "FRAME_"#name, name);
+ if (PyModule_AddIntConstant (gdb_module, "FRAME_"#name, name) < 0) \
+ return -1;
#define FIRST_ERROR(name) \
- PyModule_AddIntConstant (gdb_module, "FRAME_"#name, name);
+ if (PyModule_AddIntConstant (gdb_module, "FRAME_"#name, name) < 0) \
+ return -1;
#include "unwind_stop_reasons.def"
#undef SET
+#undef FIRST_ERROR
Py_INCREF (&frame_object_type);
- PyModule_AddObject (gdb_module, "Frame", (PyObject *) &frame_object_type);
+ return PyModule_AddObject (gdb_module, "Frame",
+ (PyObject *) &frame_object_type);
}
diff --git a/gdb/python/py-function.c b/gdb/python/py-function.c
index 395eeda..57cdfae 100644
--- a/gdb/python/py-function.c
+++ b/gdb/python/py-function.c
@@ -200,15 +200,16 @@ fnpy_init (PyObject *self, PyObject *args, PyObject *kwds)
/* Initialize internal function support. */
-void
+int
gdbpy_initialize_functions (void)
{
fnpy_object_type.tp_new = PyType_GenericNew;
if (PyType_Ready (&fnpy_object_type) < 0)
- return;
+ return -1;
Py_INCREF (&fnpy_object_type);
- PyModule_AddObject (gdb_module, "Function", (PyObject *) &fnpy_object_type);
+ return PyModule_AddObject (gdb_module, "Function",
+ (PyObject *) &fnpy_object_type);
}
diff --git a/gdb/python/py-gdb-readline.c b/gdb/python/py-gdb-readline.c
index ca7e4a6..d6576a3 100644
--- a/gdb/python/py-gdb-readline.c
+++ b/gdb/python/py-gdb-readline.c
@@ -93,7 +93,7 @@ gdbpy_initialize_gdb_readline (void)
and prevent conflicts. For now, this file implements a
sys.meta_path finder that simply fails to import the readline
module. */
- PyRun_SimpleString ("\
+ if (PyRun_SimpleString ("\
import sys\n\
\n\
class GdbRemoveReadlineFinder:\n\
@@ -106,8 +106,7 @@ class GdbRemoveReadlineFinder:\n\
raise ImportError('readline module disabled under GDB')\n\
\n\
sys.meta_path.append(GdbRemoveReadlineFinder())\n\
-");
-
- PyOS_ReadlineFunctionPointer = gdbpy_readline_wrapper;
+") == 0)
+ PyOS_ReadlineFunctionPointer = gdbpy_readline_wrapper;
}
diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c
index 4e68cdd..18ddecd 100644
--- a/gdb/python/py-inferior.c
+++ b/gdb/python/py-inferior.c
@@ -760,15 +760,16 @@ gdbpy_selected_inferior (PyObject *self, PyObject *args)
return inf_obj;
}
-void
+int
gdbpy_initialize_inferior (void)
{
if (PyType_Ready (&inferior_object_type) < 0)
- return;
+ return -1;
Py_INCREF (&inferior_object_type);
- PyModule_AddObject (gdb_module, "Inferior",
- (PyObject *) &inferior_object_type);
+ if (PyModule_AddObject (gdb_module, "Inferior",
+ (PyObject *) &inferior_object_type) < 0)
+ return -1;
infpy_inf_data_key =
register_inferior_data_with_cleanup (NULL, py_free_inferior);
@@ -782,11 +783,11 @@ gdbpy_initialize_inferior (void)
membuf_object_type.tp_new = PyType_GenericNew;
if (PyType_Ready (&membuf_object_type) < 0)
- return;
+ return -1;
Py_INCREF (&membuf_object_type);
- PyModule_AddObject (gdb_module, "Membuf", (PyObject *)
- &membuf_object_type);
+ return PyModule_AddObject (gdb_module, "Membuf", (PyObject *)
+ &membuf_object_type);
}
static PyGetSetDef inferior_object_getset[] =
diff --git a/gdb/python/py-infthread.c b/gdb/python/py-infthread.c
index a0545ec..7a5f262 100644
--- a/gdb/python/py-infthread.c
+++ b/gdb/python/py-infthread.c
@@ -255,15 +255,15 @@ gdbpy_selected_thread (PyObject *self, PyObject *args)
-void
+int
gdbpy_initialize_thread (void)
{
if (PyType_Ready (&thread_object_type) < 0)
- return;
+ return -1;
Py_INCREF (&thread_object_type);
- PyModule_AddObject (gdb_module, "InferiorThread",
- (PyObject *) &thread_object_type);
+ return PyModule_AddObject (gdb_module, "InferiorThread",
+ (PyObject *) &thread_object_type);
}
diff --git a/gdb/python/py-lazy-string.c b/gdb/python/py-lazy-string.c
index df54cf4..ea193a9 100644
--- a/gdb/python/py-lazy-string.c
+++ b/gdb/python/py-lazy-string.c
@@ -160,13 +160,14 @@ gdbpy_create_lazy_string_object (CORE_ADDR address, long length,
return (PyObject *) str_obj;
}
-void
+int
gdbpy_initialize_lazy_string (void)
{
if (PyType_Ready (&lazy_string_object_type) < 0)
- return;
+ return -1;
Py_INCREF (&lazy_string_object_type);
+ return 0;
}
/* Determine whether the printer object pointed to by OBJ is a
diff --git a/gdb/python/py-objfile.c b/gdb/python/py-objfile.c
index 27f3463..d8c893c 100644
--- a/gdb/python/py-objfile.c
+++ b/gdb/python/py-objfile.c
@@ -298,18 +298,18 @@ objfile_to_objfile_object (struct objfile *objfile)
return (PyObject *) object;
}
-void
+int
gdbpy_initialize_objfile (void)
{
objfpy_objfile_data_key
= register_objfile_data_with_cleanup (NULL, py_free_objfile);
if (PyType_Ready (&objfile_object_type) < 0)
- return;
+ return -1;
Py_INCREF (&objfile_object_type);
- PyModule_AddObject (gdb_module, "Objfile",
- (PyObject *) &objfile_object_type);
+ return PyModule_AddObject (gdb_module, "Objfile",
+ (PyObject *) &objfile_object_type);
}
diff --git a/gdb/python/py-param.c b/gdb/python/py-param.c
index 176bbc2..2cc17b6 100644
--- a/gdb/python/py-param.c
+++ b/gdb/python/py-param.c
@@ -749,33 +749,33 @@ parmpy_init (PyObject *self, PyObject *args, PyObject *kwds)
/* Initialize the 'parameters' module. */
-void
+int
gdbpy_initialize_parameters (void)
{
int i;
parmpy_object_type.tp_new = PyType_GenericNew;
if (PyType_Ready (&parmpy_object_type) < 0)
- return;
+ return -1;
set_doc_cst = PyString_FromString ("set_doc");
if (! set_doc_cst)
- return;
+ return -1;
show_doc_cst = PyString_FromString ("show_doc");
if (! show_doc_cst)
- return;
+ return -1;
for (i = 0; parm_constants[i].name; ++i)
{
if (PyModule_AddIntConstant (gdb_module,
parm_constants[i].name,
parm_constants[i].value) < 0)
- return;
+ return -1;
}
Py_INCREF (&parmpy_object_type);
- PyModule_AddObject (gdb_module, "Parameter",
- (PyObject *) &parmpy_object_type);
+ return PyModule_AddObject (gdb_module, "Parameter",
+ (PyObject *) &parmpy_object_type);
}
diff --git a/gdb/python/py-progspace.c b/gdb/python/py-progspace.c
index 5d4911a..9913313 100644
--- a/gdb/python/py-progspace.c
+++ b/gdb/python/py-progspace.c
@@ -294,18 +294,18 @@ pspace_to_pspace_object (struct program_space *pspace)
return (PyObject *) object;
}
-void
+int
gdbpy_initialize_pspace (void)
{
pspy_pspace_data_key
= register_program_space_data_with_cleanup (NULL, py_free_pspace);
if (PyType_Ready (&pspace_object_type) < 0)
- return;
+ return -1;
Py_INCREF (&pspace_object_type);
- PyModule_AddObject (gdb_module, "Progspace",
- (PyObject *) &pspace_object_type);
+ return PyModule_AddObject (gdb_module, "Progspace",
+ (PyObject *) &pspace_object_type);
}
diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c
index def0fdd..7629f70 100644
--- a/gdb/python/py-symbol.c
+++ b/gdb/python/py-symbol.c
@@ -474,11 +474,11 @@ del_objfile_symbols (struct objfile *objfile, void *datum)
}
}
-void
+int
gdbpy_initialize_symbols (void)
{
if (PyType_Ready (&symbol_object_type) < 0)
- return;
+ return -1;
/* Register an objfile "free" callback so we can properly
invalidate symbol when an object file that is about to be
@@ -486,37 +486,54 @@ gdbpy_initialize_symbols (void)
sympy_objfile_data_key
= register_objfile_data_with_cleanup (NULL, del_objfile_symbols);
- PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_UNDEF", LOC_UNDEF);
- PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_CONST", LOC_CONST);
- PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_STATIC", LOC_STATIC);
- PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_REGISTER", LOC_REGISTER);
- PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_ARG", LOC_ARG);
- PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_REF_ARG", LOC_REF_ARG);
- PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_LOCAL", LOC_LOCAL);
- PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_TYPEDEF", LOC_TYPEDEF);
- PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_LABEL", LOC_LABEL);
- PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_BLOCK", LOC_BLOCK);
- PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_CONST_BYTES",
- LOC_CONST_BYTES);
- PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_UNRESOLVED",
- LOC_UNRESOLVED);
- PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_OPTIMIZED_OUT",
- LOC_OPTIMIZED_OUT);
- PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_COMPUTED", LOC_COMPUTED);
- PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_REGPARM_ADDR",
- LOC_REGPARM_ADDR);
- PyModule_AddIntConstant (gdb_module, "SYMBOL_UNDEF_DOMAIN", UNDEF_DOMAIN);
- PyModule_AddIntConstant (gdb_module, "SYMBOL_VAR_DOMAIN", VAR_DOMAIN);
- PyModule_AddIntConstant (gdb_module, "SYMBOL_STRUCT_DOMAIN", STRUCT_DOMAIN);
- PyModule_AddIntConstant (gdb_module, "SYMBOL_LABEL_DOMAIN", LABEL_DOMAIN);
- PyModule_AddIntConstant (gdb_module, "SYMBOL_VARIABLES_DOMAIN",
- VARIABLES_DOMAIN);
- PyModule_AddIntConstant (gdb_module, "SYMBOL_FUNCTIONS_DOMAIN",
- FUNCTIONS_DOMAIN);
- PyModule_AddIntConstant (gdb_module, "SYMBOL_TYPES_DOMAIN", TYPES_DOMAIN);
+ 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_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_VARIABLES_DOMAIN",
+ VARIABLES_DOMAIN) < 0
+ || PyModule_AddIntConstant (gdb_module, "SYMBOL_FUNCTIONS_DOMAIN",
+ FUNCTIONS_DOMAIN) < 0
+ || PyModule_AddIntConstant (gdb_module, "SYMBOL_TYPES_DOMAIN",
+ TYPES_DOMAIN) < 0)
+ return -1;
Py_INCREF (&symbol_object_type);
- PyModule_AddObject (gdb_module, "Symbol", (PyObject *) &symbol_object_type);
+ return PyModule_AddObject (gdb_module, "Symbol",
+ (PyObject *) &symbol_object_type);
}
diff --git a/gdb/python/py-symtab.c b/gdb/python/py-symtab.c
index 94c05be..80a2282 100644
--- a/gdb/python/py-symtab.c
+++ b/gdb/python/py-symtab.c
@@ -484,16 +484,16 @@ del_objfile_sal (struct objfile *objfile, void *datum)
}
}
-void
+int
gdbpy_initialize_symtabs (void)
{
symtab_object_type.tp_new = PyType_GenericNew;
if (PyType_Ready (&symtab_object_type) < 0)
- return;
+ return -1;
sal_object_type.tp_new = PyType_GenericNew;
if (PyType_Ready (&sal_object_type) < 0)
- return;
+ return -1;
/* Register an objfile "free" callback so we can properly
invalidate symbol tables, and symbol table and line data
@@ -505,12 +505,13 @@ gdbpy_initialize_symtabs (void)
= register_objfile_data_with_cleanup (NULL, del_objfile_sal);
Py_INCREF (&symtab_object_type);
- PyModule_AddObject (gdb_module, "Symtab",
- (PyObject *) &symtab_object_type);
+ if (PyModule_AddObject (gdb_module, "Symtab",
+ (PyObject *) &symtab_object_type) < 0)
+ return -1;
Py_INCREF (&sal_object_type);
- PyModule_AddObject (gdb_module, "Symtab_and_line",
- (PyObject *) &sal_object_type);
+ return PyModule_AddObject (gdb_module, "Symtab_and_line",
+ (PyObject *) &sal_object_type);
}
diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c
index e29ae81..05e251b 100644
--- a/gdb/python/py-type.c
+++ b/gdb/python/py-type.c
@@ -1521,7 +1521,7 @@ gdbpy_lookup_type (PyObject *self, PyObject *args, PyObject *kw)
return (PyObject *) type_to_type_object (type);
}
-void
+int
gdbpy_initialize_types (void)
{
int i;
@@ -1530,11 +1530,11 @@ gdbpy_initialize_types (void)
= register_objfile_data_with_cleanup (save_objfile_types, NULL);
if (PyType_Ready (&type_object_type) < 0)
- return;
+ return -1;
if (PyType_Ready (&field_object_type) < 0)
- return;
+ return -1;
if (PyType_Ready (&type_iterator_object_type) < 0)
- return;
+ return -1;
for (i = 0; pyty_codes[i].name; ++i)
{
@@ -1542,18 +1542,22 @@ gdbpy_initialize_types (void)
/* Cast needed for Python 2.4. */
(char *) pyty_codes[i].name,
pyty_codes[i].code) < 0)
- return;
+ return -1;
}
Py_INCREF (&type_object_type);
- PyModule_AddObject (gdb_module, "Type", (PyObject *) &type_object_type);
+ if (PyModule_AddObject (gdb_module, "Type",
+ (PyObject *) &type_object_type) < 0)
+ return -1;
Py_INCREF (&type_iterator_object_type);
- PyModule_AddObject (gdb_module, "TypeIterator",
- (PyObject *) &type_iterator_object_type);
+ if (PyModule_AddObject (gdb_module, "TypeIterator",
+ (PyObject *) &type_iterator_object_type) < 0)
+ return -1;
Py_INCREF (&field_object_type);
- PyModule_AddObject (gdb_module, "Field", (PyObject *) &field_object_type);
+ return PyModule_AddObject (gdb_module, "Field",
+ (PyObject *) &field_object_type);
}
diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c
index 2cbb0cb..762993b 100644
--- a/gdb/python/py-value.c
+++ b/gdb/python/py-value.c
@@ -1386,16 +1386,15 @@ gdbpy_is_value_object (PyObject *obj)
return PyObject_TypeCheck (obj, &value_object_type);
}
-void
+int
gdbpy_initialize_values (void)
{
if (PyType_Ready (&value_object_type) < 0)
- return;
+ return -1;
Py_INCREF (&value_object_type);
- PyModule_AddObject (gdb_module, "Value", (PyObject *) &value_object_type);
-
- values_in_python = NULL;
+ return PyModule_AddObject (gdb_module, "Value",
+ (PyObject *) &value_object_type);
}
diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h
index 29c22f7..695bcd3 100644
--- a/gdb/python/python-internal.h
+++ b/gdb/python/python-internal.h
@@ -324,35 +324,64 @@ struct frame_info *frame_object_to_frame_info (PyObject *frame_obj);
struct gdbarch *arch_object_to_gdbarch (PyObject *obj);
void gdbpy_initialize_gdb_readline (void);
-void gdbpy_initialize_auto_load (void);
-void gdbpy_initialize_values (void);
-void gdbpy_initialize_frames (void);
-void gdbpy_initialize_symtabs (void);
-void gdbpy_initialize_commands (void);
-void gdbpy_initialize_symbols (void);
-void gdbpy_initialize_symtabs (void);
-void gdbpy_initialize_blocks (void);
-void gdbpy_initialize_types (void);
-void gdbpy_initialize_functions (void);
-void gdbpy_initialize_pspace (void);
-void gdbpy_initialize_objfile (void);
-void gdbpy_initialize_breakpoints (void);
-void gdbpy_initialize_finishbreakpoints (void);
-void gdbpy_initialize_lazy_string (void);
-void gdbpy_initialize_parameters (void);
-void gdbpy_initialize_thread (void);
-void gdbpy_initialize_inferior (void);
-void gdbpy_initialize_eventregistry (void);
-void gdbpy_initialize_event (void);
-void gdbpy_initialize_py_events (void);
-void gdbpy_initialize_stop_event (void);
-void gdbpy_initialize_signal_event (void);
-void gdbpy_initialize_breakpoint_event (void);
-void gdbpy_initialize_continue_event (void);
-void gdbpy_initialize_exited_event (void);
-void gdbpy_initialize_thread_event (void);
-void gdbpy_initialize_new_objfile_event (void);
-void gdbpy_initialize_arch (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_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_finishbreakpoints (void)
+ CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
+int gdbpy_initialize_lazy_string (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_py_events (void)
+ CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
+int gdbpy_initialize_stop_event (void)
+ CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
+int gdbpy_initialize_signal_event (void)
+ CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
+int gdbpy_initialize_breakpoint_event (void)
+ CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
+int gdbpy_initialize_continue_event (void)
+ CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
+int gdbpy_initialize_exited_event (void)
+ CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
+int gdbpy_initialize_thread_event (void)
+ CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
+int gdbpy_initialize_new_objfile_event (void)
+ CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
+int gdbpy_initialize_arch (void)
+ CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
struct cleanup *make_cleanup_py_decref (PyObject *py);
struct cleanup *make_cleanup_py_xdecref (PyObject *py);
diff --git a/gdb/python/python.c b/gdb/python/python.c
index 90581e5..5b5afcf 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -73,6 +73,11 @@ static const char *gdbpy_should_print_stack = python_excp_message;
#include "interps.h"
#include "event-top.h"
+/* True if Python has been successfully initialized, false
+ otherwise. */
+
+int gdb_python_initialized;
+
static PyMethodDef GdbMethods[];
#ifdef IS_PY3K
@@ -871,7 +876,7 @@ gdbpy_post_event (PyObject *self, PyObject *args)
}
/* Initialize the Python event handler. */
-static void
+static int
gdbpy_initialize_events (void)
{
if (serial_pipe (gdbpy_event_fds) == 0)
@@ -879,6 +884,8 @@ gdbpy_initialize_events (void)
gdbpy_event_list_end = &gdbpy_event_list;
serial_async (gdbpy_event_fds[0], gdbpy_run_events, NULL);
}
+
+ return 0;
}
@@ -1589,74 +1596,108 @@ message == an error message without a stack will be printed."),
#else
gdb_module = Py_InitModule ("_gdb", GdbMethods);
#endif
+ if (gdb_module == NULL)
+ goto fail;
/* The casts to (char*) are for python 2.4. */
- PyModule_AddStringConstant (gdb_module, "VERSION", (char*) version);
- PyModule_AddStringConstant (gdb_module, "HOST_CONFIG", (char*) host_name);
- PyModule_AddStringConstant (gdb_module, "TARGET_CONFIG",
- (char*) target_name);
+ if (PyModule_AddStringConstant (gdb_module, "VERSION", (char*) version) < 0
+ || PyModule_AddStringConstant (gdb_module, "HOST_CONFIG",
+ (char*) host_name) < 0
+ || PyModule_AddStringConstant (gdb_module, "TARGET_CONFIG",
+ (char*) target_name) < 0)
+ goto fail;
/* Add stream constants. */
- PyModule_AddIntConstant (gdb_module, "STDOUT", 0);
- PyModule_AddIntConstant (gdb_module, "STDERR", 1);
- PyModule_AddIntConstant (gdb_module, "STDLOG", 2);
+ if (PyModule_AddIntConstant (gdb_module, "STDOUT", 0) < 0
+ || PyModule_AddIntConstant (gdb_module, "STDERR", 1) < 0
+ || PyModule_AddIntConstant (gdb_module, "STDLOG", 2) < 0)
+ goto fail;
gdbpy_gdb_error = PyErr_NewException ("gdb.error", PyExc_RuntimeError, NULL);
- PyModule_AddObject (gdb_module, "error", gdbpy_gdb_error);
+ if (gdbpy_gdb_error == NULL
+ || PyModule_AddObject (gdb_module, "error", gdbpy_gdb_error) < 0)
+ goto fail;
gdbpy_gdb_memory_error = PyErr_NewException ("gdb.MemoryError",
gdbpy_gdb_error, NULL);
- PyModule_AddObject (gdb_module, "MemoryError", gdbpy_gdb_memory_error);
+ if (gdbpy_gdb_memory_error == NULL
+ || PyModule_AddObject (gdb_module, "MemoryError",
+ gdbpy_gdb_memory_error) < 0)
+ goto fail;
gdbpy_gdberror_exc = PyErr_NewException ("gdb.GdbError", NULL, NULL);
- PyModule_AddObject (gdb_module, "GdbError", gdbpy_gdberror_exc);
+ if (gdbpy_gdberror_exc == NULL
+ || PyModule_AddObject (gdb_module, "GdbError", gdbpy_gdberror_exc) < 0)
+ goto fail;
gdbpy_initialize_gdb_readline ();
- gdbpy_initialize_auto_load ();
- gdbpy_initialize_values ();
- gdbpy_initialize_frames ();
- gdbpy_initialize_commands ();
- gdbpy_initialize_symbols ();
- gdbpy_initialize_symtabs ();
- gdbpy_initialize_blocks ();
- gdbpy_initialize_functions ();
- gdbpy_initialize_parameters ();
- gdbpy_initialize_types ();
- gdbpy_initialize_pspace ();
- gdbpy_initialize_objfile ();
- gdbpy_initialize_breakpoints ();
- gdbpy_initialize_finishbreakpoints ();
- gdbpy_initialize_lazy_string ();
- gdbpy_initialize_thread ();
- gdbpy_initialize_inferior ();
- gdbpy_initialize_events ();
-
- gdbpy_initialize_eventregistry ();
- gdbpy_initialize_py_events ();
- gdbpy_initialize_event ();
- gdbpy_initialize_stop_event ();
- gdbpy_initialize_signal_event ();
- gdbpy_initialize_breakpoint_event ();
- gdbpy_initialize_continue_event ();
- gdbpy_initialize_exited_event ();
- gdbpy_initialize_thread_event ();
- gdbpy_initialize_new_objfile_event () ;
- gdbpy_initialize_arch ();
+
+ if (gdbpy_initialize_auto_load () < 0
+ || gdbpy_initialize_values () < 0
+ || gdbpy_initialize_frames () < 0
+ || gdbpy_initialize_commands () < 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_breakpoints () < 0
+ || gdbpy_initialize_finishbreakpoints () < 0
+ || gdbpy_initialize_lazy_string () < 0
+ || gdbpy_initialize_thread () < 0
+ || gdbpy_initialize_inferior () < 0
+ || gdbpy_initialize_events () < 0
+ || gdbpy_initialize_eventregistry () < 0
+ || gdbpy_initialize_py_events () < 0
+ || gdbpy_initialize_event () < 0
+ || gdbpy_initialize_stop_event () < 0
+ || gdbpy_initialize_signal_event () < 0
+ || gdbpy_initialize_breakpoint_event () < 0
+ || gdbpy_initialize_continue_event () < 0
+ || gdbpy_initialize_exited_event () < 0
+ || gdbpy_initialize_thread_event () < 0
+ || gdbpy_initialize_new_objfile_event () < 0
+ || gdbpy_initialize_arch () < 0)
+ goto fail;
observer_attach_before_prompt (before_prompt_hook);
gdbpy_to_string_cst = PyString_FromString ("to_string");
+ if (gdbpy_to_string_cst == NULL)
+ goto fail;
gdbpy_children_cst = PyString_FromString ("children");
+ if (gdbpy_children_cst == NULL)
+ goto fail;
gdbpy_display_hint_cst = PyString_FromString ("display_hint");
+ if (gdbpy_display_hint_cst == NULL)
+ goto fail;
gdbpy_doc_cst = PyString_FromString ("__doc__");
+ if (gdbpy_doc_cst == NULL)
+ goto fail;
gdbpy_enabled_cst = PyString_FromString ("enabled");
+ if (gdbpy_enabled_cst == NULL)
+ goto fail;
gdbpy_value_cst = PyString_FromString ("value");
+ if (gdbpy_value_cst == NULL)
+ goto fail;
/* Release the GIL while gdb runs. */
PyThreadState_Swap (NULL);
PyEval_ReleaseLock ();
make_final_cleanup (finalize_python, NULL);
+
+ gdb_python_initialized = 1;
+ return;
+
+ fail:
+ gdbpy_print_stack ();
+ /* Do not set 'gdb_python_initialized'. */
+ return;
+
#endif /* HAVE_PYTHON */
}