Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Luis Machado <lgustavo@codesourcery.com>
To: "'gdb-patches@sourceware.org'" <gdb-patches@sourceware.org>
Subject: [PATCH] Fix gdb.cp/typeid.exp failures for ppc64
Date: Mon, 01 Dec 2014 16:00:00 -0000	[thread overview]
Message-ID: <547C9087.1090506@codesourcery.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 430 bytes --]

This test assumes the typeid symbols are always available before 
actually starting the inferior, which is not true for architectures that 
place such symbols under relocatable sections.

The following patch fixes this by conditionalizing the execution of such 
tests on the accessibility of the typeid symbols before the inferior is 
running.

Regression-tested on ppc32/64.

Ok?

ps: A -w version of the patch is also attached.

[-- Attachment #2: typeid.diff --]
[-- Type: text/x-patch, Size: 2094 bytes --]

2014-12-01  Luis Machado  <lgustavo@codesourcery.com>

	gdb/testsuite
	* gdb.cp/typeid.exp (do_typeid_tests): Do not test type id printing
	unless the symbols are available.

diff --git a/gdb/testsuite/gdb.cp/typeid.exp b/gdb/testsuite/gdb.cp/typeid.exp
index 9963a8a..7469b2b 100644
--- a/gdb/testsuite/gdb.cp/typeid.exp
+++ b/gdb/testsuite/gdb.cp/typeid.exp
@@ -25,20 +25,35 @@ if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
 
 proc do_typeid_tests {started} {
     global hex
+    global gdb_prompt
+    set symbol_found 1
 
-    # We might see the standard type or gdb's internal type.
-    set type_re "(std::type_info|struct gdb_gnu_v3_type_info)"
+    # Try to access one of the symbols to make sure it is available.  Some
+    # architectures put the symbols on relocatable sections, which means
+    # they will not be accessible before the inferior is running.
+    send_gdb "print 'typeinfo for int'\n"
+    gdb_expect {
+	-re "No symbol \"typeinfo for int\" in current context.*$gdb_prompt" {
+	    set symbol_found 0
+	}
+	-re ".*$gdb_prompt" {
+	}
+    }
 
+    if {$symbol_found == 1} {
+	# We might see the standard type or gdb's internal type.
+	set type_re "(std::type_info|struct gdb_gnu_v3_type_info)"
 
-    foreach simple_var {i cp ccp ca b} {
-	gdb_test "print &typeid($simple_var)" \
-	    " = \\($type_re \\*\\) $hex.*"
+	foreach simple_var {i cp ccp ca b} {
+	    gdb_test "print &typeid($simple_var)" \
+		" = \\($type_re \\*\\) $hex.*"
 
-	# Note that we test pointer equality rather than object
-	# equality here.  That is because std::type_info's operator==
-	# is not present in the libstdc++ .so.
-	gdb_test "print &typeid($simple_var) == &typeid(typeof($simple_var))" \
-	    " = true"
+	    # Note that we test pointer equality rather than object
+	    # equality here.  That is because std::type_info's operator==
+	    # is not present in the libstdc++ .so.
+	    gdb_test "print &typeid($simple_var) == &typeid(typeof($simple_var))" \
+		" = true"
+	}
     }
 
     # typeid for these is Derived.  Don't try these tests until the

[-- Attachment #3: typeid_w.diff --]
[-- Type: text/x-patch, Size: 1324 bytes --]

diff --git a/gdb/testsuite/gdb.cp/typeid.exp b/gdb/testsuite/gdb.cp/typeid.exp
index 9963a8a..7469b2b 100644
--- a/gdb/testsuite/gdb.cp/typeid.exp
+++ b/gdb/testsuite/gdb.cp/typeid.exp
@@ -25,11 +25,25 @@ if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
 
 proc do_typeid_tests {started} {
     global hex
+    global gdb_prompt
+    set symbol_found 1
 
+    # Try to access one of the symbols to make sure it is available.  Some
+    # architectures put the symbols on relocatable sections, which means
+    # they will not be accessible before the inferior is running.
+    send_gdb "print 'typeinfo for int'\n"
+    gdb_expect {
+	-re "No symbol \"typeinfo for int\" in current context.*$gdb_prompt" {
+	    set symbol_found 0
+	}
+	-re ".*$gdb_prompt" {
+	}
+    }
+
+    if {$symbol_found == 1} {
 	# We might see the standard type or gdb's internal type.
 	set type_re "(std::type_info|struct gdb_gnu_v3_type_info)"
 
-
 	foreach simple_var {i cp ccp ca b} {
 	    gdb_test "print &typeid($simple_var)" \
 		" = \\($type_re \\*\\) $hex.*"
@@ -40,6 +54,7 @@ proc do_typeid_tests {started} {
 	    gdb_test "print &typeid($simple_var) == &typeid(typeof($simple_var))" \
 		" = true"
 	}
+    }
 
     # typeid for these is Derived.  Don't try these tests until the
     # inferior has started.

             reply	other threads:[~2014-12-01 16:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-01 16:00 Luis Machado [this message]
2014-12-01 20:30 ` Sergio Durigan Junior
2014-12-05 12:36   ` Luis Machado
2014-12-05 12:38     ` Luis Machado
2014-12-15 12:29       ` Luis Machado

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=547C9087.1090506@codesourcery.com \
    --to=lgustavo@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    /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