Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Kevin Pouget <kevin.pouget@gmail.com>
To: Ulrich Weigand <uweigand@de.ibm.com>
Cc: Tom Tromey <tromey@redhat.com>,
	gdb-patches@sourceware.org, brobecker@adacore.com
Subject: Re: [RFC] Python Finish Breakpoints
Date: Wed, 04 Jan 2012 15:24:00 -0000	[thread overview]
Message-ID: <CAPftXUKW3NTuTzhQpVAU-tiXz_VXmjJgGNJiCy9izrE5M4H1qQ@mail.gmail.com> (raw)
In-Reply-To: <201201041449.q04EnCCO026716@d06av02.portsmouth.uk.ibm.com>

On Wed, Jan 4, 2012 at 3:49 PM, Ulrich Weigand <uweigand@de.ibm.com> wrote:
> Kevin Pouget wrote:
>
>>       * gdb.python/py-finish-breakpoint2.cc: New file.
>>       * gdb.python/py-finish-breakpoint2.exp: New file.
>>       * gdb.python/py-finish-breakpoint2.py: New file.
>
> I'm seeing those fail on various platforms (i386, ppc, ppc64):
> FAIL: gdb.python/py-finish-breakpoint2.exp: check FinishBreakpoint in catch()
> FAIL: gdb.python/py-finish-breakpoint2.exp: check finish BP removal
> FAIL: gdb.python/py-finish-breakpoint2.exp: continue to second exception
> FAIL: gdb.python/py-finish-breakpoint2.exp: set FinishBP after the exception
>
> However in other cases the test succeeds -- this appears to be related to
> the particular compiler version that's being used.
>
> The problem is that the finish-breakpoint mechanism sets a breakpoint on
> the regular return address of the current frame, i.e. the instruction
> where the "call" instruction would return normally.  However, when an
> exception is thrown and then caught, execution continues at a different
> call site (in the catch block).  There's now two possibilities:
>
>  try
>    {
>      throw_exception_1 (10);
>    }
>  catch (const int *e)
>    {
>        std::cerr << "Exception #" << *e << std::endl;
>    }
>  i += 1; /* Break after exception 1.  */
>
>
> A) The instruction immediately following the "call" instruction to
>   throw_exception_1 is actually already one of the instructions used
>   to implement the "i += 1" line, and code flow after executing the
>   catch block branches back to that location.  I.e. we have a call
>   graph along the lines of:
>
>   [...]
>       call throw_exception_1 (10)  [ set up catch block at Lc ]
>   Lx: compute i += 1
>   [...]
>
>   Lc: call std:cerr << ...
>       goto Lx
>
>  and the finish breakpoint gets set just at label Lx, and it will
>  get hit both after a regular return and after an exception.
>
> B) The instruction immediately following the "call" instruction
>   is still part of the (clean up after the) call, or some other
>   code flow instruction, and the instructions used to implement
>   "i += 1" are elsewhere.  I.e. the call graph looks more like:
>
>   [...]
>       call throw_exception_1 (10)  [ set up catch block at Lc ]
>   Lx: goto Ly
>
>   Lc: call std:cerr <<< ...
>
>   Ly: compute i += 1
>   [...]
>
>   In this case the finish breakpoint gets set at Lx, which *never*
>   gets executed after an exception.
>
>
> It seems to me that current GDB code does not (even attempt to) properly
> handle the "finish" command and/or the new finish-breakpoint capability
> in the presence of exceptions.  Note that even in case A) above, where
> the finish breakpoint does hit, it arguably hits in the wrong location:
> at the "finish" of the throw_exception_1 line, execution continues *in
> the catch block*, so we should stop at the start of the catch block
> instead of after it has completed.
>
> Am I missing some piece of GDB code that attempts to handle this, and
> is just malfunctioning?  It would certainly be good to properly support
> this feature, but until we do, I'd suggest this test case should be
> disabled ...

Hello,

thanks for spotting and explaining this bug

I can say at least that there is no code to handle this situation in
my patch. One thing I wonder is what's the situation C which passes
the test in my environment ? (x86_64)

My knowledge about C++ is quite limited, but based on your
descriptions, a proper support would involve another breakpoint, set
at Lc, to disable the FinishBreakpoint ... but I'm not sure how
computable this Lc is.

I'll let Tom answer about what to do with the testsuite.


Thanks,

Kevin


  reply	other threads:[~2012-01-04 15:24 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <BANLkTim+YH64zkWvdz2_kVUUj=AJ7v4LKw@mail.gmail.com>
     [not found] ` <BANLkTi=gtHzWzXOJzB+a19=jkfk1hGwQBg@mail.gmail.com>
     [not found]   ` <BANLkTikVdqbMqjguTV8ct0TWiBDhHGYtLg@mail.gmail.com>
2011-05-11  7:44     ` Kevin Pouget
2011-05-11 10:31       ` Phil Muldoon
2011-05-11 11:29         ` Kevin Pouget
2011-05-12 10:38           ` Kevin Pouget
2011-05-12 10:50         ` Phil Muldoon
2011-05-12 11:29           ` Kevin Pouget
     [not found] ` <BANLkTi=Eu-5B4YyhP2rGdQXgXbBN-EmLKA@mail.gmail.com>
     [not found]   ` <BANLkTikt2hEUcXkGVH44NaUcwiF1SGdMaw@mail.gmail.com>
     [not found]     ` <BANLkTi=UpgogckTD5MZsW+PC5d2F8X-+jA@mail.gmail.com>
     [not found]       ` <BANLkTi==bj50mZgFKq_qA-+3-2CQA3tBVw@mail.gmail.com>
     [not found]         ` <BANLkTimmYEmvKT_984jYEVZnA5RGFpEgNw@mail.gmail.com>
2011-05-19 16:21           ` Tom Tromey
2011-05-24 12:51             ` Kevin Pouget
2011-05-27 20:30               ` Tom Tromey
2011-05-30  9:29                 ` Kevin Pouget
2011-10-13 14:34                   ` Kevin Pouget
2011-10-20 20:12                     ` Tom Tromey
2011-10-20 20:58                   ` Tom Tromey
2011-10-21  8:15                     ` Kevin Pouget
2011-10-24 11:43                       ` Kevin Pouget
2011-10-24 13:20                         ` Eli Zaretskii
2011-10-24 14:30                           ` Kevin Pouget
2011-10-24 17:14                             ` Eli Zaretskii
2011-10-24 15:31                         ` Kevin Pouget
2011-10-24 16:27                           ` Phil Muldoon
2011-10-25 11:05                             ` Kevin Pouget
2011-10-25 11:37                               ` Phil Muldoon
2011-10-25 12:22                                 ` Kevin Pouget
2011-10-28  8:33                                   ` Kevin Pouget
2011-10-28 20:51                                     ` Tom Tromey
2011-11-02 14:44                                       ` Kevin Pouget
2011-11-04 14:25                                         ` Kevin Pouget
2011-11-04 21:04                                           ` Tom Tromey
2011-11-09 14:10                                             ` Kevin Pouget
2011-11-16 10:53                                               ` Kevin Pouget
2011-11-17 17:49                                                 ` Tom Tromey
2011-11-17 17:48                                               ` Tom Tromey
     [not found]                                                 ` <CAPftXUJwtGJhqFyfX6LVK87QH2xeLkvv5kx=yaEnYJMv0YR_rw@mail.gmail.com>
2011-11-24  8:27                                                   ` Kevin Pouget
2011-11-30 16:02                                                     ` Kevin Pouget
2011-12-02 21:49                                                       ` Tom Tromey
2011-12-05  9:29                                                         ` Kevin Pouget
2011-12-06 21:18                                                           ` Tom Tromey
2011-12-07 13:35                                                             ` Kevin Pouget
2011-12-08 15:30                                                               ` Tom Tromey
2011-12-08 16:10                                                                 ` Kevin Pouget
2011-12-08 18:08                                                                   ` Kevin Pouget
2011-12-09  9:53                                                                     ` Kevin Pouget
2011-12-18 19:22                                                                       ` Kevin Pouget
2011-12-20 20:55                                                                       ` Tom Tromey
2011-12-20 20:58                                                                         ` Kevin Pouget
2011-12-21  7:16                                                                           ` Joel Brobecker
2011-12-21 17:13                                                                             ` Tom Tromey
     [not found]                                                                               ` <CAPftXUKXh9ekZ2kiwQ=5zbrjst+9VH9-eZk8h+Z-9SpQ1WqdLw@mail.gmail.com>
     [not found]                                                                                 ` <CAPftXULQFggY3Nz2byC0fMZA1sg4Nymp3hAhe8aSuLNG4cauFg@mail.gmail.com>
     [not found]                                                                                   ` <CAPftXUJALHd=-fajVwgowqfCDfXO6JMxSkorWD6CQArsg-PedQ@mail.gmail.com>
     [not found]                                                                                     ` <CAPftXULKC8gp3L87+PZEF3dj3crv9bh-uzZpRiYKjqEw_xyptQ@mail.gmail.com>
2011-12-27  4:18                                                                                       ` Joel Brobecker
2011-12-27  9:40                                                                                         ` Kevin Pouget
2011-12-27 12:22                                                                                           ` Joel Brobecker
2011-12-27  9:34                                                                                       ` Kevin Pouget
2011-12-24 23:56                                                                           ` [patch] Fix gdb.python/py-finish-breakpoint.exp new FAIL on x86_64-m32 [Re: [RFC] Python Finish Breakpoints] Jan Kratochvil
2011-12-27 11:13                                                                             ` Kevin Pouget
2011-12-27 21:39                                                                               ` [commit] " Jan Kratochvil
2012-01-04 17:45                                                                             ` Ulrich Weigand
2012-01-04 17:58                                                                               ` [commit 7.4] " Jan Kratochvil
2012-01-04 18:10                                                                                 ` Ulrich Weigand
2011-12-26 11:28                                                                           ` [patch] Fix remote.c crash on gdbserver close (+fix py-finish-breakpoint.exp for gdbserver) " Jan Kratochvil
2011-12-27 23:30                                                                             ` [patch] Fix remote.c crash on gdbserver close (+fix py-finish-breakpoint.exp for gdbserver) [rediff] Jan Kratochvil
2012-01-02 17:57                                                                               ` Tom Tromey
2012-01-02 19:49                                                                               ` Pedro Alves
2012-01-19 16:24                                                                                 ` Call target_close after unpushing, not before (was: Re: [patch] Fix remote.c crash on gdbserver close (+fix py-finish-breakpoint.exp for gdbserver)) Pedro Alves
2012-01-19 16:27                                                                                   ` Jan Kratochvil
2012-01-19 16:37                                                                                     ` Call target_close after unpushing, not before Pedro Alves
2012-01-19 16:53                                                                                     ` [commit] Re: Call target_close after unpushing, not before (was: Re: [patch] Fix remote.c crash on gdbserver close (+fix py-finish-breakpoint.exp for gdbserver)) Jan Kratochvil
2012-01-04 14:49                                                                       ` [RFC] Python Finish Breakpoints Ulrich Weigand
2012-01-04 15:24                                                                         ` Kevin Pouget [this message]
2012-01-04 16:29                                                                           ` Ulrich Weigand
2012-01-04 16:42                                                                           ` Tom Tromey
2012-01-04 16:40                                                                         ` Tom Tromey
2012-01-04 17:13                                                                           ` Ulrich Weigand
2012-01-09  9:21                                                                             ` Kevin Pouget
2012-01-27 17:01                                                                               ` Kevin Pouget
2011-10-28 19:26                                   ` Tom Tromey

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=CAPftXUKW3NTuTzhQpVAU-tiXz_VXmjJgGNJiCy9izrE5M4H1qQ@mail.gmail.com \
    --to=kevin.pouget@gmail.com \
    --cc=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@redhat.com \
    --cc=uweigand@de.ibm.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