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