1 # Copyright
(C
) 2024 Free Software Foundation
, Inc.
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.
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.
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
/>.
16 # Test accessing an empty linetable in Python.
19 load_lib gdb
-python.exp
21 require dwarf2_support allow_python_tests
23 standard_testfile .c
-dw.S
25 set asm_file
[standard_output_file $
{srcfile2
}]
26 Dwarf
::assemble $asm_file
{
31 {name py
-linetable
-empty.c
}
34 {MACRO_AT_func
{main
}}
40 if { [prepare_for_testing
"failed to prepare" ${testfile} \
41 [list $srcfile $asm_file
] {nodebug
}] } {
49 gdb_test
"python print(gdb.selected_frame().function().symtab.fullname())" \
50 "py-linetable-empty.c" "Test main has symtab"
52 #
Get the linetable
for main
's symbol table. This is empty as we didn't
include
53 # a linetable in the debug
info.
54 gdb_py_test_silent_cmd
"python lt = gdb.selected_frame().function().symtab.linetable()" \
57 gdb_test
"python print(lt.is_valid())" "True" \
58 "Test linetable is valid"
60 gdb_test
"python print(lt.line(1))" "None" \
61 "Test line() returns None"
63 gdb_test
"python print(lt.has_line(1))" \
64 "RuntimeError.*: Linetable information not found in symbol table.*" \
65 "Test has_line() throws exception"
67 gdb_test
"python print(lt.source_lines())" \
68 "RuntimeError.*: Linetable information not found in symbol table.*" \
69 "Test source_lines() throws exception"
71 gdb_test
"python print(list(lt))" "\\\[\\\]" \
72 "Test iterating over linetable"