catch_ex_std.exp 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. # Copyright 2019-2022 Free Software Foundation, Inc.
  2. #
  3. # This program is free software; you can redistribute it and/or modify
  4. # it under the terms of the GNU General Public License as published by
  5. # the Free Software Foundation; either version 3 of the License, or
  6. # (at your option) any later version.
  7. #
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. if {[skip_shlib_tests]} {
  16. return 0
  17. }
  18. load_lib "ada.exp"
  19. if { [skip_ada_tests] } { return -1 }
  20. standard_ada_testfile foo
  21. set srcfile2 [file join [file dirname $srcfile] some_package.adb]
  22. set sofile [standard_output_file libsome_package.so]
  23. set outdir [file dirname $binfile]
  24. # Create the shared library.
  25. if {[gdb_compile_shlib $srcfile2 $sofile {ada debug}] != ""} {
  26. return -1
  27. }
  28. # Set linkarg such that the executable can find the shared library.
  29. if {[istarget "*-*-mingw*"]
  30. || [istarget *-*-cygwin*]
  31. || [istarget *-*-pe*]} {
  32. # Do not need anything.
  33. set linkarg ""
  34. } elseif {[istarget *-*-freebsd*] || [istarget *-*-openbsd*]} {
  35. set linkarg "-Wl,-rpath,$outdir"
  36. } else {
  37. set linkarg "-Wl,-rpath,\\\$ORIGIN"
  38. }
  39. # Make sure we link against the shared GNAT run time.
  40. set gnatbind_options [list -bargs -shared -margs]
  41. # Link against the shared library.
  42. set gnatlink_options [list -largs $linkarg -Wl,-lsome_package -margs]
  43. set options [list debug]
  44. foreach option [concat $gnatbind_options $gnatlink_options] {
  45. lappend options [concat "additional_flags=" $option]
  46. }
  47. # Create executable.
  48. if {[gdb_compile_ada $srcfile $binfile executable $options] != ""} {
  49. return -1
  50. }
  51. clean_restart ${testfile}
  52. if {![runto_main]} then {
  53. return 0
  54. }
  55. set can_catch_exceptions 0
  56. gdb_test_multiple "catch exception some_kind_of_error" "" {
  57. -re "Catchpoint \[0-9\]+: `some_kind_of_error' Ada exception\r\n$gdb_prompt $" {
  58. pass $gdb_test_name
  59. set can_catch_exceptions 1
  60. }
  61. -re "Your Ada runtime appears to be missing some debugging information.\r\nCannot insert Ada exception catchpoint in this configuration.\r\n$gdb_prompt $" {
  62. unsupported $gdb_test_name
  63. }
  64. }
  65. if { $can_catch_exceptions } {
  66. gdb_test "cont" \
  67. "Catchpoint \[0-9\]+, .* at .*foo\.adb:\[0-9\]+.*" \
  68. "caught the exception"
  69. gdb_test "print \$_ada_exception = some_package.some_kind_of_error'Address" \
  70. " = true"
  71. }