Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changes between Initial Version and Version 1 of CoreFiles

2010-02-06T22:12:04Z (10 years ago)
Jiri Svoboda

Core files. Finally.


  • CoreFiles

    v1 v1  
     1= Working with core files =
     3HelenOS can now produce an ELF core file when a task crashes. While you cannot really use it yet in HelenOS directly, you can extract this core file and use it with GDB to debug the application. Note that only memory state is saved as of yet. Register state is not stored in the core file. Here we assume you are using Linux as your host system and that you run HelenOS in Qemu.
     5First configure and build HelenOS as follows:
     7 * Load preconfigured defaults: ia32 (or amd64)
     8 * Enable options: Load disk drivers on startup, Mount /data on startup, Write core files
     10Now we need a disk image with a FAT filesystem. Make sure it has at least 20 MB (we are using 4 kB clusters and we must have at least 4 k clusters for FAT16).
     13$ dd if=/dev/zero of=img bs=4096 count=5000
     14$ losetup /dev/loop0 img
     15$ mkdosfs -s 8 /dev/loop0
     16$ losetup -d /dev/loop0
     19Run HelenOS in Qemu now and it will mount the new filesystem on {{{/data}}} automatically.
     22$ qemu -hda img -cdrom image.iso -boot d
     25Good. Now we can take the crashdump. If you run {{{tester fault1}}} it will save a core dump under /data. Another way is to dump a running task. Let's start Tetris, determine it's task ID using the kernel console and finally run {{{taskdump}}} on it.
     28# tetris
     29[press F2 to switch to another VC]
     30# kcon
     31kconsole> tasks
     3332 tetris....
     34kconsole> continue
     35# taskdump -t 32 -c /data/coretet
     36# unmount /data
     39The last command {{{unmount /data}}} forces all data to be written out to the block device. Exit Qemu. Now you can extract the core file, for example with the following commands (tip: save this as a shell script).
     44mkdir /tmp/hcore
     45losetup /dev/loop0 img
     46mount -t vfat -o fat=16 /dev/loop0 /tmp/hcore
     47cp /tmp/hcore/core* .
     48umount /tmp/hcore
     49losetup -d /dev/loop0
     50rmdir /tmp/hcore
     51chmod 644 core*
     54Now you have the file {{{coretet}}} in your HelenOS source root directory. Time to fire up GDB:
     57$ gdb uspace/dist/app/tetris coretet
     60It will complain that register state is not present in the core file, but it will work. Also note that you may want to compile your binary with debugging symbols so that type and line number information is available to GDB... Happy debugging!