public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Andrew Burgess <andrew.burgess@embecosm.com>
To: Natalia Saiapova <natalia.saiapova@intel.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH v2 1/6] gdb: add in_cond_eval field to thread_control_state struct.
Date: Tue, 2 Mar 2021 10:43:27 +0000	[thread overview]
Message-ID: <20210302104327.GO265215@embecosm.com> (raw)
In-Reply-To: <20201009112719.629-2-natalia.saiapova@intel.com>

* Natalia Saiapova via Gdb-patches <gdb-patches@sourceware.org> [2020-10-09 13:27:13 +0200]:

> This patch adds a new field to thread_control_state struct, which
> is set to true when the thread is evaluating a breakpoint condition,
> and false otherwise.
> 
> gdb/ChangeLog:
> 2020-08-27  Natalia Saiapova  <natalia.saiapova@intel.com>
> 	    Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
> 
> 	* breakpoint.c (bpstat_check_breakpoint_conditions): Set/unset
> 	thread->control.in_cond_eval.
> 	* gdbthread.h (thread_control_state) <in_cond_eval>: New boolean field.
> 
> Co-authored-by: Natalia Saiapova <natalia.saiapova@intel.com>
> Co-authored-by: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
> 
> Signed-off-by: Natalia Saiapova <natalia.saiapova@intel.com>
> ---
>  gdb/breakpoint.c | 3 +++
>  gdb/gdbthread.h  | 3 +++
>  2 files changed, 6 insertions(+)
> 
> diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
> index 296b08c0afc..77f927dc645 100644
> --- a/gdb/breakpoint.c
> +++ b/gdb/breakpoint.c
> @@ -5209,10 +5209,13 @@ bpstat_check_breakpoint_conditions (bpstat bs, thread_info *thread)
>  	{
>  	  try
>  	    {
> +	      thread->control.in_cond_eval = true;
>  	      condition_result = breakpoint_cond_eval (cond);
> +	      thread->control.in_cond_eval = false;
>  	    }
>  	  catch (const gdb_exception &ex)
>  	    {
> +	      thread->control.in_cond_eval = false;
>  	      exception_fprintf (gdb_stderr, ex,
>  				 "Error in testing breakpoint condition:\n");
>  	    }

Instead of these three writes, would you consider:

	  try
	    {
	      scoped_restore save_in_cond_eval
		= make_scoped_restore (&thread->control.in_cond_eval, true);

	      condition_result = breakpoint_cond_eval (cond);
	    }
	  catch (const gdb_exception &ex)
	    {
	      exception_fprintf (gdb_stderr, ex,
				 "Error in testing breakpoint condition:\n");
	    }

This should be identical in functionality, but seems more inline with
GDB style, using RAII to handle restoring.

Thanks,
Andrew



> diff --git a/gdb/gdbthread.h b/gdb/gdbthread.h
> index ab5771fdb47..9e93587f221 100644
> --- a/gdb/gdbthread.h
> +++ b/gdb/gdbthread.h
> @@ -158,6 +158,9 @@ struct thread_control_state
>       command.  This is used to decide whether "set scheduler-locking
>       step" behaves like "on" or "off".  */
>    int stepping_command = 0;
> +
> +  /* True if the thread is evaluating a BP condition.  */
> +  bool in_cond_eval = false;
>  };
>  
>  /* Inferior thread specific part of `struct infcall_suspend_state'.  */
> -- 
> 2.17.1
> 
> Intel Deutschland GmbH
> Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
> Tel: +49 89 99 8853-0, www.intel.de
> Managing Directors: Christin Eisenschmid, Gary Kershaw
> Chairperson of the Supervisory Board: Nicole Lau
> Registered Office: Munich
> Commercial Register: Amtsgericht Muenchen HRB 186928
> 

  reply	other threads:[~2021-03-02 10:43 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20200831123519.16232-1-natalia.saiapova () intel ! com>
2020-10-09 11:27 ` [PATCH v2 0/6] Fix inferior calls from breakpoint condition Natalia Saiapova
2020-10-09 11:27   ` [PATCH v2 1/6] gdb: add in_cond_eval field to thread_control_state struct Natalia Saiapova
2021-03-02 10:43     ` Andrew Burgess [this message]
2020-10-09 11:27   ` [PATCH v2 2/6] gdb/infrun: in condition evaluation resume only current thread Natalia Saiapova
2021-03-02 11:15     ` Andrew Burgess
2020-10-09 11:27   ` [PATCH v2 3/6] gdb/infcall: in condition evaluation register target back after infcall Natalia Saiapova
2020-10-19  0:53     ` Kevin Buettner
2021-03-02 11:26     ` Andrew Burgess
2020-10-09 11:27   ` [PATCH v2 4/6] gdb/infrun: in condition evaluation wait only for the current inferior Natalia Saiapova
2020-10-19  1:44     ` Kevin Buettner
2020-10-26 12:11       ` Saiapova, Natalia
2021-03-02 12:17         ` Andrew Burgess
2020-10-09 11:27   ` [PATCH v2 5/6] gdb/infrun: in condition evaluation do not stop all threads Natalia Saiapova
2020-10-09 11:27   ` [PATCH v2 6/6] gdb/testsuite: add tests for inferior calls in breakpoint conditions Natalia Saiapova
2020-10-12  0:49   ` [PATCH v2 0/6] Fix inferior calls from breakpoint condition Kevin Buettner

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=20210302104327.GO265215@embecosm.com \
    --to=andrew.burgess@embecosm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=natalia.saiapova@intel.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).