1*6881a400Schristos /* Copyright (C) 2009-2023 Free Software Foundation, Inc. 27f2ac410Schristos 37f2ac410Schristos This file is part of GDB. 47f2ac410Schristos 57f2ac410Schristos This program is free software; you can redistribute it and/or modify 67f2ac410Schristos it under the terms of the GNU General Public License as published by 77f2ac410Schristos the Free Software Foundation; either version 3 of the License, or 87f2ac410Schristos (at your option) any later version. 97f2ac410Schristos 107f2ac410Schristos This program is distributed in the hope that it will be useful, 117f2ac410Schristos but WITHOUT ANY WARRANTY; without even the implied warranty of 127f2ac410Schristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 137f2ac410Schristos GNU General Public License for more details. 147f2ac410Schristos 157f2ac410Schristos You should have received a copy of the GNU General Public License 167f2ac410Schristos along with this program. If not, see <http://www.gnu.org/licenses/>. */ 177f2ac410Schristos 187f2ac410Schristos #include "defs.h" 197f2ac410Schristos #include "progspace-and-thread.h" 207f2ac410Schristos #include "inferior.h" 217f2ac410Schristos 227f2ac410Schristos /* See progspace-and-thread.h */ 237f2ac410Schristos 247f2ac410Schristos void 257f2ac410Schristos switch_to_program_space_and_thread (program_space *pspace) 267f2ac410Schristos { 277f2ac410Schristos inferior *inf = find_inferior_for_program_space (pspace); 287d62b00eSchristos gdb_assert (inf != nullptr); 297f2ac410Schristos 307d62b00eSchristos if (inf->pid != 0) 317f2ac410Schristos { 327f2ac410Schristos thread_info *tp = any_live_thread_of_inferior (inf); 337f2ac410Schristos 347f2ac410Schristos if (tp != NULL) 357f2ac410Schristos { 367f2ac410Schristos switch_to_thread (tp); 377f2ac410Schristos /* Switching thread switches pspace implicitly. We're 387f2ac410Schristos done. */ 397f2ac410Schristos return; 407f2ac410Schristos } 417f2ac410Schristos } 427f2ac410Schristos 437d62b00eSchristos switch_to_inferior_no_thread (inf); 447f2ac410Schristos } 45