observable.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. /* Observers
  2. Copyright (C) 2016-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 OBSERVABLE_H
  15. #define OBSERVABLE_H
  16. #include "gdbsupport/observable.h"
  17. struct bpstat;
  18. struct so_list;
  19. struct objfile;
  20. struct thread_info;
  21. struct inferior;
  22. struct process_stratum_target;
  23. struct trace_state_variable;
  24. namespace gdb
  25. {
  26. namespace observers
  27. {
  28. /* The inferior has stopped for real. The BS argument describes the
  29. breakpoints were are stopped at, if any. Second argument
  30. PRINT_FRAME non-zero means display the location where the
  31. inferior has stopped.
  32. gdb notifies all normal_stop observers when the inferior execution
  33. has just stopped, the associated messages and annotations have been
  34. printed, and the control is about to be returned to the user.
  35. Note that the normal_stop notification is not emitted when the
  36. execution stops due to a breakpoint, and this breakpoint has a
  37. condition that is not met. If the breakpoint has any associated
  38. commands list, the commands are executed after the notification is
  39. emitted. */
  40. extern observable<struct bpstat */* bs */, int /* print_frame */> normal_stop;
  41. /* The inferior was stopped by a signal. */
  42. extern observable<enum gdb_signal /* siggnal */> signal_received;
  43. /* We are done with a step/next/si/ni command. */
  44. extern observable<> end_stepping_range;
  45. /* The inferior was terminated by a signal. */
  46. extern observable<enum gdb_signal /* siggnal */> signal_exited;
  47. /* The inferior program is finished. */
  48. extern observable<int /* exitstatus */> exited;
  49. /* Reverse execution: target ran out of history info. */
  50. extern observable<> no_history;
  51. /* A synchronous command finished. */
  52. extern observable<> sync_execution_done;
  53. /* An error was caught while executing a command. */
  54. extern observable<> command_error;
  55. /* The target's register contents have changed. */
  56. extern observable<struct target_ops */* target */> target_changed;
  57. /* The executable being debugged by GDB has changed: The user
  58. decided to debug a different program, or the program he was
  59. debugging has been modified since being loaded by the debugger
  60. (by being recompiled, for instance). */
  61. extern observable<> executable_changed;
  62. /* gdb has just connected to an inferior. For 'run', gdb calls this
  63. observer while the inferior is still stopped at the entry-point
  64. instruction. For 'attach' and 'core', gdb calls this observer
  65. immediately after connecting to the inferior, and before any
  66. information on the inferior has been printed. */
  67. extern observable<inferior */* inferior */> inferior_created;
  68. /* The inferior INF has exec'ed a new executable file. */
  69. extern observable<struct inferior */* inf */> inferior_execd;
  70. /* The status of process record for inferior inferior in gdb has
  71. changed. The process record is started if STARTED is true, and
  72. the process record is stopped if STARTED is false.
  73. When STARTED is true, METHOD indicates the short name of the
  74. method used for recording. If the method supports multiple
  75. formats, FORMAT indicates which one is being used, otherwise it
  76. is NULL. When STARTED is false, they are both NULL. */
  77. extern observable<struct inferior */* inferior */, int /* started */,
  78. const char */* method */, const char */* format */>
  79. record_changed;
  80. /* The shared library specified by SOLIB has been loaded. Note that
  81. when gdb calls this observer, the library's symbols probably
  82. haven't been loaded yet. */
  83. extern observable<struct so_list */* solib */> solib_loaded;
  84. /* The shared library specified by SOLIB has been unloaded. Note
  85. that when gdb calls this observer, the library's symbols have not
  86. been unloaded yet, and thus are still available. */
  87. extern observable<struct so_list */* solib */> solib_unloaded;
  88. /* The symbol file specified by OBJFILE has been loaded. Called
  89. with OBJFILE equal to NULL to indicate previously loaded symbol
  90. table data has now been invalidated. */
  91. extern observable<struct objfile */* objfile */> new_objfile;
  92. /* The object file specified by OBJFILE is about to be freed. */
  93. extern observable<struct objfile */* objfile */> free_objfile;
  94. /* The thread specified by T has been created. */
  95. extern observable<struct thread_info */* t */> new_thread;
  96. /* The thread specified by T has exited. The SILENT argument
  97. indicates that gdb is removing the thread from its tables without
  98. wanting to notify the user about it. */
  99. extern observable<struct thread_info */* t */, int /* silent */> thread_exit;
  100. /* An explicit stop request was issued to PTID. If PTID equals
  101. minus_one_ptid, the request applied to all threads. If
  102. ptid_is_pid(PTID) returns true, the request applied to all
  103. threads of the process pointed at by PTID. Otherwise, the
  104. request applied to the single thread pointed at by PTID. */
  105. extern observable<ptid_t /* ptid */> thread_stop_requested;
  106. /* The target was resumed. The PTID parameter specifies which
  107. thread was resume, and may be RESUME_ALL if all threads are
  108. resumed. */
  109. extern observable<ptid_t /* ptid */> target_resumed;
  110. /* The target is about to be proceeded. */
  111. extern observable<> about_to_proceed;
  112. /* A new breakpoint B has been created. */
  113. extern observable<struct breakpoint */* b */> breakpoint_created;
  114. /* A breakpoint has been destroyed. The argument B is the
  115. pointer to the destroyed breakpoint. */
  116. extern observable<struct breakpoint */* b */> breakpoint_deleted;
  117. /* A breakpoint has been modified in some way. The argument B
  118. is the modified breakpoint. */
  119. extern observable<struct breakpoint */* b */> breakpoint_modified;
  120. /* The trace frame is changed to TFNUM (e.g., by using the 'tfind'
  121. command). If TFNUM is negative, it means gdb resumes live
  122. debugging. The number of the tracepoint associated with this
  123. traceframe is TPNUM. */
  124. extern observable<int /* tfnum */, int /* tpnum */> traceframe_changed;
  125. /* The current architecture has changed. The argument NEWARCH is a
  126. pointer to the new architecture. */
  127. extern observable<struct gdbarch */* newarch */> architecture_changed;
  128. /* The thread's ptid has changed. The OLD_PTID parameter specifies
  129. the old value, and NEW_PTID specifies the new value. */
  130. extern observable<process_stratum_target * /* target */,
  131. ptid_t /* old_ptid */, ptid_t /* new_ptid */>
  132. thread_ptid_changed;
  133. /* The inferior INF has been added to the list of inferiors. At
  134. this point, it might not be associated with any process. */
  135. extern observable<struct inferior */* inf */> inferior_added;
  136. /* The inferior identified by INF has been attached to a
  137. process. */
  138. extern observable<struct inferior */* inf */> inferior_appeared;
  139. /* Either the inferior associated with INF has been detached from
  140. the process, or the process has exited. */
  141. extern observable<struct inferior */* inf */> inferior_exit;
  142. /* The inferior INF has been removed from the list of inferiors.
  143. This method is called immediately before freeing INF. */
  144. extern observable<struct inferior */* inf */> inferior_removed;
  145. /* Bytes from DATA to DATA + LEN have been written to the inferior
  146. at ADDR. */
  147. extern observable<struct inferior */* inferior */, CORE_ADDR /* addr */,
  148. ssize_t /* len */, const bfd_byte */* data */>
  149. memory_changed;
  150. /* Called before a top-level prompt is displayed. CURRENT_PROMPT is
  151. the current top-level prompt. */
  152. extern observable<const char */* current_prompt */> before_prompt;
  153. /* Variable gdb_datadir has been set. The value may not necessarily
  154. change. */
  155. extern observable<> gdb_datadir_changed;
  156. /* The parameter of some 'set' commands in console are changed.
  157. This method is called after a command 'set param value'. PARAM
  158. is the parameter of 'set' command, and VALUE is the value of
  159. changed parameter. */
  160. extern observable<const char */* param */, const char */* value */>
  161. command_param_changed;
  162. /* The new trace state variable TSV is created. */
  163. extern observable<const struct trace_state_variable */* tsv */> tsv_created;
  164. /* The trace state variable TSV is deleted. If TSV is NULL, all
  165. trace state variables are deleted. */
  166. extern observable<const struct trace_state_variable */* tsv */> tsv_deleted;
  167. /* The trace state value TSV is modified. */
  168. extern observable<const struct trace_state_variable */* tsv */> tsv_modified;
  169. /* An inferior function at ADDRESS is about to be called in thread
  170. THREAD. */
  171. extern observable<ptid_t /* thread */, CORE_ADDR /* address */>
  172. inferior_call_pre;
  173. /* The inferior function at ADDRESS has just been called. This
  174. observer is called even if the inferior exits during the call.
  175. THREAD is the thread in which the function was called, which may
  176. be different from the current thread. */
  177. extern observable<ptid_t /* thread */, CORE_ADDR /* address */>
  178. inferior_call_post;
  179. /* A register in the inferior has been modified by the gdb user. */
  180. extern observable<struct frame_info */* frame */, int /* regnum */>
  181. register_changed;
  182. /* The user-selected inferior, thread and/or frame has changed. The
  183. user_select_what flag specifies if the inferior, thread and/or
  184. frame has changed. */
  185. extern observable<user_selected_what /* selection */>
  186. user_selected_context_changed;
  187. /* This is notified when a styling setting has changed, content may need
  188. to be updated based on the new settings. */
  189. extern observable<> styling_changed;
  190. /* The CLI's notion of the current source has changed. This differs
  191. from user_selected_context_changed in that it is also set by the
  192. "list" command. */
  193. extern observable<> current_source_symtab_and_line_changed;
  194. /* Called when GDB is about to exit. */
  195. extern observable<int> gdb_exiting;
  196. /* When a connection is removed. */
  197. extern observable<process_stratum_target */* target */> connection_removed;
  198. /* About to enter target_wait (). */
  199. extern observable <ptid_t /* ptid */> target_pre_wait;
  200. /* About to leave target_wait (). */
  201. extern observable <ptid_t /* event_ptid */> target_post_wait;
  202. } /* namespace observers */
  203. } /* namespace gdb */
  204. #endif /* OBSERVABLE_H */