首页 > 解决方案 > 我在使用 bochs+gdb 调试 linux-0.11 时遇到了一些问题

问题描述

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

以调试模式启动 bochs

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了一千次时,它终于[/usr/root] #在bochs中出现了。

在此处输入图像描述

为什么它没有停止main

这会是 GDB 版本的问题吗?

我在docker里跑了Ubuntu 14,在上面做了这一系列的操作

标签: linuxdebugginggdbbochs

解决方案


推荐阅读