Skip to content

ci: enable commitlint && markdownlint #23

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

Merged
merged 4 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .commitlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"extends": ["@commitlint/config-conventional"],
"rules": {
"type-enum": [
2,
"always",
[
"block",
"bot",
"build",
"chore",
"ci",
"docs",
"infra",
"feat",
"refactor",
"scripts",
"vcs"
]
],
"body-leading-blank": [2, "always"],
"footer-leading-blank": [2, "always"],
"subject-max-length": [2, "always", 72],
"body-max-line-length": [1, "always", 72]
}
}
19 changes: 19 additions & 0 deletions .github/workflows/commitlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Commitlint

on: [push, pull_request]

permissions:
contents: read
pull-requests: read

jobs:
lint:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: wagoid/commitlint-github-action@v6
with:
configFile: "./.commitlintrc.json"
helpURL: "https://sjtu-ipads.github.io/OS-Course-Lab/Contribute.html#%E4%BB%A3%E7%A0%81%E8%A7%84%E8%8C%83"
18 changes: 15 additions & 3 deletions .github/workflows/github-pages.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,34 @@
name: GitHub Pages
on:
push:
sources:
paths:
- "Pages/**"
- "README.md"
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false

permissions:
contents: write
contents: write
pages: write
id-token: write

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: DavidAnson/markdownlint-cli2-action@v16
with:
globs: Pages/**.md

build:
runs-on: ubuntu-latest
needs: lint
steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -50,7 +62,7 @@ jobs:
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: 'book'
path: "book"
deploy:
environment:
name: github-pages
Expand Down
9 changes: 9 additions & 0 deletions .markdownlint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"default": true,
"MD003": false,
"MD012": false,
"MD013": false,
"MD033": false,
"MD028": false,
"MD040": false
}
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -48,27 +48,27 @@ Contents of the .debug_info section:
> ELF文件所使用的调试信息格式为DWARF格式,如果感兴趣你可以它的官网[^DWARF]来详细了解。

构建完成后,在左侧侧边栏找到调试按钮,点击后在上方找到`QEMU(cppdbg)`的调试设置点击调试,既可以运行我们预先准备好的vscode gdb设置。此时你的调试器会暂停自动停在`start.S`中,此时你就可以像c++课上进行debug的方式一样自由的打断点以及观察点并进行调试了。由于`qemu-system-aarch64`模拟了所有的机器核心,在左侧显示了四个线程的调用堆栈。当你关闭调试后,qemu会自动退出,与调试普通的程序是一致的.
![](./assets/vscode-gdb.png)
![vscode-gdb](./assets/vscode-gdb.png)

### Debug Console

那么如果我们有的时候还是想要敲一下键盘输一些gui没有的命令,比如让gdb罗列一下这个镜像里有多少函数,此时`debug adapter protocol`协议
会帮助我们向gdb传输命令,在代码编辑栏下方的`DEBUG CONSOLE`展示的就是我们cpptools所连接的`gdb-mi`的所返回的输出,此时使用`-exec <command>`即可以如同往常我们使用gdb一样获取我们所需要的信息,如`-exec info functions` 即可以提取我们需要该镜像中的所有符号。
![](./assets/vscode-console.png)
![vscode-console](./assets/vscode-console.png)

### Disassembler

由于我们对一些重要的代码只提供了预先编译的可链接文件,所以这些文件一般都没有调试符号,但是你仍然可以对其进行的反编译代码进行查看
例如`arm64_elX_to_el1`函数你可以使用`-exec b arm64_elX_to_el1`进行断点添加,当你点击继续执行后此时`gdb-mi`会抛出异常并停下执行。
此时打开vscode的命令面板输入`disassembly`打开反编译器面板即找到断点出的代码信息,在这个面板里你也可以使用单步调试对`汇编`进行调试。
![](./assets/vscode-disassembly.png)
![vscode-disassembly](./assets/vscode-disassembly.png)

### Hex Editor

有的时候你想对一块内存区域使用16进制编码进行查看,但是苦于gdb羸弱的表达方法效率很差,此时你可以使用Microsoft官方的`hex editor`来直接进行查看,
你可以在左方的watchpoint中输入内存地址或者变量地址,当你停下后在watchpoint的右侧会出现一个16进制的按钮点开既可以对你监视点的内存区域的
内容进行16进制的编辑与阅读。这个工具当你在苦于调试一段内存读写代码的时候很有用处。
![](./assets/vscode-hex.png)
![vscode-hex](./assets/vscode-hex.png)

### GDB Stub

Expand Down
1 change: 1 addition & 0 deletions Pages/Changes.md
4 changes: 1 addition & 3 deletions Pages/Lab0/defuse.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ x0
"Type in your defuse password!"

```

在破解后续阶段时,为了避免每次都需要输入先前阶段的拆弹密码,你可以通过重定向的方式来让炸弹程序读取文件中的密码:

```console
Expand All @@ -81,6 +82,3 @@ Type in your defuse password:
Congrats! You have defused all phases!

```



10 changes: 5 additions & 5 deletions Pages/Lab1/pte.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@

[^huge-page]: 操作系统:原理与实现

![](assets/lab1-trans.svg)
![lab1-trans](assets/lab1-trans.svg)

其中,当映射为 1GB 块或 2MB 块时,图中 L2、L3 索引或 L3 索引的位置和低 12 位共同组成块内偏移。

每一级的每一个页表占用一个 4KB 物理页,称为页表页(Page Table Page),其中有 512 个条目,每个条目占 64 位。AArch64 中,页表条目称为描述符(descriptor)[^descriptor],最低位(bit[0])为 `1` 时,描述符有效,否则无效。有效描述符有两种类型,一种指向下一级页表(称为表描述符),另一种指向物理块(大页)或物理页(称为块描述符或页描述符)。在上面所说的地址翻译配置下,描述符结构如下(“Output address”在这里即物理地址,一些地方称为物理页帧号(Page Frame Number,PFN)):

**L0、L1、L2 页表描述符**
- **L0、L1、L2 页表描述符**

![](assets/lab1-pte-1.png)
![lab1-pte-1](assets/lab1-pte-1.png)

**L3 页表描述符**
- **L3 页表描述符**

![](assets/lab1-pte-2.png)
![lab1-pte-2](assets/lab1-pte-2.png)

[^descriptor]: Arm Architecture Reference Manual, D5.3

Expand Down
3 changes: 2 additions & 1 deletion Pages/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[前言](./Intro.md)
[如何开始实验](./Getting-started.md)
[贡献指南](./Contribute.md)
[CHANGELOG](./Changes.md)
---

- [Lab0:拆炸弹](./Lab0.md)
Expand Down Expand Up @@ -30,4 +31,4 @@
- [GDBServer](./Appendix/toolchains/qemu/usage.md)
- [Kernel: ELF格式](./Appendix/elf.md)
- [Kernel: Linker Script](./Appendix/linker.md)
- [Kernel: 调试指北](./Appendix/debugging.md)
- [Kernel: 调试指北](./Appendix/kernel-debugging.md)
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
> [!NOTE]
> 如果你有任何建议或更正意见,欢迎提交 Pull Requests 或 Issues。让我们一起合作改进实验

## Lab0: 拆炸弹(ARM汇编)
## Lab0: 拆炸弹 (ARM 汇编)

该实验受到CSAPP课程启发,CSAPP课程设计了一个针对x86/x86-64汇编的拆炸弹实验。
不同之处在于,本实验目标是熟悉ARM汇编语言,并为后续的ARM/树莓派内核实验做好准备。
Expand Down