x64 ubuntu下bochs+gdb调试PintOS

先装上bochs:http://blog.csdn.net/hitwhylz/article/details/24596011

装首先要执行:

$ sudo apt-get install libc6:i386 libgcc1:i386 gcc-4.6-base:i386 libstdc++5:i386 libstdc++6:i386
$ sudo apt-get install libncurses5:i386
$ sudo apt-get install g++-multilib

然后再装。

首先在终端执行命令:

galaxy@galaxy-virtual-machine:~/pintos/src/threads/build$ ../../utils/pintos --gdb -s -- run alarm-multiple

然后新建一个终端:

galaxy@galaxy-virtual-machine:~/pintos/src/threads/build$ gdb kernel.o
GNU gdb (Ubuntu 7.7-0ubuntu3) 7.7
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 kernel.o...done.
(gdb) target remote localhost:1234
Remote debugging using localhost:1234
0x0000fff0 in ?? ()
(gdb) b init.c:main
Breakpoint 1 at 0xc00201c8: file ../../threads/init.c, line 78.
(gdb) c
Continuing.

Breakpoint 1, main () at ../../threads/init.c:78
78    {
(gdb) n
82      bss_init ();
(gdb) si
0xc00201d9 in bss_init () at ../../threads/init.c:150
150      memset (&_start_bss, 0, &_end_bss - &_start_bss);
(gdb) si
0xc00201de    150      memset (&_start_bss, 0, &_end_bss - &_start_bss);
(gdb) si
0xc00201e2    150      memset (&_start_bss, 0, &_end_bss - &_start_bss);
(gdb) si
0xc00201ea    150      memset (&_start_bss, 0, &_end_bss - &_start_bss);
(gdb) si
0xc00201f1    150      memset (&_start_bss, 0, &_end_bss - &_start_bss);
(gdb) ni
read_command_line () at ../../threads/init.c:201
201      argc = *(uint32_t *) ptov (LOADER_ARG_CNT);
(gdb) define hook-stop
Type commands for definition of "hook-stop".
End with a line saying just "end".
>x/i $pc
>end
(gdb) si
=> 0xc00201fc <main+52>:    mov    $0x0,%edi
204      for (i = 0; i < argc; i++)
(gdb) si
=> 0xc0020201 <main+57>:    mov    $0xc0007d3e,%ebx
202      p = ptov (LOADER_ARGS);
(gdb) si
=> 0xc0020206 <main+62>:    test   %esi,%esi
204      for (i = 0; i < argc; i++)
(gdb) si
=> 0xc0020208 <main+64>:    jg     0xc002023b <main+115>
0xc0020208    204      for (i = 0; i < argc; i++)
(gdb) si
=> 0xc002023b <main+115>:    mov    %ebx,-0x3ffcb860(,%edi,4)
209          argv[i] = p;
(gdb) si
=> 0xc0020242 <main+122>:    mov    $0xc0007dbe,%eax
210          p += strnlen (p, end - p) + 1;
(gdb)

 

posted @ 2014-07-15 17:33  乾卦  阅读(394)  评论(0)    收藏  举报