1b725ae77Skettenis /* Code dealing with register stack frames, for GDB, the GNU debugger.
2b725ae77Skettenis
3b725ae77Skettenis Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
4b725ae77Skettenis 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 Free Software
5b725ae77Skettenis Foundation, Inc.
6b725ae77Skettenis
7b725ae77Skettenis This file is part of GDB.
8b725ae77Skettenis
9b725ae77Skettenis This program is free software; you can redistribute it and/or modify
10b725ae77Skettenis it under the terms of the GNU General Public License as published by
11b725ae77Skettenis the Free Software Foundation; either version 2 of the License, or
12b725ae77Skettenis (at your option) any later version.
13b725ae77Skettenis
14b725ae77Skettenis This program is distributed in the hope that it will be useful,
15b725ae77Skettenis but WITHOUT ANY WARRANTY; without even the implied warranty of
16b725ae77Skettenis MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17b725ae77Skettenis GNU General Public License for more details.
18b725ae77Skettenis
19b725ae77Skettenis You should have received a copy of the GNU General Public License
20b725ae77Skettenis along with this program; if not, write to the Free Software
21b725ae77Skettenis Foundation, Inc., 59 Temple Place - Suite 330,
22b725ae77Skettenis Boston, MA 02111-1307, USA. */
23b725ae77Skettenis
24b725ae77Skettenis
25b725ae77Skettenis #include "defs.h"
26b725ae77Skettenis #include "regcache.h"
27b725ae77Skettenis #include "sentinel-frame.h"
28b725ae77Skettenis #include "inferior.h"
29b725ae77Skettenis #include "frame-unwind.h"
30b725ae77Skettenis
31b725ae77Skettenis struct frame_unwind_cache
32b725ae77Skettenis {
33b725ae77Skettenis struct regcache *regcache;
34b725ae77Skettenis };
35b725ae77Skettenis
36b725ae77Skettenis void *
sentinel_frame_cache(struct regcache * regcache)37b725ae77Skettenis sentinel_frame_cache (struct regcache *regcache)
38b725ae77Skettenis {
39b725ae77Skettenis struct frame_unwind_cache *cache =
40b725ae77Skettenis FRAME_OBSTACK_ZALLOC (struct frame_unwind_cache);
41b725ae77Skettenis cache->regcache = regcache;
42b725ae77Skettenis return cache;
43b725ae77Skettenis }
44b725ae77Skettenis
45b725ae77Skettenis /* Here the register value is taken direct from the register cache. */
46b725ae77Skettenis
47b725ae77Skettenis static void
sentinel_frame_prev_register(struct frame_info * next_frame,void ** this_prologue_cache,int regnum,int * optimized,enum lval_type * lvalp,CORE_ADDR * addrp,int * realnum,void * bufferp)48b725ae77Skettenis sentinel_frame_prev_register (struct frame_info *next_frame,
49b725ae77Skettenis void **this_prologue_cache,
50b725ae77Skettenis int regnum, int *optimized,
51b725ae77Skettenis enum lval_type *lvalp, CORE_ADDR *addrp,
52b725ae77Skettenis int *realnum, void *bufferp)
53b725ae77Skettenis {
54b725ae77Skettenis struct frame_unwind_cache *cache = *this_prologue_cache;
55b725ae77Skettenis /* Describe the register's location. A reg-frame maps all registers
56b725ae77Skettenis onto the corresponding hardware register. */
57b725ae77Skettenis *optimized = 0;
58b725ae77Skettenis *lvalp = lval_register;
59b725ae77Skettenis *addrp = register_offset_hack (current_gdbarch, regnum);
60b725ae77Skettenis *realnum = regnum;
61b725ae77Skettenis
62b725ae77Skettenis /* If needed, find and return the value of the register. */
63b725ae77Skettenis if (bufferp != NULL)
64b725ae77Skettenis {
65b725ae77Skettenis /* Return the actual value. */
66b725ae77Skettenis /* Use the regcache_cooked_read() method so that it, on the fly,
67b725ae77Skettenis constructs either a raw or pseudo register from the raw
68b725ae77Skettenis register cache. */
69b725ae77Skettenis regcache_cooked_read (cache->regcache, regnum, bufferp);
70b725ae77Skettenis }
71b725ae77Skettenis }
72b725ae77Skettenis
73b725ae77Skettenis static void
sentinel_frame_this_id(struct frame_info * next_frame,void ** this_prologue_cache,struct frame_id * this_id)74b725ae77Skettenis sentinel_frame_this_id (struct frame_info *next_frame,
75b725ae77Skettenis void **this_prologue_cache,
76b725ae77Skettenis struct frame_id *this_id)
77b725ae77Skettenis {
78b725ae77Skettenis /* The sentinel frame is used as a starting point for creating the
79b725ae77Skettenis previous (inner most) frame. That frame's THIS_ID method will be
80b725ae77Skettenis called to determine the inner most frame's ID. Not this one. */
81b725ae77Skettenis internal_error (__FILE__, __LINE__, "sentinel_frame_this_id called");
82b725ae77Skettenis }
83b725ae77Skettenis
84b725ae77Skettenis const struct frame_unwind sentinel_frame_unwinder =
85b725ae77Skettenis {
86*11efff7fSkettenis SENTINEL_FRAME,
87b725ae77Skettenis sentinel_frame_this_id,
88b725ae77Skettenis sentinel_frame_prev_register
89b725ae77Skettenis };
90b725ae77Skettenis
91b725ae77Skettenis const struct frame_unwind *const sentinel_frame_unwind = &sentinel_frame_unwinder;
92