From 9d98617c1a4ccfea12a1653019d0f06e4249570c Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Mon, 15 Apr 2024 22:28:11 +0200 Subject: [PATCH] Update debugging with vscode section - We have ssh-generator now, so need for mkosi's Ssh= option anymore. - By enabling RuntimeBuildSources= by default, we don't need the gdb config file in the image anymore, since the build and source directories will be mounted at the expected locations. --- docs/HACKING.md | 27 ++++--------------- mkosi.conf | 1 + .../share/factory/mkosi/gdbinit.d/systemd.gdb | 3 --- mkosi.images/system/mkosi.finalize | 1 + 4 files changed, 7 insertions(+), 25 deletions(-) delete mode 100644 mkosi.images/system/mkosi.extra/usr/share/factory/mkosi/gdbinit.d/systemd.gdb diff --git a/docs/HACKING.md b/docs/HACKING.md index 2a58780fbf5..569f81ab0ba 100644 --- a/docs/HACKING.md +++ b/docs/HACKING.md @@ -276,22 +276,9 @@ To simplify debugging systemd when testing changes using mkosi, we're going to s QEMU. To allow VSCode's debugger to attach to systemd running in a mkosi image, we have to make sure it can access -the virtual machine spawned by mkosi where systemd is running. mkosi makes this possible via a handy SSH -option that makes the generated image accessible via SSH when booted. Thus you must build the image with -`mkosi --ssh`. The easiest way to set the option is to create a file `mkosi.local.conf` in the root of the -repository and add the following contents: - -``` -[Host] -Ssh=yes -RuntimeTrees=. -``` - -Also make sure that the SSH agent is running on your system and that you've added your SSH key to it with -`ssh-add`. Also make sure that `virtiofsd` is installed. - -After rebuilding the image and booting it with `mkosi qemu`, you should now be able to connect to it by -running `mkosi ssh` from the same directory in another terminal window. +the virtual machine spawned by mkosi where systemd is running. After booting the image with `mkosi qemu`, you +should now be able to connect to it by running `mkosi ssh` from the same directory in another terminal +window. Now we need to configure VSCode. First, make sure the C/C++ extension is installed. If you're already using a different extension for code completion and other IDE features for C in VSCode, make sure to disable the @@ -320,16 +307,12 @@ the directory, and add the following contents: "name": "systemd", "pipeTransport": { "pipeProgram": "mkosi", - "pipeArgs": [ - "-C", - "/path/to/systemd/repo/directory/on/host/system/", - "ssh" - ], + "pipeArgs": ["-C", "${workspaceFolder}", "ssh"], "debuggerPath": "/usr/bin/gdb" }, "MIMode": "gdb", "sourceFileMap": { - "/root/src/systemd": { + "/work/src": { "editorPath": "${workspaceFolder}", "useForBreakpoints": false }, diff --git a/mkosi.conf b/mkosi.conf index 96843db4881..ee7fa6e2a48 100644 --- a/mkosi.conf +++ b/mkosi.conf @@ -20,6 +20,7 @@ BuildSourcesEphemeral=yes [Host] @Incremental=yes @RuntimeSize=8G +@RuntimeBuildSources=yes ToolsTreePackages=virtiofsd KernelCommandLineExtra=systemd.crash_shell systemd.log_level=debug,console:info diff --git a/mkosi.images/system/mkosi.extra/usr/share/factory/mkosi/gdbinit.d/systemd.gdb b/mkosi.images/system/mkosi.extra/usr/share/factory/mkosi/gdbinit.d/systemd.gdb deleted file mode 100644 index 26f882bc2bb..00000000000 --- a/mkosi.images/system/mkosi.extra/usr/share/factory/mkosi/gdbinit.d/systemd.gdb +++ /dev/null @@ -1,3 +0,0 @@ -set debuginfod enabled off -set build-id-verbose 0 -set substitute-path ../src /root/src/systemd diff --git a/mkosi.images/system/mkosi.finalize b/mkosi.images/system/mkosi.finalize index 74b810c152b..6da35e51380 100755 --- a/mkosi.images/system/mkosi.finalize +++ b/mkosi.images/system/mkosi.finalize @@ -1,4 +1,5 @@ #!/bin/sh # SPDX-License-Identifier: LGPL-2.1-or-later +mkdir -p "$BUILDROOT"/usr/share/factory/mkosi cp --archive --recursive --no-target-directory --reflink=auto "$BUILDROOT"/etc "$BUILDROOT"/usr/share/factory/mkosi -- 2.39.2