From 10cb744f194dc2a0ce0c3d52965aafb2b190068b Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Thu, 23 Aug 2012 07:10:46 +0000 Subject: Add an option for darwin gdb compatibility. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162432 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'lib/CodeGen/AsmPrinter/DwarfDebug.cpp') diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 649684a..02d86c7 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -58,6 +58,10 @@ static cl::opt DwarfAccelTables("dwarf-accel-tables", cl::Hidden, cl::desc("Output prototype dwarf accelerator tables."), cl::init(false)); +static cl::opt DarwinGDBCompat("darwin-gdb-compat", cl::Hidden, + cl::desc("Compatibility with Darwin gdb."), + cl::init(false)); + namespace { const char *DWARFGroupName = "DWARF Emission"; const char *DbgTimerName = "DWARF Debug Writer"; @@ -135,9 +139,12 @@ DwarfDebug::DwarfDebug(AsmPrinter *A, Module *M) DwarfDebugRangeSectionSym = DwarfDebugLocSectionSym = 0; FunctionBeginSym = FunctionEndSym = 0; - // Turn on accelerator tables for Darwin. - if (Triple(M->getTargetTriple()).isOSDarwin()) + // Turn on accelerator tables and older gdb compatibility + // for Darwin. + if (Triple(M->getTargetTriple()).isOSDarwin()) { DwarfAccelTables = true; + DarwinGDBCompat = true; + } { NamedRegionTimer T(DbgTimerName, DWARFGroupName, TimePassesIsEnabled); -- cgit v1.1 From 360f0062bc83610e944123ee30eb057c325dfbf7 Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Thu, 23 Aug 2012 07:10:56 +0000 Subject: Emit pubtypes only when going for darwin gdb compatibility. rdar://10393214 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162434 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib/CodeGen/AsmPrinter/DwarfDebug.cpp') diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 02d86c7..944c202 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -832,7 +832,10 @@ void DwarfDebug::endModule() { } // Emit info into a debug pubtypes section. - emitDebugPubTypes(); + // TODO: When we don't need the option anymore we can + // remove all of the code that adds to the table. + if (DarwinGDBCompat) + emitDebugPubTypes(); // Emit info into a debug loc section. emitDebugLoc(); -- cgit v1.1 From 9eb1a94c2020b4d6ba53962745eef19559b39a9f Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Thu, 23 Aug 2012 07:32:02 +0000 Subject: Only emit the __debug_inlined section if we're trying to be compatible with older gdbs on darwin. rdar://10975874 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162436 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib/CodeGen/AsmPrinter/DwarfDebug.cpp') diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 944c202..2c23712 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -850,7 +850,11 @@ void DwarfDebug::endModule() { emitDebugMacInfo(); // Emit inline info. - emitDebugInlineInfo(); + // TODO: When we don't need the option anymore we + // can remove all of the code that this section + // depends upon. + if (DarwinGDBCompat) + emitDebugInlineInfo(); // Emit info into a debug str section. emitDebugStr(); -- cgit v1.1 From 9d9f5a5855a711b1154e178e26f3766dc21d846a Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Thu, 23 Aug 2012 07:32:06 +0000 Subject: Typo. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162438 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/CodeGen/AsmPrinter/DwarfDebug.cpp') diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 2c23712..d9dcd33 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -823,7 +823,7 @@ void DwarfDebug::endModule() { // Corresponding abbreviations into a abbrev section. emitAbbreviations(); - // Emit info into a dwarf accelerator table sections. + // Emit info into the dwarf accelerator table sections. if (DwarfAccelTables) { emitAccelNames(); emitAccelObjC(); -- cgit v1.1 From c1610fa3c43befd489cd41e358bfa48323594266 Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Thu, 23 Aug 2012 22:36:36 +0000 Subject: Add a flag to DwarfDebug to allow it to communicate whether or not we're using the darwin old gdb compat mode for emitting dwarf. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162486 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib/CodeGen/AsmPrinter/DwarfDebug.cpp') diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index d9dcd33..1991785 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -145,6 +145,8 @@ DwarfDebug::DwarfDebug(AsmPrinter *A, Module *M) DwarfAccelTables = true; DarwinGDBCompat = true; } + + isDarwinGDBCompat = DarwinGDBCompat; { NamedRegionTimer T(DbgTimerName, DWARFGroupName, TimePassesIsEnabled); -- cgit v1.1 From 20f47ab7688ba1e5e4c6af4be47c2f07ee4e9ab6 Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Thu, 23 Aug 2012 22:36:40 +0000 Subject: Turn these two options in to trinary state so that they can be turned on and off separate from the platform if you're on darwin. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162487 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 54 ++++++++++++++++++++++++++--------- 1 file changed, 40 insertions(+), 14 deletions(-) (limited to 'lib/CodeGen/AsmPrinter/DwarfDebug.cpp') diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 1991785..fb4ae0f 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -54,13 +54,29 @@ static cl::opt UnknownLocations("use-unknown-locations", cl::Hidden, cl::desc("Make an absence of debug location information explicit."), cl::init(false)); -static cl::opt DwarfAccelTables("dwarf-accel-tables", cl::Hidden, - cl::desc("Output prototype dwarf accelerator tables."), - cl::init(false)); +namespace { + enum DefaultOnOff { + Default, Enable, Disable + }; +} -static cl::opt DarwinGDBCompat("darwin-gdb-compat", cl::Hidden, +static cl::opt DwarfAccelTables("dwarf-accel-tables", cl::Hidden, + cl::desc("Output prototype dwarf accelerator tables."), + cl::values( + clEnumVal(Default, "Default for platform"), + clEnumVal(Enable, "Enabled"), + clEnumVal(Disable, "Disabled"), + clEnumValEnd), + cl::init(Default)); + +static cl::opt DarwinGDBCompat("darwin-gdb-compat", cl::Hidden, cl::desc("Compatibility with Darwin gdb."), - cl::init(false)); + cl::values( + clEnumVal(Default, "Default for platform"), + clEnumVal(Enable, "Enabled"), + clEnumVal(Disable, "Disabled"), + clEnumValEnd), + cl::init(Default)); namespace { const char *DWARFGroupName = "DWARF Emission"; @@ -141,13 +157,23 @@ DwarfDebug::DwarfDebug(AsmPrinter *A, Module *M) // Turn on accelerator tables and older gdb compatibility // for Darwin. - if (Triple(M->getTargetTriple()).isOSDarwin()) { - DwarfAccelTables = true; - DarwinGDBCompat = true; - } + bool isDarwin = Triple(M->getTargetTriple()).isOSDarwin(); + if (DarwinGDBCompat == Default) { + if (isDarwin) + isDarwinGDBCompat = true; + else + isDarwinGDBCompat = false; + } else + isDarwinGDBCompat = DarwinGDBCompat == Enable ? true : false; + + if (DwarfAccelTables == Default) { + if (isDarwin) + hasDwarfAccelTables = true; + else + hasDwarfAccelTables = false; + } else + hasDwarfAccelTables = DwarfAccelTables == Enable ? true : false; - isDarwinGDBCompat = DarwinGDBCompat; - { NamedRegionTimer T(DbgTimerName, DWARFGroupName, TimePassesIsEnabled); beginModule(M); @@ -826,7 +852,7 @@ void DwarfDebug::endModule() { emitAbbreviations(); // Emit info into the dwarf accelerator table sections. - if (DwarfAccelTables) { + if (useDwarfAccelTables()) { emitAccelNames(); emitAccelObjC(); emitAccelNamespaces(); @@ -836,7 +862,7 @@ void DwarfDebug::endModule() { // Emit info into a debug pubtypes section. // TODO: When we don't need the option anymore we can // remove all of the code that adds to the table. - if (DarwinGDBCompat) + if (useDarwinGDBCompat()) emitDebugPubTypes(); // Emit info into a debug loc section. @@ -855,7 +881,7 @@ void DwarfDebug::endModule() { // TODO: When we don't need the option anymore we // can remove all of the code that this section // depends upon. - if (DarwinGDBCompat) + if (useDarwinGDBCompat()) emitDebugInlineInfo(); // Emit info into a debug str section. -- cgit v1.1 From 873cf0a0d7906083578d9b793008348750636138 Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Fri, 24 Aug 2012 01:14:27 +0000 Subject: Use DW_FORM_flag_present to save space in debug information if we're not in darwin gdb compat mode. Fixes rdar://10975088 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162526 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'lib/CodeGen/AsmPrinter/DwarfDebug.cpp') diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index fb4ae0f..946ac35 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -317,7 +317,7 @@ DIE *DwarfDebug::updateSubprogramScopeDIE(CompileUnit *SPCU, if (SP.isDefinition() && !SP.getContext().isCompileUnit() && !SP.getContext().isFile() && !isSubprogramContext(SP.getContext())) { - SPCU->addUInt(SPDie, dwarf::DW_AT_declaration, dwarf::DW_FORM_flag, 1); + SPCU->addFlag(SPDie, dwarf::DW_AT_declaration); // Add arguments. DICompositeType SPTy = SP.getType(); @@ -329,7 +329,7 @@ DIE *DwarfDebug::updateSubprogramScopeDIE(CompileUnit *SPCU, DIType ATy = DIType(DIType(Args.getElement(i))); SPCU->addType(Arg, ATy); if (ATy.isArtificial()) - SPCU->addUInt(Arg, dwarf::DW_AT_artificial, dwarf::DW_FORM_flag, 1); + SPCU->addFlag(Arg, dwarf::DW_AT_artificial); SPDie->addChild(Arg); } DIE *SPDeclDie = SPDie; @@ -610,7 +610,7 @@ CompileUnit *DwarfDebug::constructCompileUnit(const MDNode *N) { if (!CompilationDir.empty()) NewCU->addString(Die, dwarf::DW_AT_comp_dir, CompilationDir); if (DIUnit.isOptimized()) - NewCU->addUInt(Die, dwarf::DW_AT_APPLE_optimized, dwarf::DW_FORM_flag, 1); + NewCU->addFlag(Die, dwarf::DW_AT_APPLE_optimized); StringRef Flags = DIUnit.getFlags(); if (!Flags.empty()) @@ -1481,8 +1481,7 @@ void DwarfDebug::endFunction(const MachineFunction *MF) { DIE *CurFnDIE = constructScopeDIE(TheCU, FnScope); if (!MF->getTarget().Options.DisableFramePointerElim(*MF)) - TheCU->addUInt(CurFnDIE, dwarf::DW_AT_APPLE_omit_frame_ptr, - dwarf::DW_FORM_flag, 1); + TheCU->addFlag(CurFnDIE, dwarf::DW_AT_APPLE_omit_frame_ptr); DebugFrames.push_back(FunctionDebugFrameInfo(Asm->getFunctionNumber(), MMI->getFrameMoves())); -- cgit v1.1