Re: [PATCH v2] PowerPC: Skip base type RTTI tests before inferior start

Tom de Vries
2025-11-25T08:40:43Z

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