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.

llvm-svn: 307160
This commit is contained in:
Pavel Labath 2017-07-05 14:54:41 +00:00
parent a6cfce6863
commit d37c946991
4 changed files with 13 additions and 9 deletions

View File

@ -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) {

View File

@ -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);

View File

@ -884,7 +884,7 @@ void PlatformPOSIX::CalculateTrapHandlerSymbolNames() {
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_private::Process *process,
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_private::Process *process,
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::ConnectProcess(llvm::StringRef connect_url,
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*);

View File

@ -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);