xref: /illumos-gate/usr/src/lib/libdwarf/common/pro_frame.h (revision 18425b359c7d1e5f7f63fae3ca5245407223a45b)
1 /*
2 
3   Copyright (C) 2000,2004 Silicon Graphics, Inc.  All Rights Reserved.
4   Portions Copyright (C) 2017 David Anderson. All Rights Reserved.
5 
6   This program is free software; you can redistribute it and/or modify it
7   under the terms of version 2.1 of the GNU Lesser General Public License
8   as published by the Free Software Foundation.
9 
10   This program is distributed in the hope that it would be useful, but
11   WITHOUT ANY WARRANTY; without even the implied warranty of
12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 
14   Further, this software is distributed without any warranty that it is
15   free of the rightful claim of any third person regarding infringement
16   or the like.  Any license provided herein, whether implied or
17   otherwise, applies only to this software file.  Patent licenses, if
18   any, provided herein do not apply to combinations of this program with
19   other software, or any other product whatsoever.
20 
21   You should have received a copy of the GNU Lesser General Public
22   License along with this program; if not, write the Free Software
23   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301,
24   USA.
25 
26 */
27 
28 
29 
30 /*
31     Largest register value that can be coded into
32     the opcode since there are only 6 bits in the
33     register field.
34 */
35 #define MAX_6_BIT_VALUE		0x3f
36 
37 /* This struct holds debug_frame instructions */
38 typedef struct Dwarf_P_Frame_Pgm_s *Dwarf_P_Frame_Pgm;
39 
40 struct Dwarf_P_Frame_Pgm_s {
41     Dwarf_Ubyte    dfp_opcode; /* opcode - includes reg # */
42     char *         dfp_args;	 /* operands */
43     Dwarf_Unsigned dfp_nbytes;	 /* number of bytes in args */
44     Dwarf_P_Frame_Pgm dfp_next;
45 };
46 
47 
48 /*
49     This struct has cie related information. Used to gather data
50     from user program, and later to transform to disk form
51 */
52 struct Dwarf_P_Cie_s {
53     Dwarf_Half cie_version;
54 
55     /*  augmentation. The string is an strdup() copy
56         and on freeing the Dwarf_P_Cie the string must be freed. */
57     char *cie_aug;
58 
59 
60     Dwarf_Ubyte cie_code_align;	/* alignment of code */
61     Dwarf_Sbyte cie_data_align;
62     Dwarf_Ubyte cie_ret_reg;	/* return register # */
63     char *cie_inst;		/* initial instruction */
64     long cie_inst_bytes;
65     /* no of init_inst */
66     Dwarf_P_Cie cie_next;
67 };
68 
69 
70 /* producer fields */
71 struct Dwarf_P_Fde_s {
72     Dwarf_Unsigned fde_unused1;
73 
74     /* function/subr die for this fde */
75     Dwarf_P_Die fde_die;
76 
77     /* index to asso. cie */
78     Dwarf_Unsigned fde_cie;
79 
80     /*  Address of first location of the code this frame applies to If
81         fde_end_symbol non-zero, this represents the offset from the
82         symbol indicated by fde_r_symidx */
83     Dwarf_Addr fde_initloc;
84 
85     /* Relocation symbol for address of the code this frame applies to.  */
86     Dwarf_Unsigned fde_r_symidx;
87 
88     /* Bytes of instr for this fde, if known */
89     Dwarf_Unsigned fde_addr_range;
90 
91     /* linked list of instructions we will put in fde. */
92     Dwarf_P_Frame_Pgm fde_inst;
93 
94     /* number of instructions in fde */
95     Dwarf_Signed fde_n_inst;
96 
97     /* number of bytes of inst in fde */
98     Dwarf_Signed fde_n_bytes;
99 
100     /* offset into exception table for this function. */
101     Dwarf_Signed fde_offset_into_exception_tables;
102 
103     /* The symbol for the exception table elf section. */
104     Dwarf_Unsigned fde_exception_table_symbol;
105 
106     /* pointer to last inst */
107     Dwarf_P_Frame_Pgm fde_last_inst;
108 
109     Dwarf_P_Fde fde_next;
110 
111     /*  The symbol and offset of the end symbol. When fde_end_symbol is
112         non-zero we must represent the */
113     Dwarf_Addr fde_end_symbol_offset;
114     Dwarf_Unsigned fde_end_symbol;
115 
116     int fde_uwordb_size;
117     Dwarf_P_Debug fde_dbg;
118 
119     /*  If fde_block is non-null, then it is the set of instructions.
120         so we should use it rather than fde_inst. */
121     Dwarf_Unsigned fde_inst_block_size;
122     void *fde_block;
123 };
124