static PyObject * create_exited_event_object (const LONGEST *exit_code, struct inferior *inf) { gdbpy_ref<> exited_event (create_event_object (&exited_event_object_type)); if (exited_event == NULL) return NULL; if (exit_code) { gdbpy_ref<> exit_code_obj (PyLong_FromLongLong (*exit_code)); if (exit_code_obj == NULL) return NULL; if (evpy_add_attribute (exited_event.get (), "exit_code", exit_code_obj.get ()) < 0) return NULL; } gdbpy_ref<> inf_obj (inferior_to_inferior_object (inf)); if (inf_obj == NULL || evpy_add_attribute (exited_event.get (), "inferior", inf_obj.get ()) < 0) return NULL; return exited_event.release (); }
static PyObject * create_inferior_call_event_object (inferior_call_kind flag, ptid_t ptid, CORE_ADDR addr) { int pid; long tid, lwp; PyObject *event; PyObject *ptid_obj = NULL; PyObject *addr_obj = NULL; int failed; struct cleanup *cleanups; struct cleanup *member_cleanups; switch (flag) { case INFERIOR_CALL_PRE: event = create_event_object (&inferior_call_pre_event_object_type); break; case INFERIOR_CALL_POST: event = create_event_object (&inferior_call_post_event_object_type); break; default: return NULL; } cleanups = make_cleanup_py_decref (event); ptid_obj = gdbpy_create_ptid_object (ptid); if (ptid_obj == NULL) goto fail; member_cleanups = make_cleanup_py_decref (ptid_obj); failed = evpy_add_attribute (event, "ptid", ptid_obj) < 0; if (failed) goto fail; addr_obj = PyLong_FromLongLong (addr); if (addr_obj == NULL) goto fail; make_cleanup_py_decref (addr_obj); failed = evpy_add_attribute (event, "address", addr_obj) < 0; if (failed) goto fail; do_cleanups (member_cleanups); discard_cleanups (cleanups); return event; fail: do_cleanups (cleanups); return NULL; }
PyObject * create_signal_event_object (enum gdb_signal stop_signal) { const char *signal_name; PyObject *signal_name_obj = NULL; PyObject *signal_event_obj = create_stop_event_object (&signal_event_object_type); if (!signal_event_obj) goto fail; signal_name = gdb_signal_to_name (stop_signal); signal_name_obj = PyString_FromString (signal_name); if (signal_name_obj == NULL) goto fail; if (evpy_add_attribute (signal_event_obj, "stop_signal", signal_name_obj) < 0) goto fail; Py_DECREF (signal_name_obj); return signal_event_obj; fail: Py_XDECREF (signal_name_obj); Py_XDECREF (signal_event_obj); return NULL; }
static PyObject* create_inferior_appeared_event_object (struct inferior *inf) { PyObject *inferior_appeared_event; PyObject *inf_obj = NULL; inferior_appeared_event = create_event_object ( &inferior_appeared_event_object_type); if (!inferior_appeared_event) goto fail; inf_obj = inferior_to_inferior_object (inf); if (!inf_obj || evpy_add_attribute (inferior_appeared_event, "inferior", inf_obj) < 0) goto fail; Py_DECREF (inf_obj); return inferior_appeared_event; fail: Py_XDECREF (inf_obj); Py_XDECREF (inferior_appeared_event); return NULL; }
static PyObject* create_solib_about_to_search_event_object (struct inferior *inf) { PyObject *solib_about_to_search_event; PyObject *inf_obj = NULL; solib_about_to_search_event = create_event_object (&solib_about_to_search_event_object_type); if (!solib_about_to_search_event) goto fail; inf_obj = inferior_to_inferior_object (inf); if (!inf_obj || evpy_add_attribute (solib_about_to_search_event, "inferior", inf_obj) < 0) goto fail; Py_DECREF (inf_obj); return solib_about_to_search_event; fail: Py_XDECREF (inf_obj); Py_XDECREF (solib_about_to_search_event); return NULL; }
PyObject * create_thread_event_object (PyTypeObject *py_type) { PyObject *thread = NULL; PyObject *thread_event_obj = NULL; thread_event_obj = create_event_object (py_type); if (!thread_event_obj) goto fail; thread = get_event_thread (); if (!thread) goto fail; if (evpy_add_attribute (thread_event_obj, "inferior_thread", thread) < 0) goto fail; return thread_event_obj; fail: Py_XDECREF (thread_event_obj); return NULL; }
static PyObject * create_register_changed_event_object (struct frame_info *frame, int regnum) { PyObject *event; PyObject *frame_obj = NULL; PyObject *regnum_obj = NULL; int failed; struct cleanup *cleanups; struct cleanup *member_cleanups; event = create_event_object (®ister_changed_event_object_type); if (event == NULL) return NULL; cleanups = make_cleanup_py_decref (event); frame_obj = frame_info_to_frame_object (frame); if (frame_obj == NULL) goto fail; member_cleanups = make_cleanup_py_decref (frame_obj); failed = evpy_add_attribute (event, "frame", frame_obj) < 0; if (failed) goto fail; regnum_obj = PyLong_FromLongLong (regnum); if (regnum_obj == NULL) goto fail; make_cleanup_py_decref (regnum_obj); failed = evpy_add_attribute (event, "regnum", regnum_obj) < 0; if (failed) goto fail; do_cleanups (member_cleanups); discard_cleanups (cleanups); return event; fail: do_cleanups (cleanups); return NULL; }
static PyObject * create_memory_changed_event_object (CORE_ADDR addr, ssize_t len) { PyObject *event; PyObject *addr_obj = NULL; PyObject *len_obj = NULL; int failed; struct cleanup *cleanups; struct cleanup *member_cleanups; event = create_event_object (&memory_changed_event_object_type); if (event == NULL) return NULL; cleanups = make_cleanup_py_decref (event); addr_obj = PyLong_FromLongLong (addr); if (addr_obj == NULL) goto fail; member_cleanups = make_cleanup_py_decref (addr_obj); failed = evpy_add_attribute (event, "address", addr_obj) < 0; if (failed) goto fail; len_obj = PyLong_FromLong (len); if (len_obj == NULL) goto fail; make_cleanup_py_decref (len_obj); failed = evpy_add_attribute (event, "length", len_obj) < 0; if (failed) goto fail; do_cleanups (member_cleanups); discard_cleanups (cleanups); return event; fail: do_cleanups (cleanups); return NULL; }
static PyObject * create_exited_event_object (const LONGEST *exit_code, struct inferior *inf) { PyObject *exited_event; PyObject *inf_obj = NULL; exited_event = create_event_object (&exited_event_object_type); if (!exited_event) goto fail; if (exit_code) { PyObject *exit_code_obj = PyLong_FromLongLong (*exit_code); int failed; if (exit_code_obj == NULL) goto fail; failed = evpy_add_attribute (exited_event, "exit_code", exit_code_obj) < 0; Py_DECREF (exit_code_obj); if (failed) goto fail; } inf_obj = inferior_to_inferior_object (inf); if (!inf_obj || evpy_add_attribute (exited_event, "inferior", inf_obj) < 0) goto fail; Py_DECREF (inf_obj); return exited_event; fail: Py_XDECREF (inf_obj); Py_XDECREF (exited_event); return NULL; }
PyObject * create_breakpoint_event_object (PyObject *breakpoint_list, PyObject *first_bp) { PyObject *breakpoint_event_obj = create_stop_event_object (&breakpoint_event_object_type); if (!breakpoint_event_obj) goto fail; if (evpy_add_attribute (breakpoint_event_obj, "breakpoint", first_bp) < 0) goto fail; if (evpy_add_attribute (breakpoint_event_obj, "breakpoints", breakpoint_list) < 0) goto fail; return breakpoint_event_obj; fail: Py_XDECREF (breakpoint_event_obj); return NULL; }
static gdbpy_ref<> create_clear_objfiles_event_object (void) { gdbpy_ref<> objfile_event = create_event_object (&clear_objfiles_event_object_type); if (objfile_event == NULL) return NULL; gdbpy_ref<> py_progspace = pspace_to_pspace_object (current_program_space); if (py_progspace == NULL || evpy_add_attribute (objfile_event.get (), "progspace", py_progspace.get ()) < 0) return NULL; return objfile_event; }
static gdbpy_ref<> create_new_objfile_event_object (struct objfile *objfile) { gdbpy_ref<> objfile_event = create_event_object (&new_objfile_event_object_type); if (objfile_event == NULL) return NULL; gdbpy_ref<> py_objfile = objfile_to_objfile_object (objfile); if (py_objfile == NULL || evpy_add_attribute (objfile_event.get (), "new_objfile", py_objfile.get ()) < 0) return NULL; return objfile_event; }
gdbpy_ref<> create_thread_event_object (PyTypeObject *py_type, PyObject *thread) { gdb_assert (thread != NULL); gdbpy_ref<> thread_event_obj = create_event_object (py_type); if (thread_event_obj == NULL) return NULL; if (evpy_add_attribute (thread_event_obj.get (), "inferior_thread", thread) < 0) return NULL; return thread_event_obj; }
PyObject * create_thread_event_object (PyTypeObject *py_type) { PyObject *thread = NULL; gdbpy_ref<> thread_event_obj (create_event_object (py_type)); if (thread_event_obj == NULL) return NULL; thread = get_event_thread (); if (!thread) return NULL; if (evpy_add_attribute (thread_event_obj.get (), "inferior_thread", thread) < 0) return NULL; return thread_event_obj.release (); }
static PyObject * create_clear_objfiles_event_object (void) { PyObject *objfile_event; PyObject *py_progspace; objfile_event = create_event_object (&clear_objfiles_event_object_type); if (!objfile_event) goto fail; /* Note that pspace_to_pspace_object returns a borrowed reference, so we don't need a decref here. */ py_progspace = pspace_to_pspace_object (current_program_space); if (!py_progspace || evpy_add_attribute (objfile_event, "progspace", py_progspace) < 0) goto fail; return objfile_event; fail: Py_XDECREF (objfile_event); return NULL; }
static PyObject * create_new_objfile_event_object (struct objfile *objfile) { PyObject *objfile_event; PyObject *py_objfile; objfile_event = create_event_object (&new_objfile_event_object_type); if (!objfile_event) goto fail; /* Note that objfile_to_objfile_object returns a borrowed reference, so we don't need a decref here. */ py_objfile = objfile_to_objfile_object (objfile); if (!py_objfile || evpy_add_attribute (objfile_event, "new_objfile", py_objfile) < 0) goto fail; return objfile_event; fail: Py_XDECREF (objfile_event); return NULL; }