mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
gem5: parse logs and exit with status 1 in case of errors
This commit is contained in:
@@ -3618,11 +3618,11 @@ Basically just calls `panic("BUG!")` for most archs.
|
||||
|
||||
===== Exit emulator on panic
|
||||
|
||||
For testing purposes, it is very useful to quit the emulator automatically with exit status non zero in case of kernel panic, instead of just hanging forever.
|
||||
|
||||
====== Exit QEMU on panic
|
||||
|
||||
For testing purposes, it is very useful to quit the emulator automatically in case of kernel panic, instead of just hanging forever.
|
||||
|
||||
In QEMU, we enable it by default with:
|
||||
Enabled by default with:
|
||||
|
||||
* `panic=-1` command line option which reboots the kernel immediately on panic, see: <<reboot-on-panic>>
|
||||
* QEMU `-no-reboot`, which makes QEMU exit when the guest tries to reboot
|
||||
@@ -3654,7 +3654,7 @@ Source: link:patches/manual/gem5-panic.patch[].
|
||||
|
||||
It does not seem to be exposed to `fs.py`.
|
||||
|
||||
However TODO it still exits with status 0... so we are just parsing the logs for now, like QEMU does.
|
||||
However TODO it still exits with status 0... so we are just parsing the logs for now, as for QEMU.
|
||||
|
||||
Detection seems to be symbol based: it parses the kernel image, and triggers when the PC reaches the address of a symbol: https://github.com/gem5/gem5/blob/1da285dfcc31b904afc27e440544d006aae25b38/src/arch/arm/linux/system.cc#L73
|
||||
|
||||
|
||||
16
run
16
run
@@ -389,7 +389,19 @@ ${extra_flags}\
|
||||
"
|
||||
fi
|
||||
"${common_root_dir}/eeval" "$cmd" "${common_run_dir}/run.sh"
|
||||
if grep 'Kernel panic - not syncing' "$common_termout_file"; then
|
||||
echo 'Kernel panic detected by parsing the terminal output. Exiting with status 1.'
|
||||
cmd_out=$?
|
||||
|
||||
# Check if guest panicked.
|
||||
if "$common_gem5"; then
|
||||
# We have to do some parsing here because gem5 exits with status 0 even when panic happens.
|
||||
#
|
||||
# Grepping for '^panic: ' does not work because some errors don't show that message
|
||||
panic_msg='--- BEGIN LIBC BACKTRACE ---$'
|
||||
else
|
||||
panic_msg='Kernel panic - not syncing'
|
||||
fi
|
||||
if grep -E -e "$panic_msg" -q "$common_termout_file"; then
|
||||
echo 'Simulation error detected by parsing logs. Exiting with status 1.'
|
||||
exit 1
|
||||
fi
|
||||
exit "$cmd_out"
|
||||
|
||||
Reference in New Issue
Block a user