当前位置:网站首页>Project0:小游戏
Project0:小游戏
2022-07-01 10:15:00 【Ingsuifon】
2.1 找到故障指令
FAIL
Test output failed to match any acceptable form.
Acceptable output:
do-nothing: exit(162)
Differences in `diff -u' format:
- do-nothing: exit(162)
+ Page fault at 0xc0000008: rights violation error reading page in user context.
+ do-nothing: dying due to interrupt 0x0e (#PF Page-Fault Exception).
+ Interrupt 0x0e (#PF Page-Fault Exception) at eip=0x80488ee
+ cr2=c0000008 error=00000005
+ eax=00000000 ebx=00000000 ecx=00000000 edx=00000000
+ esi=00000000 edi=00000000 esp=bfffffe4 ebp=bffffffc
+ cs=001b ds=0023 es=0023 ss=0023
- 程序试图从用户空间访问哪个虚拟地址导致它崩溃?
0xc0000008 - 导致崩溃的指令的虚拟地址是什么?
0x80488ee - 要进行调查,请使用 objdump 反汇编 do-nothing 二进制文件。程序崩溃时所在的函数的名称是什么?,并确定程序崩溃的指令。
080488e8 <_start>:
80488e8: 55 push %ebp
80488e9: 89 e5 mov %esp,%ebp
80488eb: 83 ec 18 sub $0x18,%esp
80488ee: 8b 45 0c mov 0xc(%ebp),%eax ;argv
80488f1: 89 44 24 04 mov %eax,0x4(%esp)
80488f5: 8b 45 08 mov 0x8(%ebp),%eax ;argc
80488f8: 89 04 24 mov %eax,(%esp)
80488fb: e8 94 f7 ff ff call 8048094 <main>
8048900: 89 04 24 mov %eax,(%esp)
8048903: e8 d3 21 00 00 call 804aadb <exit>
- 找到您在上面确定的函数的 C 代码(提示:它是在用户空间中执行的,因此它位于 do-nothing.c 或 proj-pregame/src/lib 或 proj-pregame/src/lib/user 中的文件之一)。对于 #3 中反汇编函数中的每条指令,用几句话解释为什么它是必要的和/或它试图做什么。提示:参见 80x86 调用约定。
向 main 函数传递参数。80x86 的函数参数都是通过栈传送,而80x86_64 的前 6 个参数通过寄存器传送。
//proj-pregame/src/lib/user/entry.c
#include <syscall.h>
int main(int, char* []);
void _start(int argc, char* argv[]);
void _start(int argc, char* argv[]) {
exit(main(argc, argv)); }
- 为什么您在 #3 中确定的指令尝试访问您在 #1 中确定的虚拟地址处的内存?不要用寄存器的值来解释这个;我们正在寻找更高层次的解释。
此时指令想要将参数 argv 作为调用 main 函数的参数,而 ebp 指向它的旧值,ebp + 4 指向返回地址,ebp + 8 指向 argc,ebp + 12 指向 argv,因此该指令试图访问该虚拟地址。
2.2 单步调试崩溃
- 进入进程执行功能。运行此函数的线程的名称和地址是什么?目前 Pintos 中还有哪些其他线程?复制他们的线程结构。
名称为 main,地址为 0xc000e000
pintos-debug: dumplist #0: 0xc000e000 {
tid = 1, status = THREAD_RUNNING, name = "main", '\000' <repeats 11 times>, stack = 0xc000e
dbc "\001", priority = 31, allelem = {
prev = 0xc0039cf8 <all_list>, next = 0xc0104020}, elem = {
prev = 0xc0039ce8 <fifo_ready_list
>, next = 0xc0039cf0 <fifo_ready_list+8>}, pcb = 0xc010500c, magic = 3446325067}
pintos-debug: dumplist #1: 0xc0104000 {
tid = 2, status = THREAD_BLOCKED, name = "idle", '\000' <repeats 11 times>, stack = 0xc0104
f14 "", priority = 0, allelem = {
prev = 0xc000e020, next = 0xc0039d00 <all_list+8>}, elem = {
prev = 0xc0039ce8 <fifo_ready_list>,
next = 0xc0039cf0 <fifo_ready_list+8>}, pcb = 0x0, magic = 3446325067}
- 当前线程的回溯是什么?从 GDB 复制回溯作为您的答案,并复制对应于每个函数调用的 C 代码行。
#0 process_execute (file_name=0xc0007d50 "do-nothing") at ../../userprog/process.c:55
#1 0xc0020a19 in run_task (argv=0xc0039bec <argv+12>) at ../../threads/init.c:317
#2 0xc0020b8f in run_actions (argv=0xc0039bec <argv+12>) at ../../threads/init.c:390
#3 0xc00203d9 in main () at ../../threads/init.c:138
process_wait(process_execute(task));
a->function(argv);
run_actions(argv);
- 在 start_process 处设置断点并继续运行到该点。运行此函数的线程的名称和地址是什么?目前 Pintos 中还有哪些其他线程?复制他们的结构线程。
do-nothing,0xc010b000。
pintos-debug: dumplist #0: 0xc000e000 {
tid = 1, status = THREAD_BLOCKED, name = "main", '\000' <repeats 11 times>, stack = 0xc000e
e7c "", priority = 31, allelem = {
prev = 0xc0039cf8 <all_list>, next = 0xc0104020}, elem = {
prev = 0xc003b718 <temporary+4>, next
= 0xc003b720 <temporary+12>}, pcb = 0xc010500c, magic = 3446325067}
pintos-debug: dumplist #1: 0xc0104000 {
tid = 2, status = THREAD_BLOCKED, name = "idle", '\000' <repeats 11 times>, stack = 0xc0104
f14 "", priority = 0, allelem = {
prev = 0xc000e020, next = 0xc010b020}, elem = {
prev = 0xc0039ce8 <fifo_ready_list>, next = 0xc003
9cf0 <fifo_ready_list+8>}, pcb = 0x0, magic = 3446325067}
pintos-debug: dumplist #2: 0xc010b000 {
tid = 3, status = THREAD_RUNNING, name = "do-nothing\000\000\000\000\000", stack = 0xc010bf
d4 "", priority = 31, allelem = {
prev = 0xc0104020, next = 0xc0039d00 <all_list+8>}, elem = {
prev = 0xc0039ce8 <fifo_ready_list>,
next = 0xc0039cf0 <fifo_ready_list+8>}, pcb = 0x0, magic = 3446325067}
- 单步执行 start_process 函数,直到您跨过对 load 的调用。注意 load 设置 if_ 结构中的 eip 和 esp 字段。打印出 if_ 结构的值,以十六进制显示值(提示: p/x if )。
{
edi = 0x0, esi = 0x0, ebp = 0x0, esp_dummy = 0x0, ebx = 0x0, edx = 0x0, ecx = 0x0, eax = 0x0, gs = 0x23, fs = 0x23, es = 0x2
3, ds = 0x23, vec_no = 0x0, error_code = 0x0, frame_pointer = 0x0, eip = 0x80488e8, cs = 0x1b, eflags = 0x202, esp = 0xc0000000, s
s = 0x23}
- asm volatile 语句中的第一条指令将堆栈指针设置为 if_ 结构的底部。第二条指令跳转到 intr_exit。代码中的注释解释了这里发生了什么。单步执行 asm volatile 语句,然后单步执行指令。当您逐步执行 iret 指令时,观察到函数“返回”到用户空间。为什么在执行此函数时处理器会切换模式?请随时根据 iret 时内存和/或寄存器中的值来解释这一点执行,以及 iret 指令的功能。
intr_exit:
52│ /* Restore caller's registers. */
53│ popal
54│ popl %gs
55│ popl %fs
56│ popl %es
57│ popl %ds
58│
59│ /* Discard `struct intr_frame' vec_no, error_code, 60│ frame_pointer members. */
61│ addl $12, %esp
边栏推荐
- TC8:UDP_ USER_ INTERFACE_ 01-08
- 客户端如何请求数据库?
- 【论文阅读】Trajectory-guided Control Prediction for End-to-end Autonomous Driving: A Simple yet Strong Ba
- C [byte array] and [hexadecimal string] mutual conversion - codeplus series
- Kotlin coprocessor scheduling switch threads it's time to unravel the truth
- TC8:UDP_USER_INTERFACE_01-08
- 【Laravel 】faker数据填充详解
- What is cloud primordial? Will it be the trend of future development?
- 全球基金和资管的股票建仓率达到15年内新低
- Win11账号被锁定无法登录怎么办?Win11账号被锁定无法登录
猜你喜欢

机器学习之线性回归详解

Floyd repeat

北汽蓝谷:业绩承压,极狐难期

What if the win11 account is locked and unable to log in? Win11 account is locked and unable to log in

预制菜迎来“黄金时代”,谁能领跑下一个万亿市场

Eat a rich woman's melon...

渗透常用工具-Goby

Zero foundation software testing must see, 10 years of testing old bird's conscience suggestions (a total of 15)

CodeBlocks 左侧项目栏消失,workspace 自动保存项目,Default workspace,打开上次的workspace,工作区(图文教程,已解决)

Common penetration tools -goby
随机推荐
scratch大鱼吃小鱼 电子学会图形化编程scratch等级考试二级真题和答案解析2022年6月
The "China Mobile Chain" state secret engine was officially launched on BSN
If you meet a female driver and drive didi as an amateur, you can earn 500 a day!
Venv: directory structure of venv
IDEA运行报错Command line is too long. Shorten command line for...
渗透常用工具-Goby
How did the data center change from "Britney Spears" to "Mrs. cow"?
Does anyone know the logic of limit statement execution in Clickhouse? In the picture, the SQL above can be executed successfully
微信表情符号写入判决书,你发的OK、炸弹都可能成为“呈堂证供”
MySQL interception_ MySQL method for intercepting strings [easy to understand]
Zero foundation software testing must see, 10 years of testing old bird's conscience suggestions (a total of 15)
SQL Server列一相同的情况下,如何取列二的最大值,并重新生成表
基于Matlab的开环Buck降压斩波电路Simulink仿真电路模型搭建
C one line code calculates the MD5 value of the file - codeplus series
What a high commission! The new programmer's partner plan is coming. Everyone can participate!
How do clients request databases?
[laravel] detailed explanation of faker data filling
12.Gateway新一代网关
零基础入门测试该学什么?最全整理,照着学就对了
The Lantern Festival is held on the fifteenth day of the first month, and the Lantern Festival begins to celebrate the reunion