Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Joel Brobecker <brobecker@adacore.com>
To: Pierre-Marie de Rodat <derodat@adacore.com>
Cc: GDB Patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH] Do not consider reference types as dynamic
Date: Mon, 23 Mar 2015 13:36:00 -0000	[thread overview]
Message-ID: <20150323133627.GG5438@adacore.com> (raw)
In-Reply-To: <54FEDC09.3050106@adacore.com>

Hello Pierre-Marie,

> I'm working on a GCC patch that fixes the type of Ada functions that
> return their result by reference: the debugging information
> currently says they return a pointer to the result and my patch
> turns these into references. The intent is that when evaluating a
> call to such functions from debuggers, the returned value is
> automatically dereferenced:
> 
>    # Currently we have:
>    (gdb) print my_function("foo")
>    $1 = (access ...) 0x...
> 
>    # We would like to have instead:
>    (gdb) print my_function("foo")
>    $1 = <referenced object>
> 
> Doing so in GDB is currently not possible when the referenced object
> type is dynamic. Indeed, the return value for such calls is not in
> memory and GDB considers reference types as dynamic iff the
> referenced type is dynamic. As a consequence, the type resolving
> process ends up trying to read memory at address 0x0, fails to do so
> and aborts printing the final value:
> 
>     # With my locally patched GCC, I have:
>     (gdb) print my_function("foo")
>     $1 = Cannot access memory at address 0x0
> 
> The attached patch fixes GDB so that the above works. It just makes
> GDB never consider reference types as dynamic (which makes sense per
> se IMHO) so this memory problem does not occurs.
> 
> I tested this patch on x86_64-linux with C, C++, Ada, Fortran and
> Java compilers: it triggers no regression. Note that the testcase it
> adds (gdb.ada/funcall_ref.exp) cannot pass without my local GCC
> patch and relies on my previous submitted patch
> (https://www.sourceware.org/ml/gdb-patches/2015-03/msg00241.html).

If it cannot pass without your GCC patch, let's add a setup_xfail.

> Ok to push?
> Thank you in advance!
> 
>     gdb/ChangeLog:
>     2015-03-10  Pierre-Marie de Rodat  <derodat@adacore.com>
> 
>         * gdbtypes.c (is_dynamic_type_internal): Remove special handling
>         of TYPE_CODE_REF types so that they are not considered as
>         dynamic depending on the referenced type.
> 
>     gdb/testsuite/ChangeLog:
>     2015-03-10  Pierre-Marie de Rodat  <derodat@adacore.com>
> 
>         * gdb.ada/funcall_ref.exp: New file.
>         * gdb.ada/funcall_ref/foo.adb: New file.

Mostly OK - a couple of minor comments below.

> +# Test printing and type-printing of a discriminated record that a function
> +# returns by reference.
> +
> +gdb_test "p get (\"Hello world!\")" \
> +         "= \\(n => 12, s => \"Hello world!\"\\)" \
> +         "p get (\"Hello world!\")"

If the test "label" (3rd argument) is the same as the command being
sent, you do not need to explicitly specify it. So, the following
is equivalent to your version:

        gdb_test "p get (\"Hello world!\")" \
                 "= \\(n => 12, s => \"Hello world!\"\\)"

> +gdb_test "ptype get (\"Hello world!\")" \
> +         [multi_line "type = <ref> record" \
> +                     "    n: natural;" \
> +                     "    s: access array \\(1 \\.\\. n\\) of character;" \
> +                     "end record"] \
> +         "ptype get (\"Hello world!\")"

Same here.

> +++ b/gdb/testsuite/gdb.ada/funcall_ref/foo.adb
> @@ -0,0 +1,19 @@
> +procedure Foo is

Missing copyright header.

Thank you,
-- 
Joel


  reply	other threads:[~2015-03-23 13:36 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-10 11:57 Pierre-Marie de Rodat
2015-03-23 13:36 ` Joel Brobecker [this message]
2015-04-01  8:52   ` Pierre-Marie de Rodat
2015-04-03  8:45     ` Pierre-Marie de Rodat
2015-04-03 12:47       ` Joel Brobecker
2015-04-03 13:02         ` Pierre-Marie de Rodat
2015-04-03 13:12           ` Joel Brobecker
2015-04-03 13:25             ` Pierre-Marie de Rodat
2015-04-17 10:47       ` Yao Qi
2015-04-17 11:20         ` Pierre-Marie de Rodat
2015-04-17 15:07           ` Pierre-Marie de Rodat
2015-04-17 15:29             ` Joel Brobecker
2015-04-20 14:27               ` Pierre-Marie de Rodat
2015-04-24 14:22                 ` Pierre-Marie de Rodat

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=20150323133627.GG5438@adacore.com \
    --to=brobecker@adacore.com \
    --cc=derodat@adacore.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