diff options
| author | Greg Clayton <gclayton@apple.com> | 2013-12-02 19:35:49 +0000 |
|---|---|---|
| committer | Greg Clayton <gclayton@apple.com> | 2013-12-02 19:35:49 +0000 |
| commit | 5fb8f79738c57e474bee190555c3fca490f839e8 (patch) | |
| tree | 4199db27c6331f9dcbcdacd719dbe021fd497ea2 /lldb/source | |
| parent | 2c86a723313732097759b5fbbe2d58c9c33820cd (diff) | |
| download | bcm5719-llvm-5fb8f79738c57e474bee190555c3fca490f839e8.tar.gz bcm5719-llvm-5fb8f79738c57e474bee190555c3fca490f839e8.zip | |
Fixed internal code to not link against and code from "lldb/API/*".
lldb_private::Debugger was #including some "lldb/API" header files which causes tools (lldb-platform and lldb-gdbserver) that link against the internals only (no API layer) to fail to link depending on which calls were being used.
Also fixed the current working directory so that it gets set correctly for remote test suite runs. Now the remote working directory is set to: "ARCH/TESTNUM/..." where ARCH is the current architecture name and "TESTNUM" is the current test number.
Fixed the "lldb-platform" and "lldb-gdbserver" to not warn about mismatched visibility settings by having each have their own exports file which contains nothing. This forces all symbols to not be exported, and also quiets the linker warnings.
llvm-svn: 196141
Diffstat (limited to 'lldb/source')
| -rw-r--r-- | lldb/source/API/SBDebugger.cpp | 38 | ||||
| -rw-r--r-- | lldb/source/Commands/CommandObjectPlugin.cpp | 6 | ||||
| -rw-r--r-- | lldb/source/Core/Debugger.cpp | 53 | ||||
| -rw-r--r-- | lldb/source/Interpreter/PythonDataObjects.cpp | 2 | ||||
| -rw-r--r-- | lldb/source/Interpreter/ScriptInterpreterPython.cpp | 3 | ||||
| -rw-r--r-- | lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp | 12 | ||||
| -rw-r--r-- | lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp | 20 | ||||
| -rw-r--r-- | lldb/source/Target/Platform.cpp | 14 |
8 files changed, 89 insertions, 59 deletions
diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp index 5aa5c133a16..10c0b7dea20 100644 --- a/lldb/source/API/SBDebugger.cpp +++ b/lldb/source/API/SBDebugger.cpp @@ -38,6 +38,7 @@ #include "lldb/Core/Debugger.h" #include "lldb/Core/State.h" #include "lldb/DataFormatters/DataVisualization.h" +#include "lldb/Host/DynamicLibrary.h" #include "lldb/Interpreter/Args.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/OptionGroupPlatform.h" @@ -47,6 +48,41 @@ using namespace lldb; using namespace lldb_private; + +static lldb::DynamicLibrarySP +LoadPlugin (const lldb::DebuggerSP &debugger_sp, const FileSpec& spec, Error& error) +{ + lldb::DynamicLibrarySP dynlib_sp(new lldb_private::DynamicLibrary(spec)); + if (dynlib_sp && dynlib_sp->IsValid()) + { + typedef bool (*LLDBCommandPluginInit) (lldb::SBDebugger& debugger); + + lldb::SBDebugger debugger_sb(debugger_sp); + // This calls the bool lldb::PluginInitialize(lldb::SBDebugger debugger) function. + // TODO: mangle this differently for your system - on OSX, the first underscore needs to be removed and the second one stays + LLDBCommandPluginInit init_func = dynlib_sp->GetSymbol<LLDBCommandPluginInit>("_ZN4lldb16PluginInitializeENS_10SBDebuggerE"); + if (init_func) + { + if (init_func(debugger_sb)) + return dynlib_sp; + else + error.SetErrorString("plug-in refused to load (lldb::PluginInitialize(lldb::SBDebugger) returned false)"); + } + else + { + error.SetErrorString("plug-in is missing the required initialization: lldb::PluginInitialize(lldb::SBDebugger)"); + } + } + else + { + if (spec.Exists()) + error.SetErrorString("this file does not represent a loadable dylib"); + else + error.SetErrorString("no such file"); + } + return lldb::DynamicLibrarySP(); +} + void SBDebugger::Initialize () { @@ -57,7 +93,7 @@ SBDebugger::Initialize () SBCommandInterpreter::InitializeSWIG (); - Debugger::Initialize(); + Debugger::Initialize(LoadPlugin); } void diff --git a/lldb/source/Commands/CommandObjectPlugin.cpp b/lldb/source/Commands/CommandObjectPlugin.cpp index 1bc7632e298..658c077bc3e 100644 --- a/lldb/source/Commands/CommandObjectPlugin.cpp +++ b/lldb/source/Commands/CommandObjectPlugin.cpp @@ -11,10 +11,6 @@ #include "CommandObjectPlugin.h" -#include "lldb/API/SBDebugger.h" -#include "lldb/API/SBCommandInterpreter.h" -#include "lldb/API/SBCommandReturnObject.h" - #include "lldb/Host/Host.h" #include "lldb/Interpreter/CommandInterpreter.h" @@ -79,8 +75,6 @@ protected: bool DoExecute (Args& command, CommandReturnObject &result) { - typedef void (*LLDBCommandPluginInit) (lldb::SBDebugger debugger); - size_t argc = command.GetArgumentCount(); if (argc != 1) diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index 3941d82d47b..b57c6051a96 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -9,8 +9,6 @@ #include "lldb/lldb-python.h" -#include "lldb/API/SBDebugger.h" - #include "lldb/Core/Debugger.h" #include <map> @@ -46,6 +44,7 @@ #include "lldb/Target/TargetList.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" +#include "lldb/Target/SectionLoadList.h" #include "lldb/Target/StopInfo.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" @@ -155,19 +154,7 @@ enum ePropertyAutoOneLineSummaries }; -// -//const char * -//Debugger::GetFrameFormat() const -//{ -// return m_properties_sp->GetFrameFormat(); -//} -//const char * -//Debugger::GetThreadFormat() const -//{ -// return m_properties_sp->GetThreadFormat(); -//} -// - +Debugger::LoadPluginCallbackType Debugger::g_load_plugin_callback = NULL; Error Debugger::SetPropertyValue (const ExecutionContext *exe_ctx, @@ -373,8 +360,9 @@ Debugger::TestDebuggerRefCount () } void -Debugger::Initialize () +Debugger::Initialize (LoadPluginCallbackType load_plugin_callback) { + g_load_plugin_callback = load_plugin_callback; if (g_shared_debugger_refcount++ == 0) lldb_private::Initialize(); } @@ -412,31 +400,22 @@ Debugger::SettingsTerminate () bool Debugger::LoadPlugin (const FileSpec& spec, Error& error) { - lldb::DynamicLibrarySP dynlib_sp(new lldb_private::DynamicLibrary(spec)); - if (!dynlib_sp || dynlib_sp->IsValid() == false) + if (g_load_plugin_callback) { - if (spec.Exists()) - error.SetErrorString("this file does not represent a loadable dylib"); - else - error.SetErrorString("no such file"); - return false; - } - lldb::DebuggerSP debugger_sp(shared_from_this()); - lldb::SBDebugger debugger_sb(debugger_sp); - // This calls the bool lldb::PluginInitialize(lldb::SBDebugger debugger) function. - // TODO: mangle this differently for your system - on OSX, the first underscore needs to be removed and the second one stays - LLDBCommandPluginInit init_func = dynlib_sp->GetSymbol<LLDBCommandPluginInit>("_ZN4lldb16PluginInitializeENS_10SBDebuggerE"); - if (!init_func) - { - error.SetErrorString("cannot find the initialization function lldb::PluginInitialize(lldb::SBDebugger)"); - return false; + lldb::DynamicLibrarySP dynlib_sp = g_load_plugin_callback (shared_from_this(), spec, error); + if (dynlib_sp) + { + m_loaded_plugins.push_back(dynlib_sp); + return true; + } } - if (init_func(debugger_sb)) + else { - m_loaded_plugins.push_back(dynlib_sp); - return true; + // The g_load_plugin_callback is registered in SBDebugger::Initialize() + // and if the public API layer isn't available (code is linking against + // all of the internal LLDB static libraries), then we can't load plugins + error.SetErrorString("Public API layer is not available"); } - error.SetErrorString("dylib refused to be loaded"); return false; } diff --git a/lldb/source/Interpreter/PythonDataObjects.cpp b/lldb/source/Interpreter/PythonDataObjects.cpp index 8e5c2bf8fe6..1e2bd239119 100644 --- a/lldb/source/Interpreter/PythonDataObjects.cpp +++ b/lldb/source/Interpreter/PythonDataObjects.cpp @@ -15,7 +15,7 @@ #else -#include <Python.h> +#include "lldb/lldb-python.h" #include <stdio.h> diff --git a/lldb/source/Interpreter/ScriptInterpreterPython.cpp b/lldb/source/Interpreter/ScriptInterpreterPython.cpp index a44b5a9f68c..fb60fedbe94 100644 --- a/lldb/source/Interpreter/ScriptInterpreterPython.cpp +++ b/lldb/source/Interpreter/ScriptInterpreterPython.cpp @@ -15,8 +15,7 @@ #else -#include <Python.h> - +#include "lldb/lldb-python.h" #include "lldb/Interpreter/ScriptInterpreterPython.h" #include <stdlib.h> diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp index 0a484d8cc40..ac5a615022f 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp @@ -303,7 +303,7 @@ PlatformDarwin::GetSharedModuleWithLocalCache (const lldb_private::ModuleSpec &m Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM)); if (log) - log->Printf("[%s] Trying to find module %s/%s - platform path %s/%s symbol path %s/%s\n", + log->Printf("[%s] Trying to find module %s/%s - platform path %s/%s symbol path %s/%s", (IsHost() ? "host" : "remote"), module_spec.GetFileSpec().GetDirectory().AsCString(), module_spec.GetFileSpec().GetFilename().AsCString(), @@ -328,7 +328,7 @@ PlatformDarwin::GetSharedModuleWithLocalCache (const lldb_private::ModuleSpec &m { Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM)); if (log) - log->Printf("[%s] module %s/%s was rsynced and is now there\n", + log->Printf("[%s] module %s/%s was rsynced and is now there", (IsHost() ? "host" : "remote"), module_spec.GetFileSpec().GetDirectory().AsCString(), module_spec.GetFileSpec().GetFilename().AsCString()); @@ -361,7 +361,7 @@ PlatformDarwin::GetSharedModuleWithLocalCache (const lldb_private::ModuleSpec &m // bring in the remote file Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM)); if (log) - log->Printf("[%s] module %s/%s needs to be replaced from remote copy\n", + log->Printf("[%s] module %s/%s needs to be replaced from remote copy", (IsHost() ? "host" : "remote"), module_spec.GetFileSpec().GetDirectory().AsCString(), module_spec.GetFileSpec().GetFilename().AsCString()); @@ -376,7 +376,7 @@ PlatformDarwin::GetSharedModuleWithLocalCache (const lldb_private::ModuleSpec &m module_sp->SetPlatformFileSpec(module_spec.GetFileSpec()); Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM)); if (log) - log->Printf("[%s] module %s/%s was found in the cache\n", + log->Printf("[%s] module %s/%s was found in the cache", (IsHost() ? "host" : "remote"), module_spec.GetFileSpec().GetDirectory().AsCString(), module_spec.GetFileSpec().GetFilename().AsCString()); @@ -385,7 +385,7 @@ PlatformDarwin::GetSharedModuleWithLocalCache (const lldb_private::ModuleSpec &m // bring in the remote module file if (log) - log->Printf("[%s] module %s/%s needs to come in remotely\n", + log->Printf("[%s] module %s/%s needs to come in remotely", (IsHost() ? "host" : "remote"), module_spec.GetFileSpec().GetDirectory().AsCString(), module_spec.GetFileSpec().GetFilename().AsCString()); @@ -396,7 +396,7 @@ PlatformDarwin::GetSharedModuleWithLocalCache (const lldb_private::ModuleSpec &m { Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM)); if (log) - log->Printf("[%s] module %s/%s is now cached and fine\n", + log->Printf("[%s] module %s/%s is now cached and fine", (IsHost() ? "host" : "remote"), module_spec.GetFileSpec().GetDirectory().AsCString(), module_spec.GetFileSpec().GetFilename().AsCString()); diff --git a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp index 069ff0c8918..248abaf6fea 100644 --- a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp +++ b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp @@ -199,13 +199,19 @@ PlatformRemoteGDBServer::GetRemoteWorkingDirectory() { if (IsConnected()) { - if (!m_working_dir) + Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM); + std::string cwd; + if (m_gdb_client.GetWorkingDir(cwd)) { - std::string cwd; - if (m_gdb_client.GetWorkingDir(cwd)) - m_working_dir = ConstString(cwd.c_str()); + ConstString working_dir(cwd.c_str()); + if (log) + log->Printf("PlatformRemoteGDBServer::GetRemoteWorkingDirectory() -> '%s'", working_dir.GetCString()); + return working_dir; + } + else + { + return ConstString(); } - return m_working_dir; } else { @@ -220,7 +226,9 @@ PlatformRemoteGDBServer::SetRemoteWorkingDirectory(const lldb_private::ConstStri { // Clear the working directory it case it doesn't get set correctly. This will // for use to re-read it - m_working_dir.Clear(); + Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM); + if (log) + log->Printf("PlatformRemoteGDBServer::SetRemoteWorkingDirectory('%s')", path.GetCString()); return m_gdb_client.SetWorkingDir(path.GetCString()) == 0; } else diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp index 9c6501f3894..66f9c0e552a 100644 --- a/lldb/source/Target/Platform.cpp +++ b/lldb/source/Target/Platform.cpp @@ -671,6 +671,9 @@ Platform::SetWorkingDirectory (const ConstString &path) { if (IsHost()) { + Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM); + if (log) + log->Printf("Platform::SetWorkingDirectory('%s')", path.GetCString()); #ifdef _WIN32 // Not implemented on Windows return false; @@ -685,6 +688,7 @@ Platform::SetWorkingDirectory (const ConstString &path) } else { + m_working_dir.Clear(); return SetRemoteWorkingDirectory(path); } } @@ -745,6 +749,16 @@ Platform::GetHostname () return m_name.c_str(); } +bool +Platform::SetRemoteWorkingDirectory(const ConstString &path) +{ + Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM); + if (log) + log->Printf("Platform::SetRemoteWorkingDirectory('%s')", path.GetCString()); + m_working_dir = path; + return true; +} + const char * Platform::GetUserName (uint32_t uid) { |

