summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2009-08-31 22:47:13 +0000
committerDevang Patel <dpatel@apple.com>2009-08-31 22:47:13 +0000
commit82dfc0cd8c3c2bf780a13cc35c1a8df7ad137477 (patch)
tree0dbe401e9797b8f5e4828be039e4ec2f74684f4d
parent5e005d814f13f1796cf9e32c7525a5241fface1a (diff)
downloadllvm-82dfc0cd8c3c2bf780a13cc35c1a8df7ad137477.tar.gz
llvm-82dfc0cd8c3c2bf780a13cc35c1a8df7ad137477.tar.bz2
llvm-82dfc0cd8c3c2bf780a13cc35c1a8df7ad137477.tar.xz
Subprogram is a scope. Derive DISubprogram from DIScope.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80637 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/Analysis/DebugInfo.h26
-rw-r--r--lib/Analysis/DebugInfo.cpp19
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfDebug.cpp17
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfDebug.h5
4 files changed, 59 insertions, 8 deletions
diff --git a/include/llvm/Analysis/DebugInfo.h b/include/llvm/Analysis/DebugInfo.h
index f27d03b7d0..30cc099283 100644
--- a/include/llvm/Analysis/DebugInfo.h
+++ b/include/llvm/Analysis/DebugInfo.h
@@ -342,11 +342,26 @@ namespace llvm {
};
/// DISubprogram - This is a wrapper for a subprogram (e.g. a function).
- class DISubprogram : public DIGlobal {
+ class DISubprogram : public DIScope {
public:
- explicit DISubprogram(MDNode *N = 0)
- : DIGlobal(N, dwarf::DW_TAG_subprogram) {}
+ explicit DISubprogram(MDNode *N = 0) {
+ DbgNode = N;
+ if (DbgNode && !isSubprogram())
+ DbgNode = 0;
+ }
+ DIDescriptor getContext() const { return getDescriptorField(2); }
+ const std::string &getName(std::string &F) const {
+ return getStringField(3, F);
+ }
+ const std::string &getDisplayName(std::string &F) const {
+ return getStringField(4, F);
+ }
+ const std::string &getLinkageName(std::string &F) const {
+ return getStringField(5, F);
+ }
+ DICompileUnit getCompileUnit() const{ return getFieldAs<DICompileUnit>(6); }
+ unsigned getLineNumber() const { return getUnsignedField(7); }
DICompositeType getType() const { return getFieldAs<DICompositeType>(8); }
/// getReturnTypeName - Subprogram return types are encoded either as
@@ -362,6 +377,11 @@ namespace llvm {
return T.getName(F);
}
+ /// isLocalToUnit - Return true if this subprogram is local to the current
+ /// compile unit, like 'static' in C.
+ unsigned isLocalToUnit() const { return getUnsignedField(9); }
+ unsigned isDefinition() const { return getUnsignedField(10); }
+
/// Verify - Verify that a subprogram descriptor is well formed.
bool Verify() const;
diff --git a/lib/Analysis/DebugInfo.cpp b/lib/Analysis/DebugInfo.cpp
index 92731335af..0be6fcfec5 100644
--- a/lib/Analysis/DebugInfo.cpp
+++ b/lib/Analysis/DebugInfo.cpp
@@ -494,7 +494,24 @@ void DIGlobal::dump() const {
/// dump - Print subprogram.
void DISubprogram::dump() const {
- DIGlobal::dump();
+ std::string Res;
+ if (!getName(Res).empty())
+ errs() << " [" << Res << "] ";
+
+ unsigned Tag = getTag();
+ errs() << " [" << dwarf::TagString(Tag) << "] ";
+
+ // TODO : Print context
+ getCompileUnit().dump();
+ errs() << " [" << getLineNumber() << "] ";
+
+ if (isLocalToUnit())
+ errs() << " [local] ";
+
+ if (isDefinition())
+ errs() << " [def] ";
+
+ errs() << "\n";
}
/// dump - Print global variable.
diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index f7e782c794..0e55b54583 100644
--- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -487,6 +487,23 @@ void DwarfDebug::AddSourceLine(DIE *Die, const DIGlobal *G) {
AddUInt(Die, dwarf::DW_AT_decl_file, 0, FileID);
AddUInt(Die, dwarf::DW_AT_decl_line, 0, Line);
}
+
+/// AddSourceLine - Add location information to specified debug information
+/// entry.
+void DwarfDebug::AddSourceLine(DIE *Die, const DISubprogram *SP) {
+ // If there is no compile unit specified, don't add a line #.
+ if (SP->getCompileUnit().isNull())
+ return;
+
+ unsigned Line = SP->getLineNumber();
+ unsigned FileID = FindCompileUnit(SP->getCompileUnit()).getID();
+ assert(FileID && "Invalid file id");
+ AddUInt(Die, dwarf::DW_AT_decl_file, 0, FileID);
+ AddUInt(Die, dwarf::DW_AT_decl_line, 0, Line);
+}
+
+/// AddSourceLine - Add location information to specified debug information
+/// entry.
void DwarfDebug::AddSourceLine(DIE *Die, const DIType *Ty) {
// If there is no compile unit specified, don't add a line #.
DICompileUnit CU = Ty->getCompileUnit();
diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.h b/lib/CodeGen/AsmPrinter/DwarfDebug.h
index 44fef297e2..d312eed812 100644
--- a/lib/CodeGen/AsmPrinter/DwarfDebug.h
+++ b/lib/CodeGen/AsmPrinter/DwarfDebug.h
@@ -275,11 +275,8 @@ class VISIBILITY_HIDDEN DwarfDebug : public Dwarf {
/// AddSourceLine - Add location information to specified debug information
/// entry.
void AddSourceLine(DIE *Die, const DIVariable *V);
-
- /// AddSourceLine - Add location information to specified debug information
- /// entry.
void AddSourceLine(DIE *Die, const DIGlobal *G);
-
+ void AddSourceLine(DIE *Die, const DISubprogram *SP);
void AddSourceLine(DIE *Die, const DIType *Ty);
/// AddAddress - Add an address attribute to a die based on the location