34 #define ARCHPY_REQUIRE_VALID(arch_obj, arch) \
36 arch = arch_object_to_gdbarch (arch_obj); \
39 PyErr_SetString (PyExc_RuntimeError, \
40 _("Architecture is invalid.")); \
45 extern PyTypeObject arch_object_type
61 return (
void *) arch_obj;
82 PyObject *new_ref = (PyObject *)
gdbarch_data (gdbarch, arch_object_data);
104 py_name = PyString_FromString (name);
118 static char *keywords[] = {
"start_pc",
"end_pc",
"count", NULL };
123 PyObject *result_list, *end_obj = NULL, *count_obj = NULL;
128 if (!PyArg_ParseTupleAndKeywords (args, kw,
GDB_PY_LLU_ARG "|OO", keywords,
129 &start_temp, &end_obj, &count_obj))
142 if (PyLong_Check (end_obj))
143 end = PyLong_AsUnsignedLongLong (end_obj);
144 else if (PyInt_Check (end_obj))
147 end = PyInt_AsLong (end_obj);
151 Py_XDECREF (count_obj);
152 PyErr_SetString (PyExc_TypeError,
153 _(
"Argument 'end_pc' should be a (long) integer."));
161 Py_XDECREF (count_obj);
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)
175 Py_XDECREF (end_obj);
176 PyErr_SetString (PyExc_TypeError,
177 _(
"Argument 'count' should be an non-negative "
184 result_list = PyList_New (0);
185 if (result_list == NULL)
188 for (pc = start, i = 0;
190 (end_obj && count_obj && pc <= end && i < count)
192 || (end_obj && count_obj == NULL && pc <= end)
194 || (end_obj == NULL && count_obj && i < count)
196 || (end_obj == NULL && count_obj == NULL && pc == start);)
201 PyObject *insn_dict = PyDict_New ();
203 if (insn_dict == NULL)
210 if (PyList_Append (result_list, insn_dict))
234 if (PyDict_SetItemString (insn_dict,
"addr",
236 || PyDict_SetItemString (insn_dict,
"asm",
237 PyString_FromString (*as ? as :
"<unknown>"))
238 || PyDict_SetItemString (insn_dict,
"length",
239 PyInt_FromLong (insn_len)))
264 arch_object_type.tp_new = PyType_GenericNew;
265 if (PyType_Ready (&arch_object_type) < 0)
269 (PyObject *) &arch_object_type);
274 "name () -> String.\n\
275 Return the name of the architecture as a string value." },
277 METH_VARARGS | METH_KEYWORDS,
278 "disassemble (start_pc [, end_pc [, count]]) -> List.\n\
279 Return a list of at most COUNT disassembled instructions from START_PC to\n\
284 PyTypeObject arch_object_type = {
305 "GDB architecture object",
int gdb_pymodule_addobject(PyObject *module, const char *name, PyObject *object)
PyObject_HEAD struct gdbarch * gdbarch
char * ui_file_xstrdup(struct ui_file *file, long *length)
unsigned long gdb_py_ulongest
void ui_file_delete(struct ui_file *file)
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)
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)
struct ui_file * mem_fileopen(void)
void gdbpy_convert_exception(struct gdb_exception exception)
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)
#define PyVarObject_HEAD_INIT(type, size)