]>
Commit | Line | Data |
---|---|---|
0406ec40 AC |
1 | /* Builtin frame register, for GDB, the GNU debugger. |
2 | ||
6aba47ca | 3 | Copyright (C) 2002, 2005, 2007 Free Software Foundation, Inc. |
0406ec40 AC |
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 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. */ | |
0406ec40 AC |
23 | |
24 | #include "defs.h" | |
eb8bc282 | 25 | #include "user-regs.h" |
0406ec40 AC |
26 | #include "frame.h" |
27 | #include "gdbtypes.h" | |
28 | #include "value.h" | |
b66d6d2e | 29 | #include "gdb_string.h" |
0406ec40 | 30 | |
0406ec40 AC |
31 | |
32 | static struct value * | |
123dc839 | 33 | value_of_builtin_frame_fp_reg (struct frame_info *frame, const void *baton) |
0406ec40 | 34 | { |
0ba6dca9 AC |
35 | if (DEPRECATED_FP_REGNUM >= 0) |
36 | /* NOTE: cagney/2003-04-24: Since the mere presence of "fp" in the | |
37 | register name table overrides this built-in $fp register, there | |
38 | is no real reason for this DEPRECATED_FP_REGNUM trickery here. | |
39 | An architecture wanting to implement "$fp" as alias for a raw | |
40 | register can do so by adding "fp" to register name table (mind | |
41 | you, doing this is probably a dangerous thing). */ | |
42 | return value_of_register (DEPRECATED_FP_REGNUM, frame); | |
43 | else | |
44 | { | |
45 | struct value *val = allocate_value (builtin_type_void_data_ptr); | |
10c42a71 | 46 | gdb_byte *buf = value_contents_raw (val); |
0ba6dca9 | 47 | if (frame == NULL) |
170cd118 | 48 | memset (buf, 0, TYPE_LENGTH (value_type (val))); |
0ba6dca9 | 49 | else |
76e71323 UW |
50 | gdbarch_address_to_pointer (current_gdbarch, builtin_type_void_data_ptr, |
51 | buf, get_frame_base_address (frame)); | |
0ba6dca9 AC |
52 | return val; |
53 | } | |
0406ec40 AC |
54 | } |
55 | ||
56 | static struct value * | |
123dc839 | 57 | value_of_builtin_frame_pc_reg (struct frame_info *frame, const void *baton) |
0406ec40 | 58 | { |
0406ec40 AC |
59 | if (PC_REGNUM >= 0) |
60 | return value_of_register (PC_REGNUM, frame); | |
82de1e5b AC |
61 | else |
62 | { | |
63 | struct value *val = allocate_value (builtin_type_void_data_ptr); | |
10c42a71 | 64 | gdb_byte *buf = value_contents_raw (val); |
82de1e5b | 65 | if (frame == NULL) |
170cd118 | 66 | memset (buf, 0, TYPE_LENGTH (value_type (val))); |
82de1e5b | 67 | else |
76e71323 UW |
68 | gdbarch_address_to_pointer (current_gdbarch, builtin_type_void_data_ptr, |
69 | buf, get_frame_pc (frame)); | |
82de1e5b AC |
70 | return val; |
71 | } | |
0406ec40 AC |
72 | } |
73 | ||
74 | static struct value * | |
123dc839 | 75 | value_of_builtin_frame_sp_reg (struct frame_info *frame, const void *baton) |
0406ec40 AC |
76 | { |
77 | #ifdef SP_REGNUM | |
78 | if (SP_REGNUM >= 0) | |
79 | return value_of_register (SP_REGNUM, frame); | |
80 | #endif | |
8a3fe4f8 | 81 | error (_("Standard register ``$sp'' is not available for this target")); |
0406ec40 AC |
82 | } |
83 | ||
84 | static struct value * | |
123dc839 | 85 | value_of_builtin_frame_ps_reg (struct frame_info *frame, const void *baton) |
0406ec40 AC |
86 | { |
87 | #ifdef PS_REGNUM | |
88 | if (PS_REGNUM >= 0) | |
89 | return value_of_register (PS_REGNUM, frame); | |
90 | #endif | |
8a3fe4f8 | 91 | error (_("Standard register ``$ps'' is not available for this target")); |
0406ec40 AC |
92 | } |
93 | ||
b9362cc7 AC |
94 | extern initialize_file_ftype _initialize_frame_reg; /* -Wmissing-prototypes */ |
95 | ||
0406ec40 AC |
96 | void |
97 | _initialize_frame_reg (void) | |
98 | { | |
0406ec40 AC |
99 | /* Frame based $fp, $pc, $sp and $ps. These only come into play |
100 | when the target does not define its own version of these | |
101 | registers. */ | |
123dc839 DJ |
102 | user_reg_add_builtin ("fp", value_of_builtin_frame_fp_reg, NULL); |
103 | user_reg_add_builtin ("pc", value_of_builtin_frame_pc_reg, NULL); | |
104 | user_reg_add_builtin ("sp", value_of_builtin_frame_sp_reg, NULL); | |
105 | user_reg_add_builtin ("ps", value_of_builtin_frame_ps_reg, NULL); | |
0406ec40 | 106 | } |