m1stborn / xv6-labs-2022

MIT 6.1810: Operating System Engineering Docker/VS code setup and Lab problems.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MIT 6.1810: Operating System Engineering

Course Website: https://pdos.csail.mit.edu/6.828/2022/schedule.html

Environment Setup

I use WSL(Ubuntu-22.04) + docker to run xv6, this is how I set up the environment:

docker run -it -v $PWD:/xv6-riscv -p 127.0.0.1:8080:25000 jjolly/xv6

You will need to map the default gdb port to localhost by above command.

Since the grading script was written in python, you have to install python inside docker container.

apt-get update
apt-get install -y python3

Note that if you use windows you have to set Line Separator to LF, otherwise the grade-lab script will fail to run.

Debug with VS code

To use the integrated GUI debugger in VS code:

  1. Install this vscode extension: Native Debug
    This extension allow you to attach to remote gdbserver within your docker container.
  2. Install gdb-multiarch on your wsl.
    apt install gdb-multiarch
    
  3. Add the following configuration to your launch.json file.
    {
        "type": "gdb",
        "request": "attach",
        "name": "Attach to gdbserver",
        "gdbpath": "/usr/bin/gdb-multiarch",
        "executable": "kernel/kernel",
        "target": "127.0.0.1:8080",
        "remote": true,
        "printCalls": true,
        "cwd": "${workspaceRoot}",
        "valuesFormatting": "parseText"
    }
  4. Start gdbserver:
    make qemu-gdb
    
    Now you can click the debug button "Attach to gdbserver" and add some breakpoint to debug the program.

Demo

Reference

  • docker image tutorial: Video
    I used the docker image provided by jjolly, checkout this video for step-by-step tutorial.
  • xv6 source dive: Video
    This series offers valuable insights during lab sessions. For a deeper comprehension of xv6 implementation, these videos are highly recommended.

About

MIT 6.1810: Operating System Engineering Docker/VS code setup and Lab problems.

License:Other


Languages

Language:C 86.0%Language:Python 7.3%Language:Makefile 3.3%Language:Assembly 3.0%Language:Perl 0.2%Language:Emacs Lisp 0.0%