xref: /dflybsd-src/contrib/gdb-7/gdb/python/python-internal.h (revision de8e141f24382815c10a4012d209bbbf7abf1112)
1c50c785cSJohn Marino /* Gdb/Python header for private use by Python module.
2c50c785cSJohn Marino 
3*ef5ccd6cSJohn Marino    Copyright (C) 2008-2013 Free Software Foundation, Inc.
4c50c785cSJohn Marino 
5c50c785cSJohn Marino    This file is part of GDB.
6c50c785cSJohn Marino 
7c50c785cSJohn Marino    This program is free software; you can redistribute it and/or modify
8c50c785cSJohn Marino    it under the terms of the GNU General Public License as published by
9c50c785cSJohn Marino    the Free Software Foundation; either version 3 of the License, or
10c50c785cSJohn Marino    (at your option) any later version.
11c50c785cSJohn Marino 
12c50c785cSJohn Marino    This program is distributed in the hope that it will be useful,
13c50c785cSJohn Marino    but WITHOUT ANY WARRANTY; without even the implied warranty of
14c50c785cSJohn Marino    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15c50c785cSJohn Marino    GNU General Public License for more details.
16c50c785cSJohn Marino 
17c50c785cSJohn Marino    You should have received a copy of the GNU General Public License
18c50c785cSJohn Marino    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
19c50c785cSJohn Marino 
20c50c785cSJohn Marino #ifndef GDB_PYTHON_INTERNAL_H
21c50c785cSJohn Marino #define GDB_PYTHON_INTERNAL_H
22c50c785cSJohn Marino 
23c50c785cSJohn Marino #include <stdio.h>
24c50c785cSJohn Marino 
25c50c785cSJohn Marino /* Python 2.4 doesn't include stdint.h soon enough to get {u,}intptr_t
26c50c785cSJohn Marino    needed by pyport.h.  */
27c50c785cSJohn Marino #include <stdint.h>
28c50c785cSJohn Marino 
29c50c785cSJohn Marino /* /usr/include/features.h on linux systems will define _POSIX_C_SOURCE
30c50c785cSJohn Marino    if it sees _GNU_SOURCE (which config.h will define).
31c50c785cSJohn Marino    pyconfig.h defines _POSIX_C_SOURCE to a different value than
32c50c785cSJohn Marino    /usr/include/features.h does causing compilation to fail.
33c50c785cSJohn Marino    To work around this, undef _POSIX_C_SOURCE before we include Python.h.
34c50c785cSJohn Marino 
35c50c785cSJohn Marino    Same problem with _XOPEN_SOURCE.  */
36c50c785cSJohn Marino #undef _POSIX_C_SOURCE
37c50c785cSJohn Marino #undef _XOPEN_SOURCE
38c50c785cSJohn Marino 
39c50c785cSJohn Marino /* On sparc-solaris, /usr/include/sys/feature_tests.h defines
40c50c785cSJohn Marino    _FILE_OFFSET_BITS, which pyconfig.h also defines.  Same work
41c50c785cSJohn Marino    around technique as above.  */
42c50c785cSJohn Marino #undef _FILE_OFFSET_BITS
43c50c785cSJohn Marino 
44*ef5ccd6cSJohn Marino /* A kludge to avoid redefinition of snprintf on Windows by pyerrors.h.  */
45*ef5ccd6cSJohn Marino #if defined(_WIN32) && defined(HAVE_DECL_SNPRINTF)
46*ef5ccd6cSJohn Marino #define HAVE_SNPRINTF 1
47*ef5ccd6cSJohn Marino #endif
48*ef5ccd6cSJohn Marino 
49a45ae5f8SJohn Marino /* Request clean size types from Python.  */
50a45ae5f8SJohn Marino #define PY_SSIZE_T_CLEAN
51a45ae5f8SJohn Marino 
52c50c785cSJohn Marino /* Include the Python header files using angle brackets rather than
53c50c785cSJohn Marino    double quotes.  On case-insensitive filesystems, this prevents us
54c50c785cSJohn Marino    from including our python/python.h header file.  */
55c50c785cSJohn Marino #include <Python.h>
56c50c785cSJohn Marino #include <frameobject.h>
57*ef5ccd6cSJohn Marino 
58*ef5ccd6cSJohn Marino #if PY_MAJOR_VERSION >= 3
59*ef5ccd6cSJohn Marino #define IS_PY3K 1
60*ef5ccd6cSJohn Marino #endif
61*ef5ccd6cSJohn Marino 
62*ef5ccd6cSJohn Marino #ifdef IS_PY3K
63*ef5ccd6cSJohn Marino #define Py_TPFLAGS_HAVE_ITER 0
64*ef5ccd6cSJohn Marino #define Py_TPFLAGS_CHECKTYPES 0
65*ef5ccd6cSJohn Marino 
66*ef5ccd6cSJohn Marino #define PyInt_Check PyLong_Check
67*ef5ccd6cSJohn Marino #define PyInt_FromLong PyLong_FromLong
68*ef5ccd6cSJohn Marino #define PyInt_AsLong PyLong_AsLong
69*ef5ccd6cSJohn Marino 
70*ef5ccd6cSJohn Marino #define PyString_FromString PyUnicode_FromString
71*ef5ccd6cSJohn Marino #define PyString_Decode PyUnicode_Decode
72*ef5ccd6cSJohn Marino #define PyString_FromFormat PyUnicode_FromFormat
73*ef5ccd6cSJohn Marino #define PyString_Check PyUnicode_Check
74*ef5ccd6cSJohn Marino #endif
75*ef5ccd6cSJohn Marino 
76c50c785cSJohn Marino #if HAVE_LIBPYTHON2_4
77c50c785cSJohn Marino /* Py_ssize_t is not defined until 2.5.
78c50c785cSJohn Marino    Logical type for Py_ssize_t is Py_intptr_t, but that fails in 64-bit
79c50c785cSJohn Marino    compilation due to several apparent mistakes in python2.4 API, so we
80c50c785cSJohn Marino    use 'int' instead.  */
81c50c785cSJohn Marino typedef int Py_ssize_t;
82c50c785cSJohn Marino #endif
83c50c785cSJohn Marino 
84*ef5ccd6cSJohn Marino #ifndef PyVarObject_HEAD_INIT
85*ef5ccd6cSJohn Marino /* Python 2.4 does not define PyVarObject_HEAD_INIT.  */
86*ef5ccd6cSJohn Marino #define PyVarObject_HEAD_INIT(type, size)       \
87*ef5ccd6cSJohn Marino     PyObject_HEAD_INIT(type) size,
88*ef5ccd6cSJohn Marino 
89*ef5ccd6cSJohn Marino #endif
90*ef5ccd6cSJohn Marino 
91*ef5ccd6cSJohn Marino #ifndef Py_TYPE
92*ef5ccd6cSJohn Marino /* Python 2.4 does not define Py_TYPE.  */
93*ef5ccd6cSJohn Marino #define Py_TYPE(ob)             (((PyObject*)(ob))->ob_type)
94*ef5ccd6cSJohn Marino #endif
95*ef5ccd6cSJohn Marino 
96c50c785cSJohn Marino /* If Python.h does not define WITH_THREAD, then the various
97c50c785cSJohn Marino    GIL-related functions will not be defined.  However,
98c50c785cSJohn Marino    PyGILState_STATE will be.  */
99c50c785cSJohn Marino #ifndef WITH_THREAD
100c50c785cSJohn Marino #define PyGILState_Ensure() ((PyGILState_STATE) 0)
101c50c785cSJohn Marino #define PyGILState_Release(ARG) ((void)(ARG))
102c50c785cSJohn Marino #define PyEval_InitThreads()
103c50c785cSJohn Marino #define PyThreadState_Swap(ARG) ((void)(ARG))
104c50c785cSJohn Marino #define PyEval_ReleaseLock()
105c50c785cSJohn Marino #endif
106c50c785cSJohn Marino 
107c50c785cSJohn Marino /* Python supplies HAVE_LONG_LONG and some `long long' support when it
108c50c785cSJohn Marino    is available.  These defines let us handle the differences more
109c50c785cSJohn Marino    cleanly.  */
110c50c785cSJohn Marino #ifdef HAVE_LONG_LONG
111c50c785cSJohn Marino 
112c50c785cSJohn Marino #define GDB_PY_LL_ARG "L"
113c50c785cSJohn Marino #define GDB_PY_LLU_ARG "K"
114c50c785cSJohn Marino typedef PY_LONG_LONG gdb_py_longest;
115c50c785cSJohn Marino typedef unsigned PY_LONG_LONG gdb_py_ulongest;
116c50c785cSJohn Marino #define gdb_py_long_from_longest PyLong_FromLongLong
117c50c785cSJohn Marino #define gdb_py_long_from_ulongest PyLong_FromUnsignedLongLong
118c50c785cSJohn Marino #define gdb_py_long_as_ulongest PyLong_AsUnsignedLongLong
119c50c785cSJohn Marino 
120c50c785cSJohn Marino #else /* HAVE_LONG_LONG */
121c50c785cSJohn Marino 
122c50c785cSJohn Marino #define GDB_PY_LL_ARG "L"
123c50c785cSJohn Marino #define GDB_PY_LLU_ARG "K"
124c50c785cSJohn Marino typedef long gdb_py_longest;
125c50c785cSJohn Marino typedef unsigned long gdb_py_ulongest;
126c50c785cSJohn Marino #define gdb_py_long_from_longest PyLong_FromLong
127c50c785cSJohn Marino #define gdb_py_long_from_ulongest PyLong_FromUnsignedLong
128c50c785cSJohn Marino #define gdb_py_long_as_ulongest PyLong_AsUnsignedLong
129c50c785cSJohn Marino 
130c50c785cSJohn Marino #endif /* HAVE_LONG_LONG */
131c50c785cSJohn Marino 
132c50c785cSJohn Marino 
133c50c785cSJohn Marino /* In order to be able to parse symtab_and_line_to_sal_object function
134c50c785cSJohn Marino    a real symtab_and_line structure is needed.  */
135c50c785cSJohn Marino #include "symtab.h"
136c50c785cSJohn Marino 
137c50c785cSJohn Marino /* Also needed to parse enum var_types. */
138c50c785cSJohn Marino #include "command.h"
139c50c785cSJohn Marino #include "breakpoint.h"
140c50c785cSJohn Marino 
141c50c785cSJohn Marino #include "exceptions.h"
142c50c785cSJohn Marino 
143a45ae5f8SJohn Marino enum gdbpy_iter_kind { iter_keys, iter_values, iter_items };
144a45ae5f8SJohn Marino 
145c50c785cSJohn Marino struct block;
146c50c785cSJohn Marino struct value;
147c50c785cSJohn Marino struct language_defn;
148c50c785cSJohn Marino struct program_space;
149c50c785cSJohn Marino struct bpstats;
150a45ae5f8SJohn Marino struct inferior;
151c50c785cSJohn Marino 
152c50c785cSJohn Marino extern PyObject *gdb_module;
153*ef5ccd6cSJohn Marino extern PyObject *gdb_python_module;
154c50c785cSJohn Marino extern PyTypeObject value_object_type;
155c50c785cSJohn Marino extern PyTypeObject block_object_type;
156c50c785cSJohn Marino extern PyTypeObject symbol_object_type;
157c50c785cSJohn Marino extern PyTypeObject event_object_type;
158c50c785cSJohn Marino extern PyTypeObject events_object_type;
159c50c785cSJohn Marino extern PyTypeObject stop_event_object_type;
160a45ae5f8SJohn Marino extern PyTypeObject breakpoint_object_type;
161*ef5ccd6cSJohn Marino extern PyTypeObject frame_object_type;
162c50c785cSJohn Marino 
163a45ae5f8SJohn Marino typedef struct breakpoint_object
164a45ae5f8SJohn Marino {
165a45ae5f8SJohn Marino   PyObject_HEAD
166a45ae5f8SJohn Marino 
167a45ae5f8SJohn Marino   /* The breakpoint number according to gdb.  */
168a45ae5f8SJohn Marino   int number;
169a45ae5f8SJohn Marino 
170a45ae5f8SJohn Marino   /* The gdb breakpoint object, or NULL if the breakpoint has been
171a45ae5f8SJohn Marino      deleted.  */
172a45ae5f8SJohn Marino   struct breakpoint *bp;
173a45ae5f8SJohn Marino 
174a45ae5f8SJohn Marino   /* 1 is this is a FinishBreakpoint object, 0 otherwise.  */
175a45ae5f8SJohn Marino   int is_finish_bp;
176a45ae5f8SJohn Marino } breakpoint_object;
177a45ae5f8SJohn Marino 
178a45ae5f8SJohn Marino /* Require that BREAKPOINT be a valid breakpoint ID; throw a Python
179a45ae5f8SJohn Marino    exception if it is invalid.  */
180a45ae5f8SJohn Marino #define BPPY_REQUIRE_VALID(Breakpoint)                                  \
181a45ae5f8SJohn Marino     do {                                                                \
182a45ae5f8SJohn Marino       if ((Breakpoint)->bp == NULL)                                     \
183a45ae5f8SJohn Marino         return PyErr_Format (PyExc_RuntimeError,                        \
184a45ae5f8SJohn Marino                              _("Breakpoint %d is invalid."),            \
185a45ae5f8SJohn Marino                              (Breakpoint)->number);                     \
186a45ae5f8SJohn Marino     } while (0)
187a45ae5f8SJohn Marino 
188a45ae5f8SJohn Marino /* Require that BREAKPOINT be a valid breakpoint ID; throw a Python
189a45ae5f8SJohn Marino    exception if it is invalid.  This macro is for use in setter functions.  */
190a45ae5f8SJohn Marino #define BPPY_SET_REQUIRE_VALID(Breakpoint)                              \
191a45ae5f8SJohn Marino     do {                                                                \
192a45ae5f8SJohn Marino       if ((Breakpoint)->bp == NULL)                                     \
193a45ae5f8SJohn Marino         {                                                               \
194a45ae5f8SJohn Marino           PyErr_Format (PyExc_RuntimeError, _("Breakpoint %d is invalid."), \
195a45ae5f8SJohn Marino                         (Breakpoint)->number);                          \
196a45ae5f8SJohn Marino           return -1;                                                    \
197a45ae5f8SJohn Marino         }                                                               \
198a45ae5f8SJohn Marino     } while (0)
199a45ae5f8SJohn Marino 
200a45ae5f8SJohn Marino 
201a45ae5f8SJohn Marino /* Variables used to pass information between the Breakpoint
202a45ae5f8SJohn Marino    constructor and the breakpoint-created hook function.  */
203a45ae5f8SJohn Marino extern breakpoint_object *bppy_pending_object;
204a45ae5f8SJohn Marino 
205c50c785cSJohn Marino 
206c50c785cSJohn Marino typedef struct
207c50c785cSJohn Marino {
208c50c785cSJohn Marino   PyObject_HEAD
209c50c785cSJohn Marino 
210c50c785cSJohn Marino   /* The thread we represent.  */
211c50c785cSJohn Marino   struct thread_info *thread;
212c50c785cSJohn Marino 
213c50c785cSJohn Marino   /* The Inferior object to which this thread belongs.  */
214c50c785cSJohn Marino   PyObject *inf_obj;
215c50c785cSJohn Marino } thread_object;
216c50c785cSJohn Marino 
217c50c785cSJohn Marino extern struct cmd_list_element *set_python_list;
218c50c785cSJohn Marino extern struct cmd_list_element *show_python_list;
219c50c785cSJohn Marino 
220c50c785cSJohn Marino PyObject *gdbpy_history (PyObject *self, PyObject *args);
221c50c785cSJohn Marino PyObject *gdbpy_breakpoints (PyObject *, PyObject *);
222c50c785cSJohn Marino PyObject *gdbpy_frame_stop_reason_string (PyObject *, PyObject *);
223c50c785cSJohn Marino PyObject *gdbpy_lookup_symbol (PyObject *self, PyObject *args, PyObject *kw);
224c50c785cSJohn Marino PyObject *gdbpy_lookup_global_symbol (PyObject *self, PyObject *args,
225c50c785cSJohn Marino 				      PyObject *kw);
226c50c785cSJohn Marino PyObject *gdbpy_newest_frame (PyObject *self, PyObject *args);
227c50c785cSJohn Marino PyObject *gdbpy_selected_frame (PyObject *self, PyObject *args);
228c50c785cSJohn Marino PyObject *gdbpy_block_for_pc (PyObject *self, PyObject *args);
229c50c785cSJohn Marino PyObject *gdbpy_lookup_type (PyObject *self, PyObject *args, PyObject *kw);
230c50c785cSJohn Marino PyObject *gdbpy_create_lazy_string_object (CORE_ADDR address, long length,
231c50c785cSJohn Marino 					   const char *encoding,
232c50c785cSJohn Marino 					   struct type *type);
233c50c785cSJohn Marino PyObject *gdbpy_inferiors (PyObject *unused, PyObject *unused2);
234c50c785cSJohn Marino PyObject *gdbpy_selected_thread (PyObject *self, PyObject *args);
235a45ae5f8SJohn Marino PyObject *gdbpy_selected_inferior (PyObject *self, PyObject *args);
236c50c785cSJohn Marino PyObject *gdbpy_string_to_argv (PyObject *self, PyObject *args);
237c50c785cSJohn Marino PyObject *gdbpy_parameter (PyObject *self, PyObject *args);
238c50c785cSJohn Marino PyObject *gdbpy_parameter_value (enum var_types type, void *var);
239a45ae5f8SJohn Marino char *gdbpy_parse_command_name (const char *name,
240c50c785cSJohn Marino 				struct cmd_list_element ***base_list,
241c50c785cSJohn Marino 				struct cmd_list_element **start_list);
242c50c785cSJohn Marino 
243c50c785cSJohn Marino PyObject *symtab_and_line_to_sal_object (struct symtab_and_line sal);
244c50c785cSJohn Marino PyObject *symtab_to_symtab_object (struct symtab *symtab);
245c50c785cSJohn Marino PyObject *symbol_to_symbol_object (struct symbol *sym);
246a45ae5f8SJohn Marino PyObject *block_to_block_object (const struct block *block,
247a45ae5f8SJohn Marino 				 struct objfile *objfile);
248c50c785cSJohn Marino PyObject *value_to_value_object (struct value *v);
249c50c785cSJohn Marino PyObject *type_to_type_object (struct type *);
250c50c785cSJohn Marino PyObject *frame_info_to_frame_object (struct frame_info *frame);
251c50c785cSJohn Marino 
252c50c785cSJohn Marino PyObject *pspace_to_pspace_object (struct program_space *);
253c50c785cSJohn Marino PyObject *pspy_get_printers (PyObject *, void *);
254c50c785cSJohn Marino 
255c50c785cSJohn Marino PyObject *objfile_to_objfile_object (struct objfile *);
256c50c785cSJohn Marino PyObject *objfpy_get_printers (PyObject *, void *);
257c50c785cSJohn Marino 
258*ef5ccd6cSJohn Marino PyObject *gdbarch_to_arch_object (struct gdbarch *gdbarch);
259*ef5ccd6cSJohn Marino 
260c50c785cSJohn Marino thread_object *create_thread_object (struct thread_info *tp);
261c50c785cSJohn Marino thread_object *find_thread_object (ptid_t ptid);
262c50c785cSJohn Marino PyObject *find_inferior_object (int pid);
263c50c785cSJohn Marino PyObject *inferior_to_inferior_object (struct inferior *inferior);
264c50c785cSJohn Marino 
265a45ae5f8SJohn Marino const struct block *block_object_to_block (PyObject *obj);
266c50c785cSJohn Marino struct symbol *symbol_object_to_symbol (PyObject *obj);
267c50c785cSJohn Marino struct value *value_object_to_value (PyObject *self);
268c50c785cSJohn Marino struct value *convert_value_from_python (PyObject *obj);
269c50c785cSJohn Marino struct type *type_object_to_type (PyObject *obj);
270c50c785cSJohn Marino struct symtab *symtab_object_to_symtab (PyObject *obj);
271c50c785cSJohn Marino struct symtab_and_line *sal_object_to_symtab_and_line (PyObject *obj);
272a45ae5f8SJohn Marino struct frame_info *frame_object_to_frame_info (PyObject *frame_obj);
273*ef5ccd6cSJohn Marino struct gdbarch *arch_object_to_gdbarch (PyObject *obj);
274c50c785cSJohn Marino 
275*ef5ccd6cSJohn Marino void gdbpy_initialize_gdb_readline (void);
276c50c785cSJohn Marino void gdbpy_initialize_auto_load (void);
277c50c785cSJohn Marino void gdbpy_initialize_values (void);
278c50c785cSJohn Marino void gdbpy_initialize_frames (void);
279c50c785cSJohn Marino void gdbpy_initialize_symtabs (void);
280c50c785cSJohn Marino void gdbpy_initialize_commands (void);
281c50c785cSJohn Marino void gdbpy_initialize_symbols (void);
282c50c785cSJohn Marino void gdbpy_initialize_symtabs (void);
283c50c785cSJohn Marino void gdbpy_initialize_blocks (void);
284c50c785cSJohn Marino void gdbpy_initialize_types (void);
285c50c785cSJohn Marino void gdbpy_initialize_functions (void);
286c50c785cSJohn Marino void gdbpy_initialize_pspace (void);
287c50c785cSJohn Marino void gdbpy_initialize_objfile (void);
288c50c785cSJohn Marino void gdbpy_initialize_breakpoints (void);
289a45ae5f8SJohn Marino void gdbpy_initialize_finishbreakpoints (void);
290c50c785cSJohn Marino void gdbpy_initialize_lazy_string (void);
291c50c785cSJohn Marino void gdbpy_initialize_parameters (void);
292c50c785cSJohn Marino void gdbpy_initialize_thread (void);
293c50c785cSJohn Marino void gdbpy_initialize_inferior (void);
294c50c785cSJohn Marino void gdbpy_initialize_eventregistry (void);
295c50c785cSJohn Marino void gdbpy_initialize_event (void);
296c50c785cSJohn Marino void gdbpy_initialize_py_events (void);
297c50c785cSJohn Marino void gdbpy_initialize_stop_event (void);
298c50c785cSJohn Marino void gdbpy_initialize_signal_event (void);
299c50c785cSJohn Marino void gdbpy_initialize_breakpoint_event (void);
300c50c785cSJohn Marino void gdbpy_initialize_continue_event (void);
301c50c785cSJohn Marino void gdbpy_initialize_exited_event (void);
302c50c785cSJohn Marino void gdbpy_initialize_thread_event (void);
303a45ae5f8SJohn Marino void gdbpy_initialize_new_objfile_event (void);
304*ef5ccd6cSJohn Marino void gdbpy_initialize_arch (void);
305c50c785cSJohn Marino 
306c50c785cSJohn Marino struct cleanup *make_cleanup_py_decref (PyObject *py);
307c50c785cSJohn Marino 
308c50c785cSJohn Marino struct cleanup *ensure_python_env (struct gdbarch *gdbarch,
309c50c785cSJohn Marino 				   const struct language_defn *language);
310c50c785cSJohn Marino 
311c50c785cSJohn Marino extern struct gdbarch *python_gdbarch;
312c50c785cSJohn Marino extern const struct language_defn *python_language;
313c50c785cSJohn Marino 
314c50c785cSJohn Marino /* Use this after a TRY_EXCEPT to throw the appropriate Python
315c50c785cSJohn Marino    exception.  */
316c50c785cSJohn Marino #define GDB_PY_HANDLE_EXCEPTION(Exception)				\
317c50c785cSJohn Marino     do {								\
318c50c785cSJohn Marino       if (Exception.reason < 0)						\
319c50c785cSJohn Marino 	return gdbpy_convert_exception (Exception);			\
320c50c785cSJohn Marino     } while (0)
321c50c785cSJohn Marino 
322c50c785cSJohn Marino /* Use this after a TRY_EXCEPT to throw the appropriate Python
323c50c785cSJohn Marino    exception.  This macro is for use inside setter functions.  */
324c50c785cSJohn Marino #define GDB_PY_SET_HANDLE_EXCEPTION(Exception)				\
325c50c785cSJohn Marino     do {								\
326c50c785cSJohn Marino       if (Exception.reason < 0)						\
327c50c785cSJohn Marino         {								\
328c50c785cSJohn Marino 	  gdbpy_convert_exception (Exception);				\
329c50c785cSJohn Marino 	  return -1;							\
330c50c785cSJohn Marino 	}								\
331c50c785cSJohn Marino     } while (0)
332c50c785cSJohn Marino 
333c50c785cSJohn Marino void gdbpy_print_stack (void);
334c50c785cSJohn Marino 
335*ef5ccd6cSJohn Marino void source_python_script_for_objfile (struct objfile *objfile, FILE *file,
336*ef5ccd6cSJohn Marino 				       const char *filename);
337c50c785cSJohn Marino 
338c50c785cSJohn Marino PyObject *python_string_to_unicode (PyObject *obj);
339c50c785cSJohn Marino char *unicode_to_target_string (PyObject *unicode_str);
340c50c785cSJohn Marino char *python_string_to_target_string (PyObject *obj);
341c50c785cSJohn Marino PyObject *python_string_to_target_python_string (PyObject *obj);
342c50c785cSJohn Marino char *python_string_to_host_string (PyObject *obj);
343c50c785cSJohn Marino int gdbpy_is_string (PyObject *obj);
344c50c785cSJohn Marino char *gdbpy_obj_to_string (PyObject *obj);
345c50c785cSJohn Marino char *gdbpy_exception_to_string (PyObject *ptype, PyObject *pvalue);
346c50c785cSJohn Marino 
347c50c785cSJohn Marino int gdbpy_is_lazy_string (PyObject *result);
348c50c785cSJohn Marino void gdbpy_extract_lazy_string (PyObject *string, CORE_ADDR *addr,
349c50c785cSJohn Marino 				struct type **str_type,
350c50c785cSJohn Marino 				long *length, char **encoding);
351c50c785cSJohn Marino 
352c50c785cSJohn Marino int gdbpy_is_value_object (PyObject *obj);
353c50c785cSJohn Marino 
354c50c785cSJohn Marino /* Note that these are declared here, and not in python.h with the
355c50c785cSJohn Marino    other pretty-printer functions, because they refer to PyObject.  */
356c50c785cSJohn Marino PyObject *apply_varobj_pretty_printer (PyObject *print_obj,
357c50c785cSJohn Marino 				       struct value **replacement,
358c50c785cSJohn Marino 				       struct ui_file *stream);
359c50c785cSJohn Marino PyObject *gdbpy_get_varobj_pretty_printer (struct value *value);
360c50c785cSJohn Marino char *gdbpy_get_display_hint (PyObject *printer);
361c50c785cSJohn Marino PyObject *gdbpy_default_visualizer (PyObject *self, PyObject *args);
362c50c785cSJohn Marino 
363a45ae5f8SJohn Marino void bpfinishpy_pre_stop_hook (struct breakpoint_object *bp_obj);
364a45ae5f8SJohn Marino void bpfinishpy_post_stop_hook (struct breakpoint_object *bp_obj);
365a45ae5f8SJohn Marino 
366c50c785cSJohn Marino extern PyObject *gdbpy_doc_cst;
367c50c785cSJohn Marino extern PyObject *gdbpy_children_cst;
368c50c785cSJohn Marino extern PyObject *gdbpy_to_string_cst;
369c50c785cSJohn Marino extern PyObject *gdbpy_display_hint_cst;
370c50c785cSJohn Marino extern PyObject *gdbpy_enabled_cst;
371c50c785cSJohn Marino extern PyObject *gdbpy_value_cst;
372c50c785cSJohn Marino 
373c50c785cSJohn Marino /* Exception types.  */
374c50c785cSJohn Marino extern PyObject *gdbpy_gdb_error;
375c50c785cSJohn Marino extern PyObject *gdbpy_gdb_memory_error;
376c50c785cSJohn Marino extern PyObject *gdbpy_gdberror_exc;
377c50c785cSJohn Marino 
378c50c785cSJohn Marino extern PyObject *gdbpy_convert_exception (struct gdb_exception);
379c50c785cSJohn Marino 
380c50c785cSJohn Marino int get_addr_from_python (PyObject *obj, CORE_ADDR *addr);
381c50c785cSJohn Marino 
382c50c785cSJohn Marino PyObject *gdb_py_object_from_longest (LONGEST l);
383c50c785cSJohn Marino PyObject *gdb_py_object_from_ulongest (ULONGEST l);
384c50c785cSJohn Marino int gdb_py_int_as_long (PyObject *, long *);
385c50c785cSJohn Marino 
386*ef5ccd6cSJohn Marino PyObject *gdb_py_generic_dict (PyObject *self, void *closure);
387*ef5ccd6cSJohn Marino 
388c50c785cSJohn Marino #endif /* GDB_PYTHON_INTERNAL_H */
389