info-locals-optimized-out.exp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. # Copyright 2017-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. # Test that "info locals" shows optimized out variables.
  15. load_lib dwarf.exp
  16. # This test can only be run on targets which support DWARF-2 and use gas.
  17. if {![dwarf2_support]} {
  18. return 0
  19. }
  20. standard_testfile main.c -dw.S
  21. # Make some DWARF for the test.
  22. set asm_file [standard_output_file $srcfile2]
  23. Dwarf::assemble $asm_file {
  24. global dwarf_regnum regname srcfile
  25. set buf_var [gdb_target_symbol buf]
  26. cu {} {
  27. DW_TAG_compile_unit {
  28. {DW_AT_name $srcfile}
  29. {DW_AT_comp_dir /tmp}
  30. } {
  31. declare_labels int_type_label
  32. # int
  33. int_type_label: base_type {
  34. {name "int"}
  35. {encoding @DW_ATE_signed}
  36. {byte_size 4 DW_FORM_sdata}
  37. }
  38. DW_TAG_subprogram {
  39. {MACRO_AT_func { main }}
  40. {DW_AT_external 1 flag}
  41. } {
  42. # A variable completely optimized out.
  43. DW_TAG_variable {
  44. {name "opt_out"}
  45. {type :$int_type_label}
  46. }
  47. }
  48. }
  49. }
  50. }
  51. if { [prepare_for_testing ${testfile}.exp ${testfile} \
  52. [list $srcfile $asm_file] {nodebug}] } {
  53. return -1
  54. }
  55. if ![runto_main] {
  56. return -1
  57. }
  58. # Make sure "info locals" shows optimized out variables.
  59. gdb_test "info locals" ".*opt_out = <optimized out>.*" "info local shows optimized out variable"