forked from OSchip/llvm-project
[LLDB][MIPS] Fix process load/unload on android.
To detect the correct function name based on the list of available symbols instead of the SDK version Reviewers: tberghammer, clayborg Subscribers: jaydeep, bhushan, lldb-commits Differential Revision: https://reviews.llvm.org/D36445 llvm-svn: 310856
This commit is contained in:
parent
8ac63e8f9f
commit
f7a5851d42
|
@ -21,6 +21,7 @@
|
|||
#include "AdbClient.h"
|
||||
#include "PlatformAndroid.h"
|
||||
#include "PlatformAndroidRemoteGDBServer.h"
|
||||
#include "lldb/Target/Target.h"
|
||||
|
||||
using namespace lldb;
|
||||
using namespace lldb_private;
|
||||
|
@ -366,9 +367,22 @@ bool PlatformAndroid::GetRemoteOSVersion() {
|
|||
return m_major_os_version != 0;
|
||||
}
|
||||
|
||||
llvm::StringRef PlatformAndroid::GetLibdlFunctionDeclarations() {
|
||||
llvm::StringRef
|
||||
PlatformAndroid::GetLibdlFunctionDeclarations(lldb_private::Process *process) {
|
||||
SymbolContextList matching_symbols;
|
||||
std::vector<const char *> dl_open_names = { "__dl_dlopen", "dlopen" };
|
||||
const char *dl_open_name = nullptr;
|
||||
Target &target = process->GetTarget();
|
||||
for (auto name: dl_open_names) {
|
||||
if (target.GetImages().FindFunctionSymbols(ConstString(name),
|
||||
eFunctionNameTypeFull,
|
||||
matching_symbols)) {
|
||||
dl_open_name = name;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Older platform versions have the dl function symbols mangled
|
||||
if (GetSdkVersion() < 26)
|
||||
if (dl_open_name == dl_open_names[0])
|
||||
return R"(
|
||||
extern "C" void* dlopen(const char*, int) asm("__dl_dlopen");
|
||||
extern "C" void* dlsym(void*, const char*) asm("__dl_dlsym");
|
||||
|
@ -376,7 +390,7 @@ llvm::StringRef PlatformAndroid::GetLibdlFunctionDeclarations() {
|
|||
extern "C" char* dlerror(void) asm("__dl_dlerror");
|
||||
)";
|
||||
|
||||
return PlatformPOSIX::GetLibdlFunctionDeclarations();
|
||||
return PlatformPOSIX::GetLibdlFunctionDeclarations(process);
|
||||
}
|
||||
|
||||
AdbClient::SyncService *PlatformAndroid::GetSyncService(Status &error) {
|
||||
|
|
|
@ -76,7 +76,8 @@ protected:
|
|||
Status DownloadSymbolFile(const lldb::ModuleSP &module_sp,
|
||||
const FileSpec &dst_file_spec) override;
|
||||
|
||||
llvm::StringRef GetLibdlFunctionDeclarations() override;
|
||||
llvm::StringRef
|
||||
GetLibdlFunctionDeclarations(lldb_private::Process *process) override;
|
||||
|
||||
private:
|
||||
AdbClient::SyncService *GetSyncService(Status &error);
|
||||
|
|
|
@ -944,7 +944,7 @@ uint32_t PlatformPOSIX::DoLoadImage(lldb_private::Process *process,
|
|||
the_result;
|
||||
)",
|
||||
path);
|
||||
llvm::StringRef prefix = GetLibdlFunctionDeclarations();
|
||||
llvm::StringRef prefix = GetLibdlFunctionDeclarations(process);
|
||||
lldb::ValueObjectSP result_valobj_sp;
|
||||
error = EvaluateLibdlExpression(process, expr.GetData(), prefix,
|
||||
result_valobj_sp);
|
||||
|
@ -992,7 +992,7 @@ Status PlatformPOSIX::UnloadImage(lldb_private::Process *process,
|
|||
|
||||
StreamString expr;
|
||||
expr.Printf("dlclose((void *)0x%" PRIx64 ")", image_addr);
|
||||
llvm::StringRef prefix = GetLibdlFunctionDeclarations();
|
||||
llvm::StringRef prefix = GetLibdlFunctionDeclarations(process);
|
||||
lldb::ValueObjectSP result_valobj_sp;
|
||||
Status error = EvaluateLibdlExpression(process, expr.GetData(), prefix,
|
||||
result_valobj_sp);
|
||||
|
@ -1024,7 +1024,8 @@ lldb::ProcessSP PlatformPOSIX::ConnectProcess(llvm::StringRef connect_url,
|
|||
error);
|
||||
}
|
||||
|
||||
llvm::StringRef PlatformPOSIX::GetLibdlFunctionDeclarations() {
|
||||
llvm::StringRef
|
||||
PlatformPOSIX::GetLibdlFunctionDeclarations(lldb_private::Process *process) {
|
||||
return R"(
|
||||
extern "C" void* dlopen(const char*, int);
|
||||
extern "C" void* dlsym(void*, const char*);
|
||||
|
|
|
@ -201,7 +201,8 @@ protected:
|
|||
llvm::StringRef expr_prefix,
|
||||
lldb::ValueObjectSP &result_valobj_sp);
|
||||
|
||||
virtual llvm::StringRef GetLibdlFunctionDeclarations();
|
||||
virtual
|
||||
llvm::StringRef GetLibdlFunctionDeclarations(lldb_private::Process *process);
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(PlatformPOSIX);
|
||||
|
|
Loading…
Reference in New Issue