sim-reason.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /* Generic simulator stop_reason.
  2. Copyright (C) 1997-2015 Free Software Foundation, Inc.
  3. Contributed by Cygnus Support.
  4. This file is part of GDB, the GNU debugger.
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 3 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  15. #include "sim-main.h"
  16. #include "sim-assert.h"
  17. /* Generic implementation of sim_stop_reason */
  18. void
  19. sim_stop_reason (SIM_DESC sd, enum sim_stop *reason, int *sigrc)
  20. {
  21. sim_engine *engine = NULL;
  22. SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER);
  23. engine = STATE_ENGINE (sd);
  24. *reason = engine->reason;
  25. switch (*reason)
  26. {
  27. case sim_exited :
  28. *sigrc = engine->sigrc;
  29. break;
  30. case sim_stopped :
  31. case sim_signalled :
  32. *sigrc = sim_signal_to_gdb_signal (sd, engine->sigrc);
  33. break;
  34. default :
  35. abort ();
  36. }
  37. }