tracefile.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. #ifndef TRACEFILE_H
  2. #define TRACEFILE_H 1
  3. #include "tracepoint.h"
  4. #include "target.h"
  5. #include "process-stratum-target.h"
  6. struct trace_file_writer;
  7. /* Operations to write trace frames to a specific trace format. */
  8. struct trace_frame_write_ops
  9. {
  10. /* Write a new trace frame. The tracepoint number of this trace
  11. frame is TPNUM. */
  12. void (*start) (struct trace_file_writer *self, uint16_t tpnum);
  13. /* Write an 'R' block. Buffer BUF contains its contents and SIZE is
  14. its size. */
  15. void (*write_r_block) (struct trace_file_writer *self,
  16. gdb_byte *buf, int32_t size);
  17. /* Write an 'M' block, the header and memory contents respectively.
  18. The header of 'M' block is composed of the start address and the
  19. length of memory collection, and the memory contents contain
  20. the collected memory contents in tracing.
  21. For extremely large M block, GDB is unable to get its contents
  22. and write them into trace file in one go, due to the limitation
  23. of the remote target or the size of internal buffer, we split
  24. the operation to 'M' block to two operations. */
  25. /* Write the head of 'M' block. ADDR is the start address of
  26. collected memory and LENGTH is the length of memory contents. */
  27. void (*write_m_block_header) (struct trace_file_writer *self,
  28. uint64_t addr, uint16_t length);
  29. /* Write the memory contents of 'M' block. Buffer BUF contains
  30. its contents and LENGTH is its length. This method can be called
  31. multiple times to write large memory contents of a single 'M'
  32. block. */
  33. void (*write_m_block_memory) (struct trace_file_writer *self,
  34. gdb_byte *buf, uint16_t length);
  35. /* Write a 'V' block. NUM is the trace variable number and VAL is
  36. the value of the trace variable. */
  37. void (*write_v_block) (struct trace_file_writer *self, int32_t num,
  38. uint64_t val);
  39. /* The end of the trace frame. */
  40. void (*end) (struct trace_file_writer *self);
  41. };
  42. /* Operations to write trace buffers to a specific trace format. */
  43. struct trace_file_write_ops
  44. {
  45. /* Destructor. Releases everything from SELF (but not SELF
  46. itself). */
  47. void (*dtor) (struct trace_file_writer *self);
  48. /* Save the data to file or directory NAME of desired format in
  49. target side. Return true for success, otherwise return
  50. false. */
  51. int (*target_save) (struct trace_file_writer *self,
  52. const char *name);
  53. /* Write the trace buffers to file or directory NAME. */
  54. void (*start) (struct trace_file_writer *self,
  55. const char *name);
  56. /* Write the trace header. */
  57. void (*write_header) (struct trace_file_writer *self);
  58. /* Write the type of block about registers. SIZE is the size of
  59. all registers on the target. */
  60. void (*write_regblock_type) (struct trace_file_writer *self,
  61. int size);
  62. /* Write trace status TS. */
  63. void (*write_status) (struct trace_file_writer *self,
  64. struct trace_status *ts);
  65. /* Write the uploaded TSV. */
  66. void (*write_uploaded_tsv) (struct trace_file_writer *self,
  67. struct uploaded_tsv *tsv);
  68. /* Write the uploaded tracepoint TP. */
  69. void (*write_uploaded_tp) (struct trace_file_writer *self,
  70. struct uploaded_tp *tp);
  71. /* Write target description. */
  72. void (*write_tdesc) (struct trace_file_writer *self);
  73. /* Write to mark the end of the definition part. */
  74. void (*write_definition_end) (struct trace_file_writer *self);
  75. /* Write the data of trace buffer without parsing. The content is
  76. in BUF and length is LEN. */
  77. void (*write_trace_buffer) (struct trace_file_writer *self,
  78. gdb_byte *buf, LONGEST len);
  79. /* Operations to write trace frames. The user of this field is
  80. responsible to parse the data of trace buffer. Either field
  81. 'write_trace_buffer' or field ' frame_ops' is NULL. */
  82. const struct trace_frame_write_ops *frame_ops;
  83. /* The end of writing trace buffers. */
  84. void (*end) (struct trace_file_writer *self);
  85. };
  86. /* Trace file writer for a given format. */
  87. struct trace_file_writer
  88. {
  89. const struct trace_file_write_ops *ops;
  90. };
  91. extern struct trace_file_writer *tfile_trace_file_writer_new (void);
  92. /* Base class for tracefile related targets. */
  93. class tracefile_target : public process_stratum_target
  94. {
  95. public:
  96. tracefile_target () = default;
  97. int get_trace_status (trace_status *ts) override;
  98. bool has_all_memory () override;
  99. bool has_memory () override;
  100. bool has_stack () override;
  101. bool has_registers () override;
  102. bool has_execution (inferior *inf) override { return false; }
  103. bool thread_alive (ptid_t ptid) override;
  104. };
  105. extern void tracefile_fetch_registers (struct regcache *regcache, int regno);
  106. #endif /* TRACEFILE_H */