]>
Commit | Line | Data |
---|---|---|
618f726f | 1 | # Copyright 2013-2016 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 | ||
16 | load_lib gdb-python.exp | |
17 | set opts {} | |
18 | standard_testfile .S | |
19 | ||
20 | if [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 | ||
29 | if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} $opts] } { | |
30 | return -1 | |
31 | } | |
32 | ||
33 | if ![runto_main] { | |
34 | return -1 | |
35 | } | |
36 | ||
37 | # Skip all tests if Python scripting is not enabled. | |
38 | if { [skip_python_tests] } { continue } | |
39 | ||
40 | gdb_py_test_silent_cmd "python lt = gdb.selected_frame().find_sal().symtab.linetable()" \ | |
41 | "get instruction" 0 | |
42 | ||
43 | gdb_py_test_multiple "input simple command" \ | |
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 | ||
50 | gdb_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 | 53 | gdb_test "python print(len(lt.line(42)))" "2" \ |
bc79de95 | 54 | "Test length of a multiple pc line" |
d7fc3181 | 55 | gdb_test "python print(len(lt.line(20)))" "1" \ |
bc79de95 | 56 | "Test length of a single pc line" |
d7fc3181 | 57 | gdb_test "python print(lt.line(1))" "None" \ |
bc79de95 PM |
58 | "Test None returned for line with no pc" |
59 | ||
60 | # Test gdb.Linetable.sourcelines () | |
61 | gdb_py_test_silent_cmd "python fset = lt.source_lines()" \ | |
62 | "Get all source lines into a frozen set" 0 | |
f28a0564 SM |
63 | gdb_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 | 68 | gdb_test "python print(lt.has_line(20))" \ |
bc79de95 PM |
69 | "True.*" \ |
70 | "Test has_pcs at line 20" | |
d7fc3181 | 71 | gdb_test "python print(lt.has_line(44))" \ |
bc79de95 PM |
72 | "True.*" \ |
73 | "Test has_pcs at line 40" | |
d7fc3181 | 74 | gdb_test "python print(lt.has_line(10))" \ |
bc79de95 | 75 | "False.*" \ |
bb95117e | 76 | "test has_pcs at line 10" |