4 #include "tracepoint.h"
7 struct trace_file_writer;
9 /* Operations to write trace frames to a specific trace format. */
11 struct trace_frame_write_ops
13 /* Write a new trace frame. The tracepoint number of this trace
15 void (*start) (struct trace_file_writer *self, uint16_t tpnum);
17 /* Write an 'R' block. Buffer BUF contains its contents and SIZE is
19 void (*write_r_block) (struct trace_file_writer *self,
20 gdb_byte *buf, int32_t size);
22 /* Write an 'M' block, the header and memory contents respectively.
23 The header of 'M' block is composed of the start address and the
24 length of memory collection, and the memory contents contain
25 the collected memory contents in tracing.
26 For extremely large M block, GDB is unable to get its contents
27 and write them into trace file in one go, due to the limitation
28 of the remote target or the size of internal buffer, we split
29 the operation to 'M' block to two operations. */
30 /* Write the head of 'M' block. ADDR is the start address of
31 collected memory and LENGTH is the length of memory contents. */
32 void (*write_m_block_header) (struct trace_file_writer *self,
33 uint64_t addr, uint16_t length);
34 /* Write the memory contents of 'M' block. Buffer BUF contains
35 its contents and LENGTH is its length. This method can be called
36 multiple times to write large memory contents of a single 'M'
38 void (*write_m_block_memory) (struct trace_file_writer *self,
39 gdb_byte *buf, uint16_t length);
41 /* Write a 'V' block. NUM is the trace variable number and VAL is
42 the value of the trace variable. */
43 void (*write_v_block) (struct trace_file_writer *self, int32_t num,
46 /* The end of the trace frame. */
47 void (*end) (struct trace_file_writer *self);
50 /* Operations to write trace buffers to a specific trace format. */
52 struct trace_file_write_ops
54 /* Destructor. Releases everything from SELF (but not SELF
56 void (*dtor) (struct trace_file_writer *self);
58 /* Save the data to file or directory NAME of desired format in
59 target side. Return true for success, otherwise return
61 int (*target_save) (struct trace_file_writer *self,
64 /* Write the trace buffers to file or directory NAME. */
65 void (*start) (struct trace_file_writer *self,
68 /* Write the trace header. */
69 void (*write_header) (struct trace_file_writer *self);
71 /* Write the type of block about registers. SIZE is the size of
72 all registers on the target. */
73 void (*write_regblock_type) (struct trace_file_writer *self,
76 /* Write trace status TS. */
77 void (*write_status) (struct trace_file_writer *self,
78 struct trace_status *ts);
80 /* Write the uploaded TSV. */
81 void (*write_uploaded_tsv) (struct trace_file_writer *self,
82 struct uploaded_tsv *tsv);
84 /* Write the uploaded tracepoint TP. */
85 void (*write_uploaded_tp) (struct trace_file_writer *self,
86 struct uploaded_tp *tp);
88 /* Write target description. */
89 void (*write_tdesc) (struct trace_file_writer *self);
91 /* Write to mark the end of the definition part. */
92 void (*write_definition_end) (struct trace_file_writer *self);
94 /* Write the data of trace buffer without parsing. The content is
95 in BUF and length is LEN. */
96 void (*write_trace_buffer) (struct trace_file_writer *self,
97 gdb_byte *buf, LONGEST len);
99 /* Operations to write trace frames. The user of this field is
100 responsible to parse the data of trace buffer. Either field
101 'write_trace_buffer' or field ' frame_ops' is NULL. */
102 const struct trace_frame_write_ops *frame_ops;
104 /* The end of writing trace buffers. */
105 void (*end) (struct trace_file_writer *self);
108 /* Trace file writer for a given format. */
110 struct trace_file_writer
112 const struct trace_file_write_ops *ops;
115 extern struct trace_file_writer *tfile_trace_file_writer_new (void);
117 /* Base class for tracefile related targets. */
119 class tracefile_target : public target_ops
124 int get_trace_status (trace_status *ts) override;
125 bool has_all_memory () override;
126 bool has_memory () override;
127 bool has_stack () override;
128 bool has_registers () override;
129 bool thread_alive (ptid_t ptid) override;
132 extern void tracefile_fetch_registers (struct regcache *regcache, int regno);
134 #endif /* TRACEFILE_H */