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.")); \ 62 return (
void *) arch_obj;
105 py_name = PyString_FromString (
name);
119 static const char *keywords[] = {
"start_pc",
"end_pc",
"count", NULL };
124 PyObject *end_obj = NULL, *count_obj = NULL;
130 keywords, &start_temp, &end_obj,
144 if (PyLong_Check (end_obj))
145 end = PyLong_AsUnsignedLongLong (end_obj);
146 #if PY_MAJOR_VERSION == 2 147 else if (PyInt_Check (end_obj))
150 end = PyInt_AsLong (end_obj);
154 PyErr_SetString (PyExc_TypeError,
155 _(
"Argument 'end_pc' should be a (long) integer."));
162 PyErr_SetString (PyExc_ValueError,
163 _(
"Argument 'end_pc' should be greater than or " 164 "equal to the argument 'start_pc'."));
171 count = PyInt_AsLong (count_obj);
172 if (PyErr_Occurred () || count < 0)
174 PyErr_SetString (PyExc_TypeError,
175 _(
"Argument 'count' should be an non-negative " 183 if (result_list == NULL)
186 for (pc = start, i = 0;
188 (end_obj && count_obj && pc <= end && i < count)
190 || (end_obj && count_obj == NULL && pc <= end)
192 || (end_obj == NULL && count_obj && i < count)
194 || (end_obj == NULL && count_obj == NULL && pc == start);)
199 if (insn_dict == NULL)
201 if (PyList_Append (result_list.
get (), insn_dict.
get ()))
217 if (PyDict_SetItemString (insn_dict.
get (),
"addr",
219 || PyDict_SetItemString (insn_dict.
get (),
"asm",
220 PyString_FromString (!stb.
empty ()
223 || PyDict_SetItemString (insn_dict.
get (),
"length",
224 PyInt_FromLong (insn_len)))
250 "name () -> String.\n\ 251 Return the name of the architecture as a string value." },
253 METH_VARARGS | METH_KEYWORDS,
254 "disassemble (start_pc [, end_pc [, count]]) -> List.\n\ 255 Return a list of at most COUNT disassembled instructions from START_PC to\n\ 281 "GDB architecture object",
int gdb_pymodule_addobject(PyObject *module, const char *name, PyObject *object)
PyObject_HEAD struct gdbarch * gdbarch
unsigned long gdb_py_ulongest
static PyObject * archpy_disassemble(PyObject *self, PyObject *args, PyObject *kw)
int gdbpy_initialize_arch(void)
#define gdb_py_long_from_ulongest
static void * arch_object_data_init(struct gdbarch *gdbarch)
struct gdbarch * arch_object_to_gdbarch(PyObject *obj)
static int gdb_PyArg_ParseTupleAndKeywords(PyObject *args, PyObject *kw, const char *format, const char **keywords,...)
PyTypeObject arch_object_type
#define PyVarObject_HEAD_INIT(type, size)
PyTypeObject arch_object_type CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF("arch_object")
PyObject * gdbarch_to_arch_object(struct gdbarch *gdbarch)
#define CATCH(EXCEPTION, MASK)
int gdb_print_insn(struct gdbarch *gdbarch, CORE_ADDR memaddr, struct ui_file *stream, int *branch_delay_insns)
#define ARCHPY_REQUIRE_VALID(arch_obj, arch)
struct arch_object_type_object arch_object
static PyObject * archpy_name(PyObject *self, PyObject *args)
void gdbpy_convert_exception(struct gdb_exception exception)
const char * c_str() const
static struct gdbarch_data * arch_object_data
const struct bfd_arch_info * gdbarch_bfd_arch_info(struct gdbarch *gdbarch)
static PyMethodDef arch_object_methods[]
struct gdbarch_data * gdbarch_data_register_post_init(gdbarch_data_post_init_ftype *post_init)