]>
Commit | Line | Data |
---|---|---|
1d506c26 | 1 | # Copyright (C) 2015-2024 Free Software Foundation, Inc. |
04dccad0 JB |
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 | # This file is part of the GDB testsuite. It tests the mechanism | |
17 | # of exposing types to Python. | |
18 | ||
19 | load_lib gdb-python.exp | |
20 | ||
d82e5429 | 21 | require allow_python_tests |
79749205 | 22 | |
04dccad0 JB |
23 | # Note that the purpose of this testcase is to test the behavior |
24 | # of gdb.lookup_type searching for the primitive types internally | |
25 | # created by each language since GDB. So, we must start GDB without | |
26 | # loading any symbol in. | |
27 | ||
9b2234b0 | 28 | clean_restart |
04dccad0 | 29 | |
04dccad0 JB |
30 | proc test_lookup_type { lang type_name } { |
31 | gdb_test_no_output "set language ${lang}" | |
f8313f6e JB |
32 | gdb_test "python print(gdb.lookup_type('${type_name}').name)" \ |
33 | "${type_name}" \ | |
04dccad0 JB |
34 | "lookup type ${type_name} using language ${lang}" |
35 | } | |
36 | ||
37 | test_lookup_type "ada" "character" | |
38 | ||
39 | test_lookup_type "c" "char" | |
40 | ||
41 | test_lookup_type "d" "ucent" | |
42 | ||
43 | test_lookup_type "fortran" "character" | |
44 | ||
45 | test_lookup_type "go" "int32" | |
46 | ||
04dccad0 JB |
47 | test_lookup_type "modula-2" "CARDINAL" |
48 | ||
49 | test_lookup_type "opencl" "ushort" | |
50 | ||
51 | test_lookup_type "objective-c" "char" | |
52 | ||
04dccad0 | 53 | test_lookup_type "pascal" "char" |
1da5d0e6 | 54 | |
b583c328 TT |
55 | gdb_test "show language" \ |
56 | "The current source language is .pascal.." \ | |
57 | "show language before 'with'" | |
58 | gdb_test_multiline "look up type using set_parameter" \ | |
59 | "python" "" \ | |
60 | "with gdb.with_parameter('language', 'ada'):" "" \ | |
61 | " print(gdb.lookup_type('character'))" "" \ | |
62 | "end" "character" | |
63 | gdb_test "show language" \ | |
64 | "The current source language is .pascal.." \ | |
65 | "show language after 'with'" | |
66 | ||
67 | ||
1da5d0e6 TT |
68 | # Ensure that the language can be changed from within Python and still |
69 | # affect the results. | |
70 | gdb_test_multiline "look up ada type from another language" \ | |
71 | "python" "" \ | |
72 | "gdb.execute('set language ada')" "" \ | |
73 | "print(gdb.lookup_type('character'))" "" \ | |
74 | "end" "character" | |
b583c328 TT |
75 | |
76 | gdb_test_no_output "python gdb.set_parameter('language', 'rust')" | |
77 | gdb_test "show language" \ | |
78 | "The current source language is .rust.." \ | |
79 | "show language after 'set_parameter'" |