diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-03-19 14:49:09 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-03-19 14:49:09 +0000 |
commit | f7ad50026074776bde13fdf790bcf2f647904f1b (patch) | |
tree | b3e48d9654d04f0fef66a92112ce075b72b745f9 /lib/CodeGen/CGDebugInfo.cpp | |
parent | 73061d054128e486e70e0f2874b23d6eca067e5b (diff) |
Try to improve computation of the main file name for debug
information, to address recent gdb failures.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98959 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGDebugInfo.cpp')
-rw-r--r-- | lib/CodeGen/CGDebugInfo.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index 323c458842..a40a5fbdce 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -105,16 +105,19 @@ void CGDebugInfo::CreateCompileUnit() { // Get absolute path name. SourceManager &SM = CGM.getContext().getSourceManager(); - std::string MainFileName; - if (const FileEntry *MainFile = SM.getFileEntryForID(SM.getMainFileID())) - MainFileName = MainFile->getName(); - else if (CGM.getCodeGenOpts().MainFileName.empty()) + std::string MainFileName = CGM.getCodeGenOpts().MainFileName; + if (MainFileName.empty()) MainFileName = "<unknown>"; - else - MainFileName = CGM.getCodeGenOpts().MainFileName; + llvm::sys::Path AbsFileName(MainFileName); AbsFileName.makeAbsolute(); + std::string MainFileDir; + if (const FileEntry *MainFile = SM.getFileEntryForID(SM.getMainFileID())) + MainFileDir = MainFile->getDir()->getName(); + else + MainFileDir = AbsFileName.getDirname(); + unsigned LangTag; const LangOptions &LO = CGM.getLangOptions(); if (LO.CPlusPlus) { @@ -143,7 +146,7 @@ void CGDebugInfo::CreateCompileUnit() { // Create new compile unit. TheCU = DebugFactory.CreateCompileUnit( - LangTag, AbsFileName.getLast(), AbsFileName.getDirname(), Producer, true, + LangTag, AbsFileName.getLast(), MainFileDir, Producer, true, LO.Optimize, CGM.getCodeGenOpts().DwarfDebugFlags, RuntimeVers); } |