aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Laskey <jlaskey@mac.com>2006-01-26 21:22:49 +0000
committerJim Laskey <jlaskey@mac.com>2006-01-26 21:22:49 +0000
commit6e87c0e029c011b9ee61068c607080ca4934378a (patch)
tree461d03d7672523772cac862a4a47d2f4089a5403
parent9471c8a93b117d8ac01c4ef1cb9faa583e03dec0 (diff)
Use global information to fill out Dwarf compile units.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25662 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/CodeGen/DwarfWriter.h5
-rw-r--r--include/llvm/CodeGen/MachineDebugInfo.h4
-rw-r--r--lib/CodeGen/DwarfWriter.cpp30
-rw-r--r--lib/CodeGen/MachineDebugInfo.cpp10
4 files changed, 25 insertions, 24 deletions
diff --git a/include/llvm/CodeGen/DwarfWriter.h b/include/llvm/CodeGen/DwarfWriter.h
index f199dd25fd..aec1077eed 100644
--- a/include/llvm/CodeGen/DwarfWriter.h
+++ b/include/llvm/CodeGen/DwarfWriter.h
@@ -32,6 +32,7 @@ namespace llvm {
// Forward declarations.
//
class AsmPrinter;
+ class CompileUnitWrapper;
class DIE;
class DwarfWriter;
class DWContext;
@@ -645,10 +646,10 @@ public:
unsigned Size, unsigned Align);
private:
+
/// NewCompileUnit - Create new compile unit information.
///
- DIE *NewCompileUnit(const std::string &Directory,
- const std::string &SourceName);
+ DIE *DwarfWriter::NewCompileUnit(const CompileUnitWrapper &CompileUnit);
/// EmitInitial - Emit initial Dwarf declarations.
///
diff --git a/include/llvm/CodeGen/MachineDebugInfo.h b/include/llvm/CodeGen/MachineDebugInfo.h
index 7bbd11db7a..fcd75f4749 100644
--- a/include/llvm/CodeGen/MachineDebugInfo.h
+++ b/include/llvm/CodeGen/MachineDebugInfo.h
@@ -271,6 +271,10 @@ public:
///
void MachineDebugInfo::SetupCompileUnits(Module &M);
+ /// getCompileUnits - Return a vector of debug compile units.
+ ///
+ const UniqueVector<CompileUnitWrapper> getCompileUnits() const;
+
/// getGlobalVariables - Return a vector of debug global variables.
///
static std::vector<GlobalWrapper> getGlobalVariables(Module &M);
diff --git a/lib/CodeGen/DwarfWriter.cpp b/lib/CodeGen/DwarfWriter.cpp
index 512f479fdd..cd2a9da12c 100644
--- a/lib/CodeGen/DwarfWriter.cpp
+++ b/lib/CodeGen/DwarfWriter.cpp
@@ -1242,20 +1242,16 @@ void DwarfWriter::NewGlobalVariable(DWContext *Context,
/// NewCompileUnit - Create new compile unit information.
///
-DIE *DwarfWriter::NewCompileUnit(const std::string &Directory,
- const std::string &SourceName) {
+DIE *DwarfWriter::NewCompileUnit(const CompileUnitWrapper &CompileUnit) {
DIE *Unit = new DIE(DW_TAG_compile_unit, DW_CHILDREN_yes);
// FIXME - use the correct line set.
Unit->AddLabel (DW_AT_stmt_list, DW_FORM_data4, DWLabel("line", 0));
Unit->AddLabel (DW_AT_high_pc, DW_FORM_addr, DWLabel("text_end", 0));
Unit->AddLabel (DW_AT_low_pc, DW_FORM_addr, DWLabel("text_begin", 0));
- // FIXME - The producer needs to be in this form, but should come from
- // an appropriate source.
- Unit->AddString(DW_AT_producer, DW_FORM_string,
- "llvm 3.4.x (LLVM Research Group)");
- Unit->AddInt (DW_AT_language, DW_FORM_data1, DW_LANG_C89);
- Unit->AddString(DW_AT_name, DW_FORM_string, SourceName);
- Unit->AddString(DW_AT_comp_dir, DW_FORM_string, Directory);
+ Unit->AddString(DW_AT_producer, DW_FORM_string, CompileUnit.getProducer());
+ Unit->AddInt (DW_AT_language, DW_FORM_data1, CompileUnit.getLanguage());
+ Unit->AddString(DW_AT_name, DW_FORM_string, CompileUnit.getFileName());
+ Unit->AddString(DW_AT_comp_dir, DW_FORM_string, CompileUnit.getDirectory());
Unit->Complete(*this);
return Unit;
@@ -1700,17 +1696,11 @@ void DwarfWriter::EmitDebugMacInfo() {
/// ConstructCompileUnitDIEs - Create a compile unit DIE for each source and
/// header file.
void DwarfWriter::ConstructCompileUnitDIEs() {
- // Get directory and source information.
- const UniqueVector<std::string> &Directories = DebugInfo->getDirectories();
- const UniqueVector<SourceFileInfo> &SourceFiles = DebugInfo->getSourceFiles();
-
- // Construct compile unit DIEs for each source.
- for (unsigned SourceID = 1, NSID = SourceFiles.size();
- SourceID <= NSID; ++SourceID) {
- const SourceFileInfo &SourceFile = SourceFiles[SourceID];
- const std::string &Directory = Directories[SourceFile.getDirectoryID()];
- const std::string &SourceName = SourceFile.getName();
- DIE *Unit = NewCompileUnit(Directory, SourceName);
+ const UniqueVector<CompileUnitWrapper> CUW = DebugInfo->getCompileUnits();
+
+ for (unsigned i = 1, N = CUW.size(); i <= N; ++i) {
+ const CompileUnitWrapper &CompileUnit = CUW[i];
+ DIE *Unit = NewCompileUnit(CompileUnit);
DWContext *Context = new DWContext(*this, NULL, Unit);
CompileUnits.push_back(Unit);
}
diff --git a/lib/CodeGen/MachineDebugInfo.cpp b/lib/CodeGen/MachineDebugInfo.cpp
index bfcd9815d4..7d7bb932c6 100644
--- a/lib/CodeGen/MachineDebugInfo.cpp
+++ b/lib/CodeGen/MachineDebugInfo.cpp
@@ -180,7 +180,7 @@ unsigned GlobalWrapper::getTag() const {
/// getContext - Return the "lldb.compile_unit" context global.
///
GlobalVariable *GlobalWrapper::getContext() const {
- return dyn_cast<GlobalVariable>(IC->getOperand(1));
+ return cast<GlobalVariable>(IC->getOperand(1));
}
/// getName - Return the name of the global.
@@ -192,7 +192,7 @@ const std::string GlobalWrapper::getName() const {
/// getType - Return the type of the global.
///
const GlobalVariable *GlobalWrapper::getType() const {
- return dyn_cast<GlobalVariable>(IC->getOperand(4));
+ return cast<GlobalVariable>(IC->getOperand(4));
}
/// isStatic - Return true if the global is static.
@@ -274,6 +274,12 @@ void MachineDebugInfo::SetupCompileUnits(Module &M) {
if (CompileUnits.size() != Globals.size()) CompileUnits.reset();
}
+/// getCompileUnits - Return a vector of debug compile units.
+///
+const UniqueVector<CompileUnitWrapper> MachineDebugInfo::getCompileUnits()const{
+ return CompileUnits;
+}
+
/// getGlobalVariables - Return a vector of debug global variables.
///
std::vector<GlobalWrapper> MachineDebugInfo::getGlobalVariables(Module &M) {