]>
Commit | Line | Data |
---|---|---|
213516ef | 1 | # Copyright (C) 2010-2023 Free Software Foundation, Inc. |
ded03782 DE |
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 file is part of the GDB testsuite. | |
17 | # It tests the program space support in Guile. | |
18 | ||
19 | load_lib gdb-guile.exp | |
20 | ||
e71b6502 TT |
21 | require allow_guile_tests |
22 | ||
ded03782 DE |
23 | standard_testfile |
24 | ||
25 | if {[build_executable $testfile.exp $testfile $srcfile debug] == -1} { | |
26 | return -1 | |
27 | } | |
28 | ||
888438e2 | 29 | clean_restart |
ded03782 | 30 | |
ded03782 DE |
31 | gdb_install_guile_utils |
32 | gdb_install_guile_module | |
33 | ||
34 | proc print_current_progspace { filename_regexp smob_filename_regexp } { | |
35 | gdb_test "gu (print (progspace-filename (current-progspace)))" \ | |
36 | "= $filename_regexp" "current progspace filename" | |
37 | gdb_test "gu (print (progspaces))" \ | |
38 | "= \\(#<gdb:progspace $smob_filename_regexp>\\)" | |
39 | } | |
40 | ||
41 | gdb_test "gu (print (progspace? 42))" "= #f" | |
42 | gdb_test "gu (print (progspace? (current-progspace)))" "= #t" | |
43 | ||
44 | with_test_prefix "at start" { | |
45 | print_current_progspace "#f" "{no symfile}" | |
46 | } | |
47 | ||
48 | gdb_load ${binfile} | |
49 | ||
50 | with_test_prefix "program loaded" { | |
51 | print_current_progspace ".*$testfile" ".*$testfile" | |
52 | gdb_test_no_output "gu (define progspace (current-progspace))" | |
53 | gdb_test "gu (print (progspace-valid? progspace))" "= #t" | |
54 | gdb_test "gu (print (progspace-filename progspace))" "= .*$testfile" | |
55 | gdb_test "gu (print (list? (progspace-objfiles progspace)))" "= #t" | |
56 | } | |
57 | ||
58 | # Verify we keep the same progspace when the program is unloaded. | |
59 | ||
60 | gdb_unload | |
61 | with_test_prefix "program unloaded" { | |
62 | print_current_progspace "#f" "{no symfile}" | |
63 | gdb_test "gu (print (eq? progspace (current-progspace)))" "= #t" | |
64 | } | |
65 | ||
66 | # Verify the progspace is garbage collected ok. | |
67 | # Note that when a program is unloaded, the associated progspace doesn't get | |
68 | # deleted. We need to, for example, delete an inferior to get the progspace | |
69 | # to go away. | |
70 | ||
121b3efd | 71 | gdb_test "add-inferior" "Added inferior 2.*" "create new inferior" |
cdc7edd7 | 72 | gdb_test "inferior 2" ".*" "switch to new inferior" |
9f058c10 | 73 | gdb_test_no_output "remove-inferiors 1" "remove first inferior" |
ded03782 DE |
74 | |
75 | with_test_prefix "inferior removed" { | |
76 | gdb_test "gu (print (progspace-valid? progspace))" "= #f" | |
77 | gdb_test "gu (print (progspace-filename progspace))" \ | |
78 | "ERROR:.*Invalid object.*" | |
79 | gdb_test "gu (print (progspace-objfiles progspace))" \ | |
80 | "ERROR:.*Invalid object.*" | |
81 | print_current_progspace "#f" "{no symfile}" | |
82 | } | |
83 | ||
84 | # garbage-collects can trigger segvs if we've messed up somewhere. | |
85 | ||
86 | gdb_test_no_output "gu (gc)" | |
87 | gdb_test "gu (print progspace)" "= #<gdb:progspace {invalid}>" |