2011-12-22 15:19:25 +00:00
|
|
|
#
|
|
|
|
# \brief Example for debugging a service
|
|
|
|
# \author Norman Feske
|
|
|
|
# \date 2011-09-13
|
|
|
|
#
|
|
|
|
# This example shows how GDB monitor can be used to debug a Genode service.
|
|
|
|
# GDB monitor sits in between the service and the service's parent. Any
|
|
|
|
# service announcements are transparently propagated through the GDB
|
|
|
|
# monitor to the parent. This way, the internal state of a service can
|
|
|
|
# be observed at any time via a remote GDB connection. In the example,
|
|
|
|
# the remote GDB connection is realized via an UART device. Alternatively,
|
|
|
|
# 'tcp_terminal' could be used (to attach GDB via a network connection).
|
|
|
|
#
|
|
|
|
|
2019-11-22 12:50:34 +00:00
|
|
|
if {![have_include "power_on/qemu"] ||
|
|
|
|
!([have_spec nova])} {
|
|
|
|
puts "Run script is only supported for NOVA in Qemu"; exit 0
|
|
|
|
}
|
2019-05-03 14:23:51 +00:00
|
|
|
|
2019-05-03 11:19:17 +00:00
|
|
|
create_boot_directory
|
|
|
|
import_from_depot [depot_user]/src/[base_src] \
|
|
|
|
[depot_user]/pkg/[drivers_interactive_pkg] \
|
|
|
|
[depot_user]/src/nitpicker \
|
|
|
|
[depot_user]/src/demo \
|
2020-07-23 13:14:54 +00:00
|
|
|
[depot_user]/src/init \
|
|
|
|
[depot_user]/src/vfs_pipe
|
2011-12-22 15:19:25 +00:00
|
|
|
|
2015-06-08 07:05:32 +00:00
|
|
|
set build_components {
|
2019-01-03 17:01:49 +00:00
|
|
|
drivers/uart
|
2011-12-22 15:19:25 +00:00
|
|
|
app/gdb_monitor
|
|
|
|
test/gdb_monitor
|
|
|
|
}
|
2017-02-25 22:58:37 +00:00
|
|
|
lappend build_components "lib/gdbserver_platform-$::env(KERNEL)"
|
2015-06-08 07:05:32 +00:00
|
|
|
build $build_components
|
|
|
|
|
2019-05-03 11:19:17 +00:00
|
|
|
install_config {
|
2011-12-22 15:19:25 +00:00
|
|
|
<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>
|
2017-05-29 14:50:12 +00:00
|
|
|
<default caps="100"/>
|
2019-05-03 11:19:17 +00:00
|
|
|
|
2011-12-22 15:19:25 +00:00
|
|
|
<start name="timer">
|
2014-07-21 13:29:50 +00:00
|
|
|
<resource name="RAM" quantum="1M"/>
|
2011-12-22 15:19:25 +00:00
|
|
|
<provides> <service name="Timer"/> </provides>
|
|
|
|
</start>
|
2019-05-03 11:19:17 +00:00
|
|
|
|
2019-05-03 14:23:51 +00:00
|
|
|
<start name="pc_uart_drv">
|
2011-12-22 15:19:25 +00:00
|
|
|
<resource name="RAM" quantum="1M"/>
|
2019-05-03 11:19:17 +00:00
|
|
|
<provides>
|
|
|
|
<service name="Uart"/>
|
|
|
|
<service name="Terminal"/>
|
|
|
|
</provides>
|
2011-12-22 15:19:25 +00:00
|
|
|
<config>
|
2016-11-24 14:28:32 +00:00
|
|
|
<policy label_prefix="gdb_monitor" uart="1"/>
|
2011-12-22 15:19:25 +00:00
|
|
|
</config>
|
|
|
|
</start>
|
2019-05-03 11:19:17 +00:00
|
|
|
|
2020-06-16 13:46:59 +00:00
|
|
|
<start name="drivers" caps="1500">
|
|
|
|
<resource name="RAM" quantum="64M" constrain_phys="yes"/>
|
2019-05-03 11:19:17 +00:00
|
|
|
<binary name="init"/>
|
|
|
|
<route>
|
|
|
|
<service name="ROM" label="config"> <parent label="drivers.config"/> </service>
|
2020-07-01 20:26:11 +00:00
|
|
|
<service name="Timer"> <child name="timer"/> </service>
|
|
|
|
<service name="Capture"> <child name="gdb_monitor"/> </service>
|
2020-07-16 09:28:18 +00:00
|
|
|
<service name="Event"> <child name="gdb_monitor"/> </service>
|
2019-05-03 11:19:17 +00:00
|
|
|
<any-service> <parent/> </any-service>
|
|
|
|
</route>
|
|
|
|
</start>
|
|
|
|
|
2017-05-29 14:50:12 +00:00
|
|
|
<start name="gdb_monitor" caps="200">
|
2014-07-21 13:29:50 +00:00
|
|
|
<resource name="RAM" quantum="10M"/>
|
2020-07-16 09:28:18 +00:00
|
|
|
<provides>
|
|
|
|
<service name="Gui"/> <service name="Capture"/> <service name="Event"/>
|
|
|
|
</provides>
|
2012-04-23 12:44:28 +00:00
|
|
|
<config>
|
2014-07-18 14:12:19 +00:00
|
|
|
<target name="nitpicker">
|
2020-07-16 09:28:18 +00:00
|
|
|
<config request_framebuffer="no" request_input="no">
|
|
|
|
<capture/> <event/>
|
2017-11-13 15:25:45 +00:00
|
|
|
<domain name="pointer" layer="1" xray="no" origin="pointer"
|
|
|
|
content="client" label="no"/>
|
|
|
|
<domain name="default" layer="3" content="client"
|
|
|
|
label="no" hover="always" focus="click"/>
|
2016-11-24 14:28:32 +00:00
|
|
|
<policy label_prefix="pointer" domain="pointer"/>
|
2016-03-09 14:32:23 +00:00
|
|
|
<default-policy domain="default"/>
|
2014-07-18 14:12:19 +00:00
|
|
|
</config>
|
|
|
|
</target>
|
2012-04-23 12:44:28 +00:00
|
|
|
<preserve name="RAM" quantum="2M"/>
|
2020-07-23 13:14:54 +00:00
|
|
|
<vfs>
|
|
|
|
<dir name="dev"> <log/> <terminal/> </dir>
|
|
|
|
<dir name="pipe"> <pipe/> </dir>
|
|
|
|
</vfs>
|
|
|
|
<libc stdout="/dev/log" stderr="/dev/log" pipe="/pipe"/>
|
2012-04-23 12:44:28 +00:00
|
|
|
</config>
|
2011-12-22 15:19:25 +00:00
|
|
|
</start>
|
2019-05-03 11:19:17 +00:00
|
|
|
|
2014-07-18 14:12:19 +00:00
|
|
|
<start name="pointer">
|
|
|
|
<resource name="RAM" quantum="1M"/>
|
|
|
|
</start>
|
2019-05-03 11:19:17 +00:00
|
|
|
|
2011-12-22 15:19:25 +00:00
|
|
|
<start name="scout">
|
|
|
|
<resource name="RAM" quantum="32M"/>
|
2019-05-03 11:19:17 +00:00
|
|
|
</start>
|
2011-12-22 15:19:25 +00:00
|
|
|
</config>
|
|
|
|
}
|
|
|
|
|
2017-02-25 22:58:37 +00:00
|
|
|
# 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
|
2019-05-03 11:19:17 +00:00
|
|
|
build_boot_image {
|
2020-07-23 13:14:54 +00:00
|
|
|
stdcxx.lib.so libc.lib.so libm.lib.so vfs.lib.so
|
2019-05-03 14:23:51 +00:00
|
|
|
pc_uart_drv
|
2017-02-25 22:58:37 +00:00
|
|
|
gdb_monitor gdbserver_platform.lib.so
|
2011-12-22 15:19:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Execute test case
|
|
|
|
#
|
|
|
|
#
|
|
|
|
set local_port 5555
|
|
|
|
|
|
|
|
# qemu config
|
|
|
|
|
|
|
|
# connect comport 0 to stdio
|
2020-04-06 14:05:54 +00:00
|
|
|
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 "
|
2016-05-17 14:13:23 +00:00
|
|
|
append qemu_args " -chardev socket,id=uart,port=$local_port,host=localhost,server,nowait,ipv4 "
|
2011-12-22 15:19:25 +00:00
|
|
|
|
2016-05-17 14:13:23 +00:00
|
|
|
run_genode_until {.*\[init -> gdb_monitor\].*} 30
|
2011-12-22 15:19:25 +00:00
|
|
|
|
|
|
|
puts "GDB monitor is up, starting GDB in a new terminal"
|
|
|
|
|
2017-01-04 10:38:39 +00:00
|
|
|
source ${genode_dir}/repos/ports/run/gdb_monitor.inc
|
|
|
|
|
2017-05-29 14:50:12 +00:00
|
|
|
# GDB loads symbols from 'debug/ld.lib.so'
|
2017-01-04 10:38:39 +00:00
|
|
|
if { [have_spec nova] } {
|
2017-05-29 14:50:12 +00:00
|
|
|
exec ln -sf ld-nova.lib.so debug/ld.lib.so
|
2017-01-04 10:38:39 +00:00
|
|
|
}
|
|
|
|
if { [have_spec foc] } {
|
2017-05-29 14:50:12 +00:00
|
|
|
exec ln -sf ld-foc.lib.so debug/ld.lib.so
|
2017-01-04 10:38:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
set gdb_target_binary "nitpicker"
|
|
|
|
|
|
|
|
# sequence of GDB commands to execute at startup
|
|
|
|
set gdb_cmds ""
|
|
|
|
append gdb_cmds "-ex \"target remote localhost:$local_port\" "
|
|
|
|
|
|
|
|
append gdb_cmds [gdb_initial_breakpoint_cmds $gdb_target_binary]
|
|
|
|
|
|
|
|
# ask the user for confirmations again
|
|
|
|
append gdb_cmds {-ex "set interactive-mode auto" }
|
|
|
|
|
2017-05-29 14:50:12 +00:00
|
|
|
puts "command: [gdb] debug/ld.lib.so $gdb_cmds"
|
2017-01-04 10:38:39 +00:00
|
|
|
|
2020-04-06 14:05:54 +00:00
|
|
|
exec [terminal] -e "bash -lc \"[gdb] debug/ld.lib.so $gdb_cmds\"" &
|
2011-12-22 15:19:25 +00:00
|
|
|
|
2016-05-17 14:13:23 +00:00
|
|
|
interact -i [output_spawn_id]
|
2011-12-22 15:19:25 +00:00
|
|
|
|
|
|
|
# vi: set ft=tcl :
|