mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-29 18:18:54 +00:00
638db70b94
Fixes #1971
289 lines
6.2 KiB
Tcl
289 lines
6.2 KiB
Tcl
#
|
|
# \brief Test for using the GDB monitor
|
|
# \author Christian Prochaska
|
|
# \author Norman Feske
|
|
# \date 2011-05-24
|
|
#
|
|
|
|
#
|
|
# Only the NOVA and 32-bit Fiasco.OC base platforms support most of the tested features
|
|
# at this time.
|
|
#
|
|
|
|
if {![have_include "power_on/qemu"] ||
|
|
!([have_spec nova] || ([have_spec foc] && [have_spec 32bit]))} {
|
|
puts "Run script is only supported for NOVA or 32-bit Fiasco.OC in Qemu"; exit 0
|
|
}
|
|
|
|
#
|
|
# Build
|
|
#
|
|
|
|
build {
|
|
core init
|
|
drivers/timer drivers/uart
|
|
app/gdb_monitor
|
|
test/gdb_monitor
|
|
}
|
|
|
|
create_boot_directory
|
|
|
|
#
|
|
# Generate config
|
|
#
|
|
|
|
set config {
|
|
<config verbose="yes">
|
|
<parent-provides>
|
|
<service name="ROM"/>
|
|
<service name="RAM"/>
|
|
<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>
|
|
<start name="timer">
|
|
<resource name="RAM" quantum="2M"/>
|
|
<provides> <service name="Timer"/> </provides>
|
|
</start>
|
|
<start name="uart_drv">
|
|
<resource name="RAM" quantum="2M"/>
|
|
<provides>
|
|
<service name="Terminal"/>
|
|
<service name="Uart"/>
|
|
</provides>
|
|
<config>
|
|
<policy label="gdb_monitor" uart="1"/>
|
|
</config>
|
|
</start>
|
|
<start name="gdb_monitor">
|
|
<resource name="RAM" quantum="4M"/>
|
|
<config>
|
|
<target name="test-gdb_monitor">
|
|
<config>
|
|
<libc stdout="/dev/log" stderr="/dev/log">
|
|
<vfs> <dir name="dev"> <log/> </dir> </vfs>
|
|
</libc>
|
|
</config>
|
|
</target>
|
|
<preserve name="RAM" quantum="3M"/>
|
|
<libc stdout="/dev/log" stderr="/dev/log">
|
|
<vfs> <dir name="dev"> <log/> </dir> </vfs>
|
|
</libc>
|
|
</config>
|
|
</start>
|
|
</config>
|
|
}
|
|
|
|
install_config $config
|
|
|
|
#
|
|
# Boot modules
|
|
#
|
|
|
|
# generic modules
|
|
set boot_modules {
|
|
core init timer
|
|
ld.lib.so libc.lib.so libc_pipe.lib.so libc_terminal.lib.so
|
|
uart_drv
|
|
gdb_monitor test-gdb_monitor
|
|
}
|
|
|
|
build_boot_image $boot_modules
|
|
|
|
#
|
|
# Execute test case
|
|
#
|
|
#
|
|
set local_port 5555
|
|
|
|
# qemu config
|
|
append qemu_args " -m 128 -nographic "
|
|
|
|
# connect comport 0 to stdio
|
|
append qemu_args " -serial mon: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 -> gdb_monitor\].*} 30
|
|
set genode_id [output_spawn_id]
|
|
|
|
puts "GDB monitor is up, starting GDB"
|
|
|
|
source ${genode_dir}/repos/ports/run/gdb_monitor.inc
|
|
|
|
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 [gdb_main_breakpoint_cmds $gdb_target_binary]
|
|
|
|
# run GDB and redirect stderr to stdio to get the relevant output into the expect buffer
|
|
eval spawn [gdb] bin/ld.lib.so -n $gdb_cmds 2&>1
|
|
set gdb_id [list $spawn_id $genode_id]
|
|
|
|
puts ""
|
|
puts "----- test: breakpoint in 'main()' -----"
|
|
puts ""
|
|
|
|
run_genode_until {\(gdb\)} 60 $gdb_id
|
|
|
|
if {![regexp {Breakpoint 2, main ()} $output]} {
|
|
puts stderr "*** Error: Breakpoint in main() did not trigger"
|
|
exit -1
|
|
}
|
|
|
|
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
|
|
|
|
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::entry()\n"
|
|
run_genode_until {\(gdb\)} 20 $gdb_id
|
|
|
|
send "c\n"
|
|
run_genode_until {\(gdb\)} 20 $gdb_id
|
|
|
|
if {![regexp {Breakpoint 4, Test_thread::entry()} $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 3} $output] ||
|
|
![regexp {\* 3 Thread 4 Test_thread::entry} $output] ||
|
|
![regexp { 2 Thread 2} $output] ||
|
|
![regexp { 1 Thread 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_func} $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 {Program 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::Cancelable_lock::lock\(\)} $output] ||
|
|
![regexp {Genode::Thread::join\(\)} $output] ||
|
|
![regexp {in main \(\)} $output]} {
|
|
|
|
puts stderr "*** Error: Stack trace when in syscall is not as expected"
|
|
exit -1
|
|
|
|
}
|
|
}
|
|
|
|
puts ""
|
|
|
|
# vi: set ft=tcl :
|