[Lldb-commits] [lldb] r307160 - Fix "process load" on new android targets

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Wed Jul 5 07:54:41 PDT 2017


Author: labath
Date: Wed Jul  5 07:54:41 2017
New Revision: 307160

URL: http://llvm.org/viewvc/llvm-project?rev=307160&view=rev
Log:
Fix "process load" on new android targets

Summary:
On older android targets, we needed a dlopen rename workaround to get
"process load" working. Since API 26 this is not required as the targets
have a proper libdl so with the function names one would expect.

To make this work I've had to remove the const qualifier from the
GetLibdlFunctionDeclarations function (as now the declarations can
depend on the connected target). Since I was already modifying the
prototype (and the lower levels were already converted to StringRef) I
took the oportunity to convert this function as well.

Modified:
    lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp
    lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.h
    lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
    lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.h

Modified: lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp?rev=307160&r1=307159&r2=307160&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp Wed Jul  5 07:54:41 2017
@@ -366,13 +366,17 @@ bool PlatformAndroid::GetRemoteOSVersion
   return m_major_os_version != 0;
 }
 
-const char *PlatformAndroid::GetLibdlFunctionDeclarations() const {
-  return R"(
+llvm::StringRef PlatformAndroid::GetLibdlFunctionDeclarations() {
+  // Older platform versions have the dl function symbols mangled
+  if (GetSdkVersion() < 26)
+    return R"(
               extern "C" void* dlopen(const char*, int) asm("__dl_dlopen");
               extern "C" void* dlsym(void*, const char*) asm("__dl_dlsym");
               extern "C" int   dlclose(void*) asm("__dl_dlclose");
               extern "C" char* dlerror(void) asm("__dl_dlerror");
              )";
+
+  return PlatformPOSIX::GetLibdlFunctionDeclarations();
 }
 
 AdbClient::SyncService *PlatformAndroid::GetSyncService(Status &error) {

Modified: lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.h?rev=307160&r1=307159&r2=307160&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.h (original)
+++ lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.h Wed Jul  5 07:54:41 2017
@@ -76,7 +76,7 @@ protected:
   Status DownloadSymbolFile(const lldb::ModuleSP &module_sp,
                             const FileSpec &dst_file_spec) override;
 
-  const char *GetLibdlFunctionDeclarations() const override;
+  llvm::StringRef GetLibdlFunctionDeclarations() override;
 
 private:
   AdbClient::SyncService *GetSyncService(Status &error);

Modified: lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp?rev=307160&r1=307159&r2=307160&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp Wed Jul  5 07:54:41 2017
@@ -884,7 +884,7 @@ void PlatformPOSIX::CalculateTrapHandler
 
 Status PlatformPOSIX::EvaluateLibdlExpression(
     lldb_private::Process *process, const char *expr_cstr,
-    const char *expr_prefix, lldb::ValueObjectSP &result_valobj_sp) {
+    llvm::StringRef expr_prefix, lldb::ValueObjectSP &result_valobj_sp) {
   DynamicLoader *loader = process->GetDynamicLoader();
   if (loader) {
     Status error = loader->CanLoadImage();
@@ -944,7 +944,7 @@ uint32_t PlatformPOSIX::DoLoadImage(lldb
                    the_result;
                   )",
               path);
-  const char *prefix = GetLibdlFunctionDeclarations();
+  llvm::StringRef prefix = GetLibdlFunctionDeclarations();
   lldb::ValueObjectSP result_valobj_sp;
   error = EvaluateLibdlExpression(process, expr.GetData(), prefix,
                                   result_valobj_sp);
@@ -992,7 +992,7 @@ Status PlatformPOSIX::UnloadImage(lldb_p
 
   StreamString expr;
   expr.Printf("dlclose((void *)0x%" PRIx64 ")", image_addr);
-  const char *prefix = GetLibdlFunctionDeclarations();
+  llvm::StringRef prefix = GetLibdlFunctionDeclarations();
   lldb::ValueObjectSP result_valobj_sp;
   Status error = EvaluateLibdlExpression(process, expr.GetData(), prefix,
                                          result_valobj_sp);
@@ -1024,7 +1024,7 @@ lldb::ProcessSP PlatformPOSIX::ConnectPr
                                   error);
 }
 
-const char *PlatformPOSIX::GetLibdlFunctionDeclarations() const {
+llvm::StringRef PlatformPOSIX::GetLibdlFunctionDeclarations() {
   return R"(
               extern "C" void* dlopen(const char*, int);
               extern "C" void* dlsym(void*, const char*);

Modified: lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.h?rev=307160&r1=307159&r2=307160&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.h (original)
+++ lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.h Wed Jul  5 07:54:41 2017
@@ -198,10 +198,10 @@ protected:
 
   lldb_private::Status
   EvaluateLibdlExpression(lldb_private::Process *process, const char *expr_cstr,
-                          const char *expr_prefix,
+                          llvm::StringRef expr_prefix,
                           lldb::ValueObjectSP &result_valobj_sp);
 
-  virtual const char *GetLibdlFunctionDeclarations() const;
+  virtual llvm::StringRef GetLibdlFunctionDeclarations();
 
 private:
   DISALLOW_COPY_AND_ASSIGN(PlatformPOSIX);




More information about the lldb-commits mailing list