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

Nicety for those using VSCode #1

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Conversation

maxgallup
Copy link

Hey @hammertux,

I've added support for a VSCode feature that allows you to open the project inside of a container with all dependencies preinstalled (Dev Containers). All of the make * commands from Lecture 01 seem to work. This allows us to forego installing dependencies to the host which can always be a pain and for those not on running Linux this makes life easier.

@Noorts
Copy link

Noorts commented Sep 13, 2024

Additionally, it might also be nice to include a launch.json VSCode debug configuration, such that you can debug using VSCode's debug interface. After setting it up just run make qemu-nox-gdb, and then hit F5 in VSCode.

// Add to the configurations list in .vscode/launch.json  
"configurations": [
    {
        "name": "Debug Kernel with GDB",
        "type": "cppdbg",
        "request": "launch",
        "program": "${workspaceFolder}/obj/kernel/kernel",
        "args": [],
        "stopAtEntry": true,
        "cwd": "${workspaceFolder}",
        "environment": [],
        "externalConsole": false,
        "MIMode": "gdb",
        "miDebuggerPath": "/usr/bin/gdb",
        "setupCommands": [
            {
                "description": "Load GDB commands from .gdbrc",
                "text": "source ${workspaceFolder}/.gdbrc",
                "ignoreFailures": false
            }
        ]
    }
]

@Noorts
Copy link

Noorts commented Sep 13, 2024

Finally, for proper clangd language server support you might want to add a .clangd file as well. Make sure to set the include directory correctly (in the .clangd file, see the "-I..." below) and to install the clangd and C/C++ VSCode extensions.

CompileFlags:
  Add:
    - "-I/workspace/include"
    - "-DKERNEL_VMA=0xFFFF800000000000"
    - "-DKERNEL_LMA=0x100000"

For an additional mount you'll have to add the following to the devcontainer.json.

    "workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind",
    "workspaceFolder": "/workspace"

@@ -28,7 +28,12 @@ RUN useradd dev -u 1000 -m -s /bin/bash && \
USER dev


# Install GEF for sanity & its dependencies
RUN sudo apt install -y file && bash -c "$(wget https://gef.blah.cat/sh -O -)"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't use VS, and I am not responsible for this repo, but I know a curl | sh when I see one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants