tizen 2.4 release
[external/binutils.git] / gdb / testsuite / gdb.dwarf2 / symtab-producer.exp
1 # Copyright 2014 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 load_lib dwarf.exp
17 load_lib gdb-python.exp
18
19 # This test can only be run on targets which support DWARF-2 and use gas.
20 if {![dwarf2_support]} {
21     return 0
22 }
23
24 # This test can also only be run when we have python support in gdb,
25 # but that test can only be done after gdb has started, below.
26
27 standard_testfile main.c symtab-producer-dw.S
28
29 # Make some DWARF for the test.
30 set asm_file [standard_output_file $srcfile2]
31 Dwarf::assemble $asm_file {
32     cu {} {
33         DW_TAG_compile_unit {
34             {DW_AT_producer "ACME Compiler Company"}
35             {DW_AT_language @DW_LANG_C}
36             {DW_AT_name symtab-producer-dw.c}
37             {DW_AT_comp_dir /tmp}
38         } {
39             declare_labels integer_label
40
41             integer_label: DW_TAG_base_type {
42                 {DW_AT_byte_size 4 DW_FORM_sdata}
43                 {DW_AT_encoding @DW_ATE_signed}
44                 {DW_AT_name integer}
45             }
46
47             DW_TAG_variable {
48                 {DW_AT_name with_producer}
49                 {DW_AT_type :$integer_label}
50                 {DW_AT_external 1 flag}
51                 {DW_AT_const_value 42 DW_FORM_sdata}
52             }
53         }
54     }
55     cu {} {
56         DW_TAG_compile_unit {
57             {DW_AT_language @DW_LANG_C}
58             {DW_AT_name symtab-producer2-dw.c}
59             {DW_AT_comp_dir /tmp}
60         } {
61             declare_labels integer_label
62
63             integer_label: DW_TAG_base_type {
64                 {DW_AT_byte_size 4 DW_FORM_sdata}
65                 {DW_AT_encoding @DW_ATE_signed}
66                 {DW_AT_name integer}
67             }
68
69             DW_TAG_variable {
70                 {DW_AT_name without_producer}
71                 {DW_AT_type :$integer_label}
72                 {DW_AT_external 1 flag}
73                 {DW_AT_const_value 43 DW_FORM_sdata}
74             }
75         }
76     }
77 }
78
79 # We need --readnow because otherwise we never read in the CUs we
80 # created above.
81 set saved_gdbflags $GDBFLAGS
82 set GDBFLAGS "$GDBFLAGS -readnow"
83
84 if { [prepare_for_testing ${testfile}.exp ${testfile} \
85           [list $srcfile $asm_file] {nodebug}] } {
86     set GDBFLAGS $saved_gdbflags
87     return -1
88 }
89
90 set GDBFLAGS $saved_gdbflags
91
92 # Skip all tests if Python scripting is not enabled.
93 if { [skip_python_tests] } { continue }
94
95 gdb_py_test_silent_cmd "python with_producer = gdb.lookup_global_symbol(\"with_producer\")" \
96     "get with_producer symbol" 0
97
98 gdb_test "python print with_producer.symtab.producer" "ACME Compiler Company"
99
100 gdb_py_test_silent_cmd "python without_producer = gdb.lookup_global_symbol(\"without_producer\")" \
101     "get without_producer symbol" 0
102
103 gdb_test "python print without_producer.symtab.producer" "None"