dw2-ranges.exp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. # Copyright 2007-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. # Test DW_TAG_compile_unit with no children and with neither DW_AT_low_pc nor
  16. # DW_AT_high_pc but with DW_AT_ranges instead.
  17. # This test can only be run on targets which support DWARF-2 and use gas.
  18. if {![dwarf2_support]} {
  19. verbose "Skipping $gdb_test_file_name."
  20. return 0
  21. }
  22. # The .c files use __attribute__.
  23. if [get_compiler_info] {
  24. return -1
  25. }
  26. if !$gcc_compiled {
  27. verbose "Skipping $gdb_test_file_name."
  28. return 0
  29. }
  30. standard_testfile .c -2.c -3.c
  31. set asmfile [standard_output_file ${testfile}.s]
  32. set asmfile2 [standard_output_file ${testfile}2.s]
  33. set objfile [standard_output_file ${testfile}.o]
  34. set objfile2 [standard_output_file ${testfile}2.o]
  35. set objfile3 [standard_output_file ${testfile}3.o]
  36. # Generate .s without debug info but provide debug info by the assembler.
  37. # This way we get DW_TAG_compile_unit DIE and only that DIE.
  38. if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${asmfile}" assembly {}] != ""
  39. || [gdb_compile "${asmfile}" "${objfile}" object {additional_flags=-gdwarf-2}] != "" } {
  40. return -1
  41. }
  42. if {[gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${asmfile2}" assembly {}] != ""
  43. || [gdb_compile "${asmfile2}" "${objfile2}" object {additional_flags=-gdwarf-2}] != "" } {
  44. return -1
  45. }
  46. # STABS compilation is intentional as it tests the STABS lookup where is no
  47. # partial_symtab->psymtabs_addrmap supported for that CU (Compilation Unit) in
  48. # a file containing psymtabs_addrmap-supporting DWARF CUs.
  49. if {[gdb_compile "${srcdir}/${subdir}/${srcfile3}" "${objfile3}" object {additional_flags=-gstabs}] != "" } {
  50. return -1
  51. }
  52. if {[gdb_compile "${objfile} ${objfile2} ${objfile3}" "${binfile}" executable {}] != "" } {
  53. return -1
  54. }
  55. clean_restart ${testfile}
  56. # Test also objfile->psymtabs_addrmap relocations for -fPIE -pie builds below.
  57. # On some targets it may possibly fail but the program is being started only
  58. # for the PIE build so try it anyway.
  59. runto_main
  60. # Correct output:
  61. # Line 39 of "../.././gdb/testsuite/gdb.dwarf2/dw2-ranges.S" starts at address 0x4 and ends at 0x8.
  62. # Wrong output:
  63. # No line number information available for address 0x4
  64. gdb_test "info line main" "Line \[0-9\]* of .* starts at address .* and ends at .*"
  65. gdb_test "info line func" "Line \[0-9\]* of .* starts at address .* and ends at .*"
  66. gdb_test "info line main2" "Line \[0-9\]* of .* starts at address .* and ends at .*"
  67. gdb_test "info line func2" "Line \[0-9\]* of .* starts at address .* and ends at .*"
  68. gdb_test "info line main3" \
  69. "Line \[0-9\]* of .* starts at address .* and ends at .*"