nopsys / CogNOS

A Cog VM in the bare metal using the Nopsys library
33 stars 5 forks source link

The release built by travis has problems with qemu #49

Open melkyades opened 6 years ago

melkyades commented 6 years ago

When building the system manually qemu seems to work fine, but in the image generated by travis something seems to be broken. Here is a backtrace of the code that causes the #PF and below are a few steps to debug the failing build:

(gdb) bt

0 0x0000000000459bde in warpPickSmoothPixelsxDeltahyDeltahxDeltavyDeltavsourceMapsmoothingdstShiftInc (nPixels=0, xDeltah=8776656, xDeltah@entry=65537,

yDeltah=518, yDeltah@entry=0, xDeltav=xDeltav@entry=0, yDeltav=yDeltav@entry=65537, sourceMap=sourceMap@entry=106196800, n=n@entry=4, 
dstShiftInc=dstShiftInc@entry=-32) at ../../src/plugins/BitBltPlugin/BitBltPlugin.c:8005

1 0x000000000045be22 in warpLoop () at ../../src/plugins/BitBltPlugin/BitBltPlugin.c:7760

2 0x000000000045c1a9 in primitiveWarpBits () at ../../src/plugins/BitBltPlugin/BitBltPlugin.c:5648

3 0x000000000042cf6d in primitiveExternalCall () at ../../spurstack64src/vm/gcc3x-interp.c:68089

4 0x0000000000436d7c in interpret () at ../../spurstack64src/vm/gcc3x-interp.c:5704

5 0x0000000000441075 in interpret () at ../../spurstack64src/vm/gcc3x-interp.c:2455

6 0x0000000000405b4e in nopsys_vm_main (image=, image_length=57484688) at sqMain.c:18

7 0x0000000000402c9c in nopsys_main (magic=, mbi=0x10000) at main.c:37


We need to open the nopsys.kernel file which is in nopsys.vmdk. For that, we need to access the fat partition and copy the file out.

qemu-img convert -f vmdk -O raw nopsys.vmdk nopsys.raw
dd if=nopsys.raw of=fat.raw bs=512 skip=$((2097152/512))  #the start of the fat partition
mcopy -i fat.raw ::nopsys.kernel nopsys.kernel

now we've got the kernel out, we can debug with gdb. In one terminal we run

$>qemu-system-x86_64 -s -boot d -hda nopsys.vmdk -m 512

and in other one we run

$> gdb nopsys.kernel -x qemudbg

where qemudbg has to be copied from nopsys/boot. Within gdb, you'll want to add the directories where sources are stored, using the directory command.