[Lldb-commits] [PATCH] D13201: Fix segmentation fault in lldb_private::Symbols::LocateExecutableSymbolFile()
Bruce Mitchener via lldb-commits
lldb-commits at lists.llvm.org
Tue Oct 6 03:19:27 PDT 2015
This revision was automatically updated to reflect the committed changes.
Closed by commit rL249387: Fix segmentation fault in lldb_private::Symbols::LocateExecutableSymbolFile() (authored by brucem).
Changed prior to commit:
http://reviews.llvm.org/D13201?vs=36468&id=36608#toc
Repository:
rL LLVM
http://reviews.llvm.org/D13201
Files:
lldb/trunk/source/Host/common/Symbols.cpp
lldb/trunk/unittests/Host/CMakeLists.txt
lldb/trunk/unittests/Host/SymbolsTest.cpp
Index: lldb/trunk/unittests/Host/CMakeLists.txt
===================================================================
--- lldb/trunk/unittests/Host/CMakeLists.txt
+++ lldb/trunk/unittests/Host/CMakeLists.txt
@@ -1,4 +1,5 @@
add_lldb_unittest(HostTests
SocketAddressTest.cpp
SocketTest.cpp
+ SymbolsTest.cpp
)
Index: lldb/trunk/unittests/Host/SymbolsTest.cpp
===================================================================
--- lldb/trunk/unittests/Host/SymbolsTest.cpp
+++ lldb/trunk/unittests/Host/SymbolsTest.cpp
@@ -0,0 +1,30 @@
+//===-- SymbolsTest.cpp -----------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "gtest/gtest.h"
+#include "lldb/Host/Symbols.h"
+#include "lldb/Core/ModuleSpec.h"
+
+using namespace lldb_private;
+
+TEST(SymbolsTest, LocateExecutableSymbolFileForUnknownExecutableAndUnknownSymbolFile)
+{
+ ModuleSpec module_spec;
+ FileSpec symbol_file_spec = Symbols::LocateExecutableSymbolFile(module_spec);
+ EXPECT_TRUE(symbol_file_spec.GetFilename().IsEmpty());
+}
+
+TEST(SymbolsTest, LocateExecutableSymbolFileForUnknownExecutableAndMissingSymbolFile)
+{
+ ModuleSpec module_spec;
+ // using a GUID here because the symbol file shouldn't actually exist on disk
+ module_spec.GetSymbolFileSpec().SetFile("4A524676-B24B-4F4E-968A-551D465EBAF1.so", false);
+ FileSpec symbol_file_spec = Symbols::LocateExecutableSymbolFile(module_spec);
+ EXPECT_TRUE(symbol_file_spec.GetFilename().IsEmpty());
+}
Index: lldb/trunk/source/Host/common/Symbols.cpp
===================================================================
--- lldb/trunk/source/Host/common/Symbols.cpp
+++ lldb/trunk/source/Host/common/Symbols.cpp
@@ -249,10 +249,6 @@
uuid_str = uuid_str + ".debug";
}
- // Get directory of our module. Needed to check debug files like this:
- // /usr/lib/debug/usr/lib/library.so.debug
- std::string module_directory = module_spec.GetFileSpec().GetDirectory().AsCString();
-
size_t num_directories = debug_file_search_paths.GetSize();
for (size_t idx = 0; idx < num_directories; ++idx)
{
@@ -267,7 +263,11 @@
files.push_back (dirname + "/" + symbol_filename);
files.push_back (dirname + "/.debug/" + symbol_filename);
files.push_back (dirname + "/.build-id/" + uuid_str);
- files.push_back (dirname + module_directory + "/" + symbol_filename);
+
+ // Some debug files may stored in the module directory like this:
+ // /usr/lib/debug/usr/lib/library.so.debug
+ if (!file_dir.IsEmpty())
+ files.push_back (dirname + file_dir.AsCString() + "/" + symbol_filename);
const uint32_t num_files = files.size();
for (size_t idx_file = 0; idx_file < num_files; ++idx_file)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13201.36608.patch
Type: text/x-patch
Size: 3095 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20151006/10b37b2b/attachment-0001.bin>
More information about the lldb-commits
mailing list