Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Michael Elizabeth Chastain <mec@shout.net>
To: gdb-patches@sources.redhat.com
Subject: [testsuite] add gdb.cp/gdb1355.exp
Date: Thu, 18 Sep 2003 00:00:00 -0000	[thread overview]
Message-ID: <200309180000.h8I00rK4012420@duracef.shout.net> (raw)

Here are some tests for PR gdb/1355, which is a reference to
PR gcc/12066.  This was a bug in gcc which busted the basic
stabs types with C++ (C and Java worked fine).

If you use a version of gcc with this bug, plenty of other
things break, so this test does not add any coverage.
It does add an explicit KFAIL that points to the specific PR.

Testing: I tested this with gcc 2.95.3 and gcc 3.3.1 and one
of the broken versions of gcc HEAD, with both -dwarf-2 and stabs+.

I am committing this now.

Michael C

=== gdb1355.exp

# Copyright 2003 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 2 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, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  

# Tests for PR gdb/1355, which is a reference to PR gcc/12066.
# 2003-08-26  Michael Chastain <mec@shout.net>

# This file is part of the gdb testsuite.

set ws "\[\r\n\t \]*"
set nl "\[\r\n\]+"

if $tracelevel then {
    strace $tracelevel
    }

if { [skip_cplus_tests] } { continue }

#
# test running programs
#
set prms_id 0
set bug_id 0

set testfile "gdb1355"
set srcfile ${testfile}.cc
set binfile ${objdir}/${subdir}/${testfile}

if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
     gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
}

if [get_compiler_info ${binfile} "c++"] {
    return -1
}

gdb_exit
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_load ${binfile}

if ![runto_main] then {
    perror "couldn't run to main"
    continue
} 

# See http://sources.redhat.com/gdb/bugs/1355
# See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12066
#
# g++ -gstabs+ does not emit stabs for fundamental types.
# They get emitted later inside other types, so they have no names
# and gdb cannot handle them.

set s_head  "${ws}(struct|class) mystruct \{(${ws}public:|)"
set s_tail  ".*"

set f_i     "${ws}int m_int;"
set f_c     "${ws}char m_char;"
set f_li    "${ws}long int m_long_int;"
set f_ui    "${ws}unsigned int m_unsigned_int;"
set f_lui   "${ws}long unsigned int m_long_unsigned_int;"
set f_si    "${ws}short int m_short_int;"
set f_sui   "${ws}short unsigned int m_short_unsigned_int;"
set f_uc    "${ws}unsigned char m_unsigned_char;"
set f_f     "${ws}float m_float;"
set f_d     "${ws}double m_double;"
set f_ld    "${ws}long double m_long_double;"
set f_b     "${ws}bool m_bool;"

set itc     "<invalid type code ${decimal}>"
set bad_i   "${ws}(${itc}|int) m_int;";
set bad_c   "${ws}(${itc}|char) m_char;"
set bad_li  "${ws}(${itc}|long int) m_long_int;"
set bad_ui  "${ws}(${itc}|unsigned int) m_unsigned_int;"
set bad_lui "${ws}(${itc}|long unsigned int) m_long_unsigned_int;"
set bad_si  "${ws}(${itc}|short int) m_short_int;"
set bad_sui "${ws}(${itc}|short unsigned int) m_short_unsigned_int;"
set bad_uc  "${ws}(${itc}|unsigned char) m_unsigned_char;"
set bad_f   "${ws}(${itc}|float) m_float;"
set bad_d   "${ws}(${itc}|double) m_double;"
set bad_ld  "${ws}(${itc}|long double) m_long_double;"
set bad_b   "${ws}(${itc}|bool) m_bool;"

gdb_test_multiple "ptype s1" "ptype s1" {
    -re "type = ${s_head}${f_i}${f_c}${f_li}${f_ui}${f_lui}${f_si}${f_sui}${f_uc}${f_f}${f_d}${f_ld}${f_b}${s_tail}\}$nl$gdb_prompt $" {
	pass "ptype s1"
    }
    -re "type = ${s_head}${bad_i}${bad_c}${bad_li}${bad_ui}${bad_lui}${bad_si}${bad_sui}${bad_uc}${bad_f}${bad_d}${bad_ld}${bad_b}${s_tail}\}$nl$gdb_prompt $" {
	# This happened with gcc HEAD 2003-08-20 08:00:00 UTC, -gstabs+.
	kfail "gdb/1355" "ptype s1"
    }
}

gdb_test_multiple "print s1" "print s1" {
    -re "$decimal = \{m_int = 117, m_char = 97 'a', m_long_int = 118, m_unsigned_int = 119, m_long_unsigned_int = 120, m_short_int = 123, m_short_unsigned_int = 124, m_unsigned_char = 98 'b', m_float = 125, m_double = 126, m_long_double = 127, m_bool = true\}$nl$gdb_prompt $" {
	pass "print s1"
    }
    -re "$decimal = \{m_int = 117, m_char = 97 'a', m_long_int = 118, m_unsigned_int = 119, m_long_unsigned_int = 120, m_short_int = 123, m_short_unsigned_int = 124, m_unsigned_char = 98 'b', m_float = 125, m_double = 126, m_long_double = 127, m_bool = 117\}$nl$gdb_prompt $" {
	# This pattern is very picky, but if more different output
	# shows up, I can just add more arms.  -- chastain 2003-08-26
	#
	# This happened with gcc HEAD 2003-08-20 08:00:00 UTC, -gstabs+.
	# Look at the value of m_bool.  It looks like gdb latched onto
	# random int type and then used the data at structure offset 0.
	kfail "gdb/1355" "print s1"
    }
}

=== gdb1355.c

struct mystruct
{
  int m_int;
  char m_char;
  long int m_long_int;
  unsigned int m_unsigned_int;
  long unsigned int m_long_unsigned_int;
  // long long int m_long_long_int;
  // long long unsigned int m_long_long_unsigned_int;
  short int m_short_int;
  short unsigned int m_short_unsigned_int;
  unsigned char m_unsigned_char;
  float m_float;
  double m_double;
  long double m_long_double;
  // complex int m_complex_int;
  // complex float m_complex_float;
  // complex long double m_complex_long_double;
  // wchar_t m_wchar_t;
  bool m_bool;
};

struct mystruct s1 =
{
    117, 'a', 118, 119, 120,
    // 121, 122,
    123, 124, 'b', 125.0, 126.0, 127.0,
    // complex int, complex float, complex long double, wchar_t,
    true
};

int main ()
{
  return 0;
}


             reply	other threads:[~2003-09-18  0:00 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-09-18  0:00 Michael Elizabeth Chastain [this message]
2003-09-18  0:48 ` David Carlton
2003-09-18  0:54 Michael Elizabeth Chastain
2003-09-18  0:56 ` Daniel Jacobowitz
2003-09-18  1:20   ` David Carlton
2003-09-18  1:27     ` David Carlton
2003-09-18  2:01 Michael Elizabeth Chastain
2003-09-18 14:27 ` Andrew Cagney
2003-09-18 16:05   ` David Carlton
2003-09-18 15:38 ` David Carlton
2003-09-18 15:33 Michael Elizabeth Chastain
2003-09-20 21:40 ` Andrew Cagney
2003-09-18 21:22 Michael Elizabeth Chastain
2003-09-18 21:27 Michael Elizabeth Chastain
2003-09-20 21:46 ` Andrew Cagney
2003-09-20 22:31   ` Daniel Jacobowitz
2003-09-21  0:51     ` Andrew Cagney
2003-09-20 21:59 Michael Elizabeth Chastain
2003-09-20 22:03 Michael Elizabeth Chastain

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200309180000.h8I00rK4012420@duracef.shout.net \
    --to=mec@shout.net \
    --cc=gdb-patches@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox