public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix gdb.cp/typeid.exp failures for ppc64
@ 2014-12-01 16:00 Luis Machado
  2014-12-01 20:30 ` Sergio Durigan Junior
  0 siblings, 1 reply; 5+ messages in thread
From: Luis Machado @ 2014-12-01 16:00 UTC (permalink / raw)
  To: 'gdb-patches@sourceware.org'

[-- 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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Fix gdb.cp/typeid.exp failures for ppc64
  2014-12-01 16:00 [PATCH] Fix gdb.cp/typeid.exp failures for ppc64 Luis Machado
@ 2014-12-01 20:30 ` Sergio Durigan Junior
  2014-12-05 12:36   ` Luis Machado
  0 siblings, 1 reply; 5+ messages in thread
From: Sergio Durigan Junior @ 2014-12-01 20:30 UTC (permalink / raw)
  To: lgustavo; +Cc: 'gdb-patches@sourceware.org'

On Monday, December 01 2014, Luis Machado wrote:

> 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.

Hey Luis!

Thanks for the patch.  Just a somewhat minor comment.

> 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" {
> +	}
> +    }

Any particular reason for not using gdb_test_multiple here (and
everywhere else)?  This "send_gdb...gdb_expect" dialect is not used
anymore in the testsuite, AFAIR.

>  
> +    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
>
> 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.

Thanks,

-- 
Sergio
GPG key ID: 0x65FC5E36
Please send encrypted e-mail if possible
http://sergiodj.net/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Fix gdb.cp/typeid.exp failures for ppc64
  2014-12-01 20:30 ` Sergio Durigan Junior
@ 2014-12-05 12:36   ` Luis Machado
  2014-12-05 12:38     ` Luis Machado
  0 siblings, 1 reply; 5+ messages in thread
From: Luis Machado @ 2014-12-05 12:36 UTC (permalink / raw)
  To: Sergio Durigan Junior; +Cc: 'gdb-patches@sourceware.org'

On 12/01/2014 06:30 PM, Sergio Durigan Junior wrote:
> On Monday, December 01 2014, Luis Machado wrote:
>
>> 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.
>
> Hey Luis!
>
> Thanks for the patch.  Just a somewhat minor comment.
>
>> 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" {
>> +	}
>> +    }
>
> Any particular reason for not using gdb_test_multiple here (and
> everywhere else)?  This "send_gdb...gdb_expect" dialect is not used
> anymore in the testsuite, AFAIR.
>

It looks a bit more natural when you are aiming at tests that should not 
expose PASS/FAIL. But gdb_test_multiple can be used that way as well, 
though with a somewhat strange empty testname parameter.

Works the same though.

I've updated the patch and fixed a previous gotcha in the logic.

Ok?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Fix gdb.cp/typeid.exp failures for ppc64
  2014-12-05 12:36   ` Luis Machado
@ 2014-12-05 12:38     ` Luis Machado
  2014-12-15 12:29       ` Luis Machado
  0 siblings, 1 reply; 5+ messages in thread
From: Luis Machado @ 2014-12-05 12:38 UTC (permalink / raw)
  To: Sergio Durigan Junior; +Cc: 'gdb-patches@sourceware.org'

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

On 12/05/2014 10:36 AM, Luis Machado wrote:
> On 12/01/2014 06:30 PM, Sergio Durigan Junior wrote:
>> On Monday, December 01 2014, Luis Machado wrote:
>>
>>> 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.
>>
>> Hey Luis!
>>
>> Thanks for the patch.  Just a somewhat minor comment.
>>
>>> 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" {
>>> +    }
>>> +    }
>>
>> Any particular reason for not using gdb_test_multiple here (and
>> everywhere else)?  This "send_gdb...gdb_expect" dialect is not used
>> anymore in the testsuite, AFAIR.
>>
>
> It looks a bit more natural when you are aiming at tests that should not
> expose PASS/FAIL. But gdb_test_multiple can be used that way as well,
> though with a somewhat strange empty testname parameter.
>
> Works the same though.
>
> I've updated the patch and fixed a previous gotcha in the logic.
>
> Ok?
>
>

Of course, now actually attaching the patch itself!



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

2014-12-05  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..54552d4 100644
--- a/gdb/testsuite/gdb.cp/typeid.exp
+++ b/gdb/testsuite/gdb.cp/typeid.exp
@@ -25,20 +25,34 @@ 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.
+    gdb_test_multiple "print 'typeinfo for int'" "" {
+	-re "No symbol \"typeinfo for int\" in current context.*$gdb_prompt $" {
+	    set symbol_found 0
+	}
+	-re ".*$gdb_prompt $" {
+	}
+    }
 
     # We might see the standard type or gdb's internal type.
     set type_re "(std::type_info|struct gdb_gnu_v3_type_info)"
 
+    if {$symbol_found == 1} {
+	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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Fix gdb.cp/typeid.exp failures for ppc64
  2014-12-05 12:38     ` Luis Machado
@ 2014-12-15 12:29       ` Luis Machado
  0 siblings, 0 replies; 5+ messages in thread
From: Luis Machado @ 2014-12-15 12:29 UTC (permalink / raw)
  To: Sergio Durigan Junior; +Cc: 'gdb-patches@sourceware.org'

Ping!

On 12/05/2014 10:37 AM, Luis Machado wrote:
> On 12/05/2014 10:36 AM, Luis Machado wrote:
>> On 12/01/2014 06:30 PM, Sergio Durigan Junior wrote:
>>> On Monday, December 01 2014, Luis Machado wrote:
>>>
>>>> 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.
>>>
>>> Hey Luis!
>>>
>>> Thanks for the patch.  Just a somewhat minor comment.
>>>
>>>> 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" {
>>>> +    }
>>>> +    }
>>>
>>> Any particular reason for not using gdb_test_multiple here (and
>>> everywhere else)?  This "send_gdb...gdb_expect" dialect is not used
>>> anymore in the testsuite, AFAIR.
>>>
>>
>> It looks a bit more natural when you are aiming at tests that should not
>> expose PASS/FAIL. But gdb_test_multiple can be used that way as well,
>> though with a somewhat strange empty testname parameter.
>>
>> Works the same though.
>>
>> I've updated the patch and fixed a previous gotcha in the logic.
>>
>> Ok?
>>
>>
>
> Of course, now actually attaching the patch itself!
>
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-12-15 12:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-01 16:00 [PATCH] Fix gdb.cp/typeid.exp failures for ppc64 Luis Machado
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).