[llvm-branch-commits] [lldb] r228081 - Merging r228057:
Hans Wennborg
hans at hanshq.net
Tue Feb 3 16:09:02 PST 2015
Author: hans
Date: Tue Feb 3 18:09:02 2015
New Revision: 228081
URL: http://llvm.org/viewvc/llvm-project?rev=228081&view=rev
Log:
Merging r228057:
------------------------------------------------------------------------
r228057 | sas | 2015-02-03 14:48:34 -0800 (Tue, 03 Feb 2015) | 25 lines
Use basename of main executable in POSIX-DYLD on Android.
Summary:
The Android dynamic linker reports only the basename of each SO entry, so for
the above check to be successful, we need to compare it to the basename of the
main executable.
This also has a nasty side-effect when working with older version of
Android (verified on platform version 16), and debugging PIE
executables: the dynamic linker has a bug and reports the load address
of the main executable (which is a shared object, because PIE) to be 0.
We then try to update the list of loaded sections for all shared
objects, including the main executable, and set the load address to 0,
which breaks everything that relies on resolving addresses in the main
executable (breakpoints, stepping, etc). This commit also fixes that broken
behavior when debugging on older Androids. This bug doesn't happen on newer
Android versions (verified for Android L).
Test Plan: Run test suite on linux.
Reviewers: clayborg, tfiala, richard.mitton
Subscribers: lldb-commits
Differential Revision: http://reviews.llvm.org/D7188
------------------------------------------------------------------------
Modified:
lldb/branches/release_36/ (props changed)
lldb/branches/release_36/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
lldb/branches/release_36/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h
Propchange: lldb/branches/release_36/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Feb 3 18:09:02 2015
@@ -1,2 +1,3 @@
/lldb/branches/apple/python-GIL:156467-162159
/lldb/branches/iohandler:198360-200250
+/lldb/trunk:228057
Modified: lldb/branches/release_36/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/release_36/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp?rev=228081&r1=228080&r2=228081&view=diff
==============================================================================
--- lldb/branches/release_36/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp (original)
+++ lldb/branches/release_36/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp Tue Feb 3 18:09:02 2015
@@ -19,6 +19,8 @@
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
+#include "llvm/Support/Path.h"
+
#include "DYLDRendezvous.h"
using namespace lldb;
@@ -238,9 +240,7 @@ DYLDRendezvous::UpdateSOEntriesForAdditi
return false;
// Only add shared libraries and not the executable.
- // On Linux this is indicated by an empty path in the entry.
- // On FreeBSD it is the name of the executable.
- if (entry.path.empty() || ::strcmp(entry.path.c_str(), m_exe_path) == 0)
+ if (SOEntryIsMainExecutable(entry))
continue;
pos = std::find(m_soentries.begin(), m_soentries.end(), entry);
@@ -277,6 +277,28 @@ DYLDRendezvous::UpdateSOEntriesForDeleti
}
bool
+DYLDRendezvous::SOEntryIsMainExecutable(const SOEntry &entry)
+{
+ // On Linux the executable is indicated by an empty path in the entry. On
+ // FreeBSD it is the full path to the executable. On Android, it is the
+ // basename of the executable.
+
+ auto triple = m_process->GetTarget().GetArchitecture().GetTriple();
+ auto os_type = triple.getOS();
+ auto env_type = triple.getEnvironment();
+
+ switch (os_type) {
+ case llvm::Triple::FreeBSD:
+ return ::strcmp(entry.path.c_str(), m_exe_path) == 0;
+ case llvm::Triple::Linux:
+ return entry.path.empty() || (env_type == llvm::Triple::Android &&
+ llvm::sys::path::filename(m_exe_path) == entry.path);
+ default:
+ return false;
+ }
+}
+
+bool
DYLDRendezvous::TakeSnapshot(SOEntryList &entry_list)
{
SOEntry entry;
@@ -290,9 +312,7 @@ DYLDRendezvous::TakeSnapshot(SOEntryList
return false;
// Only add shared libraries and not the executable.
- // On Linux this is indicated by an empty path in the entry.
- // On FreeBSD it is the name of the executable.
- if (entry.path.empty() || ::strcmp(entry.path.c_str(), m_exe_path) == 0)
+ if (SOEntryIsMainExecutable(entry))
continue;
entry_list.push_back(entry);
Modified: lldb/branches/release_36/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/release_36/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h?rev=228081&r1=228080&r2=228081&view=diff
==============================================================================
--- lldb/branches/release_36/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h (original)
+++ lldb/branches/release_36/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h Tue Feb 3 18:09:02 2015
@@ -247,6 +247,9 @@ protected:
bool
UpdateSOEntriesForDeletion();
+ bool
+ SOEntryIsMainExecutable(const SOEntry &entry);
+
/// Reads the current list of shared objects according to the link map
/// supplied by the runtime linker.
bool
More information about the llvm-branch-commits
mailing list