Files
binutils-gdb/gdb/testsuite/gdb.base/ctf-constvars.exp
Tom de Vries 908a926ec4 [gdb/testsuite] Fix ctf test-cases on openSUSE Tumbleweed
When running test-case gdb.base/ctf-constvars.exp on openSUSE Tumbleweed (with
system gcc version 12, providing gcc -gctf support, enabling the ctf test-cases
in the gdb testsuite), I run into:
...
(gdb) print vox^M
'vox' has unknown type; cast it to its declared type^M
(gdb) FAIL: gdb.base/ctf-constvars.exp: print vox
...

There are two causes for this:
- the linker flags are missing --ctf-variables, so the information for variable
  vox is missing (reported in PR29468), and
- the executable contains some dwarf2 due to some linked-in glibc objects,
  so the ctf info is ignored (reported in PR29160).

By using:
- -Wl,--ctf-variable,
- -Wl,--strip-debug, and
we can make the test-case and some similar test-cases pass.

Tested on x86_64-linux.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29160
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29468
2022-10-12 17:02:15 +02:00

121 lines
5.1 KiB
Plaintext

# Copyright 2019-2022 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 a subset of constvars.exp, written by
# Elena Zannoni (elz@apollo.hp.com)
#
# This file is part of the gdb testsuite
#
# Tests for: const variables,
# const pointers to vars
# pointers to const variables
# const pointers to const vars
# with mixed types.
if [skip_ctf_tests] {
unsupported "no CTF debug format support, or CTF disabled in GDB"
return 0
}
standard_testfile .c
# Using `-gctf` generates full-fledged CTF debug information.
set opts {}
lappend opts additional_flags=-gctf
lappend opts ldflags=-Wl,--strip-debug
lappend opts ldflags=-Wl,--ctf-variables
lappend opts nowarnings
if { [prepare_for_testing "failed to prepare" ${testfile} \
[list $srcfile] $opts] } {
return 0
}
#
# set it up at a breakpoint so we can play with the variable values
#
if ![runto_main] then {
perror "couldn't run to breakpoint"
return
}
# test vars and pointers
proc do_constvar_tests {} {
gdb_test "print vox" " = 66 'B'"
gdb_test "ptype vox" "type = volatile char"
gdb_test "print victuals" " = 67 'C'"
gdb_test "ptype victuals" "type = volatile unsigned char"
gdb_test "print vixen" " = 200"
gdb_test "ptype vixen" "type = volatile short.*"
gdb_test "print vitriol" " = 300"
gdb_test "ptype vitriol" "type = volatile (unsigned short|short unsigned)( int)?"
gdb_test "print vellum" " = 1000"
gdb_test "ptype vellum" "type = volatile long.*"
gdb_test "print valve" " = 2000"
gdb_test "ptype valve" "type = volatile (unsigned long|long unsigned)( int)?"
gdb_test "print vacuity" " = 3"
gdb_test "ptype vacuity" "type = volatile float"
gdb_test "print vertigo" " = 10"
gdb_test "ptype vertigo" "type = volatile double"
gdb_test "print laconic" " = 65 'A'"
gdb_test "ptype vampire" "type = volatile char.*"
gdb_test "ptype viper" "type = volatile unsigned char.*"
gdb_test "ptype vigour" "type = volatile short.*"
gdb_test "ptype vapour" "type = volatile (unsigned short|short unsigned)( int)?.*"
gdb_test "ptype ventricle" "type = volatile long.*"
gdb_test "ptype vigintillion" "type = volatile (unsigned long|long unsigned)( int)?.*"
gdb_test "ptype vocation" "type = volatile float.*"
gdb_test "ptype veracity" "type = volatile double.*"
gdb_test "ptype vapidity" "type = volatile char.* volatile"
gdb_test "ptype velocity" "type = volatile unsigned char.* volatile"
gdb_test "ptype veneer" "type = volatile short.* volatile"
gdb_test "ptype video" "type = volatile (unsigned short|short unsigned)( int)?.* volatile"
gdb_test "ptype vacuum" "type = volatile long.* volatile"
gdb_test "ptype veniality" "type = volatile (unsigned long|long unsigned)( int)?.* volatile"
gdb_test "ptype vitality" "type = volatile float.* volatile"
gdb_test "ptype voracity" "type = volatile double.* volatile"
gdb_test "ptype violent" "type = volatile char \\\[2\\\]"
gdb_test "ptype violet" "type = volatile unsigned char \\\[2\\\]"
gdb_test "ptype vips" "type = volatile short.* \\\[2\\\]"
gdb_test "ptype virgen" "type = volatile unsigned short.* \\\[2\\\]"
gdb_test "ptype vulgar" "type = volatile long.* \\\[2\\\]"
gdb_test "ptype vulture" "type = volatile (unsigned long|long unsigned)( int)? \\\[2\\\]"
gdb_test "ptype vilify" "type = volatile float \\\[2\\\]"
gdb_test "ptype villar" "type = volatile double \\\[2\\\]"
gdb_test "print victor" " = 89 'Y'"
gdb_test "ptype victor" "type = const volatile char"
gdb_test "ptype victory" "type = const volatile char.*"
gdb_test "ptype cavern" "type = const volatile char.* const"
gdb_test "ptype caveat" "type = const char.* volatile"
gdb_test "ptype covenant" "type = const unsigned char.* volatile"
gdb_test "ptype vanadium" "type = const volatile unsigned char.* volatile"
gdb_test "ptype cove" "type = const char.* const volatile"
gdb_test "ptype cavity" "type = const unsigned char.* const volatile"
gdb_test "ptype vagus" "type = volatile char.* const volatile"
gdb_test "ptype vagrancy" "type = volatile unsigned char.* const volatile"
gdb_test "ptype vagary" "type = const volatile char.* const volatile"
gdb_test "ptype vendor" "type = const volatile unsigned char.* const volatile"
gdb_test "ptype vindictive" "type = const volatile char \\\[2\\\]"
gdb_test "ptype vegetation" "type = const volatile unsigned char \\\[2\\\]"
}
do_constvar_tests