Add lldb-gdbserver support for Linux x86_64.
This change brings in lldb-gdbserver (llgs) specifically for Linux x86_64.
(More architectures coming soon).
Not every debugserver option is covered yet. Currently
the lldb-gdbserver command line can start unattached,
start attached to a pid (process-name attach not supported yet),
or accept lldb attaching and launching a process or connecting
by process id.
The history of this large change can be found here:
https://github.com/tfiala/lldb/tree/dev-tfiala-native-protocol-linux-x86_64
Until mid/late April, I was not sharing the work and continued
to rebase it off of head (developed via id tfiala@google.com). I switched over to
user todd.fiala@gmail.com in the middle, and once I went to github, I did
merges rather than rebasing so I could share with others.
llvm-svn: 212069
diff --git a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.cpp b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.cpp
index c079d0f..04a6792 100644
--- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.cpp
+++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.cpp
@@ -57,11 +57,10 @@
DataBufferSP
AuxVector::GetAuxvData()
{
-#if defined(__linux__) || defined(__FreeBSD__)
- if (m_process->GetPluginName() == ProcessElfCore::GetPluginNameStatic())
- return static_cast<ProcessElfCore *>(m_process)->GetAuxvData();
-#endif
- return lldb_private::Host::GetAuxvData(m_process);
+ if (m_process)
+ return m_process->GetAuxvData ();
+ else
+ return DataBufferSP ();
}
void
diff --git a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
index 3c5dcc5..0e203fe 100644
--- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
+++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
@@ -14,6 +14,7 @@
#include "lldb/Core/Error.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
+#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
@@ -28,21 +29,61 @@
static addr_t
ResolveRendezvousAddress(Process *process)
{
+ Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DYNAMIC_LOADER));
addr_t info_location;
addr_t info_addr;
Error error;
+ // Try to get it from our process. This might be a remote process and might
+ // grab it via some remote-specific mechanism.
info_location = process->GetImageInfoAddress();
+ if (log)
+ log->Printf ("%s info_location = 0x%" PRIx64, __FUNCTION__, info_location);
+
+ // If the process fails to return an address, fall back to seeing if the local object file can help us find it.
+ if (info_location == LLDB_INVALID_ADDRESS)
+ {
+ Target *target = process ? &process->GetTarget() : nullptr;
+ if (target)
+ {
+ ObjectFile *obj_file = target->GetExecutableModule()->GetObjectFile();
+ Address addr = obj_file->GetImageInfoAddress(target);
+
+ if (addr.IsValid())
+ {
+ info_location = addr.GetLoadAddress(target);
+ if (log)
+ log->Printf ("%s resolved via direct object file approach to 0x%" PRIx64, __FUNCTION__, info_location);
+ }
+ else
+ {
+ if (log)
+ log->Printf ("%s FAILED - direct object file approach did not yield a valid address", __FUNCTION__);
+ }
+ }
+ }
if (info_location == LLDB_INVALID_ADDRESS)
+ {
+ if (log)
+ log->Printf ("%s FAILED - invalid info address", __FUNCTION__);
return LLDB_INVALID_ADDRESS;
+ }
info_addr = process->ReadPointerFromMemory(info_location, error);
if (error.Fail())
+ {
+ if (log)
+ log->Printf ("%s FAILED - could not read from the info location: %s", __FUNCTION__, error.AsCString ());
return LLDB_INVALID_ADDRESS;
+ }
if (info_addr == 0)
+ {
+ if (log)
+ log->Printf ("%s FAILED - the rendezvous address contained at 0x%" PRIx64 " returned a null value", __FUNCTION__, info_location);
return LLDB_INVALID_ADDRESS;
+ }
return info_addr;
}
@@ -56,6 +97,8 @@
m_added_soentries(),
m_removed_soentries()
{
+ Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DYNAMIC_LOADER));
+
m_thread_info.valid = false;
// Cache a copy of the executable path
@@ -63,13 +106,24 @@
{
Module *exe_mod = m_process->GetTarget().GetExecutableModulePointer();
if (exe_mod)
+ {
exe_mod->GetFileSpec().GetPath(m_exe_path, PATH_MAX);
+ if (log)
+ log->Printf ("DYLDRendezvous::%s exe module executable path set: '%s'", __FUNCTION__, m_exe_path);
+ }
+ else
+ {
+ if (log)
+ log->Printf ("DYLDRendezvous::%s cannot cache exe module path: null executable module pointer", __FUNCTION__);
+ }
}
}
bool
DYLDRendezvous::Resolve()
{
+ Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DYNAMIC_LOADER));
+
const size_t word_size = 4;
Rendezvous info;
size_t address_size;
@@ -79,12 +133,16 @@
address_size = m_process->GetAddressByteSize();
padding = address_size - word_size;
+ if (log)
+ log->Printf ("DYLDRendezvous::%s address size: %zu, padding %zu", __FUNCTION__, address_size, padding);
if (m_rendezvous_addr == LLDB_INVALID_ADDRESS)
cursor = info_addr = ResolveRendezvousAddress(m_process);
else
cursor = info_addr = m_rendezvous_addr;
-
+ if (log)
+ log->Printf ("DYLDRendezvous::%s cursor = 0x%" PRIx64, __FUNCTION__, cursor);
+
if (cursor == LLDB_INVALID_ADDRESS)
return false;