<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - lldb cannot connect to debugserver using python API"
href="https://bugs.llvm.org/show_bug.cgi?id=50269">50269</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>lldb cannot connect to debugserver using python API
</td>
</tr>
<tr>
<th>Product</th>
<td>lldb
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>Macintosh
</td>
</tr>
<tr>
<th>OS</th>
<td>MacOS X
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>All Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>lldb-dev@lists.llvm.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>nisargjhaveri@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>jdevlieghere@apple.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>The following set of commands work fine and in the lldb cli, the same set of
commands fails with `error: the platform is not currently connected` when run
from python using the `debugger.GetCommandInterpreter().HandleCommand`
lldb CLI (works):
```
(lldb) platform select remote-macosx
(lldb) target create ~/Projects/vscode-lldb/build/debuggee/debuggee
(lldb) process connect connect://127.0.0.1:1234
(lldb) process launch
Process 64302 launched:
'/Users/nisarg/Projects/vscode-lldb/build/debuggee/debuggee' (x86_64)
...
```
Python (error: the platform is not currently connected):
-------
<span class="quote">>>> import sys; sys.path.append('/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Resources/Python3')
>>> from lldb import *
>>> debugger = SBDebugger.Create()
>>> inter = debugger.GetCommandInterpreter()
>>> res = SBCommandReturnObject()
>>> commands = ['platform select remote-macosx', >'target create /Users/nisarg/Projects/vscode-lldb/build/debuggee/debuggee', 'process connect connect://127.0.0.1:1234', 'process launch']
>>> for command in commands: inter.HandleCommand(command, res); print(command); print(res.Succeeded()); print(res.GetOutput(), "\n", res.GetError())</span >
...
2
platform select remote-macosx
True
Platform: remote-macosx
Connected: no
1
target create /Users/nisarg/Projects/vscode-lldb/build/debuggee/debuggee
True
Current executable set to
'/Users/nisarg/Projects/vscode-lldb/build/debuggee/debuggee' (x86_64).
1
process connect connect://127.0.0.1:1234
True
There is a running process, kill it and restart?: [Y/n] y
6
process launch
False
error: the platform is not currently connected
-------
I'm starting the debugserver using the following command in both the case.
```
$ debugserver 127.0.0.1:1234
```
I'm using the lldb bundled with Xcode 12.4.
Expected behavior: the same set of commands should result in the same outcome
whether run in cli or via python api.
I tried directly using python apis to connect and launch the process, but
couldn't figure out that either. It was giving the same error as platform not
connected. Also after connecting, the process status becomes unloaded and not
connected.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>