Skip to content

Commit 422ce57

Browse files
Cerdoreclaude
andcommitted
fix: address all 6 PR #4 review issues
- Remove duplicate "remote" key in target JSON output - Check output_status for error in handle_exec - Fix remote type annotation from Optional[int] to Optional[str] - Add missing mi-async on for target mode non-stop - Handle queue.Empty timeout explicitly with 60s timeout - Add remote address format validation (host:port) Constraint: Must validate remote format before passing to GDB Confidence: high Scope-risk: narrow Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent dca4dc7 commit 422ce57

4 files changed

Lines changed: 15 additions & 4 deletions

File tree

src/gdb_cli/cli.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515
import json
1616
import os
17+
import re
1718
import time
18-
from pathlib import Path
1919
from typing import Optional
2020

2121
import click
@@ -204,6 +204,10 @@ def target(
204204
gdb_path: str,
205205
) -> None:
206206
"""Connect to remote GDB server"""
207+
if not re.match(r'^[\w.-]+:\d+$', remote):
208+
print_error(f"Invalid remote format: {remote}")
209+
raise click.exceptions.Exit(1)
210+
207211
existing = find_session_by_remote(remote)
208212
if existing:
209213
print_json({
@@ -234,7 +238,6 @@ def target(
234238
"mode": session.mode,
235239
"remote": session.remote,
236240
"binary": session.binary,
237-
"remote": session.remote,
238241
"sock_path": session.sock_path,
239242
"gdb_pid": gdb_process.pid,
240243
"safety_level": session.safety_level,

src/gdb_cli/gdb_server/handlers.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,14 @@ def run_command():
590590
# where it will run, and this thread waits to receive the output
591591
# from the queue.
592592
gdb.post_event(run_command)
593-
output_status, output = result_queue.get(timeout=30.0)
593+
594+
try:
595+
output_status, output = result_queue.get(timeout=60.0)
596+
except queue.Empty:
597+
return {"command": command, "error": "Command timeout after 60s"}
598+
599+
if output_status == "error":
600+
return {"command": command, "error": output}
594601

595602
return {
596603
"command": command,

src/gdb_cli/launcher.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ def launch_target(
265265
if non_stop:
266266
gdb_commands.append("set non-stop on")
267267
gdb_commands.append("set target-async on")
268+
gdb_commands.append("set mi-async on")
268269

269270
# 加载 binary (可选)
270271
if binary:

src/gdb_cli/session.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def create_session(
5050
binary: Optional[str] = None,
5151
core: Optional[str] = None,
5252
pid: Optional[int] = None,
53-
remote: Optional[int] = None,
53+
remote: Optional[str] = None,
5454
timeout: int = 600,
5555
safety_level: str = "readonly"
5656
) -> SessionMeta:

0 commit comments

Comments
 (0)