forked from WebFreak001/code-debug
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fad0a4f
commit 2d39d51
Showing
6 changed files
with
142 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
## 用 code-debug 调试 x86 Starry | ||
|
||
首先,我们将Makefile中的 `MODE ?= release` 改为 `MODE ?= debug` | ||
|
||
其次,将主目录中的Cargo.toml里的`lto = true`注释掉 | ||
|
||
接着,将`modules/axdriver/build.rs`里的`.align 16`改为`.align 4096` | ||
|
||
最后,运行Starry并输出到一个文本文件中: | ||
|
||
``` | ||
./build_img.sh sdcard | ||
make A=apps/oscomp LOG=debug QEMU_LOG=y ARCH=x86_64 run > output.txt | ||
``` | ||
|
||
打开`output.txt`并将Qemu的启动参数修改为`launch.json`: | ||
|
||
```json | ||
//launch.json | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"type": "gdb", | ||
"request": "launch", | ||
"name": "Attach to Qemu", | ||
"executable": "${userHome}/Starry-x86/Starry/apps/oscomp/oscomp_x86_64-qemu-q35.elf", | ||
"target": ":1234",//不能和Qemu开放的tcp端口重叠 | ||
"remote": true, | ||
"cwd": "${workspaceRoot}", | ||
"valuesFormatting": "parseText", | ||
"gdbpath": "gdb-multiarch", | ||
"showDevDebugOutput":true, | ||
"internalConsoleOptions": "openOnSessionStart", | ||
"printCalls": true, | ||
"stopAtConnect": true, | ||
"qemuPath": "qemu-system-x86_64", | ||
"qemuArgs": [ | ||
"-m", | ||
"2G", | ||
"-smp", | ||
"1", | ||
"-machine", | ||
"q35", | ||
"-kernel", | ||
"apps/oscomp/oscomp_x86_64-qemu-q35.elf", | ||
"-device", | ||
"virtio-blk-pci,drive=disk0", | ||
"-drive", | ||
"id=disk0,if=none,format=raw,file=disk.img", | ||
"-device", | ||
"virtio-net-pci,netdev=net0", | ||
"-netdev", | ||
"user,id=net0,hostfwd=tcp::1235-:5555,hostfwd=udp::5555-:5555", | ||
"-nographic", | ||
"-s", | ||
"-S" | ||
], | ||
"userSpaceDebuggeeFolder": "${userHome}/Starry-x86/Starry/testcases/sdcard/bin/", | ||
"KERNEL_IN_BREAKPOINTS_LINE":12, // src/trap/mod.rs中内核入口行号。可能要修改 | ||
"KERNEL_OUT_BREAKPOINTS_LINE":770, // src/trap/mod.rs中内核出口行号。可能要修改 | ||
"GO_TO_KERNEL_LINE":30, // src/trap/mod.rs中,用于从用户态返回内核的断点行号。在rCore-Tutorial-v3中,这是set_user_trap_entry函数中的stvec::write(TRAMPOLINE as usize, TrapMode::Direct);语句。 | ||
"KERNEL_IN_BREAKPOINTS_FILENAME":"/home/oslab/Starry-x86/Starry/modules/axhal/src/arch/x86_64/trap.rs", | ||
"KERNEL_OUT_BREAKPOINTS_FILENAME":"/home/oslab/Starry-x86/Starry/modules/axtask/src/task.rs", | ||
"GO_TO_KERNEL_FILENAME":"" | ||
}, | ||
] | ||
} | ||
``` | ||
|
||
一定要debug模式。release模式没有文件名 | ||
|
||
riscv版本 | ||
离谱:debug一定要用lto | ||
Failed to get Stack Trace: PC not saved (from stack-info-depth --thread 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters