/* Gdb/Python header for private use by Python module.
- Copyright (C) 2008-2021 Free Software Foundation, Inc.
+ Copyright (C) 2008-2022 Free Software Foundation, Inc.
This file is part of GDB.
struct value;
struct language_defn;
struct program_space;
-struct bpstats;
+struct bpstat;
struct inferior;
extern int gdb_python_initialized;
\f
PyObject *gdbpy_history (PyObject *self, PyObject *args);
PyObject *gdbpy_add_history (PyObject *self, PyObject *args);
+extern PyObject *gdbpy_history_count (PyObject *self, PyObject *args);
PyObject *gdbpy_convenience_variable (PyObject *self, PyObject *args);
PyObject *gdbpy_set_convenience_variable (PyObject *self, PyObject *args);
PyObject *gdbpy_breakpoints (PyObject *, PyObject *);
PyObject *gdbpy_buffer_to_membuf (gdb::unique_xmalloc_ptr<gdb_byte> buffer,
CORE_ADDR address, ULONGEST length);
+struct process_stratum_target;
+gdbpy_ref<> target_to_connection_object (process_stratum_target *target);
+PyObject *gdbpy_connections (PyObject *self, PyObject *args);
+
const struct block *block_object_to_block (PyObject *obj);
struct symbol *symbol_object_to_symbol (PyObject *obj);
struct value *value_object_to_value (PyObject *self);
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
int gdbpy_initialize_membuf ()
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
+int gdbpy_initialize_connection ()
+ CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
/* A wrapper for PyErr_Fetch that handles reference counting for the
caller. */
{
public:
- gdbpy_enter (struct gdbarch *gdbarch, const struct language_defn *language);
+ /* Set the ambient Python architecture to GDBARCH and the language
+ to LANGUAGE. If GDBARCH is nullptr, then the architecture will
+ be computed, when needed, using get_current_arch; see the
+ get_gdbarch method. If LANGUAGE is not nullptr, then the current
+ language at time of construction will be saved (to be restored on
+ destruction), and the current language will be set to
+ LANGUAGE. */
+ explicit gdbpy_enter (struct gdbarch *gdbarch = nullptr,
+ const struct language_defn *language = nullptr);
~gdbpy_enter ();
DISABLE_COPY_AND_ASSIGN (gdbpy_enter);
+ /* Return the current gdbarch, as known to the Python layer. This
+ is either python_gdbarch (which comes from the most recent call
+ to the gdbpy_enter constructor), or, if that is nullptr, the
+ result of get_current_arch. */
+ static struct gdbarch *get_gdbarch ();
+
+ /* Called only during gdb shutdown. This sets python_gdbarch to an
+ acceptable value. */
+ static void finalize ();
+
private:
+ /* The current gdbarch, according to Python. This can be
+ nullptr. */
+ static struct gdbarch *python_gdbarch;
+
struct active_ext_lang_state *m_previous_active;
PyGILState_STATE m_state;
struct gdbarch *m_gdbarch;
PyThreadState *m_save;
};
-extern struct gdbarch *python_gdbarch;
-extern const struct language_defn *python_language;
-
/* Use this after a TRY_EXCEPT to throw the appropriate Python
exception. */
#define GDB_PY_HANDLE_EXCEPTION(Exception) \