Fix an internal error in GAS when assembling a bogus piece of source code.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.python / py-xmethods.exp
CommitLineData
32d0add0 1# Copyright 2014-2015 Free Software Foundation, Inc.
883964a7
SC
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 debug methods
17# feature in the Python extension language.
18
19load_lib gdb-python.exp
20
21if { [skip_cplus_tests] } { continue }
22
23standard_testfile py-xmethods.cc
24
25if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
26 return -1
27}
28
29# Skip all tests if Python scripting is not enabled.
30if { [skip_python_tests] } { continue }
31
32if ![runto_main] {
33 return -1
34}
35
36set xmethods_script [gdb_remote_download host \
37 ${srcdir}/${subdir}/${testfile}.py]
38
39gdb_breakpoint [gdb_get_line_number "Break here."]
40gdb_continue_to_breakpoint "Break here" ".*Break here.*"
41
42# Tests before loading the debug methods.
5d376983
SC
43gdb_test "p a1 + a2" ".* = 15" "Before: a1 + a2"
44gdb_test "p a_plus_a" ".* = 1" "Before: a_plus_a 1"
45
46gdb_test "p a2 - a1" ".* = 5" "Before: a2 - a1"
47gdb_test "p a_minus_a" ".* = 1" "Before: a_minus_a 1"
48
49gdb_test "p b1 - a1" ".* = 25" "Before: b1 - a1"
50gdb_test "p a_minus_a" ".* = 2" "Before: a_minus_a 2"
51
52gdb_test "p a1.geta()" ".* = 5" "Before: a1.geta()"
53gdb_test "p a_geta" ".* = 1" "Before: a_geta 1"
54
883964a7
SC
55gdb_test "p ++a1" "No symbol.*" "Before: ++a1"
56gdb_test "p a1.getarrayind(5)" "Couldn't find method.*" \
57 "Before: a1.getarrayind(5)"
5d376983
SC
58
59gdb_test "p a_ptr->geta()" ".* = 60" "Before: a_ptr->geta()"
60gdb_test "p b_geta" ".* = 1" "Before: b_geta 1"
61
62gdb_test "p e.geta()" ".* = 100" "Before: e.geta()"
63gdb_test "p a_geta" ".* = 2" "Before: a_geta 2"
64
65# Since g.size_diff operates of sizes of int and float, do not check for
66# actual result value as it could be different on different platforms.
67gdb_test "p g.size_diff<float>()" ".*" "Before: call g.size_diff<float>()"
68gdb_test "p g_size_diff" ".* = 2" "Before: g_size_diff 2"
69
883964a7
SC
70gdb_test "p g.size_diff<unsigned long>()" "Couldn't find method.*" \
71 "Before: g.size_diff<unsigned long>()"
5d376983
SC
72
73gdb_test "p g.size_mul<2>()" ".*" "Before: g.size_mul<2>()"
74gdb_test "p g_size_mul" ".* = 2" "Before: g_size_mul 2"
75
883964a7
SC
76gdb_test "p g.size_mul<5>()" "Couldn't find method.*" \
77 "Before: g.size_mul<5>()"
5d376983
SC
78
79gdb_test "p g.mul<double>(2.0)" ".* = 10" "Before: g.mul<double>(2.0)"
80gdb_test "p g_mul" ".* = 2" "Before: g_mul 2"
81
883964a7
SC
82gdb_test "p g.mul<char>('a')" "Couldn't find method.*" \
83 "Before: g.mul<char>('a')"
84
85# Load the script which adds the debug methods.
86gdb_test_no_output "source ${xmethods_script}" "load the script file"
87
88# Tests after loading debug methods.
89gdb_test "p a1 + a2" "From Python <A_plus_A>.*15" "After: a1 + a2"
5d376983
SC
90
91gdb_test "p a2 - a1" ".* = 5" "After: a2 - a1"
92gdb_test "p a_minus_a" ".* = 3" "After: a_minus_a 3"
93
883964a7 94gdb_test "p b1 + a1" "From Python <A_plus_A>.*35" "After: b1 + a1"
5d376983
SC
95
96gdb_test "p b1 - a1" ".* = 25" "After: b1 - a1"
97gdb_test "p a_minus_a" ".* = 4" "After: a_minus_a 4"
98
883964a7
SC
99gdb_test "p a1.geta()" "From Python <A_geta>.*5" "After: a1.geta()"
100gdb_test "p ++a1" "From Python <plus_plus_A>.*6" "After: ++a1"
101gdb_test "p a1.getarrayind(5)" "From Python <A_getarrayind>.*5" \
102 "After: a1.getarrayind(5)"
103# Note the following test. Xmethods on dynamc types are not looked up
104# currently. Hence, even though a_ptr points to a B object, the xmethod
105# defined for A objects is invoked.
106gdb_test "p a_ptr->geta()" "From Python <A_geta>.*30" "After: a_ptr->geta()"
107gdb_test "p e.geta()" "From Python <A_geta>.*100" "After: e.geta()"
108gdb_test "p e_ptr->geta()" "From Python <A_geta>.*100" "After: e_ptr->geta()"
109gdb_test "p e_ref.geta()" "From Python <A_geta>.*100" "After: e_ref.geta()"
110gdb_test "p e.method(10)" "From Python <E_method_int>.*" "After: e.method(10)"
111gdb_test "p e.method('a')" "From Python <E_method_char>.*" \
112 "After: e.method('a')"
113gdb_test "p g.size_diff<float> ()" "From Python G<>::size_diff.*" \
114 "After: g.size_diff<float>()"
115gdb_test "p g.size_diff< unsigned long >()" "From Python G<>::size_diff.*" \
116 "After: g.size_diff<unsigned long>()"
117gdb_test "p g.size_mul<2>()" "From Python G<>::size_mul.*" \
118 "After: g.size_mul<2>()"
119gdb_test "p g.size_mul< 5 >()" "From Python G<>::size_mul.*" \
120 "After: g.size_mul< 5 >()"
121gdb_test "p g.mul<double>(2.0)" "From Python G<>::mul.*" \
122 "After: g.mul<double>(2.0)"
123gdb_test "p g.mul<char>('a')" "From Python G<>::mul.*" \
124gdb_test "p g_ptr->mul<char>('a')" "From Python G<>::mul.*" \
125 "After: g_ptr->mul<char>('a')"
126
127# Tests for 'disable/enable xmethod' command.
70afc5b7 128gdb_test_no_output "disable xmethod progspace G_methods" \
883964a7
SC
129 "Disable G_methods"
130gdb_test "p g.mul<char>('a')" "Couldn't find method.*" \
131 "g.mul<char>('a') after disabling G_methods"
70afc5b7 132gdb_test_no_output "enable xmethod progspace G_methods" \
883964a7
SC
133 "Enable G_methods"
134gdb_test "p g.mul<char>('a')" "From Python G<>::mul.*" \
135 "After enabling G_methods"
70afc5b7 136gdb_test_no_output "disable xmethod progspace G_methods;mul" \
883964a7
SC
137 "Disable G_methods;mul"
138gdb_test "p g.mul<char>('a')" "Couldn't find method.*" \
139 "g.mul<char>('a') after disabling G_methods;mul"
70afc5b7 140gdb_test_no_output "enable xmethod progspace G_methods;mul" \
883964a7
SC
141 "Enable G_methods;mul"
142gdb_test "p g.mul<char>('a')" "From Python G<>::mul.*" \
143 "After enabling G_methods;mul"
144
145# Test for 'info xmethods' command
146gdb_test "info xmethod global plus" "global.*plus_plus_A" \
147 "info xmethod global plus 1"
70afc5b7
SC
148gdb_test_no_output "disable xmethod progspace E_methods;method_int" \
149 "disable xmethod progspace E_methods;method_int"
150gdb_test "info xmethod progspace E_methods;method_int" ".* \\\[disabled\\\]" \
883964a7 151 "info xmethod xmethods E_methods;method_int"
This page took 0.126544 seconds and 4 git commands to generate.