File: scm-progspace.exp

package info (click to toggle)
gdb-doc 16.3-1
  • links: PTS, VCS
  • area: non-free
  • in suites: forky, sid, trixie
  • size: 244,264 kB
  • sloc: ansic: 2,134,731; asm: 375,582; exp: 206,875; cpp: 73,639; makefile: 70,232; sh: 26,038; python: 13,697; yacc: 11,341; ada: 7,358; xml: 6,098; perl: 5,077; pascal: 3,389; tcl: 2,986; f90: 2,764; lisp: 1,984; cs: 879; lex: 738; sed: 228; awk: 181; objc: 137; fortran: 57
file content (87 lines) | stat: -rw-r--r-- 2,993 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# Copyright (C) 2010-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 <http://www.gnu.org/licenses/>.

# This file is part of the GDB testsuite.
# It tests the program space support in Guile.

load_lib gdb-guile.exp

require allow_guile_tests

standard_testfile

if {[build_executable $testfile.exp $testfile $srcfile debug] == -1} {
    return -1
}

clean_restart

gdb_install_guile_utils
gdb_install_guile_module

proc print_current_progspace { filename_regexp smob_filename_regexp } {
    gdb_test "gu (print (progspace-filename (current-progspace)))" \
	"= $filename_regexp" "current progspace filename"
    gdb_test "gu (print (progspaces))" \
	"= \\(#<gdb:progspace $smob_filename_regexp>\\)"
}

gdb_test "gu (print (progspace? 42))" "= #f"
gdb_test "gu (print (progspace? (current-progspace)))" "= #t"

with_test_prefix "at start" {
    print_current_progspace "#f" "{no symfile}"
}

gdb_load ${binfile}

with_test_prefix "program loaded" {
    print_current_progspace ".*$testfile" ".*$testfile"
    gdb_test_no_output "gu (define progspace (current-progspace))"
    gdb_test "gu (print (progspace-valid? progspace))" "= #t"
    gdb_test "gu (print (progspace-filename progspace))" "= .*$testfile"
    gdb_test "gu (print (list? (progspace-objfiles progspace)))" "= #t"
}

# Verify we keep the same progspace when the program is unloaded.

gdb_unload
with_test_prefix "program unloaded" {
    print_current_progspace "#f" "{no symfile}"
    gdb_test "gu (print (eq? progspace (current-progspace)))" "= #t"
}

# Verify the progspace is garbage collected ok.
# Note that when a program is unloaded, the associated progspace doesn't get
# deleted.  We need to, for example, delete an inferior to get the progspace
# to go away.

gdb_test "add-inferior" "Added inferior 2.*" "create new inferior"
gdb_test "inferior 2" ".*" "switch to new inferior"
gdb_test_no_output "remove-inferiors 1" "remove first inferior"

with_test_prefix "inferior removed" {
    gdb_test "gu (print (progspace-valid? progspace))" "= #f"
    gdb_test "gu (print (progspace-filename progspace))" \
	"ERROR:.*Invalid object.*"
    gdb_test "gu (print (progspace-objfiles progspace))" \
	"ERROR:.*Invalid object.*"
    print_current_progspace "#f" "{no symfile}"
}

# garbage-collects can trigger segvs if we've messed up somewhere.

gdb_test_no_output "gu (gc)"
gdb_test "gu (print progspace)" "= #<gdb:progspace {invalid}>"