bp_c_mixed_case.exp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. # Copyright 2018-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. # Test setting breakpoints in C functions with some uppercase letters
  16. # in their name, using the "<...>" notation. See gdb/22670. While at
  17. # it, also try evaluating expressions involving calls to such
  18. # functions.
  19. load_lib "ada.exp"
  20. if { [skip_ada_tests] } { return -1 }
  21. standard_ada_testfile foo_h731_021
  22. set cfile "bar"
  23. set csrcfile ${srcdir}/${subdir}/${testdir}/${cfile}.c
  24. set cobject [standard_output_file ${cfile}.o]
  25. set cfile2 "qux"
  26. set csrcfile2 ${srcdir}/${subdir}/${testdir}/${cfile2}.c
  27. set cobject2 [standard_output_file ${cfile2}.o]
  28. gdb_compile "${csrcfile}" "${cobject}" object [list debug]
  29. gdb_compile "${csrcfile2}" "${cobject2}" object ""
  30. set options [list debug \
  31. additional_flags=-largs \
  32. additional_flags=${cobject} \
  33. additional_flags=${cobject2} \
  34. additional_flags=-margs]
  35. if {[gdb_compile_ada "${srcfile}" "${binfile}" executable $options] != "" } {
  36. return -1
  37. }
  38. clean_restart ${testfile}
  39. if ![runto "foo_h731_021"] then {
  40. perror "Couldn't run ${testfile}"
  41. return
  42. }
  43. # Verify that the current language is Ada.
  44. gdb_test "show lang" \
  45. "\"auto; currently ada\"\\."
  46. # Before running to the C function (and thus switching out of Ada
  47. # mode), try printing the function using the "<...>" notation.
  48. gdb_test "p <MixedCaseFunc>" \
  49. " = void" \
  50. "p <MixedCaseFunc>, in Ada"
  51. gdb_test "p <NoDebugMixedCaseFunc>" \
  52. " = {<text variable, no debug info>} $hex <NoDebugMixedCaseFunc>" \
  53. "p <NoDebugMixedCaseFunc>, in Ada"
  54. # Try inserting a breakpoint inside a C function. Because the function's
  55. # name has some uppercase letters, we need to use the "<...>" notation.
  56. # The purpose of this testcase is to verify that we can in fact do so
  57. # and that it inserts the breakpoint at the expected location.
  58. gdb_test "break <MixedCaseFunc>" \
  59. "Breakpoint $decimal at $hex: file .*bar.c, line $decimal\\."
  60. # Same, but this time on the function with no debug info.
  61. gdb_test "break <NoDebugMixedCaseFunc>" \
  62. "Breakpoint $decimal at $hex"
  63. # Resume the program's execution, verifying that it lands at the expected
  64. # location.
  65. gdb_test "continue" \
  66. "Breakpoint $decimal, MixedCaseFunc \\(\\) at .*bar\\.c:$decimal.*"
  67. # Try printing again using the "<...>" notation. This shouldn't work
  68. # now, since the current frame is a C function.
  69. gdb_test "p <MixedCaseFunc>" \
  70. "A syntax error in expression, near `<MixedCaseFunc>'\\." \
  71. "p <MixedCaseFunc>, in C"
  72. gdb_test "p <NoDebugMixedCaseFunc>" \
  73. "A syntax error in expression, near `<NoDebugMixedCaseFunc>'\\." \
  74. "p <NoDebugMixedCaseFunc>, in C"
  75. set test "break <MixedCaseFunc>, in C"
  76. gdb_test_multiple "break <MixedCaseFunc>" $test {
  77. -re "Function \"<MixedCaseFunc>\" not defined\..*Make breakpoint pending on future shared library load.*y or .n.. $" {
  78. gdb_test_no_output "n" $test
  79. }
  80. }
  81. set test "break <NoDebugMixedCaseFunc>, in C"
  82. gdb_test_multiple "break <NoDebugMixedCaseFunc>" $test {
  83. -re "Function \"<NoDebugMixedCaseFunc>\" not defined\..*Make breakpoint pending on future shared library load.*y or .n.. $" {
  84. gdb_test_no_output "n" $test
  85. }
  86. }