sentinel-frame.c 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /* Code dealing with register stack frames, for GDB, the GNU debugger.
  2. Copyright (C) 1986-2022 Free Software Foundation, Inc.
  3. This file is part of GDB.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  14. #include "defs.h"
  15. #include "regcache.h"
  16. #include "sentinel-frame.h"
  17. #include "inferior.h"
  18. #include "frame-unwind.h"
  19. struct frame_unwind_cache
  20. {
  21. struct regcache *regcache;
  22. };
  23. void *
  24. sentinel_frame_cache (struct regcache *regcache)
  25. {
  26. struct frame_unwind_cache *cache =
  27. FRAME_OBSTACK_ZALLOC (struct frame_unwind_cache);
  28. cache->regcache = regcache;
  29. return cache;
  30. }
  31. /* Here the register value is taken direct from the register cache. */
  32. static struct value *
  33. sentinel_frame_prev_register (struct frame_info *this_frame,
  34. void **this_prologue_cache,
  35. int regnum)
  36. {
  37. struct frame_unwind_cache *cache
  38. = (struct frame_unwind_cache *) *this_prologue_cache;
  39. struct value *value;
  40. value = cache->regcache->cooked_read_value (regnum);
  41. VALUE_NEXT_FRAME_ID (value) = sentinel_frame_id;
  42. return value;
  43. }
  44. static void
  45. sentinel_frame_this_id (struct frame_info *this_frame,
  46. void **this_prologue_cache,
  47. struct frame_id *this_id)
  48. {
  49. /* The sentinel frame is used as a starting point for creating the
  50. previous (inner most) frame. That frame's THIS_ID method will be
  51. called to determine the inner most frame's ID. Not this one. */
  52. internal_error (__FILE__, __LINE__, _("sentinel_frame_this_id called"));
  53. }
  54. static struct gdbarch *
  55. sentinel_frame_prev_arch (struct frame_info *this_frame,
  56. void **this_prologue_cache)
  57. {
  58. struct frame_unwind_cache *cache
  59. = (struct frame_unwind_cache *) *this_prologue_cache;
  60. return cache->regcache->arch ();
  61. }
  62. const struct frame_unwind sentinel_frame_unwind =
  63. {
  64. "sentinel",
  65. SENTINEL_FRAME,
  66. default_frame_unwind_stop_reason,
  67. sentinel_frame_this_id,
  68. sentinel_frame_prev_register,
  69. NULL,
  70. NULL,
  71. NULL,
  72. sentinel_frame_prev_arch,
  73. };