微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

使用bochs+gdb调试linux-0.11时遇到一些问题

如何解决使用bochs+gdb调试linux-0.11时遇到一些问题

我在使用 bochs+gdb 调试 linux-0.11 内核 时遇到了一些问题。 这是我所做的:

以调试模式启动boch

root@fb805494fb03:~/oslab# ./run
========================================================================
                       Bochs x86 Emulator 2.4.6
             Build from CVS snapshot,on February 22,2011
                   Compiled at Jun  8 2013,05:16:04
========================================================================
00000000000i[     ] LTDL_LIBRARY_PATH not set. using compile time default '/usr/lib/bochs/plugins'
00000000000i[     ] BXSHARE not set. using compile time default '/usr/share/bochs'
00000000000i[     ] reading configuration from ./bochs/bochsrc-gdb.bxrc
00000000000i[     ] Enabled gdbstub
00000000000i[     ] reading configuration from ./bochs/bochsrc.bxrc
00000000000i[     ] lt_dlhandle is 0x2158f30
00000000000i[PlgiN] loaded plugin libbx_sdl.so
00000000000i[     ] installing sdl module as the Bochs GUI
00000000000i[     ] using log file ./bochsout.txt
Waiting for gdb connection on port 1235

运行 gdb:

root@fb805494fb03:~/oslab/linux-0.11/tools# gdb  ~/oslab/linux-0.11/tools/system

GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.3) 7.7.1
copyright (C) 2014 Free Software Foundation,Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY,to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions,please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help,type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /root/oslab/linux-0.11/tools/system...done.
(gdb) b main
Breakpoint 1 at 0x66d1: file init/main.c,line 110.
(gdb) target remote 127.0.0.1:1235
Remote debugging using 127.0.0.1:1235
startup_32 () at boot/head.s:19
19              movl $0x10,%eax
(gdb) c
Continuing.

Program received signal SIGTRAP,Trace/breakpoint trap.
0xffff0000 in ?? ()
(gdb) c
Continuing.

[Thread <main>] #1 stopped.
0x00000002 in startup_32 () at boot/head.s:19
19              movl $0x10,%eax
(gdb) c
Continuing.

[Thread <main>] #1 stopped.
startup_32 () at boot/head.s:19
19              movl $0x10,%eax
(gdb) c
Continuing.

[Thread <main>] #1 stopped.
0x00020df0 in user_stack ()
(gdb) c
Continuing.

[Thread <main>] #1 stopped.
0x00000002 in startup_32 () at boot/head.s:19
19              movl $0x10,%eax
(gdb) s
0x00ffd065 in ?? ()
(gdb) s
Cannot find bounds of current function
(gdb) c
Continuing.

[Thread <main>] #1 stopped.
0x00000002 in startup_32 () at boot/head.s:19
19              movl $0x10,%eax
(gdb)
Continuing.

[Thread <main>] #1 stopped.
0x00000002 in startup_32 () at boot/head.s:19
19              movl $0x10,%eax
(gdb)
...

当我按下 c 一千次时,它终于在 bochs 中出现了 [/usr/root] #

enter image description here

为什么它没有停在 main

这会是 GDB 版本的问题吗?

我在docker中运行了Ubuntu 14,在上面做了这一系列的操作

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。