xref: /dflybsd-src/contrib/gdb-7/gdb/sentinel-frame.c (revision de8e141f24382815c10a4012d209bbbf7abf1112)
15796c8dcSSimon Schubert /* Code dealing with register stack frames, for GDB, the GNU debugger.
25796c8dcSSimon Schubert 
3*ef5ccd6cSJohn Marino    Copyright (C) 1986-2013 Free Software Foundation, Inc.
45796c8dcSSimon Schubert 
55796c8dcSSimon Schubert    This file is part of GDB.
65796c8dcSSimon Schubert 
75796c8dcSSimon Schubert    This program is free software; you can redistribute it and/or modify
85796c8dcSSimon Schubert    it under the terms of the GNU General Public License as published by
95796c8dcSSimon Schubert    the Free Software Foundation; either version 3 of the License, or
105796c8dcSSimon Schubert    (at your option) any later version.
115796c8dcSSimon Schubert 
125796c8dcSSimon Schubert    This program is distributed in the hope that it will be useful,
135796c8dcSSimon Schubert    but WITHOUT ANY WARRANTY; without even the implied warranty of
145796c8dcSSimon Schubert    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
155796c8dcSSimon Schubert    GNU General Public License for more details.
165796c8dcSSimon Schubert 
175796c8dcSSimon Schubert    You should have received a copy of the GNU General Public License
185796c8dcSSimon Schubert    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
195796c8dcSSimon Schubert 
205796c8dcSSimon Schubert 
215796c8dcSSimon Schubert #include "defs.h"
225796c8dcSSimon Schubert #include "regcache.h"
235796c8dcSSimon Schubert #include "sentinel-frame.h"
245796c8dcSSimon Schubert #include "inferior.h"
255796c8dcSSimon Schubert #include "frame-unwind.h"
265796c8dcSSimon Schubert 
275796c8dcSSimon Schubert struct frame_unwind_cache
285796c8dcSSimon Schubert {
295796c8dcSSimon Schubert   struct regcache *regcache;
305796c8dcSSimon Schubert };
315796c8dcSSimon Schubert 
325796c8dcSSimon Schubert void *
sentinel_frame_cache(struct regcache * regcache)335796c8dcSSimon Schubert sentinel_frame_cache (struct regcache *regcache)
345796c8dcSSimon Schubert {
355796c8dcSSimon Schubert   struct frame_unwind_cache *cache =
365796c8dcSSimon Schubert     FRAME_OBSTACK_ZALLOC (struct frame_unwind_cache);
37cf7f2e2dSJohn Marino 
385796c8dcSSimon Schubert   cache->regcache = regcache;
395796c8dcSSimon Schubert   return cache;
405796c8dcSSimon Schubert }
415796c8dcSSimon Schubert 
425796c8dcSSimon Schubert /* Here the register value is taken direct from the register cache.  */
435796c8dcSSimon Schubert 
445796c8dcSSimon Schubert static struct value *
sentinel_frame_prev_register(struct frame_info * this_frame,void ** this_prologue_cache,int regnum)455796c8dcSSimon Schubert sentinel_frame_prev_register (struct frame_info *this_frame,
465796c8dcSSimon Schubert 			      void **this_prologue_cache,
475796c8dcSSimon Schubert 			      int regnum)
485796c8dcSSimon Schubert {
495796c8dcSSimon Schubert   struct frame_unwind_cache *cache = *this_prologue_cache;
505796c8dcSSimon Schubert   struct value *value;
515796c8dcSSimon Schubert 
52a45ae5f8SJohn Marino   value = regcache_cooked_read_value (cache->regcache, regnum);
535796c8dcSSimon Schubert   VALUE_FRAME_ID (value) = get_frame_id (this_frame);
545796c8dcSSimon Schubert 
555796c8dcSSimon Schubert   return value;
565796c8dcSSimon Schubert }
575796c8dcSSimon Schubert 
585796c8dcSSimon Schubert static void
sentinel_frame_this_id(struct frame_info * this_frame,void ** this_prologue_cache,struct frame_id * this_id)595796c8dcSSimon Schubert sentinel_frame_this_id (struct frame_info *this_frame,
605796c8dcSSimon Schubert 			void **this_prologue_cache,
615796c8dcSSimon Schubert 			struct frame_id *this_id)
625796c8dcSSimon Schubert {
635796c8dcSSimon Schubert   /* The sentinel frame is used as a starting point for creating the
645796c8dcSSimon Schubert      previous (inner most) frame.  That frame's THIS_ID method will be
655796c8dcSSimon Schubert      called to determine the inner most frame's ID.  Not this one.  */
665796c8dcSSimon Schubert   internal_error (__FILE__, __LINE__, _("sentinel_frame_this_id called"));
675796c8dcSSimon Schubert }
685796c8dcSSimon Schubert 
695796c8dcSSimon Schubert static struct gdbarch *
sentinel_frame_prev_arch(struct frame_info * this_frame,void ** this_prologue_cache)705796c8dcSSimon Schubert sentinel_frame_prev_arch (struct frame_info *this_frame,
715796c8dcSSimon Schubert 			  void **this_prologue_cache)
725796c8dcSSimon Schubert {
735796c8dcSSimon Schubert   struct frame_unwind_cache *cache = *this_prologue_cache;
74cf7f2e2dSJohn Marino 
755796c8dcSSimon Schubert   return get_regcache_arch (cache->regcache);
765796c8dcSSimon Schubert }
775796c8dcSSimon Schubert 
78c50c785cSJohn Marino const struct frame_unwind sentinel_frame_unwind =
795796c8dcSSimon Schubert {
805796c8dcSSimon Schubert   SENTINEL_FRAME,
81c50c785cSJohn Marino   default_frame_unwind_stop_reason,
825796c8dcSSimon Schubert   sentinel_frame_this_id,
835796c8dcSSimon Schubert   sentinel_frame_prev_register,
845796c8dcSSimon Schubert   NULL,
855796c8dcSSimon Schubert   NULL,
865796c8dcSSimon Schubert   NULL,
875796c8dcSSimon Schubert   sentinel_frame_prev_arch,
885796c8dcSSimon Schubert };
89