[PATCH] D72208: [bindings/go] Add methods to read debuginfo for globals

Ayke via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jan 4 09:55:59 PST 2020


aykevl created this revision.
aykevl added reviewers: whitequark, CodaFi.
Herald added a subscriber: aprantl.
Herald added a project: LLVM.
aykevl edited the summary of this revision.
aykevl edited the summary of this revision.

This adds methods to read debug info for functions (subprograms) and global variables. It is related to D72206 <https://reviews.llvm.org/D72206> (but for reading back debug info that was previously put into the IR) and requires D72207 <https://reviews.llvm.org/D72207> to be actually useful.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72208

Files:
  llvm/bindings/go/llvm/dibuilder.go


Index: llvm/bindings/go/llvm/dibuilder.go
===================================================================
--- llvm/bindings/go/llvm/dibuilder.go
+++ llvm/bindings/go/llvm/dibuilder.go
@@ -716,6 +716,12 @@
 	return string(((*[1 << 20]byte)(unsafe.Pointer(ptr)))[:length:length])
 }
 
+// GlobalVariableExpressionVariable returns the DIVariable associated with this
+// global variable expression.
+func (md Metadata) GlobalVariableExpressionVariable() Metadata {
+	return Metadata{C.LLVMDIGlobalVariableExpressionGetVariable(md.C)}
+}
+
 // LocationLine returns the line number of a DILocation.
 func (md Metadata) LocationLine() uint {
 	return uint(C.LLVMDILocationGetLine(md.C))
@@ -742,3 +748,24 @@
 func (md Metadata) ScopeFile() Metadata {
 	return Metadata{C.LLVMDIScopeGetFile(md.C)}
 }
+
+// SubprogramLine returns the line number of a DISubprogram.
+func (md Metadata) SubprogramLine() uint {
+	return uint(C.LLVMDISubprogramGetLine(md.C))
+}
+
+// VariableFile returns the file (DIFile) of a given variable.
+func (md Metadata) VariableFile() Metadata {
+	return Metadata{C.LLVMDIVariableGetFile(md.C)}
+}
+
+// VariableLine returns the line number of a DIVariable.
+func (md Metadata) VariableLine() uint {
+	return uint(C.LLVMDIVariableGetLine(md.C))
+}
+
+// VariableScope returns the metadata of the scope associated with this
+// variable.
+func (md Metadata) VariableScope() Metadata {
+	return Metadata{C.LLVMDIVariableGetScope(md.C)}
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72208.236186.patch
Type: text/x-patch
Size: 1459 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200104/3d32ba21/attachment.bin>


More information about the llvm-commits mailing list