Move macros from i386-{nat,low}.c to i386-{nat,low}.h
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.python / py-xmethods.exp
CommitLineData
883964a7
SC
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# 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.
43gdb_test "p a1 + a2" "From CC <A_plus_A>.*15" "Before: a1 + a2"
44gdb_test "p a2 - a1" "From CC <A_minus_A>.*5" "Before: a1 - a2"
45gdb_test "p b1 - a1" "From CC <A_minus_A>.*25" "Before: b1 - a1"
46gdb_test "p a1.geta()" "From CC A::geta.*5" "Before: a1.geta()"
47gdb_test "p ++a1" "No symbol.*" "Before: ++a1"
48gdb_test "p a1.getarrayind(5)" "Couldn't find method.*" \
49 "Before: a1.getarrayind(5)"
50gdb_test "p a_ptr->geta()" "From CC B::geta.*60" "Before: a_ptr->geta()"
51gdb_test "p e.geta()" "From CC A::geta.*100" "Before: e.geta()"
52gdb_test "p g.size_diff<float>()" "From CC G<>::size_diff.*" \
53 "Before: g.size_diff<float>()"
54gdb_test "p g.size_diff<unsigned long>()" "Couldn't find method.*" \
55 "Before: g.size_diff<unsigned long>()"
56gdb_test "p g.size_mul<2>()" "From CC G<>::size_mul.*" \
57 "Before: g.size_mul<2>()"
58gdb_test "p g.size_mul<5>()" "Couldn't find method.*" \
59 "Before: g.size_mul<5>()"
60gdb_test "p g.mul<double>(2.0)" "From CC G<>::mul.*" \
61 "Before: g.mul<double>(2.0)"
62gdb_test "p g.mul<char>('a')" "Couldn't find method.*" \
63 "Before: g.mul<char>('a')"
64
65# Load the script which adds the debug methods.
66gdb_test_no_output "source ${xmethods_script}" "load the script file"
67
68# Tests after loading debug methods.
69gdb_test "p a1 + a2" "From Python <A_plus_A>.*15" "After: a1 + a2"
70gdb_test "p a2 - a1" "From CC <A_minus_A>.*5" "After: a1 - a2"
71gdb_test "p b1 + a1" "From Python <A_plus_A>.*35" "After: b1 + a1"
72gdb_test "p b1 - a1" "From CC <A_minus_A>.*25" "After: b1 - a1"
73gdb_test "p a1.geta()" "From Python <A_geta>.*5" "After: a1.geta()"
74gdb_test "p ++a1" "From Python <plus_plus_A>.*6" "After: ++a1"
75gdb_test "p a1.getarrayind(5)" "From Python <A_getarrayind>.*5" \
76 "After: a1.getarrayind(5)"
77# Note the following test. Xmethods on dynamc types are not looked up
78# currently. Hence, even though a_ptr points to a B object, the xmethod
79# defined for A objects is invoked.
80gdb_test "p a_ptr->geta()" "From Python <A_geta>.*30" "After: a_ptr->geta()"
81gdb_test "p e.geta()" "From Python <A_geta>.*100" "After: e.geta()"
82gdb_test "p e_ptr->geta()" "From Python <A_geta>.*100" "After: e_ptr->geta()"
83gdb_test "p e_ref.geta()" "From Python <A_geta>.*100" "After: e_ref.geta()"
84gdb_test "p e.method(10)" "From Python <E_method_int>.*" "After: e.method(10)"
85gdb_test "p e.method('a')" "From Python <E_method_char>.*" \
86 "After: e.method('a')"
87gdb_test "p g.size_diff<float> ()" "From Python G<>::size_diff.*" \
88 "After: g.size_diff<float>()"
89gdb_test "p g.size_diff< unsigned long >()" "From Python G<>::size_diff.*" \
90 "After: g.size_diff<unsigned long>()"
91gdb_test "p g.size_mul<2>()" "From Python G<>::size_mul.*" \
92 "After: g.size_mul<2>()"
93gdb_test "p g.size_mul< 5 >()" "From Python G<>::size_mul.*" \
94 "After: g.size_mul< 5 >()"
95gdb_test "p g.mul<double>(2.0)" "From Python G<>::mul.*" \
96 "After: g.mul<double>(2.0)"
97gdb_test "p g.mul<char>('a')" "From Python G<>::mul.*" \
98gdb_test "p g_ptr->mul<char>('a')" "From Python G<>::mul.*" \
99 "After: g_ptr->mul<char>('a')"
100
101# Tests for 'disable/enable xmethod' command.
102gdb_test_no_output "disable xmethod .*xmethods G_methods" \
103 "Disable G_methods"
104gdb_test "p g.mul<char>('a')" "Couldn't find method.*" \
105 "g.mul<char>('a') after disabling G_methods"
106gdb_test_no_output "enable xmethod .*xmethods G_methods" \
107 "Enable G_methods"
108gdb_test "p g.mul<char>('a')" "From Python G<>::mul.*" \
109 "After enabling G_methods"
110gdb_test_no_output "disable xmethod .*xmethods G_methods;mul" \
111 "Disable G_methods;mul"
112gdb_test "p g.mul<char>('a')" "Couldn't find method.*" \
113 "g.mul<char>('a') after disabling G_methods;mul"
114gdb_test_no_output "enable xmethod .*xmethods G_methods;mul" \
115 "Enable G_methods;mul"
116gdb_test "p g.mul<char>('a')" "From Python G<>::mul.*" \
117 "After enabling G_methods;mul"
118
119# Test for 'info xmethods' command
120gdb_test "info xmethod global plus" "global.*plus_plus_A" \
121 "info xmethod global plus 1"
122gdb_test_no_output "disable xmethod .*xmethods E_methods;method_int" \
123 "disable xmethod .*xmethods E_methods;method_int"
124gdb_test "info xmethod .*xmethods E_methods;method_int" ".* \\\[disabled\\\]" \
125 "info xmethod xmethods E_methods;method_int"
126
127remote_file host delete ${xmethods_script}
This page took 0.032479 seconds and 4 git commands to generate.