1

Firstly, I am now learning OS implementation from MIT-jos

and I want to trace bootmain(void) which locates in boot/main.c

But I don't know how to set breakpoint there,

I do set gdb source directory to both boot and obj/boot

(gdb) dir boot:obj/boot
Source directories searched:     
/home/osdi/lab/boot:/home/osdi/lab/obj/boot:$cdir:$cwd

when I set breakpoint at bootmain(void), gdb complains:

(gdb) b bootmain
Function "bootmain" not defined.
Make breakpoint pending on future shared library load? (y or [n]) 

So,how can I correctly set breakpoint at bootmain(void?)

Secondly, I can only set breakpoint by address

(gdb) b *0x7c00
Breakpoint 1 at 0x7c00

but when I want to list the code,gdb again complains "No such file or directory"

[   0:7c00] => 0x7c00:  cli    
Breakpoint 1, 0x00007c00 in ?? ()
(gdb) list
1   {standard input}: No such file or directory.
    in {standard input}

So,how can I list the information correctly?

thanks~

user3094631
  • 425
  • 3
  • 13

2 Answers2

0

Tracing in boot/boot.asm

call bootmain
    7c45: e8 c0 00 00 00 call 7d0a <bootmain>

Bootmain function starts at 0x7d0a

Tony Tannous
  • 14,154
  • 10
  • 50
  • 86
0

Run into same issue recently and google a while but no luck with a solution. Read gdb output and lab guide and find the root cause.

It turns out you need set symbol-file to boot, then all work good. Please see following gdb output. In line '+ symbol-file obj/kern/kernel', we can see it use kernel as symbol-file by default. since bootmain() is located in boot, so we need switch to boot symbol-file.

I've summarize it in this blog.

The target architecture is assumed to be i8086
[f000:fff0]    0xffff0: ljmp   $0xf000,$0xe05b
0x0000fff0 in ?? ()
+ symbol-file obj/kern/kernel

(gdb) symbol-file obj/boot/boot.out
Load new symbol table from "obj/boot/boot.out"? (y or n) y
Reading symbols from obj/boot/boot.out...done.
(gdb) b bootmain
Breakpoint 1 at 0x7d15: file boot/main.c, line 40.
(gdb) c
Continuing.
Evan
  • 1