Commit | Line | Data |
---|---|---|
a94dd1fd AC |
1 | /* Code dealing with register stack frames, for GDB, the GNU debugger. |
2 | ||
6aba47ca | 3 | Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, |
9b254dd1 | 4 | 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2007, 2008 |
6aba47ca | 5 | Free Software Foundation, Inc. |
a94dd1fd AC |
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 | |
a9762ec7 | 11 | the Free Software Foundation; either version 3 of the License, or |
a94dd1fd AC |
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 | |
a9762ec7 | 20 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
a94dd1fd AC |
21 | |
22 | ||
23 | #include "defs.h" | |
24 | #include "regcache.h" | |
25 | #include "sentinel-frame.h" | |
26 | #include "inferior.h" | |
27 | #include "frame-unwind.h" | |
28 | ||
29 | struct frame_unwind_cache | |
30 | { | |
31 | struct regcache *regcache; | |
32 | }; | |
33 | ||
34 | void * | |
35 | sentinel_frame_cache (struct regcache *regcache) | |
36 | { | |
37 | struct frame_unwind_cache *cache = | |
38 | FRAME_OBSTACK_ZALLOC (struct frame_unwind_cache); | |
39 | cache->regcache = regcache; | |
40 | return cache; | |
41 | } | |
42 | ||
43 | /* Here the register value is taken direct from the register cache. */ | |
44 | ||
b9362cc7 | 45 | static void |
6dc42492 AC |
46 | sentinel_frame_prev_register (struct frame_info *next_frame, |
47 | void **this_prologue_cache, | |
48 | int regnum, int *optimized, | |
49 | enum lval_type *lvalp, CORE_ADDR *addrp, | |
10c42a71 | 50 | int *realnum, gdb_byte *bufferp) |
a94dd1fd | 51 | { |
6dc42492 | 52 | struct frame_unwind_cache *cache = *this_prologue_cache; |
a94dd1fd AC |
53 | /* Describe the register's location. A reg-frame maps all registers |
54 | onto the corresponding hardware register. */ | |
55 | *optimized = 0; | |
56 | *lvalp = lval_register; | |
caaa79ad | 57 | *addrp = 0; |
a94dd1fd AC |
58 | *realnum = regnum; |
59 | ||
60 | /* If needed, find and return the value of the register. */ | |
61 | if (bufferp != NULL) | |
62 | { | |
63 | /* Return the actual value. */ | |
64 | /* Use the regcache_cooked_read() method so that it, on the fly, | |
65 | constructs either a raw or pseudo register from the raw | |
66 | register cache. */ | |
67 | regcache_cooked_read (cache->regcache, regnum, bufferp); | |
68 | } | |
69 | } | |
70 | ||
b9362cc7 | 71 | static void |
6dc42492 AC |
72 | sentinel_frame_this_id (struct frame_info *next_frame, |
73 | void **this_prologue_cache, | |
74 | struct frame_id *this_id) | |
a94dd1fd | 75 | { |
6dc42492 AC |
76 | /* The sentinel frame is used as a starting point for creating the |
77 | previous (inner most) frame. That frame's THIS_ID method will be | |
78 | called to determine the inner most frame's ID. Not this one. */ | |
e2e0b3e5 | 79 | internal_error (__FILE__, __LINE__, _("sentinel_frame_this_id called")); |
a94dd1fd AC |
80 | } |
81 | ||
cbafadeb AC |
82 | static CORE_ADDR |
83 | sentinel_frame_prev_pc (struct frame_info *next_frame, | |
84 | void **this_prologue_cache) | |
85 | { | |
86 | struct gdbarch *gdbarch = get_frame_arch (next_frame); | |
87 | return gdbarch_unwind_pc (gdbarch, next_frame); | |
88 | } | |
89 | ||
a94dd1fd AC |
90 | const struct frame_unwind sentinel_frame_unwinder = |
91 | { | |
0e100dab | 92 | SENTINEL_FRAME, |
6dc42492 | 93 | sentinel_frame_this_id, |
cbafadeb AC |
94 | sentinel_frame_prev_register, |
95 | NULL, /* unwind_data */ | |
96 | NULL, /* sniffer */ | |
97 | sentinel_frame_prev_pc, | |
a94dd1fd AC |
98 | }; |
99 | ||
100 | const struct frame_unwind *const sentinel_frame_unwind = &sentinel_frame_unwinder; |