[Lldb-commits] [PATCH] D155037: Improve error messaging when debugserver fails to complete attaching to another process on Darwin systems

Jonas Devlieghere via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Jul 11 22:34:38 PDT 2023


JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

LGTM modulo code duplication.



================
Comment at: lldb/tools/debugserver/source/RNBRemote.cpp:3639-3644
+  struct proc_bsdshortinfo proc;
+  int ppid = 0;
+  if (proc_pidinfo(pid, PROC_PIDT_SHORTBSDINFO, 0, &proc,
+                   PROC_PIDT_SHORTBSDINFO_SIZE) == sizeof(proc)) {
+    ppid = proc.pbsi_ppid;
+  }
----------------
As this is the exact same code as in `MachProcess.mm`, is this worth factoring out? Something like 

```
std::optional<int> GetAttachedProcPID() {
  struct proc_bsdshortinfo proc;
  if (proc_pidinfo(pid, PROC_PIDT_SHORTBSDINFO, 0, &proc,
                   PROC_PIDT_SHORTBSDINFO_SIZE) == sizeof(proc)) {
    return proc.pbsi_ppid;
  }
  return std::null opt;
}
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D155037/new/

https://reviews.llvm.org/D155037



More information about the lldb-commits mailing list