public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Andrew Burgess <aburgess@redhat.com>
To: gdb-patches@sourceware.org
Cc: Andrew Burgess <aburgess@redhat.com>
Subject: [PATCHv6 01/10] gdb: create_breakpoint: add asserts and additional comments
Date: Mon, 30 Oct 2023 16:11:05 +0000	[thread overview]
Message-ID: <55c5841baa0a64f5b41cf6acbabff62afacc7a14.1698682161.git.aburgess@redhat.com> (raw)
In-Reply-To: <cover.1698682161.git.aburgess@redhat.com>

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 828c99cabc0..bf496f5e222 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -9229,6 +9229,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 e75efc90495..07370b83a24 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.
 
-- 
2.25.4


  reply	other threads:[~2023-10-30 16:11 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <id:cover.1696368409.git.aburgess@redhat.com>
2023-10-30 16:11 ` [PATCHv6 00/10] thread-specific breakpoints in just some inferiors Andrew Burgess
2023-10-30 16:11   ` Andrew Burgess [this message]
2023-10-30 16:11   ` [PATCHv6 02/10] gdb: create_breakpoint: asserts relating to extra_string/parse_extra Andrew Burgess
2023-10-30 16:11   ` [PATCHv6 03/10] gdb: change 'if' to gdb_assert in update_dprintf_command_list Andrew Burgess
2023-10-30 16:11   ` [PATCHv6 04/10] gdb: build dprintf commands just once in code_breakpoint constructor Andrew Burgess
2023-10-30 16:11   ` [PATCHv6 05/10] gdb: don't display inferior list for pending breakpoints Andrew Burgess
2023-10-30 16:11   ` [PATCHv6 06/10] gdb: parse pending breakpoint thread/task immediately Andrew Burgess
2023-10-30 16:11   ` [PATCHv6 07/10] gdb: don't set breakpoint::pspace for in create_breakpoint Andrew Burgess
2023-10-30 16:11   ` [PATCHv6 08/10] gdb: remove breakpoint_re_set_one Andrew Burgess
2023-10-30 16:11   ` [PATCHv6 09/10] gdb: remove tracepoint_probe_create_sals_from_location_spec Andrew Burgess
2023-10-30 16:11   ` [PATCHv6 10/10] gdb: only insert thread-specific breakpoints in the relevant inferior Andrew Burgess
2023-10-03 21:29 [PATCHv5 00/10] thread-specific breakpoints in just some inferiors Andrew Burgess
2023-12-02 10:42 ` [PATCHv6 " Andrew Burgess
2023-12-02 10:42   ` [PATCHv6 01/10] gdb: create_breakpoint: add asserts and additional comments Andrew Burgess
2023-12-04 19:21     ` Aktemur, Tankut Baris

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=55c5841baa0a64f5b41cf6acbabff62afacc7a14.1698682161.git.aburgess@redhat.com \
    --to=aburgess@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /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).