[M] Change in fuchsia/fuchsia[main]: [fx][debug] Introduce `fx debug`.

0 views
Skip to first unread message

'Darren Chan (Gerrit)' via owners-override

unread,
Dec 4, 2025, 3:19:57 PM (7 days ago) Dec 4
to Owners Override
Attention needed from Jiaming Li and Owners Override

Darren Chan has uploaded the change for review

Darren Chan would like Owners Override to review this change.

Commit message

[fx][debug] Introduce `fx debug`.

This command wraps `ffx debug connect`, but starts an ephemeral package
server if necessary, similar to what `fx test` does with target-side
tests.
Bug: 450890445
Change-Id: I49f0ca17aad0678ca05263f1af4c877c7fceaf83

Change diff

diff --git a/scripts/debug/BUILD.gn b/scripts/debug/BUILD.gn
new file mode 100644
index 0000000..4664194
--- /dev/null
+++ b/scripts/debug/BUILD.gn
@@ -0,0 +1,19 @@
+# Copyright 2025 The Fuchsia Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//build/python/host.gni")
+import("//build/python/python_binary.gni")
+
+if (is_host) {
+ python_binary("debug") {
+ main_source = "main.py"
+
+ deps = [ "//scripts/lib/package_server" ]
+ }
+
+ install_python_tool("install") {
+ name = "debug"
+ binary = ":debug"
+ }
+}
diff --git a/scripts/debug/OWNERS b/scripts/debug/OWNERS
new file mode 100644
index 0000000..8bac3da
--- /dev/null
+++ b/scripts/debug/OWNERS
@@ -0,0 +1,2 @@
+include /src/developer/debug/OWNERS
+chand...@google.com
diff --git a/scripts/debug/main.py b/scripts/debug/main.py
new file mode 100644
index 0000000..1e548ef
--- /dev/null
+++ b/scripts/debug/main.py
@@ -0,0 +1,41 @@
+# Copyright 2025 The Fuchsia Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import asyncio
+import sys
+
+import package_server
+
+
+async def main(args: list[str] = sys.argv[1:]) -> int:
+ async with package_server.ensure_running():
+ # TODO(https://fxbug.dev/464692993): Refactor `//scripts/fxtest/python/debugger.py` into a
+ # shared library and use it here.
+ ffx_cmd = await asyncio.subprocess.create_subprocess_exec(
+ "ffx", "debug", "connect", *args, stdin=sys.stdin
+ )
+
+ try:
+ return await ffx_cmd.wait()
+ except asyncio.CancelledError:
+ # This block triggers if the python script receives SIGINT (Ctrl+C)
+ # or SIGTERM, and zxdb hasn't already exited.
+
+ # Gracefully shutdown zxdb.
+ ffx_cmd.terminate()
+
+ # Give zxdb a few seconds to clean up internal state
+ await asyncio.wait_for(ffx_cmd.wait(), timeout=3.0)
+
+ # Forcefully kill zxdb if it hasn't stopped yet.
+ if ffx_cmd.returncode is None:
+ ffx_cmd.kill()
+ await ffx_cmd.wait()
+ return -9
+
+ return ffx_cmd.returncode
+
+
+if __name__ == "__main__":
+ sys.exit(asyncio.run(main()))
diff --git a/scripts/lib/package_server/OWNERS b/scripts/lib/package_server/OWNERS
index dca95eb..eba1f98 100644
--- a/scripts/lib/package_server/OWNERS
+++ b/scripts/lib/package_server/OWNERS
@@ -1,2 +1,3 @@
+include /scripts/debug/OWNERS
include /src/sys/pkg/OWNERS
chand...@google.com
diff --git a/tools/devshell/BUILD.gn b/tools/devshell/BUILD.gn
index 29fc90f..c604192 100644
--- a/tools/devshell/BUILD.gn
+++ b/tools/devshell/BUILD.gn
@@ -55,6 +55,9 @@

# For `fx disable_ctf_tests`
"//scripts/disable_ctf_tests:install",
+
+ # For `fx debug`.
+ "//scripts/debug:install",
]
}
}
diff --git a/tools/devshell/debug b/tools/devshell/debug
new file mode 100644
index 0000000..60c4404
--- /dev/null
+++ b/tools/devshell/debug
@@ -0,0 +1,12 @@
+#!/bin/bash
+# Copyright 2025 The Fuchsia Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+#### CATEGORY=Run, inspect and debug
+### Starts target-side zxdb debug sessions
+
+source "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/lib/vars.sh || exit $?
+fx-config-read
+
+fx-command-run host-tool debug "$@"

Change information

Files:
  • A scripts/debug/BUILD.gn
  • A scripts/debug/OWNERS
  • A scripts/debug/main.py
  • M scripts/lib/package_server/OWNERS
  • M tools/devshell/BUILD.gn
  • A tools/devshell/debug
Change size: M
Delta: 6 files changed, 78 insertions(+), 0 deletions(-)
Open in Gerrit

Related details

Attention is currently required from:
  • Jiaming Li
  • Owners Override
Submit Requirements:
  • requirement is not satisfiedCode-Owners
  • requirement satisfiedCode-Review
  • requirement satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newchange
Gerrit-Project: fuchsia
Gerrit-Branch: main
Gerrit-Change-Id: I49f0ca17aad0678ca05263f1af4c877c7fceaf83
Gerrit-Change-Number: 1436314
Gerrit-PatchSet: 5
Gerrit-Owner: Darren Chan <chand...@google.com>
Gerrit-Reviewer: Chase Latta <chase...@google.com>
Gerrit-Reviewer: Christopher Johnson <crj...@google.com>
Gerrit-Reviewer: Darren Chan <chand...@google.com>
Gerrit-Reviewer: Jacob Rutherford <jru...@google.com>
Gerrit-Reviewer: Owners Override <owners-...@fuchsia.dev>
Gerrit-CC: Jiaming Li <liji...@google.com>
Gerrit-CC: Thomas Zander <thomas...@google.com>
Gerrit-Attention: Owners Override <owners-...@fuchsia.dev>
Gerrit-Attention: Jiaming Li <liji...@google.com>

--
You received this message because you are subscribed to the Google Groups "owners-override" group.
To unsubscribe from this group and stop receiving emails from it, send an email to owners-overri...@fuchsia.dev.
To view this discussion visit https://groups.google.com/a/fuchsia.dev/d/msgid/owners-override/ab9c7582127a575e2628a7d26e0362ecee7b44f5-HTML%40fuchsia-review.googlesource.com.
unsatisfied_requirement
satisfied_requirement
open
diffy

'Darren Chan (Gerrit)' via owners-override

unread,
Dec 4, 2025, 3:19:58 PM (7 days ago) Dec 4
to Owners Override, Jiaming Li, Christopher Johnson, Chase Latta, Jacob Rutherford, GI Try Builder, CQ Bot, Thomas Zander
Attention needed from Jiaming Li and Owners Override

Darren Chan added 1 comment

Patchset-level comments
File-level comment, Patchset 5 (Latest):
Darren Chan . resolved

Adding @owners-...@fuchsia.dev for `//scripts/debug`

Open in Gerrit

Related details

Attention is currently required from:
  • Jiaming Li
  • Owners Override
Submit Requirements:
  • requirement is not satisfiedCode-Owners
  • requirement satisfiedCode-Review
  • requirement satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: fuchsia
Gerrit-Branch: main
Gerrit-Change-Id: I49f0ca17aad0678ca05263f1af4c877c7fceaf83
Gerrit-Change-Number: 1436314
Gerrit-PatchSet: 5
Gerrit-Owner: Darren Chan <chand...@google.com>
Gerrit-Reviewer: Chase Latta <chase...@google.com>
Gerrit-Reviewer: Christopher Johnson <crj...@google.com>
Gerrit-Reviewer: Darren Chan <chand...@google.com>
Gerrit-Reviewer: Jacob Rutherford <jru...@google.com>
Gerrit-Reviewer: Owners Override <owners-...@fuchsia.dev>
Gerrit-CC: Jiaming Li <liji...@google.com>
Gerrit-CC: Thomas Zander <thomas...@google.com>
Gerrit-Attention: Owners Override <owners-...@fuchsia.dev>
Gerrit-Attention: Jiaming Li <liji...@google.com>
Gerrit-Comment-Date: Thu, 04 Dec 2025 20:19:54 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No

--
You received this message because you are subscribed to the Google Groups "owners-override" group.
To unsubscribe from this group and stop receiving emails from it, send an email to owners-overri...@fuchsia.dev.
To view this discussion visit https://groups.google.com/a/fuchsia.dev/d/msgid/owners-override/ab9c7582127a575e2628a7d26e0362ecee7b44f5-EmailReviewComments-HTML%40fuchsia-review.googlesource.com.
unsatisfied_requirement
satisfied_requirement
open
diffy

'Adam Barth (Gerrit)' via owners-override

unread,
Dec 4, 2025, 3:24:47 PM (7 days ago) Dec 4
to Darren Chan, Owners Override, Jiaming Li, Christopher Johnson, Chase Latta, Jacob Rutherford, GI Try Builder, CQ Bot, Thomas Zander
Attention needed from Darren Chan and Owners Override

Adam Barth added 1 comment

File scripts/debug/OWNERS
Line 2, Patchset 5 (Latest):chand...@google.com
Adam Barth . unresolved

Can you add the directory and OWNERS file in a separate CL? That's easier for owners-override to approve and land.

Open in Gerrit

Related details

Attention is currently required from:
  • Darren Chan
  • Owners Override
Submit Requirements:
    • requirement is not satisfiedCode-Owners
    • requirement satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: fuchsia
    Gerrit-Branch: main
    Gerrit-Change-Id: I49f0ca17aad0678ca05263f1af4c877c7fceaf83
    Gerrit-Change-Number: 1436314
    Gerrit-PatchSet: 5
    Gerrit-Owner: Darren Chan <chand...@google.com>
    Gerrit-Reviewer: Chase Latta <chase...@google.com>
    Gerrit-Reviewer: Christopher Johnson <crj...@google.com>
    Gerrit-Reviewer: Darren Chan <chand...@google.com>
    Gerrit-Reviewer: Jacob Rutherford <jru...@google.com>
    Gerrit-Reviewer: Owners Override <owners-...@fuchsia.dev>
    Gerrit-CC: Adam Barth <aba...@google.com>
    Gerrit-CC: Jiaming Li <liji...@google.com>
    Gerrit-CC: Thomas Zander <thomas...@google.com>
    Gerrit-Attention: Owners Override <owners-...@fuchsia.dev>
    Gerrit-Attention: Darren Chan <chand...@google.com>
    Gerrit-Comment-Date: Thu, 04 Dec 2025 20:24:38 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No

    --
    You received this message because you are subscribed to the Google Groups "owners-override" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to owners-overri...@fuchsia.dev.
    To view this discussion visit https://groups.google.com/a/fuchsia.dev/d/msgid/owners-override/8c3e9d9caa1516b706430b67d253b60fe897b2c2-EmailReviewComments-HTML%40fuchsia-review.googlesource.com.
    unsatisfied_requirement
    satisfied_requirement
    open
    diffy

    'Darren Chan (Gerrit)' via owners-override

    unread,
    Dec 4, 2025, 3:33:32 PM (7 days ago) Dec 4
    to Owners Override
    Attention needed from Adam Barth

    Darren Chan has uploaded the change for review

    Darren Chan removed Owners Override from reviewers of this change.

    Change diff

    index 156dc1b..8755e34 100644
    --- a/tools/devshell/BUILD.gn
    +++ b/tools/devshell/BUILD.gn
    @@ -52,6 +52,9 @@

    Change information

    Files:
    • A scripts/debug/BUILD.gn
    • A scripts/debug/main.py
    • M scripts/lib/package_server/OWNERS
    • M tools/devshell/BUILD.gn
    • A tools/devshell/debug
      Change size: M
      Delta: 5 files changed, 76 insertions(+), 0 deletions(-)
      Open in Gerrit

      Related details

      Attention is currently required from:
      • Adam Barth
      Submit Requirements:
        • requirement is not satisfiedCode-Owners
        • requirement satisfiedCode-Review
        • requirement satisfiedReview-Enforcement
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: newchange
        Gerrit-Project: fuchsia
        Gerrit-Branch: main
        Gerrit-Change-Id: I49f0ca17aad0678ca05263f1af4c877c7fceaf83
        Gerrit-Change-Number: 1436314
        Gerrit-PatchSet: 7
        Gerrit-Owner: Darren Chan <chand...@google.com>
        Gerrit-Reviewer: Chase Latta <chase...@google.com>
        Gerrit-Reviewer: Christopher Johnson <crj...@google.com>
        Gerrit-Reviewer: Darren Chan <chand...@google.com>
        Gerrit-Reviewer: Jacob Rutherford <jru...@google.com>
        Gerrit-CC: Adam Barth <aba...@google.com>
        Gerrit-CC: Jiaming Li <liji...@google.com>
        Gerrit-CC: Thomas Zander <thomas...@google.com>
        Gerrit-Attention: Adam Barth <aba...@google.com>

        --
        You received this message because you are subscribed to the Google Groups "owners-override" group.
        To unsubscribe from this group and stop receiving emails from it, send an email to owners-overri...@fuchsia.dev.
        To view this discussion visit https://groups.google.com/a/fuchsia.dev/d/msgid/owners-override/74411fc0e431f28b716c27ecee4fb5654de3bee2-HTML%40fuchsia-review.googlesource.com.
        unsatisfied_requirement
        satisfied_requirement
        open
        diffy
        Reply all
        Reply to author
        Forward
        0 new messages