[gdb/dap] Move send_gdb and send_gdb_with_response to server module
[binutils-gdb.git] / gas / gen-sframe.h
blobfbe2fd5d9368f4ad776773fbc23434c4e6105250
1 /* gen-sframe.h - Support for generating SFrame.
2 Copyright (C) 2022-2024 Free Software Foundation, Inc.
4 This file is part of GAS, the GNU Assembler.
6 GAS 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, or (at your option)
9 any later version.
11 GAS 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 GAS; see the file COPYING. If not, write to the Free
18 Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
19 02110-1301, USA. */
21 #ifndef GENSFRAME_H
22 #define GENSFRAME_H
24 #define SFRAME_FRE_ELEM_LOC_REG 0
25 #define SFRAME_FRE_ELEM_LOC_STACK 1
27 /* SFrame Frame Row Entry (FRE).
29 A frame row entry is a slice of the frame and can be valid for a set of
30 program instructions. It keeps all information needed to retrieve the CFA
31 and the Return Address (RA) if tracked.
33 A frame row entry effectively stores accumulated information gathered by
34 interpreting multiple CFI instructions. More precisely, it is a
35 self-sufficient record in its own right. Only the subset of information
36 necessary for unwinding is stored: Given a PC, how to retrieve the CFA and
37 the RA.
40 struct sframe_row_entry
42 /* A linked list. */
43 struct sframe_row_entry *next;
45 /* Start and end of the frame row entry. */
46 symbolS *pc_begin;
47 symbolS *pc_end;
49 /* A frame row entry is a merge candidate if new information can be updated
50 on it. */
51 bool merge_candidate;
53 /* Whether the return address is mangled with pauth code. */
54 bool mangled_ra_p;
56 /* Track CFA base (architectural) register ID. */
57 unsigned int cfa_base_reg;
58 /* Offset from the CFA base register for recovering CFA. */
59 offsetT cfa_offset;
61 /* Track the other register used as base register for CFA. Specify whether
62 it is in register or memory. */
63 unsigned int base_reg;
64 unsigned int bp_loc;
65 /* If the other register is stashed on stack, note the offset. */
66 offsetT bp_offset;
68 /* Track RA location. Specify whether it is in register or memory. */
69 unsigned int ra_loc;
70 /* If RA is stashed on stack, note the offset. */
71 offsetT ra_offset;
74 /* SFrame Function Description Entry. */
76 struct sframe_func_entry
78 /* A linked list. */
79 struct sframe_func_entry *next;
81 /* Reference to the FDE created from CFI in dw2gencfi. Some information
82 like the start_address and the segment is made available via this
83 member. */
84 const struct fde_entry *dw_fde;
86 /* Reference to the first FRE for this function. */
87 struct sframe_row_entry *sframe_fres;
89 unsigned int num_fres;
92 /* SFrame Function Description Entry Translation Context. */
94 struct sframe_xlate_ctx
96 /* Reference to the FDE created from CFI in dw2gencfi. Information
97 like the FDE start_address, end_address and the cfi insns are
98 made available via this member. */
99 const struct fde_entry *dw_fde;
101 /* List of FREs in the current FDE translation context, bounded by first_fre
102 and last_fre. */
104 /* Keep track of the first FRE for the purpose of restoring state if
105 necessary (for DW_CFA_restore). */
106 struct sframe_row_entry *first_fre;
107 /* The last FRE in the list. */
108 struct sframe_row_entry *last_fre;
110 /* The current FRE under construction. */
111 struct sframe_row_entry *cur_fre;
112 /* Remember FRE for an eventual restore. */
113 struct sframe_row_entry *remember_fre;
115 unsigned num_xlate_fres;
118 /* Error codes for SFrame translation context. */
119 enum sframe_xlate_err
121 /* Success. */
122 SFRAME_XLATE_OK = 0,
123 /* Error. */
124 SFRAME_XLATE_ERROR = 1,
125 /* Detailed error codes. */
126 SFRAME_XLATE_ERR_INVAL = -1,
127 SFRAME_XLATE_ERR_NOTREPRESENTED = -2,
130 /* Callback to create the abi/arch identifier for SFrame section. */
132 unsigned char
133 sframe_get_abi_arch_callback (const char *target_arch,
134 int big_endian_p);
136 /* The list of all FDEs with data in SFrame internal representation. */
138 extern struct sframe_func_entry *all_sframe_fdes;
140 /* SFrame version specific operations structure. */
142 struct sframe_version_ops
144 unsigned char format_version; /* SFrame format version. */
145 /* set SFrame FRE info. */
146 unsigned char (*set_fre_info) (unsigned int, unsigned int, unsigned int,
147 bool);
148 /* set SFrame Func info. */
149 unsigned char (*set_func_info) (unsigned int, unsigned int, unsigned int);
152 /* Generate SFrame stack trace info and prepare contents for the output.
153 outout_sframe () is called at the end of file. */
155 extern void output_sframe (segT sframe_seg);
157 #endif /* GENSFRAME_H */