14e98e3e1Schristos /* Generic simulator stop_reason. 2*88241920Schristos Copyright (C) 1997-2024 Free Software Foundation, Inc. 34e98e3e1Schristos Contributed by Cygnus Support. 44e98e3e1Schristos 54e98e3e1Schristos This file is part of GDB, the GNU debugger. 64e98e3e1Schristos 74e98e3e1Schristos This program is free software; you can redistribute it and/or modify 84e98e3e1Schristos it under the terms of the GNU General Public License as published by 94e98e3e1Schristos the Free Software Foundation; either version 3 of the License, or 104e98e3e1Schristos (at your option) any later version. 114e98e3e1Schristos 124e98e3e1Schristos This program is distributed in the hope that it will be useful, 134e98e3e1Schristos but WITHOUT ANY WARRANTY; without even the implied warranty of 144e98e3e1Schristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 154e98e3e1Schristos GNU General Public License for more details. 164e98e3e1Schristos 174e98e3e1Schristos You should have received a copy of the GNU General Public License 184e98e3e1Schristos along with this program. If not, see <http://www.gnu.org/licenses/>. */ 194e98e3e1Schristos 204b169a6bSchristos /* This must come before any other includes. */ 214b169a6bSchristos #include "defs.h" 224e98e3e1Schristos 238dffb485Schristos #include <stdlib.h> 248dffb485Schristos 254b169a6bSchristos #include "sim-main.h" 264b169a6bSchristos #include "sim-assert.h" 274b169a6bSchristos #include "sim-signal.h" 284b169a6bSchristos 294e98e3e1Schristos /* Generic implementation of sim_stop_reason */ 304e98e3e1Schristos 314e98e3e1Schristos void 324e98e3e1Schristos sim_stop_reason (SIM_DESC sd, enum sim_stop *reason, int *sigrc) 334e98e3e1Schristos { 344e98e3e1Schristos sim_engine *engine = NULL; 354e98e3e1Schristos SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER); 364e98e3e1Schristos engine = STATE_ENGINE (sd); 374e98e3e1Schristos *reason = engine->reason; 384e98e3e1Schristos switch (*reason) 394e98e3e1Schristos { 404e98e3e1Schristos case sim_exited : 414e98e3e1Schristos *sigrc = engine->sigrc; 424e98e3e1Schristos break; 434e98e3e1Schristos case sim_stopped : 444e98e3e1Schristos case sim_signalled : 45a2e2270fSchristos *sigrc = sim_signal_to_gdb_signal (sd, engine->sigrc); 464e98e3e1Schristos break; 474e98e3e1Schristos default : 484e98e3e1Schristos abort (); 494e98e3e1Schristos } 504e98e3e1Schristos } 51