当前位置:网站首页>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
边栏推荐
- If you meet a female driver and drive didi as an amateur, you can earn 500 a day!
- 投稿开奖丨轻量应用服务器征文活动(5月)奖励公布
- 零基础入门测试该学什么?最全整理,照着学就对了
- What should I learn in the zero foundation entry test? It's the most comprehensive. Just learn from it
- Simulink simulation circuit model of open loop buck buck buck chopper circuit based on MATLAB
- STM32逆变器电源设计方案,基于STM32F103控制器[通俗易懂]
- C one line code calculates the MD5 value of the file - codeplus series
- 大佬们,数据湖iceberg的数据,怎样导出到mysql? 有什么工具? sqoop,datax都没
- 【Laravel 】faker数据填充详解
- Ubuntu system installation and MySQL configuration
猜你喜欢
CodeBlocks 左侧项目栏消失,workspace 自动保存项目,Default workspace,打开上次的workspace,工作区(图文教程,已解决)
缺少比较器,运放来救场!(运放当做比较器电路记录)
投稿开奖丨轻量应用服务器征文活动(5月)奖励公布
Win11账号被锁定无法登录怎么办?Win11账号被锁定无法登录
新数据库时代,不要只学 Oracle、MySQL
Common penetration tools -goby
bash: ln: command not found
C one line code calculates the MD5 value of the file - codeplus series
数字藏品平台搭建需要注意哪些法律风险及资质?
CSDN一站式云服务开放内测,诚邀新老用户来抢鲜
随机推荐
Lack of comparator, operational amplifier to save the field! (the op amp is recorded as a comparator circuit)
Does anyone know why? The table structure is the source table MySQL CDC that has just been directly copied
SQL optimization - in and not in, exist
SQL SERVER2014删除数据库失败,报错偏移量0x0000...
How do clients request databases?
CodeBlocks 左侧项目栏消失,workspace 自动保存项目,Default workspace,打开上次的workspace,工作区(图文教程,已解决)
京东与腾讯续签三年战略合作协议;起薪涨至26万元!韩国三星SK争相加薪留住半导体人才;Firefox 102 发布|极客头条...
442. 数组中重复的数据
The Lantern Festival is held on the fifteenth day of the first month, and the Lantern Festival begins to celebrate the reunion
It is interesting to understand MMAP in this way!
在通达信上买基金安全吗?
[laravel] detailed explanation of faker data filling
微信表情符号写入判决书,你发的OK、炸弹都可能成为“呈堂证供”
Sqlization is the first step in ETL incremental production. What are the core capabilities of such an architecture?
Sleeping second brother...
树莓派4B系统搭建(超详细版)
好高的佣金,《新程序员》合伙人计划来袭,人人皆可参与!
bash: ln: command not found
CSDN's one-stop cloud service is open for internal testing, and new and old users are sincerely invited to grab the fresh
Live broadcast management project