[Bug 36540] New: "error: this file does not represent a loadable dylib" when loading libsosplugin.so plugin from Python

Bug ID 36540
Summary “error: this file does not represent a loadable dylib” when loading libsosplugin.so plugin from Python
Product lldb
Version 4.0
Hardware PC
OS Windows NT
Status NEW
Severity enhancement
Priority P
Component All Bugs
Assignee lldb-dev@lists.llvm.org
Reporter evgeny@loop54.com
CC llvm-bugs@lists.llvm.org

I'm trying to run the following Python script on Ubuntu 16.04.4 x64:

import lldb
import sys

pid = int(sys.argv[1])
print("Attaching to process %d using %s" % (pid,
lldb.SBDebugger.GetVersionString()))

debugger = lldb.SBDebugger.Create()
target = debugger.CreateTarget('')

error = lldb.SBError()
process = target.AttachToProcessWithID(debugger.GetListener(), pid, error)
if not error.Success():
        raise Exception("Failed to attach")

sos_path = "/opt/dotnet/shared/Microsoft.NETCore.App/2.0.5/libsosplugin.so"
debugger.HandleCommand("plugin load %s" % sos_path)

It gives an error:

$ python loadsostest.py 2036
Attaching to process 2036 using lldb version 4.0.0
error: this file does not represent a loadable dylib

However, I can load the same plugin successfully from the command line:

lldb-4.0 -o "plugin load
/opt/dotnet/shared/Microsoft.NETCore.App/2.0.5/libsosplugin.so" -p 2036

(lldb) process attach --pid 2036
Process 2036 stopped
...
Executable module set to "/opt/dotnet/dotnet".
Architecture set to: x86_64-pc-linux.
(lldb) plugin load
/opt/dotnet/shared/Microsoft.NETCore.App/2.0.5/libsosplugin.so
LLDB version: 'lldb version 4.0.0'(lldb)