gdb-add-index-symlink.exp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. # Copyright 2021-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-2.
  16. if {![dwarf2_support]} {
  17. return 0
  18. }
  19. standard_testfile main.c
  20. # First check whether we can actually handle the non-symlink case.
  21. with_test_prefix non-symlink {
  22. if { [prepare_for_testing "failed to prepare" "${testfile}" \
  23. [list ${srcfile}]] } {
  24. return -1
  25. }
  26. require {ensure_gdb_index $binfile} != -1
  27. }
  28. # Regenerate exec without index.
  29. if { [prepare_for_testing "failed to prepare" "${testfile}" \
  30. [list ${srcfile}]] } {
  31. return -1
  32. }
  33. set symlink [file dirname $binfile]/symlink
  34. if { ![file exists $symlink] } {
  35. file link -symbolic $symlink $binfile
  36. }
  37. if { [ensure_gdb_index $symlink] == -1 } {
  38. fail "Unable to call gdb-add-index with a symlink to a symfile"
  39. return -1
  40. }
  41. # Ok, we have a copy of $binfile with an index.
  42. # Restart gdb and verify the index was used.
  43. clean_restart $symlink
  44. gdb_test "mt print objfiles ${testfile}" \
  45. "(gdb_index|debug_names).*" \
  46. "index used"