From 584fd9619cdc9d2a8b97de2703d0e9d87fec79d8 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Tue, 6 Sep 2016 22:50:55 -0400 Subject: [PATCH] libdebugger: Fix #12944. LocatableFile: - If there is no parent path, don't insert a path separator between parent and filename. This may be the case depending on how the source file was specified during compilation. FileManager: - When constructing an EntryPath from a LocatableEntry, ensure that the parent folder actually has a path string that isn't simply empty to ensure consistency with the raw dir/file case. Otherwise, hash lookups that are dependent on the parent dir being NULL if not specified will fail, causing us to not locate the file successfully. This was preventing us from updating source location information for make 4.2's main.c, as the latter was specified in such a way that the above combination of conditions would occur, and consequently when asking the FileManager to update the source location with the actual file, the entry couldn't be found in the table, and no information would be updated. --- src/kits/debugger/files/FileManager.cpp | 7 +++++-- src/kits/debugger/files/LocatableFile.cpp | 5 ++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/kits/debugger/files/FileManager.cpp b/src/kits/debugger/files/FileManager.cpp index 33be50f06b..bce3c02db0 100644 --- a/src/kits/debugger/files/FileManager.cpp +++ b/src/kits/debugger/files/FileManager.cpp @@ -1,6 +1,6 @@ /* * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. - * Copyright 2011-2013, Rene Gollent, rene@gollent.com. + * Copyright 2011-2016, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ @@ -41,9 +41,12 @@ struct FileManager::EntryPath { EntryPath(const LocatableEntry* entry) : - directory(entry->Parent() != NULL ? entry->Parent()->Path() : NULL), + directory(NULL), name(entry->Name()) { + LocatableDirectory* parent = entry->Parent(); + if (parent != NULL && strlen(parent->Path()) > 0) + directory = parent->Path(); } EntryPath(const EntryPath& other) diff --git a/src/kits/debugger/files/LocatableFile.cpp b/src/kits/debugger/files/LocatableFile.cpp index 38ebdc56e0..ab45947737 100644 --- a/src/kits/debugger/files/LocatableFile.cpp +++ b/src/kits/debugger/files/LocatableFile.cpp @@ -1,5 +1,6 @@ /* * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2016, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ @@ -40,7 +41,9 @@ void LocatableFile::GetPath(BString& _path) const { fParent->GetPath(_path); - _path << '/' << fName; + if (_path.Length() != 0) + _path << '/'; + _path << fName; }