remote-stdio-gdbserver.exp 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. # Copyright 2011-2022 Free Software Foundation, Inc.
  2. # This program is free software; you can redistribute it and/or modify
  3. # it under the terms of the GNU General Public License as published by
  4. # the Free Software Foundation; either version 3 of the License, or
  5. # (at your option) any later version.
  6. #
  7. # This program is distributed in the hope that it will be useful,
  8. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. # GNU General Public License for more details.
  11. #
  12. # You should have received a copy of the GNU General Public License
  13. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. # This file is a dejagnu "board file" and is used to run the testsuite
  15. # with a remotehost and gdbserver using stdio for communicating through
  16. # ssh. Certain firewalls prevent gdbserver from using the usual mechanism of
  17. # listening on a remote port, so use stdio via ssh instead.
  18. #
  19. # To use this file:
  20. # bash$ cd ${build_dir}/gdb
  21. # bash$ make check RUNTESTFLAGS="--target_board=remote-stdio-gdbserver \
  22. # REMOTE_USERNAME=... REMOTE_HOSTNAME=... REMOTE_PORTNUM=... \
  23. # [REMOTE_TMPDIR=${remote_dir}] [GDBSERVER=${remote_gdbserver}]"
  24. load_board_description "stdio-gdbserver-base"
  25. # Test machine info. The generic_config gdbserver reads some of these
  26. # values from board_info, so this file must set them there.
  27. if [info exists REMOTE_USERNAME] {
  28. set_board_info username $REMOTE_USERNAME
  29. } else {
  30. set_board_info username unspecified_username
  31. }
  32. if [info exists REMOTE_HOSTNAME] {
  33. set_board_info hostname $REMOTE_HOSTNAME
  34. } else {
  35. set_board_info hostname unspecified_hostname
  36. }
  37. # The two programs have different syntax to set the remote port, so
  38. # set it as part of the program name rather than in get_remote_login.
  39. if [info exists REMOTE_PORTNUM] {
  40. set_board_info portnum $REMOTE_PORTNUM
  41. set_board_info rsh_prog "/usr/bin/ssh -p$REMOTE_PORTNUM"
  42. set_board_info rcp_prog "/usr/bin/scp -P$REMOTE_PORTNUM"
  43. } else {
  44. set_board_info rsh_prog /usr/bin/ssh
  45. set_board_info rcp_prog /usr/bin/scp
  46. }
  47. # Some remote machines don't have writable home directories.
  48. if [info exists REMOTE_TMPDIR] {
  49. set_board_info remotedir $REMOTE_TMPDIR
  50. }
  51. unset_board_info gdb_server_prog
  52. if [info exists GDBSERVER] {
  53. set_board_info gdb_server_prog $GDBSERVER
  54. } else {
  55. set_board_info gdb_server_prog /usr/bin/gdbserver
  56. }
  57. proc get_remote_login { } {
  58. set result ""
  59. if {[board_info [target_info name] exists username]} {
  60. append result "[board_info [target_info name] username]@"
  61. }
  62. if {[board_info [target_info name] exists hostname]} {
  63. append result "[board_info [target_info name] hostname]"
  64. }
  65. return $result
  66. }
  67. proc get_target_remote_pipe_cmd { } {
  68. set target_exec [gdbserver_download_current_prog]
  69. set rsh_cmd "[board_info [target_info name] rsh_prog] [get_remote_login]"
  70. set gdbserver "[board_info [target_info name] gdb_server_prog]"
  71. return "$rsh_cmd $gdbserver --once stdio $target_exec"
  72. }
  73. proc ${board}_file { dest op args } {
  74. if { $op == "delete" } {
  75. return [remote_exec target "rm -f $args"]
  76. }
  77. return [eval [list standard_file $dest $op] $args]
  78. }