RISC-V: Handle vector type alignment.
[external/binutils.git] / gdb / tracefile.h
1 #ifndef TRACEFILE_H
2 #define TRACEFILE_H 1
3
4 #include "tracepoint.h"
5 #include "target.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 target description.  */
89   void (*write_tdesc) (struct trace_file_writer *self);
90
91   /* Write to mark the end of the definition part.  */
92   void (*write_definition_end) (struct trace_file_writer *self);
93
94   /* Write the data of trace buffer without parsing.  The content is
95      in BUF and length is LEN.  */
96   void (*write_trace_buffer) (struct trace_file_writer *self,
97                               gdb_byte *buf, LONGEST len);
98
99   /* Operations to write trace frames.  The user of this field is
100      responsible to parse the data of trace buffer.  Either field
101      'write_trace_buffer' or field ' frame_ops' is NULL.  */
102   const struct trace_frame_write_ops *frame_ops;
103
104   /* The end of writing trace buffers.  */
105   void (*end) (struct trace_file_writer *self);
106 };
107
108 /* Trace file writer for a given format.  */
109
110 struct trace_file_writer
111 {
112   const struct trace_file_write_ops *ops;
113 };
114
115 extern struct trace_file_writer *tfile_trace_file_writer_new (void);
116
117 /* Base class for tracefile related targets.  */
118
119 class tracefile_target : public target_ops
120 {
121 public:
122   tracefile_target ();
123
124   int get_trace_status (trace_status *ts) override;
125   bool has_all_memory () override;
126   bool has_memory () override;
127   bool has_stack () override;
128   bool has_registers () override;
129   bool thread_alive (ptid_t ptid) override;
130 };
131
132 extern void tracefile_fetch_registers (struct regcache *regcache, int regno);
133
134 #endif /* TRACEFILE_H */