[PATCH v4 23/44] gdb: allow switching to an inferior without threads
Markus Metzger <[email protected]>
| Newsgroups | gmane.comp.gdb.patches |
|---|---|
| Message-ID | <[email protected]> |
GPU inferiors may temporarily have no threads when no work is dispatched
to that GPU. We still want to allow switching to such inferiors and
resuming them in all-stop mode (subsequent patch).
Also refactor the code a bit to split switching and notifying based on the
(potentially new) state.
---
gdb/inferior.c | 36 ++++++++++++++++--------------------
1 file changed, 16 insertions(+), 20 deletions(-)
diff --git a/gdb/inferior.c b/gdb/inferior.c
index cc7d1cc4f94..b0112d4885c 100644
--- a/gdb/inferior.c
+++ b/gdb/inferior.c
@@ -767,29 +767,25 @@ inferior_command (const char *args, int from_tty)
if (inf == NULL)
error (_("Inferior ID %d not known."), num);
- if (inf->pid != 0)
+ if (inf->pid == 0)
+ switch_to_inferior_no_thread (inf);
+ else if (inf != current_inferior ())
{
- if (inf != current_inferior ())
- {
- thread_info *tp = any_thread_of_inferior (inf);
- if (tp == NULL)
- error (_("Inferior has no threads."));
-
- switch_to_thread (tp);
- }
-
- notify_user_selected_context_changed
- (USER_SELECTED_INFERIOR
- | USER_SELECTED_THREAD
- | USER_SELECTED_FRAME);
+ thread_info *tp = any_thread_of_inferior (inf);
+ if (tp == nullptr)
+ switch_to_inferior_no_thread (inf);
+ else
+ switch_to_thread (tp);
}
- else
- {
- switch_to_inferior_no_thread (inf);
- notify_user_selected_context_changed
- (USER_SELECTED_INFERIOR);
- }
+ if (inferior_ptid == null_ptid)
+ notify_user_selected_context_changed
+ (USER_SELECTED_INFERIOR);
+ else
+ notify_user_selected_context_changed
+ (USER_SELECTED_INFERIOR
+ | USER_SELECTED_THREAD
+ | USER_SELECTED_FRAME);
/* Switching current inferior may have made one of the inferiors
prunable, so prune it. */
--
2.43.0
________________________________________
Intel Deutschland GmbH
Registered Address: Dornacher Strasse 1, 85622 Feldkirchen, Germany
Tel: +49 (89) 99143-0
www.intel.de
Managing Directors: Candice Moore, Jeffrey Schneiderman, Ramachandran Sitaraman
Chairperson of the Supervisory Board: Sonja Pierer
Registered Seat: Munich Commercial Register B: Amtsgericht Munich HRB 186928
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.