<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/63468>63468</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            lldb-server fails to find gdbremote stub when started via a absolute path to a link
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          Maddimax
      </td>
    </tr>
</table>

<pre>
    If I start:

```/usr/bin/lldb-server platform --listen '*:10000' --server```

then I get `Launch: invalid host:port specification: '[192.168.64.5]'`
but if I start:

```lldb-server platform --listen '*:10000' --server```

then everything works and I can debug without any problems.

```
$ which lldb-server
/usr/bin/lldb-server
```

In lldb I run:
`command script import test.py`
[test.py](https://github.com/llvm/llvm-project/files/11833541/test.txt)

---
We found the reason here: https://github.com/llvm/llvm-project/issues/61955#issuecomment-1603786142

The code that is looking for the "support exe dir" is finding the wrong dir, see these two runs with logging enabled:

```
...
distribution id command returned "Distributor ID:  Ubuntu
"
distribution id set to "ubuntu"
GDBRemoteCommunication::StartDebugserverProcess(url=tcp://[192.168.64.1]:0, port=0)
shlib dir -> `/usr/bin/`
HostInfo::ComputePathRelativeToLibrary() attempting to derive the path /bin relative to liblldb install path: /usr/bin
HostInfo::ComputePathRelativeToLibrary() derived the path as: /usr/bin
support exe dir -> `/usr/bin/`
GDBRemoteCommunication::StartDebugserverProcess() could not find gdb-remote stub exe ''
GDBRemoteCommunication::StartDebugserverProcess() failed: unable to locate lldb-server-15.0.7
error: lost connection
lldb-server exiting...
```
vs.
```
distribution id set to "ubuntu"
GDBRemoteCommunication::StartDebugserverProcess(url=tcp://[192.168.64.1]:0, port=0)
shlib dir -> `/usr/lib/llvm-15/bin/`
HostInfo::ComputePathRelativeToLibrary() attempting to derive the path /bin relative to liblldb install path: /usr/lib/llvm-15/bin
HostInfo::ComputePathRelativeToLibrary() derived the path as: /usr/lib/llvm-15/bin
support exe dir -> `/usr/lib/llvm-15/bin/`
GDBRemoteCommunication::StartDebugserverProcess() found gdb-remote stub exe '/usr/lib/llvm-15/bin/lldb-server-15.0.7'
launch info for gdb-remote stub:
Executable: lldb-server-15.0.7
Triple: *-*-*
Arguments:
argv[0]="/usr/lib/llvm-15/bin/lldb-server-15.0.7"
argv[1]="gdbserver"
argv[2]="tcp://[192.168.64.1]:0"
argv[3]="--native-regs"
argv[4]="--pipe"
argv[5]="6"
argv[6]=NULL
```

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzUV9GP4rYT_mvMyygocUgIDzywx_H7IW2r0_VOfXaSIXHP2JE9ht3_vrIDLEfZbu-ulVppl91kxjOfZ75vbIRzstOIS1Y8sGI9EZ56Y5c_ibaVe_E0qU37vNzuYAuOhCWWr1i6Zun5s0xPP3zjnWV8U0vN-Eaptk4c2gNaGJSgnbF7SBIlHaEGxueMr1i-ytI0TRmfQ3Jyfol3lYR61LCFDglYmT4Kr5ue5SuQ-iCUbKE3LuAajCVwAzZyJxtB0ujgFHIVD9mCT7OympazacGKdXh5zlF7Avnm_v7-DeEB7TP1UndwNPaLA6Fb2EIjNLRY-w6OknrjCYR-hsGaWuHeTe8Xf3zkMzj2sunhCuzZ9Fp37keKn1sdA8EWrNcvdSnTxuz3AaxrrBwI5D5WntDRdHh-CVI8nF-Fglc90eBCGL5hfNNJ6n09bcw-4jmc_ySDNb9hQ4xvdlKhY3yTZVWeF7OM8U0MSE_E-OIaaZIk4z-_IuyM1y1Qj2BROKOhR4uBCN-cXzrnI4AyWxQF43l8ETaPmpKsTPN5VWYzfo3kU4_QmBaBekEgHShjvoQW74yNoBjnzg-xYPiE0ErLOA-OO6nb4BicjtbobrS9A4chGjoEOprQCheZAcp0XViAWtQK21eFGR-n0xNzWunIytoHeYBs4dxLi-StxjYAXJ99jIXtOgZefK69Jn9mE78fzCEBmRDCj-5nx_-tHz7i3hC-M_u91y_yZPnqlyC7dWD8yMgP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