35#define ARCHPY_REQUIRE_VALID(arch_obj, arch) \
37 arch = arch_object_to_gdbarch (arch_obj); \
40 PyErr_SetString (PyExc_RuntimeError, \
41 _("Architecture is invalid.")); \
93 if (new_ref ==
nullptr)
100 Py_XINCREF (new_ref);
117 return PyUnicode_FromString (
name);
129 static const char *keywords[] = {
"start_pc",
"end_pc",
"count", NULL };
130 CORE_ADDR start = 0, end = 0;
133 PyObject *start_obj =
nullptr, *end_obj =
nullptr, *count_obj =
nullptr;
139 keywords, &start_obj, &end_obj,
146 if (end_obj !=
nullptr)
153 PyErr_SetString (PyExc_ValueError,
154 _(
"Argument 'end_pc' should be greater than or "
155 "equal to the argument 'start_pc'."));
162 count = PyLong_AsLong (count_obj);
163 if (PyErr_Occurred () || count < 0)
165 PyErr_SetString (PyExc_TypeError,
166 _(
"Argument 'count' should be an non-negative "
174 if (result_list == NULL)
177 for (pc = start, i = 0;
179 (end_obj && count_obj && pc <= end && i < count)
181 || (end_obj && count_obj == NULL && pc <= end)
183 || (end_obj == NULL && count_obj && i < count)
185 || (end_obj == NULL && count_obj == NULL && pc == start);)
190 if (insn_dict == NULL)
192 if (PyList_Append (result_list.get (), insn_dict.get ()))
201 catch (
const gdb_exception &except)
208 if (pc_obj ==
nullptr)
212 (PyUnicode_FromString (!stb.
empty () ? stb.
c_str () :
"<unknown>"));
213 if (asm_obj ==
nullptr)
217 if (len_obj ==
nullptr)
220 if (PyDict_SetItemString (insn_dict.get (),
"addr", pc_obj.get ())
221 || PyDict_SetItemString (insn_dict.get (),
"asm", asm_obj.get ())
222 || PyDict_SetItemString (insn_dict.get (),
"length", len_obj.get ()))
229 return result_list.release ();
239 static const char *keywords[] = {
"reggroup", NULL };
241 const char *group_name = NULL;
272 static const char *keywords[] = {
"size",
"signed", NULL };
277 &
size, &is_signed_obj))
281 bool is_signed = (is_signed_obj ==
nullptr
282 || PyObject_IsTrue (is_signed_obj));
314 PyErr_SetString (PyExc_ValueError,
315 _(
"no integer type of that size is available"));
329 return PyUnicode_FromFormat (
"<%s (invalid)>", Py_TYPE (self)->tp_name);
332 return PyUnicode_FromFormat (
"<%s arch_name=%s printable_name=%s>",
333 Py_TYPE (self)->tp_name, arch_info->arch_name,
334 arch_info->printable_name);
348 for (
const char *
name : name_list)
350 gdbpy_ref <> py_name (PyUnicode_FromString (
name));
351 if (py_name ==
nullptr)
353 if (PyList_Append (list.get (), py_name.get ()) < 0)
357 return list.release ();
379 "name () -> String.\n\
380Return the name of the architecture as a string value." },
382 METH_VARARGS | METH_KEYWORDS,
383 "disassemble (start_pc [, end_pc [, count]]) -> List.\n\
384Return a list of at most COUNT disassembled instructions from START_PC to\n\
387 METH_VARARGS | METH_KEYWORDS,
388 "integer_type (size [, signed]) -> type\n\
389Return an integer Type corresponding to the given bitsize and signed-ness.\n\
390If not specified, the type defaults to signed." },
392 METH_VARARGS | METH_KEYWORDS,
393 "registers ([ group-name ]) -> Iterator.\n\
394Return an iterator of register descriptors for the registers in register\n\
398 "register_groups () -> Iterator.\n\
399Return an iterator over all of the register groups in this architecture." },
404 PyVarObject_HEAD_INIT (NULL, 0)
424 "GDB architecture object",
std::vector< const char * > gdbarch_printable_names()
void set(unsigned key, void *datum)
const char * c_str() const
int gdb_print_insn(struct gdbarch *gdbarch, CORE_ADDR memaddr, struct ui_file *stream, int *branch_delay_insns)
const struct bfd_arch_info * gdbarch_bfd_arch_info(struct gdbarch *gdbarch)
const struct builtin_type * builtin_type(struct gdbarch *gdbarch)
PyObject * gdbpy_all_architecture_names(PyObject *self, PyObject *args)
static PyObject * arch_object_data_init(struct gdbarch *gdbarch)
static PyObject * archpy_register_groups(PyObject *self, PyObject *args)
static PyMethodDef arch_object_methods[]
bool gdbpy_is_architecture(PyObject *obj)
struct gdbarch * arch_object_to_gdbarch(PyObject *obj)
static PyObject * archpy_name(PyObject *self, PyObject *args)
static PyObject * archpy_disassemble(PyObject *self, PyObject *args, PyObject *kw)
static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION gdbpy_initialize_arch(void)
static PyObject * archpy_registers(PyObject *self, PyObject *args, PyObject *kw)
static const registry< gdbarch >::key< PyObject, gdb::noop_deleter< PyObject > > arch_object_data
PyObject * gdbarch_to_arch_object(struct gdbarch *gdbarch)
static PyObject * archpy_repr(PyObject *self)
static PyObject * archpy_integer_type(PyObject *self, PyObject *args, PyObject *kw)
#define ARCHPY_REQUIRE_VALID(arch_obj, arch)
PyTypeObject arch_object_type
gdb::ref_ptr< T, gdbpy_ref_policy< T > > gdbpy_ref
PyObject * gdbpy_new_register_descriptor_iterator(struct gdbarch *gdbarch, const char *group_name)
PyObject * gdbpy_new_reggroup_iterator(struct gdbarch *gdbarch)
PyObject * type_to_type_object(struct type *type)
gdbpy_ref gdb_py_object_from_longest(LONGEST l)
int get_addr_from_python(PyObject *obj, CORE_ADDR *addr)
void gdbpy_convert_exception(const struct gdb_exception &exception)
int gdb_pymodule_addobject(PyObject *module, const char *name, PyObject *object)
gdbpy_ref gdb_py_object_from_ulongest(ULONGEST l)
#define CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF(ARG)
#define CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION
#define GDBPY_INITIALIZE_FILE(INIT,...)
static int gdb_PyArg_ParseTupleAndKeywords(PyObject *args, PyObject *kw, const char *format, const char **keywords,...)
PyObject_HEAD struct gdbarch * gdbarch
struct type * builtin_int0
struct type * builtin_uint16
struct type * builtin_int24
struct type * builtin_int8
struct type * builtin_uint128
struct type * builtin_uint32
struct type * builtin_uint64
struct type * builtin_int64
struct type * builtin_uint24
struct type * builtin_int32
struct type * builtin_uint8
struct type * builtin_int128
struct type * builtin_int16