tracepoint.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. /* Tracepoint code for remote server for GDB.
  2. Copyright (C) 1993-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 GDBSERVER_TRACEPOINT_H
  15. #define GDBSERVER_TRACEPOINT_H
  16. /* Size for a small buffer to report problems from the in-process
  17. agent back to GDBserver. */
  18. #define IPA_BUFSIZ 100
  19. void initialize_tracepoint (void);
  20. #if defined(__GNUC__)
  21. # define ATTR_USED __attribute__((used))
  22. # define ATTR_NOINLINE __attribute__((noinline))
  23. #else
  24. # define ATTR_USED
  25. # define ATTR_NOINLINE
  26. #endif
  27. /* How to make symbol public/exported. */
  28. #if defined _WIN32 || defined __CYGWIN__
  29. # define EXPORTED_SYMBOL __declspec (dllexport)
  30. #else
  31. # if __GNUC__ >= 4
  32. # define EXPORTED_SYMBOL __attribute__ ((visibility ("default")))
  33. # else
  34. # define EXPORTED_SYMBOL
  35. # endif
  36. #endif
  37. /* Use these to make sure the functions and variables the IPA needs to
  38. export (symbols GDBserver needs to query GDB about) are visible and
  39. have C linkage.
  40. Tag exported functions with IP_AGENT_EXPORT_FUNC, tag the
  41. definitions of exported variables with IP_AGENT_EXPORT_VAR, and
  42. variable declarations with IP_AGENT_EXPORT_VAR_DECL. Variables
  43. must also be exported with C linkage. As we can't both use extern
  44. "C" and initialize a variable in the same statement, variables that
  45. don't have a separate declaration must use
  46. EXTERN_C_PUSH/EXTERN_C_POP around their definition. */
  47. #ifdef IN_PROCESS_AGENT
  48. # define IP_AGENT_EXPORT_FUNC EXTERN_C EXPORTED_SYMBOL ATTR_NOINLINE ATTR_USED
  49. # define IP_AGENT_EXPORT_VAR EXPORTED_SYMBOL ATTR_USED
  50. # define IP_AGENT_EXPORT_VAR_DECL EXTERN_C EXPORTED_SYMBOL
  51. #else
  52. # define IP_AGENT_EXPORT_FUNC static
  53. # define IP_AGENT_EXPORT_VAR
  54. # define IP_AGENT_EXPORT_VAR_DECL extern
  55. #endif
  56. IP_AGENT_EXPORT_VAR_DECL int tracing;
  57. extern int disconnected_tracing;
  58. void tracepoint_look_up_symbols (void);
  59. void stop_tracing (void);
  60. int handle_tracepoint_general_set (char *own_buf);
  61. int handle_tracepoint_query (char *own_buf);
  62. int tracepoint_finished_step (struct thread_info *tinfo, CORE_ADDR stop_pc);
  63. int tracepoint_was_hit (struct thread_info *tinfo, CORE_ADDR stop_pc);
  64. void release_while_stepping_state_list (struct thread_info *tinfo);
  65. int in_readonly_region (CORE_ADDR addr, ULONGEST length);
  66. int traceframe_read_mem (int tfnum, CORE_ADDR addr,
  67. unsigned char *buf, ULONGEST length,
  68. ULONGEST *nbytes);
  69. int fetch_traceframe_registers (int tfnum,
  70. struct regcache *regcache,
  71. int regnum);
  72. int traceframe_read_sdata (int tfnum, ULONGEST offset,
  73. unsigned char *buf, ULONGEST length,
  74. ULONGEST *nbytes);
  75. int traceframe_read_info (int tfnum, struct buffer *buffer);
  76. /* If a thread is determined to be collecting a fast tracepoint, this
  77. structure holds the collect status. */
  78. struct fast_tpoint_collect_status
  79. {
  80. /* The tracepoint that is presently being collected. */
  81. int tpoint_num;
  82. CORE_ADDR tpoint_addr;
  83. /* The address range in the jump pad of where the original
  84. instruction the tracepoint jump was inserted was relocated
  85. to. */
  86. CORE_ADDR adjusted_insn_addr;
  87. CORE_ADDR adjusted_insn_addr_end;
  88. };
  89. /* The possible states a thread can be in, related to the collection of fast
  90. tracepoint. */
  91. enum class fast_tpoint_collect_result
  92. {
  93. /* Not collecting a fast tracepoint. */
  94. not_collecting,
  95. /* In the jump pad, but before the relocated instruction. */
  96. before_insn,
  97. /* In the jump pad, but at (or after) the relocated instruction. */
  98. at_insn,
  99. };
  100. fast_tpoint_collect_result fast_tracepoint_collecting
  101. (CORE_ADDR thread_area, CORE_ADDR stop_pc,
  102. struct fast_tpoint_collect_status *status);
  103. void force_unlock_trace_buffer (void);
  104. int handle_tracepoint_bkpts (struct thread_info *tinfo, CORE_ADDR stop_pc);
  105. #ifdef IN_PROCESS_AGENT
  106. void initialize_low_tracepoint (void);
  107. const struct target_desc *get_ipa_tdesc (int idx);
  108. void supply_fast_tracepoint_registers (struct regcache *regcache,
  109. const unsigned char *regs);
  110. void supply_static_tracepoint_registers (struct regcache *regcache,
  111. const unsigned char *regs,
  112. CORE_ADDR pc);
  113. void set_trampoline_buffer_space (CORE_ADDR begin, CORE_ADDR end,
  114. char *errmsg);
  115. void *alloc_jump_pad_buffer (size_t size);
  116. #ifndef HAVE_GETAUXVAL
  117. unsigned long getauxval (unsigned long type);
  118. #endif
  119. #else
  120. void stop_tracing (void);
  121. int claim_trampoline_space (ULONGEST used, CORE_ADDR *trampoline);
  122. int have_fast_tracepoint_trampoline_buffer (char *msgbuf);
  123. void gdb_agent_about_to_close (int pid);
  124. #endif
  125. struct traceframe;
  126. struct eval_agent_expr_context;
  127. /* Do memory copies for bytecodes. */
  128. /* Do the recording of memory blocks for actions and bytecodes. */
  129. int agent_mem_read (struct eval_agent_expr_context *ctx,
  130. unsigned char *to, CORE_ADDR from,
  131. ULONGEST len);
  132. LONGEST agent_get_trace_state_variable_value (int num);
  133. void agent_set_trace_state_variable_value (int num, LONGEST val);
  134. /* Record the value of a trace state variable. */
  135. int agent_tsv_read (struct eval_agent_expr_context *ctx, int n);
  136. int agent_mem_read_string (struct eval_agent_expr_context *ctx,
  137. unsigned char *to,
  138. CORE_ADDR from,
  139. ULONGEST len);
  140. /* The prototype the get_raw_reg function in the IPA. Each arch's
  141. bytecode compiler emits calls to this function. */
  142. ULONGEST get_raw_reg (const unsigned char *raw_regs, int regnum);
  143. /* Returns the address of the get_raw_reg function in the IPA. */
  144. CORE_ADDR get_raw_reg_func_addr (void);
  145. /* Returns the address of the get_trace_state_variable_value
  146. function in the IPA. */
  147. CORE_ADDR get_get_tsv_func_addr (void);
  148. /* Returns the address of the set_trace_state_variable_value
  149. function in the IPA. */
  150. CORE_ADDR get_set_tsv_func_addr (void);
  151. #endif /* GDBSERVER_TRACEPOINT_H */