forked from OSchip/llvm-project
There is no need to use separate dir name for AT_comp_dir attribute. Using absolute path for filename allows clients to query complete file location info from gdb breakpoints. Save constructed full file name.
llvm-svn: 109263
This commit is contained in:
parent
3032354bbe
commit
28f167699a
|
|
@ -188,18 +188,25 @@ void CGDebugInfo::CreateCompileUnit() {
|
||||||
if (MainFileName.empty())
|
if (MainFileName.empty())
|
||||||
MainFileName = "<unknown>";
|
MainFileName = "<unknown>";
|
||||||
|
|
||||||
llvm::sys::Path AbsFileName(MainFileName);
|
|
||||||
AbsFileName.makeAbsolute();
|
|
||||||
|
|
||||||
// The main file name provided via the "-main-file-name" option contains just
|
// The main file name provided via the "-main-file-name" option contains just
|
||||||
// the file name itself with no path information. This file name may have had
|
// the file name itself with no path information. This file name may have had
|
||||||
// a relative path, so we look into the actual file entry for the main
|
// a relative path, so we look into the actual file entry for the main
|
||||||
// file to determine the real absolute path for the file.
|
// file to determine the real absolute path for the file.
|
||||||
std::string MainFileDir;
|
char *FileNamePtr = NULL;
|
||||||
if (const FileEntry *MainFile = SM.getFileEntryForID(SM.getMainFileID()))
|
if (const FileEntry *MainFile = SM.getFileEntryForID(SM.getMainFileID())) {
|
||||||
|
std::string MainFileDir;
|
||||||
MainFileDir = MainFile->getDir()->getName();
|
MainFileDir = MainFile->getDir()->getName();
|
||||||
else
|
llvm::sys::Path AbsFileDirName(MainFileDir);
|
||||||
MainFileDir = AbsFileName.getDirname();
|
AbsFileDirName.makeAbsolute();
|
||||||
|
AbsFileDirName.appendComponent(MainFileName);
|
||||||
|
FileNamePtr = DebugInfoNames.Allocate<char>(AbsFileDirName.size());
|
||||||
|
memcpy(FileNamePtr, AbsFileDirName.c_str(), AbsFileDirName.size());
|
||||||
|
} else {
|
||||||
|
llvm::sys::Path AbsFileDirName(MainFileName);
|
||||||
|
AbsFileDirName.makeAbsolute();
|
||||||
|
FileNamePtr = DebugInfoNames.Allocate<char>(AbsFileDirName.size());
|
||||||
|
memcpy(FileNamePtr, AbsFileDirName.c_str(), AbsFileDirName.size());
|
||||||
|
}
|
||||||
|
|
||||||
unsigned LangTag;
|
unsigned LangTag;
|
||||||
const LangOptions &LO = CGM.getLangOptions();
|
const LangOptions &LO = CGM.getLangOptions();
|
||||||
|
|
@ -229,7 +236,7 @@ void CGDebugInfo::CreateCompileUnit() {
|
||||||
|
|
||||||
// Create new compile unit.
|
// Create new compile unit.
|
||||||
TheCU = DebugFactory.CreateCompileUnit(
|
TheCU = DebugFactory.CreateCompileUnit(
|
||||||
LangTag, AbsFileName.getLast(), MainFileDir, Producer, true,
|
LangTag, FileNamePtr, llvm::StringRef(), Producer, true,
|
||||||
LO.Optimize, CGM.getCodeGenOpts().DwarfDebugFlags, RuntimeVers);
|
LO.Optimize, CGM.getCodeGenOpts().DwarfDebugFlags, RuntimeVers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue