1//===-- DWARFDefines.cpp --------------------------------------------------===//
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"
10#include "lldb/Utility/ConstString.h"
11#include <cstdio>
12#include <cstring>
13#include <string>
14
15namespace lldb_private::plugin {
16namespace dwarf {
17
18const char *DW_TAG_value_to_name(uint32_t val) {
19 static char invalid[100];
20
21 if (val == 0)
22 return "NULL";
23
24 llvm::StringRef llvmstr = llvm::dwarf::TagString(Tag: val);
25 if (llvmstr.empty()) {
26 snprintf(s: invalid, maxlen: sizeof(invalid), format: "Unknown DW_TAG constant: 0x%x", val);
27 return invalid;
28 }
29 return llvmstr.data();
30}
31
32const char *DW_AT_value_to_name(uint32_t val) {
33 static char invalid[100];
34 llvm::StringRef llvmstr = llvm::dwarf::AttributeString(Attribute: val);
35 if (llvmstr.empty()) {
36 snprintf(s: invalid, maxlen: sizeof(invalid), format: "Unknown DW_AT constant: 0x%x", val);
37 return invalid;
38 }
39 return llvmstr.data();
40}
41
42const char *DW_FORM_value_to_name(uint32_t val) {
43 static char invalid[100];
44 llvm::StringRef llvmstr = llvm::dwarf::FormEncodingString(Encoding: val);
45 if (llvmstr.empty()) {
46 snprintf(s: invalid, maxlen: sizeof(invalid), format: "Unknown DW_FORM constant: 0x%x", val);
47 return invalid;
48 }
49 return llvmstr.data();
50}
51
52const char *DW_OP_value_to_name(uint32_t val) {
53 static char invalid[100];
54 llvm::StringRef llvmstr = llvm::dwarf::OperationEncodingString(Encoding: val);
55 if (llvmstr.empty()) {
56 snprintf(s: invalid, maxlen: sizeof(invalid), format: "Unknown DW_OP constant: 0x%x", val);
57 return invalid;
58 }
59 return llvmstr.data();
60}
61
62const char *DW_ATE_value_to_name(uint32_t val) {
63 static char invalid[100];
64 llvm::StringRef llvmstr = llvm::dwarf::AttributeEncodingString(Encoding: val);
65 if (llvmstr.empty()) {
66 snprintf(s: invalid, maxlen: sizeof(invalid), format: "Unknown DW_ATE constant: 0x%x", val);
67 return invalid;
68 }
69 return llvmstr.data();
70}
71
72const char *DW_LANG_value_to_name(uint32_t val) {
73 static char invalid[100];
74 llvm::StringRef llvmstr = llvm::dwarf::LanguageString(Language: val);
75 if (llvmstr.empty()) {
76 snprintf(s: invalid, maxlen: sizeof(invalid), format: "Unknown DW_LANG constant: 0x%x", val);
77 return invalid;
78 }
79 return llvmstr.data();
80}
81
82const char *DW_LNS_value_to_name(uint32_t val) {
83 static char invalid[100];
84 llvm::StringRef llvmstr = llvm::dwarf::LNStandardString(Standard: val);
85 if (llvmstr.empty()) {
86 snprintf(s: invalid, maxlen: sizeof(invalid), format: "Unknown DW_LNS constant: 0x%x", val);
87 return invalid;
88 }
89 return llvmstr.data();
90}
91
92} // namespace dwarf
93} // namespace lldb_private::plugin
94

source code of lldb/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp