genode/repos/ports/run/gdb_monitor.run

317 lines
6.9 KiB
Plaintext
Raw Normal View History

2011-12-22 15:19:25 +00:00
#
# \brief Test for using the GDB monitor
# \author Christian Prochaska
# \author Norman Feske
# \date 2011-05-24
#
#
# Only the NOVA platform supports most of the tested features at this time.
#
if {![have_include "power_on/qemu"] ||
!([have_spec nova])} {
puts "Run script is only supported for NOVA in Qemu"; exit 0
2012-08-10 06:13:37 +00:00
}
2011-12-22 15:19:25 +00:00
#
# Build
#
set build_components {
core init timer
drivers/uart
2011-12-22 15:19:25 +00:00
app/gdb_monitor
test/gdb_monitor
lib/vfs_pipe
2011-12-22 15:19:25 +00:00
}
lappend build_components "lib/gdbserver_platform-$::env(KERNEL)"
build $build_components
2011-12-22 15:19:25 +00:00
create_boot_directory
#
# Generate config
#
set config {
<config verbose="yes">
<parent-provides>
<service name="ROM"/>
<service name="IRQ"/>
<service name="IO_MEM"/>
<service name="IO_PORT"/>
<service name="PD"/>
<service name="RM"/>
<service name="CPU"/>
<service name="LOG"/>
</parent-provides>
<default-route>
<any-service> <parent/> <any-child/> </any-service>
</default-route>
<default caps="100"/>
2011-12-22 15:19:25 +00:00
<start name="timer">
<resource name="RAM" quantum="2M"/>
2011-12-22 15:19:25 +00:00
<provides> <service name="Timer"/> </provides>
</start>
<start name="pc_uart_drv">
<resource name="RAM" quantum="2M"/>
<provides>
<service name="Terminal"/>
<service name="Uart"/>
</provides>
2011-12-22 15:19:25 +00:00
<config>
<policy label_prefix="gdb_monitor" uart="1"/>
2011-12-22 15:19:25 +00:00
</config>
</start>
2020-08-18 14:51:28 +00:00
<start name="gdb_monitor" caps="1000">
<resource name="RAM" quantum="9M"/>
<config>
<target name="test-gdb_monitor">
<config>
<vfs> <dir name="dev"> <log/> </dir> </vfs>
<libc stdout="/dev/log" stderr="/dev/log"/>
</config>
</target>
<preserve name="RAM" quantum="5M"/>
<vfs>
<dir name="dev">
<log/>
<terminal raw="yes"/>
<inline name="rtc">2021-01-01 00:01</inline>
</dir>
<dir name="pipe"> <pipe/> </dir>
</vfs>
<libc stdout="/dev/log" stderr="/dev/log" pipe="/pipe" rtc="/dev/rtc"/>
</config>
2011-12-22 15:19:25 +00:00
</start>
</config>
}
install_config $config
#
# Boot modules
#
# evaluated by the run tool
proc binary_name_gdbserver_platform_lib_so { } {
return "gdbserver_platform-$::env(KERNEL).lib.so"
}
2011-12-22 15:19:25 +00:00
# generic modules
set boot_modules {
core init timer
ld.lib.so libc.lib.so vfs.lib.so libm.lib.so
pc_uart_drv posix.lib.so stdcxx.lib.so vfs_pipe.lib.so
gdb_monitor gdbserver_platform.lib.so test-gdb_monitor
2011-12-22 15:19:25 +00:00
}
build_boot_image $boot_modules
#
# Execute test case
#
#
set local_port 5555
# qemu config
append qemu_args " -display none "
2011-12-22 15:19:25 +00:00
# connect comport 0 to stdio
append qemu_args " -serial stdio "
2011-12-22 15:19:25 +00:00
# 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 "
2011-12-22 15:19:25 +00:00
run_genode_until {.*\[init -> gdb_monitor\] Remote debugging using /dev/terminal.*} 30
set genode_id [output_spawn_id]
2011-12-22 15:19:25 +00:00
puts "GDB monitor is up, starting GDB"
source ${genode_dir}/repos/ports/run/gdb_monitor.inc
# GDB loads symbols from 'debug/ld.lib.so'
if { [have_spec nova] } {
exec ln -sf ld-nova.lib.so debug/ld.lib.so
}
set gdb_target_binary "test-gdb_monitor"
# 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" }
append gdb_cmds [gdb_initial_breakpoint_cmds $gdb_target_binary]
# run GDB
eval spawn [gdb] debug/ld.lib.so -n $gdb_cmds
set gdb_id [list $spawn_id $genode_id]
puts ""
puts "----- test: breakpoint in 'main()' -----"
puts ""
run_genode_until {\(gdb\)} 60 $gdb_id
send "b main\n"
run_genode_until {\(gdb\)} 20 $gdb_id
send "c\n"
run_genode_until {\(gdb\)} 20 $gdb_id
if {![regexp {Breakpoint 2, main ()} $output]} {
puts stderr "*** Error: Breakpoint in main() did not trigger"
exit -1
}
send "delete 2\n"
run_genode_until {\(gdb\)} 20 $gdb_id
puts "\n"
puts "----- test: breakpoint in shared library -----"
puts ""
send "b puts\n"
run_genode_until {\(gdb\)} 20 $gdb_id
send "c\n"
run_genode_until {\(gdb\)} 20 $gdb_id
2011-12-22 15:19:25 +00:00
if {![regexp {Breakpoint 3, puts ()} $output]} {
puts "*** Error: Breakpoint in shared library did not trigger"
exit -1
}
puts "\n"
puts "----- test: stack trace when not in syscall -----"
puts ""
send "bt\n"
run_genode_until {\(gdb\)} 20 $gdb_id
if {![regexp {#0 puts} $output] ||
![regexp {in func2()} $output] ||
![regexp {in func1()} $output] ||
![regexp {in main ()} $output]} {
puts stderr "*** Error: Stack trace when not in syscall is not as expected"
exit -1
}
puts "\n"
puts "----- test: modification of a variable value -----"
puts ""
send "print test_var\n"
run_genode_until {\(gdb\)} 20 $gdb_id
if {![regexp {\$1 = 1} $output]} {
puts stderr "*** Error: first 'print test_var' command didn't result in the expected output"
exit -1
}
send "set var test_var=2\n"
run_genode_until {\(gdb\)} 20 $gdb_id
send "print test_var\n"
run_genode_until {\(gdb\)} 20 $gdb_id
if {![regexp {\$2 = 2} $output]} {
puts stderr "*** Error: second 'print test_var' command didn't result in the expected output"
exit -1
}
puts "\n"
puts "----- test: 'call' command -----"
puts ""
send "call test_var_func()\n"
run_genode_until {\(gdb\)} 60 $gdb_id
if {![regexp {\$3 = 3} $output]} {
puts stderr "*** Error: 'call' command didn't result in the expected output"
exit -1
}
puts "\n"
puts "----- test: thread info -----"
puts ""
send "b test_thread_start\n"
run_genode_until {\(gdb\)} 20 $gdb_id
send "c\n"
run_genode_until {\(gdb\)} 20 $gdb_id
if {![regexp {Breakpoint 4, test_thread_start} $output]} {
puts stderr "*** Error: Breakpoint in test thread did not trigger"
exit -1
}
send "info threads\n"
run_genode_until {\(gdb\)} 20 $gdb_id
if {![regexp {\* 4 Thread 1.4 test_thread_start} $output] ||
![regexp { 3 Thread 1.3} $output] ||
![regexp { 2 Thread 1.2} $output] ||
![regexp { 1 Thread 1.1} $output]} {
puts stderr "*** Error: Thread info is not as expected"
exit -1
}
puts "\n"
puts "----- test: step into function -----"
puts ""
send "step\n"
run_genode_until {\(gdb\)} 30 $gdb_id
send "thread 2\n"
run_genode_until {\(gdb\)} 20 $gdb_id
if {![regexp {test_thread_step} $output]} {
puts stderr "*** Error: Step into function didn't result in the expected output"
exit -1
}
puts "\n"
puts "----- test: catching a segmentation fault -----"
puts ""
send "c\n"
run_genode_until {\(gdb\)} 20 $gdb_id
if {![regexp {Thread 4 received signal SIGSEGV, Segmentation fault.} $output]} {
puts stderr "*** Error: Segmentation fault exception was not caught"
exit -1
}
# does not work well on ARM yet
if {![have_spec arm]} {
puts "\n"
puts "----- test: stack trace when in syscall -----"
puts ""
send "thread 2\n"
run_genode_until {\(gdb\)} 20 $gdb_id
send "bt\n"
run_genode_until {\(gdb\)} 20 $gdb_id
if {![regexp {Genode::Signal_receiver::block_for_signal} $output] ||
![regexp {Genode::Entrypoint::_wait_and_dispatch_one_io_signal} $output] ||
![regexp {Libc::Kernel::run} $output] } {
puts stderr "*** Error: Stack trace when in syscall is not as expected"
exit -1
}
}
2011-12-22 15:19:25 +00:00
puts ""
2011-12-22 15:19:25 +00:00
# vi: set ft=tcl :