]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/frame.h
gdb: move frame_info_ptr method implementations to frame-info.c
[thirdparty/binutils-gdb.git] / gdb / frame.h
1 /* Definitions for dealing with stack frames, for GDB, the GNU debugger.
2
3 Copyright (C) 1986-2022 Free Software Foundation, Inc.
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20 #if !defined (FRAME_H)
21 #define FRAME_H 1
22
23 #include "frame-info.h"
24
25 /* The following is the intended naming schema for frame functions.
26 It isn't 100% consistent, but it is approaching that. Frame naming
27 schema:
28
29 Prefixes:
30
31 get_frame_WHAT...(): Get WHAT from the THIS frame (functionally
32 equivalent to THIS->next->unwind->what)
33
34 frame_unwind_WHAT...(): Unwind THIS frame's WHAT from the NEXT
35 frame.
36
37 frame_unwind_caller_WHAT...(): Unwind WHAT for NEXT stack frame's
38 real caller. Any inlined functions in NEXT's stack frame are
39 skipped. Use these to ignore any potentially inlined functions,
40 e.g. inlined into the first instruction of a library trampoline.
41
42 get_stack_frame_WHAT...(): Get WHAT for THIS frame, but if THIS is
43 inlined, skip to the containing stack frame.
44
45 put_frame_WHAT...(): Put a value into this frame (unsafe, need to
46 invalidate the frame / regcache afterwards) (better name more
47 strongly hinting at its unsafeness)
48
49 safe_....(): Safer version of various functions, doesn't throw an
50 error (leave this for later?). Returns true / non-NULL if the request
51 succeeds, false / NULL otherwise.
52
53 Suffixes:
54
55 void /frame/_WHAT(): Read WHAT's value into the buffer parameter.
56
57 ULONGEST /frame/_WHAT_unsigned(): Return an unsigned value (the
58 alternative is *frame_unsigned_WHAT).
59
60 LONGEST /frame/_WHAT_signed(): Return WHAT signed value.
61
62 What:
63
64 /frame/_memory* (frame, coreaddr, len [, buf]): Extract/return
65 *memory.
66
67 /frame/_register* (frame, regnum [, buf]): extract/return register.
68
69 CORE_ADDR /frame/_{pc,sp,...} (frame): Resume address, innner most
70 stack *address, ...
71
72 */
73
74 #include "language.h"
75 #include "cli/cli-option.h"
76 #include "gdbsupport/common-debug.h"
77
78 struct symtab_and_line;
79 struct frame_unwind;
80 struct frame_base;
81 struct block;
82 struct gdbarch;
83 struct ui_file;
84 struct ui_out;
85 struct frame_print_options;
86
87 /* The frame object. */
88
89 class frame_info_ptr;
90
91 /* Save and restore the currently selected frame. */
92
93 class scoped_restore_selected_frame
94 {
95 public:
96 /* Save the currently selected frame. */
97 scoped_restore_selected_frame ();
98
99 /* Restore the currently selected frame. */
100 ~scoped_restore_selected_frame ();
101
102 DISABLE_COPY_AND_ASSIGN (scoped_restore_selected_frame);
103
104 private:
105
106 /* The ID and level of the previously selected frame. */
107 struct frame_id m_fid;
108 int m_level;
109
110 /* Save/restore the language as well, because selecting a frame
111 changes the current language to the frame's language if "set
112 language auto". */
113 enum language m_lang;
114 };
115
116 /* Flag to control debugging. */
117
118 extern bool frame_debug;
119
120 /* Print a "frame" debug statement. */
121
122 #define frame_debug_printf(fmt, ...) \
123 debug_prefixed_printf_cond (frame_debug, "frame", fmt, ##__VA_ARGS__)
124
125 /* Print "frame" enter/exit debug statements. */
126
127 #define FRAME_SCOPED_DEBUG_ENTER_EXIT \
128 scoped_debug_enter_exit (frame_debug, "frame")
129
130 /* Construct a frame ID. The first parameter is the frame's constant
131 stack address (typically the outer-bound), and the second the
132 frame's constant code address (typically the entry point).
133 The special identifier address is set to indicate a wild card. */
134 extern struct frame_id frame_id_build (CORE_ADDR stack_addr,
135 CORE_ADDR code_addr);
136
137 /* Construct a special frame ID. The first parameter is the frame's constant
138 stack address (typically the outer-bound), the second is the
139 frame's constant code address (typically the entry point),
140 and the third parameter is the frame's special identifier address. */
141 extern struct frame_id frame_id_build_special (CORE_ADDR stack_addr,
142 CORE_ADDR code_addr,
143 CORE_ADDR special_addr);
144
145 /* Construct a frame ID representing a frame where the stack address
146 exists, but is unavailable. CODE_ADDR is the frame's constant code
147 address (typically the entry point). The special identifier
148 address is set to indicate a wild card. */
149 extern struct frame_id frame_id_build_unavailable_stack (CORE_ADDR code_addr);
150
151 /* Construct a frame ID representing a frame where the stack address
152 exists, but is unavailable. CODE_ADDR is the frame's constant code
153 address (typically the entry point). SPECIAL_ADDR is the special
154 identifier address. */
155 extern struct frame_id
156 frame_id_build_unavailable_stack_special (CORE_ADDR code_addr,
157 CORE_ADDR special_addr);
158
159 /* Construct a wild card frame ID. The parameter is the frame's constant
160 stack address (typically the outer-bound). The code address as well
161 as the special identifier address are set to indicate wild cards. */
162 extern struct frame_id frame_id_build_wild (CORE_ADDR stack_addr);
163
164 /* Returns true when L is a valid frame. */
165 extern bool frame_id_p (frame_id l);
166
167 /* Returns true when L is a valid frame representing a frame made up by GDB
168 without stack data representation in inferior, such as INLINE_FRAME or
169 TAILCALL_FRAME. */
170 extern bool frame_id_artificial_p (frame_id l);
171
172 /* Frame types. Some are real, some are signal trampolines, and some
173 are completely artificial (dummy). */
174
175 enum frame_type
176 {
177 /* A true stack frame, created by the target program during normal
178 execution. */
179 NORMAL_FRAME,
180 /* A fake frame, created by GDB when performing an inferior function
181 call. */
182 DUMMY_FRAME,
183 /* A frame representing an inlined function, associated with an
184 upcoming (prev, outer, older) NORMAL_FRAME. */
185 INLINE_FRAME,
186 /* A virtual frame of a tail call - see dwarf2_tailcall_frame_unwind. */
187 TAILCALL_FRAME,
188 /* In a signal handler, various OSs handle this in various ways.
189 The main thing is that the frame may be far from normal. */
190 SIGTRAMP_FRAME,
191 /* Fake frame representing a cross-architecture call. */
192 ARCH_FRAME,
193 /* Sentinel or registers frame. This frame obtains register values
194 direct from the inferior's registers. */
195 SENTINEL_FRAME
196 };
197
198 /* For every stopped thread, GDB tracks two frames: current and
199 selected. Current frame is the inner most frame of the selected
200 thread. Selected frame is the one being examined by the GDB
201 CLI (selected using `up', `down', ...). The frames are created
202 on-demand (via get_prev_frame()) and then held in a frame cache. */
203 /* FIXME: cagney/2002-11-28: Er, there is a lie here. If you do the
204 sequence: `thread 1; up; thread 2; thread 1' you lose thread 1's
205 selected frame. At present GDB only tracks the selected frame of
206 the current thread. But be warned, that might change. */
207 /* FIXME: cagney/2002-11-14: At any time, only one thread's selected
208 and current frame can be active. Switching threads causes gdb to
209 discard all that cached frame information. Ulgh! Instead, current
210 and selected frame should be bound to a thread. */
211
212 /* On demand, create the inner most frame using information found in
213 the inferior. If the inner most frame can't be created, throw an
214 error. */
215 extern frame_info_ptr get_current_frame (void);
216
217 /* Does the current target interface have enough state to be able to
218 query the current inferior for frame info, and is the inferior in a
219 state where that is possible? */
220 extern bool has_stack_frames ();
221
222 /* Invalidates the frame cache (this function should have been called
223 invalidate_cached_frames).
224
225 FIXME: cagney/2002-11-28: There should be two methods: one that
226 reverts the thread's selected frame back to current frame (for when
227 the inferior resumes) and one that does not (for when the user
228 modifies the target invalidating the frame cache). */
229 extern void reinit_frame_cache (void);
230
231 /* Return the selected frame. Always returns non-NULL. If there
232 isn't an inferior sufficient for creating a frame, an error is
233 thrown. When MESSAGE is non-NULL, use it for the error message,
234 otherwise use a generic error message. */
235 /* FIXME: cagney/2002-11-28: At present, when there is no selected
236 frame, this function always returns the current (inner most) frame.
237 It should instead, when a thread has previously had its frame
238 selected (but not resumed) and the frame cache invalidated, find
239 and then return that thread's previously selected frame. */
240 extern frame_info_ptr get_selected_frame (const char *message = nullptr);
241
242 /* Select a specific frame. NULL implies re-select the inner most
243 frame. */
244 extern void select_frame (frame_info_ptr);
245
246 /* Save the frame ID and frame level of the selected frame in FRAME_ID
247 and FRAME_LEVEL, to be restored later with restore_selected_frame.
248
249 This is preferred over getting the same info out of
250 get_selected_frame directly because this function does not create
251 the selected-frame's frame_info object if it hasn't been created
252 yet, and thus is more efficient and doesn't throw. */
253 extern void save_selected_frame (frame_id *frame_id, int *frame_level)
254 noexcept;
255
256 /* Restore selected frame as saved with save_selected_frame.
257
258 Does not try to find the corresponding frame_info object. Instead
259 the next call to get_selected_frame will look it up and cache the
260 result.
261
262 This function does not throw. It is designed to be safe to called
263 from the destructors of RAII types. */
264 extern void restore_selected_frame (frame_id frame_id, int frame_level)
265 noexcept;
266
267 /* Given a FRAME, return the next (more inner, younger) or previous
268 (more outer, older) frame. */
269 extern frame_info_ptr get_prev_frame (frame_info_ptr);
270 extern frame_info_ptr get_next_frame (frame_info_ptr);
271
272 /* Like get_next_frame(), but allows return of the sentinel frame. NULL
273 is never returned. */
274 extern frame_info_ptr get_next_frame_sentinel_okay (frame_info_ptr);
275
276 /* Return a "struct frame_info" corresponding to the frame that called
277 THIS_FRAME. Returns NULL if there is no such frame.
278
279 Unlike get_prev_frame, this function always tries to unwind the
280 frame. */
281 extern frame_info_ptr get_prev_frame_always (frame_info_ptr);
282
283 /* Given a frame's ID, relocate the frame. Returns NULL if the frame
284 is not found. */
285 extern frame_info_ptr frame_find_by_id (frame_id id);
286
287 /* Base attributes of a frame: */
288
289 /* The frame's `resume' address. Where the program will resume in
290 this frame.
291
292 This replaced: frame->pc; */
293 extern CORE_ADDR get_frame_pc (frame_info_ptr);
294
295 /* Same as get_frame_pc, but return a boolean indication of whether
296 the PC is actually available, instead of throwing an error. */
297
298 extern bool get_frame_pc_if_available (frame_info_ptr frame, CORE_ADDR *pc);
299
300 /* An address (not necessarily aligned to an instruction boundary)
301 that falls within THIS frame's code block.
302
303 When a function call is the last statement in a block, the return
304 address for the call may land at the start of the next block.
305 Similarly, if a no-return function call is the last statement in
306 the function, the return address may end up pointing beyond the
307 function, and possibly at the start of the next function.
308
309 These methods make an allowance for this. For call frames, this
310 function returns the frame's PC-1 which "should" be an address in
311 the frame's block. */
312
313 extern CORE_ADDR get_frame_address_in_block (frame_info_ptr this_frame);
314
315 /* Same as get_frame_address_in_block, but returns a boolean
316 indication of whether the frame address is determinable (when the
317 PC is unavailable, it will not be), instead of possibly throwing an
318 error trying to read an unavailable PC. */
319
320 extern bool get_frame_address_in_block_if_available (frame_info_ptr this_frame,
321 CORE_ADDR *pc);
322
323 /* The frame's inner-most bound. AKA the stack-pointer. Confusingly
324 known as top-of-stack. */
325
326 extern CORE_ADDR get_frame_sp (frame_info_ptr);
327
328 /* Following on from the `resume' address. Return the entry point
329 address of the function containing that resume address, or zero if
330 that function isn't known. */
331 extern CORE_ADDR get_frame_func (frame_info_ptr fi);
332
333 /* Same as get_frame_func, but returns a boolean indication of whether
334 the frame function is determinable (when the PC is unavailable, it
335 will not be), instead of possibly throwing an error trying to read
336 an unavailable PC. */
337
338 extern bool get_frame_func_if_available (frame_info_ptr fi, CORE_ADDR *);
339
340 /* Closely related to the resume address, various symbol table
341 attributes that are determined by the PC. Note that for a normal
342 frame, the PC refers to the resume address after the return, and
343 not the call instruction. In such a case, the address is adjusted
344 so that it (approximately) identifies the call site (and not the
345 return site).
346
347 NOTE: cagney/2002-11-28: The frame cache could be used to cache the
348 computed value. Working on the assumption that the bottle-neck is
349 in the single step code, and that code causes the frame cache to be
350 constantly flushed, caching things in a frame is probably of little
351 benefit. As they say `show us the numbers'.
352
353 NOTE: cagney/2002-11-28: Plenty more where this one came from:
354 find_frame_block(), find_frame_partial_function(),
355 find_frame_symtab(), find_frame_function(). Each will need to be
356 carefully considered to determine if the real intent was for it to
357 apply to the PC or the adjusted PC. */
358 extern symtab_and_line find_frame_sal (frame_info_ptr frame);
359
360 /* Set the current source and line to the location given by frame
361 FRAME, if possible. */
362
363 void set_current_sal_from_frame (frame_info_ptr);
364
365 /* Return the frame base (what ever that is) (DEPRECATED).
366
367 Old code was trying to use this single method for two conflicting
368 purposes. Such code needs to be updated to use either of:
369
370 get_frame_id: A low level frame unique identifier, that consists of
371 both a stack and a function address, that can be used to uniquely
372 identify a frame. This value is determined by the frame's
373 low-level unwinder, the stack part [typically] being the
374 top-of-stack of the previous frame, and the function part being the
375 function's start address. Since the correct identification of a
376 frameless function requires both a stack and function address,
377 the old get_frame_base method was not sufficient.
378
379 get_frame_base_address: get_frame_locals_address:
380 get_frame_args_address: A set of high-level debug-info dependant
381 addresses that fall within the frame. These addresses almost
382 certainly will not match the stack address part of a frame ID (as
383 returned by get_frame_base).
384
385 This replaced: frame->frame; */
386
387 extern CORE_ADDR get_frame_base (frame_info_ptr);
388
389 /* Return the per-frame unique identifer. Can be used to relocate a
390 frame after a frame cache flush (and other similar operations). If
391 FI is NULL, return the null_frame_id. */
392 extern struct frame_id get_frame_id (frame_info_ptr fi);
393 extern struct frame_id get_stack_frame_id (frame_info_ptr fi);
394 extern struct frame_id frame_unwind_caller_id (frame_info_ptr next_frame);
395
396 /* Assuming that a frame is `normal', return its base-address, or 0 if
397 the information isn't available. NOTE: This address is really only
398 meaningful to the frame's high-level debug info. */
399 extern CORE_ADDR get_frame_base_address (frame_info_ptr);
400
401 /* Assuming that a frame is `normal', return the base-address of the
402 local variables, or 0 if the information isn't available. NOTE:
403 This address is really only meaningful to the frame's high-level
404 debug info. Typically, the argument and locals share a single
405 base-address. */
406 extern CORE_ADDR get_frame_locals_address (frame_info_ptr);
407
408 /* Assuming that a frame is `normal', return the base-address of the
409 parameter list, or 0 if that information isn't available. NOTE:
410 This address is really only meaningful to the frame's high-level
411 debug info. Typically, the argument and locals share a single
412 base-address. */
413 extern CORE_ADDR get_frame_args_address (frame_info_ptr);
414
415 /* The frame's level: 0 for innermost, 1 for its caller, ...; or -1
416 for an invalid frame). */
417 extern int frame_relative_level (frame_info_ptr fi);
418
419 /* Return the frame's type. */
420
421 extern enum frame_type get_frame_type (frame_info_ptr);
422
423 /* Return the frame's program space. */
424 extern struct program_space *get_frame_program_space (frame_info_ptr);
425
426 /* Unwind THIS frame's program space from the NEXT frame. */
427 extern struct program_space *frame_unwind_program_space (frame_info_ptr);
428
429 class address_space;
430
431 /* Return the frame's address space. */
432 extern const address_space *get_frame_address_space (frame_info_ptr);
433
434 /* For frames where we can not unwind further, describe why. */
435
436 enum unwind_stop_reason
437 {
438 #define SET(name, description) name,
439 #define FIRST_ENTRY(name) UNWIND_FIRST = name,
440 #define LAST_ENTRY(name) UNWIND_LAST = name,
441 #define FIRST_ERROR(name) UNWIND_FIRST_ERROR = name,
442
443 #include "unwind_stop_reasons.def"
444 #undef SET
445 #undef FIRST_ENTRY
446 #undef LAST_ENTRY
447 #undef FIRST_ERROR
448 };
449
450 /* Return the reason why we can't unwind past this frame. */
451
452 enum unwind_stop_reason get_frame_unwind_stop_reason (frame_info_ptr);
453
454 /* Translate a reason code to an informative string. This converts the
455 generic stop reason codes into a generic string describing the code.
456 For a possibly frame specific string explaining the stop reason, use
457 FRAME_STOP_REASON_STRING instead. */
458
459 const char *unwind_stop_reason_to_string (enum unwind_stop_reason);
460
461 /* Return a possibly frame specific string explaining why the unwind
462 stopped here. E.g., if unwinding tripped on a memory error, this
463 will return the error description string, which includes the address
464 that we failed to access. If there's no specific reason stored for
465 a frame then a generic reason string will be returned.
466
467 Should only be called for frames that don't have a previous frame. */
468
469 const char *frame_stop_reason_string (frame_info_ptr);
470
471 /* Unwind the stack frame so that the value of REGNUM, in the previous
472 (up, older) frame is returned. If VALUEP is NULL, don't
473 fetch/compute the value. Instead just return the location of the
474 value. */
475 extern void frame_register_unwind (frame_info_ptr frame, int regnum,
476 int *optimizedp, int *unavailablep,
477 enum lval_type *lvalp,
478 CORE_ADDR *addrp, int *realnump,
479 gdb_byte *valuep);
480
481 /* Fetch a register from this, or unwind a register from the next
482 frame. Note that the get_frame methods are wrappers to
483 frame->next->unwind. They all [potentially] throw an error if the
484 fetch fails. The value methods never return NULL, but usually
485 do return a lazy value. */
486
487 extern void frame_unwind_register (frame_info_ptr next_frame,
488 int regnum, gdb_byte *buf);
489 extern void get_frame_register (frame_info_ptr frame,
490 int regnum, gdb_byte *buf);
491
492 struct value *frame_unwind_register_value (frame_info_ptr next_frame,
493 int regnum);
494 struct value *get_frame_register_value (frame_info_ptr frame,
495 int regnum);
496
497 extern LONGEST frame_unwind_register_signed (frame_info_ptr next_frame,
498 int regnum);
499 extern LONGEST get_frame_register_signed (frame_info_ptr frame,
500 int regnum);
501 extern ULONGEST frame_unwind_register_unsigned (frame_info_ptr frame,
502 int regnum);
503 extern ULONGEST get_frame_register_unsigned (frame_info_ptr frame,
504 int regnum);
505
506 /* Read a register from this, or unwind a register from the next
507 frame. Note that the read_frame methods are wrappers to
508 get_frame_register_value, that do not throw if the result is
509 optimized out or unavailable. */
510
511 extern bool read_frame_register_unsigned (frame_info_ptr frame,
512 int regnum, ULONGEST *val);
513
514 /* Get the value of the register that belongs to this FRAME. This
515 function is a wrapper to the call sequence ``frame_register_unwind
516 (get_next_frame (FRAME))''. As per frame_register_unwind(), if
517 VALUEP is NULL, the registers value is not fetched/computed. */
518
519 extern void frame_register (frame_info_ptr frame, int regnum,
520 int *optimizedp, int *unavailablep,
521 enum lval_type *lvalp,
522 CORE_ADDR *addrp, int *realnump,
523 gdb_byte *valuep);
524
525 /* The reverse. Store a register value relative to the specified
526 frame. Note: this call makes the frame's state undefined. The
527 register and frame caches must be flushed. */
528 extern void put_frame_register (frame_info_ptr frame, int regnum,
529 const gdb_byte *buf);
530
531 /* Read LEN bytes from one or multiple registers starting with REGNUM
532 in frame FRAME, starting at OFFSET, into BUF. If the register
533 contents are optimized out or unavailable, set *OPTIMIZEDP,
534 *UNAVAILABLEP accordingly. */
535 extern bool get_frame_register_bytes (frame_info_ptr frame, int regnum,
536 CORE_ADDR offset,
537 gdb::array_view<gdb_byte> buffer,
538 int *optimizedp, int *unavailablep);
539
540 /* Write bytes from BUFFER to one or multiple registers starting with REGNUM
541 in frame FRAME, starting at OFFSET. */
542 extern void put_frame_register_bytes (frame_info_ptr frame, int regnum,
543 CORE_ADDR offset,
544 gdb::array_view<const gdb_byte> buffer);
545
546 /* Unwind the PC. Strictly speaking return the resume address of the
547 calling frame. For GDB, `pc' is the resume address and not a
548 specific register. */
549
550 extern CORE_ADDR frame_unwind_caller_pc (frame_info_ptr frame);
551
552 /* Discard the specified frame. Restoring the registers to the state
553 of the caller. */
554 extern void frame_pop (frame_info_ptr frame);
555
556 /* Return memory from the specified frame. A frame knows its thread /
557 LWP and hence can find its way down to a target. The assumption
558 here is that the current and previous frame share a common address
559 space.
560
561 If the memory read fails, these methods throw an error.
562
563 NOTE: cagney/2003-06-03: Should there be unwind versions of these
564 methods? That isn't clear. Can code, for instance, assume that
565 this and the previous frame's memory or architecture are identical?
566 If architecture / memory changes are always separated by special
567 adaptor frames this should be ok. */
568
569 extern void get_frame_memory (frame_info_ptr this_frame, CORE_ADDR addr,
570 gdb::array_view<gdb_byte> buffer);
571 extern LONGEST get_frame_memory_signed (frame_info_ptr this_frame,
572 CORE_ADDR memaddr, int len);
573 extern ULONGEST get_frame_memory_unsigned (frame_info_ptr this_frame,
574 CORE_ADDR memaddr, int len);
575
576 /* Same as above, but return true zero when the entire memory read
577 succeeds, false otherwise. */
578 extern bool safe_frame_unwind_memory (frame_info_ptr this_frame, CORE_ADDR addr,
579 gdb::array_view<gdb_byte> buffer);
580
581 /* Return this frame's architecture. */
582 extern struct gdbarch *get_frame_arch (frame_info_ptr this_frame);
583
584 /* Return the previous frame's architecture. */
585 extern struct gdbarch *frame_unwind_arch (frame_info_ptr next_frame);
586
587 /* Return the previous frame's architecture, skipping inline functions. */
588 extern struct gdbarch *frame_unwind_caller_arch (frame_info_ptr frame);
589
590
591 /* Values for the source flag to be used in print_frame_info ().
592 For all the cases below, the address is never printed if
593 'set print address' is off. When 'set print address' is on,
594 the address is printed if the program counter is not at the
595 beginning of the source line of the frame
596 and PRINT_WHAT is != LOC_AND_ADDRESS. */
597 enum print_what
598 {
599 /* Print only the address, source line, like in stepi. */
600 SRC_LINE = -1,
601 /* Print only the location, i.e. level, address,
602 function, args (as controlled by 'set print frame-arguments'),
603 file, line, line num. */
604 LOCATION,
605 /* Print both of the above. */
606 SRC_AND_LOC,
607 /* Print location only, print the address even if the program counter
608 is at the beginning of the source line. */
609 LOC_AND_ADDRESS,
610 /* Print only level and function,
611 i.e. location only, without address, file, line, line num. */
612 SHORT_LOCATION
613 };
614
615 /* Allocate zero initialized memory from the frame cache obstack.
616 Appendices to the frame info (such as the unwind cache) should
617 allocate memory using this method. */
618
619 extern void *frame_obstack_zalloc (unsigned long size);
620 #define FRAME_OBSTACK_ZALLOC(TYPE) \
621 ((TYPE *) frame_obstack_zalloc (sizeof (TYPE)))
622 #define FRAME_OBSTACK_CALLOC(NUMBER,TYPE) \
623 ((TYPE *) frame_obstack_zalloc ((NUMBER) * sizeof (TYPE)))
624
625 class readonly_detached_regcache;
626 /* Create a regcache, and copy the frame's registers into it. */
627 std::unique_ptr<readonly_detached_regcache> frame_save_as_regcache
628 (frame_info_ptr this_frame);
629
630 extern const struct block *get_frame_block (frame_info_ptr,
631 CORE_ADDR *addr_in_block);
632
633 /* Return the `struct block' that belongs to the selected thread's
634 selected frame. If the inferior has no state, return NULL.
635
636 NOTE: cagney/2002-11-29:
637
638 No state? Does the inferior have any execution state (a core file
639 does, an executable does not). At present the code tests
640 `target_has_stack' but I'm left wondering if it should test
641 `target_has_registers' or, even, a merged target_has_state.
642
643 Should it look at the most recently specified SAL? If the target
644 has no state, should this function try to extract a block from the
645 most recently selected SAL? That way `list foo' would give it some
646 sort of reference point. Then again, perhaps that would confuse
647 things.
648
649 Calls to this function can be broken down into two categories: Code
650 that uses the selected block as an additional, but optional, data
651 point; Code that uses the selected block as a prop, when it should
652 have the relevant frame/block/pc explicitly passed in.
653
654 The latter can be eliminated by correctly parameterizing the code,
655 the former though is more interesting. Per the "address" command,
656 it occurs in the CLI code and makes it possible for commands to
657 work, even when the inferior has no state. */
658
659 extern const struct block *get_selected_block (CORE_ADDR *addr_in_block);
660
661 extern struct symbol *get_frame_function (frame_info_ptr);
662
663 extern CORE_ADDR get_pc_function_start (CORE_ADDR);
664
665 extern frame_info_ptr find_relative_frame (frame_info_ptr, int *);
666
667 /* Wrapper over print_stack_frame modifying current_uiout with UIOUT for
668 the function call. */
669
670 extern void print_stack_frame_to_uiout (struct ui_out *uiout,
671 frame_info_ptr, int print_level,
672 enum print_what print_what,
673 int set_current_sal);
674
675 extern void print_stack_frame (frame_info_ptr, int print_level,
676 enum print_what print_what,
677 int set_current_sal);
678
679 extern void print_frame_info (const frame_print_options &fp_opts,
680 frame_info_ptr, int print_level,
681 enum print_what print_what, int args,
682 int set_current_sal);
683
684 extern frame_info_ptr block_innermost_frame (const struct block *);
685
686 extern bool deprecated_frame_register_read (frame_info_ptr frame, int regnum,
687 gdb_byte *buf);
688
689 /* From stack.c. */
690
691 /* The possible choices of "set print frame-arguments". */
692 extern const char print_frame_arguments_all[];
693 extern const char print_frame_arguments_scalars[];
694 extern const char print_frame_arguments_none[];
695
696 /* The possible choices of "set print frame-info". */
697 extern const char print_frame_info_auto[];
698 extern const char print_frame_info_source_line[];
699 extern const char print_frame_info_location[];
700 extern const char print_frame_info_source_and_location[];
701 extern const char print_frame_info_location_and_address[];
702 extern const char print_frame_info_short_location[];
703
704 /* The possible choices of "set print entry-values". */
705 extern const char print_entry_values_no[];
706 extern const char print_entry_values_only[];
707 extern const char print_entry_values_preferred[];
708 extern const char print_entry_values_if_needed[];
709 extern const char print_entry_values_both[];
710 extern const char print_entry_values_compact[];
711 extern const char print_entry_values_default[];
712
713 /* Data for the frame-printing "set print" settings exposed as command
714 options. */
715
716 struct frame_print_options
717 {
718 const char *print_frame_arguments = print_frame_arguments_scalars;
719 const char *print_frame_info = print_frame_info_auto;
720 const char *print_entry_values = print_entry_values_default;
721
722 /* If true, don't invoke pretty-printers for frame
723 arguments. */
724 bool print_raw_frame_arguments;
725 };
726
727 /* The values behind the global "set print ..." settings. */
728 extern frame_print_options user_frame_print_options;
729
730 /* Inferior function parameter value read in from a frame. */
731
732 struct frame_arg
733 {
734 /* Symbol for this parameter used for example for its name. */
735 struct symbol *sym = nullptr;
736
737 /* Value of the parameter. It is NULL if ERROR is not NULL; if both VAL and
738 ERROR are NULL this parameter's value should not be printed. */
739 struct value *val = nullptr;
740
741 /* String containing the error message, it is more usually NULL indicating no
742 error occured reading this parameter. */
743 gdb::unique_xmalloc_ptr<char> error;
744
745 /* One of the print_entry_values_* entries as appropriate specifically for
746 this frame_arg. It will be different from print_entry_values. With
747 print_entry_values_no this frame_arg should be printed as a normal
748 parameter. print_entry_values_only says it should be printed as entry
749 value parameter. print_entry_values_compact says it should be printed as
750 both as a normal parameter and entry values parameter having the same
751 value - print_entry_values_compact is not permitted fi ui_out_is_mi_like_p
752 (in such case print_entry_values_no and print_entry_values_only is used
753 for each parameter kind specifically. */
754 const char *entry_kind = nullptr;
755 };
756
757 extern void read_frame_arg (const frame_print_options &fp_opts,
758 symbol *sym, frame_info_ptr frame,
759 struct frame_arg *argp,
760 struct frame_arg *entryargp);
761 extern void read_frame_local (struct symbol *sym, frame_info_ptr frame,
762 struct frame_arg *argp);
763
764 extern void info_args_command (const char *, int);
765
766 extern void info_locals_command (const char *, int);
767
768 extern void return_command (const char *, int);
769
770 /* Set FRAME's unwinder temporarily, so that we can call a sniffer.
771 If sniffing fails, the caller should be sure to call
772 frame_cleanup_after_sniffer. */
773
774 extern void frame_prepare_for_sniffer (frame_info_ptr frame,
775 const struct frame_unwind *unwind);
776
777 /* Clean up after a failed (wrong unwinder) attempt to unwind past
778 FRAME. */
779
780 extern void frame_cleanup_after_sniffer (frame_info_ptr frame);
781
782 /* Notes (cagney/2002-11-27, drow/2003-09-06):
783
784 You might think that calls to this function can simply be replaced by a
785 call to get_selected_frame().
786
787 Unfortunately, it isn't that easy.
788
789 The relevant code needs to be audited to determine if it is
790 possible (or practical) to instead pass the applicable frame in as a
791 parameter. For instance, DEPRECATED_DO_REGISTERS_INFO() relied on
792 the deprecated_selected_frame global, while its replacement,
793 PRINT_REGISTERS_INFO(), is parameterized with the selected frame.
794 The only real exceptions occur at the edge (in the CLI code) where
795 user commands need to pick up the selected frame before proceeding.
796
797 There are also some functions called with a NULL frame meaning either "the
798 program is not running" or "use the selected frame".
799
800 This is important. GDB is trying to stamp out the hack:
801
802 saved_frame = deprecated_safe_get_selected_frame ();
803 select_frame (...);
804 hack_using_global_selected_frame ();
805 select_frame (saved_frame);
806
807 Take care!
808
809 This function calls get_selected_frame if the inferior should have a
810 frame, or returns NULL otherwise. */
811
812 extern frame_info_ptr deprecated_safe_get_selected_frame (void);
813
814 /* Create a frame using the specified BASE and PC. */
815
816 extern frame_info_ptr create_new_frame (CORE_ADDR base, CORE_ADDR pc);
817
818 /* Return true if the frame unwinder for frame FI is UNWINDER; false
819 otherwise. */
820
821 extern bool frame_unwinder_is (frame_info_ptr fi, const frame_unwind *unwinder);
822
823 /* Return the language of FRAME. */
824
825 extern enum language get_frame_language (frame_info_ptr frame);
826
827 /* Return the first non-tailcall frame above FRAME or FRAME if it is not a
828 tailcall frame. Return NULL if FRAME is the start of a tailcall-only
829 chain. */
830
831 extern frame_info_ptr skip_tailcall_frames (frame_info_ptr frame);
832
833 /* Return the first frame above FRAME or FRAME of which the code is
834 writable. */
835
836 extern frame_info_ptr skip_unwritable_frames (frame_info_ptr frame);
837
838 /* Data for the "set backtrace" settings. */
839
840 struct set_backtrace_options
841 {
842 /* Flag to indicate whether backtraces should continue past
843 main. */
844 bool backtrace_past_main = false;
845
846 /* Flag to indicate whether backtraces should continue past
847 entry. */
848 bool backtrace_past_entry = false;
849
850 /* Upper bound on the number of backtrace levels. Note this is not
851 exposed as a command option, because "backtrace" and "frame
852 apply" already have other means to set a frame count limit. */
853 unsigned int backtrace_limit = UINT_MAX;
854 };
855
856 /* The corresponding option definitions. */
857 extern const gdb::option::option_def set_backtrace_option_defs[2];
858
859 /* The values behind the global "set backtrace ..." settings. */
860 extern set_backtrace_options user_set_backtrace_options;
861
862 /* Get the number of calls to reinit_frame_cache. */
863
864 unsigned int get_frame_cache_generation ();
865
866 /* Mark that the PC value is masked for the previous frame. */
867
868 extern void set_frame_previous_pc_masked (frame_info_ptr frame);
869
870 /* Get whether the PC value is masked for the given frame. */
871
872 extern bool get_frame_pc_masked (frame_info_ptr frame);
873
874
875 #endif /* !defined (FRAME_H) */