1 # Copyright (C) 2024 Free Software Foundation, Inc. 2 3 # This program is free software; you can redistribute it and/or modify 4 # it under the terms of the GNU General Public License as published by 5 # the Free Software Foundation; either version 3 of the License, or 6 # (at your option) any later version. 7 # 8 # This program is distributed in the hope that it will be useful, 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 # GNU General Public License for more details. 12 # 13 # You should have received a copy of the GNU General Public License 14 # along with this program. If not, see <http://www.gnu.org/licenses/>. 15 # 16 # Test gdb.Symbol.artificial. 17 18 load_lib dwarf.exp 19 load_lib gdb-python.exp 20 21 require dwarf2_support allow_python_tests 22 23 # Just use a no-op main. 24 standard_testfile py-arch.c -dw.S 25 26 set asm_file [standard_output_file ${srcfile2}] 27 Dwarf::assemble $asm_file { 28 cu {} { 29 compile_unit { 30 {language @DW_LANG_C} 31 {name py-sym-artificial.c} 32 } { 33 declare_labels signed 34 35 signed: DW_TAG_base_type { 36 {DW_AT_byte_size 1 DW_FORM_sdata} 37 {DW_AT_encoding @DW_ATE_signed} 38 {DW_AT_name bool} 39 } 40 41 DW_TAG_variable { 42 {name the_variable} 43 {DW_AT_type :$signed} 44 {artificial 1 DW_FORM_flag_present} 45 } 46 } 47 } 48 } 49 50 if {[prepare_for_testing "failed to prepare" ${testfile} \ 51 [list $srcfile $asm_file] {nodebug}]} { 52 return -1 53 } 54 55 if {![runto_main]} { 56 return -1 57 } 58 59 gdb_py_test_silent_cmd "python v = gdb.lookup_symbol('the_variable')" \ 60 "get variable" 1 61 gdb_test "python print(v\[0\].is_artificial)" True \ 62 "variable is artificial" 63