GDB (API)
/home/stan/gdb/src/gdb/sentinel-frame.c
Go to the documentation of this file.
00001 /* Code dealing with register stack frames, for GDB, the GNU debugger.
00002 
00003    Copyright (C) 1986-2013 Free Software Foundation, Inc.
00004 
00005    This file is part of GDB.
00006 
00007    This program is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU General Public License as published by
00009    the Free Software Foundation; either version 3 of the License, or
00010    (at your option) any later version.
00011 
00012    This program is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015    GNU General Public License for more details.
00016 
00017    You should have received a copy of the GNU General Public License
00018    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
00019 
00020 
00021 #include "defs.h"
00022 #include "regcache.h"
00023 #include "sentinel-frame.h"
00024 #include "inferior.h"
00025 #include "frame-unwind.h"
00026 
00027 struct frame_unwind_cache
00028 {
00029   struct regcache *regcache;
00030 };
00031 
00032 void *
00033 sentinel_frame_cache (struct regcache *regcache)
00034 {
00035   struct frame_unwind_cache *cache = 
00036     FRAME_OBSTACK_ZALLOC (struct frame_unwind_cache);
00037 
00038   cache->regcache = regcache;
00039   return cache;
00040 }
00041 
00042 /* Here the register value is taken direct from the register cache.  */
00043 
00044 static struct value *
00045 sentinel_frame_prev_register (struct frame_info *this_frame,
00046                               void **this_prologue_cache,
00047                               int regnum)
00048 {
00049   struct frame_unwind_cache *cache = *this_prologue_cache;
00050   struct value *value;
00051 
00052   value = regcache_cooked_read_value (cache->regcache, regnum);
00053   VALUE_FRAME_ID (value) = get_frame_id (this_frame);
00054 
00055   return value;
00056 }
00057 
00058 static void
00059 sentinel_frame_this_id (struct frame_info *this_frame,
00060                         void **this_prologue_cache,
00061                         struct frame_id *this_id)
00062 {
00063   /* The sentinel frame is used as a starting point for creating the
00064      previous (inner most) frame.  That frame's THIS_ID method will be
00065      called to determine the inner most frame's ID.  Not this one.  */
00066   internal_error (__FILE__, __LINE__, _("sentinel_frame_this_id called"));
00067 }
00068 
00069 static struct gdbarch *
00070 sentinel_frame_prev_arch (struct frame_info *this_frame,
00071                           void **this_prologue_cache)
00072 {
00073   struct frame_unwind_cache *cache = *this_prologue_cache;
00074 
00075   return get_regcache_arch (cache->regcache);
00076 }
00077 
00078 const struct frame_unwind sentinel_frame_unwind =
00079 {
00080   SENTINEL_FRAME,
00081   default_frame_unwind_stop_reason,
00082   sentinel_frame_this_id,
00083   sentinel_frame_prev_register,
00084   NULL,
00085   NULL,
00086   NULL,
00087   sentinel_frame_prev_arch,
00088 };
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines