Commit | Line | Data |
---|---|---|
67f16606 AC |
1 | // OBSOLETE /* Target-dependent code for the Matsushita MN10200 for GDB, the GNU debugger. |
2 | // OBSOLETE | |
3 | // OBSOLETE Copyright 1997, 1998, 1999, 2000, 2001, 2003 Free Software | |
4 | // OBSOLETE Foundation, Inc. | |
5 | // OBSOLETE | |
6 | // OBSOLETE This file is part of GDB. | |
7 | // OBSOLETE | |
8 | // OBSOLETE This program is free software; you can redistribute it and/or modify | |
9 | // OBSOLETE it under the terms of the GNU General Public License as published by | |
10 | // OBSOLETE the Free Software Foundation; either version 2 of the License, or | |
11 | // OBSOLETE (at your option) any later version. | |
12 | // OBSOLETE | |
13 | // OBSOLETE This program is distributed in the hope that it will be useful, | |
14 | // OBSOLETE but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | // OBSOLETE MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | // OBSOLETE GNU General Public License for more details. | |
17 | // OBSOLETE | |
18 | // OBSOLETE You should have received a copy of the GNU General Public License | |
19 | // OBSOLETE along with this program; if not, write to the Free Software | |
20 | // OBSOLETE Foundation, Inc., 59 Temple Place - Suite 330, | |
21 | // OBSOLETE Boston, MA 02111-1307, USA. */ | |
22 | // OBSOLETE | |
23 | // OBSOLETE #include "defs.h" | |
24 | // OBSOLETE #include "frame.h" | |
25 | // OBSOLETE #include "inferior.h" | |
26 | // OBSOLETE #include "target.h" | |
27 | // OBSOLETE #include "value.h" | |
28 | // OBSOLETE #include "bfd.h" | |
29 | // OBSOLETE #include "gdb_string.h" | |
30 | // OBSOLETE #include "gdbcore.h" | |
31 | // OBSOLETE #include "symfile.h" | |
32 | // OBSOLETE #include "regcache.h" | |
33 | // OBSOLETE | |
34 | // OBSOLETE | |
35 | // OBSOLETE /* Should call_function allocate stack space for a struct return? */ | |
36 | // OBSOLETE int | |
37 | // OBSOLETE mn10200_use_struct_convention (int gcc_p, struct type *type) | |
38 | // OBSOLETE { | |
39 | // OBSOLETE return (TYPE_NFIELDS (type) > 1 || TYPE_LENGTH (type) > 8); | |
40 | // OBSOLETE } | |
41 | // OBSOLETE /* *INDENT-OFF* */ | |
42 | // OBSOLETE /* The main purpose of this file is dealing with prologues to extract | |
43 | // OBSOLETE information about stack frames and saved registers. | |
44 | // OBSOLETE | |
45 | // OBSOLETE For reference here's how prologues look on the mn10200: | |
46 | // OBSOLETE | |
47 | // OBSOLETE With frame pointer: | |
48 | // OBSOLETE mov fp,a0 | |
49 | // OBSOLETE mov sp,fp | |
50 | // OBSOLETE add <size>,sp | |
51 | // OBSOLETE Register saves for d2, d3, a1, a2 as needed. Saves start | |
52 | // OBSOLETE at fp - <size> + <outgoing_args_size> and work towards higher | |
53 | // OBSOLETE addresses. Note that the saves are actually done off the stack | |
54 | // OBSOLETE pointer in the prologue! This makes for smaller code and easier | |
55 | // OBSOLETE prologue scanning as the displacement fields will unlikely | |
56 | // OBSOLETE be more than 8 bits! | |
57 | // OBSOLETE | |
58 | // OBSOLETE Without frame pointer: | |
59 | // OBSOLETE add <size>,sp | |
60 | // OBSOLETE Register saves for d2, d3, a1, a2 as needed. Saves start | |
61 | // OBSOLETE at sp + <outgoing_args_size> and work towards higher addresses. | |
62 | // OBSOLETE | |
63 | // OBSOLETE Out of line prologue: | |
64 | // OBSOLETE add <local size>,sp -- optional | |
65 | // OBSOLETE jsr __prologue | |
66 | // OBSOLETE add <outgoing_size>,sp -- optional | |
67 | // OBSOLETE | |
68 | // OBSOLETE The stack pointer remains constant throughout the life of most | |
69 | // OBSOLETE functions. As a result the compiler will usually omit the | |
70 | // OBSOLETE frame pointer, so we must handle frame pointerless functions. */ | |
71 | // OBSOLETE | |
72 | // OBSOLETE /* Analyze the prologue to determine where registers are saved, | |
73 | // OBSOLETE the end of the prologue, etc etc. Return the end of the prologue | |
74 | // OBSOLETE scanned. | |
75 | // OBSOLETE | |
76 | // OBSOLETE We store into FI (if non-null) several tidbits of information: | |
77 | // OBSOLETE | |
78 | // OBSOLETE * stack_size -- size of this stack frame. Note that if we stop in | |
79 | // OBSOLETE certain parts of the prologue/epilogue we may claim the size of the | |
80 | // OBSOLETE current frame is zero. This happens when the current frame has | |
81 | // OBSOLETE not been allocated yet or has already been deallocated. | |
82 | // OBSOLETE | |
83 | // OBSOLETE * fsr -- Addresses of registers saved in the stack by this frame. | |
84 | // OBSOLETE | |
85 | // OBSOLETE * status -- A (relatively) generic status indicator. It's a bitmask | |
86 | // OBSOLETE with the following bits: | |
87 | // OBSOLETE | |
88 | // OBSOLETE MY_FRAME_IN_SP: The base of the current frame is actually in | |
89 | // OBSOLETE the stack pointer. This can happen for frame pointerless | |
90 | // OBSOLETE functions, or cases where we're stopped in the prologue/epilogue | |
91 | // OBSOLETE itself. For these cases mn10200_analyze_prologue will need up | |
92 | // OBSOLETE update fi->frame before returning or analyzing the register | |
93 | // OBSOLETE save instructions. | |
94 | // OBSOLETE | |
95 | // OBSOLETE MY_FRAME_IN_FP: The base of the current frame is in the | |
96 | // OBSOLETE frame pointer register ($a2). | |
97 | // OBSOLETE | |
98 | // OBSOLETE CALLER_A2_IN_A0: $a2 from the caller's frame is temporarily | |
99 | // OBSOLETE in $a0. This can happen if we're stopped in the prologue. | |
100 | // OBSOLETE | |
101 | // OBSOLETE NO_MORE_FRAMES: Set this if the current frame is "start" or | |
102 | // OBSOLETE if the first instruction looks like mov <imm>,sp. This tells | |
103 | // OBSOLETE frame chain to not bother trying to unwind past this frame. */ | |
104 | // OBSOLETE /* *INDENT-ON* */ | |
105 | // OBSOLETE | |
106 | // OBSOLETE | |
107 | // OBSOLETE | |
108 | // OBSOLETE | |
109 | // OBSOLETE #define MY_FRAME_IN_SP 0x1 | |
110 | // OBSOLETE #define MY_FRAME_IN_FP 0x2 | |
111 | // OBSOLETE #define CALLER_A2_IN_A0 0x4 | |
112 | // OBSOLETE #define NO_MORE_FRAMES 0x8 | |
113 | // OBSOLETE | |
114 | // OBSOLETE static CORE_ADDR | |
115 | // OBSOLETE mn10200_analyze_prologue (struct frame_info *fi, CORE_ADDR pc) | |
116 | // OBSOLETE { | |
117 | // OBSOLETE CORE_ADDR func_addr, func_end, addr, stop; | |
118 | // OBSOLETE CORE_ADDR stack_size = 0; | |
119 | // OBSOLETE unsigned char buf[4]; | |
120 | // OBSOLETE int status; | |
121 | // OBSOLETE char *name; | |
122 | // OBSOLETE int out_of_line_prologue = 0; | |
123 | // OBSOLETE | |
124 | // OBSOLETE /* Use the PC in the frame if it's provided to look up the | |
125 | // OBSOLETE start of this function. */ | |
126 | // OBSOLETE pc = (fi ? get_frame_pc (fi) : pc); | |
127 | // OBSOLETE | |
128 | // OBSOLETE /* Find the start of this function. */ | |
129 | // OBSOLETE status = find_pc_partial_function (pc, &name, &func_addr, &func_end); | |
130 | // OBSOLETE | |
131 | // OBSOLETE /* Do nothing if we couldn't find the start of this function or if we're | |
132 | // OBSOLETE stopped at the first instruction in the prologue. */ | |
133 | // OBSOLETE if (status == 0) | |
134 | // OBSOLETE return pc; | |
135 | // OBSOLETE | |
136 | // OBSOLETE /* If we're in start, then give up. */ | |
137 | // OBSOLETE if (strcmp (name, "start") == 0) | |
138 | // OBSOLETE { | |
139 | // OBSOLETE if (fi) | |
140 | // OBSOLETE fi->status = NO_MORE_FRAMES; | |
141 | // OBSOLETE return pc; | |
142 | // OBSOLETE } | |
143 | // OBSOLETE | |
144 | // OBSOLETE /* At the start of a function our frame is in the stack pointer. */ | |
145 | // OBSOLETE if (fi) | |
146 | // OBSOLETE fi->status = MY_FRAME_IN_SP; | |
147 | // OBSOLETE | |
148 | // OBSOLETE /* If we're physically on an RTS instruction, then our frame has already | |
149 | // OBSOLETE been deallocated. | |
150 | // OBSOLETE | |
151 | // OBSOLETE fi->frame is bogus, we need to fix it. */ | |
152 | // OBSOLETE if (fi && get_frame_pc (fi) + 1 == func_end) | |
153 | // OBSOLETE { | |
154 | // OBSOLETE status = target_read_memory (get_frame_pc (fi), buf, 1); | |
155 | // OBSOLETE if (status != 0) | |
156 | // OBSOLETE { | |
157 | // OBSOLETE if (get_next_frame (fi) == NULL) | |
158 | // OBSOLETE deprecated_update_frame_base_hack (fi, read_sp ()); | |
159 | // OBSOLETE return get_frame_pc (fi); | |
160 | // OBSOLETE } | |
161 | // OBSOLETE | |
162 | // OBSOLETE if (buf[0] == 0xfe) | |
163 | // OBSOLETE { | |
164 | // OBSOLETE if (get_next_frame (fi) == NULL) | |
165 | // OBSOLETE deprecated_update_frame_base_hack (fi, read_sp ()); | |
166 | // OBSOLETE return get_frame_pc (fi); | |
167 | // OBSOLETE } | |
168 | // OBSOLETE } | |
169 | // OBSOLETE | |
170 | // OBSOLETE /* Similarly if we're stopped on the first insn of a prologue as our | |
171 | // OBSOLETE frame hasn't been allocated yet. */ | |
172 | // OBSOLETE if (fi && get_frame_pc (fi) == func_addr) | |
173 | // OBSOLETE { | |
174 | // OBSOLETE if (get_next_frame (fi) == NULL) | |
175 | // OBSOLETE deprecated_update_frame_base_hack (fi, read_sp ()); | |
176 | // OBSOLETE return get_frame_pc (fi); | |
177 | // OBSOLETE } | |
178 | // OBSOLETE | |
179 | // OBSOLETE /* Figure out where to stop scanning. */ | |
180 | // OBSOLETE stop = fi ? get_frame_pc (fi) : func_end; | |
181 | // OBSOLETE | |
182 | // OBSOLETE /* Don't walk off the end of the function. */ | |
183 | // OBSOLETE stop = stop > func_end ? func_end : stop; | |
184 | // OBSOLETE | |
185 | // OBSOLETE /* Start scanning on the first instruction of this function. */ | |
186 | // OBSOLETE addr = func_addr; | |
187 | // OBSOLETE | |
188 | // OBSOLETE status = target_read_memory (addr, buf, 2); | |
189 | // OBSOLETE if (status != 0) | |
190 | // OBSOLETE { | |
191 | // OBSOLETE if (fi && get_next_frame (fi) == NULL && fi->status & MY_FRAME_IN_SP) | |
192 | // OBSOLETE deprecated_update_frame_base_hack (fi, read_sp ()); | |
193 | // OBSOLETE return addr; | |
194 | // OBSOLETE } | |
195 | // OBSOLETE | |
196 | // OBSOLETE /* First see if this insn sets the stack pointer; if so, it's something | |
197 | // OBSOLETE we won't understand, so quit now. */ | |
198 | // OBSOLETE if (buf[0] == 0xdf | |
199 | // OBSOLETE || (buf[0] == 0xf4 && buf[1] == 0x77)) | |
200 | // OBSOLETE { | |
201 | // OBSOLETE if (fi) | |
202 | // OBSOLETE fi->status = NO_MORE_FRAMES; | |
203 | // OBSOLETE return addr; | |
204 | // OBSOLETE } | |
205 | // OBSOLETE | |
206 | // OBSOLETE /* Now see if we have a frame pointer. | |
207 | // OBSOLETE | |
208 | // OBSOLETE Search for mov a2,a0 (0xf278) | |
209 | // OBSOLETE then mov a3,a2 (0xf27e). */ | |
210 | // OBSOLETE | |
211 | // OBSOLETE if (buf[0] == 0xf2 && buf[1] == 0x78) | |
212 | // OBSOLETE { | |
213 | // OBSOLETE /* Our caller's $a2 will be found in $a0 now. Note it for | |
214 | // OBSOLETE our callers. */ | |
215 | // OBSOLETE if (fi) | |
216 | // OBSOLETE fi->status |= CALLER_A2_IN_A0; | |
217 | // OBSOLETE addr += 2; | |
218 | // OBSOLETE if (addr >= stop) | |
219 | // OBSOLETE { | |
220 | // OBSOLETE /* We still haven't allocated our local stack. Handle this | |
221 | // OBSOLETE as if we stopped on the first or last insn of a function. */ | |
222 | // OBSOLETE if (fi && get_next_frame (fi) == NULL) | |
223 | // OBSOLETE deprecated_update_frame_base_hack (fi, read_sp ()); | |
224 | // OBSOLETE return addr; | |
225 | // OBSOLETE } | |
226 | // OBSOLETE | |
227 | // OBSOLETE status = target_read_memory (addr, buf, 2); | |
228 | // OBSOLETE if (status != 0) | |
229 | // OBSOLETE { | |
230 | // OBSOLETE if (fi && get_next_frame (fi) == NULL) | |
231 | // OBSOLETE deprecated_update_frame_base_hack (fi, read_sp ()); | |
232 | // OBSOLETE return addr; | |
233 | // OBSOLETE } | |
234 | // OBSOLETE if (buf[0] == 0xf2 && buf[1] == 0x7e) | |
235 | // OBSOLETE { | |
236 | // OBSOLETE addr += 2; | |
237 | // OBSOLETE | |
238 | // OBSOLETE /* Our frame pointer is valid now. */ | |
239 | // OBSOLETE if (fi) | |
240 | // OBSOLETE { | |
241 | // OBSOLETE fi->status |= MY_FRAME_IN_FP; | |
242 | // OBSOLETE fi->status &= ~MY_FRAME_IN_SP; | |
243 | // OBSOLETE } | |
244 | // OBSOLETE if (addr >= stop) | |
245 | // OBSOLETE return addr; | |
246 | // OBSOLETE } | |
247 | // OBSOLETE else | |
248 | // OBSOLETE { | |
249 | // OBSOLETE if (fi && get_next_frame (fi) == NULL) | |
250 | // OBSOLETE deprecated_update_frame_base_hack (fi, read_sp ()); | |
251 | // OBSOLETE return addr; | |
252 | // OBSOLETE } | |
253 | // OBSOLETE } | |
254 | // OBSOLETE | |
255 | // OBSOLETE /* Next we should allocate the local frame. | |
256 | // OBSOLETE | |
257 | // OBSOLETE Search for add imm8,a3 (0xd3XX) | |
258 | // OBSOLETE or add imm16,a3 (0xf70bXXXX) | |
259 | // OBSOLETE or add imm24,a3 (0xf467XXXXXX). | |
260 | // OBSOLETE | |
261 | // OBSOLETE If none of the above was found, then this prologue has | |
262 | // OBSOLETE no stack, and therefore can't have any register saves, | |
263 | // OBSOLETE so quit now. */ | |
264 | // OBSOLETE status = target_read_memory (addr, buf, 2); | |
265 | // OBSOLETE if (status != 0) | |
266 | // OBSOLETE { | |
267 | // OBSOLETE if (fi && get_next_frame (fi) == NULL && (fi->status & MY_FRAME_IN_SP)) | |
268 | // OBSOLETE deprecated_update_frame_base_hack (fi, read_sp ()); | |
269 | // OBSOLETE return addr; | |
270 | // OBSOLETE } | |
271 | // OBSOLETE if (buf[0] == 0xd3) | |
272 | // OBSOLETE { | |
273 | // OBSOLETE stack_size = extract_signed_integer (&buf[1], 1); | |
274 | // OBSOLETE if (fi) | |
275 | // OBSOLETE fi->stack_size = stack_size; | |
276 | // OBSOLETE addr += 2; | |
277 | // OBSOLETE if (addr >= stop) | |
278 | // OBSOLETE { | |
279 | // OBSOLETE if (fi && get_next_frame (fi) == NULL && (fi->status & MY_FRAME_IN_SP)) | |
280 | // OBSOLETE deprecated_update_frame_base_hack (fi, read_sp () - stack_size); | |
281 | // OBSOLETE return addr; | |
282 | // OBSOLETE } | |
283 | // OBSOLETE } | |
284 | // OBSOLETE else if (buf[0] == 0xf7 && buf[1] == 0x0b) | |
285 | // OBSOLETE { | |
286 | // OBSOLETE status = target_read_memory (addr + 2, buf, 2); | |
287 | // OBSOLETE if (status != 0) | |
288 | // OBSOLETE { | |
289 | // OBSOLETE if (fi && get_next_frame (fi) == NULL && (fi->status & MY_FRAME_IN_SP)) | |
290 | // OBSOLETE deprecated_update_frame_base_hack (fi, read_sp ()); | |
291 | // OBSOLETE return addr; | |
292 | // OBSOLETE } | |
293 | // OBSOLETE stack_size = extract_signed_integer (buf, 2); | |
294 | // OBSOLETE if (fi) | |
295 | // OBSOLETE fi->stack_size = stack_size; | |
296 | // OBSOLETE addr += 4; | |
297 | // OBSOLETE if (addr >= stop) | |
298 | // OBSOLETE { | |
299 | // OBSOLETE if (fi && get_next_frame (fi) == NULL && (fi->status & MY_FRAME_IN_SP)) | |
300 | // OBSOLETE deprecated_update_frame_base_hack (fi, read_sp () - stack_size); | |
301 | // OBSOLETE return addr; | |
302 | // OBSOLETE } | |
303 | // OBSOLETE } | |
304 | // OBSOLETE else if (buf[0] == 0xf4 && buf[1] == 0x67) | |
305 | // OBSOLETE { | |
306 | // OBSOLETE status = target_read_memory (addr + 2, buf, 3); | |
307 | // OBSOLETE if (status != 0) | |
308 | // OBSOLETE { | |
309 | // OBSOLETE if (fi && get_next_frame (fi) == NULL && (fi->status & MY_FRAME_IN_SP)) | |
310 | // OBSOLETE deprecated_update_frame_base_hack (fi, read_sp ()); | |
311 | // OBSOLETE return addr; | |
312 | // OBSOLETE } | |
313 | // OBSOLETE stack_size = extract_signed_integer (buf, 3); | |
314 | // OBSOLETE if (fi) | |
315 | // OBSOLETE fi->stack_size = stack_size; | |
316 | // OBSOLETE addr += 5; | |
317 | // OBSOLETE if (addr >= stop) | |
318 | // OBSOLETE { | |
319 | // OBSOLETE if (fi && get_next_frame (fi) == NULL && (fi->status & MY_FRAME_IN_SP)) | |
320 | // OBSOLETE deprecated_update_frame_base_hack (fi, read_sp () - stack_size); | |
321 | // OBSOLETE return addr; | |
322 | // OBSOLETE } | |
323 | // OBSOLETE } | |
324 | // OBSOLETE | |
325 | // OBSOLETE /* Now see if we have a call to __prologue for an out of line | |
326 | // OBSOLETE prologue. */ | |
327 | // OBSOLETE status = target_read_memory (addr, buf, 2); | |
328 | // OBSOLETE if (status != 0) | |
329 | // OBSOLETE return addr; | |
330 | // OBSOLETE | |
331 | // OBSOLETE /* First check for 16bit pc-relative call to __prologue. */ | |
332 | // OBSOLETE if (buf[0] == 0xfd) | |
333 | // OBSOLETE { | |
334 | // OBSOLETE CORE_ADDR temp; | |
335 | // OBSOLETE status = target_read_memory (addr + 1, buf, 2); | |
336 | // OBSOLETE if (status != 0) | |
337 | // OBSOLETE { | |
338 | // OBSOLETE if (fi && get_next_frame (fi) == NULL && (fi->status & MY_FRAME_IN_SP)) | |
339 | // OBSOLETE deprecated_update_frame_base_hack (fi, read_sp ()); | |
340 | // OBSOLETE return addr; | |
341 | // OBSOLETE } | |
342 | // OBSOLETE | |
343 | // OBSOLETE /* Get the PC this instruction will branch to. */ | |
344 | // OBSOLETE temp = (extract_signed_integer (buf, 2) + addr + 3) & 0xffffff; | |
345 | // OBSOLETE | |
346 | // OBSOLETE /* Get the name of the function at the target address. */ | |
347 | // OBSOLETE status = find_pc_partial_function (temp, &name, NULL, NULL); | |
348 | // OBSOLETE if (status == 0) | |
349 | // OBSOLETE { | |
350 | // OBSOLETE if (fi && get_next_frame (fi) == NULL && (fi->status & MY_FRAME_IN_SP)) | |
351 | // OBSOLETE deprecated_update_frame_base_hack (fi, read_sp ()); | |
352 | // OBSOLETE return addr; | |
353 | // OBSOLETE } | |
354 | // OBSOLETE | |
355 | // OBSOLETE /* Note if it is an out of line prologue. */ | |
356 | // OBSOLETE out_of_line_prologue = (strcmp (name, "__prologue") == 0); | |
357 | // OBSOLETE | |
358 | // OBSOLETE /* This sucks up 3 bytes of instruction space. */ | |
359 | // OBSOLETE if (out_of_line_prologue) | |
360 | // OBSOLETE addr += 3; | |
361 | // OBSOLETE | |
362 | // OBSOLETE if (addr >= stop) | |
363 | // OBSOLETE { | |
364 | // OBSOLETE if (fi && get_next_frame (fi) == NULL) | |
365 | // OBSOLETE { | |
366 | // OBSOLETE fi->stack_size -= 16; | |
367 | // OBSOLETE deprecated_update_frame_base_hack (fi, read_sp () - fi->stack_size); | |
368 | // OBSOLETE } | |
369 | // OBSOLETE return addr; | |
370 | // OBSOLETE } | |
371 | // OBSOLETE } | |
372 | // OBSOLETE /* Now check for the 24bit pc-relative call to __prologue. */ | |
373 | // OBSOLETE else if (buf[0] == 0xf4 && buf[1] == 0xe1) | |
374 | // OBSOLETE { | |
375 | // OBSOLETE CORE_ADDR temp; | |
376 | // OBSOLETE status = target_read_memory (addr + 2, buf, 3); | |
377 | // OBSOLETE if (status != 0) | |
378 | // OBSOLETE { | |
379 | // OBSOLETE if (fi && get_next_frame (fi) == NULL && (fi->status & MY_FRAME_IN_SP)) | |
380 | // OBSOLETE deprecated_update_frame_base_hack (fi, read_sp ()); | |
381 | // OBSOLETE return addr; | |
382 | // OBSOLETE } | |
383 | // OBSOLETE | |
384 | // OBSOLETE /* Get the PC this instruction will branch to. */ | |
385 | // OBSOLETE temp = (extract_signed_integer (buf, 3) + addr + 5) & 0xffffff; | |
386 | // OBSOLETE | |
387 | // OBSOLETE /* Get the name of the function at the target address. */ | |
388 | // OBSOLETE status = find_pc_partial_function (temp, &name, NULL, NULL); | |
389 | // OBSOLETE if (status == 0) | |
390 | // OBSOLETE { | |
391 | // OBSOLETE if (fi && get_next_frame (fi) == NULL && (fi->status & MY_FRAME_IN_SP)) | |
392 | // OBSOLETE deprecated_update_frame_base_hack (fi, read_sp ()); | |
393 | // OBSOLETE return addr; | |
394 | // OBSOLETE } | |
395 | // OBSOLETE | |
396 | // OBSOLETE /* Note if it is an out of line prologue. */ | |
397 | // OBSOLETE out_of_line_prologue = (strcmp (name, "__prologue") == 0); | |
398 | // OBSOLETE | |
399 | // OBSOLETE /* This sucks up 5 bytes of instruction space. */ | |
400 | // OBSOLETE if (out_of_line_prologue) | |
401 | // OBSOLETE addr += 5; | |
402 | // OBSOLETE | |
403 | // OBSOLETE if (addr >= stop) | |
404 | // OBSOLETE { | |
405 | // OBSOLETE if (fi && get_next_frame (fi) == NULL && (fi->status & MY_FRAME_IN_SP)) | |
406 | // OBSOLETE { | |
407 | // OBSOLETE fi->stack_size -= 16; | |
408 | // OBSOLETE deprecated_update_frame_base_hack (fi, read_sp () - fi->stack_size); | |
409 | // OBSOLETE } | |
410 | // OBSOLETE return addr; | |
411 | // OBSOLETE } | |
412 | // OBSOLETE } | |
413 | // OBSOLETE | |
414 | // OBSOLETE /* Now actually handle the out of line prologue. */ | |
415 | // OBSOLETE if (out_of_line_prologue) | |
416 | // OBSOLETE { | |
417 | // OBSOLETE int outgoing_args_size = 0; | |
418 | // OBSOLETE | |
419 | // OBSOLETE /* First adjust the stack size for this function. The out of | |
420 | // OBSOLETE line prologue saves 4 registers (16bytes of data). */ | |
421 | // OBSOLETE if (fi) | |
422 | // OBSOLETE fi->stack_size -= 16; | |
423 | // OBSOLETE | |
424 | // OBSOLETE /* Update fi->frame if necessary. */ | |
425 | // OBSOLETE if (fi && get_next_frame (fi) == NULL) | |
426 | // OBSOLETE deprecated_update_frame_base_hack (fi, read_sp () - fi->stack_size); | |
427 | // OBSOLETE | |
428 | // OBSOLETE /* After the out of line prologue, there may be another | |
429 | // OBSOLETE stack adjustment for the outgoing arguments. | |
430 | // OBSOLETE | |
431 | // OBSOLETE Search for add imm8,a3 (0xd3XX) | |
432 | // OBSOLETE or add imm16,a3 (0xf70bXXXX) | |
433 | // OBSOLETE or add imm24,a3 (0xf467XXXXXX). */ | |
434 | // OBSOLETE | |
435 | // OBSOLETE status = target_read_memory (addr, buf, 2); | |
436 | // OBSOLETE if (status != 0) | |
437 | // OBSOLETE { | |
438 | // OBSOLETE if (fi) | |
439 | // OBSOLETE { | |
440 | // OBSOLETE fi->fsr.regs[2] = get_frame_base (fi) + fi->stack_size + 4; | |
441 | // OBSOLETE fi->fsr.regs[3] = get_frame_base (fi) + fi->stack_size + 8; | |
442 | // OBSOLETE fi->fsr.regs[5] = get_frame_base (fi) + fi->stack_size + 12; | |
443 | // OBSOLETE fi->fsr.regs[6] = get_frame_base (fi) + fi->stack_size + 16; | |
444 | // OBSOLETE } | |
445 | // OBSOLETE return addr; | |
446 | // OBSOLETE } | |
447 | // OBSOLETE | |
448 | // OBSOLETE if (buf[0] == 0xd3) | |
449 | // OBSOLETE { | |
450 | // OBSOLETE outgoing_args_size = extract_signed_integer (&buf[1], 1); | |
451 | // OBSOLETE addr += 2; | |
452 | // OBSOLETE } | |
453 | // OBSOLETE else if (buf[0] == 0xf7 && buf[1] == 0x0b) | |
454 | // OBSOLETE { | |
455 | // OBSOLETE status = target_read_memory (addr + 2, buf, 2); | |
456 | // OBSOLETE if (status != 0) | |
457 | // OBSOLETE { | |
458 | // OBSOLETE if (fi) | |
459 | // OBSOLETE { | |
460 | // OBSOLETE fi->fsr.regs[2] = get_frame_base (fi) + fi->stack_size + 4; | |
461 | // OBSOLETE fi->fsr.regs[3] = get_frame_base (fi) + fi->stack_size + 8; | |
462 | // OBSOLETE fi->fsr.regs[5] = get_frame_base (fi) + fi->stack_size + 12; | |
463 | // OBSOLETE fi->fsr.regs[6] = get_frame_base (fi) + fi->stack_size + 16; | |
464 | // OBSOLETE } | |
465 | // OBSOLETE return addr; | |
466 | // OBSOLETE } | |
467 | // OBSOLETE outgoing_args_size = extract_signed_integer (buf, 2); | |
468 | // OBSOLETE addr += 4; | |
469 | // OBSOLETE } | |
470 | // OBSOLETE else if (buf[0] == 0xf4 && buf[1] == 0x67) | |
471 | // OBSOLETE { | |
472 | // OBSOLETE status = target_read_memory (addr + 2, buf, 3); | |
473 | // OBSOLETE if (status != 0) | |
474 | // OBSOLETE { | |
475 | // OBSOLETE if (fi && get_next_frame (fi) == NULL) | |
476 | // OBSOLETE { | |
477 | // OBSOLETE fi->fsr.regs[2] = get_frame_base (fi) + fi->stack_size + 4; | |
478 | // OBSOLETE fi->fsr.regs[3] = get_frame_base (fi) + fi->stack_size + 8; | |
479 | // OBSOLETE fi->fsr.regs[5] = get_frame_base (fi) + fi->stack_size + 12; | |
480 | // OBSOLETE fi->fsr.regs[6] = get_frame_base (fi) + fi->stack_size + 16; | |
481 | // OBSOLETE } | |
482 | // OBSOLETE return addr; | |
483 | // OBSOLETE } | |
484 | // OBSOLETE outgoing_args_size = extract_signed_integer (buf, 3); | |
485 | // OBSOLETE addr += 5; | |
486 | // OBSOLETE } | |
487 | // OBSOLETE else | |
488 | // OBSOLETE outgoing_args_size = 0; | |
489 | // OBSOLETE | |
490 | // OBSOLETE /* Now that we know the size of the outgoing arguments, fix | |
491 | // OBSOLETE fi->frame again if this is the innermost frame. */ | |
492 | // OBSOLETE if (fi && get_next_frame (fi) == NULL) | |
493 | // OBSOLETE deprecated_update_frame_base_hack (fi, get_frame_base (fi) - outgoing_args_size); | |
494 | // OBSOLETE | |
495 | // OBSOLETE /* Note the register save information and update the stack | |
496 | // OBSOLETE size for this frame too. */ | |
497 | // OBSOLETE if (fi) | |
498 | // OBSOLETE { | |
499 | // OBSOLETE fi->fsr.regs[2] = get_frame_base (fi) + fi->stack_size + 4; | |
500 | // OBSOLETE fi->fsr.regs[3] = get_frame_base (fi) + fi->stack_size + 8; | |
501 | // OBSOLETE fi->fsr.regs[5] = get_frame_base (fi) + fi->stack_size + 12; | |
502 | // OBSOLETE fi->fsr.regs[6] = get_frame_base (fi) + fi->stack_size + 16; | |
503 | // OBSOLETE fi->stack_size += outgoing_args_size; | |
504 | // OBSOLETE } | |
505 | // OBSOLETE /* There can be no more prologue insns, so return now. */ | |
506 | // OBSOLETE return addr; | |
507 | // OBSOLETE } | |
508 | // OBSOLETE | |
509 | // OBSOLETE /* At this point fi->frame needs to be correct. | |
510 | // OBSOLETE | |
511 | // OBSOLETE If MY_FRAME_IN_SP is set and we're the innermost frame, then we | |
512 | // OBSOLETE need to fix fi->frame so that backtracing, find_frame_saved_regs, | |
513 | // OBSOLETE etc work correctly. */ | |
514 | // OBSOLETE if (fi && get_next_frame (fi) == NULL && (fi->status & MY_FRAME_IN_SP) != 0) | |
515 | // OBSOLETE deprecated_update_frame_base_hack (fi, read_sp () - fi->stack_size); | |
516 | // OBSOLETE | |
517 | // OBSOLETE /* And last we have the register saves. These are relatively | |
518 | // OBSOLETE simple because they're physically done off the stack pointer, | |
519 | // OBSOLETE and thus the number of different instructions we need to | |
520 | // OBSOLETE check is greatly reduced because we know the displacements | |
521 | // OBSOLETE will be small. | |
522 | // OBSOLETE | |
523 | // OBSOLETE Search for movx d2,(X,a3) (0xf55eXX) | |
524 | // OBSOLETE then movx d3,(X,a3) (0xf55fXX) | |
525 | // OBSOLETE then mov a1,(X,a3) (0x5dXX) No frame pointer case | |
526 | // OBSOLETE then mov a2,(X,a3) (0x5eXX) No frame pointer case | |
527 | // OBSOLETE or mov a0,(X,a3) (0x5cXX) Frame pointer case. */ | |
528 | // OBSOLETE | |
529 | // OBSOLETE status = target_read_memory (addr, buf, 2); | |
530 | // OBSOLETE if (status != 0) | |
531 | // OBSOLETE return addr; | |
532 | // OBSOLETE if (buf[0] == 0xf5 && buf[1] == 0x5e) | |
533 | // OBSOLETE { | |
534 | // OBSOLETE if (fi) | |
535 | // OBSOLETE { | |
536 | // OBSOLETE status = target_read_memory (addr + 2, buf, 1); | |
537 | // OBSOLETE if (status != 0) | |
538 | // OBSOLETE return addr; | |
539 | // OBSOLETE fi->fsr.regs[2] = (get_frame_base (fi) + stack_size | |
540 | // OBSOLETE + extract_signed_integer (buf, 1)); | |
541 | // OBSOLETE } | |
542 | // OBSOLETE addr += 3; | |
543 | // OBSOLETE if (addr >= stop) | |
544 | // OBSOLETE return addr; | |
545 | // OBSOLETE status = target_read_memory (addr, buf, 2); | |
546 | // OBSOLETE if (status != 0) | |
547 | // OBSOLETE return addr; | |
548 | // OBSOLETE } | |
549 | // OBSOLETE if (buf[0] == 0xf5 && buf[1] == 0x5f) | |
550 | // OBSOLETE { | |
551 | // OBSOLETE if (fi) | |
552 | // OBSOLETE { | |
553 | // OBSOLETE status = target_read_memory (addr + 2, buf, 1); | |
554 | // OBSOLETE if (status != 0) | |
555 | // OBSOLETE return addr; | |
556 | // OBSOLETE fi->fsr.regs[3] = (get_frame_base (fi) + stack_size | |
557 | // OBSOLETE + extract_signed_integer (buf, 1)); | |
558 | // OBSOLETE } | |
559 | // OBSOLETE addr += 3; | |
560 | // OBSOLETE if (addr >= stop) | |
561 | // OBSOLETE return addr; | |
562 | // OBSOLETE status = target_read_memory (addr, buf, 2); | |
563 | // OBSOLETE if (status != 0) | |
564 | // OBSOLETE return addr; | |
565 | // OBSOLETE } | |
566 | // OBSOLETE if (buf[0] == 0x5d) | |
567 | // OBSOLETE { | |
568 | // OBSOLETE if (fi) | |
569 | // OBSOLETE { | |
570 | // OBSOLETE status = target_read_memory (addr + 1, buf, 1); | |
571 | // OBSOLETE if (status != 0) | |
572 | // OBSOLETE return addr; | |
573 | // OBSOLETE fi->fsr.regs[5] = (get_frame_base (fi) + stack_size | |
574 | // OBSOLETE + extract_signed_integer (buf, 1)); | |
575 | // OBSOLETE } | |
576 | // OBSOLETE addr += 2; | |
577 | // OBSOLETE if (addr >= stop) | |
578 | // OBSOLETE return addr; | |
579 | // OBSOLETE status = target_read_memory (addr, buf, 2); | |
580 | // OBSOLETE if (status != 0) | |
581 | // OBSOLETE return addr; | |
582 | // OBSOLETE } | |
583 | // OBSOLETE if (buf[0] == 0x5e || buf[0] == 0x5c) | |
584 | // OBSOLETE { | |
585 | // OBSOLETE if (fi) | |
586 | // OBSOLETE { | |
587 | // OBSOLETE status = target_read_memory (addr + 1, buf, 1); | |
588 | // OBSOLETE if (status != 0) | |
589 | // OBSOLETE return addr; | |
590 | // OBSOLETE fi->fsr.regs[6] = (get_frame_base (fi) + stack_size | |
591 | // OBSOLETE + extract_signed_integer (buf, 1)); | |
592 | // OBSOLETE fi->status &= ~CALLER_A2_IN_A0; | |
593 | // OBSOLETE } | |
594 | // OBSOLETE addr += 2; | |
595 | // OBSOLETE if (addr >= stop) | |
596 | // OBSOLETE return addr; | |
597 | // OBSOLETE return addr; | |
598 | // OBSOLETE } | |
599 | // OBSOLETE return addr; | |
600 | // OBSOLETE } | |
601 | // OBSOLETE | |
602 | // OBSOLETE /* Function: frame_chain | |
603 | // OBSOLETE Figure out and return the caller's frame pointer given current | |
604 | // OBSOLETE frame_info struct. | |
605 | // OBSOLETE | |
606 | // OBSOLETE We don't handle dummy frames yet but we would probably just return the | |
607 | // OBSOLETE stack pointer that was in use at the time the function call was made? */ | |
608 | // OBSOLETE | |
609 | // OBSOLETE CORE_ADDR | |
610 | // OBSOLETE mn10200_frame_chain (struct frame_info *fi) | |
611 | // OBSOLETE { | |
612 | // OBSOLETE struct frame_info *dummy_frame = deprecated_frame_xmalloc (); | |
613 | // OBSOLETE struct cleanup *old_chain = make_cleanup (xfree, dummy_frame); | |
614 | // OBSOLETE CORE_ADDR ret; | |
615 | // OBSOLETE | |
616 | // OBSOLETE /* Walk through the prologue to determine the stack size, | |
617 | // OBSOLETE location of saved registers, end of the prologue, etc. */ | |
618 | // OBSOLETE if (fi->status == 0) | |
619 | // OBSOLETE mn10200_analyze_prologue (fi, (CORE_ADDR) 0); | |
620 | // OBSOLETE | |
621 | // OBSOLETE /* Quit now if mn10200_analyze_prologue set NO_MORE_FRAMES. */ | |
622 | // OBSOLETE if (fi->status & NO_MORE_FRAMES) | |
623 | // OBSOLETE return 0; | |
624 | // OBSOLETE | |
625 | // OBSOLETE /* Now that we've analyzed our prologue, determine the frame | |
626 | // OBSOLETE pointer for our caller. | |
627 | // OBSOLETE | |
628 | // OBSOLETE If our caller has a frame pointer, then we need to | |
629 | // OBSOLETE find the entry value of $a2 to our function. | |
630 | // OBSOLETE | |
631 | // OBSOLETE If CALLER_A2_IN_A0, then the chain is in $a0. | |
632 | // OBSOLETE | |
633 | // OBSOLETE If fsr.regs[6] is nonzero, then it's at the memory | |
634 | // OBSOLETE location pointed to by fsr.regs[6]. | |
635 | // OBSOLETE | |
636 | // OBSOLETE Else it's still in $a2. | |
637 | // OBSOLETE | |
638 | // OBSOLETE If our caller does not have a frame pointer, then his | |
639 | // OBSOLETE frame base is fi->frame + -caller's stack size + 4. */ | |
640 | // OBSOLETE | |
641 | // OBSOLETE /* The easiest way to get that info is to analyze our caller's frame. | |
642 | // OBSOLETE | |
643 | // OBSOLETE So we set up a dummy frame and call mn10200_analyze_prologue to | |
644 | // OBSOLETE find stuff for us. */ | |
645 | // OBSOLETE deprecated_update_frame_pc_hack (dummy_frame, FRAME_SAVED_PC (fi)); | |
646 | // OBSOLETE deprecated_update_frame_base_hack (dummy_frame, get_frame_base (fi)); | |
647 | // OBSOLETE memset (dummy_frame->fsr.regs, '\000', sizeof dummy_frame->fsr.regs); | |
648 | // OBSOLETE dummy_frame->status = 0; | |
649 | // OBSOLETE dummy_frame->stack_size = 0; | |
650 | // OBSOLETE mn10200_analyze_prologue (dummy_frame, 0); | |
651 | // OBSOLETE | |
652 | // OBSOLETE if (dummy_frame->status & MY_FRAME_IN_FP) | |
653 | // OBSOLETE { | |
654 | // OBSOLETE /* Our caller has a frame pointer. So find the frame in $a2, $a0, | |
655 | // OBSOLETE or in the stack. */ | |
656 | // OBSOLETE if (fi->fsr.regs[6]) | |
657 | // OBSOLETE ret = (read_memory_integer (fi->fsr.regs[FP_REGNUM], REGISTER_SIZE) | |
658 | // OBSOLETE & 0xffffff); | |
659 | // OBSOLETE else if (fi->status & CALLER_A2_IN_A0) | |
660 | // OBSOLETE ret = read_register (4); | |
661 | // OBSOLETE else | |
662 | // OBSOLETE ret = read_register (FP_REGNUM); | |
663 | // OBSOLETE } | |
664 | // OBSOLETE else | |
665 | // OBSOLETE { | |
666 | // OBSOLETE /* Our caller does not have a frame pointer. So his frame starts | |
667 | // OBSOLETE at the base of our frame (fi->frame) + <his size> + 4 (saved pc). */ | |
668 | // OBSOLETE ret = get_frame_base (fi) + -dummy_frame->stack_size + 4; | |
669 | // OBSOLETE } | |
670 | // OBSOLETE do_cleanups (old_chain); | |
671 | // OBSOLETE return ret; | |
672 | // OBSOLETE } | |
673 | // OBSOLETE | |
674 | // OBSOLETE /* Function: skip_prologue | |
675 | // OBSOLETE Return the address of the first inst past the prologue of the function. */ | |
676 | // OBSOLETE | |
677 | // OBSOLETE CORE_ADDR | |
678 | // OBSOLETE mn10200_skip_prologue (CORE_ADDR pc) | |
679 | // OBSOLETE { | |
680 | // OBSOLETE /* We used to check the debug symbols, but that can lose if | |
681 | // OBSOLETE we have a null prologue. */ | |
682 | // OBSOLETE return mn10200_analyze_prologue (NULL, pc); | |
683 | // OBSOLETE } | |
684 | // OBSOLETE | |
685 | // OBSOLETE /* Function: pop_frame | |
686 | // OBSOLETE This routine gets called when either the user uses the `return' | |
687 | // OBSOLETE command, or the call dummy breakpoint gets hit. */ | |
688 | // OBSOLETE | |
689 | // OBSOLETE void | |
690 | // OBSOLETE mn10200_pop_frame (struct frame_info *frame) | |
691 | // OBSOLETE { | |
692 | // OBSOLETE int regnum; | |
693 | // OBSOLETE | |
694 | // OBSOLETE if (DEPRECATED_PC_IN_CALL_DUMMY (get_frame_pc (frame), | |
695 | // OBSOLETE get_frame_base (frame), | |
696 | // OBSOLETE get_frame_base (frame))) | |
697 | // OBSOLETE generic_pop_dummy_frame (); | |
698 | // OBSOLETE else | |
699 | // OBSOLETE { | |
700 | // OBSOLETE write_register (PC_REGNUM, FRAME_SAVED_PC (frame)); | |
701 | // OBSOLETE | |
702 | // OBSOLETE /* Restore any saved registers. */ | |
703 | // OBSOLETE for (regnum = 0; regnum < NUM_REGS; regnum++) | |
704 | // OBSOLETE if (frame->fsr.regs[regnum] != 0) | |
705 | // OBSOLETE { | |
706 | // OBSOLETE ULONGEST value; | |
707 | // OBSOLETE | |
708 | // OBSOLETE value = read_memory_unsigned_integer (frame->fsr.regs[regnum], | |
709 | // OBSOLETE REGISTER_RAW_SIZE (regnum)); | |
710 | // OBSOLETE write_register (regnum, value); | |
711 | // OBSOLETE } | |
712 | // OBSOLETE | |
713 | // OBSOLETE /* Actually cut back the stack. */ | |
714 | // OBSOLETE write_register (SP_REGNUM, get_frame_base (frame)); | |
715 | // OBSOLETE | |
716 | // OBSOLETE /* Don't we need to set the PC?!? XXX FIXME. */ | |
717 | // OBSOLETE } | |
718 | // OBSOLETE | |
719 | // OBSOLETE /* Throw away any cached frame information. */ | |
720 | // OBSOLETE flush_cached_frames (); | |
721 | // OBSOLETE } | |
722 | // OBSOLETE | |
723 | // OBSOLETE /* Function: push_arguments | |
724 | // OBSOLETE Setup arguments for a call to the target. Arguments go in | |
725 | // OBSOLETE order on the stack. */ | |
726 | // OBSOLETE | |
727 | // OBSOLETE CORE_ADDR | |
728 | // OBSOLETE mn10200_push_arguments (int nargs, struct value **args, CORE_ADDR sp, | |
729 | // OBSOLETE unsigned char struct_return, CORE_ADDR struct_addr) | |
730 | // OBSOLETE { | |
731 | // OBSOLETE int argnum = 0; | |
732 | // OBSOLETE int len = 0; | |
733 | // OBSOLETE int stack_offset = 0; | |
734 | // OBSOLETE int regsused = struct_return ? 1 : 0; | |
735 | // OBSOLETE | |
736 | // OBSOLETE /* This should be a nop, but align the stack just in case something | |
737 | // OBSOLETE went wrong. Stacks are two byte aligned on the mn10200. */ | |
738 | // OBSOLETE sp &= ~1; | |
739 | // OBSOLETE | |
740 | // OBSOLETE /* Now make space on the stack for the args. | |
741 | // OBSOLETE | |
742 | // OBSOLETE XXX This doesn't appear to handle pass-by-invisible reference | |
743 | // OBSOLETE arguments. */ | |
744 | // OBSOLETE for (argnum = 0; argnum < nargs; argnum++) | |
745 | // OBSOLETE { | |
746 | // OBSOLETE int arg_length = (TYPE_LENGTH (VALUE_TYPE (args[argnum])) + 1) & ~1; | |
747 | // OBSOLETE | |
748 | // OBSOLETE /* If we've used all argument registers, then this argument is | |
749 | // OBSOLETE pushed. */ | |
750 | // OBSOLETE if (regsused >= 2 || arg_length > 4) | |
751 | // OBSOLETE { | |
752 | // OBSOLETE regsused = 2; | |
753 | // OBSOLETE len += arg_length; | |
754 | // OBSOLETE } | |
755 | // OBSOLETE /* We know we've got some arg register space left. If this argument | |
756 | // OBSOLETE will fit entirely in regs, then put it there. */ | |
757 | // OBSOLETE else if (arg_length <= 2 | |
758 | // OBSOLETE || TYPE_CODE (VALUE_TYPE (args[argnum])) == TYPE_CODE_PTR) | |
759 | // OBSOLETE { | |
760 | // OBSOLETE regsused++; | |
761 | // OBSOLETE } | |
762 | // OBSOLETE else if (regsused == 0) | |
763 | // OBSOLETE { | |
764 | // OBSOLETE regsused = 2; | |
765 | // OBSOLETE } | |
766 | // OBSOLETE else | |
767 | // OBSOLETE { | |
768 | // OBSOLETE regsused = 2; | |
769 | // OBSOLETE len += arg_length; | |
770 | // OBSOLETE } | |
771 | // OBSOLETE } | |
772 | // OBSOLETE | |
773 | // OBSOLETE /* Allocate stack space. */ | |
774 | // OBSOLETE sp -= len; | |
775 | // OBSOLETE | |
776 | // OBSOLETE regsused = struct_return ? 1 : 0; | |
777 | // OBSOLETE /* Push all arguments onto the stack. */ | |
778 | // OBSOLETE for (argnum = 0; argnum < nargs; argnum++) | |
779 | // OBSOLETE { | |
780 | // OBSOLETE int len; | |
781 | // OBSOLETE char *val; | |
782 | // OBSOLETE | |
783 | // OBSOLETE /* XXX Check this. What about UNIONS? */ | |
784 | // OBSOLETE if (TYPE_CODE (VALUE_TYPE (*args)) == TYPE_CODE_STRUCT | |
785 | // OBSOLETE && TYPE_LENGTH (VALUE_TYPE (*args)) > 8) | |
786 | // OBSOLETE { | |
787 | // OBSOLETE /* XXX Wrong, we want a pointer to this argument. */ | |
788 | // OBSOLETE len = TYPE_LENGTH (VALUE_TYPE (*args)); | |
789 | // OBSOLETE val = (char *) VALUE_CONTENTS (*args); | |
790 | // OBSOLETE } | |
791 | // OBSOLETE else | |
792 | // OBSOLETE { | |
793 | // OBSOLETE len = TYPE_LENGTH (VALUE_TYPE (*args)); | |
794 | // OBSOLETE val = (char *) VALUE_CONTENTS (*args); | |
795 | // OBSOLETE } | |
796 | // OBSOLETE | |
797 | // OBSOLETE if (regsused < 2 | |
798 | // OBSOLETE && (len <= 2 | |
799 | // OBSOLETE || TYPE_CODE (VALUE_TYPE (*args)) == TYPE_CODE_PTR)) | |
800 | // OBSOLETE { | |
801 | // OBSOLETE write_register (regsused, extract_unsigned_integer (val, 4)); | |
802 | // OBSOLETE regsused++; | |
803 | // OBSOLETE } | |
804 | // OBSOLETE else if (regsused == 0 && len == 4) | |
805 | // OBSOLETE { | |
806 | // OBSOLETE write_register (regsused, extract_unsigned_integer (val, 2)); | |
807 | // OBSOLETE write_register (regsused + 1, extract_unsigned_integer (val + 2, 2)); | |
808 | // OBSOLETE regsused = 2; | |
809 | // OBSOLETE } | |
810 | // OBSOLETE else | |
811 | // OBSOLETE { | |
812 | // OBSOLETE regsused = 2; | |
813 | // OBSOLETE while (len > 0) | |
814 | // OBSOLETE { | |
815 | // OBSOLETE write_memory (sp + stack_offset, val, 2); | |
816 | // OBSOLETE | |
817 | // OBSOLETE len -= 2; | |
818 | // OBSOLETE val += 2; | |
819 | // OBSOLETE stack_offset += 2; | |
820 | // OBSOLETE } | |
821 | // OBSOLETE } | |
822 | // OBSOLETE args++; | |
823 | // OBSOLETE } | |
824 | // OBSOLETE | |
825 | // OBSOLETE return sp; | |
826 | // OBSOLETE } | |
827 | // OBSOLETE | |
828 | // OBSOLETE /* Function: push_return_address (pc) | |
829 | // OBSOLETE Set up the return address for the inferior function call. | |
830 | // OBSOLETE Needed for targets where we don't actually execute a JSR/BSR instruction */ | |
831 | // OBSOLETE | |
832 | // OBSOLETE CORE_ADDR | |
833 | // OBSOLETE mn10200_push_return_address (CORE_ADDR pc, CORE_ADDR sp) | |
834 | // OBSOLETE { | |
835 | // OBSOLETE unsigned char buf[4]; | |
836 | // OBSOLETE | |
837 | // OBSOLETE store_unsigned_integer (buf, 4, CALL_DUMMY_ADDRESS ()); | |
838 | // OBSOLETE write_memory (sp - 4, buf, 4); | |
839 | // OBSOLETE return sp - 4; | |
840 | // OBSOLETE } | |
841 | // OBSOLETE | |
842 | // OBSOLETE /* Function: store_struct_return (addr,sp) | |
843 | // OBSOLETE Store the structure value return address for an inferior function | |
844 | // OBSOLETE call. */ | |
845 | // OBSOLETE | |
846 | // OBSOLETE CORE_ADDR | |
847 | // OBSOLETE mn10200_store_struct_return (CORE_ADDR addr, CORE_ADDR sp) | |
848 | // OBSOLETE { | |
849 | // OBSOLETE /* The structure return address is passed as the first argument. */ | |
850 | // OBSOLETE write_register (0, addr); | |
851 | // OBSOLETE return sp; | |
852 | // OBSOLETE } | |
853 | // OBSOLETE | |
854 | // OBSOLETE /* Function: frame_saved_pc | |
855 | // OBSOLETE Find the caller of this frame. We do this by seeing if RP_REGNUM | |
856 | // OBSOLETE is saved in the stack anywhere, otherwise we get it from the | |
857 | // OBSOLETE registers. If the inner frame is a dummy frame, return its PC | |
858 | // OBSOLETE instead of RP, because that's where "caller" of the dummy-frame | |
859 | // OBSOLETE will be found. */ | |
860 | // OBSOLETE | |
861 | // OBSOLETE CORE_ADDR | |
862 | // OBSOLETE mn10200_frame_saved_pc (struct frame_info *fi) | |
863 | // OBSOLETE { | |
864 | // OBSOLETE /* The saved PC will always be at the base of the current frame. */ | |
865 | // OBSOLETE return (read_memory_integer (get_frame_base (fi), REGISTER_SIZE) & 0xffffff); | |
866 | // OBSOLETE } | |
867 | // OBSOLETE | |
868 | // OBSOLETE /* Function: init_extra_frame_info | |
869 | // OBSOLETE Setup the frame's frame pointer, pc, and frame addresses for saved | |
870 | // OBSOLETE registers. Most of the work is done in mn10200_analyze_prologue(). | |
871 | // OBSOLETE | |
872 | // OBSOLETE Note that when we are called for the last frame (currently active frame), | |
873 | // OBSOLETE that get_frame_pc (fi) and fi->frame will already be setup. However, fi->frame will | |
874 | // OBSOLETE be valid only if this routine uses FP. For previous frames, fi-frame will | |
875 | // OBSOLETE always be correct. mn10200_analyze_prologue will fix fi->frame if | |
876 | // OBSOLETE it's not valid. | |
877 | // OBSOLETE | |
878 | // OBSOLETE We can be called with the PC in the call dummy under two circumstances. | |
879 | // OBSOLETE First, during normal backtracing, second, while figuring out the frame | |
880 | // OBSOLETE pointer just prior to calling the target function (see run_stack_dummy). */ | |
881 | // OBSOLETE | |
882 | // OBSOLETE void | |
883 | // OBSOLETE mn10200_init_extra_frame_info (struct frame_info *fi) | |
884 | // OBSOLETE { | |
885 | // OBSOLETE if (get_next_frame (fi)) | |
886 | // OBSOLETE deprecated_update_frame_pc_hack (fi, FRAME_SAVED_PC (get_next_frame (fi))); | |
887 | // OBSOLETE | |
888 | // OBSOLETE memset (fi->fsr.regs, '\000', sizeof fi->fsr.regs); | |
889 | // OBSOLETE fi->status = 0; | |
890 | // OBSOLETE fi->stack_size = 0; | |
891 | // OBSOLETE | |
892 | // OBSOLETE mn10200_analyze_prologue (fi, 0); | |
893 | // OBSOLETE } | |
894 | // OBSOLETE | |
895 | // OBSOLETE void | |
896 | // OBSOLETE _initialize_mn10200_tdep (void) | |
897 | // OBSOLETE { | |
898 | // OBSOLETE tm_print_insn = print_insn_mn10200; | |
899 | // OBSOLETE } |