main-subprogram.exp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. # Copyright 2016-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. load_lib dwarf.exp
  15. # This test can only be run on targets which support DWARF-4 and use gas.
  16. if {![dwarf2_support]} {
  17. return 0
  18. }
  19. standard_testfile .c -dw.S
  20. # Make some DWARF for the test.
  21. set asm_file [standard_output_file $srcfile2]
  22. Dwarf::assemble $asm_file {
  23. global srcfile
  24. cu {} {
  25. DW_TAG_compile_unit {
  26. {DW_AT_language @DW_LANG_C}
  27. {DW_AT_name $srcfile}
  28. {DW_AT_comp_dir /tmp}
  29. } {
  30. declare_labels type
  31. type: DW_TAG_base_type {
  32. {DW_AT_byte_size 4 DW_FORM_sdata}
  33. {DW_AT_encoding @DW_ATE_signed}
  34. {DW_AT_name int}
  35. }
  36. DW_TAG_subprogram {
  37. {MACRO_AT_func {mymain}}
  38. {type :$type}
  39. {DW_AT_main_subprogram 1 flag}
  40. } {
  41. }
  42. }
  43. }
  44. }
  45. if {[prepare_for_testing "failed to prepare" ${testfile} \
  46. [list $srcfile $asm_file] {nodebug}]} {
  47. return -1
  48. }
  49. set have_index [exec_has_index_section $binfile]
  50. # Test that the "start" command stops in the "mymain" function.
  51. # This should happen because we used DW_AT_main_subprogram to tell gdb
  52. # that this was the real "main".
  53. if {[gdb_start_cmd] < 0} {
  54. untested "could not start ${testfile}"
  55. return -1
  56. }
  57. gdb_test_multiple "" "stopped at mymain" {
  58. -re -wrap "Temporary breakpoint .* mymain.*" {
  59. pass $gdb_test_name
  60. }
  61. -re -wrap "Temporary breakpoint .* main.*" {
  62. if { $have_index } {
  63. setup_kfail "gdb/24549" *-*-*
  64. }
  65. fail $gdb_test_name
  66. }
  67. }