LLDB  mainline
DWARFDefines.cpp
Go to the documentation of this file.
1 //===-- DWARFDefines.cpp ----------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "DWARFDefines.h"
11 #include <cstdio>
12 #include <cstring>
13 #include <string>
14 
15 namespace lldb_private {
16 
17 const char *DW_TAG_value_to_name(uint32_t val) {
18  static char invalid[100];
19 
20  if (val == 0)
21  return "NULL";
22 
23  llvm::StringRef llvmstr = llvm::dwarf::TagString(val);
24  if (llvmstr.empty()) {
25  snprintf(invalid, sizeof(invalid), "Unknown DW_TAG constant: 0x%x", val);
26  return invalid;
27  }
28  return llvmstr.data();
29 }
30 
31 const char *DW_AT_value_to_name(uint32_t val) {
32  static char invalid[100];
33  llvm::StringRef llvmstr = llvm::dwarf::AttributeString(val);
34  if (llvmstr.empty()) {
35  snprintf(invalid, sizeof(invalid), "Unknown DW_AT constant: 0x%x", val);
36  return invalid;
37  }
38  return llvmstr.data();
39 }
40 
41 const char *DW_FORM_value_to_name(uint32_t val) {
42  static char invalid[100];
43  llvm::StringRef llvmstr = llvm::dwarf::FormEncodingString(val);
44  if (llvmstr.empty()) {
45  snprintf(invalid, sizeof(invalid), "Unknown DW_FORM constant: 0x%x", val);
46  return invalid;
47  }
48  return llvmstr.data();
49 }
50 
51 const char *DW_OP_value_to_name(uint32_t val) {
52  static char invalid[100];
53  llvm::StringRef llvmstr = llvm::dwarf::OperationEncodingString(val);
54  if (llvmstr.empty()) {
55  snprintf(invalid, sizeof(invalid), "Unknown DW_OP constant: 0x%x", val);
56  return invalid;
57  }
58  return llvmstr.data();
59 }
60 
62  switch (val) {
63  case 0x03:
64  return DRC_ONEOPERAND;
65  case 0x06:
66  return DRC_ZEROOPERANDS;
67  case 0x08:
68  return DRC_ONEOPERAND;
69  case 0x09:
70  return DRC_ONEOPERAND;
71  case 0x0a:
72  return DRC_ONEOPERAND;
73  case 0x0b:
74  return DRC_ONEOPERAND;
75  case 0x0c:
76  return DRC_ONEOPERAND;
77  case 0x0d:
78  return DRC_ONEOPERAND;
79  case 0x0e:
80  return DRC_ONEOPERAND;
81  case 0x0f:
82  return DRC_ONEOPERAND;
83  case 0x10:
84  return DRC_ONEOPERAND;
85  case 0x11:
86  return DRC_ONEOPERAND;
87  case 0x12:
88  return DRC_ZEROOPERANDS;
89  case 0x13:
90  return DRC_ZEROOPERANDS;
91  case 0x14:
92  return DRC_ZEROOPERANDS;
93  case 0x15:
94  return DRC_ONEOPERAND;
95  case 0x16:
96  return DRC_ZEROOPERANDS;
97  case 0x17:
98  return DRC_ZEROOPERANDS;
99  case 0x18:
100  return DRC_ZEROOPERANDS;
101  case 0x19:
102  return DRC_ZEROOPERANDS;
103  case 0x1a:
104  return DRC_ZEROOPERANDS;
105  case 0x1b:
106  return DRC_ZEROOPERANDS;
107  case 0x1c:
108  return DRC_ZEROOPERANDS;
109  case 0x1d:
110  return DRC_ZEROOPERANDS;
111  case 0x1e:
112  return DRC_ZEROOPERANDS;
113  case 0x1f:
114  return DRC_ZEROOPERANDS;
115  case 0x20:
116  return DRC_ZEROOPERANDS;
117  case 0x21:
118  return DRC_ZEROOPERANDS;
119  case 0x22:
120  return DRC_ZEROOPERANDS;
121  case 0x23:
122  return DRC_ONEOPERAND;
123  case 0x24:
124  return DRC_ZEROOPERANDS;
125  case 0x25:
126  return DRC_ZEROOPERANDS;
127  case 0x26:
128  return DRC_ZEROOPERANDS;
129  case 0x27:
130  return DRC_ZEROOPERANDS;
131  case 0x2f:
132  return DRC_ONEOPERAND;
133  case 0x28:
134  return DRC_ONEOPERAND;
135  case 0x29:
136  return DRC_ZEROOPERANDS;
137  case 0x2a:
138  return DRC_ZEROOPERANDS;
139  case 0x2b:
140  return DRC_ZEROOPERANDS;
141  case 0x2c:
142  return DRC_ZEROOPERANDS;
143  case 0x2d:
144  return DRC_ZEROOPERANDS;
145  case 0x2e:
146  return DRC_ZEROOPERANDS;
147  case 0x30:
148  return DRC_ZEROOPERANDS;
149  case 0x31:
150  return DRC_ZEROOPERANDS;
151  case 0x32:
152  return DRC_ZEROOPERANDS;
153  case 0x33:
154  return DRC_ZEROOPERANDS;
155  case 0x34:
156  return DRC_ZEROOPERANDS;
157  case 0x35:
158  return DRC_ZEROOPERANDS;
159  case 0x36:
160  return DRC_ZEROOPERANDS;
161  case 0x37:
162  return DRC_ZEROOPERANDS;
163  case 0x38:
164  return DRC_ZEROOPERANDS;
165  case 0x39:
166  return DRC_ZEROOPERANDS;
167  case 0x3a:
168  return DRC_ZEROOPERANDS;
169  case 0x3b:
170  return DRC_ZEROOPERANDS;
171  case 0x3c:
172  return DRC_ZEROOPERANDS;
173  case 0x3d:
174  return DRC_ZEROOPERANDS;
175  case 0x3e:
176  return DRC_ZEROOPERANDS;
177  case 0x3f:
178  return DRC_ZEROOPERANDS;
179  case 0x40:
180  return DRC_ZEROOPERANDS;
181  case 0x41:
182  return DRC_ZEROOPERANDS;
183  case 0x42:
184  return DRC_ZEROOPERANDS;
185  case 0x43:
186  return DRC_ZEROOPERANDS;
187  case 0x44:
188  return DRC_ZEROOPERANDS;
189  case 0x45:
190  return DRC_ZEROOPERANDS;
191  case 0x46:
192  return DRC_ZEROOPERANDS;
193  case 0x47:
194  return DRC_ZEROOPERANDS;
195  case 0x48:
196  return DRC_ZEROOPERANDS;
197  case 0x49:
198  return DRC_ZEROOPERANDS;
199  case 0x4a:
200  return DRC_ZEROOPERANDS;
201  case 0x4b:
202  return DRC_ZEROOPERANDS;
203  case 0x4c:
204  return DRC_ZEROOPERANDS;
205  case 0x4d:
206  return DRC_ZEROOPERANDS;
207  case 0x4e:
208  return DRC_ZEROOPERANDS;
209  case 0x4f:
210  return DRC_ZEROOPERANDS;
211  case 0x50:
212  return DRC_ZEROOPERANDS;
213  case 0x51:
214  return DRC_ZEROOPERANDS;
215  case 0x52:
216  return DRC_ZEROOPERANDS;
217  case 0x53:
218  return DRC_ZEROOPERANDS;
219  case 0x54:
220  return DRC_ZEROOPERANDS;
221  case 0x55:
222  return DRC_ZEROOPERANDS;
223  case 0x56:
224  return DRC_ZEROOPERANDS;
225  case 0x57:
226  return DRC_ZEROOPERANDS;
227  case 0x58:
228  return DRC_ZEROOPERANDS;
229  case 0x59:
230  return DRC_ZEROOPERANDS;
231  case 0x5a:
232  return DRC_ZEROOPERANDS;
233  case 0x5b:
234  return DRC_ZEROOPERANDS;
235  case 0x5c:
236  return DRC_ZEROOPERANDS;
237  case 0x5d:
238  return DRC_ZEROOPERANDS;
239  case 0x5e:
240  return DRC_ZEROOPERANDS;
241  case 0x5f:
242  return DRC_ZEROOPERANDS;
243  case 0x60:
244  return DRC_ZEROOPERANDS;
245  case 0x61:
246  return DRC_ZEROOPERANDS;
247  case 0x62:
248  return DRC_ZEROOPERANDS;
249  case 0x63:
250  return DRC_ZEROOPERANDS;
251  case 0x64:
252  return DRC_ZEROOPERANDS;
253  case 0x65:
254  return DRC_ZEROOPERANDS;
255  case 0x66:
256  return DRC_ZEROOPERANDS;
257  case 0x67:
258  return DRC_ZEROOPERANDS;
259  case 0x68:
260  return DRC_ZEROOPERANDS;
261  case 0x69:
262  return DRC_ZEROOPERANDS;
263  case 0x6a:
264  return DRC_ZEROOPERANDS;
265  case 0x6b:
266  return DRC_ZEROOPERANDS;
267  case 0x6c:
268  return DRC_ZEROOPERANDS;
269  case 0x6d:
270  return DRC_ZEROOPERANDS;
271  case 0x6e:
272  return DRC_ZEROOPERANDS;
273  case 0x6f:
274  return DRC_ZEROOPERANDS;
275  case 0x70:
276  return DRC_ONEOPERAND;
277  case 0x71:
278  return DRC_ONEOPERAND;
279  case 0x72:
280  return DRC_ONEOPERAND;
281  case 0x73:
282  return DRC_ONEOPERAND;
283  case 0x74:
284  return DRC_ONEOPERAND;
285  case 0x75:
286  return DRC_ONEOPERAND;
287  case 0x76:
288  return DRC_ONEOPERAND;
289  case 0x77:
290  return DRC_ONEOPERAND;
291  case 0x78:
292  return DRC_ONEOPERAND;
293  case 0x79:
294  return DRC_ONEOPERAND;
295  case 0x7a:
296  return DRC_ONEOPERAND;
297  case 0x7b:
298  return DRC_ONEOPERAND;
299  case 0x7c:
300  return DRC_ONEOPERAND;
301  case 0x7d:
302  return DRC_ONEOPERAND;
303  case 0x7e:
304  return DRC_ONEOPERAND;
305  case 0x7f:
306  return DRC_ONEOPERAND;
307  case 0x80:
308  return DRC_ONEOPERAND;
309  case 0x81:
310  return DRC_ONEOPERAND;
311  case 0x82:
312  return DRC_ONEOPERAND;
313  case 0x83:
314  return DRC_ONEOPERAND;
315  case 0x84:
316  return DRC_ONEOPERAND;
317  case 0x85:
318  return DRC_ONEOPERAND;
319  case 0x86:
320  return DRC_ONEOPERAND;
321  case 0x87:
322  return DRC_ONEOPERAND;
323  case 0x88:
324  return DRC_ONEOPERAND;
325  case 0x89:
326  return DRC_ONEOPERAND;
327  case 0x8a:
328  return DRC_ONEOPERAND;
329  case 0x8b:
330  return DRC_ONEOPERAND;
331  case 0x8c:
332  return DRC_ONEOPERAND;
333  case 0x8d:
334  return DRC_ONEOPERAND;
335  case 0x8e:
336  return DRC_ONEOPERAND;
337  case 0x8f:
338  return DRC_ONEOPERAND;
339  case 0x90:
340  return DRC_ONEOPERAND;
341  case 0x91:
342  return DRC_ONEOPERAND;
343  case 0x92:
344  return DRC_TWOOPERANDS;
345  case 0x93:
346  return DRC_ONEOPERAND;
347  case 0x94:
348  return DRC_ONEOPERAND;
349  case 0x95:
350  return DRC_ONEOPERAND;
351  case 0x96:
352  return DRC_ZEROOPERANDS;
353  case 0x97:
354  return DRC_DWARFv3 | DRC_ZEROOPERANDS;
355  case 0x98:
356  return DRC_DWARFv3 | DRC_ONEOPERAND;
357  case 0x99:
358  return DRC_DWARFv3 | DRC_ONEOPERAND;
359  case 0x9a:
360  return DRC_DWARFv3 | DRC_ONEOPERAND;
361  case 0xf0:
362  return DRC_ZEROOPERANDS; /* DW_OP_APPLE_uninit */
363  case 0xe0:
364  return 0;
365  case 0xff:
366  return 0;
367  default:
368  return 0;
369  }
370 }
371 
372 const char *DW_ATE_value_to_name(uint32_t val) {
373  static char invalid[100];
374  llvm::StringRef llvmstr = llvm::dwarf::AttributeEncodingString(val);
375  if (llvmstr.empty()) {
376  snprintf(invalid, sizeof(invalid), "Unknown DW_ATE constant: 0x%x", val);
377  return invalid;
378  }
379  return llvmstr.data();
380 }
381 
382 const char *DW_LANG_value_to_name(uint32_t val) {
383  static char invalid[100];
384  llvm::StringRef llvmstr = llvm::dwarf::LanguageString(val);
385  if (llvmstr.empty()) {
386  snprintf(invalid, sizeof(invalid), "Unknown DW_LANG constant: 0x%x", val);
387  return invalid;
388  }
389  return llvmstr.data();
390 }
391 
392 const char *DW_LNS_value_to_name(uint32_t val) {
393  static char invalid[100];
394  llvm::StringRef llvmstr = llvm::dwarf::LNStandardString(val);
395  if (llvmstr.empty()) {
396  snprintf(invalid, sizeof(invalid), "Unknown DW_LNS constant: 0x%x", val);
397  return invalid;
398  }
399  return llvmstr.data();
400 }
401 
402 } // namespace lldb_private
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
const char * DW_FORM_value_to_name(uint32_t val)
const char * DW_LANG_value_to_name(uint32_t val)
const char * DW_LNS_value_to_name(uint32_t val)
uint32_t DRC_class
Definition: DWARFDefines.h:19
#define DRC_TWOOPERANDS
Definition: DWARFDefines.h:70
#define DRC_ZEROOPERANDS
Definition: DWARFDefines.h:73
const char * DW_OP_value_to_name(uint32_t val)
const char * DW_AT_value_to_name(uint32_t val)
DRC_class DW_OP_value_to_class(uint32_t val)
const char * DW_ATE_value_to_name(uint32_t val)
#define DRC_DWARFv3
Definition: DWARFDefines.h:46
#define DRC_ONEOPERAND
Definition: DWARFDefines.h:53
const char * DW_TAG_value_to_name(uint32_t val)