py-event.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /* Python interface to inferior events.
  2. Copyright (C) 2009-2022 Free Software Foundation, Inc.
  3. This file is part of GDB.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  14. #ifndef PYTHON_PY_EVENT_H
  15. #define PYTHON_PY_EVENT_H
  16. #include "py-events.h"
  17. #include "command.h"
  18. #include "python-internal.h"
  19. #include "inferior.h"
  20. /* Declare all event types. */
  21. #define GDB_PY_DEFINE_EVENT_TYPE(name, py_name, doc, base) \
  22. extern PyTypeObject name##_event_object_type \
  23. CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("event_object");
  24. #include "py-event-types.def"
  25. #undef GDB_PY_DEFINE_EVENT_TYPE
  26. struct event_object
  27. {
  28. PyObject_HEAD
  29. PyObject *dict;
  30. };
  31. extern int emit_continue_event (ptid_t ptid);
  32. extern int emit_exited_event (const LONGEST *exit_code, struct inferior *inf);
  33. /* For inferior function call events, discriminate whether event is
  34. before or after the call. */
  35. typedef enum
  36. {
  37. /* Before the call */
  38. INFERIOR_CALL_PRE,
  39. /* after the call */
  40. INFERIOR_CALL_POST,
  41. } inferior_call_kind;
  42. extern int emit_inferior_call_event (inferior_call_kind kind,
  43. ptid_t thread, CORE_ADDR addr);
  44. extern int emit_register_changed_event (struct frame_info *frame,
  45. int regnum);
  46. extern int emit_memory_changed_event (CORE_ADDR addr, ssize_t len);
  47. extern int evpy_emit_event (PyObject *event,
  48. eventregistry_object *registry);
  49. extern gdbpy_ref<> create_event_object (PyTypeObject *py_type);
  50. /* thread events can either be thread specific or process wide. If gdb is
  51. running in non-stop mode then the event is thread specific, otherwise
  52. it is process wide.
  53. This function returns the currently stopped thread in non-stop mode and
  54. Py_None otherwise. */
  55. extern gdbpy_ref<> py_get_event_thread (ptid_t ptid);
  56. extern gdbpy_ref<> create_thread_event_object (PyTypeObject *py_type,
  57. PyObject *thread);
  58. extern int emit_new_objfile_event (struct objfile *objfile);
  59. extern int emit_clear_objfiles_event (void);
  60. extern void evpy_dealloc (PyObject *self);
  61. extern int evpy_add_attribute (PyObject *event,
  62. const char *name, PyObject *attr)
  63. CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
  64. int gdbpy_initialize_event_generic (PyTypeObject *type, const char *name)
  65. CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
  66. #endif /* PYTHON_PY_EVENT_H */