GDB (xrefs)
Loading...
Searching...
No Matches
std-regs.c
Go to the documentation of this file.
1/* Builtin frame register, for GDB, the GNU debugger.
2
3 Copyright (C) 2002-2023 Free Software Foundation, Inc.
4
5 Contributed by Red Hat.
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 3 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, see <http://www.gnu.org/licenses/>. */
21
22#include "defs.h"
23#include "user-regs.h"
24#include "frame.h"
25#include "gdbtypes.h"
26#include "value.h"
27#include "gdbarch.h"
28
29static struct value *
31{
32 struct gdbarch *gdbarch = get_frame_arch (frame);
33
35 /* NOTE: cagney/2003-04-24: Since the mere presence of "fp" in the
36 register name table overrides this built-in $fp register, there
37 is no real reason for this gdbarch_deprecated_fp_regnum trickery here.
38 An architecture wanting to implement "$fp" as alias for a raw
39 register can do so by adding "fp" to register name table (mind
40 you, doing this is probably a dangerous thing). */
42 frame);
43 else
44 {
45 struct type *data_ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
46 struct value *val = value::allocate (data_ptr_type);
47 gdb_byte *buf = val->contents_raw ().data ();
48
49 gdbarch_address_to_pointer (gdbarch, data_ptr_type,
50 buf, get_frame_base_address (frame));
51 return val;
52 }
53}
54
55static struct value *
57{
58 struct gdbarch *gdbarch = get_frame_arch (frame);
59
60 if (gdbarch_pc_regnum (gdbarch) >= 0)
62 else
63 {
64 struct type *func_ptr_type = builtin_type (gdbarch)->builtin_func_ptr;
65 struct value *val = value::allocate (func_ptr_type);
66 gdb_byte *buf = val->contents_raw ().data ();
67
68 gdbarch_address_to_pointer (gdbarch, func_ptr_type,
69 buf, get_frame_pc (frame));
70 return val;
71 }
72}
73
74static struct value *
76{
77 struct gdbarch *gdbarch = get_frame_arch (frame);
78
79 if (gdbarch_sp_regnum (gdbarch) >= 0)
81 error (_("Standard register ``$sp'' is not available for this target"));
82}
83
84static struct value *
86{
87 struct gdbarch *gdbarch = get_frame_arch (frame);
88
89 if (gdbarch_ps_regnum (gdbarch) >= 0)
91 error (_("Standard register ``$ps'' is not available for this target"));
92}
93
95void
97{
98 /* Frame based $fp, $pc, $sp and $ps. These only come into play
99 when the target does not define its own version of these
100 registers. */
105}
struct value * value_of_register(int regnum, frame_info_ptr frame)
Definition findvar.c:253
CORE_ADDR get_frame_pc(frame_info_ptr frame)
Definition frame.c:2712
CORE_ADDR get_frame_base_address(frame_info_ptr fi)
Definition frame.c:2887
struct gdbarch * get_frame_arch(frame_info_ptr this_frame)
Definition frame.c:3027
int gdbarch_pc_regnum(struct gdbarch *gdbarch)
Definition gdbarch.c:2054
int gdbarch_deprecated_fp_regnum(struct gdbarch *gdbarch)
Definition gdbarch.c:2228
int gdbarch_sp_regnum(struct gdbarch *gdbarch)
Definition gdbarch.c:2037
int gdbarch_ps_regnum(struct gdbarch *gdbarch)
Definition gdbarch.c:2071
void gdbarch_address_to_pointer(struct gdbarch *gdbarch, struct type *type, gdb_byte *buf, CORE_ADDR addr)
Definition gdbarch.c:2562
const struct builtin_type * builtin_type(struct gdbarch *gdbarch)
Definition gdbtypes.c:6168
static struct value * value_of_builtin_frame_sp_reg(frame_info_ptr frame, const void *baton)
Definition std-regs.c:75
static struct value * value_of_builtin_frame_ps_reg(frame_info_ptr frame, const void *baton)
Definition std-regs.c:85
static struct value * value_of_builtin_frame_pc_reg(frame_info_ptr frame, const void *baton)
Definition std-regs.c:56
static struct value * value_of_builtin_frame_fp_reg(frame_info_ptr frame, const void *baton)
Definition std-regs.c:30
void _initialize_frame_reg()
Definition std-regs.c:96
struct type * builtin_func_ptr
Definition gdbtypes.h:2146
struct type * builtin_data_ptr
Definition gdbtypes.h:2135
Definition value.h:130
static struct value * allocate(struct type *type)
Definition value.c:957
gdb::array_view< gdb_byte > contents_raw()
Definition value.c:1009
void user_reg_add_builtin(const char *name, user_reg_read_ftype *xread, const void *baton)
Definition user-regs.c:88