From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 759733858410; Fri, 29 Oct 2021 12:54:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 759733858410 From: "simark at simark dot ca" To: gdb-prs@sourceware.org Subject: [Bug gdb/28275] commit_resumed_state assertion failure when killing running inferior and running again Date: Fri, 29 Oct 2021 12:54:15 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: gdb X-Bugzilla-Version: HEAD X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: simark at simark dot ca X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gdb-prs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-prs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Oct 2021 12:54:15 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D28275 --- Comment #3 from Simon Marchi --- Something like this should fix the original issue (when re-running): >>From 0bc259c5c7640fb9bb655b7b279eb0b2ec87c28b Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Fri, 29 Oct 2021 08:36:00 -0400 Subject: [PATCH] gdb: fix commit resumed failed assertion when re-running Change-Id: Ic7ed0524751d0e5524936b2890048cd4a3d92765 --- gdb/infcmd.c | 4 ++-- gdb/target.c | 46 +++++++++++++++++++++------------------------- gdb/target.h | 8 ++++---- 3 files changed, 27 insertions(+), 31 deletions(-) diff --git a/gdb/infcmd.c b/gdb/infcmd.c index 302db421a21f..57726650f155 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -371,7 +371,6 @@ run_command_1 (const char *args, int from_tty, enum run= _how run_how) { const char *exec_file; struct ui_out *uiout =3D current_uiout; - struct target_ops *run_target; int async_exec; dont_repeat (); @@ -403,7 +402,7 @@ run_command_1 (const char *args, int from_tty, enum run= _how run_how) /* Do validation and preparation before possibly changing anything in the inferior. */ - run_target =3D find_run_target (); + process_stratum_target *run_target =3D find_run_target (); prepare_execution_command (run_target, async_exec); @@ -445,6 +444,7 @@ run_command_1 (const char *args, int from_tty, enum run= _how run_how) uiout->flush (); } + run_target->commit_resumed_state =3D false; run_target->create_inferior (exec_file, current_inferior ()->args (), current_inferior ()->environment.envp (), diff --git a/gdb/target.c b/gdb/target.c index 6cff56474873..967551a6ad8e 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -84,7 +84,7 @@ static int default_verify_memory (struct target_ops *self, static void tcomplain (void) ATTRIBUTE_NORETURN; -static struct target_ops *find_default_run_target (const char *); +static process_stratum_target *find_default_run_target (const char *); static int dummy_find_memory_regions (struct target_ops *self, find_memory_region_ftype ignore1, @@ -2880,12 +2880,12 @@ show_auto_connect_native_target (struct ui_file *fi= le, int from_tty, /* A pointer to the target that can respond to "run" or "attach". Native targets are always singletons and instantiated early at GDB startup. */ -static target_ops *the_native_target; +static process_stratum_target *the_native_target; /* See target.h. */ void -set_native_target (target_ops *target) +set_native_target (process_stratum_target *target) { if (the_native_target !=3D NULL) internal_error (__FILE__, __LINE__, @@ -2897,7 +2897,7 @@ set_native_target (target_ops *target) /* See target.h. */ -target_ops * +process_stratum_target * get_native_target () { return the_native_target; @@ -2910,7 +2910,7 @@ get_native_target () If DO_MESG is not NULL, the result is always valid (error() is called for errors); else, return NULL on error. */ -static struct target_ops * +static process_stratum_target * find_default_run_target (const char *do_mesg) { if (auto_connect_native_target && the_native_target !=3D NULL) @@ -2923,17 +2923,15 @@ find_default_run_target (const char *do_mesg) /* See target.h. */ -struct target_ops * -find_attach_target (void) +process_stratum_target * +find_attach_target () { - /* If a target on the current stack can attach, use it. */ - for (target_ops *t =3D current_inferior ()->top_target (); - t !=3D NULL; - t =3D t->beneath ()) - { - if (t->can_attach ()) - return t; - } + /* If the current process stratum target can attach, use it. */ + process_stratum_target *current_proc_target + =3D current_inferior ()->process_target (); + if (current_proc_target !=3D nullptr + && current_proc_target->can_attach ()) + return current_proc_target; /* Otherwise, use the default run target for attaching. */ return find_default_run_target ("attach"); @@ -2941,17 +2939,15 @@ find_attach_target (void) /* See target.h. */ -struct target_ops * -find_run_target (void) +process_stratum_target * +find_run_target () { - /* If a target on the current stack can run, use it. */ - for (target_ops *t =3D current_inferior ()->top_target (); - t !=3D NULL; - t =3D t->beneath ()) - { - if (t->can_create_inferior ()) - return t; - } + /* If the current process stratum target can run, use it. */ + process_stratum_target *current_proc_target + =3D current_inferior ()->process_target (); + if (current_proc_target !=3D nullptr + && current_proc_target->can_run ()) + return current_proc_target; /* Otherwise, use the default run target. */ return find_default_run_target ("run"); diff --git a/gdb/target.h b/gdb/target.h index 92fc1381db2b..5750a7655670 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -1364,11 +1364,11 @@ typedef gdb::ref_ptr target_ops_ref; /* Native target backends call this once at initialization time to inform the core about which is the target that can respond to "run" or "attach". Note: native targets are always singletons. */ -extern void set_native_target (target_ops *target); +extern void set_native_target (process_stratum_target *target); /* Get the registered native target, if there's one. Otherwise return NULL. */ -extern target_ops *get_native_target (); +extern process_stratum_target *get_native_target (); /* Type that manages a target stack. See description of target stacks and strata at the top of the file. */ @@ -1430,13 +1430,13 @@ void target_close (struct target_ops *targ); current stack supports attaching, then it is returned. Otherwise, the default run target is returned. */ -extern struct target_ops *find_attach_target (void); +extern process_stratum_target *find_attach_target (void); /* Find the correct target to use for "run". If a target on the current stack supports creating a new inferior, then it is returned. Otherwise, the default run target is returned. */ -extern struct target_ops *find_run_target (void); +extern process_stratum_target *find_run_target (); /* Some targets don't generate traps when attaching to the inferior, or their target_attach implementation takes care of the waiting. --=20 2.33.1 --=20 You are receiving this mail because: You are on the CC list for the bug.=