2015-10-06 18:17:34 +08:00
|
|
|
//===-- SymbolsTest.cpp -----------------------------------------*- C++ -*-===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2015-10-06 18:17:34 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2016-09-07 16:46:50 +08:00
|
|
|
#include "gtest/gtest.h"
|
|
|
|
|
2015-10-06 18:17:34 +08:00
|
|
|
#include "lldb/Core/ModuleSpec.h"
|
2018-11-01 05:49:27 +08:00
|
|
|
#include "lldb/Host/FileSystem.h"
|
|
|
|
#include "lldb/Host/HostInfo.h"
|
Move Host/Symbols.cpp to Symbols/LocateSymbolFile.cpp
Given that we have a target named Symbols, one wonders why a
file named Symbols.cpp is not in this target. To be clear,
the functions exposed from this file are really focused on
*locating* a symbol file on a given host, which is where the
ambiguity comes in. However, it makes more sense conceptually
to be in the Symbols target. While some of the specific places
to search for symbol files might change depending on the Host,
this is not inherently true in the same way that, for example,
"accessing the file system" or "starting threads" is
fundamentally dependent on the Host.
PDBs, for example, recently became a reality on non-Windows platforms,
and it's theoretically possible that DSYMs could become a thing on non
MacOSX platforms (maybe in a remote debugging scenario). Other types of
symbol files, such as DWO, DWP, etc have never been tied to any Host
platform anyway.
After this patch, there is only one remaining dependency from
Host to Target.
Differential Revision: https://reviews.llvm.org/D58730
llvm-svn: 355032
2019-02-28 05:42:10 +08:00
|
|
|
#include "lldb/Symbol/LocateSymbolFile.h"
|
2019-03-07 02:20:23 +08:00
|
|
|
#include "lldb/Target/Target.h"
|
2015-10-06 18:17:34 +08:00
|
|
|
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
2018-11-01 05:49:27 +08:00
|
|
|
namespace {
|
|
|
|
class SymbolsTest : public ::testing::Test {
|
|
|
|
public:
|
|
|
|
void SetUp() override {
|
|
|
|
FileSystem::Initialize();
|
|
|
|
HostInfo::Initialize();
|
|
|
|
}
|
|
|
|
void TearDown() override {
|
|
|
|
HostInfo::Terminate();
|
|
|
|
FileSystem::Terminate();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
TEST_F(
|
|
|
|
SymbolsTest,
|
|
|
|
TerminateLocateExecutableSymbolFileForUnknownExecutableAndUnknownSymbolFile) {
|
2016-09-07 04:57:50 +08:00
|
|
|
ModuleSpec module_spec;
|
2019-03-07 02:20:23 +08:00
|
|
|
FileSpecList search_paths = Target::GetDefaultDebugFileSearchPaths();
|
|
|
|
FileSpec symbol_file_spec =
|
|
|
|
Symbols::LocateExecutableSymbolFile(module_spec, search_paths);
|
2016-09-07 04:57:50 +08:00
|
|
|
EXPECT_TRUE(symbol_file_spec.GetFilename().IsEmpty());
|
2015-10-06 18:17:34 +08:00
|
|
|
}
|
|
|
|
|
2018-11-01 05:49:27 +08:00
|
|
|
TEST_F(SymbolsTest,
|
|
|
|
LocateExecutableSymbolFileForUnknownExecutableAndMissingSymbolFile) {
|
2016-09-07 04:57:50 +08:00
|
|
|
ModuleSpec module_spec;
|
|
|
|
// using a GUID here because the symbol file shouldn't actually exist on disk
|
|
|
|
module_spec.GetSymbolFileSpec().SetFile(
|
2018-11-02 05:05:36 +08:00
|
|
|
"4A524676-B24B-4F4E-968A-551D465EBAF1.so", FileSpec::Style::native);
|
2019-03-07 02:20:23 +08:00
|
|
|
FileSpecList search_paths = Target::GetDefaultDebugFileSearchPaths();
|
|
|
|
FileSpec symbol_file_spec =
|
|
|
|
Symbols::LocateExecutableSymbolFile(module_spec, search_paths);
|
2016-09-07 04:57:50 +08:00
|
|
|
EXPECT_TRUE(symbol_file_spec.GetFilename().IsEmpty());
|
2015-10-06 18:17:34 +08:00
|
|
|
}
|