File: | src/gnu/usr.bin/binutils/gdb/std-regs.c |
Warning: | line 69, column 3 Value stored to 'buf' is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* Builtin frame register, for GDB, the GNU debugger. |
2 | |
3 | Copyright 2002 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 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 | #include "defs.h" |
25 | #include "user-regs.h" |
26 | #include "frame.h" |
27 | #include "gdbtypes.h" |
28 | #include "value.h" |
29 | #include "gdb_string.h" |
30 | |
31 | /* Types that describe the various builtin registers. */ |
32 | |
33 | static struct type *builtin_type_frame_reg; |
34 | |
35 | /* Constructors for those types. */ |
36 | |
37 | static void |
38 | build_builtin_type_frame_reg (void) |
39 | { |
40 | /* $frame. */ |
41 | if (builtin_type_frame_reg == NULL((void*)0)) |
42 | { |
43 | #if 0 |
44 | struct frame |
45 | { |
46 | void *base; |
47 | }; |
48 | #endif |
49 | builtin_type_frame_reg = init_composite_type ("frame", TYPE_CODE_STRUCT); |
50 | append_composite_type_field (builtin_type_frame_reg, "base", |
51 | builtin_type_void_data_ptr); |
52 | } |
53 | } |
54 | |
55 | static struct value * |
56 | value_of_builtin_frame_reg (struct frame_info *frame) |
57 | { |
58 | struct value *val; |
59 | char *buf; |
60 | build_builtin_type_frame_reg (); |
61 | val = allocate_value (builtin_type_frame_reg); |
62 | VALUE_LVAL (val)(val)->lval = not_lval; |
63 | buf = VALUE_CONTENTS_RAW (val)((char *) (val)->aligner.contents + (val)->embedded_offset ); |
64 | memset (buf, 0, TYPE_LENGTH (VALUE_TYPE (val))((val)->type)->length); |
65 | /* frame.base. */ |
66 | if (frame != NULL((void*)0)) |
67 | ADDRESS_TO_POINTER (builtin_type_void_data_ptr, buf,(gdbarch_address_to_pointer (current_gdbarch, builtin_type_void_data_ptr , buf, get_frame_base (frame))) |
68 | get_frame_base (frame))(gdbarch_address_to_pointer (current_gdbarch, builtin_type_void_data_ptr , buf, get_frame_base (frame))); |
69 | buf += TYPE_LENGTH (builtin_type_void_data_ptr)(builtin_type_void_data_ptr)->length; |
Value stored to 'buf' is never read | |
70 | /* frame.XXX. */ |
71 | return val; |
72 | } |
73 | |
74 | static struct value * |
75 | value_of_builtin_frame_fp_reg (struct frame_info *frame) |
76 | { |
77 | if (DEPRECATED_FP_REGNUM(gdbarch_deprecated_fp_regnum (current_gdbarch)) >= 0) |
78 | /* NOTE: cagney/2003-04-24: Since the mere presence of "fp" in the |
79 | register name table overrides this built-in $fp register, there |
80 | is no real reason for this DEPRECATED_FP_REGNUM trickery here. |
81 | An architecture wanting to implement "$fp" as alias for a raw |
82 | register can do so by adding "fp" to register name table (mind |
83 | you, doing this is probably a dangerous thing). */ |
84 | return value_of_register (DEPRECATED_FP_REGNUM(gdbarch_deprecated_fp_regnum (current_gdbarch)), frame); |
85 | else |
86 | { |
87 | struct value *val = allocate_value (builtin_type_void_data_ptr); |
88 | char *buf = VALUE_CONTENTS_RAW (val)((char *) (val)->aligner.contents + (val)->embedded_offset ); |
89 | if (frame == NULL((void*)0)) |
90 | memset (buf, 0, TYPE_LENGTH (VALUE_TYPE (val))((val)->type)->length); |
91 | else |
92 | ADDRESS_TO_POINTER (builtin_type_void_data_ptr, buf,(gdbarch_address_to_pointer (current_gdbarch, builtin_type_void_data_ptr , buf, get_frame_base_address (frame))) |
93 | get_frame_base_address (frame))(gdbarch_address_to_pointer (current_gdbarch, builtin_type_void_data_ptr , buf, get_frame_base_address (frame))); |
94 | return val; |
95 | } |
96 | } |
97 | |
98 | static struct value * |
99 | value_of_builtin_frame_pc_reg (struct frame_info *frame) |
100 | { |
101 | if (PC_REGNUM(gdbarch_pc_regnum (current_gdbarch)) >= 0) |
102 | return value_of_register (PC_REGNUM(gdbarch_pc_regnum (current_gdbarch)), frame); |
103 | else |
104 | { |
105 | struct value *val = allocate_value (builtin_type_void_data_ptr); |
106 | char *buf = VALUE_CONTENTS_RAW (val)((char *) (val)->aligner.contents + (val)->embedded_offset ); |
107 | if (frame == NULL((void*)0)) |
108 | memset (buf, 0, TYPE_LENGTH (VALUE_TYPE (val))((val)->type)->length); |
109 | else |
110 | ADDRESS_TO_POINTER (builtin_type_void_data_ptr, buf,(gdbarch_address_to_pointer (current_gdbarch, builtin_type_void_data_ptr , buf, get_frame_pc (frame))) |
111 | get_frame_pc (frame))(gdbarch_address_to_pointer (current_gdbarch, builtin_type_void_data_ptr , buf, get_frame_pc (frame))); |
112 | return val; |
113 | } |
114 | } |
115 | |
116 | static struct value * |
117 | value_of_builtin_frame_sp_reg (struct frame_info *frame) |
118 | { |
119 | #ifdef SP_REGNUM(gdbarch_sp_regnum (current_gdbarch)) |
120 | if (SP_REGNUM(gdbarch_sp_regnum (current_gdbarch)) >= 0) |
121 | return value_of_register (SP_REGNUM(gdbarch_sp_regnum (current_gdbarch)), frame); |
122 | #endif |
123 | error ("Standard register ``$sp'' is not available for this target"); |
124 | } |
125 | |
126 | static struct value * |
127 | value_of_builtin_frame_ps_reg (struct frame_info *frame) |
128 | { |
129 | #ifdef PS_REGNUM(gdbarch_ps_regnum (current_gdbarch)) |
130 | if (PS_REGNUM(gdbarch_ps_regnum (current_gdbarch)) >= 0) |
131 | return value_of_register (PS_REGNUM(gdbarch_ps_regnum (current_gdbarch)), frame); |
132 | #endif |
133 | error ("Standard register ``$ps'' is not available for this target"); |
134 | } |
135 | |
136 | extern initialize_file_ftype _initialize_frame_reg; /* -Wmissing-prototypes */ |
137 | |
138 | void |
139 | _initialize_frame_reg (void) |
140 | { |
141 | /* FIXME: cagney/2002-02-08: At present the local builtin types |
142 | can't be initialized using _initialize*() or gdbarch. Due mainly |
143 | to non-multi-arch targets, GDB initializes things piece meal and, |
144 | as a consequence can leave these types NULL. */ |
145 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_frame_reg)deprecated_register_gdbarch_swap (&(builtin_type_frame_reg ), sizeof ((builtin_type_frame_reg)), ((void*)0)); |
146 | |
147 | /* Frame based $fp, $pc, $sp and $ps. These only come into play |
148 | when the target does not define its own version of these |
149 | registers. */ |
150 | user_reg_add_builtin ("fp", value_of_builtin_frame_fp_reg); |
151 | user_reg_add_builtin ("pc", value_of_builtin_frame_pc_reg); |
152 | user_reg_add_builtin ("sp", value_of_builtin_frame_sp_reg); |
153 | user_reg_add_builtin ("ps", value_of_builtin_frame_ps_reg); |
154 | |
155 | /* NOTE: cagney/2002-04-05: For moment leave the $frame / $gdbframe |
156 | / $gdb.frame disabled. It isn't yet clear which of the many |
157 | options is the best. */ |
158 | if (0) |
159 | user_reg_add_builtin ("frame", value_of_builtin_frame_reg); |
160 | } |