[PATCH] D58334: [LLVM-C] Add bindings to create macro debug info
Jean-Bapiste Lepesme via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 18 03:45:07 PST 2019
Jiboo updated this revision to Diff 187216.
Jiboo added a comment.
Mybad, llvm::dwarf::MacinfoRecordType (in llvm/BinaryFormat/Dwarf.h) isn't generated using Dwarf.def, so I just used the same values for another enum in llvm-c/DebugInfo.h.
The values in llvm::dwarf::MacinfoRecordType won't move as they are defined by the DWARFv4 standard (Figure 39. Macinfo Type Encodings, at page 194/325), so it is safe to static_cast it from the new LLVMDWARFMacinfoRecordType to MacinfoRecordType.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D58334/new/
https://reviews.llvm.org/D58334
Files:
llvm/include/llvm-c/DebugInfo.h
llvm/lib/IR/DebugInfo.cpp
Index: llvm/lib/IR/DebugInfo.cpp
===================================================================
--- llvm/lib/IR/DebugInfo.cpp
+++ llvm/lib/IR/DebugInfo.cpp
@@ -899,6 +899,26 @@
return wrap(unwrapDI<DILocation>(Location)->getScope());
}
+LLVMMetadataRef LLVMDIBuilderCreateMacro(LLVMDIBuilderRef Builder,
+ LLVMMetadataRef ParentMacroFile,
+ unsigned Line,
+ LLVMDWARFMacinfoRecordType RecordType,
+ const char *Name, size_t NameLen,
+ const char *Value, size_t ValueLen) {
+ return wrap(
+ unwrap(Builder)->createMacro(unwrapDI<DIMacroFile>(ParentMacroFile), Line,
+ static_cast<MacinfoRecordType>(RecordType),
+ {Name, NameLen}, {Value, ValueLen}));
+}
+
+LLVMMetadataRef
+LLVMDIBuilderCreateTempMacroFile(LLVMDIBuilderRef Builder,
+ LLVMMetadataRef ParentMacroFile, unsigned Line,
+ LLVMMetadataRef File) {
+ return wrap(unwrap(Builder)->createTempMacroFile(
+ unwrapDI<DIMacroFile>(ParentMacroFile), Line, unwrapDI<DIFile>(File)));
+}
+
LLVMMetadataRef LLVMDIBuilderCreateEnumerator(LLVMDIBuilderRef Builder,
const char *Name, size_t NameLen,
int64_t Value,
Index: llvm/include/llvm-c/DebugInfo.h
===================================================================
--- llvm/include/llvm-c/DebugInfo.h
+++ llvm/include/llvm-c/DebugInfo.h
@@ -169,6 +169,18 @@
*/
typedef unsigned LLVMDWARFTypeEncoding;
+/**
+ * Describes the kind of macro declaration used for LLVMDIBuilderCreateMacro.
+ * @see llvm::dwarf::MacinfoRecordType
+ */
+typedef enum {
+ LLVMDWARFMacinfoRecordTypeDefine = 0x01,
+ LLVMDWARFMacinfoRecordTypeMacro = 0x02,
+ LLVMDWARFMacinfoRecordTypeStartFile = 0x03,
+ LLVMDWARFMacinfoRecordTypeEndFile = 0x04,
+ LLVMDWARFMacinfoRecordTypeVendorExt = 0xff
+} LLVMDWARFMacinfoRecordType;
+
/**
* The current debug metadata version number.
*/
@@ -478,6 +490,38 @@
unsigned NumParameterTypes,
LLVMDIFlags Flags);
+/**
+ * Create debugging information entry for a macro.
+ * @param Builder The DIBuilder.
+ * @param ParentMacroFile Macro parent (could be NULL).
+ * @param Line Source line number where the macro is defined.
+ * @param MacroType DW_MACINFO_define or DW_MACINFO_undef.
+ * @param Name Macro name.
+ * @param NameLen Macro name length.
+ * @param Value Macro value.
+ * @param ValueLen Macro value length.
+ */
+LLVMMetadataRef LLVMDIBuilderCreateMacro(LLVMDIBuilderRef Builder,
+ LLVMMetadataRef ParentMacroFile,
+ unsigned Line,
+ LLVMDWARFMacinfoRecordType RecordType,
+ const char *Name, size_t NameLen,
+ const char *Value, size_t ValueLen);
+
+/**
+ * Create debugging information temporary entry for a macro file.
+ * List of macro node direct children will be calculated by DIBuilder,
+ * using the \p ParentMacroFile relationship.
+ * @param Builder The DIBuilder.
+ * @param ParentMacroFile Macro parent (could be NULL).
+ * @param Line Source line number where the macro file is included.
+ * @param File File descriptor containing the name of the macro file.
+ */
+LLVMMetadataRef
+LLVMDIBuilderCreateTempMacroFile(LLVMDIBuilderRef Builder,
+ LLVMMetadataRef ParentMacroFile, unsigned Line,
+ LLVMMetadataRef File);
+
/**
* Create debugging information entry for an enumerator.
* @param Builder The DIBuilder.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58334.187216.patch
Type: text/x-patch
Size: 4050 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190218/c042a29c/attachment.bin>
More information about the llvm-commits
mailing list