| 1 |
24 |
jeremybenn |
# Copyright 2002, 2004, 2007, 2008 Free Software Foundation, Inc.
|
| 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 .
|
| 15 |
|
|
|
| 16 |
|
|
# Tests for member static data
|
| 17 |
|
|
# 2002-05-13 Benjamin Kosnik
|
| 18 |
|
|
# 2002-08-22 David Carlton
|
| 19 |
|
|
|
| 20 |
|
|
# This file is part of the gdb testsuite
|
| 21 |
|
|
|
| 22 |
|
|
if $tracelevel then {
|
| 23 |
|
|
strace $tracelevel
|
| 24 |
|
|
}
|
| 25 |
|
|
|
| 26 |
|
|
if { [skip_cplus_tests] } { continue }
|
| 27 |
|
|
|
| 28 |
|
|
#
|
| 29 |
|
|
# test running programs
|
| 30 |
|
|
#
|
| 31 |
|
|
set prms_id 0
|
| 32 |
|
|
set bug_id 0
|
| 33 |
|
|
|
| 34 |
|
|
set testfile "m-static"
|
| 35 |
|
|
set srcfile "${testfile}.cc"
|
| 36 |
|
|
set srcfile1 "${testfile}1.cc"
|
| 37 |
|
|
set objfile "${testfile}.o"
|
| 38 |
|
|
set objfile1 "${testfile}1.o"
|
| 39 |
|
|
set binfile "${objdir}/${subdir}/${testfile}"
|
| 40 |
|
|
|
| 41 |
|
|
if { [gdb_compile "$srcdir/$subdir/$srcfile" "$objdir/$subdir/$objfile" object {debug c++}] != "" } {
|
| 42 |
|
|
untested m-static.exp
|
| 43 |
|
|
return -1
|
| 44 |
|
|
}
|
| 45 |
|
|
|
| 46 |
|
|
if { [gdb_compile "$srcdir/$subdir/$srcfile1" "$objdir/$subdir/$objfile1" object {debug c++}] != "" } {
|
| 47 |
|
|
untested m-static.exp
|
| 48 |
|
|
return -1
|
| 49 |
|
|
}
|
| 50 |
|
|
|
| 51 |
|
|
if { [gdb_compile "$objdir/$subdir/$objfile $objdir/$subdir/$objfile1" "${binfile}" executable {debug c++}] != "" } {
|
| 52 |
|
|
untested m-static.exp
|
| 53 |
|
|
return -1
|
| 54 |
|
|
}
|
| 55 |
|
|
|
| 56 |
|
|
gdb_exit
|
| 57 |
|
|
gdb_start
|
| 58 |
|
|
gdb_reinitialize_dir $srcdir/$subdir
|
| 59 |
|
|
gdb_load ${binfile}
|
| 60 |
|
|
|
| 61 |
|
|
|
| 62 |
|
|
if ![runto_main] then {
|
| 63 |
|
|
perror "couldn't run to breakpoint"
|
| 64 |
|
|
continue
|
| 65 |
|
|
}
|
| 66 |
|
|
|
| 67 |
|
|
# First, run to after we've constructed all the objects:
|
| 68 |
|
|
|
| 69 |
|
|
gdb_breakpoint [gdb_get_line_number "constructs-done"]
|
| 70 |
|
|
gdb_continue_to_breakpoint "end of constructors"
|
| 71 |
|
|
|
| 72 |
|
|
|
| 73 |
|
|
# One.
|
| 74 |
|
|
|
| 75 |
|
|
# simple object, static const bool
|
| 76 |
|
|
gdb_test "print test1.test" "\\$\[0-9\]* = true" "simple object, static const bool"
|
| 77 |
|
|
|
| 78 |
|
|
# simple object, static const int
|
| 79 |
|
|
gdb_test "print test1.key1" "\\$\[0-9\]* = 5" "simple object, static const int"
|
| 80 |
|
|
|
| 81 |
|
|
# simple object, static long
|
| 82 |
|
|
gdb_test "print test1.key2" "\\$\[0-9\]* = 77" "simple object, static long"
|
| 83 |
|
|
|
| 84 |
|
|
# simple object, static enum
|
| 85 |
|
|
gdb_test "print test1.value" "\\$\[0-9\]* = oriental" "simple object, static enum"
|
| 86 |
|
|
|
| 87 |
|
|
# Two.
|
| 88 |
|
|
|
| 89 |
|
|
# derived template object, base static const bool
|
| 90 |
|
|
gdb_test "print test2.test" "\\$\[0-9\]* = true" "derived template object, base static const bool"
|
| 91 |
|
|
|
| 92 |
|
|
# derived template object, base static const int
|
| 93 |
|
|
gdb_test "print test2.key1" "\\$\[0-9\]* = 5" "derived template object, base static const int"
|
| 94 |
|
|
|
| 95 |
|
|
# derived template object, base static long
|
| 96 |
|
|
gdb_test "print test2.key2" "\\$\[0-9\]* = 77" "derived template object, base static long"
|
| 97 |
|
|
|
| 98 |
|
|
# derived template object, base static enum
|
| 99 |
|
|
gdb_test "print test2.value" "\\$\[0-9\].* = oriental" "derived template object, base static enum"
|
| 100 |
|
|
|
| 101 |
|
|
# derived template object, static enum
|
| 102 |
|
|
gdb_test "print test2.value_derived" "\\$\[0-9\].* = etruscan" "derived template object, static enum"
|
| 103 |
|
|
|
| 104 |
|
|
# Three.
|
| 105 |
|
|
|
| 106 |
|
|
# template object, static derived template data member's base static const bool
|
| 107 |
|
|
gdb_test "print test3.data.test" "\\$\[0-9\].* = true" "template object, static const bool"
|
| 108 |
|
|
|
| 109 |
|
|
# template object, static derived template data member's base static const int
|
| 110 |
|
|
gdb_test "print test3.data.key1" "\\$\[0-9\].* = 5" "template object, static const int"
|
| 111 |
|
|
|
| 112 |
|
|
# template object, static derived template data member's base static long
|
| 113 |
|
|
gdb_test "print test3.data.key2" "\\$\[0-9\].* = 77" "template object, static long"
|
| 114 |
|
|
|
| 115 |
|
|
# template object, static derived template data member's base static enum
|
| 116 |
|
|
gdb_test "print test3.data.value" "\\$\[0-9\].* = oriental" "template object, static enum"
|
| 117 |
|
|
|
| 118 |
|
|
# template object, static derived template data member's static enum
|
| 119 |
|
|
gdb_test "print test3.data.value_derived" "\\$\[0-9\].* = etruscan" "template object, static derived enum"
|
| 120 |
|
|
|
| 121 |
|
|
# 2002-08-16
|
| 122 |
|
|
# Four.
|
| 123 |
|
|
|
| 124 |
|
|
# static const int initialized in another file.
|
| 125 |
|
|
gdb_test "print test4.elsewhere" "\\$\[0-9\].* = 221" "static const int initialized elsewhere"
|
| 126 |
|
|
|
| 127 |
|
|
# static const int that nobody initializes. From PR gdb/635.
|
| 128 |
|
|
gdb_test "print test4.nowhere" "field nowhere is nonexistent or has been optimised out" "static const int initialized nowhere"
|
| 129 |
|
|
|
| 130 |
|
|
# Perhaps at some point test4 should also include a test for a static
|
| 131 |
|
|
# const int that was initialized in the header file. But I'm not sure
|
| 132 |
|
|
# that GDB's current behavior in such situations is either consistent
|
| 133 |
|
|
# across platforms or optimal, so I'm not including one now.
|
| 134 |
|
|
|
| 135 |
|
|
gdb_exit
|
| 136 |
|
|
return 0
|