In a previous post, I wrote about how to setup and run xv6 operating system on a QEMU platform. However, when making changes and doing advanced stuff with xv6 operating system, it is highly necessary to have debugging option to see how things work behind the seen. Let's run xv6 with debugging mode enabled.
(1) First of all, I should configure my GDB. Since the source code of xv6 is located in /home/asanka/Downloads/my-xv6/xv6-master of my computer, I have to do the following. First I should move into my home directory and create a text file as follows
nano .gdbinit
Then add the following line inside it.
add-auto-load-safe-path /home/asanka/Downloads/my-xv6/xv6-master/.gdbinit
nano .gdbinit
Then add the following line inside it.
add-auto-load-safe-path /home/asanka/Downloads/my-xv6/xv6-master/.gdbinit
Now save the file and exit from nano editor.
(2) It's time to start and run our xv6 system. Open a terminal and goto xv6 directory and start it.
make qemu-gdb
It will start QEMU but will stop in the middle with a black screen. Now, open a new
terminal tab inside the same source code directory of xv6 and run the command
gdb
It will bring us to the (gdb) prompt. We can add some break points here as follows.
break main.c:main
break trap
break alltraps
Finally we are ready to continue the program execution of xv6. For that, type
following command on (gdb) prompt.
continue
or you can simply type,
c
Now, the OS will start booting in the QEMU window but will stop at the breakpoints to give us some information at the (gdb) prompt. In each time it stops at a breakpoint, we can use above continue or c command to move to the next breakpoint. Finallly, when we want to quit, we can close QEMU window to stop xv6 OS and then in the terminal where the (gdb) prompt is running, type quit in order to exit from the debugging session.
References:
No comments:
Post a Comment