Share some code between ctf and tfile target.
[deliverable/binutils-gdb.git] / gdb / tracefile.h
1 #ifndef TRACEFILE_H
2 #define TRACEFILE_H 1
3
4 #include "defs.h"
5 #include "tracepoint.h"
6
7 struct trace_file_writer;
8
9 /* Operations to write trace frames to a specific trace format. */
10
11 struct trace_frame_write_ops
12 {
13 /* Write a new trace frame. The tracepoint number of this trace
14 frame is TPNUM. */
15 void (*start) (struct trace_file_writer *self, uint16_t tpnum);
16
17 /* Write an 'R' block. Buffer BUF contains its contents and SIZE is
18 its size. */
19 void (*write_r_block) (struct trace_file_writer *self,
20 gdb_byte *buf, int32_t size);
21
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'
37 block. */
38 void (*write_m_block_memory) (struct trace_file_writer *self,
39 gdb_byte *buf, uint16_t length);
40
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,
44 uint64_t val);
45
46 /* The end of the trace frame. */
47 void (*end) (struct trace_file_writer *self);
48 };
49
50 /* Operations to write trace buffers to a specific trace format. */
51
52 struct trace_file_write_ops
53 {
54 /* Destructor. Releases everything from SELF (but not SELF
55 itself). */
56 void (*dtor) (struct trace_file_writer *self);
57
58 /* Save the data to file or directory NAME of desired format in
59 target side. Return true for success, otherwise return
60 false. */
61 int (*target_save) (struct trace_file_writer *self,
62 const char *name);
63
64 /* Write the trace buffers to file or directory NAME. */
65 void (*start) (struct trace_file_writer *self,
66 const char *name);
67
68 /* Write the trace header. */
69 void (*write_header) (struct trace_file_writer *self);
70
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,
74 int size);
75
76 /* Write trace status TS. */
77 void (*write_status) (struct trace_file_writer *self,
78 struct trace_status *ts);
79
80 /* Write the uploaded TSV. */
81 void (*write_uploaded_tsv) (struct trace_file_writer *self,
82 struct uploaded_tsv *tsv);
83
84 /* Write the uploaded tracepoint TP. */
85 void (*write_uploaded_tp) (struct trace_file_writer *self,
86 struct uploaded_tp *tp);
87
88 /* Write to mark the end of the definition part. */
89 void (*write_definition_end) (struct trace_file_writer *self);
90
91 /* Write the data of trace buffer without parsing. The content is
92 in BUF and length is LEN. */
93 void (*write_trace_buffer) (struct trace_file_writer *self,
94 gdb_byte *buf, LONGEST len);
95
96 /* Operations to write trace frames. The user of this field is
97 responsible to parse the data of trace buffer. Either field
98 'write_trace_buffer' or field ' frame_ops' is NULL. */
99 const struct trace_frame_write_ops *frame_ops;
100
101 /* The end of writing trace buffers. */
102 void (*end) (struct trace_file_writer *self);
103 };
104
105 /* Trace file writer for a given format. */
106
107 struct trace_file_writer
108 {
109 const struct trace_file_write_ops *ops;
110 };
111
112 extern struct trace_file_writer *tfile_trace_file_writer_new (void);
113
114 extern void init_tracefile_ops (struct target_ops *ops);
115
116 #endif /* TRACEFILE_H */
This page took 0.041616 seconds and 5 git commands to generate.