From c0689161ed0d44e60c3529b1ee94b9654572a457 Mon Sep 17 00:00:00 2001 From: Toby Lloyd Davies Date: Tue, 19 Mar 2024 11:08:46 +0000 Subject: gdb/python: Fix segfault when iterating over empty linetable symtab-> linetable () is set to null in buildsym_compunit::end_compunit_symtab_with_blockvector () if the symtab has no linetable. Attempting to iterate over this linetable using the Python API caused GDB to segfault. Approved-By: Tom Tromey --- gdb/testsuite/gdb.python/py-linetable-empty.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 gdb/testsuite/gdb.python/py-linetable-empty.c (limited to 'gdb/testsuite/gdb.python/py-linetable-empty.c') diff --git a/gdb/testsuite/gdb.python/py-linetable-empty.c b/gdb/testsuite/gdb.python/py-linetable-empty.c new file mode 100644 index 0000000..85e5588 --- /dev/null +++ b/gdb/testsuite/gdb.python/py-linetable-empty.c @@ -0,0 +1,23 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2024 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +int +main() +{ + asm ("main_label: .globl main_label"); + return 0; +} -- cgit v1.1