Save .log output files to out/arch/

This is cleaner as it removes yet another .gitignore rule and allows
for one command per arch.

This was prompted by the recent Docker patch creating files as root,
which then breaks future host runs.

Also separate all arguments by newlines. This:

- makes it much easier to minimize when reporting QEMU bugs
- shows the full command on the screen despite line wrapping being turned off
  by one of the annoying emulators, to be investigated.

The commands are not yet pristine, because:

- there are some leading spaces
- options not sorted

but it is already a huge improvement, and those operations are now be easy from Vim.

The general strategy is:

- end every variable containing a command with a newline
- when expanding such variables, don't add an extra newline
This commit is contained in:
Ciro Santilli
2018-04-08 16:55:06 +01:00
parent 21499559eb
commit 9e79b9b06f
5 changed files with 113 additions and 97 deletions

1
.gitignore vendored
View File

@@ -1,5 +1,4 @@
# Extensions and prefixes. # Extensions and prefixes.
*.log
*.tmp *.tmp
*~ *~
?*.gitignore ?*.gitignore

View File

@@ -1436,7 +1436,7 @@ To enable initrd instead of the default ext2 disk image, do:
Notice how it boots fine, even though this leads to not giving QEMU the `-drive` option, as can be verified with: Notice how it boots fine, even though this leads to not giving QEMU the `-drive` option, as can be verified with:
.... ....
cat ./run.log cat ./out/x86_64/run.sh
.... ....
Also as expected, there is no filesystem persistency, since we are doing everything in memory: Also as expected, there is no filesystem persistency, since we are doing everything in memory:
@@ -3799,7 +3799,7 @@ Stdout shows a line with the full command of type:
and this line is also saved to a file for convenience: and this line is also saved to a file for convenience:
.... ....
cat ./run.log cat ./out/arm/run.sh
.... ....
Next, you will also want to give the relevant images to save them time. Zip the images with: Next, you will also want to give the relevant images to save them time. Zip the images with:

36
build
View File

@@ -5,7 +5,7 @@ set -- ${cli_build:-} "$@"
rm -f br2_cli.gitignore rm -f br2_cli.gitignore
touch br2_cli.gitignore touch br2_cli.gitignore
configure=true configure=true
config_fragments='br2' config_fragments=br2
extra_make_args= extra_make_args=
gem5=false gem5=false
j="$(nproc)" j="$(nproc)"
@@ -29,7 +29,8 @@ while getopts 'a:B:b:CGgj:hIiK:klp:qSv' OPT; do
configure=false configure=false
;; ;;
G) G)
extra_make_args="$extra_make_args gem5-reconfigure" extra_make_args="${extra_make_args} gem5-reconfigure \\
"
gem5=true gem5=true
;; ;;
g) g)
@@ -60,17 +61,20 @@ BR2_TARGET_ROOTFS_INITRAMFS=n
linux_kernel_custom_config_file="$OPTARG" linux_kernel_custom_config_file="$OPTARG"
;; ;;
k) k)
extra_make_args="$extra_make_args kernel_module-reconfigure" extra_make_args="${extra_make_args} kernel_module-reconfigure \\
"
;; ;;
l) l)
linux_reconfigure=true linux_reconfigure=true
extra_make_args="$extra_make_args linux-reconfigure" extra_make_args="${extra_make_args} linux-reconfigure \\
"
;; ;;
p) p)
post_script_args="$OPTARG" post_script_args="$OPTARG"
;; ;;
q) q)
extra_make_args="$extra_make_args host-qemu-reconfigure" extra_make_args="${extra_make_args} host-qemu-reconfigure \\
"
;; ;;
S) S)
qemu_sdl= qemu_sdl=
@@ -84,7 +88,7 @@ BR2_TARGET_ROOTFS_INITRAMFS=n
esac esac
done done
shift $(($OPTIND - 1)) shift $(($OPTIND - 1))
extra_make_args="$extra_make_args $@" extra_make_args="${extra_make_args} $@"
set_common_vars "$arch" "$gem5" set_common_vars "$arch" "$gem5"
config_file="${buildroot_out_dir}/.config" config_file="${buildroot_out_dir}/.config"
case "$arch" in case "$arch" in
@@ -173,15 +177,15 @@ cd "${buildroot_dir}"
# #
# BR2_ options may be given on the command line here, and they do have direct "define" effects. # BR2_ options may be given on the command line here, and they do have direct "define" effects.
# But this is generally bad, as it skips the Kconfig mechanism, e.g. it does not set defaults properly. # But this is generally bad, as it skips the Kconfig mechanism, e.g. it does not set defaults properly.
cmd="time \ cmd="time \\
env \ env \\
-u LD_LIBRARY_PATH \ -u LD_LIBRARY_PATH \\
make \ make \\
O='${buildroot_out_dir}' \ O='${buildroot_out_dir}' \\
HOST_QEMU_OPTS='--enable-debug --extra-cflags=-DDEBUG_PL061=1 --enable-trace-backends=simple ${qemu_sdl}' \ HOST_QEMU_OPTS='--enable-debug --extra-cflags=-DDEBUG_PL061=1 --enable-trace-backends=simple ${qemu_sdl}' \\
V='$v' \ V='${v}' \\
${extra_make_args} \ ${extra_make_args} \
all \ all \\
" "
echo "$cmd" | tee "${root_dir}/build.log" echo "$cmd" | tee "${out_arch_dir}/build.sh"
eval "$cmd" eval "$cmd"

140
run
View File

@@ -38,11 +38,13 @@ while getopts a:c:DdE:e:f:G:ghIiKkm:T:Vx OPT; do
cpus="$OPTARG" cpus="$OPTARG"
;; ;;
D) D)
debug_vm='gdb -q -ex start --args' debug_vm="gdb -q -ex start --args \\
"
;; ;;
d) d)
debug=true debug=true
extra_flags_qemu="$extra_flags_qemu -S" extra_flags_qemu="$extra_flags_qemu -S \\
"
;; ;;
E) E)
lkmc_eval="$OPTARG" lkmc_eval="$OPTARG"
@@ -54,7 +56,8 @@ while getopts a:c:DdE:e:f:G:ghIiKkm:T:Vx OPT; do
extra_append_after_dash="$extra_append_after_dash $OPTARG" extra_append_after_dash="$extra_append_after_dash $OPTARG"
;; ;;
G) G)
gem5opts="$OPTARG" gem5opts="$OPTARG \\
"
;; ;;
g) g)
gem5=true gem5=true
@@ -76,7 +79,8 @@ while getopts a:c:DdE:e:f:G:ghIiKkm:T:Vx OPT; do
extra_append="$extra_append kgdbwait" extra_append="$extra_append kgdbwait"
# For those who want to try KDB. # For those who want to try KDB.
#extra_append="$extra_append kgdbwait kgdboc=kbd" #extra_append="$extra_append kgdbwait kgdboc=kbd"
extra_flags_qemu="$extra_flags_qemu -serial tcp::1234,server,nowait" extra_flags_qemu="$extra_flags_qemu -serial tcp::1234,server,nowait \\
"
kgdb=true kgdb=true
;; ;;
m) m)
@@ -89,7 +93,8 @@ while getopts a:c:DdE:e:f:G:ghIiKkm:T:Vx OPT; do
nographic=false nographic=false
;; ;;
V) V)
vnc='-vnc :0' vnc="-vnc :0 \\
"
;; ;;
?) ?)
exit 2 exit 2
@@ -119,8 +124,9 @@ if [ -n "$lkmc_eval" ]; then
extra_append_after_dash="${extra_append_after_dash} lkmc_eval=\"$(printf "$lkmc_eval" | base64)\"" extra_append_after_dash="${extra_append_after_dash} lkmc_eval=\"$(printf "$lkmc_eval" | base64)\""
fi fi
if "$nographic" && [ "$arch" = x86_64 ]; then if "$nographic" && [ "$arch" = x86_64 ]; then
extra_append="$extra_append console=ttyS0" extra_append="${extra_append} console=ttyS0"
extra_flags_qemu="$extra_flags_qemu -nographic" extra_flags_qemu="${extra_flags_qemu} -nographic \\
"
fi fi
if [ -n "$extra_append_after_dash" ]; then if [ -n "$extra_append_after_dash" ]; then
extra_append="${extra_append} - ${extra_append_after_dash}" extra_append="${extra_append} - ${extra_append_after_dash}"
@@ -136,18 +142,18 @@ if "$gem5"; then
gem5_arch=ARM gem5_arch=ARM
fi fi
gem5_common="\ gem5_common="\
M5_PATH='${gem5_build_dir}/system' \ M5_PATH='${gem5_build_dir}/system' \\
${debug_vm} \ ${debug_vm} \
'${gem5_src_dir}/build/${gem5_arch}/gem5.opt' \ '${gem5_src_dir}/build/${gem5_arch}/gem5.opt' \\
--debug-file=trace.txt \ --debug-file=trace.txt \\
${gem5opts} \ ${gem5opts} \
-d '${m5out_dir}' \ -d '${m5out_dir}' \\
'${gem5_src_dir}/configs/example/fs.py' \ '${gem5_src_dir}/configs/example/fs.py' \\
--disk-image='${images_dir}/rootfs.ext2' \ --disk-image='${images_dir}/rootfs.ext2' \\
--kernel='${buildroot_out_dir}/build/linux-custom/vmlinux' \ --kernel='${buildroot_out_dir}/build/linux-custom/vmlinux' \\
--mem-size=${memory} \ --mem-size='${memory}' \\
--num-cpus='${cpus}' \ --num-cpus='${cpus}' \\
--script='${readfile_file}' \ --script='${readfile_file}' \\
" "
if [ "$arch" = x86_64 ]; then if [ "$arch" = x86_64 ]; then
if "$kvm"; then if "$kvm"; then
@@ -155,16 +161,16 @@ ${gem5opts} \
fi fi
cmd="\ cmd="\
${gem5_common} \ ${gem5_common} \
--command-line='earlyprintk=ttyS0 console=ttyS0 lpj=7999923 root=/dev/hda ${extra_append}' \ --command-line='earlyprintk=ttyS0 console=ttyS0 lpj=7999923 root=/dev/hda ${extra_append}' \\
${extra_flags} \ ${extra_flags} \
" "
elif [ "$arch" = arm ] || [ "$arch" = aarch64 ]; then elif [ "$arch" = arm ] || [ "$arch" = aarch64 ]; then
# TODO why is it mandatory to pass mem= here? Not true for QEMU. # TODO why is it mandatory to pass mem= here? Not true for QEMU.
# Anything smaller than physical blows up as expected, but why can't it auto-detect the right value? # Anything smaller than physical blows up as expected, but why can't it auto-detect the right value?
cmd="${gem5_common} \ cmd="${gem5_common} \
--command-line='earlyprintk=pl011,0x1c090000 console=ttyAMA0 lpj=19988480 rw loglevel=8 mem=${memory} root=/dev/sda ${extra_append}' \ --command-line='earlyprintk=pl011,0x1c090000 console=ttyAMA0 lpj=19988480 rw loglevel=8 mem=${memory} root=/dev/sda ${extra_append}' \\
--dtb-file='${gem5_src_dir}/system/arm/dt/$([ "$arch" = arm ] && echo "armv7_gem5_v1_${cpus}cpu" || echo "armv8_gem5_v1_${cpus}cpu").dtb' \ --dtb-file='${gem5_src_dir}/system/arm/dt/$([ "$arch" = arm ] && echo "armv7_gem5_v1_${cpus}cpu" || echo "armv8_gem5_v1_${cpus}cpu").dtb' \\
--machine-type=VExpress_GEM5_V1 \ --machine-type=VExpress_GEM5_V1 \\
${extra_flags} \ ${extra_flags} \
" "
fi fi
@@ -175,19 +181,19 @@ else
extra_flags="${extra_flags_qemu} ${extra_flags}" extra_flags="${extra_flags_qemu} ${extra_flags}"
qemu_common="\ qemu_common="\
${debug_vm} \ ${debug_vm} \
'${buildroot_out_dir}/host/usr/bin/qemu-system-${arch}' \ '${buildroot_out_dir}/host/usr/bin/qemu-system-${arch}' \\
-gdb tcp::1234 \ -gdb tcp::1234 \\
-m '${memory}' \ -m '${memory}' \\
-monitor telnet::45454,server,nowait \ -monitor telnet::45454,server,nowait \\
-netdev user,hostfwd=tcp::45455-:45455,hostfwd=tcp::45456-:22,id=net0 \ -netdev user,hostfwd=tcp::45455-:45455,hostfwd=tcp::45456-:22,id=net0 \\
-smp '${cpus}' \ -smp '${cpus}' \\
-trace 'enable=${trace_enable},file=${qemu_out_dir}/trace.bin' \ -trace 'enable=${trace_enable},file=${qemu_out_dir}/trace.bin' \\
-virtfs 'local,path=${p9_dir},mount_tag=host_scratch,security_model=mapped,id=host_scratch' \ -virtfs 'local,path=${p9_dir},mount_tag=host_scratch,security_model=mapped,id=host_scratch' \\
-virtfs 'local,path=${buildroot_out_dir}/build,mount_tag=host_out,security_model=mapped,id=host_out' \ -virtfs 'local,path=${buildroot_out_dir}/build,mount_tag=host_out,security_model=mapped,id=host_out' \\
$vnc \ ${vnc}"
"
if "$initrd"; then if "$initrd"; then
extra_flags="${extra_flags} -initrd '${images_dir}/rootfs.cpio'" extra_flags="${extra_flags} -initrd '${images_dir}/rootfs.cpio' \\
"
fi fi
if "$ramfs"; then if "$ramfs"; then
# TODO why is this needed, and why any string works. # TODO why is this needed, and why any string works.
@@ -201,16 +207,17 @@ $vnc \
fi fi
if ! "$ramfs"; then if ! "$ramfs"; then
root='root=/dev/vda' root='root=/dev/vda'
extra_flags="${extra_flags} -drive file='${images_dir}/rootfs.ext2.qcow2,if=virtio,format=qcow2'" extra_flags="${extra_flags} -drive file='${images_dir}/rootfs.ext2.qcow2,if=virtio,format=qcow2' \\
"
fi fi
cmd="\ cmd="\
${qemu_common} \ ${qemu_common} \
-M pc \ -M pc \\
-append '${root} nopat ${extra_append}' \ -append '${root} nopat ${extra_append}' \\
-device edu \ -device edu \\
-device lkmc_pci_min \ -device lkmc_pci_min \\
-device virtio-net-pci,netdev=net0 \ -device virtio-net-pci,netdev=net0 \\
-kernel '${images_dir}/bzImage' \ -kernel '${images_dir}/bzImage' \\
${extra_flags} \ ${extra_flags} \
" "
;; ;;
@@ -219,18 +226,19 @@ ${extra_flags} \
extra_append="${extra_append} kgdboc=ttyAMA0,115200" extra_append="${extra_append} kgdboc=ttyAMA0,115200"
fi fi
if ! "$ramfs"; then if ! "$ramfs"; then
extra_flags="${extra_flags} -drive file='${images_dir}/rootfs.ext2.qcow2,if=scsi,format=qcow2'" extra_flags="${extra_flags} -drive file='${images_dir}/rootfs.ext2.qcow2,if=scsi,format=qcow2' \\
"
root='root=/dev/sda' root='root=/dev/sda'
fi fi
cmd="\ cmd="\
$qemu_common \ ${qemu_common} \
-M versatilepb \ -M versatilepb \\
-append '${root} ${extra_append}' \ -append '${root} ${extra_append}' \\
-device rtl8139,netdev=net0 \ -device rtl8139,netdev=net0 \\
-dtb '${images_dir}/versatile-pb.dtb' \ -dtb '${images_dir}/versatile-pb.dtb' \\
-kernel '${images_dir}/zImage' \ -kernel '${images_dir}/zImage' \\
-serial stdio \ -serial stdio \\
$extra_flags \ ${extra_flags} \
" "
;; ;;
aarch64) aarch64)
@@ -239,37 +247,39 @@ $extra_flags \
fi fi
if ! "$ramfs"; then if ! "$ramfs"; then
root='root=/dev/vda' root='root=/dev/vda'
extra_flags="${extra_flags} -drive file='${images_dir}/rootfs.ext2.qcow2,if=virtio,format=qcow2'" extra_flags="${extra_flags} -drive file='${images_dir}/rootfs.ext2.qcow2,if=virtio,format=qcow2' \\
"
fi fi
cmd="\ cmd="\
${qemu_common} \ ${qemu_common} \
-M virt \ -M virt \\
-append '${root} ${extra_append}' \ -append '${root} ${extra_append}' \\
-cpu cortex-a57 \ -cpu cortex-a57 \\
-device virtio-net-device,netdev=net0 \ -device virtio-net-device,netdev=net0 \\
-kernel '${images_dir}/Image' \ -kernel '${images_dir}/Image' \\
-nographic \ -nographic \\
-serial stdio \ -serial stdio \\
${extra_flags} \ ${extra_flags} \
" "
;; ;;
mips64) mips64)
if ! "$ramfs"; then if ! "$ramfs"; then
root='root=/dev/hda' root='root=/dev/hda'
extra_flags="${extra_flags} -drive file='${images_dir}/rootfs.ext2.qcow2,format=qcow2'" extra_flags="${extra_flags} -drive file='${images_dir}/rootfs.ext2.qcow2,format=qcow2' \\
"
fi fi
cmd="\ cmd="\
${qemu_common} \ ${qemu_common} \
-M malta \ -M malta \\
-append '${root} ${extra_append}' \ -append '${root} ${extra_append}' \\
-cpu I6400 \ -cpu I6400 \\
-device pcnet \ -device pcnet \\
-kernel '${images_dir}/vmlinux' \ -kernel '${images_dir}/vmlinux' \\
-nographic \ -nographic \\
${extra_flags} \ ${extra_flags} \
" "
;; ;;
esac esac
fi fi
echo "$cmd" | tee run.log echo "$cmd" | tee "${out_arch_dir}/run.sh"
eval "$cmd" eval "$cmd"

29
rungdb
View File

@@ -5,7 +5,8 @@ set -- ${cli_rungdb:-} "$@"
after= after=
before= before=
gem5=false gem5=false
lx_symbols="-ex 'lx-symbols ../kernel_module-1.0/'" lx_symbols="-ex 'lx-symbols ../kernel_module-1.0/' \\
"
kgdb=false kgdb=false
while getopts A:a:b:gkL OPT; do while getopts A:a:b:gkL OPT; do
case "$OPT" in case "$OPT" in
@@ -34,7 +35,8 @@ while getopts A:a:b:gkL OPT; do
done done
shift "$(($OPTIND - 1))" shift "$(($OPTIND - 1))"
if [ "$#" -gt 0 ]; then if [ "$#" -gt 0 ]; then
brk="-ex 'break ${1}'" brk="-ex 'break ${1}' \\
"
shift shift
else else
brk= brk=
@@ -45,15 +47,16 @@ else
port=1234 port=1234
fi fi
set_common_vars "$arch" "$gem5" set_common_vars "$arch" "$gem5"
gdb="${host_dir}/usr/bin/${arch}-linux-gdb ${before}" gdb="${host_dir}/usr/bin/${arch}-linux-gdb \\
${before}"
cd "${build_dir}/linux-custom/" cd "${build_dir}/linux-custom/"
if "$kgdb"; then if "$kgdb"; then
cmd="\ cmd="\
${gdb} \ ${gdb} \
-q \ -q \\
-ex 'add-auto-load-safe-path $(pwd)' \ -ex 'add-auto-load-safe-path $(pwd)' \\
-ex 'file vmlinux' \ -ex 'file vmlinux' \\
-ex 'target remote localhost:${port}' -ex 'target remote localhost:${port}' \\
" "
else else
# ## lx-symbols # ## lx-symbols
@@ -77,15 +80,15 @@ else
# which gets put on the kernel build root when python debugging scripts are enabled. # which gets put on the kernel build root when python debugging scripts are enabled.
cmd="\ cmd="\
${gdb} \ ${gdb} \
-q \ -q \\
-ex 'add-auto-load-safe-path $(pwd)' \ -ex 'add-auto-load-safe-path $(pwd)' \\
-ex 'file vmlinux' \ -ex 'file vmlinux' \\
-ex 'target remote localhost:${port}' \ -ex 'target remote localhost:${port}' \\
${brk} \ ${brk} \
-ex 'continue' \ -ex 'continue' \\
${lx_symbols} \ ${lx_symbols} \
" "
fi fi
cmd="$cmd $after" cmd="$cmd $after"
echo "$cmd" | tee "${root_dir}/rungdb.log" echo "$cmd" | tee "${out_arch_dir}/rungdb.sh"
eval "$cmd" eval "$cmd"