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