Well, I did get what I wanted, and was able to single step the visopsys kernel with QEMU and gdb.
First, I set QEMU to start with "stopped" option:
Code: Select all
qemu-system-i386 -hda ./visopsys1.img -cdrom ./visopsys-2014-12-02.iso -boot d -s -serial stdio -S
Then, in separate terminal, I started gdb:
Code: Select all
gdb ./visopsys
(loading debug symbols)
(gdb) target remote localhost:1234
(gdb) b identify
(Breakpoint 1 at 0xc0047a45: file kernelIdeDriver.c, line 1081.)
(gdb) cont
(Continuing.)
Breakpoint 1, identify (diskNum=diskNum@entry=0,
buffer=buffer@entry=0xc00d841c) at kernelIdeDriver.c:1081
1081 {
(gdb) si
I tried to pick a series of good breakpoints, so that I might isolate the issue quicker, which is that the device was not identified. The following is a small snippet of the debugging session. I guess I should study the code to select some good breakpoints for this issue...
Code: Select all
0xc004631b 367 kernelProcessorInPort8(DISK_CHAN(diskNum).ports.altComStat,
369 if (statReg & ATA_STAT_ERR)
0xc0046321 369 if (statReg & ATA_STAT_ERR)
376 if (kernelSysTimerRead() > (startTime + timeout))
kernelSysTimerRead () at kernelSysTimer.c:136
136 if (systemTimer == NULL)
0xc002cf3d 136 if (systemTimer == NULL)
141 if (ops->driverRead == NULL)
0xc002cf49 141 if (ops->driverRead == NULL)
148 timer = ops->driverRead();
0xc0053cc5 in driverRead () at kernelSysTimerDriver.c:71
71 }
driverSetupTimer (counter=-1073454261, mode=-1073257218, count=0)
at kernelSysTimerDriver.c:115
115 {
0xc0053ccc in driverSetupTimer (counter=-1073257218, mode=0, count=37)
at kernelSysTimerDriver.c:115
115 {
0xc0053ccd in driverSetupTimer (counter=0, mode=20, count=-1072856236)
at kernelSysTimerDriver.c:115
115 {
0xc004634b in waitOperationComplete (diskNum=diskNum@entry=0,
yield=yield@entry=0, dataWait=dataWait@entry=1, ack=0, timeout=20)
at kernelIdeDriver.c:376
376 if (kernelSysTimerRead() > (startTime + timeout))
0xc004634e 376 if (kernelSysTimerRead() > (startTime + timeout))
346 if (yield && !DISK_CHAN(diskNum).gotInterrupt)
0xc0046296 346 if (yield && !DISK_CHAN(diskNum).gotInterrupt)
355 if (DISK_CHAN(diskNum).gotInterrupt)
0xc00462bf 355 if (DISK_CHAN(diskNum).gotInterrupt)
367 kernelProcessorInPort8(DISK_CHAN(diskNum).ports.altComStat,
0xc004631c 367 kernelProcessorInPort8(DISK_CHAN(diskNum).ports.altComStat,
369 if (statReg & ATA_STAT_ERR)
0xc0046321 369 if (statReg & ATA_STAT_ERR)
376 if (kernelSysTimerRead() > (startTime + timeout))
kernelSysTimerRead () at kernelSysTimer.c:136
136 if (systemTimer == NULL)
0xc002cf3d 136 if (systemTimer == NULL)
141 if (ops->driverRead == NULL)
0xc002cf44 141 if (ops->driverRead == NULL)
148 timer = ops->driverRead();
0xc0053cc5 in driverRead () at kernelSysTimerDriver.c:71
71 }
driverSetupTimer (counter=-1073454261, mode=-1073257218, count=0)
at kernelSysTimerDriver.c:115
115 {
0xc0053ccc in driverSetupTimer (counter=-1073257218, mode=0, count=37)
at kernelSysTimerDriver.c:115
115 {
0xc0053ccd in driverSetupTimer (counter=0, mode=20, count=-1072856236)
at kernelSysTimerDriver.c:115
115 {
0xc004634b in waitOperationComplete (diskNum=diskNum@entry=0,
yield=yield@entry=0, dataWait=dataWait@entry=1, ack=0, timeout=20)
at kernelIdeDriver.c:376
376 if (kernelSysTimerRead() > (startTime + timeout))
0xc004634e 376 if (kernelSysTimerRead() > (startTime + timeout))
346 if (yield && !DISK_CHAN(diskNum).gotInterrupt)
0xc0046296 346 if (yield && !DISK_CHAN(diskNum).gotInterrupt)
355 if (DISK_CHAN(diskNum).gotInterrupt)
0xc00462bf 355 if (DISK_CHAN(diskNum).gotInterrupt)
367 kernelProcessorInPort8(DISK_CHAN(diskNum).ports.altComStat,
0xc004631c 367 kernelProcessorInPort8(DISK_CHAN(diskNum).ports.altComStat,
369 if (statReg & ATA_STAT_ERR)
0xc0046321 369 if (statReg & ATA_STAT_ERR)
376 if (kernelSysTimerRead() > (startTime + timeout))
kernelSysTimerRead () at kernelSysTimer.c:136
136 if (systemTimer == NULL)
(gdb) quit
A debugging session is active.
Obviously I really need to find some decent breakpoints. Stepping with "n" commands directly in GDB results in ugly output. I'd do better with an IDE here (emacs). But, I'm feeling like I might learn something about your kernel!