public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: Nils-Christian Kempke via Gdb-patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH 2/2] gdb: Resolve dynamic target types of pointers.
Date: Thu, 10 Feb 2022 12:47:01 -0700	[thread overview]
Message-ID: <87k0e2tsga.fsf@tromey.com> (raw)
In-Reply-To: <20220118132626.3786176-3-nils-christian.kempke@intel.com> (Nils-Christian Kempke via Gdb-patches's message of "Tue, 18 Jan 2022 14:26:26 +0100")

>>>>> Nils-Christian Kempke via Gdb-patches <gdb-patches@sourceware.org> writes:

Hi.  Thanks for the patch.

> +	  if (type->code () == TYPE_CODE_PTR && is_dynamic_type (type))
> +	    {
> +	      CORE_ADDR addr;
> +	      if (nullptr != TYPE_DATA_LOCATION (TYPE_TARGET_TYPE (type)))
> +		addr = value_address (val);
> +	      else
> +		addr = value_as_address (val);

This seems weird to me.  When does value_as_address fail?
It seems to me that a value whose type is TYPE_CODE_PTR should be more
easily convertible to a CORE_ADDR without examining TYPE_DATA_LOCATION.

The same thing applies in a couple more spots in the patch.

I'm curious why the code added here is not also needed in f-valprint.c.

> --- a/gdb/testsuite/gdb.cp/vla-cxx.exp
> +++ b/gdb/testsuite/gdb.cp/vla-cxx.exp
> @@ -23,6 +23,36 @@ if ![runto_main] {
>      return -1
>  }
 
> +gdb_breakpoint [gdb_get_line_number "Before pointer assignment"]
> +gdb_continue_to_breakpoint "Before pointer assignment"
> +
> +set test_name "ptype ptr, Before pointer assignment"
> +gdb_test_multiple "ptype ptr" $test_name {
> +  # gfortran
> +  -re "= int \\(\\*\\)\\\[variable length\\\]\r\n$gdb_prompt $" {
> +    pass $test_name
> +  }
> +  # ifort/ifx

This references fortran compilers but is a c++ test.

> +gdb_test "ptype ptr" "int \\(\\*\\)\\\[3\\\]"
> +gdb_test "print ptr" "\\(int \\(\\*\\)\\\[3\\\]\\) $hex"
> +gdb_test "print *ptr" " = \\{5, 7, 9\\}"

Do these pass with all compilers or do they also need to be conditional?

thanks,
Tom

  reply	other threads:[~2022-02-10 19:47 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-18 13:26 [PATCH 0/2] Resolve dynamic types for pointers Nils-Christian Kempke
2022-01-18 13:26 ` [PATCH 1/2] gdb/types: Resolve dynamic properties of pointer types Nils-Christian Kempke
2022-01-28 18:30   ` Tom Tromey
2022-01-31  8:15     ` Kempke, Nils-Christian
2022-01-18 13:26 ` [PATCH 2/2] gdb: Resolve dynamic target types of pointers Nils-Christian Kempke
2022-02-10 19:47   ` Tom Tromey [this message]
2022-04-14 10:22     ` Kempke, Nils-Christian
2022-04-15 16:14       ` Tom Tromey
2022-04-19  6:59         ` Kempke, Nils-Christian
2022-05-13 14:45           ` Kempke, Nils-Christian

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=87k0e2tsga.fsf@tromey.com \
    --to=tom@tromey.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).