From: Pedro Alves <pedro@codesourcery.com>
To: gdb-patches@sourceware.org
Cc: Jan Kratochvil <jan.kratochvil@redhat.com>
Subject: Re: [patch] Do not bpstat_clear_actions on throw_exception
Date: Mon, 08 Aug 2011 15:44:00 -0000 [thread overview]
Message-ID: <201108081644.08465.pedro@codesourcery.com> (raw)
In-Reply-To: <20110805201417.GA23405@host1.jankratochvil.net>
On Friday 05 August 2011 21:14:17, Jan Kratochvil wrote:
> Hi,
>
> as discussed here recently throw_exception does various unwised side effects.
> This patch is a pre-requisite for the entryval patchset as unavailable entry
> values is a normal caught silent exception there but it now stops any commands
> execution.
>
> This function was there already during initial import of GDB to CVS. I do not
> see its reason as any uncaught exception throws through bpstat_do_actions_1
> and thus terminates the bpstat evaluation anyway.
>
> And it the exception is caught there it is wrong to stop the commands
> execution.
This isn't enough. If you have a bpstat with only one breakpoint with
commands, and the error you tried was while running the breakpoint's
commands, you won't see a problem, because bpstat_do_actions_1
does bs->commands_left = NULL before executing the commands.
But, e.g., try something like:
(gdb) b foo
(gdb) commands
> p 1
> p *0
> p 2
end
(gdb) b foo
(gdb) commands
> p 3
> p *0
> p 4
end
and run to foo. After seeing the error, try any other
command, like "p 5". You'll see the breakpoint commands
of the other breakpoint running...
Things get more complicated with any error that is thrown
from between bpstat_stop_status, and actually running the
breakpoint commands. You'll also leave bs->commands_left
set then.
Maybe bs->commands_left shouldn't be set by
bpstat_stop_status at all.
>
> There was also the reset of bpstat->commands but I do not find it related:
>
> http://sourceware.org/ml/gdb-patches/2003-12/msg00350.html
> RFA: protect breakpoint commands from being freed
> http://sourceware.org/ml/gdb-cvs/2003-12/msg00136.html
> commit 79dbd81d5190cb413c7c44fdf00a858576f14e7e
> Author: Jim Blandy <jimb@codesourcery.com>
> Date: Mon Dec 22 03:43:19 2003 +0000
>
> * breakpoint.c (bpstat_do_actions): To ensure that
> clear_proceed_status doesn't free the command tree we're
> evaluating out from under us, zero the bpstat's pointer to it, and
> take care of freeing it ourselves.
> * cli/cli-script.c (make_cleanup_free_command_lines): Make this
> function externally visible.
> * cli/cli-script.h (make_cleanup_free_command_lines): New
> declaration.
>
> No regressions on {x86_64,x86_64-m32,i686}-fedora16pre-linux-gnu.
>
>
> Thanks,
> Jan
>
>
> gdb/
> 2011-08-05 Jan Kratochvil <jan.kratochvil@redhat.com>
>
> * breakpoint.c (bpstat_clear_actions): Remove.
> * breakpoint.h (bpstat_clear_actions): Remove.
> * exceptions.c (throw_exception): Remove variable tp, its
> initialization and the call of bpstat_clear_actions.
>
> --- a/gdb/breakpoint.c
> +++ b/gdb/breakpoint.c
> @@ -3186,23 +3186,6 @@ bpstat_num (bpstat *bsp, int *num)
> return 1;
> }
>
> -/* Modify BS so that the actions will not be performed. */
> -
> -void
> -bpstat_clear_actions (bpstat bs)
> -{
> - for (; bs != NULL; bs = bs->next)
> - {
> - decref_counted_command_line (&bs->commands);
> - bs->commands_left = NULL;
> - if (bs->old_val != NULL)
> - {
> - value_free (bs->old_val);
> - bs->old_val = NULL;
> - }
> - }
> -}
> -
> /* Called when a command is about to proceed the inferior. */
>
> static void
> --- a/gdb/breakpoint.h
> +++ b/gdb/breakpoint.h
> @@ -895,9 +895,6 @@ extern int bpstat_num (bpstat *, int *);
> command loop). */
> extern void bpstat_do_actions (void);
>
> -/* Modify BS so that the actions will not be performed. */
> -extern void bpstat_clear_actions (bpstat);
> -
> /* Implementation: */
>
> /* Values used to tell the printing routine how to behave for this
> --- a/gdb/exceptions.c
> +++ b/gdb/exceptions.c
> @@ -207,22 +207,9 @@ exceptions_state_mc_action_iter_1 (void)
> void
> throw_exception (struct gdb_exception exception)
> {
> - struct thread_info *tp = NULL;
> -
> quit_flag = 0;
> immediate_quit = 0;
>
> - if (!ptid_equal (inferior_ptid, null_ptid))
> - tp = find_thread_ptid (inferior_ptid);
> -
> - /* Perhaps it would be cleaner to do this via the cleanup chain (not sure
> - I can think of a reason why that is vital, though). */
> - if (tp != NULL)
> - {
> - /* Clear queued breakpoint commands. */
> - bpstat_clear_actions (tp->control.stop_bpstat);
> - }
> -
> do_cleanups (ALL_CLEANUPS);
>
> /* Jump to the containing catch_errors() call, communicating REASON
>
--
Pedro Alves
next prev parent reply other threads:[~2011-08-08 15:44 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-05 20:14 Jan Kratochvil
2011-08-08 15:44 ` Pedro Alves [this message]
2011-08-18 15:34 ` Jan Kratochvil
2011-08-18 16:42 ` Pedro Alves
2011-08-18 19:05 ` [patch] Code cleanup: Remove commands_left [Do not bpstat_clear_actions on throw_exception] Jan Kratochvil
2011-08-21 14:34 ` Jan Kratochvil
2011-08-22 14:52 ` [patch 1/2] Code reshuffle for patch 2/2 [Re: [patch] Do " Jan Kratochvil
2011-08-26 9:29 ` Jan Kratochvil
2011-08-26 12:07 ` 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=201108081644.08465.pedro@codesourcery.com \
--to=pedro@codesourcery.com \
--cc=gdb-patches@sourceware.org \
--cc=jan.kratochvil@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