[PATCHv6,01/10] gdb: create_breakpoint: add asserts and additional comments

Message ID b110130c716f5f4b4f8acb07afdb2529fffc0186.1701513409.git.aburgess@redhat.com
State New
Headers
Series [PATCHv6,01/10] gdb: create_breakpoint: add asserts and additional comments |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Testing passed

Commit Message

Andrew Burgess Dec. 2, 2023, 10:42 a.m. UTC
  This commit extends the asserts on create_breakpoint (in the header
file), and adds some additional assertions into the definition.

The new assert confirms that when the thread and inferior information
is going to be parsed from the extra_string, then the thread and
inferior arguments should be -1.  That is, the caller of
create_breakpoint should not try to create a thread/inferior specific
breakpoint by *both* specifying thread/inferior *and* asking to parse
the extra_string, it's one or the other.

There should be no user visible changes after this commit.
---
 gdb/breakpoint.c |  6 ++++++
 gdb/breakpoint.h | 16 ++++++++++++++++
 2 files changed, 22 insertions(+)
  

Comments

Tankut Baris Aktemur Dec. 4, 2023, 7:21 p.m. UTC | #1
On Saturday, December 2, 2023 11:42 AM, Andrew Burgess wrote:
> This commit extends the asserts on create_breakpoint (in the header
> file), and adds some additional assertions into the definition.
> 
> The new assert confirms that when the thread and inferior information
> is going to be parsed from the extra_string, then the thread and
> inferior arguments should be -1.  That is, the caller of
> create_breakpoint should not try to create a thread/inferior specific
> breakpoint by *both* specifying thread/inferior *and* asking to parse
> the extra_string, it's one or the other.
> 
> There should be no user visible changes after this commit.
> ---
>  gdb/breakpoint.c |  6 ++++++
>  gdb/breakpoint.h | 16 ++++++++++++++++
>  2 files changed, 22 insertions(+)
> 
> diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
> index 699919e32b3..dd415ff42f0 100644
> --- a/gdb/breakpoint.c
> +++ b/gdb/breakpoint.c
> @@ -9228,6 +9228,12 @@ create_breakpoint (struct gdbarch *gdbarch,
>    gdb_assert (inferior == -1 || inferior > 0);
>    gdb_assert (thread == -1 || inferior == -1);
> 
> +  /* If PARSE_EXTRA is true then the thread and inferior details will be
> +     parsed from  the EXTRA_STRING, the THREAD and INFERIOR arguments
                   ^^^
Redundant space.

-Baris


Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva  
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
  

Patch

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 699919e32b3..dd415ff42f0 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -9228,6 +9228,12 @@  create_breakpoint (struct gdbarch *gdbarch,
   gdb_assert (inferior == -1 || inferior > 0);
   gdb_assert (thread == -1 || inferior == -1);
 
+  /* If PARSE_EXTRA is true then the thread and inferior details will be
+     parsed from  the EXTRA_STRING, the THREAD and INFERIOR arguments
+     should be -1.  */
+  gdb_assert (!parse_extra || thread == -1);
+  gdb_assert (!parse_extra || inferior == -1);
+
   gdb_assert (ops != NULL);
 
   /* If extra_string isn't useful, set it to NULL.  */
diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
index feb798224c0..4abf6d0762c 100644
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
@@ -1600,6 +1600,22 @@  enum breakpoint_create_flags
    the FORCE_CONDITION parameter is ignored and the corresponding argument
    is parsed from EXTRA_STRING.
 
+   The THREAD should be a global thread number, the created breakpoint will
+   only apply for that thread.  If the breakpoint should apply for all
+   threads then pass -1.  However, if PARSE_EXTRA is non-zero then the
+   THREAD parameter is ignored and an optional thread number will be parsed
+   from EXTRA_STRING.
+
+   The INFERIOR should be a global inferior number, the created breakpoint
+   will only apply for that inferior.  If the breakpoint should apply for
+   all inferiors then pass -1.  However, if PARSE_EXTRA is non-zero then
+   the INFERIOR parameter is ignored and an optional inferior number will
+   be parsed from EXTRA_STRING.
+
+   At most one of THREAD and INFERIOR should be set to a value other than
+   -1; breakpoints can be thread specific, or inferior specific, but not
+   both.
+
    If INTERNAL is non-zero, the breakpoint number will be allocated
    from the internal breakpoint count.