]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: create_breakpoint: add asserts and additional comments
authorAndrew Burgess <aburgess@redhat.com>
Wed, 15 Mar 2023 16:06:30 +0000 (16:06 +0000)
committerAndrew Burgess <aburgess@redhat.com>
Sun, 31 Mar 2024 10:12:35 +0000 (11:12 +0100)
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
gdb/breakpoint.h

index 053d17df03ebd0d7a630164ec73dca79217d40c6..0da666d6f728596f6c15dd764c0787f31ba1f634 100644 (file)
@@ -9220,6 +9220,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.  */
index 226e4d06993e6b1c3f15e1ffa2158383abd3f5de..2e2fe1d32e5cd12e2337bd41590ccc2c7b281e07 100644 (file)
@@ -1610,6 +1610,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.