Fix test breakages caused by removal of gdb_py_test_multiple.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.python / py-linetable.exp
CommitLineData
b811d2c2 1# Copyright 2013-2020 Free Software Foundation, Inc.
bc79de95
PM
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
16load_lib gdb-python.exp
17set opts {}
18standard_testfile .S
19
20if [info exists COMPILE] {
21 # make check RUNTESTFLAGS="gdb.python/py-linetable.exp COMPILE=1"
22 standard_testfile
23 lappend opts debug optimize=-O2
24} elseif { ![istarget x86_64-*-* ] || ![is_lp64_target] } {
25 verbose "Skipping ${testfile}."
26 return
27}
28
5b362f04 29if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} $opts] } {
bc79de95
PM
30 return -1
31}
32
33if ![runto_main] {
34 return -1
35}
36
37# Skip all tests if Python scripting is not enabled.
38if { [skip_python_tests] } { continue }
39
40gdb_py_test_silent_cmd "python lt = gdb.selected_frame().find_sal().symtab.linetable()" \
41 "get instruction" 0
42
2a17c803 43gdb_test_multiline "input simple command" \
bc79de95
PM
44 "python" "" \
45 "def list_lines():" "" \
46 " for l in lt:" "" \
d7fc3181 47 " print ('L' + str(l.line) + ' A ' + hex(l.pc))" "" \
bc79de95
PM
48 "end" ""
49
50gdb_test "python list_lines()" \
51 "L20 A $hex.*L21 A $hex.*L22 A $hex.*L24 A $hex.*L25 A $hex.*L40 A $hex.*L42 A $hex.*L44 A $hex.*L42 A $hex.*L46 A $hex.*" \
52 "test linetable iterator addr"
d7fc3181 53gdb_test "python print(len(lt.line(42)))" "2" \
bc79de95 54 "Test length of a multiple pc line"
d7fc3181 55gdb_test "python print(len(lt.line(20)))" "1" \
bc79de95 56 "Test length of a single pc line"
d7fc3181 57gdb_test "python print(lt.line(1))" "None" \
bc79de95
PM
58 "Test None returned for line with no pc"
59
60# Test gdb.Linetable.sourcelines ()
61gdb_py_test_silent_cmd "python fset = lt.source_lines()" \
62 "Get all source lines into a frozen set" 0
f28a0564
SM
63gdb_test "python print (sorted(fset))" \
64 "\\\[20, 21, 22, 24, 25, 28, 29, 30, 32, 33, 37, 39, 40, 42, 44, 45, 46\\\].*" \
bb95117e 65 "test frozen set contains line numbers"
bc79de95
PM
66
67# Test gdb.Linetable.has_line ()
d7fc3181 68gdb_test "python print(lt.has_line(20))" \
bc79de95
PM
69 "True.*" \
70 "Test has_pcs at line 20"
d7fc3181 71gdb_test "python print(lt.has_line(44))" \
bc79de95
PM
72 "True.*" \
73 "Test has_pcs at line 40"
d7fc3181 74gdb_test "python print(lt.has_line(10))" \
bc79de95 75 "False.*" \
bb95117e 76 "test has_pcs at line 10"
This page took 0.777058 seconds and 4 git commands to generate.