[Lldb-commits] [lldb] [lldb-dap] Add process picker command to VS Code extension (PR #128943)

John Harrison via lldb-commits lldb-commits at lists.llvm.org
Fri Feb 28 10:35:05 PST 2025


================
@@ -0,0 +1,102 @@
+import { ChildProcessWithoutNullStreams } from "child_process";
+import { Process, ProcessTree } from ".";
+import { Transform } from "stream";
+
+/** Parses process information from a given line of process output. */
+export type ProcessTreeParser = (line: string) => Process | undefined;
+
+/**
+ * Implements common behavior between the different {@link ProcessTree} implementations.
+ */
+export abstract class BaseProcessTree implements ProcessTree {
+  /**
+   * Spawn the process responsible for collecting all processes on the system.
+   */
+  protected abstract spawnProcess(): ChildProcessWithoutNullStreams;
----------------
ashgti wrote:

It may be easer to use the `exec`/`execFile`. If you use the promise form of the `exec`/`execFile` call you get the output as a single chunk which simplifies processing.

You could use something like:
```
const exec = util.promisify(child_process.execFile); // this can go at the top of the file
const { stdout } = await exec("ps", [...]);
for (const line of stdout.split('\n')) {
  /* process lines */
}
```

https://github.com/llvm/llvm-project/pull/128943


More information about the lldb-commits mailing list