]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/sentinel-frame.c
2003-01-27 Andrew Cagney <ac131313@redhat.com>
[thirdparty/binutils-gdb.git] / gdb / sentinel-frame.c
1 /* Code dealing with register stack frames, for GDB, the GNU debugger.
2
3 Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
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
21 Foundation, Inc., 59 Temple Place - Suite 330,
22 Boston, MA 02111-1307, USA. */
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
31 struct frame_unwind_cache
32 {
33 struct regcache *regcache;
34 };
35
36 void *
37 sentinel_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
47 void
48 sentinel_frame_register_unwind (struct frame_info *frame,
49 void **unwind_cache,
50 int regnum, int *optimized,
51 enum lval_type *lvalp, CORE_ADDR *addrp,
52 int *realnum, void *bufferp)
53 {
54 struct frame_unwind_cache *cache = *unwind_cache;
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;
59 *addrp = REGISTER_BYTE (regnum);
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
73 CORE_ADDR
74 sentinel_frame_pc_unwind (struct frame_info *frame,
75 void **cache)
76 {
77 /* FIXME: cagney/2003-01-08: This should be using a per-architecture
78 method that doesn't suffer from DECR_PC_AFTER_BREAK problems.
79 Such a method would take unwind_cache, regcache and stop reason
80 parameters. */
81 return read_pc ();
82 }
83
84 void
85 sentinel_frame_id_unwind (struct frame_info *frame,
86 void **cache,
87 struct frame_id *id)
88 {
89 /* FIXME: cagney/2003-01-08: This should be using a per-architecture
90 method that doesn't suffer from DECR_PC_AFTER_BREAK problems.
91 Such a method would take unwind_cache, regcache and stop reason
92 parameters. */
93 id->base = read_fp ();
94 id->pc = read_pc ();
95 }
96
97 static void
98 sentinel_frame_pop (struct frame_info *frame,
99 void **cache,
100 struct regcache *regcache)
101 {
102 internal_error (__FILE__, __LINE__, "Function sentinal_frame_pop called");
103 }
104
105 const struct frame_unwind sentinel_frame_unwinder =
106 {
107 sentinel_frame_pop,
108 sentinel_frame_pc_unwind,
109 sentinel_frame_id_unwind,
110 sentinel_frame_register_unwind
111 };
112
113 const struct frame_unwind *const sentinel_frame_unwind = &sentinel_frame_unwinder;