Crafter.Debug/implementations/main.cpp
Jorijn van der Graaf 5d34df7afb
fix(cli): print lldb by its path, and report a held app as held
Tried on the example with the app's sandbox, two things were wrong:
- `debugger` printed `flatpak enter <id> lldb -p <pid>`, and flatpak
  enter runs a command without the sandbox's PATH, which /app/bin is
  on: "Failed to execute child process lldb". It now prints the path
  it found, /app/bin/lldb, which attached, listed threads and detached.
- With the app held by that debugger, the handshake times out, and
  the client said "cannot reach basic on port ..." and exited 3, no
  instance, though its lock said it lived. It now says the app is
  alive but not answering, stopped in a debugger or hung, prints how
  to attach, check and end it, and exits 5.

Environment::haveLldb becomes lldb, the path or empty. ShouldServeOverQuic
covers the second with an instance whose lock is held and whose port
is silent.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 03:21:41 +01:00

35 lines
1.2 KiB
C++

// SPDX-License-Identifier: LGPL-3.0-only
// SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts®
// crafter-debug: Cli::Run with the QUIC transport.
import std;
import Crafter.Thread;
import Crafter.Debug.Core;
import Crafter.Debug.Cli;
using namespace Crafter::Debug;
int main(int argc, char** argv) {
// Crafter.Network reports some failures through the pool. One request
// at a time needs one worker.
Crafter::ThreadPool::Start(2);
const std::vector<std::string_view> args(argv + 1, argv + argc);
std::int32_t code = 0;
{
Cli::Environment environment;
environment.connect = Cli::ConnectQuic;
environment.lldb = [] {
for (const char* path : { "/app/bin/lldb", "/usr/bin/lldb" }) {
if (std::filesystem::exists(path)) return std::string(path);
}
return std::string();
};
// Run closes its connections before it returns.
code = Cli::Run(args, environment);
}
std::cout.flush();
std::cerr.flush();
std::fflush(nullptr);
// Not through exit: msquic's teardown at exit waits for connections,
// and the pool's workers would need stopping first.
std::_Exit(code);
}