LLDB hang at ::read() function

When I use lldb to debug llvm code, it always hang at this place (sys::RetryAfterSignal(-1, ::read, FD, Buf.data(), Size);).

Anyone meet similar issue before?

Expected<size_t> readNativeFile(file_t FD, MutableArrayRef<char> Buf) {
#if defined(__APPLE__)
  size_t Size = std::min<size_t>(Buf.size(), INT32_MAX);
#else
  size_t Size = Buf.size();
#endif
  ssize_t NumRead =
      sys::RetryAfterSignal(-1, ::read, FD, Buf.data(), Size);
  if (ssize_t(NumRead) == -1)
    return errorCodeToError(std::error_code(errno, std::generic_category()));
  return NumRead;
}

template <typename FailT, typename Fun, typename... Args>
inline decltype(auto) RetryAfterSignal(const FailT &Fail, const Fun &F,
                                       const Args &... As) {
  decltype(F(As...)) Res;
  do {
    errno = 0;
    Res = F(As...);
  } while (Res == Fail && errno == EINTR);
  return Res;
}

The lldb configruations is like below:

{
    "configurations": [
        {
            "type": "lldb",
            "request": "launch",
            "name": "Launch",
            "program": "${workspaceFolder}/build_bpf_debug/bin/llc",
            "args": ["-mtriple=bpf -debug-only=isel < /data/test/test.ll"],
            "cwd": "${workspaceFolder}",
            "stopOnEntry": true
        },
    ]
}

After further debugging, it is hang at syscall. Permission issue?

Some questions:

  1. What OS and core are you running on?

  2. What version of LLDB are you using?

  3. What LLDB plugin are you using with vscode?

  1. What OS and core are you running on?

    Ubuntu 20.04, 12th Gen Intel(R) Core™ i7-12700

  2. What version of LLDB are you using?

    LLDB15 debugging version which is build by myself.

  3. What LLDB plugin are you using with vscode?

    CodeLLDB

Thanks for the info, this is useful but now I’m going to ask for more :slight_smile:

Can you tell us how you are debugging? Are you continuing to a breakpoint or stepping, that sort of thing.

Does it reproduce with the latest build of lldb?

Does it reproduce if you debug from the command line?

If we can unpick the templates llvm is using perhaps we can make a small reproducer program for it.

It happens lldb configuration issue:

it should be one pair of " instead of only one, like below.

"args": ["-mtriple=bpf",  "/data/test/test.ll"],

Instead of only have one pair " in total.

"args": ["-mtriple=bpf -debug-only=isel < /data/test/test.ll"],

The file name will become ‘-’ if use above configuration, that’s why the read function do not return from syscall again.