Mercurial > hg > Document > Growi
changeset 88:fd9f5bb6fb3d
backup 2021-09-16
author | autobackup |
---|---|
date | Thu, 16 Sep 2021 00:10:04 +0900 (2021-09-15) |
parents | c3604a1c6b0e |
children | 171fc32d9b07 |
files | user/matac42/docker-xv6.md user/matac42/singularity-xv6.md |
diffstat | 2 files changed, 214 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/user/matac42/docker-xv6.md Thu Sep 16 00:10:04 2021 +0900 @@ -0,0 +1,108 @@ +# dockerなxv6でdebugする + +docker for macを用います + +- https://docs.docker.com/desktop/mac/install/ + +## お手軽 + +これを使う + +- https://github.com/matac42/xv6-riscv + +`$git clone git@github.com:matac42/xv6-riscv.git` + +`$cd xv6-riscv` + +`$docker-compose build --no-cache` + +`$docker-compose run --name xv6 xv6` + +別端末にて + +`$docker exec -it xv6 /bin/sh` + +`#gdb-multiarch` + +## 詳細 + +### xv6をcloneする + +`$git clone git@github.com:mit-pdos/xv6-riscv.git` + +`$cd xv6-riscv` + +### Dockerfile, docker-compose.yml, root-gdbinitを作成する + +**Dockerfile** + +```Dockerfile +FROM debian:10.3 + +COPY root-gdbinit /root/.gdbinit + +RUN apt-get update && apt-get install -y \ + git \ + build-essential \ + gdb-multiarch \ + qemu-system-misc \ + gcc-riscv64-linux-gnu \ + binutils-riscv64-linux-gnu + +WORKDIR /xv6 + +# for running +#CMD [ "make", "qemu" ] +# for debug +CMD [ "make", "qemu-gdb" ] +``` + +**docker-compose.yml** + +```docker-compose.yml +version: "3.8" +services: + xv6: + build: . + container_name: xv6 + volumes: + - .:/xv6 + working_dir: /xv6 +``` + +**root-gdbinit** + +``` +add-auto-load-safe-path /xv6/.gdbinit +set auto-load safe-path / +``` + +### build & run + +`$docker-compose build` + +`$docker-compose run --name xv6 xv6` + +### debug + +別端末にて + +`$docker exec -it xv6 /bin/sh` + +`#gdb-multiarch` + +**example** + +``` +(gdb) file kernel/fs.c +"/xv6/kernel/fs.c": not in executable format: file format not recognized +(gdb) b iget +Breakpoint 1 at 0x8000337c: file kernel/fs.c, line 244. +(gdb) c +Continuing. +[Switching to Thread 2] + +Thread 2 hit Breakpoint 1, iget (dev=1, inum=3) at kernel/fs.c:244 +244 { +(gdb) +``` \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/user/matac42/singularity-xv6.md Thu Sep 16 00:10:04 2021 +0900 @@ -0,0 +1,106 @@ +# singularityなxv6の作成 + +学科サーバー上のsingularityを用いた + +## 作成したsif + +`amane:/ie-ryukyu/singularity/xv6`においてある + +### 単にxv6を起動する + +`$cd /ie-ryukyu/singularity/xv6` + +`$singularity shell --fakeroot --writable xv6.sif` + +`Singularity> cd /xv6/xv6-riscv` + +`Singularity> make qemu` + +### debugする + +`$cd /ie-ryukyu/singularity/xv6` + +`$singularity shell --fakeroot --writable xv6.sif` + +`Singularity> cd /xv6/xv6-riscv` + +`Singularity> make qemu-gdb` + +別端末、同ディレクトリにて + +`$singularity shell --fakeroot --writable xv6.sif` + +`Singularity> cd /xv6/xv6-riscv` + +`Singularity> gdb-multiarch` + +## sif作成の手順 + +### defファイルを作成する + +`$cd /ie-ryukyu/singularity/xv6` + +xv6.def +``` +BootStrap: docker +From: debian:10.10 + +%post + apt update + apt install -y \ + git \ + zsh \ + build-essential \ + gdb-multiarch \ + qemu-system-misc \ + gcc-riscv64-linux-gnu \ + binutils-riscv64-linux-gnu +``` + +### build + +`$singularity build --sandbox --fakeroot xv6 xv6.def` + +### singularityのシェルに入る + +`$singularity shell --fakeroot --writable xv6` + +### 作業ディレクトリを作成する + +`Singularity> mkdir /xv6` + +`Singularity> cd /xv6` + +### 足りなかったもの追加 + +`Singularity> apt install vim` + +`Singularity> vim /root/.gdbinit` + +/root/.gdbinit +``` +add-auto-load-safe-path /xv6/xv6-riscv/.gdbinit +set auto-load safe-path / +``` + +### xv6をcloneする + +`Singularity> git clone git@github.com:mit-pdos/xv6-riscv.git` + +`Singularity> cd xv6-riscv` + +### makeしてみる + +`Singularity> make qemu` (Ctrl+a xで抜ける) + +`Singularity> make qemu-gdb` (Ctrl+a xで抜ける) + +### sifに変換する + +singularityのシェルを抜けてから + +`$singularity build --fakeroot xv6.sif xv6` + +### sifを用いてsingularityのシェルに入る + +`$singularity shell xv6.sif` \ No newline at end of file