1 /* Tracefile declarations
2 Copyright (C) 2014-2024 Free Software Foundation, Inc.
4 This file is part of GDB.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 #ifndef GDB_TRACEFILE_H
20 #define GDB_TRACEFILE_H
22 #include "tracepoint.h"
24 #include "process-stratum-target.h"
26 struct trace_file_writer
;
28 /* Operations to write trace frames to a specific trace format. */
30 struct trace_frame_write_ops
32 /* Write a new trace frame. The tracepoint number of this trace
34 void (*start
) (struct trace_file_writer
*self
, uint16_t tpnum
);
36 /* Write an 'R' block. Buffer BUF contains its contents and SIZE is
38 void (*write_r_block
) (struct trace_file_writer
*self
,
39 gdb_byte
*buf
, int32_t size
);
41 /* Write an 'M' block, the header and memory contents respectively.
42 The header of 'M' block is composed of the start address and the
43 length of memory collection, and the memory contents contain
44 the collected memory contents in tracing.
45 For extremely large M block, GDB is unable to get its contents
46 and write them into trace file in one go, due to the limitation
47 of the remote target or the size of internal buffer, we split
48 the operation to 'M' block to two operations. */
49 /* Write the head of 'M' block. ADDR is the start address of
50 collected memory and LENGTH is the length of memory contents. */
51 void (*write_m_block_header
) (struct trace_file_writer
*self
,
52 uint64_t addr
, uint16_t length
);
53 /* Write the memory contents of 'M' block. Buffer BUF contains
54 its contents and LENGTH is its length. This method can be called
55 multiple times to write large memory contents of a single 'M'
57 void (*write_m_block_memory
) (struct trace_file_writer
*self
,
58 gdb_byte
*buf
, uint16_t length
);
60 /* Write a 'V' block. NUM is the trace variable number and VAL is
61 the value of the trace variable. */
62 void (*write_v_block
) (struct trace_file_writer
*self
, int32_t num
,
65 /* The end of the trace frame. */
66 void (*end
) (struct trace_file_writer
*self
);
69 /* Operations to write trace buffers to a specific trace format. */
71 struct trace_file_write_ops
73 /* Destructor. Releases everything from SELF (but not SELF
75 void (*dtor
) (struct trace_file_writer
*self
);
77 /* Save the data to file or directory NAME of desired format in
78 target side. Return true for success, otherwise return
80 int (*target_save
) (struct trace_file_writer
*self
,
83 /* Write the trace buffers to file or directory NAME. */
84 void (*start
) (struct trace_file_writer
*self
,
87 /* Write the trace header. */
88 void (*write_header
) (struct trace_file_writer
*self
);
90 /* Write the type of block about registers. SIZE is the size of
91 all registers on the target. */
92 void (*write_regblock_type
) (struct trace_file_writer
*self
,
95 /* Write trace status TS. */
96 void (*write_status
) (struct trace_file_writer
*self
,
97 struct trace_status
*ts
);
99 /* Write the uploaded TSV. */
100 void (*write_uploaded_tsv
) (struct trace_file_writer
*self
,
101 struct uploaded_tsv
*tsv
);
103 /* Write the uploaded tracepoint TP. */
104 void (*write_uploaded_tp
) (struct trace_file_writer
*self
,
105 struct uploaded_tp
*tp
);
107 /* Write target description. */
108 void (*write_tdesc
) (struct trace_file_writer
*self
);
110 /* Write to mark the end of the definition part. */
111 void (*write_definition_end
) (struct trace_file_writer
*self
);
113 /* Write the data of trace buffer without parsing. The content is
114 in BUF and length is LEN. */
115 void (*write_trace_buffer
) (struct trace_file_writer
*self
,
116 gdb_byte
*buf
, LONGEST len
);
118 /* Operations to write trace frames. The user of this field is
119 responsible to parse the data of trace buffer. Either field
120 'write_trace_buffer' or field ' frame_ops' is NULL. */
121 const struct trace_frame_write_ops
*frame_ops
;
123 /* The end of writing trace buffers. */
124 void (*end
) (struct trace_file_writer
*self
);
127 /* Trace file writer for a given format. */
129 struct trace_file_writer
131 const struct trace_file_write_ops
*ops
;
134 extern struct trace_file_writer
*tfile_trace_file_writer_new (void);
136 /* Base class for tracefile related targets. */
138 class tracefile_target
: public process_stratum_target
141 tracefile_target () = default;
143 int get_trace_status (trace_status
*ts
) override
;
144 bool has_all_memory () override
;
145 bool has_memory () override
;
146 bool has_stack () override
;
147 bool has_registers () override
;
148 bool has_execution (inferior
*inf
) override
{ return false; }
149 bool thread_alive (ptid_t ptid
) override
;
152 extern void tracefile_fetch_registers (struct regcache
*regcache
, int regno
);
154 #endif /* GDB_TRACEFILE_H */