mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
run: trace to stdout
This commit is contained in:
40
README.adoc
40
README.adoc
@@ -8351,7 +8351,7 @@ TODO do even more awesome offline post-mortem analysis things, such as:
|
||||
|
||||
==== QEMU record and replay
|
||||
|
||||
QEMU runs are not deterministic by default, however it does support a record and replay mechanism that allows you to replay a previous run deterministically:
|
||||
QEMU runs, unlike gem5, are not deterministic by default, however it does support a record and replay mechanism that allows you to replay a previous run deterministically.
|
||||
|
||||
This awesome feature allows you to examine a single run as many times as you would like until you understand everything:
|
||||
|
||||
@@ -8410,8 +8410,8 @@ TODO `arm` and `aarch64` only seem to work with initrd since I cannot plug a wor
|
||||
Then, when I tried with <<initrd>> and no disk:
|
||||
|
||||
....
|
||||
./build-buildroot --arch aarch64 -i
|
||||
./qemu-rr --arch aarch64 --eval-after '/rand_check.out;/poweroff.out;' -i
|
||||
./build-buildroot --arch aarch64 --initrd
|
||||
./qemu-rr --arch aarch64 --eval-after '/rand_check.out;/poweroff.out;' --initrd
|
||||
....
|
||||
|
||||
QEMU crashes with:
|
||||
@@ -8466,15 +8466,21 @@ just appears to output both cores intertwined without any clear differentiation.
|
||||
|
||||
==== gem5 tracing
|
||||
|
||||
gem5 unlike QEMU is deterministic by default without needing to replay traces
|
||||
|
||||
But it also provides a tracing mechanism documented at: link:http://www.gem5.org/Trace_Based_Debugging[] to allow easily inspecting certain aspects of the system:
|
||||
gem5 provides also provides a tracing mechanism documented at: link:http://www.gem5.org/Trace_Based_Debugging[]:
|
||||
|
||||
....
|
||||
./run --arch aarch64 --eval 'm5 exit' --gem5 --trace Exec
|
||||
less "$(./getvar --arch aarch64 run_dir)/trace.txt"
|
||||
....
|
||||
|
||||
Output the trace to stdout instead of a file:
|
||||
|
||||
....
|
||||
./run --arch aarch64 --eval 'm5 exit' --gem5 --trace Exec --trace-stdout
|
||||
....
|
||||
|
||||
This would produce a lot of output however, so you will likely not want that when tracing a Linux kernel boot instructions. But it can be very convenient for smaller traces.
|
||||
|
||||
List all available debug flags:
|
||||
|
||||
....
|
||||
@@ -8488,6 +8494,8 @@ less "$(./getvar gem5_src_dir)/src/cpu/SConscript"
|
||||
less "$(./getvar gem5_src_dir)/src/cpu/exetrace.cc"
|
||||
....
|
||||
|
||||
The traces are generated from `DPRINTF(<trace-id>` calls scattered throughout the code.
|
||||
|
||||
As can be seen on the `Sconstruct`, `Exec` is just an alias that enables a set of flags.
|
||||
|
||||
Be warned, the trace is humongous, at 16Gb.
|
||||
@@ -11779,6 +11787,11 @@ We have some link:https://github.com/pexpect/pexpect[pexpect] automated tests fo
|
||||
./test-gdb
|
||||
....
|
||||
|
||||
Sources:
|
||||
|
||||
* link:build-test-gdb[]
|
||||
* link:test-gdb[]
|
||||
|
||||
Not all of them are passing right now due to: <<gem5-gdb-step-debug-kernel-aarch64>>.
|
||||
|
||||
If something goes wrong, re-run the test commands manually and use `--verbose` to understand what happened:
|
||||
@@ -11794,10 +11807,19 @@ and possibly repeat the GDB steps manually with the usual:
|
||||
./run-gdb --arch arm --baremetal add --no-continue --verbose
|
||||
....
|
||||
|
||||
Sources:
|
||||
To debug GDB problems on gem5, you might want to enable the following <<gem5-tracing,tracing>> options:
|
||||
|
||||
* link:build-test-gdb[]
|
||||
* link:test-gdb[]
|
||||
....
|
||||
./run \
|
||||
--arch arm \
|
||||
--baremetal add \
|
||||
--wait-gdb \
|
||||
--trace GDBRecv,GDBSend \
|
||||
--trace-stdout \
|
||||
;
|
||||
....
|
||||
|
||||
====== Test GDB Linux kernel
|
||||
|
||||
For the Linux kernel, do the following manual tests for now.
|
||||
|
||||
|
||||
13
run
13
run
@@ -35,6 +35,7 @@ defaults = {
|
||||
'terminal': False,
|
||||
'tmux': None,
|
||||
'trace': None,
|
||||
'trace_stdout': False,
|
||||
'userland': None,
|
||||
'userland_before': '',
|
||||
'vnc': False,
|
||||
@@ -151,10 +152,14 @@ def main(args, extra_args=None):
|
||||
extra_env['M5_PATH'] = common.gem5_system_dir
|
||||
# https://stackoverflow.com/questions/52312070/how-to-modify-a-file-under-src-python-and-run-it-without-rebuilding-in-gem5/52312071#52312071
|
||||
extra_env['M5_OVERRIDE_PY_SOURCE'] = 'true'
|
||||
if args.trace_stdout:
|
||||
debug_file = 'cout'
|
||||
else:
|
||||
debug_file = 'trace.txt'
|
||||
cmd.extend(
|
||||
[
|
||||
common.executable, common.Newline,
|
||||
'--debug-file=trace.txt', common.Newline,
|
||||
'--debug-file', debug_file, common.Newline,
|
||||
'--listener-mode', 'on', common.Newline,
|
||||
'--outdir', common.m5out_dir, common.Newline,
|
||||
] +
|
||||
@@ -553,6 +558,12 @@ disabled, while QEMU tracing is enabled but uses default traces that are very
|
||||
rare and don't affect performance, because `./configure
|
||||
--enable-trace-backends=simple` seems to enable some traces by default, e.g.
|
||||
`pr_manager_run`, and I don't know how to get rid of them.
|
||||
'''
|
||||
)
|
||||
parser.add_argument(
|
||||
'--trace-stdout', default=defaults['trace_stdout'], action='store_true',
|
||||
help='''\
|
||||
Output trace to stdout instead of a file. Only works for gem5 currently.
|
||||
'''
|
||||
)
|
||||
init_group.add_argument(
|
||||
|
||||
Reference in New Issue
Block a user