Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH v2] PowerPC: Skip base type RTTI tests before inferior start
@ 2025-11-25  6:50 Abhay Kandpal
  2025-11-25  8:39 ` Tom de Vries
  0 siblings, 1 reply; 2+ messages in thread
From: Abhay Kandpal @ 2025-11-25  6:50 UTC (permalink / raw)
  To: gdb-patches; +Cc: Ulrich.Weigand, tdevries, cel, abhay.k, Abhay Kandpal

On PowerPC targets, RTTI typeinfo objects for simple base types such as
`int`, `char*`, and `const char*` may not be emitted until the inferior
has been started.  As a result, the `gdb.cp/typeid.exp` test fails when
checking typeid results before program execution begins.

This patch extends the existing Clang-specific logic that skips base type
RTTI checks before the inferior starts, to also apply on PowerPC.  This
ensures consistent test behavior across compilers and targets.

gdb/testsuite/
    * gdb.cp/typeid.exp (do_typeid_tests): Skip base type RTTI tests
    before inferior start on PowerPC.
---
This patch is reg tested.
Change from v1 -> v2
<Change the logic to skip base type RTTI test>
<Modified commit log>

 gdb/testsuite/gdb.cp/typeid.exp | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/gdb/testsuite/gdb.cp/typeid.exp b/gdb/testsuite/gdb.cp/typeid.exp
index bd97b26c6e4..cce6a294dd5 100644
--- a/gdb/testsuite/gdb.cp/typeid.exp
+++ b/gdb/testsuite/gdb.cp/typeid.exp
@@ -28,14 +28,24 @@ proc do_typeid_tests {started} {
     set type_re "(std::type_info|gdb_gnu_v3_type_info)"
 
     set var {ca b}
-    if {$started || ![test_compiler_info clang-*-* c++]} {
-	# Clang doesn't place type information for the base types in
-	# the executable, and relies on this being linked in from the
-	# standard library.  As a result, type information for these
-	# variables is only available once the inferior is started.
+    set have_base_types 1
+    if {!$started} {
+       if {[test_compiler_info clang-*-* c++]} {
+	   # Note that we test pointer equality rather than object
+	   # Clang doesn't place type information for the base types in
+	   # the executable, and relies on this being linked in from the
+	   # standard library.  As a result, type information for these
+	   # variables is only available once the inferior is started.
+	   set have_base_types 0
+       } elseif {[istarget "powerpc*-*-*"]} {
+	   # On PowerPC, RTTI typeinfo for base types (i, cp, ccp) may not be
+	   # emitted until the inferior is started.
+	   set have_base_types 0
+       }
+    }
+    if { $have_base_types } {
 	lappend var i cp ccp
     }
-
     foreach simple_var $var {
 	gdb_test "print &typeid($simple_var)" \
 	    " = \\($type_re \\*\\) $hex.*"
-- 
2.51.1


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

* Re: [PATCH v2] PowerPC: Skip base type RTTI tests before inferior start
  2025-11-25  6:50 [PATCH v2] PowerPC: Skip base type RTTI tests before inferior start Abhay Kandpal
@ 2025-11-25  8:39 ` Tom de Vries
  0 siblings, 0 replies; 2+ messages in thread
From: Tom de Vries @ 2025-11-25  8:39 UTC (permalink / raw)
  To: Abhay Kandpal, gdb-patches; +Cc: Ulrich.Weigand, cel, abhay.k

On 11/25/25 7:50 AM, Abhay Kandpal wrote:
> On PowerPC targets, RTTI typeinfo objects for simple base types such as
> `int`, `char*`, and `const char*` may not be emitted until the inferior
> has been started.  As a result, the `gdb.cp/typeid.exp` test fails when
> checking typeid results before program execution begins.
> 
> This patch extends the existing Clang-specific logic that skips base type
> RTTI checks before the inferior starts, to also apply on PowerPC.  This
> ensures consistent test behavior across compilers and targets.
> 

LGTM, with one nit below.

Approved-By: Tom de Vries <tdevries@suse.de>

Thanks,
- Tom

> gdb/testsuite/
>      * gdb.cp/typeid.exp (do_typeid_tests): Skip base type RTTI tests
>      before inferior start on PowerPC.
> ---
> This patch is reg tested.
> Change from v1 -> v2
> <Change the logic to skip base type RTTI test>
> <Modified commit log>
> 
>   gdb/testsuite/gdb.cp/typeid.exp | 22 ++++++++++++++++------
>   1 file changed, 16 insertions(+), 6 deletions(-)
> 
> diff --git a/gdb/testsuite/gdb.cp/typeid.exp b/gdb/testsuite/gdb.cp/typeid.exp
> index bd97b26c6e4..cce6a294dd5 100644
> --- a/gdb/testsuite/gdb.cp/typeid.exp
> +++ b/gdb/testsuite/gdb.cp/typeid.exp
> @@ -28,14 +28,24 @@ proc do_typeid_tests {started} {
>       set type_re "(std::type_info|gdb_gnu_v3_type_info)"
>   
>       set var {ca b}
> -    if {$started || ![test_compiler_info clang-*-* c++]} {
> -	# Clang doesn't place type information for the base types in
> -	# the executable, and relies on this being linked in from the
> -	# standard library.  As a result, type information for these
> -	# variables is only available once the inferior is started.
> +    set have_base_types 1
> +    if {!$started} {
> +       if {[test_compiler_info clang-*-* c++]} {
> +	   # Note that we test pointer equality rather than object
> +	   # Clang doesn't place type information for the base types in
> +	   # the executable, and relies on this being linked in from the
> +	   # standard library.  As a result, type information for these
> +	   # variables is only available once the inferior is started.
> +	   set have_base_types 0
> +       } elseif {[istarget "powerpc*-*-*"]} {
> +	   # On PowerPC, RTTI typeinfo for base types (i, cp, ccp) may not be
> +	   # emitted until the inferior is started.
> +	   set have_base_types 0
> +       }
> +    }
> +    if { $have_base_types } {
>   	lappend var i cp ccp
>       }
> -

Don't remove this empty line.

>       foreach simple_var $var {
>   	gdb_test "print &typeid($simple_var)" \
>   	    " = \\($type_re \\*\\) $hex.*"


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

end of thread, other threads:[~2025-11-25  8:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-11-25  6:50 [PATCH v2] PowerPC: Skip base type RTTI tests before inferior start Abhay Kandpal
2025-11-25  8:39 ` Tom de Vries

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox