public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Martin Galvan <martin.galvan@tallertechnologies.com>
To: Pedro Alves <palves@redhat.com>
Cc: gdb-patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH v2] Fix gdb crash when trying to print the address of a synthetic pointer.
Date: Sun, 28 Jun 2015 05:06:00 -0000	[thread overview]
Message-ID: <CAOKbPbbg-VV77=3KKYu=fYZPQonSWNesRyJjq_34rXq9R7SyqQ@mail.gmail.com> (raw)
In-Reply-To: <558A90D7.30505@redhat.com>

On Wed, Jun 24, 2015 at 8:13 AM, Pedro Alves <palves@redhat.com> wrote:
> On 06/20/2015 04:25 AM, Martin Galvan wrote:
>> Yes, 'function' ends up inlined. If we try to set a breakpoint at a
>> line inside 'function', the breakpoint will be set at an address we'll
>> never hit, thus we need to advance using 'step' and 'next' instead.
>
> Then it sounds like you were putting a breakpoint at a line that was
> optimized out.  If you put the breakpoint at the same line that you
> "step" and "next" to, then it should work, I think.  You'll still
> need a "step" to go from real stack frame to inline frame, as GDB always
> presents you the stack frame on breakpoint hits.

That's what I tried at the beginning. However, if I set the breakpoint
at the line I step to, using "continue" will either take me to an
address after the one I want to stop at, or just finish the program.

> Hmm, that looks too long to me and still escaping out a detail
> that isn't really that interesting to the user.  I was just thinking:
>
> if (is reference)
>  "Attempt to take address of a synthetic reference."
> else
>  "Attempt to take address of a synthetic pointer."

The case on which the variable is an actual synthetic pointer (as
opposed to a synthetic reference) doesn't seem to reach value_addr;
instead it prints the "Can't take address of foo which isn't an
lvalue" message from address_of_variable.

If you think it's ok, I'll print "Attempt to take address of a
synthetic reference" at value_addr, and move the check inside the
TYPE_CODE_REF path.

>> I haven't been able to test this so far because the test requires an
>> x86-like target, which I don't have at hand. I'll keep you posted,
>> though.
>
> Do you have an x86-64 box?  If so, you can just run the test with:
>
>  make check RUNTESTFLAGS="--target_board=unix/-m32 gdb.dwarf2/implptr.exp"

That worked alright. Is this documented somewhere?

>> Assuming gdb crashes there too, couldn't I just add a "print &j" test
>> there and discard the synthetic-pointer-reference.exp test altogether?
>
> Actually from your description, I assume it _doesn't_ crash, because it's
> not a reference.  But it's not tested presently, so who know.  I think it's
> worth it to have both pointers and references covered.

You're right, it doesn't crash. I'll still add a test to implptr.exp
to catch the "Can't take address of foo which isn't an lvalue"
message, though.

About not using printf inside synthetic-pointer-reference.cc, is there
any way to make sure gcc won't optimize 'arg' out completely other
than that? Declaring it as volatile doesn't seem to work.

  reply	other threads:[~2015-06-28  5:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-14  4:49 Martin Galvan
2015-06-15 11:17 ` Pedro Alves
2015-06-20  3:25   ` Martin Galvan
2015-06-24 11:13     ` Pedro Alves
2015-06-28  5:06       ` Martin Galvan [this message]
2015-06-30 10:46         ` Pedro Alves

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='CAOKbPbbg-VV77=3KKYu=fYZPQonSWNesRyJjq_34rXq9R7SyqQ@mail.gmail.com' \
    --to=martin.galvan@tallertechnologies.com \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.com \
    /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).