1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 
4 // Copyright (c) 2008, 2010 Google Inc. All Rights Reserved.
5 //
6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions are
8 // met:
9 //
10 //     * Redistributions of source code must retain the above copyright
11 // notice, this list of conditions and the following disclaimer.
12 //     * Redistributions in binary form must reproduce the above
13 // copyright notice, this list of conditions and the following disclaimer
14 // in the documentation and/or other materials provided with the
15 // distribution.
16 //     * Neither the name of Google Inc. nor the names of its
17 // contributors may be used to endorse or promote products derived from
18 // this software without specific prior written permission.
19 //
20 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 
32 // CFI reader author: Jim Blandy <jimb@mozilla.com> <jimb@red-bean.com>
33 
34 // This file is derived from the following file in
35 // toolkit/crashreporter/google-breakpad:
36 //   src/common/dwarf/dwarf2enums.h
37 
38 #ifndef LulDwarfInt_h
39 #define LulDwarfInt_h
40 
41 #include "LulCommonExt.h"
42 #include "LulDwarfExt.h"
43 
44 namespace lul {
45 
46 // These enums do not follow the google3 style only because they are
47 // known universally (specs, other implementations) by the names in
48 // exactly this capitalization.
49 // Tag names and codes.
50 
51 // Call Frame Info instructions.
52 enum DwarfCFI {
53   DW_CFA_advance_loc = 0x40,
54   DW_CFA_offset = 0x80,
55   DW_CFA_restore = 0xc0,
56   DW_CFA_nop = 0x00,
57   DW_CFA_set_loc = 0x01,
58   DW_CFA_advance_loc1 = 0x02,
59   DW_CFA_advance_loc2 = 0x03,
60   DW_CFA_advance_loc4 = 0x04,
61   DW_CFA_offset_extended = 0x05,
62   DW_CFA_restore_extended = 0x06,
63   DW_CFA_undefined = 0x07,
64   DW_CFA_same_value = 0x08,
65   DW_CFA_register = 0x09,
66   DW_CFA_remember_state = 0x0a,
67   DW_CFA_restore_state = 0x0b,
68   DW_CFA_def_cfa = 0x0c,
69   DW_CFA_def_cfa_register = 0x0d,
70   DW_CFA_def_cfa_offset = 0x0e,
71   DW_CFA_def_cfa_expression = 0x0f,
72   DW_CFA_expression = 0x10,
73   DW_CFA_offset_extended_sf = 0x11,
74   DW_CFA_def_cfa_sf = 0x12,
75   DW_CFA_def_cfa_offset_sf = 0x13,
76   DW_CFA_val_offset = 0x14,
77   DW_CFA_val_offset_sf = 0x15,
78   DW_CFA_val_expression = 0x16,
79 
80   // Opcodes in this range are reserved for user extensions.
81   DW_CFA_lo_user = 0x1c,
82   DW_CFA_hi_user = 0x3f,
83 
84   // SGI/MIPS specific.
85   DW_CFA_MIPS_advance_loc8 = 0x1d,
86 
87   // GNU extensions.
88   DW_CFA_GNU_window_save = 0x2d,
89   DW_CFA_GNU_args_size = 0x2e,
90   DW_CFA_GNU_negative_offset_extended = 0x2f
91 };
92 
93 // Exception handling 'z' augmentation letters.
94 enum DwarfZAugmentationCodes {
95   // If the CFI augmentation string begins with 'z', then the CIE and FDE
96   // have an augmentation data area just before the instructions, whose
97   // contents are determined by the subsequent augmentation letters.
98   DW_Z_augmentation_start = 'z',
99 
100   // If this letter is present in a 'z' augmentation string, the CIE
101   // augmentation data includes a pointer encoding, and the FDE
102   // augmentation data includes a language-specific data area pointer,
103   // represented using that encoding.
104   DW_Z_has_LSDA = 'L',
105 
106   // If this letter is present in a 'z' augmentation string, the CIE
107   // augmentation data includes a pointer encoding, followed by a pointer
108   // to a personality routine, represented using that encoding.
109   DW_Z_has_personality_routine = 'P',
110 
111   // If this letter is present in a 'z' augmentation string, the CIE
112   // augmentation data includes a pointer encoding describing how the FDE's
113   // initial location, address range, and DW_CFA_set_loc operands are
114   // encoded.
115   DW_Z_has_FDE_address_encoding = 'R',
116 
117   // If this letter is present in a 'z' augmentation string, then code
118   // addresses covered by FDEs that cite this CIE are signal delivery
119   // trampolines. Return addresses of frames in trampolines should not be
120   // adjusted as described in section 6.4.4 of the DWARF 3 spec.
121   DW_Z_is_signal_trampoline = 'S'
122 };
123 
124 // Expression opcodes
125 enum DwarfExpressionOpcodes {
126   DW_OP_addr = 0x03,
127   DW_OP_deref = 0x06,
128   DW_OP_const1s = 0x09,
129   DW_OP_const2u = 0x0a,
130   DW_OP_const2s = 0x0b,
131   DW_OP_const4u = 0x0c,
132   DW_OP_const4s = 0x0d,
133   DW_OP_const8u = 0x0e,
134   DW_OP_const8s = 0x0f,
135   DW_OP_constu = 0x10,
136   DW_OP_consts = 0x11,
137   DW_OP_dup = 0x12,
138   DW_OP_drop = 0x13,
139   DW_OP_over = 0x14,
140   DW_OP_pick = 0x15,
141   DW_OP_swap = 0x16,
142   DW_OP_rot = 0x17,
143   DW_OP_xderef = 0x18,
144   DW_OP_abs = 0x19,
145   DW_OP_and = 0x1a,
146   DW_OP_div = 0x1b,
147   DW_OP_minus = 0x1c,
148   DW_OP_mod = 0x1d,
149   DW_OP_mul = 0x1e,
150   DW_OP_neg = 0x1f,
151   DW_OP_not = 0x20,
152   DW_OP_or = 0x21,
153   DW_OP_plus = 0x22,
154   DW_OP_plus_uconst = 0x23,
155   DW_OP_shl = 0x24,
156   DW_OP_shr = 0x25,
157   DW_OP_shra = 0x26,
158   DW_OP_xor = 0x27,
159   DW_OP_skip = 0x2f,
160   DW_OP_bra = 0x28,
161   DW_OP_eq = 0x29,
162   DW_OP_ge = 0x2a,
163   DW_OP_gt = 0x2b,
164   DW_OP_le = 0x2c,
165   DW_OP_lt = 0x2d,
166   DW_OP_ne = 0x2e,
167   DW_OP_lit0 = 0x30,
168   DW_OP_lit31 = 0x4f,
169   DW_OP_reg0 = 0x50,
170   DW_OP_reg31 = 0x6f,
171   DW_OP_breg0 = 0x70,
172   DW_OP_breg31 = 0x8f,
173   DW_OP_regx = 0x90,
174   DW_OP_fbreg = 0x91,
175   DW_OP_bregx = 0x92,
176   DW_OP_piece = 0x93,
177   DW_OP_deref_size = 0x94,
178   DW_OP_xderef_size = 0x95,
179   DW_OP_nop = 0x96,
180   DW_OP_push_object_address = 0x97,
181   DW_OP_call2 = 0x98,
182   DW_OP_call4 = 0x99,
183   DW_OP_call_ref = 0x9a,
184   DW_OP_form_tls_address = 0x9b,
185   DW_OP_call_frame_cfa = 0x9c,
186   DW_OP_bit_piece = 0x9d,
187   DW_OP_lo_user = 0xe0,
188   DW_OP_hi_user = 0xff
189 };
190 
191 }  // namespace lul
192 
193 #endif  // LulDwarfInt_h
194