0

I'm getting started with LLDB and am following the tutorial here: https://lldb.llvm.org/python_reference/lldb.SBDebugger-class.html. Whenever I Launch a target the process gets stuck in the launching state and will never launch. I've tried lldb in bash and it works perfectly. I've read through the documentation with the tutorial and can't find an explanation about the launching state, or how to discover what is causing it to get stuck.

System is Ubuntu 18.04 64 bit dual core 8GB RAM using python2.7.

The most simple code to reproduce the error is as follows:

import lldb
import os

exe = './a.out'
db = lldb.SBDebugger.Create()
db.SetAsync(False)
target = db.CreateTargetWithFileAndArch(exe, 'x86_64-linux-gnu')
pro = target.LaunchSimple(None,None,os.getcwd())
print(pro)

Running the python code will always give me the following output:

SBProcess: pid = 0, state = launching, threads = 0, executable = a.out

The a.out is just a heloworld.cpp compiled with clang++ -fstandalone-debug

UPDATE: Thanks to Jim's suggestion I tried SBTarget.Launch() instead and used the error to discover that lldb could not find lldb-server-6.0.0 because it installs as lldb-server-6.0

The Fix

sudo ln -s /usr/bin/lldb-server6.0 /usr/bin/lldb-server6.0.0

KFH
  • 1
  • 1
  • There was a bug in CreateTargetWithFileAndArch (fixed late Jan. 2021) that caused it not to create a valid target. Can you check `target.IsValid()` in your script above. If that returns False, you either have to get a newer lldb, or use one of the other API's to make a target. You actually only need to specify an architecture if you are on a system that supports multi-architecture binaries, which I don't think Ubuntu does. Otherwise the plain SBDebugger.CreateTarget that just takes the file name is all you need. – Jim Ingham Jun 30 '21 at 01:30
  • If your target is valid, then try using the SBTarget.Launch API, that takes an input SBError parameter, which you can print to see a hopefully useful error. – Jim Ingham Jun 30 '21 at 01:30
  • I checked target.IsValid() and it was True. I did not realize how an error would be handled, when I used Launch() instead of LaunchSimple() the error told me it could not find lldb-server-6.0.0. I checked and the file I had was lldb-server-6.0. what a day. The fix for this was to run "sudo ln -s /usr/bin/lldb-server6.0 /usr/bin/lldb-server6.0.0 – KFH Jun 30 '21 at 15:53
  • I don't know who is making up the lldb package for Ubuntu, but you might want to report this to them. Sounds like that package is broken. – Jim Ingham Jun 30 '21 at 17:10

1 Answers1

0

I found a solution in https://github.com/lldb-tools/lldb-mi/issues/66

I solve this problem by setting:

export LLDB_DEBUGSERVER_PATH=/usr/bin/lldb-server-16.0.6

Vanish丶
  • 1
  • 1