From: jkratoch <> Date: Sun, 5 Sep 2010 18:27:30 +0000 (+0000) Subject: +runtest-ugdb X-Git-Url: https://git.jankratochvil.net/?p=nethome.git;a=commitdiff_plain;h=5d80aa26cb9b39b06b941acb56d5f76594f47099 +runtest-ugdb --- diff --git a/src/runtest-ugdb/INSTALL b/src/runtest-ugdb/INSTALL new file mode 100644 index 0000000..bf13598 --- /dev/null +++ b/src/runtest-ugdb/INSTALL @@ -0,0 +1 @@ +ln -s $HOME/src/runtest-ugdb/native-ugdb-config.exp gdb/testsuite/config/native-ugdb-config.exp diff --git a/src/runtest-ugdb/boards/native-ugdb.exp b/src/runtest-ugdb/boards/native-ugdb.exp new file mode 100644 index 0000000..11afb30 --- /dev/null +++ b/src/runtest-ugdb/boards/native-ugdb.exp @@ -0,0 +1,47 @@ +# Copyright 2010 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# ugdb running native. + +load_generic_config "native-ugdb-config" +process_multilib_options "" + +# The default compiler for this target. +set_board_info compiler "[find_gcc]" + +# This ugdb can only run a process once per session. +set_board_info gdb,do_reload_on_run 1 + +# There's no support for argument-passing (yet). +set_board_info noargs 1 + +# Can't do input (or output) in the current ugdb. +set_board_info gdb,noinferiorio 1 + +# ugdb does not intercept target file operations and perform them +# on the host. +set_board_info gdb,nofileio 1 + +# Can't do hardware watchpoints, in general. +set_board_info gdb,no_hardware_watchpoints 1 + +set_board_info sockethost "localhost:" + +# FIXME: ugdb probably should not be a stub. +#set_board_info use_gdb_stub 1 + +# That is, the target processes are on the same host. +# Does not work: set_board_info isremote 0 +set board_info(native-ugdb,isremote) 0 diff --git a/src/runtest-ugdb/native-ugdb-config.exp b/src/runtest-ugdb/native-ugdb-config.exp new file mode 100644 index 0000000..ae8cf29 --- /dev/null +++ b/src/runtest-ugdb/native-ugdb-config.exp @@ -0,0 +1,94 @@ +# Copyright 2010 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Override its functions +load_config gdbserver.exp + +proc port_open { port } { + set fi [open "/proc/net/tcp" "r"] + fconfigure $fi -translation binary + set data [read $fi] + close $fi + + # 0: 00000000:07D0 00000000:0000 0A 00000000:00000000 00:00000000 00000000 500 ... + + set port_hex4 [format "%04X" $port] + return [regexp -line "^ *\[0-9\]+: 0100007F:${port_hex4} 00000000:0000 0A " $data] +} + +# OPTIONS and ARGUMENTS are ignored now. +proc gdbserver_start { options arguments } { + set port 2000 + set delay 0.1 + set timeout 100 + + verbose -log "gdbserver_start options=$options arguments=$arguments" + + if [port_open $port] { + error "Port $port is already allocated" + } + + # FIXME: IPv6 wrt /proc/net/tcp. + set cmd "nc -l 127.0.0.1 $port <>/proc/ugdb >&0" + set cmd "exec $cmd" + regsub -all { } $cmd {\ } cmd + set cmd "bash -c $cmd" + set server_spawn_id [remote_spawn target $cmd] + + for {set i 0} {$i < $timeout} {incr i} { + if [port_open $port] { + break + } + sleep $delay + } + if {$i == $timeout} { + error "Port $port is still closed" + } + + # It should be "extended-remote" but gdbserver_start_extended prepends + # another "extended-" string. + return [list "remote" "localhost:$port"] +} + +load_lib mi-support.exp + +proc mi_gdb_start { args } { + set retval [default_mi_gdb_start $args] + + if {$retval == 0} { + global mi_gdb_prompt + + set test "-gdb-set debug remote 1" + gdb_test_multiple $test $test { + -re "\\\^done\r\n$mi_gdb_prompt$" { + pass $test + } + } + } + + return $retval +} + +load_lib gdb.exp + +proc gdb_start { } { + set retval [default_gdb_start] + + if {$retval == 0} { + gdb_test "set debug remote 1" + } + + return $retval +} diff --git a/src/runtest-ugdb/runtest-ugdb b/src/runtest-ugdb/runtest-ugdb new file mode 100755 index 0000000..433b7f2 --- /dev/null +++ b/src/runtest-ugdb/runtest-ugdb @@ -0,0 +1,3 @@ +#! /bin/sh +which nc >/dev/null || exit 2 +DEJAGNU=$HOME/src/runtest-ugdb/site.exp runtest --target_board native-ugdb "$@" diff --git a/src/runtest-ugdb/site.exp b/src/runtest-ugdb/site.exp new file mode 100644 index 0000000..e69de29