Sign inSign up

cs1550/linuxdev

By cs1550

•Updated almost 5 years ago

Image
0

1.2K

cs1550/linuxdev repository overview

This is a linux development environment for cs1550 projects.

⁠Basic Commands

To download the linuxdev image

docker pull cs1550/linuxdev:latest

For more information: https://www.docker.com/sites/default/files/d8/2019-09/docker-cheat-sheet.pdf⁠

⁠Usage

  1. Run the container inside a bash

docker run --rm -it -v {absolutepath_to_projectfolder}:/home/ubuntu/project cs1550/linuxdev

  1. cd into the project directory

  2. Build the kernel:

    make kernel
    
  3. Build and run the test programs (to be done once the syscalls are added to syscall_32.tbl):

    make debug
    

Debug

Here is a way to run gdb on Xv6:

  1. In the first terminal, run cs1550/xv6 and start Xv6 with the following command: make qemu-nox-gdb
  2. Open a second terminal, use the command to print the list of running container, docker container ls
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
2aa06ec5b33c        cs1550/xv6          "/bin/bash"         24 seconds ago      Up 23 seconds                           silly_gagarin
  1. Login to the cs1550/xv6 container using the following command in the second terminal. docker exec -it <container_id> /bin/bash
docker exec -it 2aa06ec5b33c /bin/bash
  1. Run cd xv6 and then run gdb on the second terminal using the command: gdb -iex "set auto-load safe-path ."
  2. You are now ready to start debugging your code. Feel free to use your GDB skills. For example, you can place a breakpoint at a given line in the Xv6 source code as follows: (gdb) b proc.c:215
  3. Then continue running the kernel using the command (gdb) c. This will start the debugging session.
  4. To debug a user program (e.g., getcount), you can add the symbol table inside the user program to the GDB session as follows (note the underscore in front of the program name) (gdb) add-symbol-file _getcount 0
  5. You would then be able to add breakpoints in the user program: (gdb) b getcount.c:7
  6. Using the next command in the GDB prompt (n) you can trace inside kernel code and out to the user code.
  7. Here is a nice page about gdb commands⁠.

For sudo access, the default password is ubuntu.

⁠Common Issues

When compiling on a Windows machine, your Linux installation may suffer from clock skew. This will prevent you from compiling.

ubuntu@7d1144ddb629:~/project/project1$ make kernel
make -C linux-5.10.10
make[1]: Entering directory '/home/ubuntu/project/project1/linux-5.10.10'
  CALL    scripts/checksyscalls.sh
  CALL    scripts/atomic/check-atomics.sh
  CHK     include/generated/compile.h
  UPD     include/generated/compile.h
  CC      init/version.o
  AR      init/built-in.a
make[1]: Warning: File 'init/built-in.a' has modification time 18957 s in the future
  GEN     .version
make[2]: Warning: File 'init/.version.o.cmd' has modification time 18950 s in the future
  CHK     include/generated/compile.h
  UPD     include/generated/compile.h
  CC      init/version.o
  AR      init/built-in.a
make[2]: warning:  Clock skew detected.  Your build may be incomplete.
  LD      vmlinux.o
make[2]: Warning: File 'vmlinux.o' has modification time 19380 s in the future
  MODPOST vmlinux.symvers
make[2]: warning:  Clock skew detected.  Your build may be incomplete.
  MODINFO modules.builtin.modinfo
  GEN     modules.builtin
  LD      vmlinux
  SORTTAB vmlinux
  SYSMAP  System.map
make[3]: Warning: File 'vmlinux' has modification time 19375 s in the future

To fix this, use Network Time Protocol (ntp) to set the system time from a network time server.

$ sudo apt install ntpdate

And, whenever your Linux clock is wrong, run the following command to sync the time:

$ sudo ntpdate time.windows.com

Tag summary

Content type

Image

Digest

Size

799.8 MB

Last updated

almost 5 years ago

docker pull cs1550/linuxdev