[gdb/tdep] Simplify amd64_windows_store_arg_in_reg
[binutils-gdb.git] / gdb / sentinel-frame.c
blob4eaeae0d254f730397d13a077369cba81d684989
1 /* Code dealing with register stack frames, for GDB, the GNU debugger.
3 Copyright (C) 1986-2024 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21 #include "regcache.h"
22 #include "sentinel-frame.h"
23 #include "inferior.h"
24 #include "frame-unwind.h"
26 struct frame_unwind_cache
28 struct regcache *regcache;
31 void *
32 sentinel_frame_cache (struct regcache *regcache)
34 struct frame_unwind_cache *cache =
35 FRAME_OBSTACK_ZALLOC (struct frame_unwind_cache);
37 cache->regcache = regcache;
38 return cache;
41 /* Here the register value is taken direct from the register cache. */
43 static struct value *
44 sentinel_frame_prev_register (const frame_info_ptr &this_frame,
45 void **this_prologue_cache,
46 int regnum)
48 struct frame_unwind_cache *cache
49 = (struct frame_unwind_cache *) *this_prologue_cache;
50 struct value *value;
52 frame_id this_frame_id = get_frame_id (this_frame);
53 gdb_assert (is_sentinel_frame_id (this_frame_id));
55 value = cache->regcache->cooked_read_value (regnum);
57 return value;
60 static void
61 sentinel_frame_this_id (const frame_info_ptr &this_frame,
62 void **this_prologue_cache,
63 struct frame_id *this_id)
65 /* The sentinel frame is used as a starting point for creating the
66 previous (inner most) frame. That frame's THIS_ID method will be
67 called to determine the inner most frame's ID. Not this one. */
68 internal_error (_("sentinel_frame_this_id called"));
71 static struct gdbarch *
72 sentinel_frame_prev_arch (const frame_info_ptr &this_frame,
73 void **this_prologue_cache)
75 struct frame_unwind_cache *cache
76 = (struct frame_unwind_cache *) *this_prologue_cache;
78 return cache->regcache->arch ();
81 const struct frame_unwind sentinel_frame_unwind =
83 "sentinel",
84 SENTINEL_FRAME,
85 default_frame_unwind_stop_reason,
86 sentinel_frame_this_id,
87 sentinel_frame_prev_register,
88 NULL,
89 NULL,
90 NULL,
91 sentinel_frame_prev_arch,