From 2dd1365af3da8f5bb93f8b73a1fe0c5e4b988d1f Mon Sep 17 00:00:00 2001 From: Christian Prochaska Date: Wed, 28 Jun 2023 16:56:31 +0200 Subject: [PATCH] monitor: separate 'monitor_gdb' run scripts Fixes #4944 --- repos/os/run/monitor_gdb.inc | 105 +++++++++++++++++++ repos/os/run/monitor_gdb.run | 123 +++-------------------- repos/os/run/monitor_gdb_interactive.run | 10 ++ tool/autopilot.list | 1 + 4 files changed, 129 insertions(+), 110 deletions(-) create mode 100644 repos/os/run/monitor_gdb.inc create mode 100644 repos/os/run/monitor_gdb_interactive.run diff --git a/repos/os/run/monitor_gdb.inc b/repos/os/run/monitor_gdb.inc new file mode 100644 index 0000000000..47a97cbfe0 --- /dev/null +++ b/repos/os/run/monitor_gdb.inc @@ -0,0 +1,105 @@ +proc platform_supported { } { + if {[have_spec x86_64] && [have_board pc]} { + if {![have_spec linux] && ![have_spec foc] && ![have_spec sel4]} { + return 1 } } + return 0 +} + +if {![platform_supported]} { + puts "Run script is not supported on this platform" + exit 0 +} + +build { core lib/ld init timer monitor drivers/uart test/log } + +create_boot_directory + +install_config { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +} + +build_boot_image [build_artifacts] + +set local_port 5555 + +# qemu config +append qemu_args " -display none " + +# connect comport 0 to stdio +append qemu_args " -serial stdio " + +# connect comport 1 with TCP port $local_port +append qemu_args " -serial chardev:uart " +append qemu_args " -chardev socket,id=uart,port=$local_port,host=localhost,server,nowait,ipv4 " + +run_genode_until {.*\[init -> monitor -> first-test-log\].*} 30 +set genode_id [output_spawn_id] diff --git a/repos/os/run/monitor_gdb.run b/repos/os/run/monitor_gdb.run index 45db802f29..05e541149c 100644 --- a/repos/os/run/monitor_gdb.run +++ b/repos/os/run/monitor_gdb.run @@ -1,120 +1,23 @@ -proc platform_supported { } { - if {[have_spec x86_64] && [have_board pc]} { - if {![have_spec linux] && ![have_spec foc] && ![have_spec sel4]} { - return 1 } } - return 0 -} - -if {![platform_supported]} { - puts "Run script is not supported on this platform" - exit 0 -} - -build { core lib/ld init timer monitor drivers/uart test/log } - -create_boot_directory - -install_config { - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -} - -build_boot_image [build_artifacts] - -set local_port 5555 - -# qemu config -append qemu_args " -display none " - -# connect comport 0 to stdio -append qemu_args " -serial stdio " - -# connect comport 1 with TCP port $local_port -append qemu_args " -serial chardev:uart " -append qemu_args " -chardev socket,id=uart,port=$local_port,host=localhost,server,nowait,ipv4 " - -run_genode_until {.*\[init -> monitor -> first-test-log\].*} 30 -set genode_id [output_spawn_id] +source ${genode_dir}/repos/os/run/monitor_gdb.inc # sequence of GDB commands to execute at startup set gdb_cmds "" append gdb_cmds {-ex "target remote localhost:$local_port" } append gdb_cmds {-ex "set style enabled off" } -# test for dumping memory -append gdb_cmds {-ex "x/x 0x1003e8b" } - # run GDB eval spawn [gdb] debug/ld.lib.so -n $gdb_cmds set gdb_id [list $spawn_id $genode_id] -# show output of both GDB and Genode, supply user input to GDB -interact -i $gdb_id $genode_id +puts "" +puts "----- test: dump memory -----" +puts "" + +run_genode_until {\(gdb\)} 60 $gdb_id + +send "x/x 0x1003e8b\n" +run_genode_until {\(gdb\)} 20 $gdb_id + +if {![regexp {0x1003e8b:\t0x6f636e6f} $output]} { + puts stderr "*** Error: Dumped memory is not as expected" +} diff --git a/repos/os/run/monitor_gdb_interactive.run b/repos/os/run/monitor_gdb_interactive.run new file mode 100644 index 0000000000..a8cd93e975 --- /dev/null +++ b/repos/os/run/monitor_gdb_interactive.run @@ -0,0 +1,10 @@ +source ${genode_dir}/repos/os/run/monitor_gdb.inc + +# sequence of GDB commands to execute at startup +set gdb_cmds "" +append gdb_cmds "-ex \"target remote localhost:$local_port\" " + +# run GDB +exec [terminal] -e "bash -lc \'[gdb] debug/ld.lib.so $gdb_cmds\'" & + +interact -i $genode_id diff --git a/tool/autopilot.list b/tool/autopilot.list index 150f18ad63..6f47444752 100644 --- a/tool/autopilot.list +++ b/tool/autopilot.list @@ -34,6 +34,7 @@ lx_hybrid_pthread_ipc microcode migrate monitor +monitor_gdb netperf_lwip netperf_lwip_bridge netperf_lwip_usb