]>
Commit | Line | Data |
---|---|---|
7cc19214 AC |
1 | /* Get info from stack frames; convert between frames, blocks, |
2 | functions and pc values. | |
3 | ||
4 | Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, | |
5 | 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 Free Software | |
6 | Foundation, Inc. | |
c906108c | 7 | |
c5aa993b | 8 | This file is part of GDB. |
c906108c | 9 | |
c5aa993b JM |
10 | This program is free software; you can redistribute it and/or modify |
11 | it under the terms of the GNU General Public License as published by | |
12 | the Free Software Foundation; either version 2 of the License, or | |
13 | (at your option) any later version. | |
c906108c | 14 | |
c5aa993b JM |
15 | This program is distributed in the hope that it will be useful, |
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 | GNU General Public License for more details. | |
c906108c | 19 | |
c5aa993b JM |
20 | You should have received a copy of the GNU General Public License |
21 | along with this program; if not, write to the Free Software | |
22 | Foundation, Inc., 59 Temple Place - Suite 330, | |
23 | Boston, MA 02111-1307, USA. */ | |
c906108c SS |
24 | |
25 | #include "defs.h" | |
26 | #include "symtab.h" | |
27 | #include "bfd.h" | |
28 | #include "symfile.h" | |
29 | #include "objfiles.h" | |
30 | #include "frame.h" | |
31 | #include "gdbcore.h" | |
32 | #include "value.h" /* for read_register */ | |
33 | #include "target.h" /* for target_has_stack */ | |
34 | #include "inferior.h" /* for read_pc */ | |
35 | #include "annotate.h" | |
4e052eda | 36 | #include "regcache.h" |
4f460812 | 37 | #include "gdb_assert.h" |
c906108c SS |
38 | |
39 | /* Prototypes for exported functions. */ | |
40 | ||
4f460812 AC |
41 | static void generic_call_dummy_register_unwind (struct frame_info *frame, |
42 | void **cache, | |
43 | int regnum, | |
44 | int *optimized, | |
45 | enum lval_type *lval, | |
46 | CORE_ADDR *addrp, | |
47 | int *realnum, | |
48 | void *raw_buffer); | |
49 | static void frame_saved_regs_register_unwind (struct frame_info *frame, | |
50 | void **cache, | |
51 | int regnum, | |
52 | int *optimized, | |
53 | enum lval_type *lval, | |
54 | CORE_ADDR *addrp, | |
55 | int *realnum, | |
56 | void *buffer); | |
57 | ||
58 | ||
53a5351d | 59 | void _initialize_blockframe (void); |
c906108c SS |
60 | |
61 | /* A default FRAME_CHAIN_VALID, in the form that is suitable for most | |
62 | targets. If FRAME_CHAIN_VALID returns zero it means that the given | |
63 | frame is the outermost one and has no caller. */ | |
64 | ||
65 | int | |
fba45db2 | 66 | file_frame_chain_valid (CORE_ADDR chain, struct frame_info *thisframe) |
c906108c SS |
67 | { |
68 | return ((chain) != 0 | |
c4093a6a | 69 | && !inside_entry_file (FRAME_SAVED_PC (thisframe))); |
c906108c SS |
70 | } |
71 | ||
72 | /* Use the alternate method of avoiding running up off the end of the | |
73 | frame chain or following frames back into the startup code. See | |
74 | the comments in objfiles.h. */ | |
c5aa993b | 75 | |
c906108c | 76 | int |
fba45db2 | 77 | func_frame_chain_valid (CORE_ADDR chain, struct frame_info *thisframe) |
c906108c SS |
78 | { |
79 | return ((chain) != 0 | |
c4093a6a JM |
80 | && !inside_main_func ((thisframe)->pc) |
81 | && !inside_entry_func ((thisframe)->pc)); | |
c906108c SS |
82 | } |
83 | ||
84 | /* A very simple method of determining a valid frame */ | |
c5aa993b | 85 | |
c906108c | 86 | int |
fba45db2 | 87 | nonnull_frame_chain_valid (CORE_ADDR chain, struct frame_info *thisframe) |
c906108c SS |
88 | { |
89 | return ((chain) != 0); | |
90 | } | |
91 | ||
92 | /* Is ADDR inside the startup file? Note that if your machine | |
93 | has a way to detect the bottom of the stack, there is no need | |
94 | to call this function from FRAME_CHAIN_VALID; the reason for | |
95 | doing so is that some machines have no way of detecting bottom | |
96 | of stack. | |
97 | ||
98 | A PC of zero is always considered to be the bottom of the stack. */ | |
99 | ||
100 | int | |
fba45db2 | 101 | inside_entry_file (CORE_ADDR addr) |
c906108c SS |
102 | { |
103 | if (addr == 0) | |
104 | return 1; | |
105 | if (symfile_objfile == 0) | |
106 | return 0; | |
7a292a7a SS |
107 | if (CALL_DUMMY_LOCATION == AT_ENTRY_POINT) |
108 | { | |
109 | /* Do not stop backtracing if the pc is in the call dummy | |
c5aa993b | 110 | at the entry point. */ |
7a292a7a | 111 | /* FIXME: Won't always work with zeros for the last two arguments */ |
c5aa993b | 112 | if (PC_IN_CALL_DUMMY (addr, 0, 0)) |
7a292a7a SS |
113 | return 0; |
114 | } | |
c5aa993b JM |
115 | return (addr >= symfile_objfile->ei.entry_file_lowpc && |
116 | addr < symfile_objfile->ei.entry_file_highpc); | |
c906108c SS |
117 | } |
118 | ||
119 | /* Test a specified PC value to see if it is in the range of addresses | |
120 | that correspond to the main() function. See comments above for why | |
121 | we might want to do this. | |
122 | ||
123 | Typically called from FRAME_CHAIN_VALID. | |
124 | ||
125 | A PC of zero is always considered to be the bottom of the stack. */ | |
126 | ||
127 | int | |
fba45db2 | 128 | inside_main_func (CORE_ADDR pc) |
c906108c SS |
129 | { |
130 | if (pc == 0) | |
131 | return 1; | |
132 | if (symfile_objfile == 0) | |
133 | return 0; | |
134 | ||
135 | /* If the addr range is not set up at symbol reading time, set it up now. | |
136 | This is for FRAME_CHAIN_VALID_ALTERNATE. I do this for coff, because | |
137 | it is unable to set it up and symbol reading time. */ | |
138 | ||
c5aa993b JM |
139 | if (symfile_objfile->ei.main_func_lowpc == INVALID_ENTRY_LOWPC && |
140 | symfile_objfile->ei.main_func_highpc == INVALID_ENTRY_HIGHPC) | |
c906108c SS |
141 | { |
142 | struct symbol *mainsym; | |
143 | ||
51cc5b07 | 144 | mainsym = lookup_symbol (main_name (), NULL, VAR_NAMESPACE, NULL, NULL); |
c5aa993b JM |
145 | if (mainsym && SYMBOL_CLASS (mainsym) == LOC_BLOCK) |
146 | { | |
147 | symfile_objfile->ei.main_func_lowpc = | |
c906108c | 148 | BLOCK_START (SYMBOL_BLOCK_VALUE (mainsym)); |
c5aa993b | 149 | symfile_objfile->ei.main_func_highpc = |
c906108c | 150 | BLOCK_END (SYMBOL_BLOCK_VALUE (mainsym)); |
c5aa993b | 151 | } |
c906108c | 152 | } |
c5aa993b JM |
153 | return (symfile_objfile->ei.main_func_lowpc <= pc && |
154 | symfile_objfile->ei.main_func_highpc > pc); | |
c906108c SS |
155 | } |
156 | ||
157 | /* Test a specified PC value to see if it is in the range of addresses | |
158 | that correspond to the process entry point function. See comments | |
159 | in objfiles.h for why we might want to do this. | |
160 | ||
161 | Typically called from FRAME_CHAIN_VALID. | |
162 | ||
163 | A PC of zero is always considered to be the bottom of the stack. */ | |
164 | ||
165 | int | |
fba45db2 | 166 | inside_entry_func (CORE_ADDR pc) |
c906108c SS |
167 | { |
168 | if (pc == 0) | |
169 | return 1; | |
170 | if (symfile_objfile == 0) | |
171 | return 0; | |
7a292a7a SS |
172 | if (CALL_DUMMY_LOCATION == AT_ENTRY_POINT) |
173 | { | |
174 | /* Do not stop backtracing if the pc is in the call dummy | |
c5aa993b | 175 | at the entry point. */ |
7a292a7a SS |
176 | /* FIXME: Won't always work with zeros for the last two arguments */ |
177 | if (PC_IN_CALL_DUMMY (pc, 0, 0)) | |
178 | return 0; | |
179 | } | |
c5aa993b JM |
180 | return (symfile_objfile->ei.entry_func_lowpc <= pc && |
181 | symfile_objfile->ei.entry_func_highpc > pc); | |
c906108c SS |
182 | } |
183 | ||
184 | /* Info about the innermost stack frame (contents of FP register) */ | |
185 | ||
186 | static struct frame_info *current_frame; | |
187 | ||
188 | /* Cache for frame addresses already read by gdb. Valid only while | |
189 | inferior is stopped. Control variables for the frame cache should | |
190 | be local to this module. */ | |
191 | ||
192 | static struct obstack frame_cache_obstack; | |
193 | ||
194 | void * | |
fba45db2 | 195 | frame_obstack_alloc (unsigned long size) |
c906108c SS |
196 | { |
197 | return obstack_alloc (&frame_cache_obstack, size); | |
198 | } | |
199 | ||
200 | void | |
fba45db2 | 201 | frame_saved_regs_zalloc (struct frame_info *fi) |
c906108c | 202 | { |
c5aa993b | 203 | fi->saved_regs = (CORE_ADDR *) |
c906108c SS |
204 | frame_obstack_alloc (SIZEOF_FRAME_SAVED_REGS); |
205 | memset (fi->saved_regs, 0, SIZEOF_FRAME_SAVED_REGS); | |
206 | } | |
207 | ||
208 | ||
209 | /* Return the innermost (currently executing) stack frame. */ | |
210 | ||
211 | struct frame_info * | |
fba45db2 | 212 | get_current_frame (void) |
c906108c SS |
213 | { |
214 | if (current_frame == NULL) | |
215 | { | |
216 | if (target_has_stack) | |
217 | current_frame = create_new_frame (read_fp (), read_pc ()); | |
218 | else | |
219 | error ("No stack."); | |
220 | } | |
221 | return current_frame; | |
222 | } | |
223 | ||
224 | void | |
fba45db2 | 225 | set_current_frame (struct frame_info *frame) |
c906108c SS |
226 | { |
227 | current_frame = frame; | |
228 | } | |
229 | ||
4f460812 AC |
230 | |
231 | /* Using the PC, select a mechanism for unwinding a frame returning | |
232 | the previous frame. The register unwind function should, on | |
233 | demand, initialize the ->context object. */ | |
234 | ||
235 | static void | |
236 | set_unwind_by_pc (CORE_ADDR pc, CORE_ADDR fp, | |
237 | frame_register_unwind_ftype **unwind) | |
238 | { | |
239 | if (!USE_GENERIC_DUMMY_FRAMES) | |
240 | /* Still need to set this to something. The ``info frame'' code | |
241 | calls this function to find out where the saved registers are. | |
242 | Hopefully this is robust enough to stop any core dumps and | |
243 | return vaguely correct values.. */ | |
244 | *unwind = frame_saved_regs_register_unwind; | |
245 | else if (PC_IN_CALL_DUMMY (pc, fp, fp)) | |
246 | *unwind = generic_call_dummy_register_unwind; | |
247 | else | |
248 | *unwind = frame_saved_regs_register_unwind; | |
249 | } | |
250 | ||
c906108c SS |
251 | /* Create an arbitrary (i.e. address specified by user) or innermost frame. |
252 | Always returns a non-NULL value. */ | |
253 | ||
254 | struct frame_info * | |
fba45db2 | 255 | create_new_frame (CORE_ADDR addr, CORE_ADDR pc) |
c906108c SS |
256 | { |
257 | struct frame_info *fi; | |
258 | char *name; | |
259 | ||
260 | fi = (struct frame_info *) | |
261 | obstack_alloc (&frame_cache_obstack, | |
262 | sizeof (struct frame_info)); | |
263 | ||
736d0890 MS |
264 | /* Zero all fields by default. */ |
265 | memset (fi, 0, sizeof (struct frame_info)); | |
266 | ||
c906108c SS |
267 | fi->frame = addr; |
268 | fi->pc = pc; | |
c5aa993b | 269 | find_pc_partial_function (pc, &name, (CORE_ADDR *) NULL, (CORE_ADDR *) NULL); |
d7bd68ca | 270 | fi->signal_handler_caller = PC_IN_SIGTRAMP (fi->pc, name); |
c906108c | 271 | |
5fdff426 AC |
272 | if (INIT_EXTRA_FRAME_INFO_P ()) |
273 | INIT_EXTRA_FRAME_INFO (0, fi); | |
c906108c | 274 | |
4f460812 AC |
275 | /* Select/initialize an unwind function. */ |
276 | set_unwind_by_pc (fi->pc, fi->frame, &fi->register_unwind); | |
277 | ||
c906108c SS |
278 | return fi; |
279 | } | |
280 | ||
c906108c SS |
281 | /* Return the frame that FRAME calls (NULL if FRAME is the innermost |
282 | frame). */ | |
283 | ||
284 | struct frame_info * | |
fba45db2 | 285 | get_next_frame (struct frame_info *frame) |
c906108c SS |
286 | { |
287 | return frame->next; | |
288 | } | |
289 | ||
290 | /* Flush the entire frame cache. */ | |
291 | ||
292 | void | |
fba45db2 | 293 | flush_cached_frames (void) |
c906108c SS |
294 | { |
295 | /* Since we can't really be sure what the first object allocated was */ | |
296 | obstack_free (&frame_cache_obstack, 0); | |
297 | obstack_init (&frame_cache_obstack); | |
298 | ||
c5aa993b | 299 | current_frame = NULL; /* Invalidate cache */ |
0f7d239c | 300 | select_frame (NULL); |
c906108c SS |
301 | annotate_frames_invalid (); |
302 | } | |
303 | ||
304 | /* Flush the frame cache, and start a new one if necessary. */ | |
305 | ||
306 | void | |
fba45db2 | 307 | reinit_frame_cache (void) |
c906108c SS |
308 | { |
309 | flush_cached_frames (); | |
310 | ||
39f77062 KB |
311 | /* FIXME: The inferior_ptid test is wrong if there is a corefile. */ |
312 | if (PIDGET (inferior_ptid) != 0) | |
c906108c | 313 | { |
0f7d239c | 314 | select_frame (get_current_frame ()); |
c906108c SS |
315 | } |
316 | } | |
317 | ||
c906108c SS |
318 | /* Return nonzero if the function for this frame lacks a prologue. Many |
319 | machines can define FRAMELESS_FUNCTION_INVOCATION to just call this | |
320 | function. */ | |
321 | ||
322 | int | |
fba45db2 | 323 | frameless_look_for_prologue (struct frame_info *frame) |
c906108c SS |
324 | { |
325 | CORE_ADDR func_start, after_prologue; | |
53a5351d | 326 | |
c906108c SS |
327 | func_start = get_pc_function_start (frame->pc); |
328 | if (func_start) | |
329 | { | |
330 | func_start += FUNCTION_START_OFFSET; | |
53a5351d JM |
331 | /* This is faster, since only care whether there *is* a |
332 | prologue, not how long it is. */ | |
dad41f9a | 333 | return PROLOGUE_FRAMELESS_P (func_start); |
c906108c SS |
334 | } |
335 | else if (frame->pc == 0) | |
53a5351d JM |
336 | /* A frame with a zero PC is usually created by dereferencing a |
337 | NULL function pointer, normally causing an immediate core dump | |
338 | of the inferior. Mark function as frameless, as the inferior | |
339 | has no chance of setting up a stack frame. */ | |
c906108c SS |
340 | return 1; |
341 | else | |
342 | /* If we can't find the start of the function, we don't really | |
343 | know whether the function is frameless, but we should be able | |
344 | to get a reasonable (i.e. best we can do under the | |
345 | circumstances) backtrace by saying that it isn't. */ | |
346 | return 0; | |
347 | } | |
348 | ||
c906108c SS |
349 | /* Return a structure containing various interesting information |
350 | about the frame that called NEXT_FRAME. Returns NULL | |
351 | if there is no such frame. */ | |
352 | ||
353 | struct frame_info * | |
fba45db2 | 354 | get_prev_frame (struct frame_info *next_frame) |
c906108c SS |
355 | { |
356 | CORE_ADDR address = 0; | |
357 | struct frame_info *prev; | |
358 | int fromleaf = 0; | |
359 | char *name; | |
360 | ||
361 | /* If the requested entry is in the cache, return it. | |
362 | Otherwise, figure out what the address should be for the entry | |
363 | we're about to add to the cache. */ | |
364 | ||
365 | if (!next_frame) | |
366 | { | |
367 | #if 0 | |
368 | /* This screws value_of_variable, which just wants a nice clean | |
c5aa993b JM |
369 | NULL return from block_innermost_frame if there are no frames. |
370 | I don't think I've ever seen this message happen otherwise. | |
371 | And returning NULL here is a perfectly legitimate thing to do. */ | |
c906108c SS |
372 | if (!current_frame) |
373 | { | |
374 | error ("You haven't set up a process's stack to examine."); | |
375 | } | |
376 | #endif | |
377 | ||
378 | return current_frame; | |
379 | } | |
380 | ||
381 | /* If we have the prev one, return it */ | |
382 | if (next_frame->prev) | |
383 | return next_frame->prev; | |
384 | ||
385 | /* On some machines it is possible to call a function without | |
386 | setting up a stack frame for it. On these machines, we | |
387 | define this macro to take two args; a frameinfo pointer | |
388 | identifying a frame and a variable to set or clear if it is | |
389 | or isn't leafless. */ | |
392a587b | 390 | |
c906108c SS |
391 | /* Still don't want to worry about this except on the innermost |
392 | frame. This macro will set FROMLEAF if NEXT_FRAME is a | |
393 | frameless function invocation. */ | |
394 | if (!(next_frame->next)) | |
395 | { | |
392a587b | 396 | fromleaf = FRAMELESS_FUNCTION_INVOCATION (next_frame); |
c906108c SS |
397 | if (fromleaf) |
398 | address = FRAME_FP (next_frame); | |
399 | } | |
c906108c SS |
400 | |
401 | if (!fromleaf) | |
402 | { | |
403 | /* Two macros defined in tm.h specify the machine-dependent | |
c5aa993b JM |
404 | actions to be performed here. |
405 | First, get the frame's chain-pointer. | |
406 | If that is zero, the frame is the outermost frame or a leaf | |
407 | called by the outermost frame. This means that if start | |
408 | calls main without a frame, we'll return 0 (which is fine | |
409 | anyway). | |
410 | ||
411 | Nope; there's a problem. This also returns when the current | |
412 | routine is a leaf of main. This is unacceptable. We move | |
413 | this to after the ffi test; I'd rather have backtraces from | |
414 | start go curfluy than have an abort called from main not show | |
415 | main. */ | |
c906108c SS |
416 | address = FRAME_CHAIN (next_frame); |
417 | if (!FRAME_CHAIN_VALID (address, next_frame)) | |
418 | return 0; | |
c906108c SS |
419 | } |
420 | if (address == 0) | |
421 | return 0; | |
422 | ||
423 | prev = (struct frame_info *) | |
424 | obstack_alloc (&frame_cache_obstack, | |
425 | sizeof (struct frame_info)); | |
426 | ||
bb30608f | 427 | /* Zero all fields by default. */ |
0c8053b6 | 428 | memset (prev, 0, sizeof (struct frame_info)); |
bb30608f | 429 | |
c906108c SS |
430 | if (next_frame) |
431 | next_frame->prev = prev; | |
432 | prev->next = next_frame; | |
c906108c | 433 | prev->frame = address; |
7cc19214 | 434 | prev->level = next_frame->level + 1; |
c906108c SS |
435 | |
436 | /* This change should not be needed, FIXME! We should | |
437 | determine whether any targets *need* INIT_FRAME_PC to happen | |
438 | after INIT_EXTRA_FRAME_INFO and come up with a simple way to | |
439 | express what goes on here. | |
440 | ||
c5aa993b JM |
441 | INIT_EXTRA_FRAME_INFO is called from two places: create_new_frame |
442 | (where the PC is already set up) and here (where it isn't). | |
443 | INIT_FRAME_PC is only called from here, always after | |
444 | INIT_EXTRA_FRAME_INFO. | |
445 | ||
c906108c SS |
446 | The catch is the MIPS, where INIT_EXTRA_FRAME_INFO requires the PC |
447 | value (which hasn't been set yet). Some other machines appear to | |
448 | require INIT_EXTRA_FRAME_INFO before they can do INIT_FRAME_PC. Phoo. | |
449 | ||
450 | We shouldn't need INIT_FRAME_PC_FIRST to add more complication to | |
451 | an already overcomplicated part of GDB. [email protected], 15Sep92. | |
452 | ||
453 | Assuming that some machines need INIT_FRAME_PC after | |
454 | INIT_EXTRA_FRAME_INFO, one possible scheme: | |
455 | ||
456 | SETUP_INNERMOST_FRAME() | |
c5aa993b JM |
457 | Default version is just create_new_frame (read_fp ()), |
458 | read_pc ()). Machines with extra frame info would do that (or the | |
459 | local equivalent) and then set the extra fields. | |
c906108c | 460 | SETUP_ARBITRARY_FRAME(argc, argv) |
c5aa993b JM |
461 | Only change here is that create_new_frame would no longer init extra |
462 | frame info; SETUP_ARBITRARY_FRAME would have to do that. | |
c906108c | 463 | INIT_PREV_FRAME(fromleaf, prev) |
c5aa993b JM |
464 | Replace INIT_EXTRA_FRAME_INFO and INIT_FRAME_PC. This should |
465 | also return a flag saying whether to keep the new frame, or | |
466 | whether to discard it, because on some machines (e.g. mips) it | |
467 | is really awkward to have FRAME_CHAIN_VALID called *before* | |
468 | INIT_EXTRA_FRAME_INFO (there is no good way to get information | |
469 | deduced in FRAME_CHAIN_VALID into the extra fields of the new frame). | |
c906108c | 470 | std_frame_pc(fromleaf, prev) |
c5aa993b JM |
471 | This is the default setting for INIT_PREV_FRAME. It just does what |
472 | the default INIT_FRAME_PC does. Some machines will call it from | |
473 | INIT_PREV_FRAME (either at the beginning, the end, or in the middle). | |
474 | Some machines won't use it. | |
c906108c SS |
475 | [email protected], 13Apr93, 31Jan94, 14Dec94. */ |
476 | ||
c906108c | 477 | INIT_FRAME_PC_FIRST (fromleaf, prev); |
c906108c | 478 | |
e6b47f07 AC |
479 | if (INIT_EXTRA_FRAME_INFO_P ()) |
480 | INIT_EXTRA_FRAME_INFO (fromleaf, prev); | |
c906108c SS |
481 | |
482 | /* This entry is in the frame queue now, which is good since | |
483 | FRAME_SAVED_PC may use that queue to figure out its value | |
484 | (see tm-sparc.h). We want the pc saved in the inferior frame. */ | |
c5aa993b | 485 | INIT_FRAME_PC (fromleaf, prev); |
c906108c SS |
486 | |
487 | /* If ->frame and ->pc are unchanged, we are in the process of getting | |
488 | ourselves into an infinite backtrace. Some architectures check this | |
489 | in FRAME_CHAIN or thereabouts, but it seems like there is no reason | |
490 | this can't be an architecture-independent check. */ | |
491 | if (next_frame != NULL) | |
492 | { | |
493 | if (prev->frame == next_frame->frame | |
494 | && prev->pc == next_frame->pc) | |
495 | { | |
496 | next_frame->prev = NULL; | |
497 | obstack_free (&frame_cache_obstack, prev); | |
498 | return NULL; | |
499 | } | |
500 | } | |
501 | ||
4f460812 AC |
502 | /* Initialize the code used to unwind the frame PREV based on the PC |
503 | (and probably other architectural information). The PC lets you | |
504 | check things like the debug info at that point (dwarf2cfi?) and | |
505 | use that to decide how the frame should be unwound. */ | |
506 | set_unwind_by_pc (prev->pc, prev->frame, &prev->register_unwind); | |
507 | ||
c906108c | 508 | find_pc_partial_function (prev->pc, &name, |
c5aa993b | 509 | (CORE_ADDR *) NULL, (CORE_ADDR *) NULL); |
d7bd68ca | 510 | if (PC_IN_SIGTRAMP (prev->pc, name)) |
c906108c SS |
511 | prev->signal_handler_caller = 1; |
512 | ||
513 | return prev; | |
514 | } | |
515 | ||
516 | CORE_ADDR | |
fba45db2 | 517 | get_frame_pc (struct frame_info *frame) |
c906108c SS |
518 | { |
519 | return frame->pc; | |
520 | } | |
521 | ||
522 | ||
523 | #ifdef FRAME_FIND_SAVED_REGS | |
524 | /* XXX - deprecated. This is a compatibility function for targets | |
525 | that do not yet implement FRAME_INIT_SAVED_REGS. */ | |
526 | /* Find the addresses in which registers are saved in FRAME. */ | |
527 | ||
528 | void | |
fba45db2 KB |
529 | get_frame_saved_regs (struct frame_info *frame, |
530 | struct frame_saved_regs *saved_regs_addr) | |
c906108c SS |
531 | { |
532 | if (frame->saved_regs == NULL) | |
533 | { | |
c5aa993b | 534 | frame->saved_regs = (CORE_ADDR *) |
c906108c SS |
535 | frame_obstack_alloc (SIZEOF_FRAME_SAVED_REGS); |
536 | } | |
537 | if (saved_regs_addr == NULL) | |
538 | { | |
539 | struct frame_saved_regs saved_regs; | |
540 | FRAME_FIND_SAVED_REGS (frame, saved_regs); | |
541 | memcpy (frame->saved_regs, &saved_regs, SIZEOF_FRAME_SAVED_REGS); | |
542 | } | |
543 | else | |
544 | { | |
545 | FRAME_FIND_SAVED_REGS (frame, *saved_regs_addr); | |
546 | memcpy (frame->saved_regs, saved_regs_addr, SIZEOF_FRAME_SAVED_REGS); | |
547 | } | |
548 | } | |
549 | #endif | |
550 | ||
551 | /* Return the innermost lexical block in execution | |
ae767bfb JB |
552 | in a specified stack frame. The frame address is assumed valid. |
553 | ||
554 | If ADDR_IN_BLOCK is non-zero, set *ADDR_IN_BLOCK to the exact code | |
555 | address we used to choose the block. We use this to find a source | |
556 | line, to decide which macro definitions are in scope. | |
557 | ||
558 | The value returned in *ADDR_IN_BLOCK isn't necessarily the frame's | |
559 | PC, and may not really be a valid PC at all. For example, in the | |
560 | caller of a function declared to never return, the code at the | |
561 | return address will never be reached, so the call instruction may | |
562 | be the very last instruction in the block. So the address we use | |
563 | to choose the block is actually one byte before the return address | |
564 | --- hopefully pointing us at the call instruction, or its delay | |
565 | slot instruction. */ | |
c906108c SS |
566 | |
567 | struct block * | |
ae767bfb | 568 | get_frame_block (struct frame_info *frame, CORE_ADDR *addr_in_block) |
c906108c SS |
569 | { |
570 | CORE_ADDR pc; | |
571 | ||
572 | pc = frame->pc; | |
573 | if (frame->next != 0 && frame->next->signal_handler_caller == 0) | |
574 | /* We are not in the innermost frame and we were not interrupted | |
575 | by a signal. We need to subtract one to get the correct block, | |
576 | in case the call instruction was the last instruction of the block. | |
577 | If there are any machines on which the saved pc does not point to | |
578 | after the call insn, we probably want to make frame->pc point after | |
579 | the call insn anyway. */ | |
580 | --pc; | |
ae767bfb JB |
581 | |
582 | if (addr_in_block) | |
583 | *addr_in_block = pc; | |
584 | ||
c906108c SS |
585 | return block_for_pc (pc); |
586 | } | |
587 | ||
588 | struct block * | |
ae767bfb | 589 | get_current_block (CORE_ADDR *addr_in_block) |
c906108c | 590 | { |
ae767bfb JB |
591 | CORE_ADDR pc = read_pc (); |
592 | ||
593 | if (addr_in_block) | |
594 | *addr_in_block = pc; | |
595 | ||
596 | return block_for_pc (pc); | |
c906108c SS |
597 | } |
598 | ||
599 | CORE_ADDR | |
fba45db2 | 600 | get_pc_function_start (CORE_ADDR pc) |
c906108c SS |
601 | { |
602 | register struct block *bl; | |
603 | register struct symbol *symbol; | |
604 | register struct minimal_symbol *msymbol; | |
605 | CORE_ADDR fstart; | |
606 | ||
607 | if ((bl = block_for_pc (pc)) != NULL && | |
608 | (symbol = block_function (bl)) != NULL) | |
609 | { | |
610 | bl = SYMBOL_BLOCK_VALUE (symbol); | |
611 | fstart = BLOCK_START (bl); | |
612 | } | |
613 | else if ((msymbol = lookup_minimal_symbol_by_pc (pc)) != NULL) | |
614 | { | |
615 | fstart = SYMBOL_VALUE_ADDRESS (msymbol); | |
616 | } | |
617 | else | |
618 | { | |
619 | fstart = 0; | |
620 | } | |
621 | return (fstart); | |
622 | } | |
623 | ||
624 | /* Return the symbol for the function executing in frame FRAME. */ | |
625 | ||
626 | struct symbol * | |
fba45db2 | 627 | get_frame_function (struct frame_info *frame) |
c906108c | 628 | { |
ae767bfb | 629 | register struct block *bl = get_frame_block (frame, 0); |
c906108c SS |
630 | if (bl == 0) |
631 | return 0; | |
632 | return block_function (bl); | |
633 | } | |
634 | \f | |
635 | ||
636 | /* Return the blockvector immediately containing the innermost lexical block | |
637 | containing the specified pc value and section, or 0 if there is none. | |
638 | PINDEX is a pointer to the index value of the block. If PINDEX | |
639 | is NULL, we don't pass this information back to the caller. */ | |
640 | ||
641 | struct blockvector * | |
fba45db2 KB |
642 | blockvector_for_pc_sect (register CORE_ADDR pc, struct sec *section, |
643 | int *pindex, struct symtab *symtab) | |
c906108c SS |
644 | { |
645 | register struct block *b; | |
646 | register int bot, top, half; | |
647 | struct blockvector *bl; | |
648 | ||
c5aa993b | 649 | if (symtab == 0) /* if no symtab specified by caller */ |
c906108c SS |
650 | { |
651 | /* First search all symtabs for one whose file contains our pc */ | |
652 | if ((symtab = find_pc_sect_symtab (pc, section)) == 0) | |
653 | return 0; | |
654 | } | |
655 | ||
656 | bl = BLOCKVECTOR (symtab); | |
657 | b = BLOCKVECTOR_BLOCK (bl, 0); | |
658 | ||
659 | /* Then search that symtab for the smallest block that wins. */ | |
660 | /* Use binary search to find the last block that starts before PC. */ | |
661 | ||
662 | bot = 0; | |
663 | top = BLOCKVECTOR_NBLOCKS (bl); | |
664 | ||
665 | while (top - bot > 1) | |
666 | { | |
667 | half = (top - bot + 1) >> 1; | |
668 | b = BLOCKVECTOR_BLOCK (bl, bot + half); | |
669 | if (BLOCK_START (b) <= pc) | |
670 | bot += half; | |
671 | else | |
672 | top = bot + half; | |
673 | } | |
674 | ||
675 | /* Now search backward for a block that ends after PC. */ | |
676 | ||
677 | while (bot >= 0) | |
678 | { | |
679 | b = BLOCKVECTOR_BLOCK (bl, bot); | |
43e526b9 | 680 | if (BLOCK_END (b) > pc) |
c906108c SS |
681 | { |
682 | if (pindex) | |
683 | *pindex = bot; | |
684 | return bl; | |
685 | } | |
686 | bot--; | |
687 | } | |
688 | return 0; | |
689 | } | |
690 | ||
691 | /* Return the blockvector immediately containing the innermost lexical block | |
692 | containing the specified pc value, or 0 if there is none. | |
693 | Backward compatibility, no section. */ | |
694 | ||
695 | struct blockvector * | |
fba45db2 | 696 | blockvector_for_pc (register CORE_ADDR pc, int *pindex) |
c906108c SS |
697 | { |
698 | return blockvector_for_pc_sect (pc, find_pc_mapped_section (pc), | |
699 | pindex, NULL); | |
700 | } | |
701 | ||
702 | /* Return the innermost lexical block containing the specified pc value | |
703 | in the specified section, or 0 if there is none. */ | |
704 | ||
705 | struct block * | |
fba45db2 | 706 | block_for_pc_sect (register CORE_ADDR pc, struct sec *section) |
c906108c SS |
707 | { |
708 | register struct blockvector *bl; | |
709 | int index; | |
710 | ||
711 | bl = blockvector_for_pc_sect (pc, section, &index, NULL); | |
712 | if (bl) | |
713 | return BLOCKVECTOR_BLOCK (bl, index); | |
714 | return 0; | |
715 | } | |
716 | ||
717 | /* Return the innermost lexical block containing the specified pc value, | |
718 | or 0 if there is none. Backward compatibility, no section. */ | |
719 | ||
720 | struct block * | |
fba45db2 | 721 | block_for_pc (register CORE_ADDR pc) |
c906108c SS |
722 | { |
723 | return block_for_pc_sect (pc, find_pc_mapped_section (pc)); | |
724 | } | |
725 | ||
726 | /* Return the function containing pc value PC in section SECTION. | |
727 | Returns 0 if function is not known. */ | |
728 | ||
729 | struct symbol * | |
fba45db2 | 730 | find_pc_sect_function (CORE_ADDR pc, struct sec *section) |
c906108c SS |
731 | { |
732 | register struct block *b = block_for_pc_sect (pc, section); | |
733 | if (b == 0) | |
734 | return 0; | |
735 | return block_function (b); | |
736 | } | |
737 | ||
738 | /* Return the function containing pc value PC. | |
739 | Returns 0 if function is not known. Backward compatibility, no section */ | |
740 | ||
741 | struct symbol * | |
fba45db2 | 742 | find_pc_function (CORE_ADDR pc) |
c906108c SS |
743 | { |
744 | return find_pc_sect_function (pc, find_pc_mapped_section (pc)); | |
745 | } | |
746 | ||
747 | /* These variables are used to cache the most recent result | |
748 | * of find_pc_partial_function. */ | |
749 | ||
c5aa993b JM |
750 | static CORE_ADDR cache_pc_function_low = 0; |
751 | static CORE_ADDR cache_pc_function_high = 0; | |
752 | static char *cache_pc_function_name = 0; | |
c906108c SS |
753 | static struct sec *cache_pc_function_section = NULL; |
754 | ||
755 | /* Clear cache, e.g. when symbol table is discarded. */ | |
756 | ||
757 | void | |
fba45db2 | 758 | clear_pc_function_cache (void) |
c906108c SS |
759 | { |
760 | cache_pc_function_low = 0; | |
761 | cache_pc_function_high = 0; | |
c5aa993b | 762 | cache_pc_function_name = (char *) 0; |
c906108c SS |
763 | cache_pc_function_section = NULL; |
764 | } | |
765 | ||
766 | /* Finds the "function" (text symbol) that is smaller than PC but | |
767 | greatest of all of the potential text symbols in SECTION. Sets | |
768 | *NAME and/or *ADDRESS conditionally if that pointer is non-null. | |
769 | If ENDADDR is non-null, then set *ENDADDR to be the end of the | |
770 | function (exclusive), but passing ENDADDR as non-null means that | |
771 | the function might cause symbols to be read. This function either | |
772 | succeeds or fails (not halfway succeeds). If it succeeds, it sets | |
773 | *NAME, *ADDRESS, and *ENDADDR to real information and returns 1. | |
774 | If it fails, it sets *NAME, *ADDRESS, and *ENDADDR to zero and | |
775 | returns 0. */ | |
776 | ||
777 | int | |
fba45db2 KB |
778 | find_pc_sect_partial_function (CORE_ADDR pc, asection *section, char **name, |
779 | CORE_ADDR *address, CORE_ADDR *endaddr) | |
c906108c SS |
780 | { |
781 | struct partial_symtab *pst; | |
c5aa993b | 782 | struct symbol *f; |
c906108c SS |
783 | struct minimal_symbol *msymbol; |
784 | struct partial_symbol *psb; | |
c5aa993b | 785 | struct obj_section *osect; |
c906108c SS |
786 | int i; |
787 | CORE_ADDR mapped_pc; | |
788 | ||
789 | mapped_pc = overlay_mapped_address (pc, section); | |
790 | ||
c5aa993b | 791 | if (mapped_pc >= cache_pc_function_low && |
c906108c SS |
792 | mapped_pc < cache_pc_function_high && |
793 | section == cache_pc_function_section) | |
794 | goto return_cached_value; | |
795 | ||
796 | /* If sigtramp is in the u area, it counts as a function (especially | |
797 | important for step_1). */ | |
798 | #if defined SIGTRAMP_START | |
d7bd68ca | 799 | if (PC_IN_SIGTRAMP (mapped_pc, (char *) NULL)) |
c906108c | 800 | { |
c5aa993b JM |
801 | cache_pc_function_low = SIGTRAMP_START (mapped_pc); |
802 | cache_pc_function_high = SIGTRAMP_END (mapped_pc); | |
803 | cache_pc_function_name = "<sigtramp>"; | |
c906108c SS |
804 | cache_pc_function_section = section; |
805 | goto return_cached_value; | |
806 | } | |
807 | #endif | |
808 | ||
809 | msymbol = lookup_minimal_symbol_by_pc_section (mapped_pc, section); | |
810 | pst = find_pc_sect_psymtab (mapped_pc, section); | |
811 | if (pst) | |
812 | { | |
813 | /* Need to read the symbols to get a good value for the end address. */ | |
814 | if (endaddr != NULL && !pst->readin) | |
815 | { | |
816 | /* Need to get the terminal in case symbol-reading produces | |
817 | output. */ | |
818 | target_terminal_ours_for_output (); | |
819 | PSYMTAB_TO_SYMTAB (pst); | |
820 | } | |
821 | ||
822 | if (pst->readin) | |
823 | { | |
824 | /* Checking whether the msymbol has a larger value is for the | |
825 | "pathological" case mentioned in print_frame_info. */ | |
826 | f = find_pc_sect_function (mapped_pc, section); | |
827 | if (f != NULL | |
828 | && (msymbol == NULL | |
829 | || (BLOCK_START (SYMBOL_BLOCK_VALUE (f)) | |
830 | >= SYMBOL_VALUE_ADDRESS (msymbol)))) | |
831 | { | |
c5aa993b JM |
832 | cache_pc_function_low = BLOCK_START (SYMBOL_BLOCK_VALUE (f)); |
833 | cache_pc_function_high = BLOCK_END (SYMBOL_BLOCK_VALUE (f)); | |
834 | cache_pc_function_name = SYMBOL_NAME (f); | |
c906108c SS |
835 | cache_pc_function_section = section; |
836 | goto return_cached_value; | |
837 | } | |
838 | } | |
839 | else | |
840 | { | |
841 | /* Now that static symbols go in the minimal symbol table, perhaps | |
842 | we could just ignore the partial symbols. But at least for now | |
843 | we use the partial or minimal symbol, whichever is larger. */ | |
844 | psb = find_pc_sect_psymbol (pst, mapped_pc, section); | |
845 | ||
846 | if (psb | |
847 | && (msymbol == NULL || | |
848 | (SYMBOL_VALUE_ADDRESS (psb) | |
849 | >= SYMBOL_VALUE_ADDRESS (msymbol)))) | |
850 | { | |
851 | /* This case isn't being cached currently. */ | |
852 | if (address) | |
853 | *address = SYMBOL_VALUE_ADDRESS (psb); | |
854 | if (name) | |
855 | *name = SYMBOL_NAME (psb); | |
856 | /* endaddr non-NULL can't happen here. */ | |
857 | return 1; | |
858 | } | |
859 | } | |
860 | } | |
861 | ||
862 | /* Not in the normal symbol tables, see if the pc is in a known section. | |
863 | If it's not, then give up. This ensures that anything beyond the end | |
864 | of the text seg doesn't appear to be part of the last function in the | |
865 | text segment. */ | |
866 | ||
867 | osect = find_pc_sect_section (mapped_pc, section); | |
868 | ||
869 | if (!osect) | |
870 | msymbol = NULL; | |
871 | ||
872 | /* Must be in the minimal symbol table. */ | |
873 | if (msymbol == NULL) | |
874 | { | |
875 | /* No available symbol. */ | |
876 | if (name != NULL) | |
877 | *name = 0; | |
878 | if (address != NULL) | |
879 | *address = 0; | |
880 | if (endaddr != NULL) | |
881 | *endaddr = 0; | |
882 | return 0; | |
883 | } | |
884 | ||
c5aa993b JM |
885 | cache_pc_function_low = SYMBOL_VALUE_ADDRESS (msymbol); |
886 | cache_pc_function_name = SYMBOL_NAME (msymbol); | |
c906108c SS |
887 | cache_pc_function_section = section; |
888 | ||
889 | /* Use the lesser of the next minimal symbol in the same section, or | |
890 | the end of the section, as the end of the function. */ | |
c5aa993b | 891 | |
c906108c SS |
892 | /* Step over other symbols at this same address, and symbols in |
893 | other sections, to find the next symbol in this section with | |
894 | a different address. */ | |
895 | ||
c5aa993b | 896 | for (i = 1; SYMBOL_NAME (msymbol + i) != NULL; i++) |
c906108c | 897 | { |
c5aa993b JM |
898 | if (SYMBOL_VALUE_ADDRESS (msymbol + i) != SYMBOL_VALUE_ADDRESS (msymbol) |
899 | && SYMBOL_BFD_SECTION (msymbol + i) == SYMBOL_BFD_SECTION (msymbol)) | |
c906108c SS |
900 | break; |
901 | } | |
902 | ||
903 | if (SYMBOL_NAME (msymbol + i) != NULL | |
904 | && SYMBOL_VALUE_ADDRESS (msymbol + i) < osect->endaddr) | |
905 | cache_pc_function_high = SYMBOL_VALUE_ADDRESS (msymbol + i); | |
906 | else | |
907 | /* We got the start address from the last msymbol in the objfile. | |
908 | So the end address is the end of the section. */ | |
909 | cache_pc_function_high = osect->endaddr; | |
910 | ||
c5aa993b | 911 | return_cached_value: |
c906108c SS |
912 | |
913 | if (address) | |
914 | { | |
915 | if (pc_in_unmapped_range (pc, section)) | |
c5aa993b | 916 | *address = overlay_unmapped_address (cache_pc_function_low, section); |
c906108c | 917 | else |
c5aa993b | 918 | *address = cache_pc_function_low; |
c906108c | 919 | } |
c5aa993b | 920 | |
c906108c SS |
921 | if (name) |
922 | *name = cache_pc_function_name; | |
923 | ||
924 | if (endaddr) | |
925 | { | |
926 | if (pc_in_unmapped_range (pc, section)) | |
c5aa993b | 927 | { |
c906108c SS |
928 | /* Because the high address is actually beyond the end of |
929 | the function (and therefore possibly beyond the end of | |
930 | the overlay), we must actually convert (high - 1) | |
931 | and then add one to that. */ | |
932 | ||
c5aa993b | 933 | *endaddr = 1 + overlay_unmapped_address (cache_pc_function_high - 1, |
c906108c | 934 | section); |
c5aa993b | 935 | } |
c906108c | 936 | else |
c5aa993b | 937 | *endaddr = cache_pc_function_high; |
c906108c SS |
938 | } |
939 | ||
940 | return 1; | |
941 | } | |
942 | ||
943 | /* Backward compatibility, no section argument */ | |
944 | ||
945 | int | |
fba45db2 KB |
946 | find_pc_partial_function (CORE_ADDR pc, char **name, CORE_ADDR *address, |
947 | CORE_ADDR *endaddr) | |
c906108c | 948 | { |
c5aa993b | 949 | asection *section; |
c906108c SS |
950 | |
951 | section = find_pc_overlay (pc); | |
952 | return find_pc_sect_partial_function (pc, section, name, address, endaddr); | |
953 | } | |
954 | ||
955 | /* Return the innermost stack frame executing inside of BLOCK, | |
956 | or NULL if there is no such frame. If BLOCK is NULL, just return NULL. */ | |
957 | ||
958 | struct frame_info * | |
fba45db2 | 959 | block_innermost_frame (struct block *block) |
c906108c SS |
960 | { |
961 | struct frame_info *frame; | |
962 | register CORE_ADDR start; | |
963 | register CORE_ADDR end; | |
964 | ||
965 | if (block == NULL) | |
966 | return NULL; | |
967 | ||
968 | start = BLOCK_START (block); | |
969 | end = BLOCK_END (block); | |
970 | ||
971 | frame = NULL; | |
972 | while (1) | |
973 | { | |
974 | frame = get_prev_frame (frame); | |
975 | if (frame == NULL) | |
976 | return NULL; | |
977 | if (frame->pc >= start && frame->pc < end) | |
978 | return frame; | |
979 | } | |
980 | } | |
981 | ||
982 | /* Return the full FRAME which corresponds to the given CORE_ADDR | |
983 | or NULL if no FRAME on the chain corresponds to CORE_ADDR. */ | |
984 | ||
985 | struct frame_info * | |
fba45db2 | 986 | find_frame_addr_in_frame_chain (CORE_ADDR frame_addr) |
c906108c SS |
987 | { |
988 | struct frame_info *frame = NULL; | |
989 | ||
c5aa993b | 990 | if (frame_addr == (CORE_ADDR) 0) |
c906108c SS |
991 | return NULL; |
992 | ||
993 | while (1) | |
994 | { | |
995 | frame = get_prev_frame (frame); | |
996 | if (frame == NULL) | |
997 | return NULL; | |
998 | if (FRAME_FP (frame) == frame_addr) | |
999 | return frame; | |
1000 | } | |
1001 | } | |
1002 | ||
1003 | #ifdef SIGCONTEXT_PC_OFFSET | |
1004 | /* Get saved user PC for sigtramp from sigcontext for BSD style sigtramp. */ | |
1005 | ||
1006 | CORE_ADDR | |
fba45db2 | 1007 | sigtramp_saved_pc (struct frame_info *frame) |
c906108c SS |
1008 | { |
1009 | CORE_ADDR sigcontext_addr; | |
35fc8285 | 1010 | char *buf; |
c906108c SS |
1011 | int ptrbytes = TARGET_PTR_BIT / TARGET_CHAR_BIT; |
1012 | int sigcontext_offs = (2 * TARGET_INT_BIT) / TARGET_CHAR_BIT; | |
1013 | ||
35fc8285 | 1014 | buf = alloca (ptrbytes); |
c906108c SS |
1015 | /* Get sigcontext address, it is the third parameter on the stack. */ |
1016 | if (frame->next) | |
1017 | sigcontext_addr = read_memory_integer (FRAME_ARGS_ADDRESS (frame->next) | |
1018 | + FRAME_ARGS_SKIP | |
1019 | + sigcontext_offs, | |
1020 | ptrbytes); | |
1021 | else | |
1022 | sigcontext_addr = read_memory_integer (read_register (SP_REGNUM) | |
c5aa993b | 1023 | + sigcontext_offs, |
c906108c SS |
1024 | ptrbytes); |
1025 | ||
1026 | /* Don't cause a memory_error when accessing sigcontext in case the stack | |
1027 | layout has changed or the stack is corrupt. */ | |
1028 | target_read_memory (sigcontext_addr + SIGCONTEXT_PC_OFFSET, buf, ptrbytes); | |
1029 | return extract_unsigned_integer (buf, ptrbytes); | |
1030 | } | |
1031 | #endif /* SIGCONTEXT_PC_OFFSET */ | |
1032 | ||
7a292a7a SS |
1033 | |
1034 | /* Are we in a call dummy? The code below which allows DECR_PC_AFTER_BREAK | |
1035 | below is for infrun.c, which may give the macro a pc without that | |
1036 | subtracted out. */ | |
1037 | ||
1038 | extern CORE_ADDR text_end; | |
1039 | ||
1040 | int | |
fba45db2 KB |
1041 | pc_in_call_dummy_before_text_end (CORE_ADDR pc, CORE_ADDR sp, |
1042 | CORE_ADDR frame_address) | |
7a292a7a SS |
1043 | { |
1044 | return ((pc) >= text_end - CALL_DUMMY_LENGTH | |
1045 | && (pc) <= text_end + DECR_PC_AFTER_BREAK); | |
1046 | } | |
1047 | ||
1048 | int | |
fba45db2 KB |
1049 | pc_in_call_dummy_after_text_end (CORE_ADDR pc, CORE_ADDR sp, |
1050 | CORE_ADDR frame_address) | |
7a292a7a SS |
1051 | { |
1052 | return ((pc) >= text_end | |
1053 | && (pc) <= text_end + CALL_DUMMY_LENGTH + DECR_PC_AFTER_BREAK); | |
1054 | } | |
1055 | ||
1056 | /* Is the PC in a call dummy? SP and FRAME_ADDRESS are the bottom and | |
1057 | top of the stack frame which we are checking, where "bottom" and | |
1058 | "top" refer to some section of memory which contains the code for | |
1059 | the call dummy. Calls to this macro assume that the contents of | |
1060 | SP_REGNUM and FP_REGNUM (or the saved values thereof), respectively, | |
1061 | are the things to pass. | |
1062 | ||
1063 | This won't work on the 29k, where SP_REGNUM and FP_REGNUM don't | |
1064 | have that meaning, but the 29k doesn't use ON_STACK. This could be | |
1065 | fixed by generalizing this scheme, perhaps by passing in a frame | |
1066 | and adding a few fields, at least on machines which need them for | |
1067 | PC_IN_CALL_DUMMY. | |
1068 | ||
1069 | Something simpler, like checking for the stack segment, doesn't work, | |
1070 | since various programs (threads implementations, gcc nested function | |
1071 | stubs, etc) may either allocate stack frames in another segment, or | |
1072 | allocate other kinds of code on the stack. */ | |
1073 | ||
1074 | int | |
fba45db2 | 1075 | pc_in_call_dummy_on_stack (CORE_ADDR pc, CORE_ADDR sp, CORE_ADDR frame_address) |
7a292a7a SS |
1076 | { |
1077 | return (INNER_THAN ((sp), (pc)) | |
1078 | && (frame_address != 0) | |
1079 | && INNER_THAN ((pc), (frame_address))); | |
1080 | } | |
1081 | ||
1082 | int | |
fba45db2 KB |
1083 | pc_in_call_dummy_at_entry_point (CORE_ADDR pc, CORE_ADDR sp, |
1084 | CORE_ADDR frame_address) | |
7a292a7a SS |
1085 | { |
1086 | return ((pc) >= CALL_DUMMY_ADDRESS () | |
1087 | && (pc) <= (CALL_DUMMY_ADDRESS () + DECR_PC_AFTER_BREAK)); | |
1088 | } | |
1089 | ||
c906108c SS |
1090 | |
1091 | /* | |
1092 | * GENERIC DUMMY FRAMES | |
1093 | * | |
1094 | * The following code serves to maintain the dummy stack frames for | |
1095 | * inferior function calls (ie. when gdb calls into the inferior via | |
1096 | * call_function_by_hand). This code saves the machine state before | |
b7d6b182 | 1097 | * the call in host memory, so we must maintain an independent stack |
c906108c SS |
1098 | * and keep it consistant etc. I am attempting to make this code |
1099 | * generic enough to be used by many targets. | |
1100 | * | |
1101 | * The cheapest and most generic way to do CALL_DUMMY on a new target | |
1102 | * is probably to define CALL_DUMMY to be empty, CALL_DUMMY_LENGTH to | |
1103 | * zero, and CALL_DUMMY_LOCATION to AT_ENTRY. Then you must remember | |
1104 | * to define PUSH_RETURN_ADDRESS, because no call instruction will be | |
1105 | * being executed by the target. Also FRAME_CHAIN_VALID as | |
c4093a6a | 1106 | * generic_{file,func}_frame_chain_valid and FIX_CALL_DUMMY as |
cce74817 | 1107 | * generic_fix_call_dummy. */ |
c906108c | 1108 | |
7a292a7a SS |
1109 | /* Dummy frame. This saves the processor state just prior to setting |
1110 | up the inferior function call. Older targets save the registers | |
72229eb7 | 1111 | on the target stack (but that really slows down function calls). */ |
7a292a7a SS |
1112 | |
1113 | struct dummy_frame | |
1114 | { | |
1115 | struct dummy_frame *next; | |
1116 | ||
1117 | CORE_ADDR pc; | |
1118 | CORE_ADDR fp; | |
1119 | CORE_ADDR sp; | |
43ff13b4 | 1120 | CORE_ADDR top; |
7a292a7a | 1121 | char *registers; |
6096c27a AC |
1122 | |
1123 | /* Address range of the call dummy code. Look for PC in the range | |
1124 | [LO..HI) (after allowing for DECR_PC_AFTER_BREAK). */ | |
1125 | CORE_ADDR call_lo; | |
1126 | CORE_ADDR call_hi; | |
7a292a7a SS |
1127 | }; |
1128 | ||
c906108c SS |
1129 | static struct dummy_frame *dummy_frame_stack = NULL; |
1130 | ||
1131 | /* Function: find_dummy_frame(pc, fp, sp) | |
6096c27a AC |
1132 | |
1133 | Search the stack of dummy frames for one matching the given PC, FP | |
1134 | and SP. Unlike PC_IN_CALL_DUMMY, this function doesn't need to | |
1135 | adjust for DECR_PC_AFTER_BREAK. This is because it is only legal | |
1136 | to call this function after the PC has been adjusted. */ | |
c906108c | 1137 | |
c5aa993b | 1138 | char * |
fba45db2 | 1139 | generic_find_dummy_frame (CORE_ADDR pc, CORE_ADDR fp) |
c906108c | 1140 | { |
c5aa993b | 1141 | struct dummy_frame *dummyframe; |
c906108c | 1142 | |
c906108c SS |
1143 | for (dummyframe = dummy_frame_stack; dummyframe != NULL; |
1144 | dummyframe = dummyframe->next) | |
6096c27a AC |
1145 | if ((pc >= dummyframe->call_lo && pc < dummyframe->call_hi) |
1146 | && (fp == dummyframe->fp | |
1147 | || fp == dummyframe->sp | |
1148 | || fp == dummyframe->top)) | |
c906108c | 1149 | /* The frame in question lies between the saved fp and sp, inclusive */ |
7a292a7a | 1150 | return dummyframe->registers; |
c906108c SS |
1151 | |
1152 | return 0; | |
1153 | } | |
1154 | ||
6096c27a AC |
1155 | /* Function: pc_in_call_dummy (pc, sp, fp) |
1156 | ||
1157 | Return true if the PC falls in a dummy frame created by gdb for an | |
1158 | inferior call. The code below which allows DECR_PC_AFTER_BREAK is | |
1159 | for infrun.c, which may give the function a PC without that | |
1160 | subtracted out. */ | |
c906108c SS |
1161 | |
1162 | int | |
fba45db2 | 1163 | generic_pc_in_call_dummy (CORE_ADDR pc, CORE_ADDR sp, CORE_ADDR fp) |
c906108c | 1164 | { |
6096c27a AC |
1165 | struct dummy_frame *dummyframe; |
1166 | for (dummyframe = dummy_frame_stack; | |
1167 | dummyframe != NULL; | |
1168 | dummyframe = dummyframe->next) | |
1169 | { | |
1170 | if ((pc >= dummyframe->call_lo) | |
1171 | && (pc < dummyframe->call_hi + DECR_PC_AFTER_BREAK)) | |
1172 | return 1; | |
1173 | } | |
1174 | return 0; | |
c906108c SS |
1175 | } |
1176 | ||
1177 | /* Function: read_register_dummy | |
1178 | Find a saved register from before GDB calls a function in the inferior */ | |
1179 | ||
1180 | CORE_ADDR | |
fba45db2 | 1181 | generic_read_register_dummy (CORE_ADDR pc, CORE_ADDR fp, int regno) |
c906108c SS |
1182 | { |
1183 | char *dummy_regs = generic_find_dummy_frame (pc, fp); | |
1184 | ||
1185 | if (dummy_regs) | |
1186 | return extract_address (&dummy_regs[REGISTER_BYTE (regno)], | |
c5aa993b | 1187 | REGISTER_RAW_SIZE (regno)); |
c906108c SS |
1188 | else |
1189 | return 0; | |
1190 | } | |
1191 | ||
1192 | /* Save all the registers on the dummy frame stack. Most ports save the | |
1193 | registers on the target stack. This results in lots of unnecessary memory | |
1194 | references, which are slow when debugging via a serial line. Instead, we | |
1195 | save all the registers internally, and never write them to the stack. The | |
1196 | registers get restored when the called function returns to the entry point, | |
1197 | where a breakpoint is laying in wait. */ | |
1198 | ||
1199 | void | |
fba45db2 | 1200 | generic_push_dummy_frame (void) |
c906108c SS |
1201 | { |
1202 | struct dummy_frame *dummy_frame; | |
1203 | CORE_ADDR fp = (get_current_frame ())->frame; | |
1204 | ||
1205 | /* check to see if there are stale dummy frames, | |
1206 | perhaps left over from when a longjump took us out of a | |
1207 | function that was called by the debugger */ | |
1208 | ||
1209 | dummy_frame = dummy_frame_stack; | |
1210 | while (dummy_frame) | |
1211 | if (INNER_THAN (dummy_frame->fp, fp)) /* stale -- destroy! */ | |
1212 | { | |
1213 | dummy_frame_stack = dummy_frame->next; | |
b8c9b27d KB |
1214 | xfree (dummy_frame->registers); |
1215 | xfree (dummy_frame); | |
c906108c SS |
1216 | dummy_frame = dummy_frame_stack; |
1217 | } | |
1218 | else | |
1219 | dummy_frame = dummy_frame->next; | |
1220 | ||
1221 | dummy_frame = xmalloc (sizeof (struct dummy_frame)); | |
7a292a7a SS |
1222 | dummy_frame->registers = xmalloc (REGISTER_BYTES); |
1223 | ||
4478b372 JB |
1224 | dummy_frame->pc = read_pc (); |
1225 | dummy_frame->sp = read_sp (); | |
c5aa993b JM |
1226 | dummy_frame->top = dummy_frame->sp; |
1227 | dummy_frame->fp = fp; | |
7a292a7a | 1228 | read_register_bytes (0, dummy_frame->registers, REGISTER_BYTES); |
c906108c SS |
1229 | dummy_frame->next = dummy_frame_stack; |
1230 | dummy_frame_stack = dummy_frame; | |
1231 | } | |
1232 | ||
43ff13b4 | 1233 | void |
fba45db2 | 1234 | generic_save_dummy_frame_tos (CORE_ADDR sp) |
43ff13b4 JM |
1235 | { |
1236 | dummy_frame_stack->top = sp; | |
1237 | } | |
1238 | ||
6096c27a AC |
1239 | /* Record the upper/lower bounds on the address of the call dummy. */ |
1240 | ||
1241 | void | |
1242 | generic_save_call_dummy_addr (CORE_ADDR lo, CORE_ADDR hi) | |
1243 | { | |
1244 | dummy_frame_stack->call_lo = lo; | |
1245 | dummy_frame_stack->call_hi = hi; | |
1246 | } | |
1247 | ||
ed9a39eb | 1248 | /* Restore the machine state from either the saved dummy stack or a |
c906108c SS |
1249 | real stack frame. */ |
1250 | ||
1251 | void | |
ed9a39eb | 1252 | generic_pop_current_frame (void (*popper) (struct frame_info * frame)) |
c906108c SS |
1253 | { |
1254 | struct frame_info *frame = get_current_frame (); | |
ed9a39eb | 1255 | |
c5aa993b | 1256 | if (PC_IN_CALL_DUMMY (frame->pc, frame->frame, frame->frame)) |
c906108c SS |
1257 | generic_pop_dummy_frame (); |
1258 | else | |
ed9a39eb | 1259 | (*popper) (frame); |
c906108c SS |
1260 | } |
1261 | ||
1262 | /* Function: pop_dummy_frame | |
1263 | Restore the machine state from a saved dummy stack frame. */ | |
1264 | ||
1265 | void | |
fba45db2 | 1266 | generic_pop_dummy_frame (void) |
c906108c SS |
1267 | { |
1268 | struct dummy_frame *dummy_frame = dummy_frame_stack; | |
1269 | ||
1270 | /* FIXME: what if the first frame isn't the right one, eg.. | |
1271 | because one call-by-hand function has done a longjmp into another one? */ | |
1272 | ||
1273 | if (!dummy_frame) | |
1274 | error ("Can't pop dummy frame!"); | |
1275 | dummy_frame_stack = dummy_frame->next; | |
7a292a7a | 1276 | write_register_bytes (0, dummy_frame->registers, REGISTER_BYTES); |
c906108c | 1277 | flush_cached_frames (); |
7a292a7a | 1278 | |
b8c9b27d KB |
1279 | xfree (dummy_frame->registers); |
1280 | xfree (dummy_frame); | |
c906108c SS |
1281 | } |
1282 | ||
1283 | /* Function: frame_chain_valid | |
1284 | Returns true for a user frame or a call_function_by_hand dummy frame, | |
1285 | and false for the CRT0 start-up frame. Purpose is to terminate backtrace */ | |
c5aa993b | 1286 | |
c906108c | 1287 | int |
fba45db2 | 1288 | generic_file_frame_chain_valid (CORE_ADDR fp, struct frame_info *fi) |
c906108c | 1289 | { |
c5aa993b JM |
1290 | if (PC_IN_CALL_DUMMY (FRAME_SAVED_PC (fi), fp, fp)) |
1291 | return 1; /* don't prune CALL_DUMMY frames */ | |
1292 | else /* fall back to default algorithm (see frame.h) */ | |
c906108c SS |
1293 | return (fp != 0 |
1294 | && (INNER_THAN (fi->frame, fp) || fi->frame == fp) | |
c5aa993b | 1295 | && !inside_entry_file (FRAME_SAVED_PC (fi))); |
c906108c | 1296 | } |
c5aa993b | 1297 | |
c4093a6a | 1298 | int |
fba45db2 | 1299 | generic_func_frame_chain_valid (CORE_ADDR fp, struct frame_info *fi) |
c4093a6a JM |
1300 | { |
1301 | if (PC_IN_CALL_DUMMY ((fi)->pc, fp, fp)) | |
1302 | return 1; /* don't prune CALL_DUMMY frames */ | |
1303 | else /* fall back to default algorithm (see frame.h) */ | |
1304 | return (fp != 0 | |
1305 | && (INNER_THAN (fi->frame, fp) || fi->frame == fp) | |
1306 | && !inside_main_func ((fi)->pc) | |
1307 | && !inside_entry_func ((fi)->pc)); | |
1308 | } | |
1309 | ||
cce74817 | 1310 | /* Function: fix_call_dummy |
c570663e | 1311 | Stub function. Generic dummy frames typically do not need to fix |
cce74817 JM |
1312 | the frame being created */ |
1313 | ||
1314 | void | |
fba45db2 KB |
1315 | generic_fix_call_dummy (char *dummy, CORE_ADDR pc, CORE_ADDR fun, int nargs, |
1316 | struct value **args, struct type *type, int gcc_p) | |
cce74817 JM |
1317 | { |
1318 | return; | |
1319 | } | |
1320 | ||
4f460812 AC |
1321 | /* Given a call-dummy dummy-frame, return the registers. Here the |
1322 | register value is taken from the local copy of the register buffer. */ | |
1323 | ||
1324 | static void | |
1325 | generic_call_dummy_register_unwind (struct frame_info *frame, void **cache, | |
1326 | int regnum, int *optimized, | |
1327 | enum lval_type *lvalp, CORE_ADDR *addrp, | |
1328 | int *realnum, void *bufferp) | |
1329 | { | |
1330 | gdb_assert (frame != NULL); | |
1331 | gdb_assert (PC_IN_CALL_DUMMY (frame->pc, frame->frame, frame->frame)); | |
1332 | ||
1333 | /* Describe the register's location. Generic dummy frames always | |
1334 | have the register value in an ``expression''. */ | |
1335 | *optimized = 0; | |
1336 | *lvalp = not_lval; | |
1337 | *addrp = 0; | |
1338 | *realnum = -1; | |
1339 | ||
1340 | /* If needed, find and return the value of the register. */ | |
1341 | if (bufferp != NULL) | |
1342 | { | |
1343 | char *registers; | |
1344 | #if 1 | |
1345 | /* Get the address of the register buffer that contains all the | |
1346 | saved registers for this dummy frame. Cache that address. */ | |
1347 | registers = (*cache); | |
1348 | if (registers == NULL) | |
1349 | { | |
1350 | registers = generic_find_dummy_frame (frame->pc, frame->frame); | |
1351 | (*cache) = registers; | |
1352 | } | |
1353 | #else | |
1354 | /* Get the address of the register buffer that contains the | |
1355 | saved registers and then extract the value from that. */ | |
1356 | registers = generic_find_dummy_frame (frame->pc, frame->frame); | |
1357 | #endif | |
1358 | gdb_assert (registers != NULL); | |
1359 | /* Return the actual value. */ | |
1360 | memcpy (bufferp, registers + REGISTER_BYTE (regnum), | |
1361 | REGISTER_RAW_SIZE (regnum)); | |
1362 | } | |
1363 | } | |
1364 | ||
1365 | /* Return the register saved in the simplistic ``saved_regs'' cache. | |
1366 | If the value isn't here AND a value is needed, try the next inner | |
1367 | most frame. */ | |
1368 | ||
1369 | static void | |
1370 | frame_saved_regs_register_unwind (struct frame_info *frame, void **cache, | |
1371 | int regnum, int *optimizedp, | |
1372 | enum lval_type *lvalp, CORE_ADDR *addrp, | |
1373 | int *realnump, void *bufferp) | |
1374 | { | |
1375 | /* There is always a frame at this point. And THIS is the frame | |
1376 | we're interested in. */ | |
1377 | gdb_assert (frame != NULL); | |
1378 | gdb_assert (!PC_IN_CALL_DUMMY (frame->pc, frame->frame, frame->frame)); | |
1379 | ||
1380 | /* Load the saved_regs register cache. */ | |
1381 | if (frame->saved_regs == NULL) | |
1382 | FRAME_INIT_SAVED_REGS (frame); | |
1383 | ||
1384 | if (frame->saved_regs != NULL | |
1385 | && frame->saved_regs[regnum] != 0) | |
1386 | { | |
1387 | if (regnum == SP_REGNUM) | |
1388 | { | |
1389 | /* SP register treated specially. */ | |
1390 | *optimizedp = 0; | |
1391 | *lvalp = not_lval; | |
1392 | *addrp = 0; | |
1393 | *realnump = -1; | |
1394 | if (bufferp != NULL) | |
1395 | store_address (bufferp, REGISTER_RAW_SIZE (regnum), | |
1396 | frame->saved_regs[regnum]); | |
1397 | } | |
1398 | else | |
1399 | { | |
1400 | /* Any other register is saved in memory, fetch it but cache | |
1401 | a local copy of its value. */ | |
1402 | *optimizedp = 0; | |
1403 | *lvalp = lval_memory; | |
1404 | *addrp = frame->saved_regs[regnum]; | |
1405 | *realnump = -1; | |
1406 | if (bufferp != NULL) | |
1407 | { | |
1408 | #if 1 | |
1409 | /* Save each register value, as it is read in, in a | |
1410 | frame based cache. */ | |
1411 | void **regs = (*cache); | |
1412 | if (regs == NULL) | |
1413 | { | |
1414 | int sizeof_cache = ((NUM_REGS + NUM_PSEUDO_REGS) | |
1415 | * sizeof (void *)); | |
1416 | regs = frame_obstack_alloc (sizeof_cache); | |
1417 | memset (regs, 0, sizeof_cache); | |
1418 | (*cache) = regs; | |
1419 | } | |
1420 | if (regs[regnum] == NULL) | |
1421 | { | |
1422 | regs[regnum] | |
1423 | = frame_obstack_alloc (REGISTER_RAW_SIZE (regnum)); | |
1424 | read_memory (frame->saved_regs[regnum], regs[regnum], | |
1425 | REGISTER_RAW_SIZE (regnum)); | |
1426 | } | |
1427 | memcpy (bufferp, regs[regnum], REGISTER_RAW_SIZE (regnum)); | |
1428 | #else | |
1429 | /* Read the value in from memory. */ | |
1430 | read_memory (frame->saved_regs[regnum], bufferp, | |
1431 | REGISTER_RAW_SIZE (regnum)); | |
1432 | #endif | |
1433 | } | |
1434 | } | |
1435 | return; | |
1436 | } | |
1437 | ||
1438 | /* No luck, assume this and the next frame have the same register | |
1439 | value. If a value is needed, pass the request on down the chain; | |
1440 | otherwise just return an indication that the value is in the same | |
1441 | register as the next frame. */ | |
1442 | if (bufferp == NULL) | |
1443 | { | |
1444 | *optimizedp = 0; | |
1445 | *lvalp = lval_register; | |
1446 | *addrp = 0; | |
1447 | *realnump = regnum; | |
1448 | } | |
1449 | else | |
1450 | { | |
1451 | frame_register_unwind (frame->next, regnum, optimizedp, lvalp, addrp, | |
1452 | realnump, bufferp); | |
1453 | } | |
1454 | } | |
1455 | ||
c906108c SS |
1456 | /* Function: get_saved_register |
1457 | Find register number REGNUM relative to FRAME and put its (raw, | |
1458 | target format) contents in *RAW_BUFFER. | |
1459 | ||
1460 | Set *OPTIMIZED if the variable was optimized out (and thus can't be | |
1461 | fetched). Note that this is never set to anything other than zero | |
1462 | in this implementation. | |
1463 | ||
1464 | Set *LVAL to lval_memory, lval_register, or not_lval, depending on | |
1465 | whether the value was fetched from memory, from a register, or in a | |
1466 | strange and non-modifiable way (e.g. a frame pointer which was | |
1467 | calculated rather than fetched). We will use not_lval for values | |
1468 | fetched from generic dummy frames. | |
1469 | ||
7036d6ce | 1470 | Set *ADDRP to the address, either in memory or as a REGISTER_BYTE |
c906108c SS |
1471 | offset into the registers array. If the value is stored in a dummy |
1472 | frame, set *ADDRP to zero. | |
1473 | ||
1474 | To use this implementation, define a function called | |
1475 | "get_saved_register" in your target code, which simply passes all | |
1476 | of its arguments to this function. | |
1477 | ||
1478 | The argument RAW_BUFFER must point to aligned memory. */ | |
1479 | ||
1480 | void | |
fba45db2 KB |
1481 | generic_get_saved_register (char *raw_buffer, int *optimized, CORE_ADDR *addrp, |
1482 | struct frame_info *frame, int regnum, | |
1483 | enum lval_type *lval) | |
c906108c SS |
1484 | { |
1485 | if (!target_has_registers) | |
1486 | error ("No registers."); | |
1487 | ||
1488 | /* Normal systems don't optimize out things with register numbers. */ | |
1489 | if (optimized != NULL) | |
1490 | *optimized = 0; | |
1491 | ||
c5aa993b | 1492 | if (addrp) /* default assumption: not found in memory */ |
c906108c SS |
1493 | *addrp = 0; |
1494 | ||
1495 | /* Note: since the current frame's registers could only have been | |
1496 | saved by frames INTERIOR TO the current frame, we skip examining | |
1497 | the current frame itself: otherwise, we would be getting the | |
1498 | previous frame's registers which were saved by the current frame. */ | |
1499 | ||
1500 | while (frame && ((frame = frame->next) != NULL)) | |
1501 | { | |
1502 | if (PC_IN_CALL_DUMMY (frame->pc, frame->frame, frame->frame)) | |
1503 | { | |
c5aa993b | 1504 | if (lval) /* found it in a CALL_DUMMY frame */ |
c906108c SS |
1505 | *lval = not_lval; |
1506 | if (raw_buffer) | |
c5aa993b JM |
1507 | memcpy (raw_buffer, |
1508 | generic_find_dummy_frame (frame->pc, frame->frame) + | |
c906108c SS |
1509 | REGISTER_BYTE (regnum), |
1510 | REGISTER_RAW_SIZE (regnum)); | |
c5aa993b | 1511 | return; |
c906108c SS |
1512 | } |
1513 | ||
1514 | FRAME_INIT_SAVED_REGS (frame); | |
1515 | if (frame->saved_regs != NULL | |
1516 | && frame->saved_regs[regnum] != 0) | |
1517 | { | |
c5aa993b | 1518 | if (lval) /* found it saved on the stack */ |
c906108c SS |
1519 | *lval = lval_memory; |
1520 | if (regnum == SP_REGNUM) | |
1521 | { | |
c5aa993b JM |
1522 | if (raw_buffer) /* SP register treated specially */ |
1523 | store_address (raw_buffer, REGISTER_RAW_SIZE (regnum), | |
c906108c SS |
1524 | frame->saved_regs[regnum]); |
1525 | } | |
1526 | else | |
1527 | { | |
c5aa993b | 1528 | if (addrp) /* any other register */ |
c906108c SS |
1529 | *addrp = frame->saved_regs[regnum]; |
1530 | if (raw_buffer) | |
c5aa993b | 1531 | read_memory (frame->saved_regs[regnum], raw_buffer, |
c906108c SS |
1532 | REGISTER_RAW_SIZE (regnum)); |
1533 | } | |
1534 | return; | |
1535 | } | |
1536 | } | |
1537 | ||
1538 | /* If we get thru the loop to this point, it means the register was | |
1539 | not saved in any frame. Return the actual live-register value. */ | |
1540 | ||
c5aa993b | 1541 | if (lval) /* found it in a live register */ |
c906108c SS |
1542 | *lval = lval_register; |
1543 | if (addrp) | |
1544 | *addrp = REGISTER_BYTE (regnum); | |
1545 | if (raw_buffer) | |
1546 | read_register_gen (regnum, raw_buffer); | |
1547 | } | |
c906108c SS |
1548 | |
1549 | void | |
53a5351d | 1550 | _initialize_blockframe (void) |
c906108c SS |
1551 | { |
1552 | obstack_init (&frame_cache_obstack); | |
1553 | } |