genode/repos/ports/run/noux_gdb.inc

70 lines
2.0 KiB
PHP
Raw Normal View History

cli_monitor: add a 'gdb' command This patch adds a 'gdb' command to 'cli_monitor', which makes it possible to debug an application with GDB. The command works similarly to the 'start' command, but instead of starting the subsystem binary directly, an 'init' subsystem gets started, which then starts 'terminal_crosslink', 'noux', GDB and 'gdb_monitor' (which starts the application binary as its target). So, for the 'gdb' command to work, these additional components need to be available, too. 'terminal_crosslink', 'noux', 'gdb_monitor' and the file 'gdb_command_config' are expected to be ROM modules. The Noux GDB client needs to get mounted at '/bin' in Noux and the target binaries need to be available as ROM modules (loaded by 'gdb_monitor') and also mounted at '/gdb' in Noux (loaded by the GDB client). Additionally, the source code of the target application can be provided at '/gdb/src/ in Noux. How the Noux mountings get established can be configured in the 'gdb_command_config' file. The default configuration in 'os/src/server/cli_monitor/gdb_command_config' mounts GDB from a tar archive named 'gdb.tar', the GDB target binaries from a tar archive named 'gdb_target.tar' and the target source code from a tar archive named 'gdb_target-src.tar'. The patch includes an 'expect' include file (ports/run/noux_gdb.inc) which provides functions that help to create those tar files: - 'create_gdb_tar' creates a tar archive for the 'gdb' client - 'create_binary_tar' creates a tar archive for the target application - 'create_source_tar' creates a tar archive for the source code of the target application - 'create_binary_and_source_tars' is a convenience wrapper for the previous two functions The patch also includes an example run script (ports/run/noux_gdb_dynamic.run). The 'gdb' command supports the following command line options: - --ram: the initial RAM quota provided to the whole subsystem (including the GDB-related components) - --ram-limit: limit for expanding RAM quota - --gdb-ram-preserve: the RAM quota that 'gdb_monitor' ahould preserve for itself Fixes #928.
2013-10-25 20:28:55 +00:00
#
# Utility functions for run scripts using Noux GDB
#
#
# Return the name of the Noux GDB package for the configured platform
#
proc noux_gdb_pkg_name { } {
if {[have_spec arm]} {
return "gdb_arm"
} elseif {[have_spec x86]} {
return "gdb_x86"
}
}
#
# Create a tar archive for GDB (stripped)
#
proc create_gdb_tar { } {
exec sh -c "find bin/[noux_gdb_pkg_name]/ -type f | (xargs [cross_dev_prefix]strip || true) 2>/dev/null"
exec tar cfhv bin/gdb.tar -C bin/[noux_gdb_pkg_name] .
}
#
# Create a tar archive for a Noux application and its shared libraries (unstripped)
#
proc create_binary_tar { application_name application_binaries } {
foreach application_binary ${application_binaries} {
exec tar ufv bin/${application_name}.tar -h -C bin ${application_binary}
}
}
#
# Create a tar archive for the source code of a Noux application and its shared
# libraries.
#
# Currently, directories need to have their own tar records
#
proc create_source_tar { application_name application_binaries } {
exec mkdir -p bin/${application_name}-src
foreach application_binary $application_binaries {
set source_files [ exec [cross_dev_prefix]objdump -dl bin/${application_binary} | grep "^/.*:.*" | sed -e "s/:.*//" | uniq ]
foreach source_file ${source_files} {
# resolve '..' to avoid problems with 'tar' with parts like '/a/b/../'
# where '/a' exists, but '/a/b' does not
set source_file [file normalize ${source_file}]
if [file exists ${source_file}] {
set dirname [ exec dirname ${source_file}]
exec mkdir -p bin/${application_name}-src${dirname}
exec ln -sf ${source_file} bin/${application_name}-src${source_file}
}
}
}
exec tar chf bin/${application_name}-src.tar -C bin/${application_name}-src .
}
#
# Create tar archives for binaries and source code of a Noux application
#
proc create_binary_and_source_tars { application_name application_binaries } {
create_binary_tar ${application_name} ${application_binaries}
create_source_tar ${application_name} ${application_binaries}
}