* p-lang.c (is_pascal_string_type): Remove unneeded parentheses.
[deliverable/binutils-gdb.git] / gdb / python / python-internal.h
CommitLineData
d57a3c85
TJB
1/* Gdb/Python header for private use by Python module.
2
4c38e0a4 3 Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
d57a3c85
TJB
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20#ifndef GDB_PYTHON_INTERNAL_H
21#define GDB_PYTHON_INTERNAL_H
22
23/* Python 2.4 doesn't include stdint.h soon enough to get {u,}intptr_t
24 needed by pyport.h. */
25#include <stdint.h>
26
27/* /usr/include/features.h on linux systems will define _POSIX_C_SOURCE
28 if it sees _GNU_SOURCE (which config.h will define).
29 pyconfig.h defines _POSIX_C_SOURCE to a different value than
30 /usr/include/features.h does causing compilation to fail.
31 To work around this, undef _POSIX_C_SOURCE before we include Python.h. */
32#undef _POSIX_C_SOURCE
33
34#if HAVE_LIBPYTHON2_4
35#include "python2.4/Python.h"
a6bac58e 36#include "python2.4/frameobject.h"
5171e6b3
TT
37/* Py_ssize_t is not defined until 2.5.
38 Logical type for Py_ssize_t is Py_intptr_t, but that fails in 64-bit
39 compilation due to several apparent mistakes in python2.4 API, so we
40 use 'int' instead. */
41typedef int Py_ssize_t;
d57a3c85
TJB
42#elif HAVE_LIBPYTHON2_5
43#include "python2.5/Python.h"
a6bac58e 44#include "python2.5/frameobject.h"
d57a3c85
TJB
45#elif HAVE_LIBPYTHON2_6
46#include "python2.6/Python.h"
a6bac58e 47#include "python2.6/frameobject.h"
d57a3c85
TJB
48#else
49#error "Unable to find usable Python.h"
50#endif
51
ca30a762
TT
52/* If Python.h does not define WITH_THREAD, then the various
53 GIL-related functions will not be defined. However,
54 PyGILState_STATE will be. */
55#ifndef WITH_THREAD
56#define PyGILState_Ensure() ((PyGILState_STATE) 0)
548a926a 57#define PyGILState_Release(ARG) ((void)(ARG))
ca30a762 58#define PyEval_InitThreads() 0
548a926a 59#define PyThreadState_Swap(ARG) ((void)(ARG))
ca30a762 60#define PyEval_InitThreads() 0
f2f35b75 61#define PyEval_ReleaseLock() 0
ca30a762
TT
62#endif
63
f3e9a817
PM
64struct block;
65struct symbol;
66struct symtab_and_line;
a08702d6 67struct value;
d452c4bc 68struct language_defn;
d57a3c85
TJB
69
70extern PyObject *gdb_module;
a08702d6 71extern PyTypeObject value_object_type;
f3e9a817
PM
72extern PyTypeObject block_object_type;
73extern PyTypeObject symbol_object_type;
a08702d6 74
08c637de 75PyObject *gdbpy_history (PyObject *self, PyObject *args);
f8f6f20b 76PyObject *gdbpy_frame_stop_reason_string (PyObject *, PyObject *);
f3e9a817 77PyObject *gdbpy_lookup_symbol (PyObject *self, PyObject *args, PyObject *kw);
f8f6f20b 78PyObject *gdbpy_selected_frame (PyObject *self, PyObject *args);
f3e9a817 79PyObject *gdbpy_block_for_pc (PyObject *self, PyObject *args);
2c74e833 80PyObject *gdbpy_lookup_type (PyObject *self, PyObject *args, PyObject *kw);
be759fcf
PM
81PyObject *gdbpy_create_lazy_string_object (CORE_ADDR address, long length,
82 const char *encoding, struct type *type);
a08702d6 83
f3e9a817
PM
84PyObject *symtab_and_line_to_sal_object (struct symtab_and_line sal);
85PyObject *symtab_to_symtab_object (struct symtab *symtab);
86PyObject *symbol_to_symbol_object (struct symbol *sym);
87PyObject *block_to_block_object (struct block *block, struct objfile *objfile);
a08702d6 88PyObject *value_to_value_object (struct value *v);
2c74e833 89PyObject *type_to_type_object (struct type *);
89c73ade
TT
90PyObject *objfile_to_objfile_object (struct objfile *);
91
92PyObject *objfpy_get_printers (PyObject *, void *);
a08702d6 93
f3e9a817
PM
94struct block *block_object_to_block (PyObject *obj);
95struct symbol *symbol_object_to_symbol (PyObject *obj);
a6bac58e 96struct value *value_object_to_value (PyObject *self);
a08702d6 97struct value *convert_value_from_python (PyObject *obj);
2c74e833 98struct type *type_object_to_type (PyObject *obj);
f3e9a817
PM
99struct symtab *symtab_object_to_symtab (PyObject *obj);
100struct symtab_and_line *sal_object_to_symtab_and_line (PyObject *obj);
a08702d6
TJB
101
102void gdbpy_initialize_values (void);
f8f6f20b 103void gdbpy_initialize_frames (void);
f3e9a817 104void gdbpy_initialize_symtabs (void);
d8906c6f 105void gdbpy_initialize_commands (void);
f3e9a817
PM
106void gdbpy_initialize_symbols (void);
107void gdbpy_initialize_symtabs (void);
108void gdbpy_initialize_blocks (void);
2c74e833 109void gdbpy_initialize_types (void);
bc3b79fd 110void gdbpy_initialize_functions (void);
89c73ade 111void gdbpy_initialize_objfile (void);
be759fcf 112void gdbpy_initialize_lazy_string (void);
d57a3c85
TJB
113
114struct cleanup *make_cleanup_py_decref (PyObject *py);
d452c4bc
UW
115
116struct cleanup *ensure_python_env (struct gdbarch *gdbarch,
117 const struct language_defn *language);
118
119extern struct gdbarch *python_gdbarch;
120extern const struct language_defn *python_language;
d57a3c85
TJB
121
122/* Use this after a TRY_EXCEPT to throw the appropriate Python
123 exception. */
124#define GDB_PY_HANDLE_EXCEPTION(Exception) \
125 do { \
126 if (Exception.reason < 0) \
127 return PyErr_Format (Exception.reason == RETURN_QUIT \
128 ? PyExc_KeyboardInterrupt : PyExc_RuntimeError, \
129 "%s", Exception.message); \
130 } while (0)
131
132
133void gdbpy_print_stack (void);
134
135PyObject *python_string_to_unicode (PyObject *obj);
136char *unicode_to_target_string (PyObject *unicode_str);
137char *python_string_to_target_string (PyObject *obj);
fbb8f299 138PyObject *python_string_to_target_python_string (PyObject *obj);
08c637de 139char *python_string_to_host_string (PyObject *obj);
b6cb8e7d 140PyObject *target_string_to_unicode (const gdb_byte *str, int length);
08c637de 141int gdbpy_is_string (PyObject *obj);
be759fcf
PM
142int gdbpy_is_lazy_string (PyObject *result);
143gdb_byte *gdbpy_extract_lazy_string (PyObject *string,
144 struct type **str_type,
145 long *length, char **encoding);
d57a3c85 146
b6313243
TT
147/* Note that these are declared here, and not in python.h with the
148 other pretty-printer functions, because they refer to PyObject. */
fbb8f299
PM
149PyObject *apply_varobj_pretty_printer (PyObject *print_obj,
150 struct value **replacement);
b6313243
TT
151PyObject *gdbpy_get_varobj_pretty_printer (struct value *value);
152char *gdbpy_get_display_hint (PyObject *printer);
153PyObject *gdbpy_default_visualizer (PyObject *self, PyObject *args);
154
d8906c6f 155extern PyObject *gdbpy_doc_cst;
a6bac58e
TT
156extern PyObject *gdbpy_children_cst;
157extern PyObject *gdbpy_to_string_cst;
158extern PyObject *gdbpy_display_hint_cst;
d8906c6f 159
d57a3c85 160#endif /* GDB_PYTHON_INTERNAL_H */
This page took 0.173452 seconds and 4 git commands to generate.