Skip to content

Commit 668593f

Browse files
authored
Infra: introduce dev-container with debugging support and refactor grader (SJTU-IPADS#22)
* chore: update github badges Signed-off-by: Yiyang Wu <toolmanp@tlmp.cc> * CI: use self-maintained preprocessors Signed-off-by: Yiyang Wu <toolmanp@tlmp.cc> * infra: add devcontainer support Signed-off-by: Yiyang Wu <toolmanp@tlmp.cc> * refactor: refactor variable name and scripts Signed-off-by: Yiyang Wu <toolmanp@tlmp.cc> * infra: add py-based scores.json for grader Signed-off-by: Yiyang Wu <toolmanp@tlmp.cc> * infra: refactor out chbuild Signed-off-by: Yiyang Wu <toolmanp@tlmp.cc> * vcs: remove .vscode from .gitignore Signed-off-by: Yiyang Wu <toolmanp@tlmp.cc> * docs: update Getting-Started.md Signed-off-by: Yiyang Wu <toolmanp@tlmp.cc> * docs: update Contribute.md Signed-off-by: Yiyang Wu <toolmanp@tlmp.cc> * infra: introduce gdb 13.2 && qemu 9.1.0 Signed-off-by: Yiyang Wu <toolmanp@tlmp.cc> * infra: add chcore_target_precompile Include a new macro to select the object file to choose to use whether debug mode or release mode Signed-off-by: Yiyang Wu <toolmanp@tlmp.cc> * fix(lab1): fix linker to include debug symbols linker.tpl.ld does not include symbols for init objects. This commits fix it. * lab1: use split-mode precompiled objects Signed-off-by: Yiyang Wu <toolmanp@tlmp.cc> * lab1: move gdbinit Signed-off-by: Yiyang Wu <toolmanp@tlmp.cc> * infra: add clangd and cppdbg support Signed-off-by: Yiyang Wu <toolmanp@tlmp.cc> * lab1: fix procmgr binary Signed-off-by: Yiyang Wu <toolmanp@tlmp.cc> * infra: add additional comment to capturer.py Signed-off-by: Yiyang Wu <toolmanp@tlmp.cc> * infra: add qemu auto launch task Signed-off-by: Yiyang Wu <toolmanp@tlmp.cc> * infra: add arm highlight && hexeditor Signed-off-by: Yiyang Wu <toolmanp@tlmp.cc> * docs: add debugging.md Signed-off-by: Yiyang Wu <toolmanp@tlmp.cc> * docs(lab1): fix typo Signed-off-by: Yiyang Wu <toolmanp@tlmp.cc> * docs(lab0): fix fense Signed-off-by: Yiyang Wu <toolmanp@tlmp.cc> * docs: rearrange SUMMARY.md Signed-off-by: Yiyang Wu <toolmanp@tlmp.cc> * scripts: fix qemu and grade recipes Signed-off-by: Yiyang Wu <toolmanp@tlmp.cc> * scripts: fix gendeps.sh for customized ubuntu Signed-off-by: Yiyang Wu <toolmanp@tlmp.cc> * docs: enhance linker.md Signed-off-by: Yiyang Wu <toolmanp@tlmp.cc> * docs: update Contribute.md Signed-off-by: Yiyang Wu <toolmanp@tlmp.cc> * lab1: remove LICENSE Signed-off-by: Yiyang Wu <toolmanp@tlmp.cc> * docs: add Contribute lab assignment Signed-off-by: Yiyang Wu <toolmanp@tlmp.cc> * docs: fix mdbook guide Signed-off-by: Yiyang Wu <toolmanp@tlmp.cc> * docs(lab1): add RTFSC.md Signed-off-by: Yiyang Wu <toolmanp@tlmp.cc> --------- Signed-off-by: Yiyang Wu <toolmanp@tlmp.cc>
1 parent 01b999d commit 668593f

File tree

198 files changed

+749
-369
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

198 files changed

+749
-369
lines changed

.devcontainer/Dockerfile

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
FROM ipads/chcore_builder:v1.9.0
2+
3+
ARG USERNAME=stu
4+
ARG USER_UID=1000
5+
ARG USER_GID=$USER_UID
6+
7+
RUN sed -i "s/archive.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/g" /etc/apt/sources.list
8+
RUN apt-get update && apt-get upgrade -y
9+
RUN apt-get install -y sudo \
10+
binutils-dev \
11+
libgmp-dev \
12+
libmpfr-dev \
13+
curl \
14+
meson \
15+
python3 \
16+
python3-pip \
17+
python3-psutil \
18+
bear \
19+
cmake \
20+
git \
21+
pkgconf \
22+
clangd
23+
24+
# We need to install a latest gdb to support cppdbg.
25+
RUN curl -SLO https://ftp.gnu.org/gnu/gdb/gdb-13.2.tar.xz && \
26+
tar -xf gdb-13.2.tar.xz && \
27+
cd gdb-13.2 && \
28+
./configure --prefix=/usr/local \
29+
--enable-targets=aarch64-linux-gnu,x86_64-linux-gnu \
30+
--enable-tui \
31+
--disable-sim \
32+
&& \
33+
make -j$(nproc) && \
34+
make install && \
35+
cd .. && \
36+
rm -rf gdb-13.2 gdb-13.2.tar.xz
37+
38+
# install tomli for .toml file required by qemu 9.1.x
39+
RUN pip install tomli
40+
41+
# we need to install >=glib-2.66.8 to support qemu 9.1.x
42+
RUN curl -SLO https://download.gnome.org/sources/glib/2.66/glib-2.66.8.tar.xz && \
43+
tar -xvf glib-2.66.8.tar.xz && \
44+
cd glib-2.66.8 && \
45+
meson build --prefix /usr/local && \
46+
ninja -C build && \
47+
ninja -C build install && \
48+
cd .. && \
49+
rm -rf glib-2.66.8 glib-2.66.8.tar.xz
50+
51+
# install latest supported qemu supported by ubuntu-20.04.
52+
RUN curl -SLO https://download.qemu.org/qemu-9.1.0.tar.xz && \
53+
tar -xf qemu-9.1.0.tar.xz && \
54+
cd qemu-9.1.0 && \
55+
./configure --prefix=/usr/local \
56+
--target-list=aarch64-softmmu,aarch64-linux-user && \
57+
make -j$(nproc) && \
58+
make install && \
59+
cd .. && \
60+
rm -rf qemu-9.1.0 qemu-9.1.0.tar.xz
61+
62+
RUN apt-get install -y libglib2.0-dev
63+
RUN apt-get clean
64+
65+
RUN useradd -m -u $USER_UID -U -s /bin/bash stu
66+
RUN usermod -aG sudo stu
67+
RUN passwd -d stu
68+
USER $USERNAME
69+
CMD ["/bin/bash"]

.devcontainer/devcontainer.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "OS-Course-Lab-Dev",
3+
"build": { "dockerfile": "Dockerfile" },
4+
"remoteUser": "stu",
5+
"updateRemoteUserUID": true,
6+
"runArgs": ["--hostname", "Chcore"],
7+
"customizations": {
8+
"vscode": {
9+
"extensions": [
10+
"ms-vscode.cpptools",
11+
"ms-vscode.hexeditor",
12+
"llvm-vs-code-extensions.vscode-clangd",
13+
"ms-vscode.makefile-tools",
14+
"dan-c-underwood.arm"
15+
]
16+
}
17+
}
18+
}

.github/workflows/github-pages.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
name: GitHub Pages
2-
32
on:
43
push:
54
sources:
@@ -26,7 +25,7 @@ jobs:
2625
run: |
2726
mkdir mdbook
2827
tag=$(curl 'https://api.github.com/repos/toolmanp/rs-mdbook-callouts/releases/latest' | jq -r '.tag_name')
29-
url="https://github.com/toolmanp/rs-mdbook-callouts/releases/download/${tag}/mdbook-callouts-x86_64-unknown-linux-gnu.tar.gz"
28+
url="https://github.com/toolmanp/rs-mdbook-callouts/releases/download/${tag}/mdbook-callouts-${tag}-x86_64-unknown-linux-gnu.tar.gz"
3029
curl -sSL $url | tar -xz --directory=./mdbook
3130
tag=$(curl 'https://api.github.com/repos/rust-lang/mdbook/releases/latest' | jq -r '.tag_name')
3231
url="https://github.com/rust-lang/mdbook/releases/download/${tag}/mdbook-${tag}-x86_64-unknown-linux-gnu.tar.gz"
@@ -37,8 +36,8 @@ jobs:
3736
tag=$(curl 'https://api.github.com/repos/badboy/mdbook-last-changed/releases/latest' | jq -r '.tag_name')
3837
url="https://github.com/badboy/mdbook-last-changed/releases/download/${tag}/mdbook-last-changed-${tag}-x86_64-unknown-linux-gnu.tar.gz"
3938
curl -sSL $url | tar -xz --directory=./mdbook
40-
tag=$(curl 'https://api.github.com/repos/badboy/mdbook-mermaid/releases/latest' | jq -r '.tag_name')
41-
url="https://github.com/badboy/mdbook-mermaid/releases/download/${tag}/mdbook-mermaid-${tag}-x86_64-unknown-linux-gnu.tar.gz"
39+
tag=$(curl 'https://api.github.com/repos/toolmanp/mdbook-mermaid/releases/latest' | jq -r '.tag_name')
40+
url="https://github.com/toolmanp/mdbook-mermaid/releases/download/${tag}/mdbook-mermaid-${tag}-x86_64-unknown-linux-gnu.tar.gz"
4241
curl -sSL $url | tar -xz --directory=./mdbook
4342
echo `pwd`/mdbook >> $GITHUB_PATH
4443
- name: Setup Pages

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ cscope.*
1010
!/**/firmware/*.elf
1111

1212
build
13-
.vscode
1413
simulate.sh
1514
debug.sh
1615
.config

Lab0/Makefile

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
LAB := 0
2+
TIMEOUT := 10
23

3-
PROJECT := $(CURDIR)/..
4-
GRADER := $(PROJECT)/Scripts/grader.sh
4+
include $(CURDIR)/../Scripts/lab.mk
55

6-
export PROJECT CURDIR LAB
7-
8-
include $(PROJECT)/Scripts/lab.mk
6+
export LABROOT LABDIR LAB TIMEOUT
97

108
bomb: student-number.txt
119
@echo " GEN bomb"
@@ -17,19 +15,19 @@ clean:
1715

1816
## execute bomb
1917
qemu:
20-
@qemu-aarch64 bomb
18+
@$(QEMU) bomb
2119

2220
qemu-gdb:
23-
@qemu-aarch64 -g 1234 bomb
21+
@$(QEMU) -g 1234 bomb
2422

2523
qemu-grade:
26-
@qemu-aarch64 bomb < ans.txt
24+
@$(QEMU) bomb < ans.txt
2725

2826
gdb:
2927
$(GDB) -ex "set architecture aarch64" -ex "target remote localhost:1234" -ex "add-symbol-file bomb"
3028

3129
grade:
32-
@$(GRADER)
30+
@$(GRADER) -t $(TIMEOUT) -f $(CURDIR)/scores.json make qemu-grade
3331

3432
submit:
3533
@echo " SUBMIT lab0"

Lab0/grade.exp

Lines changed: 0 additions & 42 deletions
This file was deleted.

Lab0/scores.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[
2+
{
3+
"capture": "Congrats! You have defused all phases!",
4+
"msg": "Bomb Defused",
5+
"proposed": 100
6+
}
7+
]

Lab0/scripts/generate_bomb.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
#!/bin/bash
22

3-
if [[ -z $PROJECT ]]; then
4-
echo "Please set the PROJECT environment variable to the root directory of your project. (Makefile)"
3+
if [[ -z $LABROOT ]]; then
4+
echo "Please set the LABROOT environment variable to the root directory of your project. (Makefile)"
55
exit 1
66
fi
77

8-
if [[ ! -d "${CURDIR}/warehouse" ]]; then
8+
if [[ ! -d "${LABDIR}/warehouse" ]]; then
99
echo "Please run under the root directory of this lab!"
1010
exit 1
1111
fi
1212

1313
total_bombs=30
14-
student=$(cat ${CURDIR}/student-number.txt)
14+
student=$(cat ${LABDIR}/student-number.txt)
1515

1616
if [[ -z $student ]]; then
1717
echo "Please enter your student number in student-number.txt at first! Otherwise you would recieve 0 POINTS!"
@@ -20,4 +20,4 @@ fi
2020

2121
bomb_id=$(($student % $total_bombs + 1))
2222

23-
cp ${CURDIR}/warehouse/bomb-${bomb_id} ${CURDIR}/bomb
23+
cp ${LABDIR}/warehouse/bomb-${bomb_id} ${LABDIR}/bomb

Lab1/.clangd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CompileFlags:
2+
CompilationDatabasePath: build/kernel/

Lab1/.vscode/launch.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "QEMU (cppdbg)",
6+
"type": "cppdbg",
7+
"request": "launch",
8+
"program": "${workspaceFolder}/build/kernel.img",
9+
"args": [],
10+
"cwd": "${workspaceFolder}",
11+
"environment": [],
12+
"externalConsole": false,
13+
"stopAtEntry": true,
14+
"stopAtConnect": true,
15+
"setupCommands": [
16+
{
17+
"description": "Enable pretty-printing for gdb",
18+
"text": "-enable-pretty-printing",
19+
"ignoreFailures": true
20+
},
21+
],
22+
"MIMode": "gdb",
23+
"targetArchitecture": "arm64",
24+
"miDebuggerServerAddress": "localhost:1234",
25+
"miDebuggerPath": "/usr/local/bin/gdb",
26+
"preLaunchTask": "Setup QEMU"
27+
}
28+
]
29+
}

0 commit comments

Comments
 (0)