]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Fix MI -break-insert assertion failure (submit separately) (WIP)
authorPedro Alves <pedro@palves.net>
Wed, 9 Apr 2025 13:29:53 +0000 (14:29 +0100)
committerPedro Alves <pedro@palves.net>
Mon, 9 Jun 2025 17:09:18 +0000 (18:09 +0100)
TODO:
  - commit log
  - testcase

This is exposed by some pre-existing test.  Need to check which one it
was.

 (gdb) interpreter-exec mi "222-break-insert -g i100 foo"
 &"../../src/gdb/breakpoint.c:9165: internal-error: find_program_space_for_breakpoint: Assertion `inf != nullptr' failed.\nA problem internal to GDB has been detected,\nfurther debugging may prove unreliable."
 &"\n"
 &"----- Backtrace -----\n"
 &"Backtrace unavailable\n"
 &"---------------------\n"
 ~"../../src/gdb/breakpoint.c:9165: internal-error: find_program_space_for_breakpoint: Assertion `inf != nullptr' failed.\nA problem internal to GDB has been detected,\nfurther debugging may prove unreliable.\nQuit this debugging session? (y or n) "

From here:

 (top-gdb) bt
 #0  internal_error_loc (file=0x555556187e56 "../../src/gdb/breakpoint.c", line=9165, fmt=0x555556187bc8 "%s: Assertion `%s' failed.") at ../../src/gdbsupport/errors.cc:53
 #1  0x0000555555791a55 in find_program_space_for_breakpoint (thread=-1, inferior=100) at ../../src/gdb/breakpoint.c:9165
 #2  0x0000555555791f96 in create_breakpoint (gdbarch=0x5555568db900, locspec=0x5555567e7100, cond_string=0x0, thread=-1, inferior=100, extra_string=0x0, force_condition=false, parse_extra=0, tempflag=0, type_wanted=bp_breakpoint, ignore_count=0, pending_break_support=AUTO_BOOLEAN_FALSE, ops=0x555556642aa0 <code_breakpoint_ops>, from_tty=0, enabled=1, internal=0, flags=0) at ../../src/gdb/breakpoint.c:9275
 #3  0x0000555555bb9d15 in mi_cmd_break_insert_1 (dprintf=0, command=0x5555567e6fd0 "break-insert", argv=0x5555567e7070, argc=3) at ../../src/gdb/mi/mi-cmd-break.c:366
 #4  0x0000555555bb9e15 in mi_cmd_break_insert (command=0x5555567e6fd0 "break-insert", argv=0x5555567e7070, argc=3) at ../../src/gdb/mi/mi-cmd-break.c:383
 ...

Change-Id: Ibde0d4d098bf0b5d7b057e818a77a63c84806a3c

gdb/inferior.c
gdb/inferior.h
gdb/mi/mi-cmd-break.c

index e8a28cd2a0e1a4f76946d4fc9c1abdfab08b5d3e..29d1aee89744ee15b8c930f36db2df0dc6e03d2a 100644 (file)
@@ -397,6 +397,15 @@ find_inferior_id (int num)
   return NULL;
 }
 
+/* See inferior.h.  */
+
+bool
+valid_inferior_id (int num)
+{
+  inferior *inf = find_inferior_id (num);
+  return inf != nullptr;
+}
+
 struct inferior *
 find_inferior_pid (process_stratum_target *targ, int pid)
 {
index 301a78f9ebbb65ae8605c7a18be84fb39ba3d39b..71c7642286f47bab6863a2ff60827d3292a2af91 100644 (file)
@@ -730,6 +730,9 @@ extern struct inferior *find_inferior_ptid (process_stratum_target *targ,
 /* Search function to lookup an inferior by GDB 'num'.  */
 extern struct inferior *find_inferior_id (int num);
 
+/* Return true if inferior NUM exists, false otherwise.  */
+extern bool valid_inferior_id (int num);
+
 /* Find an inferior bound to PSPACE, giving preference to the current
    inferior.  */
 extern struct inferior *
index e4cb2e7d335601a1357baae6c669b93fe89fc363..0e17b45ddfa10feb7134d33e9f4cbd615410071d 100644 (file)
@@ -30,6 +30,7 @@
 #include "linespec.h"
 #include <ctype.h>
 #include "tracepoint.h"
+#include "inferior.h"
 
 enum
   {
@@ -249,6 +250,8 @@ mi_cmd_break_insert_1 (int dprintf, const char *command,
          break;
        case THREAD_GROUP_OPT:
          thread_group = mi_parse_thread_group_id (oarg);
+         if (!valid_inferior_id (thread_group))
+           error (_("Non-existent thread-group id '%d'"), thread_group);
          break;
        case PENDING_OPT:
          pending = 1;