From ae899b9bc7008c737a30c56b0c325b6ca647bbf8 Mon Sep 17 00:00:00 2001 From: Christian Prochaska Date: Mon, 7 Aug 2023 08:47:03 +0200 Subject: [PATCH] ports: add a test for GDB Fixes #5014 --- repos/ports/recipes/src/gdb_arm_64/content.mk | 12 + repos/ports/recipes/src/gdb_arm_64/hash | 1 + repos/ports/recipes/src/gdb_arm_64/used_apis | 7 + repos/ports/recipes/src/gdb_x86/content.mk | 12 + repos/ports/recipes/src/gdb_x86/hash | 1 + repos/ports/recipes/src/gdb_x86/used_apis | 7 + repos/ports/run/gdb.inc | 403 ++++++++++++++++++ repos/ports/run/gdb.run | 7 + repos/ports/run/gdb_interactive.run | 6 + tool/autopilot.list | 1 + 10 files changed, 457 insertions(+) create mode 100644 repos/ports/recipes/src/gdb_arm_64/content.mk create mode 100644 repos/ports/recipes/src/gdb_arm_64/hash create mode 100644 repos/ports/recipes/src/gdb_arm_64/used_apis create mode 100644 repos/ports/recipes/src/gdb_x86/content.mk create mode 100644 repos/ports/recipes/src/gdb_x86/hash create mode 100644 repos/ports/recipes/src/gdb_x86/used_apis create mode 100644 repos/ports/run/gdb.inc create mode 100644 repos/ports/run/gdb.run create mode 100644 repos/ports/run/gdb_interactive.run diff --git a/repos/ports/recipes/src/gdb_arm_64/content.mk b/repos/ports/recipes/src/gdb_arm_64/content.mk new file mode 100644 index 0000000000..633b48fee8 --- /dev/null +++ b/repos/ports/recipes/src/gdb_arm_64/content.mk @@ -0,0 +1,12 @@ +content: src/noux-pkg/gdb LICENSE + +PORT_DIR := $(call port_dir,$(REP_DIR)/ports/gdb) + +src/noux-pkg/gdb: + mkdir -p $@ + cp -a $(PORT_DIR)/src/noux-pkg/gdb/* $@ + cp -a $(REP_DIR)/src/noux-pkg/gdb/* $@ + cp -a $(REP_DIR)/src/noux-pkg/gdb_arm_64/* $@ + +LICENSE: + cp $(PORT_DIR)/src/noux-pkg/gdb/COPYING $@ diff --git a/repos/ports/recipes/src/gdb_arm_64/hash b/repos/ports/recipes/src/gdb_arm_64/hash new file mode 100644 index 0000000000..a53cdef23b --- /dev/null +++ b/repos/ports/recipes/src/gdb_arm_64/hash @@ -0,0 +1 @@ +2023-09-29 76b4ea5f4173a0a868f4261443bb0f6425a1cfbb diff --git a/repos/ports/recipes/src/gdb_arm_64/used_apis b/repos/ports/recipes/src/gdb_arm_64/used_apis new file mode 100644 index 0000000000..d45ce9c41d --- /dev/null +++ b/repos/ports/recipes/src/gdb_arm_64/used_apis @@ -0,0 +1,7 @@ +expat +gmp +libc +ncurses +noux +posix +stdcxx diff --git a/repos/ports/recipes/src/gdb_x86/content.mk b/repos/ports/recipes/src/gdb_x86/content.mk new file mode 100644 index 0000000000..8ce1a2e5fb --- /dev/null +++ b/repos/ports/recipes/src/gdb_x86/content.mk @@ -0,0 +1,12 @@ +content: src/noux-pkg/gdb LICENSE + +PORT_DIR := $(call port_dir,$(REP_DIR)/ports/gdb) + +src/noux-pkg/gdb: + mkdir -p $@ + cp -a $(PORT_DIR)/src/noux-pkg/gdb/* $@ + cp -a $(REP_DIR)/src/noux-pkg/gdb/* $@ + cp -a $(REP_DIR)/src/noux-pkg/gdb_x86/* $@ + +LICENSE: + cp $(PORT_DIR)/src/noux-pkg/gdb/COPYING $@ diff --git a/repos/ports/recipes/src/gdb_x86/hash b/repos/ports/recipes/src/gdb_x86/hash new file mode 100644 index 0000000000..d88465ec60 --- /dev/null +++ b/repos/ports/recipes/src/gdb_x86/hash @@ -0,0 +1 @@ +2023-09-29 60ae0a0b191902482e8d89280588afb8f6b60422 diff --git a/repos/ports/recipes/src/gdb_x86/used_apis b/repos/ports/recipes/src/gdb_x86/used_apis new file mode 100644 index 0000000000..d45ce9c41d --- /dev/null +++ b/repos/ports/recipes/src/gdb_x86/used_apis @@ -0,0 +1,7 @@ +expat +gmp +libc +ncurses +noux +posix +stdcxx diff --git a/repos/ports/run/gdb.inc b/repos/ports/run/gdb.inc new file mode 100644 index 0000000000..b76aca74d7 --- /dev/null +++ b/repos/ports/run/gdb.inc @@ -0,0 +1,403 @@ +proc platform_supported { } { + if {[have_spec x86_64] && [have_board pc]} { + if {[have_spec nova] || [have_spec hw]} { + return 1 } + } elseif {[have_spec arm_v8a] && [have_board rpi3]} { + if {[have_spec hw]} { + return 1 } + } + return 0 +} + +if {![platform_supported]} { + puts "Run script is not supported on this platform" + exit 0 +} + +proc gdb_pkg_name { } { + if {[have_spec arm_64]} { + return "gdb_arm_64" + } elseif {[have_spec x86]} { + return "gdb_x86" + } +} + +proc gdb_prefix { } { + if {[have_spec arm_64]} { + return "genode-aarch64-" + } elseif {[have_spec x86]} { + return "genode-x86-" + } +} + +create_boot_directory + +import_from_depot [depot_user]/src/[base_src] \ + [depot_user]/src/init \ + [depot_user]/src/sandbox \ + [depot_user]/src/monitor \ + [depot_user]/src/vfs \ + [depot_user]/src/fs_rom \ + [depot_user]/src/vfs_pipe \ + [depot_user]/src/terminal_crosslink \ + [depot_user]/src/libc \ + [depot_user]/src/posix \ + [depot_user]/src/socat \ + [depot_user]/src/expat \ + [depot_user]/src/gmp \ + [depot_user]/src/ncurses \ + [depot_user]/src/stdcxx \ + [depot_user]/src/[gdb_pkg_name] + +if {[have_include power_on/qemu]} { + append build_components { drivers/uart } +} else { + import_from_depot [depot_user]/pkg/[drivers_nic_pkg] \ + [depot_user]/src/nic_router \ + [depot_user]/src/vfs_lwip +} + +append build_components " + test/monitor_gdb + test/log +" + +build $build_components + +append config { + + + + + + + + + + + + + + + + + + + + +} + +if { [have_include power_on/qemu] } { + + append_if [have_board pc] config { + + + + + + + + + + + + } + + append_if [have_board rpi3] config { + + + + + + + + + + + + } + +} else { + + append config { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + } +} + +append config { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 2018-01-01 00:01 + } +append_if [have_include power_on/qemu] config { + +} +append config { + } +if {![have_include power_on/qemu]} { + append config { + + } +} +append config { + + + + + } +if {[have_include power_on/qemu]} { + append config { + + } +} else { + append config { + + } +} +append config { + + + + + + + + + + + + + + + + + + + + + + + 2023-01-01 00:01 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +} + +install_config $config + +# GDB loads symbols from 'debug/ld.lib.so' +if { [have_spec nova] } { + exec ln -sf ld-nova.lib.so debug/ld.lib.so +} elseif { [have_spec hw] } { + exec ln -sf ld-hw.lib.so debug/ld.lib.so +} + +exec tar cf bin/gdb_run_debug.tar -h debug/ld.lib.so debug/test-monitor_gdb debug/test-log + +build_boot_image "[build_artifacts] gdb_run_debug.tar" + +set port 5555 + +if {[have_include power_on/qemu]} { + + set host "localhost" + + # qemu config + append qemu_args " -display none " + + if {[have_board rpi3]} { + # connect comport 0 with TCP port $port + append qemu_args " -serial chardev:uart " + # connect comport 1 to stdio + append qemu_args " -serial stdio " + } else { + # connect comport 0 to stdio + append qemu_args " -serial stdio " + # connect comport 1 with TCP port $port + append qemu_args " -serial chardev:uart " + } + + append qemu_args " -chardev socket,id=uart,port=$port,host=$host,server,nowait,ipv4 " + + run_genode_until {.*monitor ready*} 30 + +} else { + + set match_string "nic_router. .uplink. dynamic IP config: interface .*\n" + + run_genode_until $match_string 30 + + regexp $match_string $output host + regexp {[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+} $host host +} + +set genode_id [output_spawn_id] diff --git a/repos/ports/run/gdb.run b/repos/ports/run/gdb.run new file mode 100644 index 0000000000..878f9d81fd --- /dev/null +++ b/repos/ports/run/gdb.run @@ -0,0 +1,7 @@ +source ${genode_dir}/repos/ports/run/gdb.inc + +# run socat for interaction with GDB +eval spawn socat - TCP:$host:$port +set gdb_id [list $spawn_id $genode_id] + +source ${genode_dir}/repos/os/run/monitor_gdb_tests.inc diff --git a/repos/ports/run/gdb_interactive.run b/repos/ports/run/gdb_interactive.run new file mode 100644 index 0000000000..ab1366a96b --- /dev/null +++ b/repos/ports/run/gdb_interactive.run @@ -0,0 +1,6 @@ +source ${genode_dir}/repos/ports/run/gdb.inc + +# run socat for interaction with GDB +exec [terminal] -e "socat - TCP:$host:$port" & + +interact -i $genode_id diff --git a/tool/autopilot.list b/tool/autopilot.list index f0726439be..98cbc16992 100644 --- a/tool/autopilot.list +++ b/tool/autopilot.list @@ -16,6 +16,7 @@ fb_bench fetchurl_lwip fetchurl_lxip fs_query +gdb gdb_monitor hello ieee754