I write codes about P-Mode,and sometimes it doesn't runs well,
for example the PC restart and so on, I want to know if I can
get error information,and how to do?
How to get error information
- gravaera
- Member
- Posts: 737
- Joined: Tue Jun 02, 2009 4:35 pm
- Location: Supporting the cause: Use \tabs to indent code. NOT \x20 spaces.
Re: How to get error information
Yo:
The bochs error log, (or homologous output from whatever emulator you use) is highly useful for debugging boot problems, but ideally since it's very easy to boot a kernel (the firmware does most of the initial work, and then it jumps to you, so the hardware is usable by the time you gain control), you shouldn't be too dependent on a log from an emulator. I'd advise you to go learn about the PC boot process, so you can understand the boot sequence from power-on up until it gets to your kernel's entry point.
Then you can make better debugging assumptions, and not depend on an emulator constantly. Additionally, the adage still applies: Infinite loops, HLT opcodes and printf()s will competently debug all of your problems until you get into concurrent processing (SMP), and even then I'd say it can still be used to debug about 40-60% of the problems you'll have to debug
So try learning about the boot process, and that way you'll have a more intuitive feel for what's happening. It has the added advantage of you being more equipped to debug problems that occur on IRL r3al h4rdwar3z .
--All the best
gravaera
The bochs error log, (or homologous output from whatever emulator you use) is highly useful for debugging boot problems, but ideally since it's very easy to boot a kernel (the firmware does most of the initial work, and then it jumps to you, so the hardware is usable by the time you gain control), you shouldn't be too dependent on a log from an emulator. I'd advise you to go learn about the PC boot process, so you can understand the boot sequence from power-on up until it gets to your kernel's entry point.
Then you can make better debugging assumptions, and not depend on an emulator constantly. Additionally, the adage still applies: Infinite loops, HLT opcodes and printf()s will competently debug all of your problems until you get into concurrent processing (SMP), and even then I'd say it can still be used to debug about 40-60% of the problems you'll have to debug
So try learning about the boot process, and that way you'll have a more intuitive feel for what's happening. It has the added advantage of you being more equipped to debug problems that occur on IRL r3al h4rdwar3z .
--All the best
gravaera
17:56 < sortie> Paging is called paging because you need to draw it on pages in your notebook to succeed at it.
- DavidCooper
- Member
- Posts: 1150
- Joined: Wed Oct 27, 2010 4:53 pm
- Location: Scotland
Re: How to get error information
When the PC crashes, just before it reboots it will try to run some interrupt code to handle the fault, so if you build an IDT for protected mode and link it up to some debug code you may be able to work out what caused the crash - your debug code should be able to look at the information that's been put on the stack by the fault to find out which instruction it failed at, and then it can display that information on the screen. Maybe someone has written some simple code to do this which you could copy and use - if so, perhaps they might be kind enough to post it here for you. I've never got round to writing such code myself because I wrote a monitor program instead - it lets me run my code indirectly so that I can see where it goes wrong, so that's another option you might want to try. I assume that you can do the same kind of thing in Bochs without having to go to the trouble of writing a monitor program of your own, but I designed mine to be able to display all the names of routines and variables while it runs the code, and that makes it easy to see which bit of code is running even while it's running at full gallop (which is one instruction per key repeat for as long as I hold the key down).leetow2003 wrote:I write codes about P-Mode,and sometimes it doesn't runs well,
for example the PC restart and so on, I want to know if I can
get error information,and how to do?
Help the people of Laos by liking - https://www.facebook.com/TheSBInitiative/?ref=py_c
MSB-OS: http://www.magicschoolbook.com/computing/os-project - direct machine code programming
MSB-OS: http://www.magicschoolbook.com/computing/os-project - direct machine code programming
-
- Member
- Posts: 70
- Joined: Fri Nov 19, 2010 6:54 pm
Re: How to get error information
[quote="DavidCooper
When the PC crashes, just before it reboots it will try to run some interrupt code to handle the fault, so if you build an IDT for protected mode and link it up to some debug code you may be able to work out what caused the crash - ......[/quote]
How to know the interrupt vector? When the PC crashed,how to link the debug code because I don't
know the vector.
When the PC crashes, just before it reboots it will try to run some interrupt code to handle the fault, so if you build an IDT for protected mode and link it up to some debug code you may be able to work out what caused the crash - ......[/quote]
How to know the interrupt vector? When the PC crashed,how to link the debug code because I don't
know the vector.
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: How to get error information
I think RTFM applies here. Intel 3A - exception reference.
- DavidCooper
- Member
- Posts: 1150
- Joined: Wed Oct 27, 2010 4:53 pm
- Location: Scotland
Re: How to get error information
I think you might be best off trying working within Bochs because the standard log that it provides does actually tell you which instruction your code crashes at and gives you the contents of all the registers at that point. That will save you from writing any debug code of your own and you won't have to do anything special to set Bochs up for the job. You'll also find it much more efficient for your trial-and-error approach to learning how things work.leetow2003 wrote:How to know the interrupt vector? When the PC crashed,how to link the debug code because I don't know the vector.
Help the people of Laos by liking - https://www.facebook.com/TheSBInitiative/?ref=py_c
MSB-OS: http://www.magicschoolbook.com/computing/os-project - direct machine code programming
MSB-OS: http://www.magicschoolbook.com/computing/os-project - direct machine code programming