1. 程式人生 > >Linux-0.11-Lab: 五分鐘實驗環境

Linux-0.11-Lab: 五分鐘實驗環境

http://www.tinylab.org/project/linux-0-11-lab/

專案描述

該專案致力於快速構建一個 Linux 0.11 實驗環境,可配合《Linux核心完全註釋》 一書使用。

  • 基本特性:
    • 包含所有可用的映像檔案: ramfs/floppy/hard disk image。
    • 輕鬆支援 qemu 和 bochs,可通過配置 tools/vm.cfg 切換。
    • 可以生成任何函式的呼叫關係,方便程式碼分析:make cg f=func d=file|dir
    • 支援 Ubuntu 和 Mac OS X,在 VirtualBox 的支援下也可以在 Windows 上工作。
    • 測試過的編譯器: Ubuntu: gcc-4.8, Mac OS X:i386-elf-gcc 4.7.2
    • 在解壓之前整個大小隻有 30M

相關文章

五分鐘教程

準備

以 Ubuntu 和 Qemu 為例, 對於 Mac OS X 和 Bochs 的用法,請參考 README.md.

apt-get install vim cscope exuberant-ctags build-essential qemu
12apt-getinstall vim cscopeexuberant-ctagsbuild-essentialqemu

下載

git clone https://github.com/tinyclub/linux-0.11-lab.git
12gitclonehttps://github.com/tinyclub/linux-0.11-lab.git

編譯

make
12make

從硬碟啟動

make start-hd
12makestart-hd

除錯

開啟一個終端並啟動進入除錯模式:

make debug-hd
12makedebug-hd

開啟另外一個終端啟動 gdb 開始除錯:

gdb images/kernel.sym (gdb) target remote :1234 (gdb) b main (gdb) c
12345gdbimages/kernel.sym(gdb)target remote:1234(gdb)bmain(gdb)c

獲得幫助

make help > Usage: make --generate a kernel floppy Image with a fs on hda1 make start -- boot the kernel in qemu make start-fd -- boot the kernel with fs in floppy make start-hd -- boot the kernel with fs in hard disk make debug -- debug the kernel in qemu & gdb at port 1234 make debug-fd -- debug the kernel with fs in floppy make debug-hd -- debug the kernel with fs in hard disk make disk -- generate a kernel Image & copy it to floppy make cscope -- genereate the cscope index databases make tags -- generate the tag file make cg -- generate callgraph of the system architecture make clean -- clean the object files make distclean -- only keep the source code files
12345678910111213141516makehelp>Usage:make--generateakernelfloppy Image withafson hda1make start--bootthe kernel inqemumakestart-fd--bootthe kernel withfs infloppymake start-hd--bootthe kernel withfs inhard diskmakedebug--debug the kernelinqemu&gdbat port1234make debug-fd--debugthe kernel withfs infloppymakedebug-hd--debugthe kernel withfs inhard diskmake disk--generateakernel Image&copyit tofloppymakecscope--genereate the cscope index databasesmake tags--generatethe tag filemakecg--generate callgraph of the systemarchitecturemake clean--cleanthe objectfilesmakedistclean--only keep thesource code files

生成 main 函式呼叫關係

make cg ls calltree/linux-0.11.jpg
123makecgls calltree/linux-0.11.jpg

See:

Linux 0.11 Calltree