"CLI-Anything: Making ALL Software Agent-Native" -- CLI-Hub: https://clianything.cc/
Python
feat: add lldb dap stop rule profiles
aimidif7730069198f
diff --git a/lldb/agent-harness/HARNESS.md b/lldb/agent-harness/HARNESS.mdindex cc4ef5ae6..fdd21a539 100644--- a/lldb/agent-harness/HARNESS.md+++ b/lldb/agent-harness/HARNESS.md@@ -79,6 +79,16 @@ Variable references are adapter-local and reset on resume. This keeps stoppedframe state honest for AI agents and avoids reusing stale LLDB `SBValue`objects after execution continues.+Long-running GUI targets can provide DAP stop-rule profiles either with+`cli-anything-lldb-dap --profile PATH`, `cli-anything-lldb dap --profile PATH`,+or launch/attach arguments such as `stopRuleProfile` and inline `stopRules`.+Rules match structured stop context (`reason`, `module`, `function`, `regex`)+and either classify the stop or auto-continue it. Stopped events expose+`body.cliAnythingStop.origin` so clients can distinguish manual pauses,+debugger-internal traps, and ordinary debuggee stops. Profiles are loaded by the+current adapter process only; running DAP sessions must restart and re-attach or+re-launch before new code/profile contents take effect.+## Patterns1. **Lazy import of LLDB**:@@ -97,6 +107,10 @@ objects after execution continues.7. **Secure persistent daemon**:CLI session auth state is written under a per-user directory with restrictivepermissions and RPC dispatch uses an explicit method allowlist.+8. **Structured stop classification**:+ DAP stop handling uses profile-driven rules instead of ad hoc substring+ checks, while preserving `autoContinueInternalBreakpoints` as a compatibility+ shortcut for common NVIDIA/Windows internal traps.## Dependency Modeldiff --git a/lldb/agent-harness/LLDB.md b/lldb/agent-harness/LLDB.mdindex 41c3dcc71..1ffd6b329 100644--- a/lldb/agent-harness/LLDB.md+++ b/lldb/agent-harness/LLDB.md@@ -29,6 +29,7 @@ This is implemented in `utils/lldb_backend.py`.All core operations return plain dictionaries:- process info (`pid`, `state`, `num_threads`)+- stop info (`reason`, `description`, `module`, `function`, `frame`)- frame info (`function`, `file`, `line`, `address`)- breakpoints (`id`, `locations`, `condition`)- expression result (`type`, `value`, `summary`, `error`)diff --git a/lldb/agent-harness/cli_anything/lldb/README.md b/lldb/agent-harness/cli_anything/lldb/README.mdindex 2ec0c393a..e97fbe06d 100644--- a/lldb/agent-harness/cli_anything/lldb/README.md+++ b/lldb/agent-harness/cli_anything/lldb/README.md@@ -91,12 +91,14 @@ Run the formal stdio DAP server with:```bashcli-anything-lldb-dap+cli-anything-lldb-dap --profile /path/to/stop-rules.json```or through the CLI convenience command:```bashcli-anything-lldb dap+cli-anything-lldb dap --profile /path/to/stop-rules.json```The DAP server owns one in-process `LLDBSession` and writes only DAP frames to@@ -126,12 +128,43 @@ requests an async interrupt, waits for the continue thread to observe a stoppedstate, and only then mutates LLDB breakpoints. If the process does not stop intime, the request fails clearly instead of hanging the DAP loop.-`launch` and `attach` accept the non-standard boolean argument-`autoContinueInternalBreakpoints`. When enabled, the adapter auto-continues-known internal JIT/startup breakpoint stops such as NVIDIA-`__jit_debug_register_code` / `jit-debug-register` and Windows-`Exception 0x80000003` at ``ntdll.dll`DbgBreakPoint``, while writing a DAP-`output` event explaining the auto-continue.+`launch` and `attach` accept non-standard stop-rule controls for noisy GUI+debuggees:++- `autoContinueInternalBreakpoints`: compatibility boolean that enables built-in+ rules for NVIDIA `__jit_debug_register_code` / `jit-debug-register` and+ Windows `Exception 0x80000003` at ``ntdll.dll`DbgBreakPoint``.+- `stopRules`: inline structured rules with optional `name`, `action`+ (`stop` or `continue`), `origin`, `reason`, `module`, `function`, and `regex`.+ Each rule must include at least one matcher, so a profile cannot accidentally+ classify every stop.+- `stopRuleProfile` / `stopProfile` / `profile`: external JSON profile path+ loaded for that launch/attach request.++The DAP process also accepts `--profile` to load a base profile at adapter+startup. Profiles are JSON objects such as:++```json+{+ "autoContinueInternalBreakpoints": true,+ "stopRules": [+ {+ "name": "c4d-nvidia-jit",+ "action": "continue",+ "origin": "internalTrap",+ "module": "nvgpucomp64.dll",+ "function": "__jit_debug_register_code"+ }+ ]+}+```++Every DAP `stopped` event includes `body.cliAnythingStop` with+`origin` (`manualPause`, `internalTrap`, or `debuggee`), LLDB stop reason,+module/function/frame metadata, and the matched rule when applicable. Running+`cli-anything-lldb-dap` processes do not hot-load code or profile changes;+restart the adapter and re-attach/re-launch the target for new rules to take+effect.The persistent session daemon now speaks a localhost JSON socket protocol andstores its session token in an owner-scoped state file. `memory find` scans indiff --git a/lldb/agent-harness/cli_anything/lldb/core/session.py b/lldb/agent-harness/cli_anything/lldb/core/session.pyindex 3ea6eccb0..f0619353c 100644--- a/lldb/agent-harness/cli_anything/lldb/core/session.py+++ b/lldb/agent-harness/cli_anything/lldb/core/session.py@@ -580,14 +580,18 @@ class LLDBSession:def _stop_info(self, thread) -> Dict[str, Any]:if thread is None or not thread.IsValid():- return {"reason": None, "description": None, "hit_breakpoint_ids": []}+ return {"reason": None, "description": None, "hit_breakpoint_ids": [], "frame": None}reason = thread.GetStopReason()reason_name = self._stop_reason_name(reason)+ frame = self._thread_frame_summary(thread)return {"reason": reason_name,"description": self._thread_stop_description(thread),"hit_breakpoint_ids": self._hit_breakpoint_ids(thread) if reason_name == "breakpoint" else [],+ "frame": frame,+ "module": frame.get("module") if frame else None,+ "function": frame.get("function") if frame else None,}def _stop_reason_name(self, reason: int) -> str | None:@@ -612,6 +616,24 @@ class LLDBSession:text = stream.GetData().strip()return text or None+ def _thread_frame_summary(self, thread) -> Dict[str, Any] | None:+ frame = thread.GetSelectedFrame()+ if not frame or not frame.IsValid():+ if thread.GetNumFrames() <= 0:+ return None+ frame = thread.GetFrameAtIndex(0)+ line_entry = frame.GetLineEntry()+ module = frame.GetModule()+ module_path = self._filespec_path(module.GetFileSpec()) if module and module.IsValid() else None+ return {+ "function": frame.GetFunctionName(),+ "module": os.path.basename(module_path) if module_path else None,+ "module_path": module_path,+ "file": str(line_entry.GetFileSpec()) if line_entry.IsValid() else None,+ "line": line_entry.GetLine() if line_entry.IsValid() else None,+ "address": hex(frame.GetPC()),+ }+def _hit_breakpoint_ids(self, thread) -> List[int]:ids = []data_count = thread.GetStopReasonDataCount()diff --git a/lldb/agent-harness/cli_anything/lldb/dap.py b/lldb/agent-harness/cli_anything/lldb/dap.pyindex 94468ac16..93e312682 100644--- a/lldb/agent-harness/cli_anything/lldb/dap.py+++ b/lldb/agent-harness/cli_anything/lldb/dap.py@@ -6,9 +6,11 @@ import argparseimport base64import jsonimport os+import reimport shleximport sysimport threading+from dataclasses import dataclassfrom pathlib import Pathfrom typing import Any, BinaryIO, Callable@@ -65,10 +67,123 @@ def _raise_protocol_error(message: str):raise DAPProtocolError(message)+@dataclass(frozen=True)+class StopRule:+ """Structured rule used to classify or auto-continue debugger stops."""++ name: str+ action: str = "stop"+ origin: str = "internalTrap"+ reason: str | None = None+ module: str | None = None+ function: str | None = None+ regex: str | None = None+ source: str | None = None++ @classmethod+ def from_mapping(cls, raw: dict[str, Any], *, source: str) -> "StopRule":+ if not isinstance(raw, dict):+ raise RuntimeError("stopRules entries must be objects")+ name = str(raw.get("name") or raw.get("id") or "unnamed-stop-rule")+ action = str(raw.get("action") or "stop")+ if action not in {"stop", "continue"}:+ raise RuntimeError(f"Unsupported stop rule action for {name}: {action}")+ regex = raw.get("regex")+ if regex is not None:+ try:+ re.compile(str(regex))+ except re.error as exc:+ raise RuntimeError(f"Invalid stop rule regex for {name}: {exc}") from exc+ if not any(raw.get(key) is not None for key in ("reason", "module", "function", "regex")):+ raise RuntimeError(f"Stop rule {name} must include reason, module, function, or regex")+ return cls(+ name=name,+ action=action,+ origin=str(raw.get("origin") or "internalTrap"),+ reason=str(raw["reason"]) if raw.get("reason") is not None else None,+ module=str(raw["module"]) if raw.get("module") is not None else None,+ function=str(raw["function"]) if raw.get("function") is not None else None,+ regex=str(regex) if regex is not None else None,+ source=source,+ )++ def matches(self, stop_context: dict[str, Any]) -> bool:+ if self.reason and not _stop_field_matches(self.reason, [stop_context.get("reason"), stop_context.get("lldbReason")]):+ return False+ if self.module and not _stop_field_matches(+ self.module,+ [stop_context.get("module"), stop_context.get("modulePath")],+ allow_basename=True,+ ):+ return False+ if self.function and not _stop_field_matches(+ self.function,+ [stop_context.get("function")],+ allow_symbol_suffix=True,+ ):+ return False+ if self.regex and not re.search(self.regex, _stop_context_text(stop_context), re.IGNORECASE):+ return False+ return True++ def to_dap(self) -> dict[str, Any]:+ return {+ "name": self.name,+ "action": self.action,+ "origin": self.origin,+ "source": self.source,+ }+++def _stop_field_matches(+ expected: str,+ values: list[Any],+ *,+ allow_basename: bool = False,+ allow_symbol_suffix: bool = False,+) -> bool:+ expected_norm = expected.casefold()+ for value in values:+ if value is None:+ continue+ text = str(value)+ candidates = [text.casefold()]+ if allow_basename:+ candidates.append(Path(text).name.casefold())+ for candidate in candidates:+ if candidate == expected_norm:+ return True+ if allow_symbol_suffix and (+ candidate.endswith(f"::{expected_norm}") or candidate.endswith(f"`{expected_norm}")+ ):+ return True+ return False+++def _stop_context_text(stop_context: dict[str, Any]) -> str:+ fields = [+ stop_context.get("reason"),+ stop_context.get("lldbReason"),+ stop_context.get("description"),+ stop_context.get("module"),+ stop_context.get("modulePath"),+ stop_context.get("function"),+ ]+ frame = stop_context.get("frame")+ if isinstance(frame, dict):+ fields.extend(frame.get(key) for key in ("module", "module_path", "function", "file", "address"))+ return "\n".join(str(field) for field in fields if field)++class LLDBDebugAdapter:"""Single-session stdio DAP adapter for LLDB."""- def __init__(self, session_factory: Callable[[], LLDBSession] = LLDBSession, log_file: str | None = None):+ def __init__(+ self,+ session_factory: Callable[[], LLDBSession] = LLDBSession,+ log_file: str | None = None,+ profile_file: str | None = None,+ ):self._session_factory = session_factoryself._session: LLDBSession | None = Noneself._out: BinaryIO | None = None@@ -86,8 +201,16 @@ class LLDBDebugAdapter:self._continue_state = threading.Condition()self._continue_active = Falseself._auto_continue_internal_breakpoints = False+ self._base_auto_continue_internal_breakpoints = False+ self._base_stop_rules: list[StopRule] = []+ self._active_stop_rules: list[StopRule] = []self._pause_requested = Falseself._mutation_stop_timeout = 10.0+ if profile_file:+ self._base_stop_rules, self._base_auto_continue_internal_breakpoints = self._load_stop_profile_file(+ profile_file+ )+ self._active_stop_rules = list(self._base_stop_rules)def run(self, instream: BinaryIO | None = None, outstream: BinaryIO | None = None) -> int:instream = instream or sys.stdin.buffer@@ -165,7 +288,7 @@ class LLDBDebugAdapter:"stop_at_entry": bool(args.get("stopOnEntry", False)),"suppress_stdio": True,}- self._auto_continue_internal_breakpoints = bool(args.get("autoContinueInternalBreakpoints", False))+ self._configure_stop_rules(args)self._pending_attach = Nonereturn {}, None@@ -183,7 +306,7 @@ class LLDBDebugAdapter:"name": str(name) if name else None,"wait_for": bool(args.get("waitFor", False)),}- self._auto_continue_internal_breakpoints = bool(args.get("autoContinueInternalBreakpoints", False))+ self._configure_stop_rules(args)self._pending_launch = Nonereturn {}, None@@ -532,6 +655,67 @@ class LLDBDebugAdapter:return interrupt()return session.interrupt()+ def _configure_stop_rules(self, args: dict[str, Any]):+ rules = list(self._base_stop_rules)+ auto_continue = self._base_auto_continue_internal_breakpoints or bool(+ args.get("autoContinueInternalBreakpoints", False)+ )+ profile_path = args.get("stopRuleProfile") or args.get("stopProfile") or args.get("profile")+ if profile_path:+ profile_rules, profile_auto_continue = self._load_stop_profile_file(str(profile_path))+ rules.extend(profile_rules)+ auto_continue = auto_continue or profile_auto_continue+ inline_rules = args.get("stopRules")+ if inline_rules:+ rules.extend(self._coerce_stop_rules(inline_rules, source="dap-arguments"))+ if auto_continue:+ rules.extend(self._builtin_internal_stop_rules())+ self._auto_continue_internal_breakpoints = auto_continue+ self._active_stop_rules = rules++ def _load_stop_profile_file(self, profile_file: str) -> tuple[list[StopRule], bool]:+ profile_path = Path(profile_file).expanduser().resolve()+ try:+ payload = json.loads(profile_path.read_text(encoding="utf-8"))+ except OSError as exc:+ raise RuntimeError(f"Failed to read stop rule profile {profile_path}: {exc}") from exc+ except json.JSONDecodeError as exc:+ raise RuntimeError(f"Invalid stop rule profile JSON {profile_path}: {exc}") from exc++ auto_continue = False+ if isinstance(payload, list):+ rules_payload = payload+ elif isinstance(payload, dict):+ auto_continue = bool(payload.get("autoContinueInternalBreakpoints", False))+ rules_payload = payload.get("stopRules", [])+ else:+ raise RuntimeError("Stop rule profile must be a JSON object or array")+ return self._coerce_stop_rules(rules_payload, source=str(profile_path)), auto_continue++ def _coerce_stop_rules(self, raw_rules: Any, *, source: str) -> list[StopRule]:+ if not isinstance(raw_rules, list):+ raise RuntimeError("stopRules must be a list")+ return [StopRule.from_mapping(raw_rule, source=source) for raw_rule in raw_rules]++ def _builtin_internal_stop_rules(self) -> list[StopRule]:+ return [+ StopRule(+ name="nvidia-shader-jit-debug-register",+ action="continue",+ origin="internalTrap",+ reason="breakpoint",+ regex=r"(__jit_debug_register_code|jit-debug-register)",+ source="builtin:autoContinueInternalBreakpoints",+ ),+ StopRule(+ name="windows-debugger-startup-breakpoint",+ action="continue",+ origin="internalTrap",+ regex=r"(Exception 0x80000003|ntdll\.dll`DbgBreakPoint|DbgBreakPoint)",+ source="builtin:autoContinueInternalBreakpoints",+ ),+ ]+def _emit_execution_event(self, default_reason: str | None = None):info = self._ensure_session().process_info()state = info.get("state")@@ -547,29 +731,62 @@ class LLDBDebugAdapter:returnstop = info.get("stop") or {}- reason = "entry" if default_reason == "entry" else (stop.get("reason") or default_reason or "pause")+ lldb_reason = stop.get("reason")+ reason = "entry" if default_reason == "entry" else (lldb_reason or default_reason or "pause")if reason in {"signal", "crashed"}:reason = "exception"+ stop_origin = "debuggee"if self._pause_requested:self._pause_requested = Falsereason = "pause"+ stop_origin = "manualPause"++ frame = stop.get("frame") if isinstance(stop.get("frame"), dict) else {}+ stop_context = {+ "reason": reason,+ "lldbReason": lldb_reason,+ "description": stop.get("description"),+ "module": stop.get("module") or frame.get("module"),+ "modulePath": frame.get("module_path"),+ "function": stop.get("function") or frame.get("function"),+ "frame": frame,+ }+ matched_rule = None if stop_origin == "manualPause" else self._match_stop_rule(stop_context)+ if matched_rule is not None:+ stop_origin = matched_rule.origin+body = {"reason": reason,"threadId": info.get("selected_thread_id"),"allThreadsStopped": True,+ "cliAnythingStop": {+ "origin": stop_origin,+ "lldbReason": lldb_reason,+ "module": stop_context["module"],+ "modulePath": stop_context["modulePath"],+ "function": stop_context["function"],+ "description": stop_context["description"],+ },}+ if frame:+ body["cliAnythingStop"]["frame"] = frame+ if matched_rule is not None:+ body["cliAnythingStop"]["matchedRule"] = matched_rule.to_dap()hit_ids = stop.get("hit_breakpoint_ids") or []if hit_ids:body["hitBreakpointIds"] = hit_idsif stop.get("description"):body["description"] = stop["description"]body["text"] = stop["description"]- if self._should_auto_continue_internal_stop(body):+ if matched_rule is not None and matched_rule.action == "continue":self._send_event("output",{"category": "console",- "output": f"auto-continued internal breakpoint: {self._summarize_stop(body)}\n",+ "output": (+ f"auto-continued stop rule {matched_rule.name}: "+ f"{self._summarize_stop(body)}\n"+ ),},)self._send_continued_event(info.get("selected_thread_id"))@@ -580,17 +797,11 @@ class LLDBDebugAdapter:returnself._send_event("stopped", body)- def _should_auto_continue_internal_stop(self, body: dict[str, Any]) -> bool:- if not self._auto_continue_internal_breakpoints:- return False- if body.get("reason") == "pause":- return False- text = str(body.get("description") or body.get("text") or "")- if "jit-debug-register" in text or "__jit_debug_register_code" in text:- return True- if "Exception 0x80000003" in text and "ntdll.dll`DbgBreakPoint" in text:- return True- return False+ def _match_stop_rule(self, stop_context: dict[str, Any]) -> StopRule | None:+ for rule in self._active_stop_rules:+ if rule.matches(stop_context):+ return rule+ return Nonedef _summarize_stop(self, body: dict[str, Any]) -> str:text = str(body.get("description") or body.get("text") or body.get("reason") or "unknown")@@ -771,8 +982,9 @@ class LLDBDebugAdapter:def main(argv: list[str] | None = None) -> int:parser = argparse.ArgumentParser(description="Run cli-anything-lldb Debug Adapter Protocol server")parser.add_argument("--log-file", default=None, help="Optional file for adapter diagnostics")+ parser.add_argument("--profile", default=None, help="Optional stop-rule profile JSON loaded at adapter startup")args = parser.parse_args(argv)- adapter = LLDBDebugAdapter(log_file=args.log_file)+ adapter = LLDBDebugAdapter(log_file=args.log_file, profile_file=args.profile)return adapter.run()diff --git a/lldb/agent-harness/cli_anything/lldb/lldb_cli.py b/lldb/agent-harness/cli_anything/lldb/lldb_cli.pyindex 224d8c261..962f792dc 100644--- a/lldb/agent-harness/cli_anything/lldb/lldb_cli.py+++ b/lldb/agent-harness/cli_anything/lldb/lldb_cli.py@@ -583,11 +583,18 @@ def core_load(ctx, core_path: str):@cli.command("dap")-def dap_server():[email protected]("--log-file", default=None, type=click.Path(dir_okay=False), help="Optional file for adapter diagnostics.")[email protected]("--profile", default=None, type=click.Path(exists=True, dir_okay=False), help="Stop-rule profile JSON.")+def dap_server(log_file: str | None, profile: str | None):"""Run a stdio Debug Adapter Protocol server."""from cli_anything.lldb.dap import main as dap_main- dap_main([])+ args = []+ if log_file:+ args.extend(["--log-file", log_file])+ if profile:+ args.extend(["--profile", profile])+ dap_main(args)# ===========================================================================diff --git a/lldb/agent-harness/cli_anything/lldb/skills/SKILL.md b/lldb/agent-harness/cli_anything/lldb/skills/SKILL.mdindex 65e80a565..563c28e39 100644--- a/lldb/agent-harness/cli_anything/lldb/skills/SKILL.md+++ b/lldb/agent-harness/cli_anything/lldb/skills/SKILL.md@@ -53,12 +53,14 @@ instead of shelling out separate CLI commands:```bashcli-anything-lldb-dap+cli-anything-lldb-dap --profile /path/to/stop-rules.json```or:```bashcli-anything-lldb dap+cli-anything-lldb dap --profile /path/to/stop-rules.json```The DAP server speaks stdio `Content-Length` frames and must have exclusive@@ -85,6 +87,18 @@ For GUI apps that stop on debugger-internal startup or shader-JIT breakpoints,`launch` and `attach` accept the non-standard boolean argument`autoContinueInternalBreakpoints`. Enable it only when those internal stops arenoise for the task; the adapter emits an `output` event before auto-continuing.+For target-specific noise, prefer structured stop rules through inline+`stopRules` or an external `stopRuleProfile`/`--profile` JSON file. Rules can+match by `reason`, `module`, `function`, and/or `regex`, then either `stop` with+clear `cliAnythingStop.origin` metadata or `continue` automatically. Use+profiles for apps such as C4D so their NVIDIA shader-JIT/startup traps live+outside the generic adapter.++DAP `stopped` events include `body.cliAnythingStop.origin`: `manualPause` for a+client pause request, `internalTrap` for a matched internal rule, and `debuggee`+for ordinary program stops. Existing `cli-anything-lldb-dap` processes do not+hot-load new code or profile contents; restart the adapter and re-attach or+re-launch before expecting new rules to apply.## Command Groups@@ -148,6 +162,7 @@ cli-anything-lldb --json core load --path /path/to/core- DAP unresolved breakpoints use protocol semantics: `verified: false` until resolved.- DAP `continue` is non-blocking for long-running GUI processes, and DAP `pause` uses async interrupt.- DAP breakpoint changes during an active continue first interrupt and wait for a stopped state before mutating LLDB.+- Use DAP stop-rule profiles for app-specific internal traps; restart and re-attach/re-launch after profile changes.- `memory find` uses a chunked scan capped at 1 MiB per call.- Call `target create` before process or core commands.- Expect structured errors: `{"error": "...", "type": "..."}`diff --git a/lldb/agent-harness/cli_anything/lldb/tests/TEST.md b/lldb/agent-harness/cli_anything/lldb/tests/TEST.mdindex e2ec7c697..230dcf7c9 100644--- a/lldb/agent-harness/cli_anything/lldb/tests/TEST.md+++ b/lldb/agent-harness/cli_anything/lldb/tests/TEST.md@@ -46,6 +46,9 @@- Validate DAP breakpoint mutation during an active continue requests async interrupt and waits for stopped state- Validate DAP breakpoint mutation reports a clear timeout when the target does not stop- Validate DAP auto-continues known internal JIT/startup breakpoint stops when explicitly enabled+- Validate structured DAP stop rules can match by module/function/reason/regex and classify internal traps+- Validate external DAP stop-rule profile files inject target-specific auto-continue rules+- Validate DAP stopped events distinguish manual pauses, internal traps, and ordinary debuggee stops- Validate DAP transcript response/event ordering for initialize, launch, breakpoint setup, and configuration completion- Validate DAP `modules` and `exceptionInfo` response shapes- Validate DAP `readMemory` base64 encoding and expandable variable references@@ -160,9 +163,9 @@ python -m pytest cli_anything/lldb/tests -q### Result summary-- `test_core.py`: 44 passed+- `test_core.py`: 46 passed- `test_full_e2e.py`: 7 passed, 2 warnings from LLDB SWIG bindings-- combined default run: 51 passed, 2 warnings from LLDB SWIG bindings+- combined default run: 53 passed, 2 warnings from LLDB SWIG bindings- skip situation: 0 skipped in the current local run; older runs could skip the optional core-load negative-path scenario when `LLDB_TEST_CORE` was unset, but the fixture now creates a local placeholder core path for that negative-path test### Notes@@ -183,3 +186,4 @@ python -m pytest cli_anything/lldb/tests -q- Added DAP `loadedSources` and `readMemory` coverage while keeping the harness at version 1.0.0- Added DAP variable child expansion, `setVariable`, `modules`, `exceptionInfo`, and transcript ordering coverage while keeping the harness at version 1.0.0- Added non-blocking DAP continue, async pause, guarded running-state breakpoint mutation, and internal breakpoint auto-continue coverage+- Added DAP structured stop-rule profile coverage and `cliAnythingStop` stopped-event metadata for manual pause vs internal trap classificationdiff --git a/lldb/agent-harness/cli_anything/lldb/tests/test_core.py b/lldb/agent-harness/cli_anything/lldb/tests/test_core.pyindex 01558952f..d4b3338de 100644--- a/lldb/agent-harness/cli_anything/lldb/tests/test_core.py+++ b/lldb/agent-harness/cli_anything/lldb/tests/test_core.py@@ -200,6 +200,7 @@ class TestDAPProtocol:assert response["success"] is Trueassert event["event"] == "stopped"assert event["body"]["reason"] == "pause"+ assert event["body"]["cliAnythingStop"]["origin"] == "manualPause"fake_session.interrupt_async.assert_called_once()def test_set_breakpoints_interrupts_active_continue_before_mutation(self):@@ -276,7 +277,7 @@ class TestDAPProtocol:out = io.BytesIO()adapter = LLDBDebugAdapter(session_factory=lambda: fake_session)adapter._out = out- adapter._auto_continue_internal_breakpoints = True+ adapter._configure_stop_rules({"autoContinueInternalBreakpoints": True})adapter._start_continue_thread = MagicMock()adapter._emit_execution_event(default_reason="breakpoint")@@ -286,11 +287,111 @@ class TestDAPProtocol:stopped_event = read_message(out)assert output_event["event"] == "output"- assert "auto-continued internal breakpoint" in output_event["body"]["output"]+ assert "auto-continued stop rule nvidia-shader-jit-debug-register" in output_event["body"]["output"]assert continued_event["event"] == "continued"assert stopped_event is Noneadapter._start_continue_thread.assert_called_once()+ def test_stop_rule_profile_can_auto_continue_structured_internal_stop(self, tmp_path: Path):+ from cli_anything.lldb.dap import LLDBDebugAdapter, read_message++ profile = tmp_path / "c4d-stop-rules.json"+ profile.write_text(+ json.dumps(+ {+ "stopRules": [+ {+ "name": "c4d-nvidia-jit",+ "action": "continue",+ "origin": "internalTrap",+ "module": "nvgpucomp64.dll",+ "function": "__jit_debug_register_code",+ }+ ]+ }+ ),+ encoding="utf-8",+ )+ fake_session = MagicMock()+ fake_session.process_info.return_value = {+ "state": "stopped",+ "selected_thread_id": 99,+ "stop": {+ "reason": "breakpoint",+ "description": "driver JIT registration",+ "hit_breakpoint_ids": [],+ "frame": {+ "module": "nvgpucomp64.dll",+ "module_path": "C:/Windows/System32/DriverStore/nvgpucomp64.dll",+ "function": "__jit_debug_register_code",+ },+ },+ "exit_status": 0,+ }+ out = io.BytesIO()+ adapter = LLDBDebugAdapter(session_factory=lambda: fake_session, profile_file=str(profile))+ adapter._out = out+ adapter._configure_stop_rules({})+ adapter._start_continue_thread = MagicMock()++ adapter._emit_execution_event(default_reason="breakpoint")+ out.seek(0)+ output_event = read_message(out)+ continued_event = read_message(out)+ stopped_event = read_message(out)++ assert "auto-continued stop rule c4d-nvidia-jit" in output_event["body"]["output"]+ assert continued_event["event"] == "continued"+ assert stopped_event is None+ adapter._start_continue_thread.assert_called_once()++ def test_structured_stop_rule_marks_internal_trap_without_continuing(self):+ from cli_anything.lldb.dap import LLDBDebugAdapter, read_message++ fake_session = MagicMock()+ fake_session.process_info.return_value = {+ "state": "stopped",+ "selected_thread_id": 99,+ "stop": {+ "reason": "exception",+ "description": "Exception 0x80000003 at ntdll.dll`DbgBreakPoint",+ "hit_breakpoint_ids": [],+ "module": "ntdll.dll",+ "function": "DbgBreakPoint",+ },+ "exit_status": 0,+ }+ out = io.BytesIO()+ adapter = LLDBDebugAdapter(session_factory=lambda: fake_session)+ adapter._out = out+ adapter._configure_stop_rules(+ {+ "stopRules": [+ {+ "name": "windows-startup-trap",+ "action": "stop",+ "origin": "internalTrap",+ "reason": "exception",+ "module": "ntdll.dll",+ "regex": "DbgBreakPoint",+ }+ ]+ }+ )+ adapter._start_continue_thread = MagicMock()++ adapter._emit_execution_event(default_reason="breakpoint")+ out.seek(0)+ stopped_event = read_message(out)++ assert stopped_event["event"] == "stopped"+ stop = stopped_event["body"]["cliAnythingStop"]+ assert stop["origin"] == "internalTrap"+ assert stop["module"] == "ntdll.dll"+ assert stop["function"] == "DbgBreakPoint"+ assert stop["matchedRule"]["name"] == "windows-startup-trap"+ adapter._start_continue_thread.assert_not_called()+def test_stack_trace_reports_total_frames(self):from cli_anything.lldb.dap import LLDBDebugAdapter, read_messagediff --git a/skills/cli-anything-lldb/SKILL.md b/skills/cli-anything-lldb/SKILL.mdindex 8c6dc32cb..4141ea178 100644--- a/skills/cli-anything-lldb/SKILL.md+++ b/skills/cli-anything-lldb/SKILL.md@@ -53,12 +53,14 @@ instead of shelling out separate CLI commands:```bashcli-anything-lldb-dap+cli-anything-lldb-dap --profile /path/to/stop-rules.json```or:```bashcli-anything-lldb dap+cli-anything-lldb dap --profile /path/to/stop-rules.json```The DAP server speaks stdio `Content-Length` frames and must have exclusive@@ -85,6 +87,18 @@ For GUI apps that stop on debugger-internal startup or shader-JIT breakpoints,`launch` and `attach` accept the non-standard boolean argument`autoContinueInternalBreakpoints`. Enable it only when those internal stops arenoise for the task; the adapter emits an `output` event before auto-continuing.+For target-specific noise, prefer structured stop rules through inline+`stopRules` or an external `stopRuleProfile`/`--profile` JSON file. Rules can+match by `reason`, `module`, `function`, and/or `regex`, then either `stop` with+clear `cliAnythingStop.origin` metadata or `continue` automatically. Use+profiles for apps such as C4D so their NVIDIA shader-JIT/startup traps live+outside the generic adapter.++DAP `stopped` events include `body.cliAnythingStop.origin`: `manualPause` for a+client pause request, `internalTrap` for a matched internal rule, and `debuggee`+for ordinary program stops. Existing `cli-anything-lldb-dap` processes do not+hot-load new code or profile contents; restart the adapter and re-attach or+re-launch before expecting new rules to apply.## Command Groups@@ -148,6 +162,7 @@ cli-anything-lldb --json core load --path /path/to/core- DAP unresolved breakpoints use protocol semantics: `verified: false` until resolved.- DAP `continue` is non-blocking for long-running GUI processes, and DAP `pause` uses async interrupt.- DAP breakpoint changes during an active continue first interrupt and wait for a stopped state before mutating LLDB.+- Use DAP stop-rule profiles for app-specific internal traps; restart and re-attach/re-launch after profile changes.- `memory find` uses a chunked scan capped at 1 MiB per call.- Call `target create` before process or core commands.- Expect structured errors: `{"error": "...", "type": "..."}`