From: Daan De Meyer Date: Tue, 21 Mar 2023 15:06:15 +0000 (+0100) Subject: docs: Fix vscode debugging section in HACKING.md X-Git-Tag: v254-rc1~966 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c84d14c52521f95752c9f5643854e9e836df38b9;p=thirdparty%2Fsystemd.git docs: Fix vscode debugging section in HACKING.md Let's account for the recent changes in mkosi in the debugging with vscode section. --- diff --git a/docs/HACKING.md b/docs/HACKING.md index 0adf5ada547..a7ddfc0ca8e 100644 --- a/docs/HACKING.md +++ b/docs/HACKING.md @@ -215,24 +215,25 @@ vscode documentation [here](https://code.visualstudio.com/docs/cpp/launch-json-r ## Debugging systemd with mkosi + vscode To simplify debugging systemd when testing changes using mkosi, we're going to show how to attach -[VSCode](https://code.visualstudio.com/)'s debugger to an instance of systemd running in a mkosi image -(either using QEMU or systemd-nspawn). +[VSCode](https://code.visualstudio.com/)'s debugger to an instance of systemd running in a mkosi image using +QEMU. To allow VSCode's debugger to attach to systemd running in a mkosi image, we have to make sure it can access -the container/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 20-local.conf in mkosi.default.d/ (in the directory you ran mkosi in) and add -the following contents: +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 20-local.conf in mkosi.conf.d/ (in the +directory you ran mkosi in) and add the following contents: ``` [Host] Ssh=yes ``` -Next, make sure systemd-networkd is running on the host system so that it can configure the network interface -connecting the host system to the container/VM spawned by mkosi. Once systemd-networkd is running, you should -be able to connect to a running mkosi image by executing `mkosi ssh` in the systemd repo directory. +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`. + +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. 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 @@ -270,11 +271,11 @@ the directory, and add the following contents: }, "MIMode": "gdb", "sourceFileMap": { - "/root/build/../src": { + "/work/build/../src": { "editorPath": "${workspaceFolder}", "useForBreakpoints": false }, - "/root/build/*": { + "/work/build/*": { "editorPath": "${workspaceFolder}/mkosi.builddir", "useForBreakpoints": false }