]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/fork-no-detach-follow-child-dlopen.exp
Automatic date update in version.in
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / fork-no-detach-follow-child-dlopen.exp
CommitLineData
1d506c26 1# Copyright 2022-2024 Free Software Foundation, Inc.
fcf8e814
LS
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 test is a regression test for when GDB debugs a program with:
17# - set follow-fork-mode child
18# - set detach-on-fork off
19#
20# If the program forks, and the child loads a shared library (via
21# dlopen for example), GDB should still load the symtab for this objfile.
22# When a breakpoint is hit in this file, GDB should display the location
23# in the source of the shlib, and "list" should display the source where
24# the program stopped.
25
d6195dc9 26require allow_shlib_tests
fcf8e814
LS
27
28standard_testfile .c -shlib.c
29set shlib_path [standard_output_file ${testfile}-lib.so]
30
31if { [gdb_compile_shlib $srcdir/$subdir/$srcfile2 $shlib_path {debug}] != "" } {
32 return
33}
34
dfe30a41
TV
35set shlib_path_target [gdb_download_shlib $::shlib_path]
36
37set opts [list shlib_load additional_flags=-DSHLIB_PATH="${shlib_path_target}"]
fcf8e814
LS
38if { [build_executable "failed to prepare" ${testfile} ${srcfile} $opts] } {
39 return
40}
41
42proc do_test {} {
43 clean_restart $::binfile
dfe30a41 44 gdb_locate_shlib $::shlib_path
fcf8e814
LS
45 gdb_test_no_output "set follow-fork-mode child"
46 gdb_test_no_output "set detach-on-fork off"
47
9c25a9d0 48 runto "add" qualified allow-pending
fcf8e814
LS
49
50 # Since we have debug info in the shlib, we should have the file name available.
51 gdb_test "frame" "add \(.*\) at .*$::srcfile2:\[0-9\]+.*"
52
53 # We must also be able to display the source for the current function.
54 gdb_test "list" "return a \\+ b;.*"
55}
56
57do_test