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