In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
In the last blog, we wrote a main bootstrap program, which runs perfectly and has correctly achieved the function we want. So the problem is, it just displays a string, and if the program dies before the string is displayed, how should we check it at this time? In other words, how do you debug the code in the main boot area? Today we are going to introduce another excellent virtual machine software (Bochs).
First take a look at some of the characteristics of Bochs: 1, professional simulation of the x86 architecture of the virtual machine; 2, it is open source and high portability, the source code is written by C++; 3, support operating system development process of breakpoint debugging; 4, through simple configuration will be able to run on the vast majority of mainstream operating systems.
So how do you configure a version of Bochs that supports debugging? The steps are as follows
1. Download source code: https://sourceforge.net/projects/bochs/files/
2. Decompress bochs-2.x.x.tar.gz to get bochs-2.x.x folder
3. Enter the source directory: cd bochs-2.x.x
4. Configure:. / configure-- enable-debugger-- enable-disasm
5 、 make
6 、 make install
After the above six steps, the Bochs environment is built. It is worth noting that the blogger made an error in the construction process, which occurred in the fifth step of make: / usr/bin/ld: gui/libgui.a (gtk_enh_dbg_osdep.o): undefined reference to symbo error so that the execution could not continue. After searching the data, the solution is to Makefile in the bochs-2.x.x folder. Find LIBS = around line 92. Add-lpthread at the end of the line to ok. Note: do not re-configure after the modification, otherwise the added-lpthread will disappear, just make it after you add it.
After setting up the environment, we need to configure a startup file, bochsrc.txt, with the following contents
On the above startup files in several path determination methods are as follows: 1, determine the installation path of bochs: which bochs;2, install vgabios, determine its path: whereis vgabios.
Let's take a look at the ways to start the bochs virtual machine, which are divided into two ways: explicit boot and implicit boot.
A > Show launch: bochs-f bochsrc_file
B > implicit startup: bochs
So how do you verify the debugging environment? After we start bochs, press 6 to simulate startup, and then type continue. If the analog terminal shows the string we want to print, we have successfully installed the bochs virtual machine. Let's take a look at the final effect picture.
After we enter the bochs implicit startup mode, and then enter 6 to simulate the startup terminal, the results are as follows
We see that the terminal successfully displays our own output string after entering continue, which proves that our bochs environment has been successfully built at this time. So how do we debug bochs (similar to GDB debugging in Linux)? Some common debugging commands for bochs are as follows
Let's try to set a breakpoint as follows
We see that after setting the breakpoint 0x7c00, info looks at the breakpoint information and does hit a breakpoint at 0x7c00. Continue the continue execution and find that the virtual machine bochs has been powered on successfully. We see that the next instruction it is going to execute is mov ax, cs. Is it the first instruction of start that we wrote at that time? Yes, it is, so what does the 8cc8 behind it mean? It refers to the data of the address corresponding to this instruction. Let's continue to execute continue to see the final effect.
We see that the main bootstrap program written by ourselves has been successfully executed. Next, let's perform the next step debugging to see the results.
We see that the result of single-step debugging of step is the same as the code of the main bootstrapper we wrote earlier. Through the construction of the debugging environment bochs today, the summary is as follows: 1, bochs is a professional virtual machine simulating x86 architecture; 2, installing bochs from the source code can get debugging support; 3, the startup configuration file of bochs is the key to running correctly; 4. Bochs supports breakpoint debugging, and its debugging commands are similar to GDB debugging.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.