debug-that 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +514 -162
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -299,12 +299,29 @@ class DapClient {
|
|
|
299
299
|
var init_client = () => {};
|
|
300
300
|
|
|
301
301
|
// src/dap/session.ts
|
|
302
|
+
import { existsSync } from "fs";
|
|
303
|
+
import { join } from "path";
|
|
304
|
+
function getManagedAdaptersDir() {
|
|
305
|
+
const home = process.env.HOME ?? process.env.USERPROFILE ?? "/tmp";
|
|
306
|
+
return join(home, ".debug-that", "adapters");
|
|
307
|
+
}
|
|
302
308
|
function resolveAdapterCommand(runtime) {
|
|
303
309
|
switch (runtime) {
|
|
304
310
|
case "lldb":
|
|
305
311
|
case "lldb-dap": {
|
|
312
|
+
const managedPath = join(getManagedAdaptersDir(), "lldb-dap");
|
|
313
|
+
if (existsSync(managedPath)) {
|
|
314
|
+
return [managedPath];
|
|
315
|
+
}
|
|
316
|
+
const whichResult = Bun.spawnSync(["which", "lldb-dap"]);
|
|
317
|
+
if (whichResult.exitCode === 0) {
|
|
318
|
+
return ["lldb-dap"];
|
|
319
|
+
}
|
|
306
320
|
const brewPath = "/opt/homebrew/opt/llvm/bin/lldb-dap";
|
|
307
|
-
|
|
321
|
+
if (existsSync(brewPath)) {
|
|
322
|
+
return [brewPath];
|
|
323
|
+
}
|
|
324
|
+
return ["lldb-dap"];
|
|
308
325
|
}
|
|
309
326
|
case "codelldb":
|
|
310
327
|
return ["codelldb", "--port", "0"];
|
|
@@ -653,8 +670,8 @@ class DapSession {
|
|
|
653
670
|
};
|
|
654
671
|
});
|
|
655
672
|
}
|
|
656
|
-
getStack(
|
|
657
|
-
|
|
673
|
+
getStack(options = {}) {
|
|
674
|
+
const frames = this._stackFrames.map((frame) => {
|
|
658
675
|
const ref = this.refs.addFrame(String(frame.id), frame.name);
|
|
659
676
|
return {
|
|
660
677
|
ref,
|
|
@@ -664,6 +681,11 @@ class DapSession {
|
|
|
664
681
|
column: frame.column > 0 ? frame.column : undefined
|
|
665
682
|
};
|
|
666
683
|
});
|
|
684
|
+
if (options.filter) {
|
|
685
|
+
const filterLower = options.filter.toLowerCase();
|
|
686
|
+
return frames.filter((f) => f.functionName.toLowerCase().includes(filterLower) || f.file.toLowerCase().includes(filterLower));
|
|
687
|
+
}
|
|
688
|
+
return frames;
|
|
667
689
|
}
|
|
668
690
|
async getSource(options = {}) {
|
|
669
691
|
const file = options.file ?? this._pauseInfo?.url;
|
|
@@ -827,12 +849,41 @@ class DapSession {
|
|
|
827
849
|
async restartFrame(_frameRef) {
|
|
828
850
|
throw new Error("Frame restart is not supported in DAP mode.");
|
|
829
851
|
}
|
|
830
|
-
async runTo(
|
|
831
|
-
|
|
852
|
+
async runTo(file, line) {
|
|
853
|
+
this.requireConnected();
|
|
854
|
+
this.requirePaused();
|
|
855
|
+
const tempBp = await this.setBreakpoint(file, line);
|
|
856
|
+
try {
|
|
857
|
+
await this.continue();
|
|
858
|
+
} finally {
|
|
859
|
+
try {
|
|
860
|
+
await this.removeBreakpoint(tempBp.ref);
|
|
861
|
+
} catch {}
|
|
862
|
+
}
|
|
832
863
|
}
|
|
833
864
|
getScripts(_filter) {
|
|
834
865
|
return [];
|
|
835
866
|
}
|
|
867
|
+
async getModules(filter) {
|
|
868
|
+
this.requireConnected();
|
|
869
|
+
if (!this.capabilities.supportsModulesRequest) {
|
|
870
|
+
throw new Error(`This debug adapter does not support the modules request.
|
|
871
|
+
-> The adapter may not report module/symbol information.`);
|
|
872
|
+
}
|
|
873
|
+
const response = await this.getDap().send("modules", { startModule: 0, moduleCount: 0 });
|
|
874
|
+
const body = response.body;
|
|
875
|
+
let modules = body.modules ?? [];
|
|
876
|
+
if (filter) {
|
|
877
|
+
const filterLower = filter.toLowerCase();
|
|
878
|
+
modules = modules.filter((m) => m.name.toLowerCase().includes(filterLower) || (m.path?.toLowerCase().includes(filterLower) ?? false));
|
|
879
|
+
}
|
|
880
|
+
return modules.map((m) => ({
|
|
881
|
+
id: String(m.id),
|
|
882
|
+
name: m.name,
|
|
883
|
+
path: m.path,
|
|
884
|
+
symbolStatus: m.symbolStatus
|
|
885
|
+
}));
|
|
886
|
+
}
|
|
836
887
|
async addBlackbox(_patterns) {
|
|
837
888
|
throw new Error("Blackboxing is not supported in DAP mode.");
|
|
838
889
|
}
|
|
@@ -878,8 +929,8 @@ class DapSession {
|
|
|
878
929
|
async initializeAdapter() {
|
|
879
930
|
const response = await this.getDap().send("initialize", {
|
|
880
931
|
adapterID: this._runtime,
|
|
881
|
-
clientID: "
|
|
882
|
-
clientName: "
|
|
932
|
+
clientID: "debug-that",
|
|
933
|
+
clientName: "debug-that",
|
|
883
934
|
linesStartAt1: true,
|
|
884
935
|
columnsStartAt1: true,
|
|
885
936
|
pathFormat: "path",
|
|
@@ -1060,6 +1111,38 @@ var init_session = __esm(() => {
|
|
|
1060
1111
|
init_client();
|
|
1061
1112
|
});
|
|
1062
1113
|
|
|
1114
|
+
// src/daemon/eval-suggestions.ts
|
|
1115
|
+
function suggestEvalFix(errorMsg) {
|
|
1116
|
+
const lower = errorMsg.toLowerCase();
|
|
1117
|
+
if (lower.includes("invalid use of 'this'") || lower.includes("invalid use of this")) {
|
|
1118
|
+
return `This frame may lack debug symbols. Try: debug-that modules
|
|
1119
|
+
Or try a different frame: debug-that eval <expr> --frame @f1`;
|
|
1120
|
+
}
|
|
1121
|
+
if (lower.includes("no member named") || lower.includes("has no member")) {
|
|
1122
|
+
return "Try: debug-that props <@ref> to list available members";
|
|
1123
|
+
}
|
|
1124
|
+
if (lower.includes("undeclared identifier") || lower.includes("use of undeclared") || lower.includes("is not defined")) {
|
|
1125
|
+
return "Try: debug-that vars to see variables in scope";
|
|
1126
|
+
}
|
|
1127
|
+
if (lower.includes("not paused")) {
|
|
1128
|
+
return "Try: debug-that pause";
|
|
1129
|
+
}
|
|
1130
|
+
if (lower.includes("timed out")) {
|
|
1131
|
+
return `The expression may be blocking. Try: debug-that eval <expr> --timeout 30000
|
|
1132
|
+
Or use --side-effect-free to safely inspect without side effects`;
|
|
1133
|
+
}
|
|
1134
|
+
if (lower.includes("side effect")) {
|
|
1135
|
+
return "Expression has side effects. Remove --side-effect-free flag to allow mutation";
|
|
1136
|
+
}
|
|
1137
|
+
if (lower.includes("syntaxerror") || lower.includes("unexpected token")) {
|
|
1138
|
+
return "Check expression syntax. Wrap multi-line expressions in parentheses";
|
|
1139
|
+
}
|
|
1140
|
+
if (lower.includes("cannot read propert") || lower.includes("undefined is not")) {
|
|
1141
|
+
return "The value may be null/undefined. Try: debug-that vars to inspect available values";
|
|
1142
|
+
}
|
|
1143
|
+
return;
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1063
1146
|
// src/daemon/logger.ts
|
|
1064
1147
|
import { appendFileSync, writeFileSync } from "fs";
|
|
1065
1148
|
|
|
@@ -1096,31 +1179,31 @@ class DaemonLogger {
|
|
|
1096
1179
|
var init_logger = () => {};
|
|
1097
1180
|
|
|
1098
1181
|
// src/daemon/paths.ts
|
|
1099
|
-
import { existsSync, mkdirSync } from "fs";
|
|
1100
|
-
import { join } from "path";
|
|
1182
|
+
import { existsSync as existsSync2, mkdirSync } from "fs";
|
|
1183
|
+
import { join as join2 } from "path";
|
|
1101
1184
|
function getSocketDir() {
|
|
1102
1185
|
const xdgRuntime = process.env.XDG_RUNTIME_DIR;
|
|
1103
1186
|
if (xdgRuntime) {
|
|
1104
|
-
return
|
|
1187
|
+
return join2(xdgRuntime, "debug-that");
|
|
1105
1188
|
}
|
|
1106
1189
|
const tmpdir = process.env.TMPDIR || "/tmp";
|
|
1107
|
-
return
|
|
1190
|
+
return join2(tmpdir, `debug-that-${process.getuid?.() ?? 0}`);
|
|
1108
1191
|
}
|
|
1109
1192
|
function getSocketPath(session) {
|
|
1110
|
-
return
|
|
1193
|
+
return join2(getSocketDir(), `${session}.sock`);
|
|
1111
1194
|
}
|
|
1112
1195
|
function getLockPath(session) {
|
|
1113
|
-
return
|
|
1196
|
+
return join2(getSocketDir(), `${session}.lock`);
|
|
1114
1197
|
}
|
|
1115
1198
|
function getLogPath(session) {
|
|
1116
|
-
return
|
|
1199
|
+
return join2(getSocketDir(), `${session}.cdp.log`);
|
|
1117
1200
|
}
|
|
1118
1201
|
function getDaemonLogPath(session) {
|
|
1119
|
-
return
|
|
1202
|
+
return join2(getSocketDir(), `${session}.daemon.log`);
|
|
1120
1203
|
}
|
|
1121
1204
|
function ensureSocketDir() {
|
|
1122
1205
|
const dir = getSocketDir();
|
|
1123
|
-
if (!
|
|
1206
|
+
if (!existsSync2(dir)) {
|
|
1124
1207
|
mkdirSync(dir, { recursive: true });
|
|
1125
1208
|
}
|
|
1126
1209
|
}
|
|
@@ -7149,7 +7232,7 @@ var init_esm2 = __esm(() => {
|
|
|
7149
7232
|
});
|
|
7150
7233
|
|
|
7151
7234
|
// src/protocol/messages.ts
|
|
7152
|
-
var PingRequest, LaunchRequest, AttachRequest, StatusRequest, StateRequest, ContinueRequest, StepRequest, PauseRequest, RunToRequest, BreakRequest, BreakFnRequest, BreakRmRequest, BreakLsRequest, LogpointRequest, CatchRequest, SourceRequest, ScriptsRequest, StackRequest, SearchRequest, ConsoleRequest, ExceptionsRequest, EvalRequest, VarsRequest, PropsRequest, BlackboxRequest, BlackboxLsRequest, BlackboxRmRequest, SetRequest, SetReturnRequest, HotpatchRequest, BreakToggleRequest, BreakableRequest, RestartFrameRequest, SourcemapRequest, SourcemapDisableRequest, RestartRequest, StopRequest, DaemonRequestSchema, SuccessResponse, ErrorResponse, DaemonResponseSchema;
|
|
7235
|
+
var PingRequest, LaunchRequest, AttachRequest, StatusRequest, StateRequest, ContinueRequest, StepRequest, PauseRequest, RunToRequest, BreakRequest, BreakFnRequest, BreakRmRequest, BreakLsRequest, LogpointRequest, CatchRequest, SourceRequest, ScriptsRequest, StackRequest, SearchRequest, ConsoleRequest, ExceptionsRequest, EvalRequest, VarsRequest, PropsRequest, BlackboxRequest, BlackboxLsRequest, BlackboxRmRequest, SetRequest, SetReturnRequest, HotpatchRequest, BreakToggleRequest, BreakableRequest, RestartFrameRequest, SourcemapRequest, SourcemapDisableRequest, RestartRequest, StopRequest, ModulesRequest, DaemonRequestSchema, SuccessResponse, ErrorResponse, DaemonResponseSchema;
|
|
7153
7236
|
var init_messages = __esm(() => {
|
|
7154
7237
|
init_esm2();
|
|
7155
7238
|
PingRequest = exports_external.object({ cmd: exports_external.literal("ping") });
|
|
@@ -7265,7 +7348,8 @@ var init_messages = __esm(() => {
|
|
|
7265
7348
|
cmd: exports_external.literal("stack"),
|
|
7266
7349
|
args: exports_external.object({
|
|
7267
7350
|
asyncDepth: exports_external.optional(exports_external.number()),
|
|
7268
|
-
generated: exports_external.optional(exports_external.boolean())
|
|
7351
|
+
generated: exports_external.optional(exports_external.boolean()),
|
|
7352
|
+
filter: exports_external.optional(exports_external.string())
|
|
7269
7353
|
})
|
|
7270
7354
|
});
|
|
7271
7355
|
SearchRequest = exports_external.object({
|
|
@@ -7382,6 +7466,12 @@ var init_messages = __esm(() => {
|
|
|
7382
7466
|
SourcemapDisableRequest = exports_external.object({ cmd: exports_external.literal("sourcemap-disable") });
|
|
7383
7467
|
RestartRequest = exports_external.object({ cmd: exports_external.literal("restart") });
|
|
7384
7468
|
StopRequest = exports_external.object({ cmd: exports_external.literal("stop") });
|
|
7469
|
+
ModulesRequest = exports_external.object({
|
|
7470
|
+
cmd: exports_external.literal("modules"),
|
|
7471
|
+
args: exports_external.object({
|
|
7472
|
+
filter: exports_external.optional(exports_external.string())
|
|
7473
|
+
})
|
|
7474
|
+
});
|
|
7385
7475
|
DaemonRequestSchema = exports_external.union([
|
|
7386
7476
|
PingRequest,
|
|
7387
7477
|
LaunchRequest,
|
|
@@ -7419,7 +7509,8 @@ var init_messages = __esm(() => {
|
|
|
7419
7509
|
RestartRequest,
|
|
7420
7510
|
SourcemapRequest,
|
|
7421
7511
|
SourcemapDisableRequest,
|
|
7422
|
-
StopRequest
|
|
7512
|
+
StopRequest,
|
|
7513
|
+
ModulesRequest
|
|
7423
7514
|
]);
|
|
7424
7515
|
SuccessResponse = exports_external.object({
|
|
7425
7516
|
ok: exports_external.literal(true),
|
|
@@ -7434,7 +7525,7 @@ var init_messages = __esm(() => {
|
|
|
7434
7525
|
});
|
|
7435
7526
|
|
|
7436
7527
|
// src/daemon/server.ts
|
|
7437
|
-
import { existsSync as
|
|
7528
|
+
import { existsSync as existsSync3, unlinkSync, writeFileSync as writeFileSync2 } from "fs";
|
|
7438
7529
|
|
|
7439
7530
|
class DaemonServer {
|
|
7440
7531
|
session;
|
|
@@ -7457,14 +7548,14 @@ class DaemonServer {
|
|
|
7457
7548
|
}
|
|
7458
7549
|
async start() {
|
|
7459
7550
|
ensureSocketDir();
|
|
7460
|
-
if (
|
|
7551
|
+
if (existsSync3(this.lockPath)) {
|
|
7461
7552
|
const existingPid = parseInt(await Bun.file(this.lockPath).text(), 10);
|
|
7462
7553
|
if (!Number.isNaN(existingPid) && isProcessRunning(existingPid)) {
|
|
7463
7554
|
throw new Error(`Daemon already running for session "${this.session}" (pid ${existingPid})`);
|
|
7464
7555
|
}
|
|
7465
7556
|
unlinkSync(this.lockPath);
|
|
7466
7557
|
}
|
|
7467
|
-
if (
|
|
7558
|
+
if (existsSync3(this.socketPath)) {
|
|
7468
7559
|
unlinkSync(this.socketPath);
|
|
7469
7560
|
}
|
|
7470
7561
|
writeFileSync2(this.lockPath, String(process.pid));
|
|
@@ -7547,7 +7638,7 @@ class DaemonServer {
|
|
|
7547
7638
|
this.sendResponse(socket, cmd ? {
|
|
7548
7639
|
ok: false,
|
|
7549
7640
|
error: `Unknown command: ${cmd}`,
|
|
7550
|
-
suggestion: "-> Try:
|
|
7641
|
+
suggestion: "-> Try: debug-that --help"
|
|
7551
7642
|
} : {
|
|
7552
7643
|
ok: false,
|
|
7553
7644
|
error: "Invalid request: must have { cmd: string, args: object }"
|
|
@@ -7591,10 +7682,10 @@ class DaemonServer {
|
|
|
7591
7682
|
this.listener.stop(true);
|
|
7592
7683
|
this.listener = null;
|
|
7593
7684
|
}
|
|
7594
|
-
if (
|
|
7685
|
+
if (existsSync3(this.socketPath)) {
|
|
7595
7686
|
unlinkSync(this.socketPath);
|
|
7596
7687
|
}
|
|
7597
|
-
if (
|
|
7688
|
+
if (existsSync3(this.lockPath)) {
|
|
7598
7689
|
unlinkSync(this.lockPath);
|
|
7599
7690
|
}
|
|
7600
7691
|
}
|
|
@@ -9458,7 +9549,7 @@ async function continueExecution(session) {
|
|
|
9458
9549
|
if (!session.cdp) {
|
|
9459
9550
|
throw new Error("Cannot continue: no CDP connection");
|
|
9460
9551
|
}
|
|
9461
|
-
const waiter = session.createPauseWaiter();
|
|
9552
|
+
const waiter = session.createPauseWaiter(CONTINUE_GRACE_MS);
|
|
9462
9553
|
await session.cdp.send("Debugger.resume");
|
|
9463
9554
|
await waiter;
|
|
9464
9555
|
}
|
|
@@ -9479,8 +9570,8 @@ async function stepExecution(session, mode) {
|
|
|
9479
9570
|
await waiter;
|
|
9480
9571
|
}
|
|
9481
9572
|
async function pauseExecution(session) {
|
|
9482
|
-
if (session.
|
|
9483
|
-
throw new Error("Cannot pause: process is
|
|
9573
|
+
if (session.isPaused()) {
|
|
9574
|
+
throw new Error("Cannot pause: process is already paused");
|
|
9484
9575
|
}
|
|
9485
9576
|
if (!session.cdp) {
|
|
9486
9577
|
throw new Error("Cannot pause: no CDP connection");
|
|
@@ -9540,6 +9631,7 @@ async function restartFrameExecution(session, frameRef) {
|
|
|
9540
9631
|
await waiter;
|
|
9541
9632
|
return { status: "restarted" };
|
|
9542
9633
|
}
|
|
9634
|
+
var CONTINUE_GRACE_MS = 500;
|
|
9543
9635
|
var init_session_execution = () => {};
|
|
9544
9636
|
|
|
9545
9637
|
// src/daemon/session-inspection.ts
|
|
@@ -9715,6 +9807,10 @@ async function getProps(session, ref, options = {}) {
|
|
|
9715
9807
|
if (objectId.startsWith("primitive:") || objectId.startsWith("eval:")) {
|
|
9716
9808
|
throw new Error(`Ref ${ref} is a primitive and has no properties`);
|
|
9717
9809
|
}
|
|
9810
|
+
const depth = Math.min(options.depth ?? 1, MAX_DEPTH);
|
|
9811
|
+
return fetchPropsRecursive(session, objectId, options, depth);
|
|
9812
|
+
}
|
|
9813
|
+
async function fetchPropsRecursive(session, objectId, options, remainingDepth) {
|
|
9718
9814
|
const propsParams = {
|
|
9719
9815
|
objectId,
|
|
9720
9816
|
ownProperties: options.own ?? true,
|
|
@@ -9723,7 +9819,10 @@ async function getProps(session, ref, options = {}) {
|
|
|
9723
9819
|
if (options.internal) {
|
|
9724
9820
|
propsParams.accessorPropertiesOnly = false;
|
|
9725
9821
|
}
|
|
9726
|
-
const
|
|
9822
|
+
const cdp = session.cdp;
|
|
9823
|
+
if (!cdp)
|
|
9824
|
+
throw new Error("No active debug session");
|
|
9825
|
+
const propsResult = await session.adapter.getProperties(cdp, propsParams);
|
|
9727
9826
|
const properties = propsResult.result ?? [];
|
|
9728
9827
|
const internalProps = options.internal ? propsResult.internalProperties ?? [] : [];
|
|
9729
9828
|
const result = [];
|
|
@@ -9758,6 +9857,9 @@ async function getProps(session, ref, options = {}) {
|
|
|
9758
9857
|
if (isAccessor) {
|
|
9759
9858
|
item.isAccessor = true;
|
|
9760
9859
|
}
|
|
9860
|
+
if (propValue?.objectId && remainingDepth > 1) {
|
|
9861
|
+
item.children = await fetchPropsRecursive(session, propValue.objectId, options, remainingDepth - 1);
|
|
9862
|
+
}
|
|
9761
9863
|
result.push(item);
|
|
9762
9864
|
}
|
|
9763
9865
|
for (const prop of internalProps) {
|
|
@@ -9777,6 +9879,9 @@ async function getProps(session, ref, options = {}) {
|
|
|
9777
9879
|
if (propRef) {
|
|
9778
9880
|
item.ref = propRef;
|
|
9779
9881
|
}
|
|
9882
|
+
if (propValue.objectId && remainingDepth > 1) {
|
|
9883
|
+
item.children = await fetchPropsRecursive(session, propValue.objectId, options, remainingDepth - 1);
|
|
9884
|
+
}
|
|
9780
9885
|
result.push(item);
|
|
9781
9886
|
}
|
|
9782
9887
|
return result;
|
|
@@ -9945,6 +10050,10 @@ function getStack(session, options = {}) {
|
|
|
9945
10050
|
}
|
|
9946
10051
|
stackFrames.push(stackEntry);
|
|
9947
10052
|
}
|
|
10053
|
+
if (options.filter) {
|
|
10054
|
+
const filterLower = options.filter.toLowerCase();
|
|
10055
|
+
return stackFrames.filter((f) => f.functionName.toLowerCase().includes(filterLower) || f.file.toLowerCase().includes(filterLower));
|
|
10056
|
+
}
|
|
9948
10057
|
return stackFrames;
|
|
9949
10058
|
}
|
|
9950
10059
|
async function searchInScripts(session, query, options = {}) {
|
|
@@ -10011,6 +10120,7 @@ function getExceptions(session, options = {}) {
|
|
|
10011
10120
|
function clearConsole(session) {
|
|
10012
10121
|
session.consoleMessages = [];
|
|
10013
10122
|
}
|
|
10123
|
+
var MAX_DEPTH = 5;
|
|
10014
10124
|
var init_session_inspection = () => {};
|
|
10015
10125
|
|
|
10016
10126
|
// src/daemon/session-mutation.ts
|
|
@@ -10161,7 +10271,12 @@ var init_session_mutation = () => {};
|
|
|
10161
10271
|
// src/daemon/session-state.ts
|
|
10162
10272
|
async function buildState(session, options = {}) {
|
|
10163
10273
|
if (session.sessionState !== "paused" || !session.cdp || !session.pauseInfo) {
|
|
10164
|
-
|
|
10274
|
+
const snapshot2 = { status: session.sessionState };
|
|
10275
|
+
if (session.sessionState === "idle" && session.exceptionEntries.length > 0) {
|
|
10276
|
+
const last = session.exceptionEntries[session.exceptionEntries.length - 1];
|
|
10277
|
+
snapshot2.lastException = { text: last.text, description: last.description };
|
|
10278
|
+
}
|
|
10279
|
+
return snapshot2;
|
|
10165
10280
|
}
|
|
10166
10281
|
session.refs.clearVolatile();
|
|
10167
10282
|
const showAll = !options.vars && !options.stack && !options.breakpoints && !options.code;
|
|
@@ -10475,6 +10590,10 @@ class DebugSession {
|
|
|
10475
10590
|
}
|
|
10476
10591
|
status.pauseInfo = translated;
|
|
10477
10592
|
}
|
|
10593
|
+
if (this.state === "idle" && this.exceptionEntries.length > 0) {
|
|
10594
|
+
const last = this.exceptionEntries[this.exceptionEntries.length - 1];
|
|
10595
|
+
status.lastException = { text: last.text, description: last.description };
|
|
10596
|
+
}
|
|
10478
10597
|
return status;
|
|
10479
10598
|
}
|
|
10480
10599
|
async stop() {
|
|
@@ -10701,7 +10820,7 @@ class DebugSession {
|
|
|
10701
10820
|
};
|
|
10702
10821
|
this.cdp?.waitFor("Debugger.paused", { timeoutMs }).then(() => settle()).catch(() => settle());
|
|
10703
10822
|
const pollTimer = setInterval(() => {
|
|
10704
|
-
if (this.isPaused() || this.state === "idle") {
|
|
10823
|
+
if (this.isPaused() || this.state === "idle" || !this.cdp) {
|
|
10705
10824
|
settle();
|
|
10706
10825
|
}
|
|
10707
10826
|
}, 100);
|
|
@@ -10978,7 +11097,7 @@ var init_entry = __esm(async () => {
|
|
|
10978
11097
|
daemonIdx = process.argv.indexOf("--daemon");
|
|
10979
11098
|
session = daemonIdx !== -1 ? process.argv[daemonIdx + 1] : process.argv[2];
|
|
10980
11099
|
if (!session) {
|
|
10981
|
-
console.error("Usage:
|
|
11100
|
+
console.error("Usage: debug-that --daemon <session> [--timeout <seconds>]");
|
|
10982
11101
|
process.exit(1);
|
|
10983
11102
|
}
|
|
10984
11103
|
timeoutIdx = process.argv.indexOf("--timeout");
|
|
@@ -11129,8 +11248,13 @@ var init_entry = __esm(async () => {
|
|
|
11129
11248
|
}
|
|
11130
11249
|
case "eval": {
|
|
11131
11250
|
const { expression, ...evalOptions } = req.args;
|
|
11132
|
-
|
|
11133
|
-
|
|
11251
|
+
try {
|
|
11252
|
+
const evalResult = await activeSession().eval(expression, evalOptions);
|
|
11253
|
+
return { ok: true, data: evalResult };
|
|
11254
|
+
} catch (err) {
|
|
11255
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
11256
|
+
return { ok: false, error: msg, suggestion: suggestEvalFix(msg) };
|
|
11257
|
+
}
|
|
11134
11258
|
}
|
|
11135
11259
|
case "vars": {
|
|
11136
11260
|
const varsResult = await activeSession().getVars(req.args);
|
|
@@ -11204,6 +11328,18 @@ var init_entry = __esm(async () => {
|
|
|
11204
11328
|
const result = await activeSession().restart();
|
|
11205
11329
|
return { ok: true, data: result };
|
|
11206
11330
|
}
|
|
11331
|
+
case "modules": {
|
|
11332
|
+
const session2 = activeSession();
|
|
11333
|
+
if (!("getModules" in session2)) {
|
|
11334
|
+
return {
|
|
11335
|
+
ok: false,
|
|
11336
|
+
error: "Modules are only available in DAP mode (e.g. --runtime lldb)",
|
|
11337
|
+
suggestion: "For CDP sessions, use: debug-that scripts"
|
|
11338
|
+
};
|
|
11339
|
+
}
|
|
11340
|
+
const modulesResult = await session2.getModules(req.args.filter);
|
|
11341
|
+
return { ok: true, data: modulesResult };
|
|
11342
|
+
}
|
|
11207
11343
|
case "stop":
|
|
11208
11344
|
await activeSession().stop();
|
|
11209
11345
|
dapSession = null;
|
|
@@ -11236,7 +11372,7 @@ var init_registry = __esm(() => {
|
|
|
11236
11372
|
});
|
|
11237
11373
|
|
|
11238
11374
|
// src/daemon/client.ts
|
|
11239
|
-
import { existsSync as
|
|
11375
|
+
import { existsSync as existsSync4, readdirSync, readFileSync, unlinkSync as unlinkSync2 } from "fs";
|
|
11240
11376
|
|
|
11241
11377
|
class DaemonClient {
|
|
11242
11378
|
session;
|
|
@@ -11333,11 +11469,11 @@ class DaemonClient {
|
|
|
11333
11469
|
}
|
|
11334
11470
|
static isRunning(session2) {
|
|
11335
11471
|
const socketPath = getSocketPath(session2);
|
|
11336
|
-
if (!
|
|
11472
|
+
if (!existsSync4(socketPath)) {
|
|
11337
11473
|
return false;
|
|
11338
11474
|
}
|
|
11339
11475
|
const lockPath = getLockPath(session2);
|
|
11340
|
-
if (!
|
|
11476
|
+
if (!existsSync4(lockPath)) {
|
|
11341
11477
|
return false;
|
|
11342
11478
|
}
|
|
11343
11479
|
try {
|
|
@@ -11353,14 +11489,14 @@ class DaemonClient {
|
|
|
11353
11489
|
static cleanStaleFiles(session2) {
|
|
11354
11490
|
const socketPath = getSocketPath(session2);
|
|
11355
11491
|
const lockPath = getLockPath(session2);
|
|
11356
|
-
if (
|
|
11492
|
+
if (existsSync4(socketPath))
|
|
11357
11493
|
unlinkSync2(socketPath);
|
|
11358
|
-
if (
|
|
11494
|
+
if (existsSync4(lockPath))
|
|
11359
11495
|
unlinkSync2(lockPath);
|
|
11360
11496
|
}
|
|
11361
11497
|
static async isAlive(session2) {
|
|
11362
11498
|
const socketPath = getSocketPath(session2);
|
|
11363
|
-
if (!
|
|
11499
|
+
if (!existsSync4(socketPath)) {
|
|
11364
11500
|
return false;
|
|
11365
11501
|
}
|
|
11366
11502
|
try {
|
|
@@ -11373,7 +11509,7 @@ class DaemonClient {
|
|
|
11373
11509
|
}
|
|
11374
11510
|
static listSessions() {
|
|
11375
11511
|
const dir = getSocketDir();
|
|
11376
|
-
if (!
|
|
11512
|
+
if (!existsSync4(dir)) {
|
|
11377
11513
|
return [];
|
|
11378
11514
|
}
|
|
11379
11515
|
const files = readdirSync(dir);
|
|
@@ -11386,7 +11522,7 @@ var init_client3 = __esm(() => {
|
|
|
11386
11522
|
});
|
|
11387
11523
|
|
|
11388
11524
|
// src/daemon/spawn.ts
|
|
11389
|
-
import { closeSync, existsSync as
|
|
11525
|
+
import { closeSync, existsSync as existsSync5, openSync, readFileSync as readFileSync2 } from "fs";
|
|
11390
11526
|
async function spawnDaemon(session2, options = {}) {
|
|
11391
11527
|
const socketPath = getSocketPath(session2);
|
|
11392
11528
|
const spawnArgs = [];
|
|
@@ -11413,7 +11549,7 @@ async function spawnDaemon(session2, options = {}) {
|
|
|
11413
11549
|
proc.unref();
|
|
11414
11550
|
const deadline = Date.now() + SPAWN_TIMEOUT_MS;
|
|
11415
11551
|
while (Date.now() < deadline) {
|
|
11416
|
-
if (
|
|
11552
|
+
if (existsSync5(socketPath)) {
|
|
11417
11553
|
return;
|
|
11418
11554
|
}
|
|
11419
11555
|
await Bun.sleep(SPAWN_POLL_INTERVAL_MS);
|
|
@@ -11486,7 +11622,7 @@ var init_launch = __esm(() => {
|
|
|
11486
11622
|
const command = args.subcommand ? [args.subcommand, ...args.positionals] : [...args.positionals];
|
|
11487
11623
|
if (command.length === 0) {
|
|
11488
11624
|
console.error("No command specified");
|
|
11489
|
-
console.error(" -> Try:
|
|
11625
|
+
console.error(" -> Try: dbg launch --brk node app.js");
|
|
11490
11626
|
return 1;
|
|
11491
11627
|
}
|
|
11492
11628
|
await ensureDaemon(session2, { timeout: timeout2 });
|
|
@@ -11527,12 +11663,12 @@ var init_attach = __esm(() => {
|
|
|
11527
11663
|
const runtime = typeof args.flags.runtime === "string" ? args.flags.runtime : undefined;
|
|
11528
11664
|
if (!target) {
|
|
11529
11665
|
console.error("No target specified");
|
|
11530
|
-
console.error(" -> Try:
|
|
11666
|
+
console.error(" -> Try: dbg attach <ws-url | port>");
|
|
11531
11667
|
return 1;
|
|
11532
11668
|
}
|
|
11533
11669
|
if (DaemonClient.isRunning(session2)) {
|
|
11534
11670
|
console.error(`Session "${session2}" is already active`);
|
|
11535
|
-
console.error(` -> Try:
|
|
11671
|
+
console.error(` -> Try: dbg stop --session ${session2}`);
|
|
11536
11672
|
return 1;
|
|
11537
11673
|
}
|
|
11538
11674
|
const timeout2 = parseIntFlag(args.flags, "timeout");
|
|
@@ -11594,7 +11730,7 @@ var init_restart = __esm(() => {
|
|
|
11594
11730
|
const session2 = args.global.session;
|
|
11595
11731
|
if (!DaemonClient.isRunning(session2)) {
|
|
11596
11732
|
console.error(`No active session "${session2}"`);
|
|
11597
|
-
console.error(" -> Try:
|
|
11733
|
+
console.error(" -> Try: dbg launch --brk node app.js");
|
|
11598
11734
|
return 1;
|
|
11599
11735
|
}
|
|
11600
11736
|
const client = new DaemonClient(session2);
|
|
@@ -11697,7 +11833,7 @@ var init_status = __esm(() => {
|
|
|
11697
11833
|
const session2 = args.global.session;
|
|
11698
11834
|
if (!DaemonClient.isRunning(session2)) {
|
|
11699
11835
|
console.error(`No active session "${session2}"`);
|
|
11700
|
-
console.error(" -> Try:
|
|
11836
|
+
console.error(" -> Try: dbg launch --brk node app.js");
|
|
11701
11837
|
return 1;
|
|
11702
11838
|
}
|
|
11703
11839
|
const client = new DaemonClient(session2);
|
|
@@ -11724,6 +11860,12 @@ var init_status = __esm(() => {
|
|
|
11724
11860
|
const loc = data.pauseInfo.url ? `${shortPath(data.pauseInfo.url)}:${data.pauseInfo.line}${data.pauseInfo.column !== undefined ? `:${data.pauseInfo.column}` : ""}` : "unknown";
|
|
11725
11861
|
console.log(` Paused: ${data.pauseInfo.reason} at ${loc}`);
|
|
11726
11862
|
}
|
|
11863
|
+
if (data.lastException) {
|
|
11864
|
+
const desc = data.lastException.description ?? data.lastException.text;
|
|
11865
|
+
const firstLine = desc.split(`
|
|
11866
|
+
`)[0] ?? desc;
|
|
11867
|
+
console.log(` Last exception: ${firstLine}`);
|
|
11868
|
+
}
|
|
11727
11869
|
}
|
|
11728
11870
|
return 0;
|
|
11729
11871
|
});
|
|
@@ -11900,7 +12042,17 @@ var init_variables = __esm(() => {
|
|
|
11900
12042
|
function printState(data) {
|
|
11901
12043
|
if (data.status !== "paused") {
|
|
11902
12044
|
const icon = data.status === "running" ? "\u25B6" : "\u25CB";
|
|
11903
|
-
|
|
12045
|
+
const label = data.status === "running" ? "Running" : "Idle";
|
|
12046
|
+
if (data.lastException) {
|
|
12047
|
+
const desc = data.lastException.description ?? data.lastException.text;
|
|
12048
|
+
const firstLine = desc.split(`
|
|
12049
|
+
`)[0] ?? desc;
|
|
12050
|
+
console.log(`${icon} ${label} (crashed)`);
|
|
12051
|
+
console.log(` ${firstLine}`);
|
|
12052
|
+
console.log(" -> Try: dbg exceptions");
|
|
12053
|
+
} else {
|
|
12054
|
+
console.log(`${icon} ${label}`);
|
|
12055
|
+
}
|
|
11904
12056
|
return;
|
|
11905
12057
|
}
|
|
11906
12058
|
const loc = data.location ? `${shortPath(data.location.url)}:${data.location.line}${data.location.column !== undefined ? `:${data.location.column}` : ""}` : "unknown";
|
|
@@ -11972,7 +12124,7 @@ var init_state = __esm(() => {
|
|
|
11972
12124
|
const session2 = args.global.session;
|
|
11973
12125
|
if (!DaemonClient.isRunning(session2)) {
|
|
11974
12126
|
console.error(`No active session "${session2}"`);
|
|
11975
|
-
console.error(" -> Try:
|
|
12127
|
+
console.error(" -> Try: dbg launch --brk node app.js");
|
|
11976
12128
|
return 1;
|
|
11977
12129
|
}
|
|
11978
12130
|
const client = new DaemonClient(session2);
|
|
@@ -12027,7 +12179,7 @@ var init_continue = __esm(() => {
|
|
|
12027
12179
|
const session2 = args.global.session;
|
|
12028
12180
|
if (!DaemonClient.isRunning(session2)) {
|
|
12029
12181
|
console.error(`No active session "${session2}"`);
|
|
12030
|
-
console.error(" -> Try:
|
|
12182
|
+
console.error(" -> Try: dbg launch --brk node app.js");
|
|
12031
12183
|
return 1;
|
|
12032
12184
|
}
|
|
12033
12185
|
const client = new DaemonClient(session2);
|
|
@@ -12058,7 +12210,7 @@ var init_step = __esm(() => {
|
|
|
12058
12210
|
const session2 = args.global.session;
|
|
12059
12211
|
if (!DaemonClient.isRunning(session2)) {
|
|
12060
12212
|
console.error(`No active session "${session2}"`);
|
|
12061
|
-
console.error(" -> Try:
|
|
12213
|
+
console.error(" -> Try: dbg launch --brk node app.js");
|
|
12062
12214
|
return 1;
|
|
12063
12215
|
}
|
|
12064
12216
|
const validModes = new Set(["over", "into", "out"]);
|
|
@@ -12091,7 +12243,7 @@ var init_pause = __esm(() => {
|
|
|
12091
12243
|
const session2 = args.global.session;
|
|
12092
12244
|
if (!DaemonClient.isRunning(session2)) {
|
|
12093
12245
|
console.error(`No active session "${session2}"`);
|
|
12094
|
-
console.error(" -> Try:
|
|
12246
|
+
console.error(" -> Try: dbg launch --brk node app.js");
|
|
12095
12247
|
return 1;
|
|
12096
12248
|
}
|
|
12097
12249
|
const client = new DaemonClient(session2);
|
|
@@ -12157,13 +12309,13 @@ var init_run_to = __esm(() => {
|
|
|
12157
12309
|
const session2 = args.global.session;
|
|
12158
12310
|
if (!DaemonClient.isRunning(session2)) {
|
|
12159
12311
|
console.error(`No active session "${session2}"`);
|
|
12160
|
-
console.error(" -> Try:
|
|
12312
|
+
console.error(" -> Try: dbg launch --brk node app.js");
|
|
12161
12313
|
return 1;
|
|
12162
12314
|
}
|
|
12163
12315
|
const target = args.subcommand ?? args.positionals[0];
|
|
12164
12316
|
if (!target) {
|
|
12165
12317
|
console.error("No target specified");
|
|
12166
|
-
console.error(" -> Try:
|
|
12318
|
+
console.error(" -> Try: dbg run-to src/file.ts:42");
|
|
12167
12319
|
return 1;
|
|
12168
12320
|
}
|
|
12169
12321
|
const parsed = parseFileLine(target);
|
|
@@ -12201,7 +12353,7 @@ var init_break = __esm(() => {
|
|
|
12201
12353
|
const session2 = args.global.session;
|
|
12202
12354
|
if (!DaemonClient.isRunning(session2)) {
|
|
12203
12355
|
console.error(`No active session "${session2}"`);
|
|
12204
|
-
console.error(" -> Try:
|
|
12356
|
+
console.error(" -> Try: dbg launch --brk node app.js");
|
|
12205
12357
|
return 1;
|
|
12206
12358
|
}
|
|
12207
12359
|
const patternFlag = typeof args.flags.pattern === "string" ? args.flags.pattern : undefined;
|
|
@@ -12213,7 +12365,7 @@ var init_break = __esm(() => {
|
|
|
12213
12365
|
const lastColon = patternFlag.lastIndexOf(":");
|
|
12214
12366
|
if (lastColon === -1 || lastColon === 0) {
|
|
12215
12367
|
console.error(`Invalid --pattern target: "${patternFlag}"`);
|
|
12216
|
-
console.error(" -> Try:
|
|
12368
|
+
console.error(" -> Try: dbg break --pattern 'app\\.js':42");
|
|
12217
12369
|
return 1;
|
|
12218
12370
|
}
|
|
12219
12371
|
file2 = patternFlag.slice(0, lastColon);
|
|
@@ -12226,13 +12378,13 @@ var init_break = __esm(() => {
|
|
|
12226
12378
|
const target = args.subcommand;
|
|
12227
12379
|
if (!target) {
|
|
12228
12380
|
console.error("No target specified");
|
|
12229
|
-
console.error(" -> Try:
|
|
12381
|
+
console.error(" -> Try: dbg break src/app.ts:42");
|
|
12230
12382
|
return 1;
|
|
12231
12383
|
}
|
|
12232
12384
|
const parsed = parseFileLineColumn(target);
|
|
12233
12385
|
if (!parsed) {
|
|
12234
12386
|
console.error(`Invalid breakpoint target: "${target}"`);
|
|
12235
|
-
console.error(" -> Try:
|
|
12387
|
+
console.error(" -> Try: dbg break src/app.ts:42 or src/app.ts:42:5");
|
|
12236
12388
|
return 1;
|
|
12237
12389
|
}
|
|
12238
12390
|
file2 = parsed.file;
|
|
@@ -12319,14 +12471,14 @@ var init_break_fn = __esm(() => {
|
|
|
12319
12471
|
const session2 = args.global.session;
|
|
12320
12472
|
if (!DaemonClient.isRunning(session2)) {
|
|
12321
12473
|
console.error(`No active session "${session2}"`);
|
|
12322
|
-
console.error(" -> Try:
|
|
12474
|
+
console.error(" -> Try: dbg launch --brk --runtime lldb ./program");
|
|
12323
12475
|
return 1;
|
|
12324
12476
|
}
|
|
12325
12477
|
const name = args.subcommand;
|
|
12326
12478
|
if (!name) {
|
|
12327
|
-
console.error("Usage:
|
|
12328
|
-
console.error(" Example:
|
|
12329
|
-
console.error(" Example:
|
|
12479
|
+
console.error("Usage: dbg break-fn <function-name>");
|
|
12480
|
+
console.error(" Example: dbg break-fn __assert_rtn");
|
|
12481
|
+
console.error(" Example: dbg break-fn 'yoga::Style::operator=='");
|
|
12330
12482
|
return 1;
|
|
12331
12483
|
}
|
|
12332
12484
|
const condition = typeof args.flags.condition === "string" ? args.flags.condition : undefined;
|
|
@@ -12357,13 +12509,13 @@ var init_break_rm = __esm(() => {
|
|
|
12357
12509
|
const session2 = args.global.session;
|
|
12358
12510
|
if (!DaemonClient.isRunning(session2)) {
|
|
12359
12511
|
console.error(`No active session "${session2}"`);
|
|
12360
|
-
console.error(" -> Try:
|
|
12512
|
+
console.error(" -> Try: dbg launch --brk node app.js");
|
|
12361
12513
|
return 1;
|
|
12362
12514
|
}
|
|
12363
12515
|
const ref = args.subcommand;
|
|
12364
12516
|
if (!ref) {
|
|
12365
12517
|
console.error("No breakpoint ref specified");
|
|
12366
|
-
console.error(" -> Try:
|
|
12518
|
+
console.error(" -> Try: dbg break-rm BP#1");
|
|
12367
12519
|
return 1;
|
|
12368
12520
|
}
|
|
12369
12521
|
const client = new DaemonClient(session2);
|
|
@@ -12397,7 +12549,7 @@ var init_break_ls = __esm(() => {
|
|
|
12397
12549
|
const session2 = args.global.session;
|
|
12398
12550
|
if (!DaemonClient.isRunning(session2)) {
|
|
12399
12551
|
console.error(`No active session "${session2}"`);
|
|
12400
|
-
console.error(" -> Try:
|
|
12552
|
+
console.error(" -> Try: dbg launch --brk node app.js");
|
|
12401
12553
|
return 1;
|
|
12402
12554
|
}
|
|
12403
12555
|
const client = new DaemonClient(session2);
|
|
@@ -12445,26 +12597,26 @@ var init_logpoint = __esm(() => {
|
|
|
12445
12597
|
const session2 = args.global.session;
|
|
12446
12598
|
if (!DaemonClient.isRunning(session2)) {
|
|
12447
12599
|
console.error(`No active session "${session2}"`);
|
|
12448
|
-
console.error(" -> Try:
|
|
12600
|
+
console.error(" -> Try: dbg launch --brk node app.js");
|
|
12449
12601
|
return 1;
|
|
12450
12602
|
}
|
|
12451
12603
|
const target = args.subcommand;
|
|
12452
12604
|
if (!target) {
|
|
12453
12605
|
console.error("No target specified");
|
|
12454
|
-
console.error(' -> Try:
|
|
12606
|
+
console.error(' -> Try: dbg logpoint src/app.ts:42 "x =", x');
|
|
12455
12607
|
return 1;
|
|
12456
12608
|
}
|
|
12457
12609
|
const parsed = parseFileLine(target);
|
|
12458
12610
|
if (!parsed) {
|
|
12459
12611
|
console.error(`Invalid logpoint target: "${target}"`);
|
|
12460
|
-
console.error(' -> Try:
|
|
12612
|
+
console.error(' -> Try: dbg logpoint src/app.ts:42 "x =", x');
|
|
12461
12613
|
return 1;
|
|
12462
12614
|
}
|
|
12463
12615
|
const { file: file2, line } = parsed;
|
|
12464
12616
|
const template = args.positionals[0];
|
|
12465
12617
|
if (!template) {
|
|
12466
12618
|
console.error("No log template specified");
|
|
12467
|
-
console.error(' -> Try:
|
|
12619
|
+
console.error(' -> Try: dbg logpoint src/app.ts:42 "x =", x');
|
|
12468
12620
|
return 1;
|
|
12469
12621
|
}
|
|
12470
12622
|
const condition = typeof args.flags.condition === "string" ? args.flags.condition : undefined;
|
|
@@ -12505,13 +12657,13 @@ var init_catch = __esm(() => {
|
|
|
12505
12657
|
const session2 = args.global.session;
|
|
12506
12658
|
if (!DaemonClient.isRunning(session2)) {
|
|
12507
12659
|
console.error(`No active session "${session2}"`);
|
|
12508
|
-
console.error(" -> Try:
|
|
12660
|
+
console.error(" -> Try: dbg launch --brk node app.js");
|
|
12509
12661
|
return 1;
|
|
12510
12662
|
}
|
|
12511
12663
|
const mode = args.subcommand ?? "all";
|
|
12512
12664
|
if (!VALID_MODES.has(mode)) {
|
|
12513
12665
|
console.error(`Invalid catch mode: "${mode}"`);
|
|
12514
|
-
console.error(" -> Try:
|
|
12666
|
+
console.error(" -> Try: dbg catch [all | uncaught | caught | none]");
|
|
12515
12667
|
return 1;
|
|
12516
12668
|
}
|
|
12517
12669
|
const client = new DaemonClient(session2);
|
|
@@ -12542,7 +12694,7 @@ var init_source2 = __esm(() => {
|
|
|
12542
12694
|
const session2 = args.global.session;
|
|
12543
12695
|
if (!DaemonClient.isRunning(session2)) {
|
|
12544
12696
|
console.error(`No active session "${session2}"`);
|
|
12545
|
-
console.error(" -> Try:
|
|
12697
|
+
console.error(" -> Try: dbg launch --brk node app.js");
|
|
12546
12698
|
return 1;
|
|
12547
12699
|
}
|
|
12548
12700
|
const client = new DaemonClient(session2);
|
|
@@ -12591,7 +12743,7 @@ var init_scripts = __esm(() => {
|
|
|
12591
12743
|
const session2 = args.global.session;
|
|
12592
12744
|
if (!DaemonClient.isRunning(session2)) {
|
|
12593
12745
|
console.error(`No active session "${session2}"`);
|
|
12594
|
-
console.error(" -> Try:
|
|
12746
|
+
console.error(" -> Try: dbg launch --brk node app.js");
|
|
12595
12747
|
return 1;
|
|
12596
12748
|
}
|
|
12597
12749
|
const client = new DaemonClient(session2);
|
|
@@ -12628,6 +12780,52 @@ var init_scripts = __esm(() => {
|
|
|
12628
12780
|
});
|
|
12629
12781
|
});
|
|
12630
12782
|
|
|
12783
|
+
// src/commands/modules.ts
|
|
12784
|
+
var exports_modules = {};
|
|
12785
|
+
var init_modules = __esm(() => {
|
|
12786
|
+
init_registry();
|
|
12787
|
+
init_client3();
|
|
12788
|
+
registerCommand("modules", async (args) => {
|
|
12789
|
+
const session2 = args.global.session;
|
|
12790
|
+
if (!DaemonClient.isRunning(session2)) {
|
|
12791
|
+
console.error(`No active session "${session2}"`);
|
|
12792
|
+
console.error(" -> Try: dbg launch --brk node app.js");
|
|
12793
|
+
return 1;
|
|
12794
|
+
}
|
|
12795
|
+
const client = new DaemonClient(session2);
|
|
12796
|
+
const modulesArgs = {};
|
|
12797
|
+
const filter = args.subcommand ?? (typeof args.flags.filter === "string" ? args.flags.filter : undefined);
|
|
12798
|
+
if (filter) {
|
|
12799
|
+
modulesArgs.filter = filter;
|
|
12800
|
+
}
|
|
12801
|
+
const response = await client.request("modules", modulesArgs);
|
|
12802
|
+
if (!response.ok) {
|
|
12803
|
+
console.error(`${response.error}`);
|
|
12804
|
+
if (response.suggestion)
|
|
12805
|
+
console.error(` ${response.suggestion}`);
|
|
12806
|
+
return 1;
|
|
12807
|
+
}
|
|
12808
|
+
const data = response.data;
|
|
12809
|
+
if (args.global.json) {
|
|
12810
|
+
console.log(JSON.stringify(data, null, 2));
|
|
12811
|
+
return 0;
|
|
12812
|
+
}
|
|
12813
|
+
if (data.length === 0) {
|
|
12814
|
+
console.log("No modules loaded");
|
|
12815
|
+
return 0;
|
|
12816
|
+
}
|
|
12817
|
+
const nameWidth = Math.max(...data.map((m) => m.name.length), 4);
|
|
12818
|
+
const statusWidth = Math.max(...data.map((m) => (m.symbolStatus ?? "").length), 7);
|
|
12819
|
+
for (const mod of data) {
|
|
12820
|
+
const name = mod.name.padEnd(nameWidth);
|
|
12821
|
+
const status = (mod.symbolStatus ?? "unknown").padEnd(statusWidth);
|
|
12822
|
+
const path = mod.path ?? "";
|
|
12823
|
+
console.log(` ${name} ${status} ${path}`);
|
|
12824
|
+
}
|
|
12825
|
+
return 0;
|
|
12826
|
+
});
|
|
12827
|
+
});
|
|
12828
|
+
|
|
12631
12829
|
// src/commands/stack.ts
|
|
12632
12830
|
var exports_stack = {};
|
|
12633
12831
|
var init_stack2 = __esm(() => {
|
|
@@ -12638,7 +12836,7 @@ var init_stack2 = __esm(() => {
|
|
|
12638
12836
|
const session2 = args.global.session;
|
|
12639
12837
|
if (!DaemonClient.isRunning(session2)) {
|
|
12640
12838
|
console.error(`No active session "${session2}"`);
|
|
12641
|
-
console.error(" -> Try:
|
|
12839
|
+
console.error(" -> Try: dbg launch --brk node app.js");
|
|
12642
12840
|
return 1;
|
|
12643
12841
|
}
|
|
12644
12842
|
const client = new DaemonClient(session2);
|
|
@@ -12649,6 +12847,9 @@ var init_stack2 = __esm(() => {
|
|
|
12649
12847
|
if (args.flags.generated === true) {
|
|
12650
12848
|
stackArgs.generated = true;
|
|
12651
12849
|
}
|
|
12850
|
+
if (typeof args.flags.filter === "string") {
|
|
12851
|
+
stackArgs.filter = args.flags.filter;
|
|
12852
|
+
}
|
|
12652
12853
|
const response = await client.request("stack", stackArgs);
|
|
12653
12854
|
if (!response.ok) {
|
|
12654
12855
|
console.error(`${response.error}`);
|
|
@@ -12688,7 +12889,7 @@ var init_search = __esm(() => {
|
|
|
12688
12889
|
const session2 = args.global.session;
|
|
12689
12890
|
if (!DaemonClient.isRunning(session2)) {
|
|
12690
12891
|
console.error(`No active session "${session2}"`);
|
|
12691
|
-
console.error(" -> Try:
|
|
12892
|
+
console.error(" -> Try: dbg launch --brk node app.js");
|
|
12692
12893
|
return 1;
|
|
12693
12894
|
}
|
|
12694
12895
|
const parts = [];
|
|
@@ -12701,7 +12902,7 @@ var init_search = __esm(() => {
|
|
|
12701
12902
|
const query = parts.join(" ");
|
|
12702
12903
|
if (!query) {
|
|
12703
12904
|
console.error("No search query specified");
|
|
12704
|
-
console.error(" -> Try:
|
|
12905
|
+
console.error(" -> Try: dbg search <query> [--regex] [--case-sensitive]");
|
|
12705
12906
|
return 1;
|
|
12706
12907
|
}
|
|
12707
12908
|
const client = new DaemonClient(session2);
|
|
@@ -12756,7 +12957,7 @@ var init_console = __esm(() => {
|
|
|
12756
12957
|
const session2 = args.global.session;
|
|
12757
12958
|
if (!DaemonClient.isRunning(session2)) {
|
|
12758
12959
|
console.error(`No active session "${session2}"`);
|
|
12759
|
-
console.error(" -> Try:
|
|
12960
|
+
console.error(" -> Try: dbg launch --brk node app.js");
|
|
12760
12961
|
return 1;
|
|
12761
12962
|
}
|
|
12762
12963
|
const client = new DaemonClient(session2);
|
|
@@ -12803,7 +13004,7 @@ var init_exceptions = __esm(() => {
|
|
|
12803
13004
|
const session2 = args.global.session;
|
|
12804
13005
|
if (!DaemonClient.isRunning(session2)) {
|
|
12805
13006
|
console.error(`No active session "${session2}"`);
|
|
12806
|
-
console.error(" -> Try:
|
|
13007
|
+
console.error(" -> Try: dbg launch --brk node app.js");
|
|
12807
13008
|
return 1;
|
|
12808
13009
|
}
|
|
12809
13010
|
const client = new DaemonClient(session2);
|
|
@@ -12850,7 +13051,7 @@ var init_eval = __esm(() => {
|
|
|
12850
13051
|
const session2 = args.global.session;
|
|
12851
13052
|
if (!DaemonClient.isRunning(session2)) {
|
|
12852
13053
|
console.error(`No active session "${session2}"`);
|
|
12853
|
-
console.error(" -> Try:
|
|
13054
|
+
console.error(" -> Try: dbg launch --brk node app.js");
|
|
12854
13055
|
return 1;
|
|
12855
13056
|
}
|
|
12856
13057
|
const parts = [];
|
|
@@ -12861,7 +13062,7 @@ var init_eval = __esm(() => {
|
|
|
12861
13062
|
const expression = parts.join(" ");
|
|
12862
13063
|
if (!expression) {
|
|
12863
13064
|
console.error("No expression specified");
|
|
12864
|
-
console.error(" -> Try:
|
|
13065
|
+
console.error(" -> Try: dbg eval 1 + 2");
|
|
12865
13066
|
return 1;
|
|
12866
13067
|
}
|
|
12867
13068
|
const evalArgs = {
|
|
@@ -12910,7 +13111,7 @@ var init_vars = __esm(() => {
|
|
|
12910
13111
|
const session2 = args.global.session;
|
|
12911
13112
|
if (!DaemonClient.isRunning(session2)) {
|
|
12912
13113
|
console.error(`No active session "${session2}"`);
|
|
12913
|
-
console.error(" -> Try:
|
|
13114
|
+
console.error(" -> Try: dbg launch --brk node app.js");
|
|
12914
13115
|
return 1;
|
|
12915
13116
|
}
|
|
12916
13117
|
const names = [];
|
|
@@ -12968,13 +13169,13 @@ var init_props = __esm(() => {
|
|
|
12968
13169
|
const session2 = args.global.session;
|
|
12969
13170
|
if (!DaemonClient.isRunning(session2)) {
|
|
12970
13171
|
console.error(`No active session "${session2}"`);
|
|
12971
|
-
console.error(" -> Try:
|
|
13172
|
+
console.error(" -> Try: dbg launch --brk node app.js");
|
|
12972
13173
|
return 1;
|
|
12973
13174
|
}
|
|
12974
13175
|
const ref = args.subcommand;
|
|
12975
13176
|
if (!ref) {
|
|
12976
13177
|
console.error("No ref specified");
|
|
12977
|
-
console.error(" -> Try:
|
|
13178
|
+
console.error(" -> Try: dbg props @v1");
|
|
12978
13179
|
return 1;
|
|
12979
13180
|
}
|
|
12980
13181
|
const propsArgs = {
|
|
@@ -13030,7 +13231,7 @@ var init_blackbox = __esm(() => {
|
|
|
13030
13231
|
const session2 = args.global.session;
|
|
13031
13232
|
if (!DaemonClient.isRunning(session2)) {
|
|
13032
13233
|
console.error(`No active session "${session2}"`);
|
|
13033
|
-
console.error(" -> Try:
|
|
13234
|
+
console.error(" -> Try: dbg launch --brk node app.js");
|
|
13034
13235
|
return 1;
|
|
13035
13236
|
}
|
|
13036
13237
|
const patterns = [];
|
|
@@ -13042,7 +13243,7 @@ var init_blackbox = __esm(() => {
|
|
|
13042
13243
|
}
|
|
13043
13244
|
if (patterns.length === 0) {
|
|
13044
13245
|
console.error("No patterns specified");
|
|
13045
|
-
console.error(" -> Try:
|
|
13246
|
+
console.error(" -> Try: dbg blackbox node_modules");
|
|
13046
13247
|
return 1;
|
|
13047
13248
|
}
|
|
13048
13249
|
const client = new DaemonClient(session2);
|
|
@@ -13075,7 +13276,7 @@ var init_blackbox_ls = __esm(() => {
|
|
|
13075
13276
|
const session2 = args.global.session;
|
|
13076
13277
|
if (!DaemonClient.isRunning(session2)) {
|
|
13077
13278
|
console.error(`No active session "${session2}"`);
|
|
13078
|
-
console.error(" -> Try:
|
|
13279
|
+
console.error(" -> Try: dbg launch --brk node app.js");
|
|
13079
13280
|
return 1;
|
|
13080
13281
|
}
|
|
13081
13282
|
const client = new DaemonClient(session2);
|
|
@@ -13112,7 +13313,7 @@ var init_blackbox_rm = __esm(() => {
|
|
|
13112
13313
|
const session2 = args.global.session;
|
|
13113
13314
|
if (!DaemonClient.isRunning(session2)) {
|
|
13114
13315
|
console.error(`No active session "${session2}"`);
|
|
13115
|
-
console.error(" -> Try:
|
|
13316
|
+
console.error(" -> Try: dbg launch --brk node app.js");
|
|
13116
13317
|
return 1;
|
|
13117
13318
|
}
|
|
13118
13319
|
const patterns = [];
|
|
@@ -13128,8 +13329,8 @@ var init_blackbox_rm = __esm(() => {
|
|
|
13128
13329
|
}
|
|
13129
13330
|
if (patterns.length === 0) {
|
|
13130
13331
|
console.error("No patterns specified");
|
|
13131
|
-
console.error(" -> Try:
|
|
13132
|
-
console.error(" -> Try:
|
|
13332
|
+
console.error(" -> Try: dbg blackbox-rm node_modules");
|
|
13333
|
+
console.error(" -> Try: dbg blackbox-rm all");
|
|
13133
13334
|
return 1;
|
|
13134
13335
|
}
|
|
13135
13336
|
const client = new DaemonClient(session2);
|
|
@@ -13166,19 +13367,19 @@ var init_set = __esm(() => {
|
|
|
13166
13367
|
const session2 = args.global.session;
|
|
13167
13368
|
if (!DaemonClient.isRunning(session2)) {
|
|
13168
13369
|
console.error(`No active session "${session2}"`);
|
|
13169
|
-
console.error(" -> Try:
|
|
13370
|
+
console.error(" -> Try: dbg launch --brk node app.js");
|
|
13170
13371
|
return 1;
|
|
13171
13372
|
}
|
|
13172
13373
|
const varName = args.subcommand;
|
|
13173
13374
|
if (!varName) {
|
|
13174
13375
|
console.error("No variable name specified");
|
|
13175
|
-
console.error(" -> Try:
|
|
13376
|
+
console.error(" -> Try: dbg set counter 42");
|
|
13176
13377
|
return 1;
|
|
13177
13378
|
}
|
|
13178
13379
|
const valueParts = args.positionals;
|
|
13179
13380
|
if (valueParts.length === 0) {
|
|
13180
13381
|
console.error("No value specified");
|
|
13181
|
-
console.error(" -> Try:
|
|
13382
|
+
console.error(" -> Try: dbg set counter 42");
|
|
13182
13383
|
return 1;
|
|
13183
13384
|
}
|
|
13184
13385
|
const value = valueParts.join(" ");
|
|
@@ -13216,7 +13417,7 @@ var init_set_return = __esm(() => {
|
|
|
13216
13417
|
const session2 = args.global.session;
|
|
13217
13418
|
if (!DaemonClient.isRunning(session2)) {
|
|
13218
13419
|
console.error(`No active session "${session2}"`);
|
|
13219
|
-
console.error(" -> Try:
|
|
13420
|
+
console.error(" -> Try: dbg launch --brk node app.js");
|
|
13220
13421
|
return 1;
|
|
13221
13422
|
}
|
|
13222
13423
|
const parts = [];
|
|
@@ -13227,7 +13428,7 @@ var init_set_return = __esm(() => {
|
|
|
13227
13428
|
const value = parts.join(" ");
|
|
13228
13429
|
if (!value) {
|
|
13229
13430
|
console.error("No value specified");
|
|
13230
|
-
console.error(" -> Try:
|
|
13431
|
+
console.error(" -> Try: dbg set-return 42");
|
|
13231
13432
|
return 1;
|
|
13232
13433
|
}
|
|
13233
13434
|
const client = new DaemonClient(session2);
|
|
@@ -13257,13 +13458,13 @@ var init_hotpatch = __esm(() => {
|
|
|
13257
13458
|
const session2 = args.global.session;
|
|
13258
13459
|
if (!DaemonClient.isRunning(session2)) {
|
|
13259
13460
|
console.error(`No active session "${session2}"`);
|
|
13260
|
-
console.error(" -> Try:
|
|
13461
|
+
console.error(" -> Try: dbg launch --brk node app.js");
|
|
13261
13462
|
return 1;
|
|
13262
13463
|
}
|
|
13263
13464
|
const file2 = args.subcommand;
|
|
13264
13465
|
if (!file2) {
|
|
13265
13466
|
console.error("No file specified");
|
|
13266
|
-
console.error(" -> Try:
|
|
13467
|
+
console.error(" -> Try: dbg hotpatch app.js");
|
|
13267
13468
|
return 1;
|
|
13268
13469
|
}
|
|
13269
13470
|
let source;
|
|
@@ -13312,13 +13513,13 @@ var init_break_toggle = __esm(() => {
|
|
|
13312
13513
|
const session2 = args.global.session;
|
|
13313
13514
|
if (!DaemonClient.isRunning(session2)) {
|
|
13314
13515
|
console.error(`No active session "${session2}"`);
|
|
13315
|
-
console.error(" -> Try:
|
|
13516
|
+
console.error(" -> Try: dbg launch --brk node app.js");
|
|
13316
13517
|
return 1;
|
|
13317
13518
|
}
|
|
13318
13519
|
const ref = args.subcommand;
|
|
13319
13520
|
if (!ref) {
|
|
13320
13521
|
console.error("No breakpoint ref specified");
|
|
13321
|
-
console.error(" -> Try:
|
|
13522
|
+
console.error(" -> Try: dbg break-toggle BP#1");
|
|
13322
13523
|
return 1;
|
|
13323
13524
|
}
|
|
13324
13525
|
const client = new DaemonClient(session2);
|
|
@@ -13352,13 +13553,13 @@ var init_breakable = __esm(() => {
|
|
|
13352
13553
|
const session2 = args.global.session;
|
|
13353
13554
|
if (!DaemonClient.isRunning(session2)) {
|
|
13354
13555
|
console.error(`No active session "${session2}"`);
|
|
13355
|
-
console.error(" -> Try:
|
|
13556
|
+
console.error(" -> Try: dbg launch --brk node app.js");
|
|
13356
13557
|
return 1;
|
|
13357
13558
|
}
|
|
13358
13559
|
const target = args.subcommand;
|
|
13359
13560
|
if (!target) {
|
|
13360
13561
|
console.error("No target specified");
|
|
13361
|
-
console.error(" -> Try:
|
|
13562
|
+
console.error(" -> Try: dbg breakable src/app.ts:10-20");
|
|
13362
13563
|
return 1;
|
|
13363
13564
|
}
|
|
13364
13565
|
const lastColon = target.lastIndexOf(":");
|
|
@@ -13415,7 +13616,7 @@ var init_restart_frame = __esm(() => {
|
|
|
13415
13616
|
const session2 = args.global.session;
|
|
13416
13617
|
if (!DaemonClient.isRunning(session2)) {
|
|
13417
13618
|
console.error(`No active session "${session2}"`);
|
|
13418
|
-
console.error(" -> Try:
|
|
13619
|
+
console.error(" -> Try: dbg launch --brk node app.js");
|
|
13419
13620
|
return 1;
|
|
13420
13621
|
}
|
|
13421
13622
|
const frameRef = args.subcommand ?? undefined;
|
|
@@ -13448,7 +13649,7 @@ var init_sourcemap = __esm(() => {
|
|
|
13448
13649
|
const session2 = args.global.session;
|
|
13449
13650
|
if (!DaemonClient.isRunning(session2)) {
|
|
13450
13651
|
console.error(`No active session "${session2}"`);
|
|
13451
|
-
console.error(" -> Try:
|
|
13652
|
+
console.error(" -> Try: dbg launch --brk node app.js");
|
|
13452
13653
|
return 1;
|
|
13453
13654
|
}
|
|
13454
13655
|
const client = new DaemonClient(session2);
|
|
@@ -13491,6 +13692,148 @@ var init_sourcemap = __esm(() => {
|
|
|
13491
13692
|
});
|
|
13492
13693
|
});
|
|
13493
13694
|
|
|
13695
|
+
// src/commands/install.ts
|
|
13696
|
+
var exports_install = {};
|
|
13697
|
+
import { existsSync as existsSync6, mkdirSync as mkdirSync2 } from "fs";
|
|
13698
|
+
import { join as join3 } from "path";
|
|
13699
|
+
function getPlatformArch() {
|
|
13700
|
+
const os = process.platform;
|
|
13701
|
+
const arch = process.arch;
|
|
13702
|
+
return { os, arch };
|
|
13703
|
+
}
|
|
13704
|
+
function getLlvmDownloadUrl(version, os, arch) {
|
|
13705
|
+
if (os === "darwin") {
|
|
13706
|
+
if (arch === "arm64") {
|
|
13707
|
+
return `https://github.com/llvm/llvm-project/releases/download/llvmorg-${version}/LLVM-${version}-macOS-ARM64.tar.xz`;
|
|
13708
|
+
}
|
|
13709
|
+
if (arch === "x64") {
|
|
13710
|
+
return `https://github.com/llvm/llvm-project/releases/download/llvmorg-${version}/LLVM-${version}-macOS-X64.tar.xz`;
|
|
13711
|
+
}
|
|
13712
|
+
}
|
|
13713
|
+
if (os === "linux") {
|
|
13714
|
+
if (arch === "x64") {
|
|
13715
|
+
return `https://github.com/llvm/llvm-project/releases/download/llvmorg-${version}/LLVM-${version}-Linux-X64.tar.xz`;
|
|
13716
|
+
}
|
|
13717
|
+
if (arch === "arm64") {
|
|
13718
|
+
return `https://github.com/llvm/llvm-project/releases/download/llvmorg-${version}/LLVM-${version}-Linux-AArch64.tar.xz`;
|
|
13719
|
+
}
|
|
13720
|
+
}
|
|
13721
|
+
return null;
|
|
13722
|
+
}
|
|
13723
|
+
var LLVM_VERSION = "19.1.7";
|
|
13724
|
+
var init_install = __esm(() => {
|
|
13725
|
+
init_registry();
|
|
13726
|
+
init_session();
|
|
13727
|
+
registerCommand("install", async (args) => {
|
|
13728
|
+
const adapter = args.subcommand;
|
|
13729
|
+
if (args.flags.list === true) {
|
|
13730
|
+
const dir = getManagedAdaptersDir();
|
|
13731
|
+
console.log(`Managed adapters directory: ${dir}`);
|
|
13732
|
+
if (!existsSync6(dir)) {
|
|
13733
|
+
console.log(" (empty \u2014 no adapters installed)");
|
|
13734
|
+
return 0;
|
|
13735
|
+
}
|
|
13736
|
+
const entries = Array.from(new Bun.Glob("*").scanSync(dir));
|
|
13737
|
+
if (entries.length === 0) {
|
|
13738
|
+
console.log(" (empty \u2014 no adapters installed)");
|
|
13739
|
+
} else {
|
|
13740
|
+
for (const entry of entries) {
|
|
13741
|
+
console.log(` ${entry}`);
|
|
13742
|
+
}
|
|
13743
|
+
}
|
|
13744
|
+
return 0;
|
|
13745
|
+
}
|
|
13746
|
+
if (!adapter) {
|
|
13747
|
+
console.error("Usage: dbg install <adapter>");
|
|
13748
|
+
console.error(" Supported adapters: lldb");
|
|
13749
|
+
console.error(" Options: --list (show installed adapters)");
|
|
13750
|
+
return 1;
|
|
13751
|
+
}
|
|
13752
|
+
if (adapter !== "lldb") {
|
|
13753
|
+
console.error(`Unknown adapter: ${adapter}`);
|
|
13754
|
+
console.error(" Supported adapters: lldb");
|
|
13755
|
+
return 1;
|
|
13756
|
+
}
|
|
13757
|
+
const { os, arch } = getPlatformArch();
|
|
13758
|
+
const url2 = getLlvmDownloadUrl(LLVM_VERSION, os, arch);
|
|
13759
|
+
if (!url2) {
|
|
13760
|
+
console.error(`Unsupported platform: ${os}-${arch}`);
|
|
13761
|
+
console.error(" Supported: darwin-arm64, darwin-x64, linux-x64, linux-arm64");
|
|
13762
|
+
return 1;
|
|
13763
|
+
}
|
|
13764
|
+
const adaptersDir = getManagedAdaptersDir();
|
|
13765
|
+
const targetPath = join3(adaptersDir, "lldb-dap");
|
|
13766
|
+
if (existsSync6(targetPath)) {
|
|
13767
|
+
console.log(`lldb-dap already installed at ${targetPath}`);
|
|
13768
|
+
console.log(` To reinstall, remove it first: rm ${targetPath}`);
|
|
13769
|
+
return 0;
|
|
13770
|
+
}
|
|
13771
|
+
console.log(`Downloading LLVM ${LLVM_VERSION} for ${os}-${arch}...`);
|
|
13772
|
+
console.log(` From: ${url2}`);
|
|
13773
|
+
const response = await fetch(url2, { redirect: "follow" });
|
|
13774
|
+
if (!response.ok) {
|
|
13775
|
+
console.error(`Download failed: HTTP ${response.status}`);
|
|
13776
|
+
console.error(" -> Check your internet connection or try again later");
|
|
13777
|
+
return 1;
|
|
13778
|
+
}
|
|
13779
|
+
const tarball = await response.arrayBuffer();
|
|
13780
|
+
console.log(`Downloaded ${(tarball.byteLength / 1024 / 1024).toFixed(1)} MB`);
|
|
13781
|
+
mkdirSync2(adaptersDir, { recursive: true });
|
|
13782
|
+
const tmpTar = join3(adaptersDir, "llvm-download.tar.xz");
|
|
13783
|
+
await Bun.write(tmpTar, tarball);
|
|
13784
|
+
console.log("Extracting lldb-dap...");
|
|
13785
|
+
const listResult = Bun.spawnSync(["tar", "-tf", tmpTar], {
|
|
13786
|
+
stdout: "pipe"
|
|
13787
|
+
});
|
|
13788
|
+
const files = listResult.stdout.toString().split(`
|
|
13789
|
+
`);
|
|
13790
|
+
const lldbDapEntry = files.find((f) => f.endsWith("/bin/lldb-dap") || f === "bin/lldb-dap");
|
|
13791
|
+
if (!lldbDapEntry) {
|
|
13792
|
+
Bun.spawnSync(["rm", tmpTar]);
|
|
13793
|
+
console.error("Could not find lldb-dap in the LLVM archive");
|
|
13794
|
+
console.error(` Archive entries searched: ${files.length}`);
|
|
13795
|
+
console.error(" -> Try installing manually: brew install llvm");
|
|
13796
|
+
return 1;
|
|
13797
|
+
}
|
|
13798
|
+
const extractResult = Bun.spawnSync([
|
|
13799
|
+
"tar",
|
|
13800
|
+
"-xf",
|
|
13801
|
+
tmpTar,
|
|
13802
|
+
"-C",
|
|
13803
|
+
adaptersDir,
|
|
13804
|
+
"--strip-components",
|
|
13805
|
+
String(lldbDapEntry.split("/").length - 1),
|
|
13806
|
+
lldbDapEntry
|
|
13807
|
+
], { stdout: "pipe", stderr: "pipe" });
|
|
13808
|
+
Bun.spawnSync(["rm", tmpTar]);
|
|
13809
|
+
if (extractResult.exitCode !== 0) {
|
|
13810
|
+
console.error(`Extraction failed: ${extractResult.stderr.toString()}`);
|
|
13811
|
+
return 1;
|
|
13812
|
+
}
|
|
13813
|
+
const liblldbEntries = files.filter((f) => f.includes("liblldb") && (f.endsWith(".so") || f.endsWith(".dylib")));
|
|
13814
|
+
for (const libEntry of liblldbEntries) {
|
|
13815
|
+
Bun.spawnSync([
|
|
13816
|
+
"tar",
|
|
13817
|
+
"-xf",
|
|
13818
|
+
tmpTar,
|
|
13819
|
+
"-C",
|
|
13820
|
+
adaptersDir,
|
|
13821
|
+
"--strip-components",
|
|
13822
|
+
String(libEntry.split("/").length - 1),
|
|
13823
|
+
libEntry
|
|
13824
|
+
], { stdout: "pipe", stderr: "pipe" });
|
|
13825
|
+
}
|
|
13826
|
+
Bun.spawnSync(["chmod", "+x", targetPath]);
|
|
13827
|
+
if (existsSync6(targetPath)) {
|
|
13828
|
+
console.log(`Installed lldb-dap to ${targetPath}`);
|
|
13829
|
+
return 0;
|
|
13830
|
+
}
|
|
13831
|
+
console.error("Installation failed \u2014 lldb-dap not found after extraction");
|
|
13832
|
+
console.error(" -> Try installing manually: brew install llvm");
|
|
13833
|
+
return 1;
|
|
13834
|
+
});
|
|
13835
|
+
});
|
|
13836
|
+
|
|
13494
13837
|
// src/formatter/logs.ts
|
|
13495
13838
|
function formatTime(ts) {
|
|
13496
13839
|
const d = new Date(ts);
|
|
@@ -13609,7 +13952,7 @@ var init_logs = __esm(() => {
|
|
|
13609
13952
|
var exports_logs = {};
|
|
13610
13953
|
import {
|
|
13611
13954
|
closeSync as closeSync2,
|
|
13612
|
-
existsSync as
|
|
13955
|
+
existsSync as existsSync7,
|
|
13613
13956
|
openSync as openSync2,
|
|
13614
13957
|
readFileSync as readFileSync3,
|
|
13615
13958
|
readSync,
|
|
@@ -13673,7 +14016,7 @@ var init_logs2 = __esm(() => {
|
|
|
13673
14016
|
const isDaemon = args.flags.daemon === true;
|
|
13674
14017
|
const logPath = isDaemon ? getDaemonLogPath(session2) : getLogPath(session2);
|
|
13675
14018
|
if (args.flags.clear === true) {
|
|
13676
|
-
if (
|
|
14019
|
+
if (existsSync7(logPath)) {
|
|
13677
14020
|
writeFileSync4(logPath, "");
|
|
13678
14021
|
console.log(`${isDaemon ? "Daemon log" : "Log"} cleared`);
|
|
13679
14022
|
} else {
|
|
@@ -13681,9 +14024,9 @@ var init_logs2 = __esm(() => {
|
|
|
13681
14024
|
}
|
|
13682
14025
|
return 0;
|
|
13683
14026
|
}
|
|
13684
|
-
if (!
|
|
14027
|
+
if (!existsSync7(logPath)) {
|
|
13685
14028
|
console.error(`No ${isDaemon ? "daemon " : ""}log file for session "${session2}"`);
|
|
13686
|
-
console.error(" -> Try:
|
|
14029
|
+
console.error(" -> Try: dbg launch --brk node app.js");
|
|
13687
14030
|
return 1;
|
|
13688
14031
|
}
|
|
13689
14032
|
const isJson = args.global.json;
|
|
@@ -13748,16 +14091,16 @@ var init_logs2 = __esm(() => {
|
|
|
13748
14091
|
// package.json
|
|
13749
14092
|
var require_package = __commonJS((exports, module) => {
|
|
13750
14093
|
module.exports = {
|
|
13751
|
-
name: "
|
|
13752
|
-
version: "0.2.
|
|
14094
|
+
name: "debug-that",
|
|
14095
|
+
version: "0.2.1",
|
|
13753
14096
|
description: "Node.js Debugger CLI for AI Agents",
|
|
13754
14097
|
license: "MIT",
|
|
13755
14098
|
author: "Theodo Group",
|
|
13756
14099
|
repository: {
|
|
13757
14100
|
type: "git",
|
|
13758
|
-
url: "https://github.com/theodo-group/
|
|
14101
|
+
url: "https://github.com/theodo-group/debug-that.git"
|
|
13759
14102
|
},
|
|
13760
|
-
homepage: "https://github.com/theodo-group/
|
|
14103
|
+
homepage: "https://github.com/theodo-group/debug-that",
|
|
13761
14104
|
keywords: [
|
|
13762
14105
|
"debugger",
|
|
13763
14106
|
"cli",
|
|
@@ -13771,7 +14114,8 @@ var require_package = __commonJS((exports, module) => {
|
|
|
13771
14114
|
],
|
|
13772
14115
|
type: "module",
|
|
13773
14116
|
bin: {
|
|
13774
|
-
"
|
|
14117
|
+
"debug-that": "./dist/main.js",
|
|
14118
|
+
dbg: "./dist/main.js"
|
|
13775
14119
|
},
|
|
13776
14120
|
files: [
|
|
13777
14121
|
"dist",
|
|
@@ -13912,9 +14256,9 @@ async function run(args) {
|
|
|
13912
14256
|
const suggestion = suggestCommand(args.command);
|
|
13913
14257
|
console.error(`\u2717 Unknown command: ${args.command}`);
|
|
13914
14258
|
if (suggestion) {
|
|
13915
|
-
console.error(` \u2192 Did you mean:
|
|
14259
|
+
console.error(` \u2192 Did you mean: dbg ${suggestion}`);
|
|
13916
14260
|
} else {
|
|
13917
|
-
console.error(" \u2192 Try:
|
|
14261
|
+
console.error(" \u2192 Try: dbg --help");
|
|
13918
14262
|
}
|
|
13919
14263
|
return 1;
|
|
13920
14264
|
}
|
|
@@ -13932,7 +14276,7 @@ async function run(args) {
|
|
|
13932
14276
|
}
|
|
13933
14277
|
function printVersion() {
|
|
13934
14278
|
const pkg = require_package();
|
|
13935
|
-
console.log(`
|
|
14279
|
+
console.log(`dbg ${pkg.version}`);
|
|
13936
14280
|
}
|
|
13937
14281
|
function suggestCommand(input) {
|
|
13938
14282
|
let bestMatch = null;
|
|
@@ -13961,9 +14305,9 @@ function editDistance(a, b) {
|
|
|
13961
14305
|
return prev[n] ?? m;
|
|
13962
14306
|
}
|
|
13963
14307
|
function printHelp() {
|
|
13964
|
-
console.log(`
|
|
14308
|
+
console.log(`dbg \u2014 Node.js debugger CLI for AI agents
|
|
13965
14309
|
|
|
13966
|
-
Usage:
|
|
14310
|
+
Usage: dbg <command> [options]
|
|
13967
14311
|
|
|
13968
14312
|
Session:
|
|
13969
14313
|
launch [--brk] <command...> Start + attach debugger
|
|
@@ -13985,7 +14329,7 @@ Inspection:
|
|
|
13985
14329
|
vars [name...] Show local variables
|
|
13986
14330
|
[--frame @fN] [--all-scopes]
|
|
13987
14331
|
stack [--async-depth N] Show call stack
|
|
13988
|
-
[--generated]
|
|
14332
|
+
[--generated] [--filter <keyword>]
|
|
13989
14333
|
eval <expression> Evaluate expression
|
|
13990
14334
|
[--frame @fN] [--silent] [--timeout MS] [--side-effect-free]
|
|
13991
14335
|
props <@ref> Expand object properties
|
|
@@ -13995,6 +14339,7 @@ Inspection:
|
|
|
13995
14339
|
search <query> Search loaded scripts
|
|
13996
14340
|
[--regex] [--case-sensitive] [--file <id>]
|
|
13997
14341
|
scripts [--filter <pattern>] List loaded scripts
|
|
14342
|
+
modules [--filter <pattern>] List loaded modules/libraries (DAP only)
|
|
13998
14343
|
console [--since N] [--level] Console output
|
|
13999
14344
|
[--clear]
|
|
14000
14345
|
exceptions [--since N] Captured exceptions
|
|
@@ -14024,6 +14369,10 @@ Source Maps:
|
|
|
14024
14369
|
sourcemap [file] Show source map info
|
|
14025
14370
|
sourcemap --disable Disable resolution globally
|
|
14026
14371
|
|
|
14372
|
+
Setup:
|
|
14373
|
+
install <adapter> Download managed adapter binary
|
|
14374
|
+
install --list Show installed adapters
|
|
14375
|
+
|
|
14027
14376
|
Diagnostics:
|
|
14028
14377
|
logs [-f|--follow] Show CDP protocol log
|
|
14029
14378
|
[--limit N] [--domain <name>] [--clear]
|
|
@@ -14037,69 +14386,70 @@ Global flags:
|
|
|
14037
14386
|
--version Show version`);
|
|
14038
14387
|
}
|
|
14039
14388
|
function printHelpAgent() {
|
|
14040
|
-
console.log(`
|
|
14389
|
+
console.log(`dbg \u2014 Node.js debugger CLI for AI agents
|
|
14041
14390
|
|
|
14042
14391
|
CORE LOOP:
|
|
14043
|
-
1.
|
|
14044
|
-
2.
|
|
14045
|
-
3.
|
|
14046
|
-
4. Inspect:
|
|
14047
|
-
5. Mutate/fix:
|
|
14392
|
+
1. dbg launch --brk "node app.js" \u2192 pauses at first line, returns state
|
|
14393
|
+
2. dbg break src/file.ts:42 \u2192 set breakpoint
|
|
14394
|
+
3. dbg continue \u2192 run to breakpoint, returns state
|
|
14395
|
+
4. Inspect: dbg vars, dbg eval, dbg props @v1
|
|
14396
|
+
5. Mutate/fix: dbg set @v1 value, dbg hotpatch src/file.ts
|
|
14048
14397
|
6. Repeat from 3
|
|
14049
14398
|
|
|
14050
14399
|
REFS: Every output assigns @refs. Use them everywhere:
|
|
14051
|
-
@v1..@vN variables |
|
|
14052
|
-
@f0..@fN stack frames |
|
|
14053
|
-
BP#1..N breakpoints |
|
|
14400
|
+
@v1..@vN variables | dbg props @v1, dbg set @v2 true
|
|
14401
|
+
@f0..@fN stack frames | dbg eval --frame @f1
|
|
14402
|
+
BP#1..N breakpoints | dbg break-rm BP#1, dbg break-toggle BP#1
|
|
14054
14403
|
|
|
14055
14404
|
EXECUTION (all return state automatically):
|
|
14056
|
-
|
|
14057
|
-
|
|
14058
|
-
|
|
14059
|
-
|
|
14060
|
-
|
|
14405
|
+
dbg continue Resume to next breakpoint
|
|
14406
|
+
dbg step [over|into|out] Step one statement
|
|
14407
|
+
dbg run-to file:line Continue to location
|
|
14408
|
+
dbg pause Interrupt running process
|
|
14409
|
+
dbg restart-frame [@fN] Re-run frame from beginning
|
|
14061
14410
|
|
|
14062
14411
|
BREAKPOINTS:
|
|
14063
|
-
|
|
14064
|
-
|
|
14065
|
-
|
|
14066
|
-
|
|
14067
|
-
|
|
14068
|
-
|
|
14069
|
-
|
|
14070
|
-
|
|
14412
|
+
dbg break file:line [--condition expr] [--hit-count N] [--continue]
|
|
14413
|
+
dbg break --pattern "regex":line
|
|
14414
|
+
dbg break-rm <BP#|all> Remove breakpoints
|
|
14415
|
+
dbg break-ls List breakpoints
|
|
14416
|
+
dbg break-toggle <BP#|all> Enable/disable breakpoints
|
|
14417
|
+
dbg breakable file:start-end Valid breakpoint locations
|
|
14418
|
+
dbg logpoint file:line "template \${var}" [--condition expr]
|
|
14419
|
+
dbg catch [all|uncaught|caught|none]
|
|
14071
14420
|
|
|
14072
14421
|
INSPECTION:
|
|
14073
|
-
|
|
14074
|
-
|
|
14075
|
-
|
|
14076
|
-
|
|
14077
|
-
|
|
14078
|
-
|
|
14079
|
-
|
|
14080
|
-
|
|
14081
|
-
|
|
14082
|
-
|
|
14422
|
+
dbg state [-v|-s|-b|-c] [--depth N] [--lines N] [--frame @fN] [--all-scopes] [--compact] [--generated]
|
|
14423
|
+
dbg vars [name...] [--frame @fN] [--all-scopes]
|
|
14424
|
+
dbg stack [--async-depth N] [--generated] [--filter <keyword>]
|
|
14425
|
+
dbg eval <expr> [--frame @fN] [--silent] [--timeout MS] [--side-effect-free]
|
|
14426
|
+
dbg props @ref [--own] [--depth N] [--private] [--internal]
|
|
14427
|
+
dbg modules [--filter <pattern>] (DAP only: list loaded libraries with symbol status)
|
|
14428
|
+
dbg source [--lines N] [--file path] [--all] [--generated]
|
|
14429
|
+
dbg search "query" [--regex] [--case-sensitive] [--file id]
|
|
14430
|
+
dbg scripts [--filter pattern]
|
|
14431
|
+
dbg console [--since N] [--level type] [--clear]
|
|
14432
|
+
dbg exceptions [--since N]
|
|
14083
14433
|
|
|
14084
14434
|
MUTATION:
|
|
14085
|
-
|
|
14086
|
-
|
|
14087
|
-
|
|
14435
|
+
dbg set <@ref|name> <value> Change variable
|
|
14436
|
+
dbg set-return <value> Change return value (at return point)
|
|
14437
|
+
dbg hotpatch <file> [--dry-run] Live-edit code (no restart!)
|
|
14088
14438
|
|
|
14089
14439
|
BLACKBOXING:
|
|
14090
|
-
|
|
14091
|
-
|
|
14092
|
-
|
|
14440
|
+
dbg blackbox <pattern...> Skip stepping into matching scripts
|
|
14441
|
+
dbg blackbox-ls List current patterns
|
|
14442
|
+
dbg blackbox-rm <pattern|all> Remove patterns
|
|
14093
14443
|
|
|
14094
14444
|
SOURCE MAPS:
|
|
14095
|
-
|
|
14096
|
-
|
|
14445
|
+
dbg sourcemap [file] Show source map info
|
|
14446
|
+
dbg sourcemap --disable Disable resolution globally
|
|
14097
14447
|
|
|
14098
14448
|
DIAGNOSTICS:
|
|
14099
|
-
|
|
14100
|
-
|
|
14101
|
-
|
|
14102
|
-
|
|
14449
|
+
dbg logs [-f|--follow] Show CDP protocol log
|
|
14450
|
+
dbg logs --limit 100 Show last N entries (default: 50)
|
|
14451
|
+
dbg logs --domain Debugger Filter by CDP domain
|
|
14452
|
+
dbg logs --clear Clear the log file`);
|
|
14103
14453
|
}
|
|
14104
14454
|
var GLOBAL_FLAGS, BOOLEAN_FLAGS;
|
|
14105
14455
|
var init_parser = __esm(() => {
|
|
@@ -14163,6 +14513,7 @@ if (process.argv.includes("--daemon")) {
|
|
|
14163
14513
|
await Promise.resolve().then(() => (init_catch(), exports_catch));
|
|
14164
14514
|
await Promise.resolve().then(() => (init_source2(), exports_source));
|
|
14165
14515
|
await Promise.resolve().then(() => (init_scripts(), exports_scripts));
|
|
14516
|
+
await Promise.resolve().then(() => (init_modules(), exports_modules));
|
|
14166
14517
|
await Promise.resolve().then(() => (init_stack2(), exports_stack));
|
|
14167
14518
|
await Promise.resolve().then(() => (init_search(), exports_search));
|
|
14168
14519
|
await Promise.resolve().then(() => (init_console(), exports_console));
|
|
@@ -14180,6 +14531,7 @@ if (process.argv.includes("--daemon")) {
|
|
|
14180
14531
|
await Promise.resolve().then(() => (init_breakable(), exports_breakable));
|
|
14181
14532
|
await Promise.resolve().then(() => (init_restart_frame(), exports_restart_frame));
|
|
14182
14533
|
await Promise.resolve().then(() => (init_sourcemap(), exports_sourcemap));
|
|
14534
|
+
await Promise.resolve().then(() => (init_install(), exports_install));
|
|
14183
14535
|
await Promise.resolve().then(() => (init_logs2(), exports_logs));
|
|
14184
14536
|
const { parseArgs: parseArgs2, run: run2 } = await Promise.resolve().then(() => (init_parser(), exports_parser));
|
|
14185
14537
|
const args = parseArgs2(process.argv.slice(2));
|