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