implptr-optimized-out.exp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. # Copyright 2011-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 and use gas.
  16. if {![dwarf2_support]} {
  17. return 0
  18. }
  19. standard_testfile main.c .S
  20. set executable ${testfile}
  21. # Create the DWARF.
  22. set asm_file [standard_output_file $srcfile2]
  23. Dwarf::assemble $asm_file {
  24. cu { version 3 addr_size 4 } {
  25. compile_unit {
  26. {producer "GNU C 4.4.3"}
  27. {language @DW_LANG_C89}
  28. {name 1.c}
  29. } {
  30. declare_labels int_label struct_label pointer_label variable_label
  31. int_label: base_type {
  32. {byte_size 4 sdata}
  33. {encoding @DW_ATE_signed}
  34. {name int}
  35. }
  36. struct_label: structure_type {
  37. {name s}
  38. {byte_size 4 sdata}
  39. } {
  40. member {
  41. {name f}
  42. {type :$int_label}
  43. {data_member_location 0 data1}
  44. }
  45. }
  46. subprogram {
  47. {MACRO_AT_func { main }}
  48. {type :$int_label}
  49. {external 1 flag}
  50. } {
  51. pointer_label: pointer_type {
  52. {byte_size 4 sdata}
  53. {type :$struct_label}
  54. }
  55. variable_label: DW_TAG_variable {
  56. {name v}
  57. {location {} DW_FORM_block1}
  58. {type :$struct_label}
  59. }
  60. DW_TAG_variable {
  61. {name p}
  62. {location {
  63. GNU_implicit_pointer $variable_label 0
  64. } SPECIAL_expr}
  65. {type :$pointer_label}
  66. }
  67. }
  68. }
  69. }
  70. }
  71. if [prepare_for_testing "failed to prepare" $executable "${asm_file} ${srcfile}" {}] {
  72. return -1
  73. }
  74. # DW_OP_GNU_implicit_pointer implementation requires a valid frame.
  75. if ![runto_main] {
  76. return -1
  77. }
  78. gdb_test "p p->f" " = <optimized out>"