gdb/sentinel-frame.c - gdb

Global variables defined

Data types defined

Functions defined

Source code

  1. /* Code dealing with register stack frames, for GDB, the GNU debugger.

  2.    Copyright (C) 1986-2015 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 = *this_prologue_cache;
  38.   struct value *value;

  39.   value = regcache_cooked_read_value (cache->regcache, regnum);
  40.   VALUE_FRAME_ID (value) = get_frame_id (this_frame);

  41.   return value;
  42. }

  43. static void
  44. sentinel_frame_this_id (struct frame_info *this_frame,
  45.                         void **this_prologue_cache,
  46.                         struct frame_id *this_id)
  47. {
  48.   /* The sentinel frame is used as a starting point for creating the
  49.      previous (inner most) frame.  That frame's THIS_ID method will be
  50.      called to determine the inner most frame's ID.  Not this one.  */
  51.   internal_error (__FILE__, __LINE__, _("sentinel_frame_this_id called"));
  52. }

  53. static struct gdbarch *
  54. sentinel_frame_prev_arch (struct frame_info *this_frame,
  55.                           void **this_prologue_cache)
  56. {
  57.   struct frame_unwind_cache *cache = *this_prologue_cache;

  58.   return get_regcache_arch (cache->regcache);
  59. }

  60. const struct frame_unwind sentinel_frame_unwind =
  61. {
  62.   SENTINEL_FRAME,
  63.   default_frame_unwind_stop_reason,
  64.   sentinel_frame_this_id,
  65.   sentinel_frame_prev_register,
  66.   NULL,
  67.   NULL,
  68.   NULL,
  69.   sentinel_frame_prev_arch,
  70. };