Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guide: Debug with gdb #37

Open
Hofer-Julian opened this issue Jul 25, 2021 · 1 comment
Open

Guide: Debug with gdb #37

Hofer-Julian opened this issue Jul 25, 2021 · 1 comment
Labels
documentation Improvements or additions to documentation

Comments

@Hofer-Julian
Copy link
Collaborator

Hofer-Julian commented Jul 25, 2021

  1. Install Native Debug

  2. Allow breakpoints everywhere (maybe native debug doesn't include .rs files? Let's open an issue there)

{
    "debug.allowBreakpointsEverywhere": true
}
  1. Create the file gdb.sh with content similar to this (we could create that automatically)
    (Note: "Everything before gdb "$@" should be the same command as when you run the flatpak minus the executable name (which is in this case "shortwave))
#!/bin/sh

flatpak-spawn --host flatpak build --with-appdir --allow=devel --bind-mount=/run/user/1000/doc=/run/user/1000/doc/by-app/de.haeckerfelix.Shortwave.Devel --share=network --share=ipc --socket=fallback-x11 --socket=wayland --device=dri --socket=pulseaudio --filesystem=xdg-music --env=RUST_LOG=shortwave=debug --env=RUST_BACKTRACE=1 --talk-name='org.freedesktop.portal.*' --talk-name=org.a11y.Bus --env=DESKTOP_SESSION=gnome --env=XDG_SESSION_DESKTOP=gnome --env=XDG_SESSION_TYPE=wayland --env=LANG=de_AT.UTF-8 --env=XDG_CURRENT_DESKTOP=GNOME --env=WAYLAND_DISPLAY=wayland-0 --env=AT_SPI_BUS_ADDRESS=unix:path=/run/user/1000/at-spi-bus /var/home/julian/Projekte/gnome/applications/Shortwave/.flatpak/repo gdb "$@"
  1. Make gdb.sh executable
chmod +x gdb.sh
  1. Create a file .vscode/launch.json with similar content
    (Replace the executable name with yours. We should also auto generate that)
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Debug",
            "type": "gdb",
            "request": "launch",
            "gdbpath": "./gdb.sh",
            "target": ".flatpak/repo/files/bin/shortwave",
            "arguments": "launch.json",
            "cwd": "${workspaceRoot}",
            "valuesFormatting": "parseText"
        },        
    ]
}
@haecker-felix
Copy link

Bonus: Automatically build the application first.

adapt launch.json to include preLaunchTask

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Debug",
            "type": "gdb",
            "request": "launch",
            "preLaunchTask": "flatpak: build",
            "gdbpath": "./gdb.sh",
            "target": ".flatpak/repo/files/bin/shortwave",
            "arguments": "",
            "cwd": "${workspaceRoot}",
            "valuesFormatting": "parseText"
        },        
    ]
}

add to your tasks.json file

{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "shell",
            "command": "flatpak-spawn --host flatpak build --share=network --nofilesystem=host --filesystem=/home/haecker-felix/Dokumente/Projekte/Shortwave --filesystem=/home/haecker-felix/Dokumente/Projekte/Shortwave/.flatpak/repo --env=PATH=$PATH:/usr/lib/sdk/rust-stable/bin --filesystem=/home/haecker-felix/Dokumente/Projekte/Shortwave/_build /home/haecker-felix/Dokumente/Projekte/Shortwave/.flatpak/repo meson install -C _build",
            "label": "flatpak: build",
            "group": "build"
        }
    ]
}

@bilelmoussaoui bilelmoussaoui added the documentation Improvements or additions to documentation label Apr 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants