microhobby / linuxkerneldev

Visual Studio Code extension to help find documentation, device tree matching on device driver source code, by compatible strings
MIT License
42 stars 9 forks source link

Cannot launch a debugging session on Ubuntu 23.04 #35

Open kyselejsyrecek opened 1 year ago

kyselejsyrecek commented 1 year ago

The extension is unable to start a debugging session on Ubuntu 23.04. When launching the session, an error window pops up in bottom-right corner of VS Code, reading that /bin/bash failed to launch. The following error message then appears in the Output Window:

[error] [Extension Host] stderr: agent-proxy: žádný proces nenalezen

(In English: no process found)

I have tried launching the debugging session without and with agent-proxy downloaded from Linux kernel website and linked to ${workspaceFolder}/agent-proxy with a symbolic link with the same result. I am using the latest version of this extension, but behaviour of the experimental version is the same.

image image

Configuration from launch.json:

    {
      "name": "KGDB: remote kernel debugging (serial console)",
      "type": "cppdbg", // required for GDB and LLDB
      "request": "launch", // attach to running Linux kernel
      "program": "${workspaceFolder}/rpm/${input:targetPlatform}/BUILD/linux/vmlinux",
      "preLaunchTask": "${command:embeddedLinuxDev.breakKernel}",
      "cwd": "${workspaceFolder}",
      "MIMode": "gdb", 
      "setupCommands": [
        {
          "description": "Set path to source files",
          "text": "set dir ${workspaceFolder}/linux",
          "ignoreFailures": false
        },
        {
          "description": "Connect to target machine.",
          "text": "target remote localhost:${config:kerneldev.serial_port}",
          "ignoreFailures": false
        }
      ],
      "miDebuggerPath": "gdb-multiarch"
    }
kyselejsyrecek commented 1 year ago

It seems that the shellArgs: ["--norc", "--noprofile"] property from file out/Utils/ExtensionsUtils.js (two occurrences) is passed incorrectly to the bash process. Modifying it to shellArgs: ["--noprofile"] solves the problem with Bash process crashing but does not help with agent-proxy.

I also found that the error agent-proxy: no process found was coming from killall agent-proxy command in file scripts/agentProxy.sh and thus was a false positive. After enabling debugging output from the script file with set -x, I was finally able to find the cause for agent-proxy failures which was the setting "kerneldev.serial_dev": "/dev/ttyUSB0" in settings.json. The correct setting is "kerneldev.serial_dev": "ttyUSB0". Moreover, "text": "target remote localhost:${config:kerneldev.serial_port}" from launch.json must be replaced with "text": "target remote localhost:${config:kerneldev.kgdb_port}" to make GDB attach to the correct port from serial splitter.

The only issue is thus the crash of bash process with parameters "--norc", "--noprofile".

microhobby commented 1 year ago

hey @kyselejsyrecek thanks for the reports! I will take a look

kyselejsyrecek commented 1 year ago

Hello @microhobby, sorry for my typos (which I have now corrected) and thanks for taking a look at the crashing Bash process.