GDB (xrefs)
Loading...
Searching...
No Matches
/tmp/gdb-13.1/gdb/frame.c
Go to the documentation of this file.
1/* Cache and manage frames for GDB, the GNU debugger.
2
3 Copyright (C) 1986-2023 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#include "defs.h"
21#include "frame.h"
22#include "frame-info.h"
23#include "target.h"
24#include "value.h"
25#include "inferior.h" /* for inferior_ptid */
26#include "regcache.h"
27#include "user-regs.h"
28#include "gdbsupport/gdb_obstack.h"
29#include "dummy-frame.h"
30#include "sentinel-frame.h"
31#include "gdbcore.h"
32#include "annotate.h"
33#include "language.h"
34#include "frame-unwind.h"
35#include "frame-base.h"
36#include "command.h"
37#include "gdbcmd.h"
38#include "observable.h"
39#include "objfiles.h"
40#include "gdbthread.h"
41#include "block.h"
42#include "inline-frame.h"
43#include "tracepoint.h"
44#include "hashtab.h"
45#include "valprint.h"
46#include "cli/cli-option.h"
47
48/* The sentinel frame terminates the innermost end of the frame chain.
49 If unwound, it returns the information needed to construct an
50 innermost frame.
51
52 The current frame, which is the innermost frame, can be found at
53 sentinel_frame->prev. */
54
56
57/* Number of calls to reinit_frame_cache. */
58static unsigned int frame_cache_generation = 0;
59
60/* See frame.h. */
61
62unsigned int
64{
66}
67
68/* The values behind the global "set backtrace ..." settings. */
70
72static const char *frame_stop_reason_symbol_string (enum unwind_stop_reason reason);
73
74/* Status of some values cached in the frame_info object. */
75
77{
78 /* Value is unknown. */
80
81 /* We have a value. */
83
84 /* Value was not saved. */
86
87 /* Value is unavailable. */
89};
90
92{
93 /* Frame id is not computed. */
94 NOT_COMPUTED = 0,
95
96 /* Frame id is being computed (compute_frame_id is active). */
98
99 /* Frame id has been computed. */
100 COMPUTED,
101};
102
103/* We keep a cache of stack frames, each of which is a "struct
104 frame_info". The innermost one gets allocated (in
105 wait_for_inferior) each time the inferior stops; sentinel_frame
106 points to it. Additional frames get allocated (in get_prev_frame)
107 as needed, and are chained through the next and prev fields. Any
108 time that the frame cache becomes invalid (most notably when we
109 execute something, but also if we change how we interpret the
110 frames (e.g. "set heuristic-fence-post" in mips-tdep.c, or anything
111 which reads new symbols)), we should call reinit_frame_cache. */
112
114{
115 /* Return a string representation of this frame. */
116 std::string to_string () const;
117
118 /* Level of this frame. The inner-most (youngest) frame is at level
119 0. As you move towards the outer-most (oldest) frame, the level
120 increases. This is a cached value. It could just as easily be
121 computed by counting back from the selected frame to the inner
122 most frame. */
123 /* NOTE: cagney/2002-04-05: Perhaps a level of ``-1'' should be
124 reserved to indicate a bogus frame - one that has been created
125 just to keep GDB happy (GDB always needs a frame). For the
126 moment leave this as speculation. */
127 int level;
128
129 /* The frame's program space. */
131
132 /* The frame's address space. */
134
135 /* The frame's low-level unwinder and corresponding cache. The
136 low-level unwinder is responsible for unwinding register values
137 for the previous frame. The low-level unwind methods are
138 selected based on the presence, or otherwise, of register unwind
139 information such as CFI. */
141 const struct frame_unwind *unwind;
142
143 /* Cached copy of the previous frame's architecture. */
144 struct
145 {
146 bool p;
147 struct gdbarch *arch;
149
150 /* Cached copy of the previous frame's resume address. */
151 struct {
153 /* Did VALUE require unmasking when being read. */
154 bool masked;
155 CORE_ADDR value;
157
158 /* Cached copy of the previous frame's function address. */
159 struct
160 {
161 CORE_ADDR addr;
164
165 /* This frame's ID. */
166 struct
167 {
171
172 /* The frame's high-level base methods, and corresponding cache.
173 The high level base methods are selected based on the frame's
174 debug info. */
175 const struct frame_base *base;
177
178 /* Pointers to the next (down, inner, younger) and previous (up,
179 outer, older) frame_info's in the frame cache. */
180 struct frame_info *next; /* down, inner, younger */
181 bool prev_p;
182 struct frame_info *prev; /* up, outer, older */
183
184 /* The reason why we could not set PREV, or UNWIND_NO_REASON if we
185 could. Only valid when PREV_P is set. */
187
188 /* A frame specific string describing the STOP_REASON in more detail.
189 Only valid when PREV_P is set, but even then may still be NULL. */
190 const char *stop_string;
191};
192
193/* See frame.h. */
194
195void
197{
198 frame->prev_pc.masked = true;
199}
200
201/* See frame.h. */
202
203bool
205{
206 gdb_assert (frame->next != nullptr);
207 gdb_assert (frame->next->prev_pc.status == CC_VALUE);
208
209 return frame->next->prev_pc.masked;
210}
211
212/* A frame stash used to speed up frame lookups. Create a hash table
213 to stash frames previously accessed from the frame cache for
214 quicker subsequent retrieval. The hash table is emptied whenever
215 the frame cache is invalidated. */
216
217static htab_t frame_stash;
218
219/* Internal function to calculate a hash from the frame_id addresses,
220 using as many valid addresses as possible. Frames below level 0
221 are not stored in the hash table. */
222
223static hashval_t
224frame_addr_hash (const void *ap)
225{
226 const frame_info *frame = (const frame_info *) ap;
227 const struct frame_id f_id = frame->this_id.value;
228 hashval_t hash = 0;
229
230 gdb_assert (f_id.stack_status != FID_STACK_INVALID
231 || f_id.code_addr_p
232 || f_id.special_addr_p);
233
234 if (f_id.stack_status == FID_STACK_VALID)
235 hash = iterative_hash (&f_id.stack_addr,
236 sizeof (f_id.stack_addr), hash);
237 if (f_id.code_addr_p)
238 hash = iterative_hash (&f_id.code_addr,
239 sizeof (f_id.code_addr), hash);
240 if (f_id.special_addr_p)
241 hash = iterative_hash (&f_id.special_addr,
242 sizeof (f_id.special_addr), hash);
243
244 return hash;
245}
246
247/* Internal equality function for the hash table. This function
248 defers equality operations to frame_id::operator==. */
249
250static int
251frame_addr_hash_eq (const void *a, const void *b)
252{
253 const frame_info *f_entry = (const frame_info *) a;
254 const frame_info *f_element = (const frame_info *) b;
255
256 return f_entry->this_id.value == f_element->this_id.value;
257}
258
259/* Internal function to create the frame_stash hash table. 100 seems
260 to be a good compromise to start the hash table at. */
261
262static void
264{
265 frame_stash = htab_create (100,
268 NULL);
269}
270
271/* Internal function to add a frame to the frame_stash hash table.
272 Returns false if a frame with the same ID was already stashed, true
273 otherwise. */
274
275static bool
277{
278 /* Do not try to stash the sentinel frame. */
279 gdb_assert (frame->level >= 0);
280
281 frame_info **slot = (frame_info **) htab_find_slot (frame_stash,
282 frame, INSERT);
283
284 /* If we already have a frame in the stack with the same id, we
285 either have a stack cycle (corrupted stack?), or some bug
286 elsewhere in GDB. In any case, ignore the duplicate and return
287 an indication to the caller. */
288 if (*slot != nullptr)
289 return false;
290
291 *slot = frame;
292 return true;
293}
294
295/* Internal function to search the frame stash for an entry with the
296 given frame ID. If found, return that frame. Otherwise return
297 NULL. */
298
299static frame_info_ptr
301{
302 struct frame_info dummy;
303 frame_info *frame;
304
305 dummy.this_id.value = id;
306 frame = (frame_info *) htab_find (frame_stash, &dummy);
307 return frame_info_ptr (frame);
308}
309
310/* Internal function to invalidate the frame stash by removing all
311 entries in it. This only occurs when the frame cache is
312 invalidated. */
313
314static void
316{
317 htab_empty (frame_stash);
318}
319
320/* See frame.h */
322{
325}
326
327/* See frame.h */
329{
332}
333
334/* Flag to control debugging. */
335
337
338static void
339show_frame_debug (struct ui_file *file, int from_tty,
340 struct cmd_list_element *c, const char *value)
341{
342 gdb_printf (file, _("Frame debugging is %s.\n"), value);
343}
344
345/* Implementation of "show backtrace past-main". */
346
347static void
348show_backtrace_past_main (struct ui_file *file, int from_tty,
349 struct cmd_list_element *c, const char *value)
350{
351 gdb_printf (file,
352 _("Whether backtraces should "
353 "continue past \"main\" is %s.\n"),
354 value);
355}
356
357/* Implementation of "show backtrace past-entry". */
358
359static void
360show_backtrace_past_entry (struct ui_file *file, int from_tty,
361 struct cmd_list_element *c, const char *value)
362{
363 gdb_printf (file, _("Whether backtraces should continue past the "
364 "entry point of a program is %s.\n"),
365 value);
366}
367
368/* Implementation of "show backtrace limit". */
369
370static void
371show_backtrace_limit (struct ui_file *file, int from_tty,
372 struct cmd_list_element *c, const char *value)
373{
374 gdb_printf (file,
375 _("An upper bound on the number "
376 "of backtrace levels is %s.\n"),
377 value);
378}
379
380/* See frame.h. */
381
382std::string
384{
385 const struct frame_id &id = *this;
386
387 std::string res = "{";
388
390 res += "!stack";
391 else if (id.stack_status == FID_STACK_UNAVAILABLE)
392 res += "stack=<unavailable>";
393 else if (id.stack_status == FID_STACK_SENTINEL)
394 res += "stack=<sentinel>";
395 else if (id.stack_status == FID_STACK_OUTER)
396 res += "stack=<outer>";
397 else
398 res += std::string ("stack=") + hex_string (id.stack_addr);
399
400 /* Helper function to format 'N=A' if P is true, otherwise '!N'. */
401 auto field_to_string = [] (const char *n, bool p, CORE_ADDR a) -> std::string
402 {
403 if (p)
404 return std::string (n) + "=" + core_addr_to_string (a);
405 else
406 return std::string ("!") + std::string (n);
407 };
408
409 res += (std::string (",")
410 + field_to_string ("code", id.code_addr_p, id.code_addr)
411 + std::string (",")
412 + field_to_string ("special", id.special_addr_p, id.special_addr));
413
414 if (id.artificial_depth)
415 res += ",artificial=" + std::to_string (id.artificial_depth);
416 res += "}";
417 return res;
418}
419
420/* Return a string representation of TYPE. */
421
422static const char *
424{
425 switch (type)
426 {
427 case NORMAL_FRAME:
428 return "NORMAL_FRAME";
429
430 case DUMMY_FRAME:
431 return "DUMMY_FRAME";
432
433 case INLINE_FRAME:
434 return "INLINE_FRAME";
435
436 case TAILCALL_FRAME:
437 return "TAILCALL_FRAME";
438
439 case SIGTRAMP_FRAME:
440 return "SIGTRAMP_FRAME";
441
442 case ARCH_FRAME:
443 return "ARCH_FRAME";
444
445 case SENTINEL_FRAME:
446 return "SENTINEL_FRAME";
447
448 default:
449 return "<unknown type>";
450 };
451}
452
453 /* See struct frame_info. */
454
455std::string
457{
458 const frame_info *fi = this;
459
460 std::string res;
461
462 res += string_printf ("{level=%d,", fi->level);
463
464 if (fi->unwind != NULL)
465 res += string_printf ("type=%s,", frame_type_str (fi->unwind->type));
466 else
467 res += "type=<unknown>,";
468
469 if (fi->unwind != NULL)
470 res += string_printf ("unwinder=\"%s\",", fi->unwind->name);
471 else
472 res += "unwinder=<unknown>,";
473
474 if (fi->next == NULL || fi->next->prev_pc.status == CC_UNKNOWN)
475 res += "pc=<unknown>,";
476 else if (fi->next->prev_pc.status == CC_VALUE)
477 res += string_printf ("pc=%s%s,", hex_string (fi->next->prev_pc.value),
478 fi->next->prev_pc.masked ? "[PAC]" : "");
479 else if (fi->next->prev_pc.status == CC_NOT_SAVED)
480 res += "pc=<not saved>,";
481 else if (fi->next->prev_pc.status == CC_UNAVAILABLE)
482 res += "pc=<unavailable>,";
483
484 if (fi->this_id.p == frame_id_status::NOT_COMPUTED)
485 res += "id=<not computed>,";
486 else if (fi->this_id.p == frame_id_status::COMPUTING)
487 res += "id=<computing>,";
488 else
489 res += string_printf ("id=%s,", fi->this_id.value.to_string ().c_str ());
490
491 if (fi->next != NULL && fi->next->prev_func.status == CC_VALUE)
492 res += string_printf ("func=%s", hex_string (fi->next->prev_func.addr));
493 else
494 res += "func=<unknown>";
495
496 res += "}";
497
498 return res;
499}
500
501/* Given FRAME, return the enclosing frame as found in real frames read-in from
502 inferior memory. Skip any previous frames which were made up by GDB.
503 Return FRAME if FRAME is a non-artificial frame.
504 Return NULL if FRAME is the start of an artificial-only chain. */
505
506static frame_info_ptr
508{
509 /* Note we use get_prev_frame_always, and not get_prev_frame. The
510 latter will truncate the frame chain, leading to this function
511 unintentionally returning a null_frame_id (e.g., when the user
512 sets a backtrace limit).
513
514 Note that for record targets we may get a frame chain that consists
515 of artificial frames only. */
516 while (get_frame_type (frame) == INLINE_FRAME
517 || get_frame_type (frame) == TAILCALL_FRAME)
518 {
519 frame = get_prev_frame_always (frame);
520 if (frame == NULL)
521 break;
522 }
523
524 return frame;
525}
526
529{
530 while (gdbarch_code_of_frame_writable (get_frame_arch (frame), frame) == 0)
531 {
532 frame = get_prev_frame (frame);
533 if (frame == NULL)
534 break;
535 }
536
537 return frame;
538}
539
540/* See frame.h. */
541
544{
545 while (get_frame_type (frame) == TAILCALL_FRAME)
546 {
547 /* Note that for record targets we may get a frame chain that consists of
548 tailcall frames only. */
549 frame = get_prev_frame (frame);
550 if (frame == NULL)
551 break;
552 }
553
554 return frame;
555}
556
557/* Compute the frame's uniq ID that can be used to, later, re-find the
558 frame. */
559
560static void
562{
564
565 gdb_assert (fi->this_id.p == frame_id_status::NOT_COMPUTED);
566
567 unsigned int entry_generation = get_frame_cache_generation ();
568
569 try
570 {
571 /* Mark this frame's id as "being computed. */
573
574 frame_debug_printf ("fi=%d", fi->level);
575
576 /* Find the unwinder. */
577 if (fi->unwind == NULL)
579
580 /* Find THIS frame's ID. */
581 /* Default to outermost if no ID is found. */
583 fi->unwind->this_id (fi, &fi->prologue_cache, &fi->this_id.value);
584 gdb_assert (frame_id_p (fi->this_id.value));
585
586 /* Mark this frame's id as "computed". */
588
589 frame_debug_printf (" -> %s", fi->this_id.value.to_string ().c_str ());
590 }
591 catch (const gdb_exception &ex)
592 {
593 /* On error, revert the frame id status to not computed. If the frame
594 cache generation changed, the frame object doesn't exist anymore, so
595 don't touch it. */
596 if (get_frame_cache_generation () == entry_generation)
598
599 throw;
600 }
601}
602
603/* Return a frame uniq ID that can be used to, later, re-find the
604 frame. */
605
606struct frame_id
608{
609 if (fi == NULL)
610 return null_frame_id;
611
612 /* It's always invalid to try to get a frame's id while it is being
613 computed. */
614 gdb_assert (fi->this_id.p != frame_id_status::COMPUTING);
615
616 if (fi->this_id.p == frame_id_status::NOT_COMPUTED)
617 {
618 /* If we haven't computed the frame id yet, then it must be that
619 this is the current frame. Compute it now, and stash the
620 result. The IDs of other frames are computed as soon as
621 they're created, in order to detect cycles. See
622 get_prev_frame_if_no_cycle. */
623 gdb_assert (fi->level == 0);
624
625 /* Compute. */
626 compute_frame_id (fi);
627
628 /* Since this is the first frame in the chain, this should
629 always succeed. */
630 bool stashed = frame_stash_add (fi.get ());
631 gdb_assert (stashed);
632 }
633
634 return fi->this_id.value;
635}
636
637struct frame_id
639{
640 return get_frame_id (skip_artificial_frames (next_frame));
641}
642
643struct frame_id
645{
646 frame_info_ptr this_frame;
647
648 /* Use get_prev_frame_always, and not get_prev_frame. The latter
649 will truncate the frame chain, leading to this function
650 unintentionally returning a null_frame_id (e.g., when a caller
651 requests the frame ID of "main()"s caller. */
652
653 next_frame = skip_artificial_frames (next_frame);
654 if (next_frame == NULL)
655 return null_frame_id;
656
657 this_frame = get_prev_frame_always (next_frame);
658 if (this_frame)
659 return get_frame_id (skip_artificial_frames (this_frame));
660 else
661 return null_frame_id;
662}
663
664const struct frame_id null_frame_id = { 0 }; /* All zeros. */
665const struct frame_id sentinel_frame_id = { 0, 0, 0, FID_STACK_SENTINEL, 0, 1, 0 };
666const struct frame_id outer_frame_id = { 0, 0, 0, FID_STACK_OUTER, 0, 1, 0 };
667
668struct frame_id
670 CORE_ADDR special_addr)
671{
672 struct frame_id id = null_frame_id;
673
675 id.stack_status = FID_STACK_VALID;
676 id.code_addr = code_addr;
677 id.code_addr_p = true;
678 id.special_addr = special_addr;
679 id.special_addr_p = true;
680 return id;
681}
682
683/* See frame.h. */
684
685struct frame_id
687{
688 struct frame_id id = null_frame_id;
689
691 id.code_addr = code_addr;
692 id.code_addr_p = true;
693 return id;
694}
695
696/* See frame.h. */
697
698struct frame_id
700 CORE_ADDR special_addr)
701{
702 struct frame_id id = null_frame_id;
703
705 id.code_addr = code_addr;
706 id.code_addr_p = true;
707 id.special_addr = special_addr;
708 id.special_addr_p = true;
709 return id;
710}
711
712struct frame_id
713frame_id_build (CORE_ADDR stack_addr, CORE_ADDR code_addr)
714{
715 struct frame_id id = null_frame_id;
716
718 id.stack_status = FID_STACK_VALID;
719 id.code_addr = code_addr;
720 id.code_addr_p = true;
721 return id;
722}
723
724struct frame_id
726{
727 struct frame_id id = null_frame_id;
728
730 id.stack_status = FID_STACK_VALID;
731 return id;
732}
733
734bool
736{
737 /* The frame is valid iff it has a valid stack address. */
738 bool p = l.stack_status != FID_STACK_INVALID;
739
740 frame_debug_printf ("l=%s -> %d", l.to_string ().c_str (), p);
741
742 return p;
743}
744
745bool
747{
748 if (!frame_id_p (l))
749 return false;
750
751 return l.artificial_depth != 0;
752}
753
754bool
756{
757 bool eq;
758
761 /* Like a NaN, if either ID is invalid, the result is false.
762 Note that a frame ID is invalid iff it is the null frame ID. */
763 eq = false;
764 else if (stack_status != r.stack_status || stack_addr != r.stack_addr)
765 /* If .stack addresses are different, the frames are different. */
766 eq = false;
767 else if (code_addr_p && r.code_addr_p && code_addr != r.code_addr)
768 /* An invalid code addr is a wild card. If .code addresses are
769 different, the frames are different. */
770 eq = false;
771 else if (special_addr_p && r.special_addr_p
773 /* An invalid special addr is a wild card (or unused). Otherwise
774 if special addresses are different, the frames are different. */
775 eq = false;
777 /* If artificial depths are different, the frames must be different. */
778 eq = false;
779 else
780 /* Frames are equal. */
781 eq = true;
782
783 frame_debug_printf ("l=%s, r=%s -> %d",
784 to_string ().c_str (), r.to_string ().c_str (), eq);
785
786 return eq;
787}
788
789/* Safety net to check whether frame ID L should be inner to
790 frame ID R, according to their stack addresses.
791
792 This method cannot be used to compare arbitrary frames, as the
793 ranges of valid stack addresses may be discontiguous (e.g. due
794 to sigaltstack).
795
796 However, it can be used as safety net to discover invalid frame
797 IDs in certain circumstances. Assuming that NEXT is the immediate
798 inner frame to THIS and that NEXT and THIS are both NORMAL frames:
799
800 * The stack address of NEXT must be inner-than-or-equal to the stack
801 address of THIS.
802
803 Therefore, if frame_id_inner (THIS, NEXT) holds, some unwind
804 error has occurred.
805
806 * If NEXT and THIS have different stack addresses, no other frame
807 in the frame chain may have a stack address in between.
808
809 Therefore, if frame_id_inner (TEST, THIS) holds, but
810 frame_id_inner (TEST, NEXT) does not hold, TEST cannot refer
811 to a valid frame in the frame chain.
812
813 The sanity checks above cannot be performed when a SIGTRAMP frame
814 is involved, because signal handlers might be executed on a different
815 stack than the stack used by the routine that caused the signal
816 to be raised. This can happen for instance when a thread exceeds
817 its maximum stack size. In this case, certain compilers implement
818 a stack overflow strategy that cause the handler to be run on a
819 different stack. */
820
821static bool
822frame_id_inner (struct gdbarch *gdbarch, struct frame_id l, struct frame_id r)
823{
824 bool inner;
825
827 /* Like NaN, any operation involving an invalid ID always fails.
828 Likewise if either ID has an unavailable stack address. */
829 inner = false;
831 && l.stack_addr == r.stack_addr
832 && l.code_addr_p == r.code_addr_p
834 && l.special_addr == r.special_addr)
835 {
836 /* Same function, different inlined functions. */
837 const struct block *lb, *rb;
838
839 gdb_assert (l.code_addr_p && r.code_addr_p);
840
841 lb = block_for_pc (l.code_addr);
842 rb = block_for_pc (r.code_addr);
843
844 if (lb == NULL || rb == NULL)
845 /* Something's gone wrong. */
846 inner = false;
847 else
848 /* This will return true if LB and RB are the same block, or
849 if the block with the smaller depth lexically encloses the
850 block with the greater depth. */
851 inner = contained_in (lb, rb);
852 }
853 else
854 /* Only return non-zero when strictly inner than. Note that, per
855 comment in "frame.h", there is some fuzz here. Frameless
856 functions are not strictly inner than (same .stack but
857 different .code and/or .special address). */
859
860 frame_debug_printf ("is l=%s inner than r=%s? %d",
861 l.to_string ().c_str (), r.to_string ().c_str (),
862 inner);
863
864 return inner;
865}
866
869{
870 frame_info_ptr frame, prev_frame;
871
872 /* ZERO denotes the null frame, let the caller decide what to do
873 about it. Should it instead return get_current_frame()? */
874 if (!frame_id_p (id))
875 return NULL;
876
877 /* Check for the sentinel frame. */
878 if (id == sentinel_frame_id)
880
881 /* Try using the frame stash first. Finding it there removes the need
882 to perform the search by looping over all frames, which can be very
883 CPU-intensive if the number of frames is very high (the loop is O(n)
884 and get_prev_frame performs a series of checks that are relatively
885 expensive). This optimization is particularly useful when this function
886 is called from another function (such as value_fetch_lazy, case
887 VALUE_LVAL (val) == lval_register) which already loops over all frames,
888 making the overall behavior O(n^2). */
889 frame = frame_stash_find (id);
890 if (frame)
891 return frame;
892
893 for (frame = get_current_frame (); ; frame = prev_frame)
894 {
895 struct frame_id self = get_frame_id (frame);
896
897 if (id == self)
898 /* An exact match. */
899 return frame;
900
901 prev_frame = get_prev_frame (frame);
902 if (!prev_frame)
903 return NULL;
904
905 /* As a safety net to avoid unnecessary backtracing while trying
906 to find an invalid ID, we check for a common situation where
907 we can detect from comparing stack addresses that no other
908 frame in the current frame chain can have this ID. See the
909 comment at frame_id_inner for details. */
910 if (get_frame_type (frame) == NORMAL_FRAME
911 && !frame_id_inner (get_frame_arch (frame), id, self)
912 && frame_id_inner (get_frame_arch (prev_frame), id,
913 get_frame_id (prev_frame)))
914 return NULL;
915 }
916 return NULL;
917}
918
919static CORE_ADDR
921{
922 if (this_frame->prev_pc.status == CC_UNKNOWN)
923 {
924 struct gdbarch *prev_gdbarch;
925 CORE_ADDR pc = 0;
926 bool pc_p = false;
927
928 /* The right way. The `pure' way. The one true way. This
929 method depends solely on the register-unwind code to
930 determine the value of registers in THIS frame, and hence
931 the value of this frame's PC (resume address). A typical
932 implementation is no more than:
933
934 frame_unwind_register (this_frame, ISA_PC_REGNUM, buf);
935 return extract_unsigned_integer (buf, size of ISA_PC_REGNUM);
936
937 Note: this method is very heavily dependent on a correct
938 register-unwind implementation, it pays to fix that
939 method first; this method is frame type agnostic, since
940 it only deals with register values, it works with any
941 frame. This is all in stark contrast to the old
942 FRAME_SAVED_PC which would try to directly handle all the
943 different ways that a PC could be unwound. */
944 prev_gdbarch = frame_unwind_arch (this_frame);
945
946 try
947 {
948 pc = gdbarch_unwind_pc (prev_gdbarch, this_frame);
949 pc_p = true;
950 }
951 catch (const gdb_exception_error &ex)
952 {
953 if (ex.error == NOT_AVAILABLE_ERROR)
954 {
955 this_frame->prev_pc.status = CC_UNAVAILABLE;
956
957 frame_debug_printf ("this_frame=%d -> <unavailable>",
958 this_frame->level);
959 }
960 else if (ex.error == OPTIMIZED_OUT_ERROR)
961 {
962 this_frame->prev_pc.status = CC_NOT_SAVED;
963
964 frame_debug_printf ("this_frame=%d -> <not saved>",
965 this_frame->level);
966 }
967 else
968 throw;
969 }
970
971 if (pc_p)
972 {
973 this_frame->prev_pc.value = pc;
974 this_frame->prev_pc.status = CC_VALUE;
975
976 frame_debug_printf ("this_frame=%d -> %s",
977 this_frame->level,
978 hex_string (this_frame->prev_pc.value));
979 }
980 }
981
982 if (this_frame->prev_pc.status == CC_VALUE)
983 return this_frame->prev_pc.value;
984 else if (this_frame->prev_pc.status == CC_UNAVAILABLE)
985 throw_error (NOT_AVAILABLE_ERROR, _("PC not available"));
986 else if (this_frame->prev_pc.status == CC_NOT_SAVED)
987 throw_error (OPTIMIZED_OUT_ERROR, _("PC not saved"));
988 else
989 internal_error ("unexpected prev_pc status: %d",
990 (int) this_frame->prev_pc.status);
991}
992
993CORE_ADDR
995{
996 this_frame = skip_artificial_frames (this_frame);
997
998 /* We must have a non-artificial frame. The caller is supposed to check
999 the result of frame_unwind_caller_id (), which returns NULL_FRAME_ID
1000 in this case. */
1001 gdb_assert (this_frame != NULL);
1002
1003 return frame_unwind_pc (this_frame);
1004}
1005
1006bool
1008{
1009 frame_info *next_frame = this_frame->next;
1010
1011 if (next_frame->prev_func.status == CC_UNKNOWN)
1012 {
1013 CORE_ADDR addr_in_block;
1014
1015 /* Make certain that this, and not the adjacent, function is
1016 found. */
1017 if (!get_frame_address_in_block_if_available (this_frame, &addr_in_block))
1018 {
1019 next_frame->prev_func.status = CC_UNAVAILABLE;
1020
1021 frame_debug_printf ("this_frame=%d -> unavailable",
1022 this_frame->level);
1023 }
1024 else
1025 {
1026 next_frame->prev_func.status = CC_VALUE;
1027 next_frame->prev_func.addr = get_pc_function_start (addr_in_block);
1028
1029 frame_debug_printf ("this_frame=%d -> %s",
1030 this_frame->level,
1031 hex_string (next_frame->prev_func.addr));
1032 }
1033 }
1034
1035 if (next_frame->prev_func.status == CC_UNAVAILABLE)
1036 {
1037 *pc = -1;
1038 return false;
1039 }
1040 else
1041 {
1042 gdb_assert (next_frame->prev_func.status == CC_VALUE);
1043
1044 *pc = next_frame->prev_func.addr;
1045 return true;
1046 }
1047}
1048
1049CORE_ADDR
1051{
1052 CORE_ADDR pc;
1053
1054 if (!get_frame_func_if_available (this_frame, &pc))
1055 throw_error (NOT_AVAILABLE_ERROR, _("PC not available"));
1056
1057 return pc;
1058}
1059
1060std::unique_ptr<readonly_detached_regcache>
1062{
1063 auto cooked_read = [this_frame] (int regnum, gdb_byte *buf)
1064 {
1065 if (!deprecated_frame_register_read (this_frame, regnum, buf))
1066 return REG_UNAVAILABLE;
1067 else
1068 return REG_VALID;
1069 };
1070
1071 std::unique_ptr<readonly_detached_regcache> regcache
1072 (new readonly_detached_regcache (get_frame_arch (this_frame), cooked_read));
1073
1074 return regcache;
1075}
1076
1077void
1079{
1080 frame_info_ptr prev_frame;
1081
1082 if (get_frame_type (this_frame) == DUMMY_FRAME)
1083 {
1084 /* Popping a dummy frame involves restoring more than just registers.
1085 dummy_frame_pop does all the work. */
1086 dummy_frame_pop (get_frame_id (this_frame), inferior_thread ());
1087 return;
1088 }
1089
1090 /* Ensure that we have a frame to pop to. */
1091 prev_frame = get_prev_frame_always (this_frame);
1092
1093 if (!prev_frame)
1094 error (_("Cannot pop the initial frame."));
1095
1096 /* Ignore TAILCALL_FRAME type frames, they were executed already before
1097 entering THISFRAME. */
1098 prev_frame = skip_tailcall_frames (prev_frame);
1099
1100 if (prev_frame == NULL)
1101 error (_("Cannot find the caller frame."));
1102
1103 /* Make a copy of all the register values unwound from this frame.
1104 Save them in a scratch buffer so that there isn't a race between
1105 trying to extract the old values from the current regcache while
1106 at the same time writing new values into that same cache. */
1107 std::unique_ptr<readonly_detached_regcache> scratch
1108 = frame_save_as_regcache (prev_frame);
1109
1110 /* FIXME: cagney/2003-03-16: It should be possible to tell the
1111 target's register cache that it is about to be hit with a burst
1112 register transfer and that the sequence of register writes should
1113 be batched. The pair target_prepare_to_store() and
1114 target_store_registers() kind of suggest this functionality.
1115 Unfortunately, they don't implement it. Their lack of a formal
1116 definition can lead to targets writing back bogus values
1117 (arguably a bug in the target code mind). */
1118 /* Now copy those saved registers into the current regcache. */
1119 get_current_regcache ()->restore (scratch.get ());
1120
1121 /* We've made right mess of GDB's local state, just discard
1122 everything. */
1124}
1125
1126void
1128 int *optimizedp, int *unavailablep,
1129 enum lval_type *lvalp, CORE_ADDR *addrp,
1130 int *realnump, gdb_byte *bufferp)
1131{
1132 struct value *value;
1133
1134 /* Require all but BUFFERP to be valid. A NULL BUFFERP indicates
1135 that the value proper does not need to be fetched. */
1136 gdb_assert (optimizedp != NULL);
1137 gdb_assert (lvalp != NULL);
1138 gdb_assert (addrp != NULL);
1139 gdb_assert (realnump != NULL);
1140 /* gdb_assert (bufferp != NULL); */
1141
1143
1144 gdb_assert (value != NULL);
1145
1146 *optimizedp = value_optimized_out (value);
1147 *unavailablep = !value_entirely_available (value);
1148 *lvalp = VALUE_LVAL (value);
1149 *addrp = value_address (value);
1150 if (*lvalp == lval_register)
1151 *realnump = VALUE_REGNUM (value);
1152 else
1153 *realnump = -1;
1154
1155 if (bufferp)
1156 {
1157 if (!*optimizedp && !*unavailablep)
1158 memcpy (bufferp, value_contents_all (value).data (),
1159 value_type (value)->length ());
1160 else
1161 memset (bufferp, 0, value_type (value)->length ());
1162 }
1163
1164 /* Dispose of the new value. This prevents watchpoints from
1165 trying to watch the saved frame pointer. */
1167}
1168
1169/* Get the value of the register that belongs to this FRAME. This
1170 function is a wrapper to the call sequence ``frame_register_unwind
1171 (get_next_frame (FRAME))''. As per frame_register_unwind(), if
1172 VALUEP is NULL, the registers value is not fetched/computed. */
1173
1174static void
1176 int *optimizedp, int *unavailablep, enum lval_type *lvalp,
1177 CORE_ADDR *addrp, int *realnump, gdb_byte *bufferp)
1178{
1179 /* Require all but BUFFERP to be valid. A NULL BUFFERP indicates
1180 that the value proper does not need to be fetched. */
1181 gdb_assert (optimizedp != NULL);
1182 gdb_assert (lvalp != NULL);
1183 gdb_assert (addrp != NULL);
1184 gdb_assert (realnump != NULL);
1185 /* gdb_assert (bufferp != NULL); */
1186
1187 /* Obtain the register value by unwinding the register from the next
1188 (more inner frame). */
1189 gdb_assert (frame != NULL && frame->next != NULL);
1190 frame_register_unwind (frame_info_ptr (frame->next), regnum, optimizedp,
1191 unavailablep, lvalp, addrp, realnump, bufferp);
1192}
1193
1194void
1195frame_unwind_register (frame_info_ptr next_frame, int regnum, gdb_byte *buf)
1196{
1197 int optimized;
1198 int unavailable;
1199 CORE_ADDR addr;
1200 int realnum;
1201 enum lval_type lval;
1202
1203 frame_register_unwind (next_frame, regnum, &optimized, &unavailable,
1204 &lval, &addr, &realnum, buf);
1205
1206 if (optimized)
1207 throw_error (OPTIMIZED_OUT_ERROR,
1208 _("Register %d was not saved"), regnum);
1209 if (unavailable)
1210 throw_error (NOT_AVAILABLE_ERROR,
1211 _("Register %d is not available"), regnum);
1212}
1213
1214void
1216 int regnum, gdb_byte *buf)
1217{
1219}
1220
1221struct value *
1223{
1225
1226 gdb_assert (next_frame != NULL);
1227 gdbarch *gdbarch = frame_unwind_arch (next_frame);
1228 frame_debug_printf ("frame=%d, regnum=%d(%s)",
1229 next_frame->level, regnum,
1231
1232 /* Find the unwinder. */
1233 if (next_frame->unwind == NULL)
1234 frame_unwind_find_by_frame (next_frame, &next_frame->prologue_cache);
1235
1236 /* Ask this frame to unwind its register. */
1237 value *value = next_frame->unwind->prev_register (next_frame,
1238 &next_frame->prologue_cache,
1239 regnum);
1240
1241 if (frame_debug)
1242 {
1243 string_file debug_file;
1244
1245 gdb_printf (&debug_file, " ->");
1247 {
1248 gdb_printf (&debug_file, " ");
1249 val_print_not_saved (&debug_file);
1250 }
1251 else
1252 {
1254 gdb_printf (&debug_file, " register=%d",
1256 else if (VALUE_LVAL (value) == lval_memory)
1257 gdb_printf (&debug_file, " address=%s",
1259 value_address (value)));
1260 else
1261 gdb_printf (&debug_file, " computed");
1262
1263 if (value_lazy (value))
1264 gdb_printf (&debug_file, " lazy");
1265 else
1266 {
1267 int i;
1268 gdb::array_view<const gdb_byte> buf = value_contents (value);
1269
1270 gdb_printf (&debug_file, " bytes=");
1271 gdb_printf (&debug_file, "[");
1272 for (i = 0; i < register_size (gdbarch, regnum); i++)
1273 gdb_printf (&debug_file, "%02x", buf[i]);
1274 gdb_printf (&debug_file, "]");
1275 }
1276 }
1277
1278 frame_debug_printf ("%s", debug_file.c_str ());
1279 }
1280
1281 return value;
1282}
1283
1284struct value *
1286{
1288}
1289
1290LONGEST
1292{
1293 struct gdbarch *gdbarch = frame_unwind_arch (next_frame);
1294 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
1295 struct value *value = frame_unwind_register_value (next_frame, regnum);
1296
1297 gdb_assert (value != NULL);
1298
1300 {
1301 throw_error (OPTIMIZED_OUT_ERROR,
1302 _("Register %d was not saved"), regnum);
1303 }
1305 {
1306 throw_error (NOT_AVAILABLE_ERROR,
1307 _("Register %d is not available"), regnum);
1308 }
1309
1310 LONGEST r = extract_signed_integer (value_contents_all (value), byte_order);
1311
1313 return r;
1314}
1315
1316LONGEST
1318{
1320}
1321
1322ULONGEST
1324{
1325 struct gdbarch *gdbarch = frame_unwind_arch (next_frame);
1326 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
1328 struct value *value = frame_unwind_register_value (next_frame, regnum);
1329
1330 gdb_assert (value != NULL);
1331
1333 {
1334 throw_error (OPTIMIZED_OUT_ERROR,
1335 _("Register %d was not saved"), regnum);
1336 }
1338 {
1339 throw_error (NOT_AVAILABLE_ERROR,
1340 _("Register %d is not available"), regnum);
1341 }
1342
1343 ULONGEST r = extract_unsigned_integer (value_contents_all (value).data (),
1344 size, byte_order);
1345
1347 return r;
1348}
1349
1350ULONGEST
1352{
1354}
1355
1356bool
1358 ULONGEST *val)
1359{
1360 struct value *regval = get_frame_register_value (frame, regnum);
1361
1362 if (!value_optimized_out (regval)
1363 && value_entirely_available (regval))
1364 {
1365 struct gdbarch *gdbarch = get_frame_arch (frame);
1366 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
1367 int size = register_size (gdbarch, VALUE_REGNUM (regval));
1368
1369 *val = extract_unsigned_integer (value_contents (regval).data (), size,
1370 byte_order);
1371 return true;
1372 }
1373
1374 return false;
1375}
1376
1377void
1379 const gdb_byte *buf)
1380{
1381 struct gdbarch *gdbarch = get_frame_arch (frame);
1382 int realnum;
1383 int optim;
1384 int unavail;
1385 enum lval_type lval;
1386 CORE_ADDR addr;
1387
1388 frame_register (frame, regnum, &optim, &unavail,
1389 &lval, &addr, &realnum, NULL);
1390 if (optim)
1391 error (_("Attempt to assign to a register that was not saved."));
1392 switch (lval)
1393 {
1394 case lval_memory:
1395 {
1396 write_memory (addr, buf, register_size (gdbarch, regnum));
1397 break;
1398 }
1399 case lval_register:
1400 get_current_regcache ()->cooked_write (realnum, buf);
1401 break;
1402 default:
1403 error (_("Attempt to assign to an unmodifiable value."));
1404 }
1405}
1406
1407/* This function is deprecated. Use get_frame_register_value instead,
1408 which provides more accurate information.
1409
1410 Find and return the value of REGNUM for the specified stack frame.
1411 The number of bytes copied is REGISTER_SIZE (REGNUM).
1412
1413 Returns 0 if the register value could not be found. */
1414
1415bool
1417 gdb_byte *myaddr)
1418{
1419 int optimized;
1420 int unavailable;
1421 enum lval_type lval;
1422 CORE_ADDR addr;
1423 int realnum;
1424
1425 frame_register (frame, regnum, &optimized, &unavailable,
1426 &lval, &addr, &realnum, myaddr);
1427
1428 return !optimized && !unavailable;
1429}
1430
1431bool
1433 CORE_ADDR offset,
1434 gdb::array_view<gdb_byte> buffer,
1435 int *optimizedp, int *unavailablep)
1436{
1437 struct gdbarch *gdbarch = get_frame_arch (frame);
1438 int i;
1439 int maxsize;
1440 int numregs;
1441
1442 /* Skip registers wholly inside of OFFSET. */
1443 while (offset >= register_size (gdbarch, regnum))
1444 {
1445 offset -= register_size (gdbarch, regnum);
1446 regnum++;
1447 }
1448
1449 /* Ensure that we will not read beyond the end of the register file.
1450 This can only ever happen if the debug information is bad. */
1451 maxsize = -offset;
1452 numregs = gdbarch_num_cooked_regs (gdbarch);
1453 for (i = regnum; i < numregs; i++)
1454 {
1455 int thissize = register_size (gdbarch, i);
1456
1457 if (thissize == 0)
1458 break; /* This register is not available on this architecture. */
1459 maxsize += thissize;
1460 }
1461
1462 int len = buffer.size ();
1463 if (len > maxsize)
1464 error (_("Bad debug information detected: "
1465 "Attempt to read %d bytes from registers."), len);
1466
1467 /* Copy the data. */
1468 while (len > 0)
1469 {
1470 int curr_len = register_size (gdbarch, regnum) - offset;
1471
1472 if (curr_len > len)
1473 curr_len = len;
1474
1475 gdb_byte *myaddr = buffer.data ();
1476
1477 if (curr_len == register_size (gdbarch, regnum))
1478 {
1479 enum lval_type lval;
1480 CORE_ADDR addr;
1481 int realnum;
1482
1483 frame_register (frame, regnum, optimizedp, unavailablep,
1484 &lval, &addr, &realnum, myaddr);
1485 if (*optimizedp || *unavailablep)
1486 return false;
1487 }
1488 else
1489 {
1490 struct value *value
1492 regnum);
1493 gdb_assert (value != NULL);
1494 *optimizedp = value_optimized_out (value);
1495 *unavailablep = !value_entirely_available (value);
1496
1497 if (*optimizedp || *unavailablep)
1498 {
1500 return false;
1501 }
1502
1503 memcpy (myaddr, value_contents_all (value).data () + offset,
1504 curr_len);
1506 }
1507
1508 myaddr += curr_len;
1509 len -= curr_len;
1510 offset = 0;
1511 regnum++;
1512 }
1513
1514 *optimizedp = 0;
1515 *unavailablep = 0;
1516
1517 return true;
1518}
1519
1520void
1522 CORE_ADDR offset,
1523 gdb::array_view<const gdb_byte> buffer)
1524{
1525 struct gdbarch *gdbarch = get_frame_arch (frame);
1526
1527 /* Skip registers wholly inside of OFFSET. */
1528 while (offset >= register_size (gdbarch, regnum))
1529 {
1530 offset -= register_size (gdbarch, regnum);
1531 regnum++;
1532 }
1533
1534 int len = buffer.size ();
1535 /* Copy the data. */
1536 while (len > 0)
1537 {
1538 int curr_len = register_size (gdbarch, regnum) - offset;
1539
1540 if (curr_len > len)
1541 curr_len = len;
1542
1543 const gdb_byte *myaddr = buffer.data ();
1544 if (curr_len == register_size (gdbarch, regnum))
1545 {
1546 put_frame_register (frame, regnum, myaddr);
1547 }
1548 else
1549 {
1550 struct value *value
1552 regnum);
1553 gdb_assert (value != NULL);
1554
1555 memcpy ((char *) value_contents_writeable (value).data () + offset,
1556 myaddr, curr_len);
1557 put_frame_register (frame, regnum,
1558 value_contents_raw (value).data ());
1560 }
1561
1562 myaddr += curr_len;
1563 len -= curr_len;
1564 offset = 0;
1565 regnum++;
1566 }
1567}
1568
1569/* Create a sentinel frame. */
1570
1571static frame_info *
1573{
1574 frame_info *frame = FRAME_OBSTACK_ZALLOC (struct frame_info);
1575
1576 frame->level = -1;
1577 frame->pspace = pspace;
1578 frame->aspace = regcache->aspace ();
1579 /* Explicitly initialize the sentinel frame's cache. Provide it
1580 with the underlying regcache. In the future additional
1581 information, such as the frame's thread will be added. */
1583 /* For the moment there is only one sentinel frame implementation. */
1584 frame->unwind = &sentinel_frame_unwind;
1585 /* Link this frame back to itself. The frame is self referential
1586 (the unwound PC is the same as the pc), so make it so. */
1587 frame->next = frame;
1588 /* The sentinel frame has a special ID. */
1591
1592 frame_debug_printf (" -> %s", frame->to_string ().c_str ());
1593
1594 return frame;
1595}
1596
1597/* Cache for frame addresses already read by gdb. Valid only while
1598 inferior is stopped. Control variables for the frame cache should
1599 be local to this module. */
1600
1601static struct obstack frame_cache_obstack;
1602
1603void *
1605{
1606 void *data = obstack_alloc (&frame_cache_obstack, size);
1607
1608 memset (data, 0, size);
1609 return data;
1610}
1611
1613
1616{
1617 frame_info_ptr current_frame;
1618
1619 /* First check, and report, the lack of registers. Having GDB
1620 report "No stack!" or "No memory" when the target doesn't even
1621 have registers is very confusing. Besides, "printcmd.exp"
1622 explicitly checks that ``print $pc'' with no registers prints "No
1623 registers". */
1624 if (!target_has_registers ())
1625 error (_("No registers."));
1626 if (!target_has_stack ())
1627 error (_("No stack."));
1628 if (!target_has_memory ())
1629 error (_("No memory."));
1630 /* Traceframes are effectively a substitute for the live inferior. */
1631 if (get_traceframe_number () < 0)
1633
1634 if (sentinel_frame == NULL)
1637
1638 /* Set the current frame before computing the frame id, to avoid
1639 recursion inside compute_frame_id, in case the frame's
1640 unwinder decides to do a symbol lookup (which depends on the
1641 selected frame's block).
1642
1643 This call must always succeed. In particular, nothing inside
1644 get_prev_frame_always_1 should try to unwind from the
1645 sentinel frame, because that could fail/throw, and we always
1646 want to leave with the current frame created and linked in --
1647 we should never end up with the sentinel frame as outermost
1648 frame. */
1650 gdb_assert (current_frame != NULL);
1651
1652 return current_frame;
1653}
1654
1655/* The "selected" stack frame is used by default for local and arg
1656 access.
1657
1658 The "single source of truth" for the selected frame is the
1659 SELECTED_FRAME_ID / SELECTED_FRAME_LEVEL pair.
1660
1661 Frame IDs can be saved/restored across reinitializing the frame
1662 cache, while frame_info pointers can't (frame_info objects are
1663 invalidated). If we know the corresponding frame_info object, it
1664 is cached in SELECTED_FRAME.
1665
1666 If SELECTED_FRAME_ID / SELECTED_FRAME_LEVEL are null_frame_id / -1,
1667 and the target has stack and is stopped, the selected frame is the
1668 current (innermost) frame. This means that SELECTED_FRAME_LEVEL is
1669 never 0 and SELECTED_FRAME_ID is never the ID of the innermost
1670 frame.
1671
1672 If SELECTED_FRAME_ID / SELECTED_FRAME_LEVEL are null_frame_id / -1,
1673 and the target has no stack or is executing, then there's no
1674 selected frame. */
1676static int selected_frame_level = -1;
1677
1678/* The cached frame_info object pointing to the selected frame.
1679 Looked up on demand by get_selected_frame. */
1681
1682/* See frame.h. */
1683
1684void
1686 noexcept
1687{
1689 *frame_level = selected_frame_level;
1690}
1691
1692/* See frame.h. */
1693
1694void
1696 noexcept
1697{
1698 /* save_selected_frame never returns level == 0, so we shouldn't see
1699 it here either. */
1700 gdb_assert (frame_level != 0);
1701
1702 /* FRAME_ID can be null_frame_id only IFF frame_level is -1. */
1703 gdb_assert ((frame_level == -1 && !frame_id_p (frame_id))
1704 || (frame_level != -1 && frame_id_p (frame_id)));
1705
1707 selected_frame_level = frame_level;
1708
1709 /* Will be looked up later by get_selected_frame. */
1710 selected_frame = nullptr;
1711}
1712
1713/* Lookup the frame_info object for the selected frame FRAME_ID /
1714 FRAME_LEVEL and cache the result.
1715
1716 If FRAME_LEVEL > 0 and the originally selected frame isn't found,
1717 warn and select the innermost (current) frame. */
1718
1719static void
1720lookup_selected_frame (struct frame_id a_frame_id, int frame_level)
1721{
1722 frame_info_ptr frame = NULL;
1723 int count;
1724
1725 /* This either means there was no selected frame, or the selected
1726 frame was the current frame. In either case, select the current
1727 frame. */
1728 if (frame_level == -1)
1729 {
1731 return;
1732 }
1733
1734 /* select_frame never saves 0 in SELECTED_FRAME_LEVEL, so we
1735 shouldn't see it here. */
1736 gdb_assert (frame_level > 0);
1737
1738 /* Restore by level first, check if the frame id is the same as
1739 expected. If that fails, try restoring by frame id. If that
1740 fails, nothing to do, just warn the user. */
1741
1742 count = frame_level;
1743 frame = find_relative_frame (get_current_frame (), &count);
1744 if (count == 0
1745 && frame != NULL
1746 /* The frame ids must match - either both valid or both
1747 outer_frame_id. The latter case is not failsafe, but since
1748 it's highly unlikely the search by level finds the wrong
1749 frame, it's 99.9(9)% of the time (for all practical purposes)
1750 safe. */
1751 && get_frame_id (frame) == a_frame_id)
1752 {
1753 /* Cool, all is fine. */
1754 select_frame (frame);
1755 return;
1756 }
1757
1758 frame = frame_find_by_id (a_frame_id);
1759 if (frame != NULL)
1760 {
1761 /* Cool, refound it. */
1762 select_frame (frame);
1763 return;
1764 }
1765
1766 /* Nothing else to do, the frame layout really changed. Select the
1767 innermost stack frame. */
1769
1770 /* Warn the user. */
1771 if (frame_level > 0 && !current_uiout->is_mi_like_p ())
1772 {
1773 warning (_("Couldn't restore frame #%d in "
1774 "current thread. Bottom (innermost) frame selected:"),
1775 frame_level);
1776 /* For MI, we should probably have a notification about current
1777 frame change. But this error is not very likely, so don't
1778 bother for now. */
1780 }
1781}
1782
1783bool
1785{
1787 || !target_has_memory ())
1788 return false;
1789
1790 /* Traceframes are effectively a substitute for the live inferior. */
1791 if (get_traceframe_number () < 0)
1792 {
1793 /* No current inferior, no frame. */
1794 if (inferior_ptid == null_ptid)
1795 return false;
1796
1798 /* Don't try to read from a dead thread. */
1799 if (tp->state == THREAD_EXITED)
1800 return false;
1801
1802 /* ... or from a spinning thread. */
1803 if (tp->executing ())
1804 return false;
1805 }
1806
1807 return true;
1808}
1809
1810/* See frame.h. */
1811
1813get_selected_frame (const char *message)
1814{
1815 if (selected_frame == NULL)
1816 {
1817 if (message != NULL && !has_stack_frames ())
1818 error (("%s"), message);
1819
1821 }
1822 /* There is always a frame. */
1823 gdb_assert (selected_frame != NULL);
1824 return selected_frame;
1825}
1826
1827/* This is a variant of get_selected_frame() which can be called when
1828 the inferior does not have a frame; in that case it will return
1829 NULL instead of calling error(). */
1830
1833{
1834 if (!has_stack_frames ())
1835 return NULL;
1836 return get_selected_frame (NULL);
1837}
1838
1839/* Invalidate the selected frame. */
1840
1841static void
1843{
1844 selected_frame = nullptr;
1847}
1848
1849/* See frame.h. */
1850
1851void
1853{
1854 gdb_assert (fi != nullptr);
1855
1856 selected_frame = fi;
1858 if (selected_frame_level == 0)
1859 {
1860 /* Treat the current frame especially -- we want to always
1861 save/restore it without warning, even if the frame ID changes
1862 (see lookup_selected_frame). E.g.:
1863
1864 // The current frame is selected, the target had just stopped.
1865 {
1866 scoped_restore_selected_frame restore_frame;
1867 some_operation_that_changes_the_stack ();
1868 }
1869 // scoped_restore_selected_frame's dtor runs, but the
1870 // original frame_id can't be found. No matter whether it
1871 // is found or not, we still end up with the now-current
1872 // frame selected. Warning in lookup_selected_frame in this
1873 // case seems pointless.
1874
1875 Also get_frame_id may access the target's registers/memory,
1876 and thus skipping get_frame_id optimizes the common case.
1877
1878 Saving the selected frame this way makes get_selected_frame
1879 and restore_current_frame return/re-select whatever frame is
1880 the innermost (current) then. */
1883 }
1884 else
1886
1887 /* NOTE: cagney/2002-05-04: FI can be NULL. This occurs when the
1888 frame is being invalidated. */
1889
1890 /* FIXME: kseitz/2002-08-28: It would be nice to call
1891 selected_frame_level_changed_event() right here, but due to limitations
1892 in the current interfaces, we would end up flooding UIs with events
1893 because select_frame() is used extensively internally.
1894
1895 Once we have frame-parameterized frame (and frame-related) commands,
1896 the event notification can be moved here, since this function will only
1897 be called when the user's selected frame is being changed. */
1898
1899 /* Ensure that symbols for this frame are read in. Also, determine the
1900 source language of this frame, and switch to it if desired. */
1901 if (fi)
1902 {
1903 CORE_ADDR pc;
1904
1905 /* We retrieve the frame's symtab by using the frame PC.
1906 However we cannot use the frame PC as-is, because it usually
1907 points to the instruction following the "call", which is
1908 sometimes the first instruction of another function. So we
1909 rely on get_frame_address_in_block() which provides us with a
1910 PC which is guaranteed to be inside the frame's code
1911 block. */
1913 {
1914 struct compunit_symtab *cust = find_pc_compunit_symtab (pc);
1915
1916 if (cust != NULL
1917 && cust->language () != current_language->la_language
1918 && cust->language () != language_unknown
1920 set_language (cust->language ());
1921 }
1922 }
1923}
1924
1925/* Create an arbitrary (i.e. address specified by user) or innermost frame.
1926 Always returns a non-NULL value. */
1927
1929create_new_frame (CORE_ADDR addr, CORE_ADDR pc)
1930{
1931 frame_info *fi;
1932
1933 frame_debug_printf ("addr=%s, pc=%s", hex_string (addr), hex_string (pc));
1934
1935 fi = FRAME_OBSTACK_ZALLOC (struct frame_info);
1936
1939
1940 /* Set/update this frame's cached PC value, found in the next frame.
1941 Do this before looking for this frame's unwinder. A sniffer is
1942 very likely to read this, and the corresponding unwinder is
1943 entitled to rely that the PC doesn't magically change. */
1944 fi->next->prev_pc.value = pc;
1945 fi->next->prev_pc.status = CC_VALUE;
1946
1947 /* We currently assume that frame chain's can't cross spaces. */
1948 fi->pspace = fi->next->pspace;
1949 fi->aspace = fi->next->aspace;
1950
1951 /* Select/initialize both the unwind function and the frame's type
1952 based on the PC. */
1954
1956 fi->this_id.value = frame_id_build (addr, pc);
1957
1958 frame_debug_printf (" -> %s", fi->to_string ().c_str ());
1959
1960 return frame_info_ptr (fi);
1961}
1962
1963/* Return the frame that THIS_FRAME calls (NULL if THIS_FRAME is the
1964 innermost frame). Be careful to not fall off the bottom of the
1965 frame chain and onto the sentinel frame. */
1966
1969{
1970 if (this_frame->level > 0)
1971 return frame_info_ptr (this_frame->next);
1972 else
1973 return NULL;
1974}
1975
1976/* Return the frame that THIS_FRAME calls. If THIS_FRAME is the
1977 innermost (i.e. current) frame, return the sentinel frame. Thus,
1978 unlike get_next_frame(), NULL will never be returned. */
1979
1982{
1983 gdb_assert (this_frame != NULL);
1984
1985 /* Note that, due to the manner in which the sentinel frame is
1986 constructed, this_frame->next still works even when this_frame
1987 is the sentinel frame. But we disallow it here anyway because
1988 calling get_next_frame_sentinel_okay() on the sentinel frame
1989 is likely a coding error. */
1990 gdb_assert (this_frame != sentinel_frame);
1991
1992 return frame_info_ptr (this_frame->next);
1993}
1994
1995/* Observer for the target_changed event. */
1996
1997static void
1999{
2001}
2002
2003/* Flush the entire frame cache. */
2004
2005void
2007{
2009
2010 /* Tear down all frame caches. */
2011 for (frame_info *fi = sentinel_frame; fi != NULL; fi = fi->prev)
2012 {
2013 if (fi->prologue_cache && fi->unwind->dealloc_cache)
2014 fi->unwind->dealloc_cache (fi, fi->prologue_cache);
2015 if (fi->base_cache && fi->base->unwind->dealloc_cache)
2016 fi->base->unwind->dealloc_cache (fi, fi->base_cache);
2017 }
2018
2019 /* Since we can't really be sure what the first object allocated was. */
2020 obstack_free (&frame_cache_obstack, 0);
2021 obstack_init (&frame_cache_obstack);
2022
2023 if (sentinel_frame != NULL)
2025
2026 sentinel_frame = NULL; /* Invalidate cache */
2029
2031 iter.invalidate ();
2032
2033 frame_debug_printf ("generation=%d", frame_cache_generation);
2034}
2035
2036/* Find where a register is saved (in memory or another register).
2037 The result of frame_register_unwind is just where it is saved
2038 relative to this particular frame. */
2039
2040static void
2042 int *optimizedp, enum lval_type *lvalp,
2043 CORE_ADDR *addrp, int *realnump)
2044{
2045 gdb_assert (this_frame == NULL || this_frame->level >= 0);
2046
2047 while (this_frame != NULL)
2048 {
2049 int unavailable;
2050
2051 frame_register_unwind (this_frame, regnum, optimizedp, &unavailable,
2052 lvalp, addrp, realnump, NULL);
2053
2054 if (*optimizedp)
2055 break;
2056
2057 if (*lvalp != lval_register)
2058 break;
2059
2060 regnum = *realnump;
2061 this_frame = get_next_frame (this_frame);
2062 }
2063}
2064
2065/* Get the previous raw frame, and check that it is not identical to
2066 same other frame frame already in the chain. If it is, there is
2067 most likely a stack cycle, so we discard it, and mark THIS_FRAME as
2068 outermost, with UNWIND_SAME_ID stop reason. Unlike the other
2069 validity tests, that compare THIS_FRAME and the next frame, we do
2070 this right after creating the previous frame, to avoid ever ending
2071 up with two frames with the same id in the frame chain.
2072
2073 There is however, one case where this cycle detection is not desirable,
2074 when asking for the previous frame of an inline frame, in this case, if
2075 the previous frame is a duplicate and we return nullptr then we will be
2076 unable to calculate the frame_id of the inline frame, this in turn
2077 causes inline_frame_this_id() to fail. So for inline frames (and only
2078 for inline frames), the previous frame will always be returned, even when it
2079 has a duplicate frame_id. We're not worried about cycles in the frame
2080 chain as, if the previous frame returned here has a duplicate frame_id,
2081 then the frame_id of the inline frame, calculated based off the frame_id
2082 of the previous frame, should also be a duplicate. */
2083
2084static frame_info_ptr
2086{
2087 frame_info_ptr prev_frame = get_prev_frame_raw (this_frame);
2088
2089 /* Don't compute the frame id of the current frame yet. Unwinding
2090 the sentinel frame can fail (e.g., if the thread is gone and we
2091 can't thus read its registers). If we let the cycle detection
2092 code below try to compute a frame ID, then an error thrown from
2093 within the frame ID computation would result in the sentinel
2094 frame as outermost frame, which is bogus. Instead, we'll compute
2095 the current frame's ID lazily in get_frame_id. Note that there's
2096 no point in doing cycle detection when there's only one frame, so
2097 nothing is lost here. */
2098 if (prev_frame->level == 0)
2099 return prev_frame;
2100
2101 unsigned int entry_generation = get_frame_cache_generation ();
2102
2103 try
2104 {
2105 compute_frame_id (prev_frame);
2106
2107 bool cycle_detection_p = get_frame_type (this_frame) != INLINE_FRAME;
2108
2109 /* This assert checks GDB's state with respect to calculating the
2110 frame-id of THIS_FRAME, in the case where THIS_FRAME is an inline
2111 frame.
2112
2113 If THIS_FRAME is frame #0, and is an inline frame, then we put off
2114 calculating the frame_id until we specifically make a call to
2115 get_frame_id(). As a result we can enter this function in two
2116 possible states. If GDB asked for the previous frame of frame #0
2117 then THIS_FRAME will be frame #0 (an inline frame), and the
2118 frame_id will be in the NOT_COMPUTED state. However, if GDB asked
2119 for the frame_id of frame #0, then, as getting the frame_id of an
2120 inline frame requires us to get the frame_id of the previous
2121 frame, we will still end up in here, and the frame_id status will
2122 be COMPUTING.
2123
2124 If, instead, THIS_FRAME is at a level greater than #0 then things
2125 are simpler. For these frames we immediately compute the frame_id
2126 when the frame is initially created, and so, for those frames, we
2127 will always enter this function with the frame_id status of
2128 COMPUTING. */
2129 gdb_assert (cycle_detection_p
2130 || (this_frame->level > 0
2131 && (this_frame->this_id.p
2133 || (this_frame->level == 0
2134 && (this_frame->this_id.p
2136
2137 /* We must do the CYCLE_DETECTION_P check after attempting to add
2138 PREV_FRAME into the cache; if PREV_FRAME is unique then we do want
2139 it in the cache, but if it is a duplicate and CYCLE_DETECTION_P is
2140 false, then we don't want to unlink it. */
2141 if (!frame_stash_add (prev_frame.get ()) && cycle_detection_p)
2142 {
2143 /* Another frame with the same id was already in the stash. We just
2144 detected a cycle. */
2145 frame_debug_printf (" -> nullptr // this frame has same ID");
2146
2147 this_frame->stop_reason = UNWIND_SAME_ID;
2148 /* Unlink. */
2149 prev_frame->next = NULL;
2150 this_frame->prev = NULL;
2151 prev_frame = NULL;
2152 }
2153 }
2154 catch (const gdb_exception &ex)
2155 {
2156 if (get_frame_cache_generation () == entry_generation)
2157 {
2158 prev_frame->next = NULL;
2159 this_frame->prev = NULL;
2160 }
2161
2162 throw;
2163 }
2164
2165 return prev_frame;
2166}
2167
2168/* Helper function for get_prev_frame_always, this is called inside a
2169 TRY_CATCH block. Return the frame that called THIS_FRAME or NULL if
2170 there is no such frame. This may throw an exception. */
2171
2172static frame_info_ptr
2174{
2176
2177 gdb_assert (this_frame != NULL);
2178
2179 if (frame_debug)
2180 {
2181 if (this_frame != NULL)
2182 frame_debug_printf ("this_frame=%d", this_frame->level);
2183 else
2184 frame_debug_printf ("this_frame=nullptr");
2185 }
2186
2187 struct gdbarch *gdbarch = get_frame_arch (this_frame);
2188
2189 /* Only try to do the unwind once. */
2190 if (this_frame->prev_p)
2191 {
2192 if (this_frame->prev != nullptr)
2193 frame_debug_printf (" -> %s // cached",
2194 this_frame->prev->to_string ().c_str ());
2195 else
2197 (" -> nullptr // %s // cached",
2199 return frame_info_ptr (this_frame->prev);
2200 }
2201
2202 /* If the frame unwinder hasn't been selected yet, we must do so
2203 before setting prev_p; otherwise the check for misbehaved
2204 sniffers will think that this frame's sniffer tried to unwind
2205 further (see frame_cleanup_after_sniffer). */
2206 if (this_frame->unwind == NULL)
2207 frame_unwind_find_by_frame (this_frame, &this_frame->prologue_cache);
2208
2209 this_frame->prev_p = true;
2210 this_frame->stop_reason = UNWIND_NO_REASON;
2211
2212 /* If we are unwinding from an inline frame, all of the below tests
2213 were already performed when we unwound from the next non-inline
2214 frame. We must skip them, since we can not get THIS_FRAME's ID
2215 until we have unwound all the way down to the previous non-inline
2216 frame. */
2217 if (get_frame_type (this_frame) == INLINE_FRAME)
2218 return get_prev_frame_maybe_check_cycle (this_frame);
2219
2220 /* If this_frame is the current frame, then compute and stash its
2221 frame id prior to fetching and computing the frame id of the
2222 previous frame. Otherwise, the cycle detection code in
2223 get_prev_frame_if_no_cycle() will not work correctly. When
2224 get_frame_id() is called later on, an assertion error will be
2225 triggered in the event of a cycle between the current frame and
2226 its previous frame.
2227
2228 Note we do this after the INLINE_FRAME check above. That is
2229 because the inline frame's frame id computation needs to fetch
2230 the frame id of its previous real stack frame. I.e., we need to
2231 avoid recursion in that case. This is OK since we're sure the
2232 inline frame won't create a cycle with the real stack frame. See
2233 inline_frame_this_id. */
2234 if (this_frame->level == 0)
2235 get_frame_id (this_frame);
2236
2237 /* Check that this frame is unwindable. If it isn't, don't try to
2238 unwind to the prev frame. */
2239 this_frame->stop_reason
2240 = this_frame->unwind->stop_reason (this_frame,
2241 &this_frame->prologue_cache);
2242
2243 if (this_frame->stop_reason != UNWIND_NO_REASON)
2244 {
2246 (" -> nullptr // %s",
2248 return NULL;
2249 }
2250
2251 /* Check that this frame's ID isn't inner to (younger, below, next)
2252 the next frame. This happens when a frame unwind goes backwards.
2253 This check is valid only if this frame and the next frame are NORMAL.
2254 See the comment at frame_id_inner for details. */
2255 if (get_frame_type (this_frame) == NORMAL_FRAME
2256 && this_frame->next->unwind->type == NORMAL_FRAME
2258 get_frame_id (this_frame),
2259 get_frame_id (frame_info_ptr (this_frame->next))))
2260 {
2261 CORE_ADDR this_pc_in_block;
2262 struct minimal_symbol *morestack_msym;
2263 const char *morestack_name = NULL;
2264
2265 /* gcc -fsplit-stack __morestack can continue the stack anywhere. */
2266 this_pc_in_block = get_frame_address_in_block (this_frame);
2267 morestack_msym = lookup_minimal_symbol_by_pc (this_pc_in_block).minsym;
2268 if (morestack_msym)
2269 morestack_name = morestack_msym->linkage_name ();
2270 if (!morestack_name || strcmp (morestack_name, "__morestack") != 0)
2271 {
2272 frame_debug_printf (" -> nullptr // this frame ID is inner");
2273 this_frame->stop_reason = UNWIND_INNER_ID;
2274 return NULL;
2275 }
2276 }
2277
2278 /* Check that this and the next frame do not unwind the PC register
2279 to the same memory location. If they do, then even though they
2280 have different frame IDs, the new frame will be bogus; two
2281 functions can't share a register save slot for the PC. This can
2282 happen when the prologue analyzer finds a stack adjustment, but
2283 no PC save.
2284
2285 This check does assume that the "PC register" is roughly a
2286 traditional PC, even if the gdbarch_unwind_pc method adjusts
2287 it (we do not rely on the value, only on the unwound PC being
2288 dependent on this value). A potential improvement would be
2289 to have the frame prev_pc method and the gdbarch unwind_pc
2290 method set the same lval and location information as
2291 frame_register_unwind. */
2292 if (this_frame->level > 0
2293 && gdbarch_pc_regnum (gdbarch) >= 0
2294 && get_frame_type (this_frame) == NORMAL_FRAME
2295 && (get_frame_type (frame_info_ptr (this_frame->next)) == NORMAL_FRAME
2296 || get_frame_type (frame_info_ptr (this_frame->next)) == INLINE_FRAME))
2297 {
2298 int optimized, realnum, nrealnum;
2299 enum lval_type lval, nlval;
2300 CORE_ADDR addr, naddr;
2301
2304 &optimized, &lval, &addr, &realnum);
2307 &optimized, &nlval, &naddr, &nrealnum);
2308
2309 if ((lval == lval_memory && lval == nlval && addr == naddr)
2310 || (lval == lval_register && lval == nlval && realnum == nrealnum))
2311 {
2312 frame_debug_printf (" -> nullptr // no saved PC");
2313 this_frame->stop_reason = UNWIND_NO_SAVED_PC;
2314 this_frame->prev = NULL;
2315 return NULL;
2316 }
2317 }
2318
2319 return get_prev_frame_maybe_check_cycle (this_frame);
2320}
2321
2322/* Return a "struct frame_info" corresponding to the frame that called
2323 THIS_FRAME. Returns NULL if there is no such frame.
2324
2325 Unlike get_prev_frame, this function always tries to unwind the
2326 frame. */
2327
2330{
2331 frame_info_ptr prev_frame = NULL;
2332
2333 try
2334 {
2335 prev_frame = get_prev_frame_always_1 (this_frame);
2336 }
2337 catch (const gdb_exception_error &ex)
2338 {
2339 if (ex.error == MEMORY_ERROR)
2340 {
2341 this_frame->stop_reason = UNWIND_MEMORY_ERROR;
2342 if (ex.message != NULL)
2343 {
2344 char *stop_string;
2345 size_t size;
2346
2347 /* The error needs to live as long as the frame does.
2348 Allocate using stack local STOP_STRING then assign the
2349 pointer to the frame, this allows the STOP_STRING on the
2350 frame to be of type 'const char *'. */
2351 size = ex.message->size () + 1;
2352 stop_string = (char *) frame_obstack_zalloc (size);
2353 memcpy (stop_string, ex.what (), size);
2354 this_frame->stop_string = stop_string;
2355 }
2356 prev_frame = NULL;
2357 }
2358 else
2359 throw;
2360 }
2361
2362 return prev_frame;
2363}
2364
2365/* Construct a new "struct frame_info" and link it previous to
2366 this_frame. */
2367
2368static frame_info_ptr
2370{
2371 frame_info *prev_frame;
2372
2373 /* Allocate the new frame but do not wire it in to the frame chain.
2374 Some (bad) code in INIT_FRAME_EXTRA_INFO tries to look along
2375 frame->next to pull some fancy tricks (of course such code is, by
2376 definition, recursive). Try to prevent it.
2377
2378 There is no reason to worry about memory leaks, should the
2379 remainder of the function fail. The allocated memory will be
2380 quickly reclaimed when the frame cache is flushed, and the `we've
2381 been here before' check above will stop repeated memory
2382 allocation calls. */
2383 prev_frame = FRAME_OBSTACK_ZALLOC (struct frame_info);
2384 prev_frame->level = this_frame->level + 1;
2385
2386 /* For now, assume we don't have frame chains crossing address
2387 spaces. */
2388 prev_frame->pspace = this_frame->pspace;
2389 prev_frame->aspace = this_frame->aspace;
2390
2391 /* Don't yet compute ->unwind (and hence ->type). It is computed
2392 on-demand in get_frame_type, frame_register_unwind, and
2393 get_frame_id. */
2394
2395 /* Don't yet compute the frame's ID. It is computed on-demand by
2396 get_frame_id(). */
2397
2398 /* The unwound frame ID is validate at the start of this function,
2399 as part of the logic to decide if that frame should be further
2400 unwound, and not here while the prev frame is being created.
2401 Doing this makes it possible for the user to examine a frame that
2402 has an invalid frame ID.
2403
2404 Some very old VAX code noted: [...] For the sake of argument,
2405 suppose that the stack is somewhat trashed (which is one reason
2406 that "info frame" exists). So, return 0 (indicating we don't
2407 know the address of the arglist) if we don't know what frame this
2408 frame calls. */
2409
2410 /* Link it in. */
2411 this_frame->prev = prev_frame;
2412 prev_frame->next = this_frame.get ();
2413
2414 frame_debug_printf (" -> %s", prev_frame->to_string ().c_str ());
2415
2416 return frame_info_ptr (prev_frame);
2417}
2418
2419/* Debug routine to print a NULL frame being returned. */
2420
2421static void
2423 const char *reason)
2424{
2425 if (frame_debug)
2426 {
2427 if (this_frame != NULL)
2428 frame_debug_printf ("this_frame=%d -> %s", this_frame->level, reason);
2429 else
2430 frame_debug_printf ("this_frame=nullptr -> %s", reason);
2431 }
2432}
2433
2434/* Is this (non-sentinel) frame in the "main"() function? */
2435
2436static bool
2438{
2440 return false;
2441
2442 CORE_ADDR sym_addr;
2443 const char *name = main_name ();
2444 bound_minimal_symbol msymbol
2445 = lookup_minimal_symbol (name, NULL,
2447 if (msymbol.minsym == nullptr)
2448 {
2449 /* In some language (for example Fortran) there will be no minimal
2450 symbol with the name of the main function. In this case we should
2451 search the full symbols to see if we can find a match. */
2452 struct block_symbol bs = lookup_symbol (name, NULL, VAR_DOMAIN, 0);
2453 if (bs.symbol == nullptr)
2454 return false;
2455
2456 const struct block *block = bs.symbol->value_block ();
2457 gdb_assert (block != nullptr);
2458 sym_addr = block->start ();
2459 }
2460 else
2461 sym_addr = msymbol.value_address ();
2462
2463 /* Convert any function descriptor addresses into the actual function
2464 code address. */
2466 (get_frame_arch (this_frame), sym_addr, current_inferior ()->top_target ());
2467
2468 return sym_addr == get_frame_func (this_frame);
2469}
2470
2471/* Test whether THIS_FRAME is inside the process entry point function. */
2472
2473static bool
2475{
2476 CORE_ADDR entry_point;
2477
2478 if (!entry_point_address_query (&entry_point))
2479 return false;
2480
2481 return get_frame_func (this_frame) == entry_point;
2482}
2483
2484/* Return a structure containing various interesting information about
2485 the frame that called THIS_FRAME. Returns NULL if there is entier
2486 no such frame or the frame fails any of a set of target-independent
2487 condition that should terminate the frame chain (e.g., as unwinding
2488 past main()).
2489
2490 This function should not contain target-dependent tests, such as
2491 checking whether the program-counter is zero. */
2492
2495{
2497
2498 CORE_ADDR frame_pc;
2499 int frame_pc_p;
2500
2501 /* There is always a frame. If this assertion fails, suspect that
2502 something should be calling get_selected_frame() or
2503 get_current_frame(). */
2504 gdb_assert (this_frame != NULL);
2505
2506 frame_pc_p = get_frame_pc_if_available (this_frame, &frame_pc);
2507
2508 /* tausq/2004-12-07: Dummy frames are skipped because it doesn't make much
2509 sense to stop unwinding at a dummy frame. One place where a dummy
2510 frame may have an address "inside_main_func" is on HPUX. On HPUX, the
2511 pcsqh register (space register for the instruction at the head of the
2512 instruction queue) cannot be written directly; the only way to set it
2513 is to branch to code that is in the target space. In order to implement
2514 frame dummies on HPUX, the called function is made to jump back to where
2515 the inferior was when the user function was called. If gdb was inside
2516 the main function when we created the dummy frame, the dummy frame will
2517 point inside the main function. */
2518 if (this_frame->level >= 0
2519 && get_frame_type (this_frame) == NORMAL_FRAME
2521 && frame_pc_p
2522 && inside_main_func (this_frame))
2523 /* Don't unwind past main(). Note, this is done _before_ the
2524 frame has been marked as previously unwound. That way if the
2525 user later decides to enable unwinds past main(), that will
2526 automatically happen. */
2527 {
2528 frame_debug_got_null_frame (this_frame, "inside main func");
2529 return NULL;
2530 }
2531
2532 /* If the user's backtrace limit has been exceeded, stop. We must
2533 add two to the current level; one of those accounts for backtrace_limit
2534 being 1-based and the level being 0-based, and the other accounts for
2535 the level of the new frame instead of the level of the current
2536 frame. */
2537 if (this_frame->level + 2 > user_set_backtrace_options.backtrace_limit)
2538 {
2539 frame_debug_got_null_frame (this_frame, "backtrace limit exceeded");
2540 return NULL;
2541 }
2542
2543 /* If we're already inside the entry function for the main objfile,
2544 then it isn't valid. Don't apply this test to a dummy frame -
2545 dummy frame PCs typically land in the entry func. Don't apply
2546 this test to the sentinel frame. Sentinel frames should always
2547 be allowed to unwind. */
2548 /* NOTE: cagney/2003-07-07: Fixed a bug in inside_main_func() -
2549 wasn't checking for "main" in the minimal symbols. With that
2550 fixed asm-source tests now stop in "main" instead of halting the
2551 backtrace in weird and wonderful ways somewhere inside the entry
2552 file. Suspect that tests for inside the entry file/func were
2553 added to work around that (now fixed) case. */
2554 /* NOTE: cagney/2003-07-15: danielj (if I'm reading it right)
2555 suggested having the inside_entry_func test use the
2556 inside_main_func() msymbol trick (along with entry_point_address()
2557 I guess) to determine the address range of the start function.
2558 That should provide a far better stopper than the current
2559 heuristics. */
2560 /* NOTE: tausq/2004-10-09: this is needed if, for example, the compiler
2561 applied tail-call optimizations to main so that a function called
2562 from main returns directly to the caller of main. Since we don't
2563 stop at main, we should at least stop at the entry point of the
2564 application. */
2565 if (this_frame->level >= 0
2566 && get_frame_type (this_frame) == NORMAL_FRAME
2568 && frame_pc_p
2569 && inside_entry_func (this_frame))
2570 {
2571 frame_debug_got_null_frame (this_frame, "inside entry func");
2572 return NULL;
2573 }
2574
2575 /* Assume that the only way to get a zero PC is through something
2576 like a SIGSEGV or a dummy frame, and hence that NORMAL frames
2577 will never unwind a zero PC. */
2578 if (this_frame->level > 0
2579 && (get_frame_type (this_frame) == NORMAL_FRAME
2580 || get_frame_type (this_frame) == INLINE_FRAME)
2581 && get_frame_type (get_next_frame (this_frame)) == NORMAL_FRAME
2582 && frame_pc_p && frame_pc == 0)
2583 {
2584 frame_debug_got_null_frame (this_frame, "zero PC");
2585 return NULL;
2586 }
2587
2588 return get_prev_frame_always (this_frame);
2589}
2590
2591CORE_ADDR
2593{
2594 gdb_assert (frame->next != NULL);
2595 return frame_unwind_pc (frame_info_ptr (frame->next));
2596}
2597
2598bool
2600{
2601
2602 gdb_assert (frame->next != NULL);
2603
2604 try
2605 {
2606 *pc = frame_unwind_pc (frame_info_ptr (frame->next));
2607 }
2608 catch (const gdb_exception_error &ex)
2609 {
2610 if (ex.error == NOT_AVAILABLE_ERROR)
2611 return false;
2612 else
2613 throw;
2614 }
2615
2616 return true;
2617}
2618
2619/* Return an address that falls within THIS_FRAME's code block. */
2620
2621CORE_ADDR
2623{
2624 /* A draft address. */
2625 CORE_ADDR pc = get_frame_pc (this_frame);
2626
2627 frame_info_ptr next_frame (this_frame->next);
2628
2629 /* Calling get_frame_pc returns the resume address for THIS_FRAME.
2630 Normally the resume address is inside the body of the function
2631 associated with THIS_FRAME, but there is a special case: when
2632 calling a function which the compiler knows will never return
2633 (for instance abort), the call may be the very last instruction
2634 in the calling function. The resume address will point after the
2635 call and may be at the beginning of a different function
2636 entirely.
2637
2638 If THIS_FRAME is a signal frame or dummy frame, then we should
2639 not adjust the unwound PC. For a dummy frame, GDB pushed the
2640 resume address manually onto the stack. For a signal frame, the
2641 OS may have pushed the resume address manually and invoked the
2642 handler (e.g. GNU/Linux), or invoked the trampoline which called
2643 the signal handler - but in either case the signal handler is
2644 expected to return to the trampoline. So in both of these
2645 cases we know that the resume address is executable and
2646 related. So we only need to adjust the PC if THIS_FRAME
2647 is a normal function.
2648
2649 If the program has been interrupted while THIS_FRAME is current,
2650 then clearly the resume address is inside the associated
2651 function. There are three kinds of interruption: debugger stop
2652 (next frame will be SENTINEL_FRAME), operating system
2653 signal or exception (next frame will be SIGTRAMP_FRAME),
2654 or debugger-induced function call (next frame will be
2655 DUMMY_FRAME). So we only need to adjust the PC if
2656 NEXT_FRAME is a normal function.
2657
2658 We check the type of NEXT_FRAME first, since it is already
2659 known; frame type is determined by the unwinder, and since
2660 we have THIS_FRAME we've already selected an unwinder for
2661 NEXT_FRAME.
2662
2663 If the next frame is inlined, we need to keep going until we find
2664 the real function - for instance, if a signal handler is invoked
2665 while in an inlined function, then the code address of the
2666 "calling" normal function should not be adjusted either. */
2667
2668 while (get_frame_type (next_frame) == INLINE_FRAME)
2669 next_frame = frame_info_ptr (next_frame->next);
2670
2671 if ((get_frame_type (next_frame) == NORMAL_FRAME
2672 || get_frame_type (next_frame) == TAILCALL_FRAME)
2673 && (get_frame_type (this_frame) == NORMAL_FRAME
2674 || get_frame_type (this_frame) == TAILCALL_FRAME
2675 || get_frame_type (this_frame) == INLINE_FRAME))
2676 return pc - 1;
2677
2678 return pc;
2679}
2680
2681bool
2683 CORE_ADDR *pc)
2684{
2685
2686 try
2687 {
2688 *pc = get_frame_address_in_block (this_frame);
2689 }
2690 catch (const gdb_exception_error &ex)
2691 {
2692 if (ex.error == NOT_AVAILABLE_ERROR)
2693 return false;
2694 throw;
2695 }
2696
2697 return true;
2698}
2699
2702{
2703 frame_info_ptr next_frame;
2704 int notcurrent;
2705 CORE_ADDR pc;
2706
2707 if (frame_inlined_callees (frame) > 0)
2708 {
2709 struct symbol *sym;
2710
2711 /* If the current frame has some inlined callees, and we have a next
2712 frame, then that frame must be an inlined frame. In this case
2713 this frame's sal is the "call site" of the next frame's inlined
2714 function, which can not be inferred from get_frame_pc. */
2715 next_frame = get_next_frame (frame);
2716 if (next_frame)
2717 sym = get_frame_function (next_frame);
2718 else
2720
2721 /* If frame is inline, it certainly has symbols. */
2722 gdb_assert (sym);
2723
2724 symtab_and_line sal;
2725 if (sym->line () != 0)
2726 {
2727 sal.symtab = sym->symtab ();
2728 sal.line = sym->line ();
2729 }
2730 else
2731 /* If the symbol does not have a location, we don't know where
2732 the call site is. Do not pretend to. This is jarring, but
2733 we can't do much better. */
2734 sal.pc = get_frame_pc (frame);
2735
2736 sal.pspace = get_frame_program_space (frame);
2737 return sal;
2738 }
2739
2740 /* If FRAME is not the innermost frame, that normally means that
2741 FRAME->pc points at the return instruction (which is *after* the
2742 call instruction), and we want to get the line containing the
2743 call (because the call is where the user thinks the program is).
2744 However, if the next frame is either a SIGTRAMP_FRAME or a
2745 DUMMY_FRAME, then the next frame will contain a saved interrupt
2746 PC and such a PC indicates the current (rather than next)
2747 instruction/line, consequently, for such cases, want to get the
2748 line containing fi->pc. */
2749 if (!get_frame_pc_if_available (frame, &pc))
2750 return {};
2751
2752 notcurrent = (pc != get_frame_address_in_block (frame));
2753 return find_pc_line (pc, notcurrent);
2754}
2755
2756/* Per "frame.h", return the ``address'' of the frame. Code should
2757 really be using get_frame_id(). */
2758CORE_ADDR
2760{
2761 return get_frame_id (fi).stack_addr;
2762}
2763
2764/* High-level offsets into the frame. Used by the debug info. */
2765
2766CORE_ADDR
2768{
2769 if (get_frame_type (fi) != NORMAL_FRAME)
2770 return 0;
2771 if (fi->base == NULL)
2772 fi->base = frame_base_find_by_frame (fi);
2773 /* Sneaky: If the low-level unwind and high-level base code share a
2774 common unwinder, let them share the prologue cache. */
2775 if (fi->base->unwind == fi->unwind)
2776 return fi->base->this_base (fi, &fi->prologue_cache);
2777 return fi->base->this_base (fi, &fi->base_cache);
2778}
2779
2780CORE_ADDR
2782{
2783 if (get_frame_type (fi) != NORMAL_FRAME)
2784 return 0;
2785 /* If there isn't a frame address method, find it. */
2786 if (fi->base == NULL)
2787 fi->base = frame_base_find_by_frame (fi);
2788 /* Sneaky: If the low-level unwind and high-level base code share a
2789 common unwinder, let them share the prologue cache. */
2790 if (fi->base->unwind == fi->unwind)
2791 return fi->base->this_locals (fi, &fi->prologue_cache);
2792 return fi->base->this_locals (fi, &fi->base_cache);
2793}
2794
2795CORE_ADDR
2797{
2798 if (get_frame_type (fi) != NORMAL_FRAME)
2799 return 0;
2800 /* If there isn't a frame address method, find it. */
2801 if (fi->base == NULL)
2802 fi->base = frame_base_find_by_frame (fi);
2803 /* Sneaky: If the low-level unwind and high-level base code share a
2804 common unwinder, let them share the prologue cache. */
2805 if (fi->base->unwind == fi->unwind)
2806 return fi->base->this_args (fi, &fi->prologue_cache);
2807 return fi->base->this_args (fi, &fi->base_cache);
2808}
2809
2810/* Return true if the frame unwinder for frame FI is UNWINDER; false
2811 otherwise. */
2812
2813bool
2815{
2816 if (fi->unwind == nullptr)
2818
2819 return fi->unwind == unwinder;
2820}
2821
2822/* Level of the selected frame: 0 for innermost, 1 for its caller, ...
2823 or -1 for a NULL frame. */
2824
2825int
2827{
2828 if (fi == NULL)
2829 return -1;
2830 else
2831 return fi->level;
2832}
2833
2834enum frame_type
2836{
2837 if (frame->unwind == NULL)
2838 /* Initialize the frame's unwinder because that's what
2839 provides the frame's type. */
2841 return frame->unwind->type;
2842}
2843
2844struct program_space *
2846{
2847 return frame->pspace;
2848}
2849
2850struct program_space *
2852{
2853 gdb_assert (this_frame);
2854
2855 /* This is really a placeholder to keep the API consistent --- we
2856 assume for now that we don't have frame chains crossing
2857 spaces. */
2858 return this_frame->pspace;
2859}
2860
2861const address_space *
2863{
2864 return frame->aspace;
2865}
2866
2867/* Memory access methods. */
2868
2869void
2870get_frame_memory (frame_info_ptr this_frame, CORE_ADDR addr,
2871 gdb::array_view<gdb_byte> buffer)
2872{
2873 read_memory (addr, buffer.data (), buffer.size ());
2874}
2875
2876LONGEST
2877get_frame_memory_signed (frame_info_ptr this_frame, CORE_ADDR addr,
2878 int len)
2879{
2880 struct gdbarch *gdbarch = get_frame_arch (this_frame);
2881 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
2882
2883 return read_memory_integer (addr, len, byte_order);
2884}
2885
2886ULONGEST
2887get_frame_memory_unsigned (frame_info_ptr this_frame, CORE_ADDR addr,
2888 int len)
2889{
2890 struct gdbarch *gdbarch = get_frame_arch (this_frame);
2891 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
2892
2893 return read_memory_unsigned_integer (addr, len, byte_order);
2894}
2895
2896bool
2898 CORE_ADDR addr, gdb::array_view<gdb_byte> buffer)
2899{
2900 /* NOTE: target_read_memory returns zero on success! */
2901 return target_read_memory (addr, buffer.data (), buffer.size ()) == 0;
2902}
2903
2904/* Architecture methods. */
2905
2906struct gdbarch *
2908{
2909 return frame_unwind_arch (frame_info_ptr (this_frame->next));
2910}
2911
2912struct gdbarch *
2914{
2915 if (!next_frame->prev_arch.p)
2916 {
2917 struct gdbarch *arch;
2918
2919 if (next_frame->unwind == NULL)
2920 frame_unwind_find_by_frame (next_frame, &next_frame->prologue_cache);
2921
2922 if (next_frame->unwind->prev_arch != NULL)
2923 arch = next_frame->unwind->prev_arch (next_frame,
2924 &next_frame->prologue_cache);
2925 else
2926 arch = get_frame_arch (next_frame);
2927
2928 next_frame->prev_arch.arch = arch;
2929 next_frame->prev_arch.p = true;
2930 frame_debug_printf ("next_frame=%d -> %s",
2931 next_frame->level,
2932 gdbarch_bfd_arch_info (arch)->printable_name);
2933 }
2934
2935 return next_frame->prev_arch.arch;
2936}
2937
2938struct gdbarch *
2940{
2941 next_frame = skip_artificial_frames (next_frame);
2942
2943 /* We must have a non-artificial frame. The caller is supposed to check
2944 the result of frame_unwind_caller_id (), which returns NULL_FRAME_ID
2945 in this case. */
2946 gdb_assert (next_frame != NULL);
2947
2948 return frame_unwind_arch (next_frame);
2949}
2950
2951/* Gets the language of FRAME. */
2952
2953enum language
2955{
2956 CORE_ADDR pc = 0;
2957 bool pc_p = false;
2958
2959 gdb_assert (frame!= NULL);
2960
2961 /* We determine the current frame language by looking up its
2962 associated symtab. To retrieve this symtab, we use the frame
2963 PC. However we cannot use the frame PC as is, because it
2964 usually points to the instruction following the "call", which
2965 is sometimes the first instruction of another function. So
2966 we rely on get_frame_address_in_block(), it provides us with
2967 a PC that is guaranteed to be inside the frame's code
2968 block. */
2969
2970 try
2971 {
2972 pc = get_frame_address_in_block (frame);
2973 pc_p = true;
2974 }
2975 catch (const gdb_exception_error &ex)
2976 {
2977 if (ex.error != NOT_AVAILABLE_ERROR)
2978 throw;
2979 }
2980
2981 if (pc_p)
2982 {
2983 struct compunit_symtab *cust = find_pc_compunit_symtab (pc);
2984
2985 if (cust != NULL)
2986 return cust->language ();
2987 }
2988
2989 return language_unknown;
2990}
2991
2992/* Stack pointer methods. */
2993
2994CORE_ADDR
2996{
2997 struct gdbarch *gdbarch = get_frame_arch (this_frame);
2998
2999 /* NOTE drow/2008-06-28: gdbarch_unwind_sp could be converted to
3000 operate on THIS_FRAME now. */
3001 return gdbarch_unwind_sp (gdbarch, frame_info_ptr (this_frame->next));
3002}
3003
3004/* Return the reason why we can't unwind past FRAME. */
3005
3008{
3009 /* Fill-in STOP_REASON. */
3010 get_prev_frame_always (frame);
3011 gdb_assert (frame->prev_p);
3012
3013 return frame->stop_reason;
3014}
3015
3016/* Return a string explaining REASON. */
3017
3018const char *
3020{
3021 switch (reason)
3022 {
3023#define SET(name, description) \
3024 case name: return _(description);
3025#include "unwind_stop_reasons.def"
3026#undef SET
3027
3028 default:
3029 internal_error ("Invalid frame stop reason");
3030 }
3031}
3032
3033const char *
3035{
3036 gdb_assert (fi->prev_p);
3037 gdb_assert (fi->prev == NULL);
3038
3039 /* Return the specific string if we have one. */
3040 if (fi->stop_string != NULL)
3041 return fi->stop_string;
3042
3043 /* Return the generic string if we have nothing better. */
3045}
3046
3047/* Return the enum symbol name of REASON as a string, to use in debug
3048 output. */
3049
3050static const char *
3052{
3053 switch (reason)
3054 {
3055#define SET(name, description) \
3056 case name: return #name;
3057#include "unwind_stop_reasons.def"
3058#undef SET
3059
3060 default:
3061 internal_error ("Invalid frame stop reason");
3062 }
3063}
3064
3065/* Clean up after a failed (wrong unwinder) attempt to unwind past
3066 FRAME. */
3067
3068void
3070{
3071 /* The sniffer should not allocate a prologue cache if it did not
3072 match this frame. */
3073 gdb_assert (frame->prologue_cache == NULL);
3074
3075 /* No sniffer should extend the frame chain; sniff based on what is
3076 already certain. */
3077 gdb_assert (!frame->prev_p);
3078
3079 /* The sniffer should not check the frame's ID; that's circular. */
3080 gdb_assert (frame->this_id.p != frame_id_status::COMPUTED);
3081
3082 /* Clear cached fields dependent on the unwinder.
3083
3084 The previous PC is independent of the unwinder, but the previous
3085 function is not (see get_frame_address_in_block). */
3086 frame->prev_func.status = CC_UNKNOWN;
3087 frame->prev_func.addr = 0;
3088
3089 /* Discard the unwinder last, so that we can easily find it if an assertion
3090 in this function triggers. */
3091 frame->unwind = NULL;
3092}
3093
3094/* Set FRAME's unwinder temporarily, so that we can call a sniffer.
3095 If sniffing fails, the caller should be sure to call
3096 frame_cleanup_after_sniffer. */
3097
3098void
3100 const struct frame_unwind *unwind)
3101{
3102 gdb_assert (frame->unwind == NULL);
3103 frame->unwind = unwind;
3104}
3105
3108
3109/* Definition of the "set backtrace" settings that are exposed as
3110 "backtrace" command options. */
3111
3114
3116
3118 "past-main",
3119 [] (set_backtrace_options *opt) { return &opt->backtrace_past_main; },
3120 show_backtrace_past_main, /* show_cmd_cb */
3121 N_("Set whether backtraces should continue past \"main\"."),
3122 N_("Show whether backtraces should continue past \"main\"."),
3123 N_("Normally the caller of \"main\" is not of interest, so GDB will terminate\n\
3124the backtrace at \"main\". Set this if you need to see the rest\n\
3125of the stack trace."),
3126 },
3127
3129 "past-entry",
3130 [] (set_backtrace_options *opt) { return &opt->backtrace_past_entry; },
3131 show_backtrace_past_entry, /* show_cmd_cb */
3132 N_("Set whether backtraces should continue past the entry point of a program."),
3133 N_("Show whether backtraces should continue past the entry point of a program."),
3134 N_("Normally there are no callers beyond the entry point of a program, so GDB\n\
3135will terminate the backtrace there. Set this if you need to see\n\
3136the rest of the stack trace."),
3137 },
3138};
3139
3140/* Implement the 'maintenance print frame-id' command. */
3141
3142static void
3143maintenance_print_frame_id (const char *args, int from_tty)
3144{
3145 frame_info_ptr frame;
3146
3147 /* Use the currently selected frame, or select a frame based on the level
3148 number passed by the user. */
3149 if (args == nullptr)
3150 frame = get_selected_frame ("No frame selected");
3151 else
3152 {
3153 int level = value_as_long (parse_and_eval (args));
3154 frame = find_relative_frame (get_current_frame (), &level);
3155 }
3156
3157 /* Print the frame-id. */
3158 gdb_assert (frame != nullptr);
3159 gdb_printf ("frame-id for frame #%d: %s\n",
3160 frame_relative_level (frame),
3161 get_frame_id (frame).to_string ().c_str ());
3162}
3163
3164void _initialize_frame ();
3165void
3167{
3168 obstack_init (&frame_cache_obstack);
3169
3171
3173 "frame");
3174
3176 _("\
3177Set backtrace specific variables.\n\
3178Configure backtrace variables such as the backtrace limit"),
3179 _("\
3180Show backtrace specific variables.\n\
3181Show backtrace variables such as the backtrace limit."),
3183 &setlist, &showlist);
3184
3187Set an upper bound on the number of backtrace levels."), _("\
3188Show the upper bound on the number of backtrace levels."), _("\
3189No more than the specified number of frames can be displayed or examined.\n\
3190Literal \"unlimited\" or zero means no limit."),
3191 NULL,
3195
3199
3200 /* Debug this files internals. */
3202Set frame debugging."), _("\
3203Show frame debugging."), _("\
3204When non-zero, frame specific internal debugging is enabled."),
3205 NULL,
3208
3210 _("Print the current frame-id."),
3212}
int regnum
Definition: aarch64-tdep.c:68
const char *const name
Definition: aarch64-tdep.c:67
void annotate_frames_invalid(void)
Definition: annotate.c:201
bool contained_in(const struct block *a, const struct block *b, bool allow_nested)
Definition: block.c:71
const struct block * block_for_pc(CORE_ADDR pc)
Definition: block.c:283
struct symbol * get_frame_function(frame_info_ptr frame)
Definition: blockframe.c:118
CORE_ADDR get_pc_function_start(CORE_ADDR pc)
Definition: blockframe.c:86
static intrusive_list< frame_info_ptr > frame_list
Definition: frame-info.h:169
frame_info * get() const
Definition: frame-info.h:120
void cooked_write(int regnum, const gdb_byte *buf)
Definition: regcache.c:861
const address_space * aspace() const
Definition: regcache.h:342
void restore(readonly_detached_regcache *src)
Definition: regcache.c:276
enum language m_lang
Definition: frame.h:113
struct frame_id m_fid
Definition: frame.h:107
const char * c_str() const
Definition: ui-file.h:218
enum thread_state state
Definition: gdbthread.h:336
bool executing() const
Definition: gdbthread.h:316
struct cmd_list_element * showlist
Definition: cli-cmds.c:125
struct cmd_list_element * maintenanceprintlist
Definition: cli-cmds.c:149
struct cmd_list_element * setlist
Definition: cli-cmds.c:117
struct cmd_list_element * showdebuglist
Definition: cli-cmds.c:165
struct cmd_list_element * setdebuglist
Definition: cli-cmds.c:163
set_show_commands add_setshow_uinteger_cmd(const char *name, enum command_class theclass, unsigned int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
Definition: cli-decode.c:1053
struct cmd_list_element * add_cmd(const char *name, enum command_class theclass, const char *doc, struct cmd_list_element **list)
Definition: cli-decode.c:233
set_show_commands add_setshow_prefix_cmd(const char *name, command_class theclass, const char *set_doc, const char *show_doc, cmd_list_element **set_subcommands_list, cmd_list_element **show_subcommands_list, cmd_list_element **set_list, cmd_list_element **show_list)
Definition: cli-decode.c:428
set_show_commands add_setshow_boolean_cmd(const char *name, enum command_class theclass, bool *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
Definition: cli-decode.c:739
@ class_obscure
Definition: command.h:64
@ class_maintenance
Definition: command.h:65
@ class_stack
Definition: command.h:56
void write_memory(CORE_ADDR memaddr, const bfd_byte *myaddr, ssize_t len)
Definition: corefile.c:346
ULONGEST read_memory_unsigned_integer(CORE_ADDR memaddr, int len, enum bfd_endian byte_order)
Definition: corefile.c:305
void read_memory(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
Definition: corefile.c:237
LONGEST read_memory_integer(CORE_ADDR memaddr, int len, enum bfd_endian byte_order)
Definition: corefile.c:295
language
Definition: defs.h:211
@ language_unknown
Definition: defs.h:212
lval_type
Definition: defs.h:360
@ lval_memory
Definition: defs.h:364
@ lval_register
Definition: defs.h:366
static LONGEST extract_signed_integer(gdb::array_view< const gdb_byte > buf, enum bfd_endian byte_order)
Definition: defs.h:511
static ULONGEST extract_unsigned_integer(gdb::array_view< const gdb_byte > buf, enum bfd_endian byte_order)
Definition: defs.h:526
void dummy_frame_pop(frame_id dummy_id, thread_info *thread)
Definition: dummy-frame.c:206
struct value * parse_and_eval(const char *exp)
Definition: eval.c:70
const struct frame_base * frame_base_find_by_frame(frame_info_ptr this_frame)
Definition: frame-base.c:102
const struct frame_id null_frame_id
Definition: frame.c:664
@ FID_STACK_SENTINEL
Definition: frame-id.h:34
@ FID_STACK_OUTER
Definition: frame-id.h:40
@ FID_STACK_VALID
Definition: frame-id.h:31
@ FID_STACK_UNAVAILABLE
Definition: frame-id.h:45
@ FID_STACK_INVALID
Definition: frame-id.h:28
void frame_unwind_find_by_frame(frame_info_ptr this_frame, void **this_cache)
Definition: frame-unwind.c:184
const struct frame_id null_frame_id
Definition: frame.c:664
frame_info_ptr get_next_frame(frame_info_ptr this_frame)
Definition: frame.c:1968
enum unwind_stop_reason get_frame_unwind_stop_reason(frame_info_ptr frame)
Definition: frame.c:3007
static frame_info_ptr skip_artificial_frames(frame_info_ptr frame)
Definition: frame.c:507
struct program_space * get_frame_program_space(frame_info_ptr frame)
Definition: frame.c:2845
int frame_relative_level(frame_info_ptr fi)
Definition: frame.c:2826
struct value * get_frame_register_value(frame_info_ptr frame, int regnum)
Definition: frame.c:1285
static frame_info_ptr get_prev_frame_raw(frame_info_ptr this_frame)
Definition: frame.c:2369
const char * frame_stop_reason_string(frame_info_ptr fi)
Definition: frame.c:3034
ULONGEST get_frame_register_unsigned(frame_info_ptr frame, int regnum)
Definition: frame.c:1351
void frame_cleanup_after_sniffer(frame_info_ptr frame)
Definition: frame.c:3069
ULONGEST frame_unwind_register_unsigned(frame_info_ptr next_frame, int regnum)
Definition: frame.c:1323
static void maintenance_print_frame_id(const char *args, int from_tty)
Definition: frame.c:3143
void restore_selected_frame(frame_id frame_id, int frame_level) noexcept
Definition: frame.c:1695
frame_info_ptr skip_unwritable_frames(frame_info_ptr frame)
Definition: frame.c:528
static struct cmd_list_element * set_backtrace_cmdlist
Definition: frame.c:3106
frame_info_ptr deprecated_safe_get_selected_frame(void)
Definition: frame.c:1832
LONGEST get_frame_register_signed(frame_info_ptr frame, int regnum)
Definition: frame.c:1317
LONGEST get_frame_memory_signed(frame_info_ptr this_frame, CORE_ADDR addr, int len)
Definition: frame.c:2877
void select_frame(frame_info_ptr fi)
Definition: frame.c:1852
CORE_ADDR frame_unwind_caller_pc(frame_info_ptr this_frame)
Definition: frame.c:994
CORE_ADDR get_frame_pc(frame_info_ptr frame)
Definition: frame.c:2592
std::unique_ptr< readonly_detached_regcache > frame_save_as_regcache(frame_info_ptr this_frame)
Definition: frame.c:1061
static const char * frame_type_str(frame_type type)
Definition: frame.c:423
const struct frame_id sentinel_frame_id
Definition: frame.c:665
void get_frame_memory(frame_info_ptr this_frame, CORE_ADDR addr, gdb::array_view< gdb_byte > buffer)
Definition: frame.c:2870
bool read_frame_register_unsigned(frame_info_ptr frame, int regnum, ULONGEST *val)
Definition: frame.c:1357
void _initialize_frame()
Definition: frame.c:3166
CORE_ADDR get_frame_sp(frame_info_ptr this_frame)
Definition: frame.c:2995
void reinit_frame_cache(void)
Definition: frame.c:2006
static void compute_frame_id(frame_info_ptr fi)
Definition: frame.c:561
void frame_pop(frame_info_ptr this_frame)
Definition: frame.c:1078
struct frame_id get_stack_frame_id(frame_info_ptr next_frame)
Definition: frame.c:638
static bool inside_main_func(frame_info_ptr this_frame)
Definition: frame.c:2437
CORE_ADDR get_frame_base_address(frame_info_ptr fi)
Definition: frame.c:2767
static void invalidate_selected_frame()
Definition: frame.c:1842
frame_info_ptr get_prev_frame_always(frame_info_ptr this_frame)
Definition: frame.c:2329
set_backtrace_options user_set_backtrace_options
Definition: frame.c:69
const address_space * get_frame_address_space(frame_info_ptr frame)
Definition: frame.c:2862
static struct obstack frame_cache_obstack
Definition: frame.c:1601
static frame_info_ptr selected_frame
Definition: frame.c:1680
LONGEST frame_unwind_register_signed(frame_info_ptr next_frame, int regnum)
Definition: frame.c:1291
static const char * frame_stop_reason_symbol_string(enum unwind_stop_reason reason)
Definition: frame.c:3051
bool frame_id_p(frame_id l)
Definition: frame.c:735
static frame_info_ptr get_prev_frame_always_1(frame_info_ptr this_frame)
Definition: frame.c:2173
struct frame_id frame_id_build_special(CORE_ADDR stack_addr, CORE_ADDR code_addr, CORE_ADDR special_addr)
Definition: frame.c:669
void get_frame_register(frame_info_ptr frame, int regnum, gdb_byte *buf)
Definition: frame.c:1215
bool frame_debug
Definition: frame.c:336
bool get_frame_func_if_available(frame_info_ptr this_frame, CORE_ADDR *pc)
Definition: frame.c:1007
bool frame_id_artificial_p(frame_id l)
Definition: frame.c:746
const char * unwind_stop_reason_to_string(enum unwind_stop_reason reason)
Definition: frame.c:3019
static void frame_observer_target_changed(struct target_ops *target)
Definition: frame.c:1998
struct frame_id frame_id_build(CORE_ADDR stack_addr, CORE_ADDR code_addr)
Definition: frame.c:713
struct frame_id frame_id_build_wild(CORE_ADDR stack_addr)
Definition: frame.c:725
static bool frame_id_inner(struct gdbarch *gdbarch, struct frame_id l, struct frame_id r)
Definition: frame.c:822
cached_copy_status
Definition: frame.c:77
@ CC_VALUE
Definition: frame.c:82
@ CC_UNKNOWN
Definition: frame.c:79
@ CC_UNAVAILABLE
Definition: frame.c:88
@ CC_NOT_SAVED
Definition: frame.c:85
void save_selected_frame(frame_id *frame_id, int *frame_level) noexcept
Definition: frame.c:1685
static unsigned int frame_cache_generation
Definition: frame.c:58
struct frame_id frame_id_build_unavailable_stack_special(CORE_ADDR code_addr, CORE_ADDR special_addr)
Definition: frame.c:699
static void frame_stash_invalidate(void)
Definition: frame.c:315
struct gdbarch * frame_unwind_arch(frame_info_ptr next_frame)
Definition: frame.c:2913
const gdb::option::option_def set_backtrace_option_defs[]
Definition: frame.c:3115
struct gdbarch * get_frame_arch(frame_info_ptr this_frame)
Definition: frame.c:2907
static bool frame_stash_add(frame_info *frame)
Definition: frame.c:276
static void frame_stash_create(void)
Definition: frame.c:263
struct value * frame_unwind_register_value(frame_info_ptr next_frame, int regnum)
Definition: frame.c:1222
enum frame_type get_frame_type(frame_info_ptr frame)
Definition: frame.c:2835
static void show_frame_debug(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
Definition: frame.c:339
struct frame_id frame_unwind_caller_id(frame_info_ptr next_frame)
Definition: frame.c:644
bool get_frame_pc_masked(frame_info_ptr frame)
Definition: frame.c:204
void frame_prepare_for_sniffer(frame_info_ptr frame, const struct frame_unwind *unwind)
Definition: frame.c:3099
struct program_space * frame_unwind_program_space(frame_info_ptr this_frame)
Definition: frame.c:2851
bool frame_unwinder_is(frame_info_ptr fi, const frame_unwind *unwinder)
Definition: frame.c:2814
bool get_frame_pc_if_available(frame_info_ptr frame, CORE_ADDR *pc)
Definition: frame.c:2599
CORE_ADDR get_frame_args_address(frame_info_ptr fi)
Definition: frame.c:2796
bool get_frame_address_in_block_if_available(frame_info_ptr this_frame, CORE_ADDR *pc)
Definition: frame.c:2682
static frame_info_ptr frame_stash_find(struct frame_id id)
Definition: frame.c:300
CORE_ADDR get_frame_locals_address(frame_info_ptr fi)
Definition: frame.c:2781
void frame_unwind_register(frame_info_ptr next_frame, int regnum, gdb_byte *buf)
Definition: frame.c:1195
static void frame_register(frame_info_ptr frame, int regnum, int *optimizedp, int *unavailablep, enum lval_type *lvalp, CORE_ADDR *addrp, int *realnump, gdb_byte *bufferp)
Definition: frame.c:1175
ULONGEST get_frame_memory_unsigned(frame_info_ptr this_frame, CORE_ADDR addr, int len)
Definition: frame.c:2887
struct frame_id frame_id_build_unavailable_stack(CORE_ADDR code_addr)
Definition: frame.c:686
void * frame_obstack_zalloc(unsigned long size)
Definition: frame.c:1604
const struct frame_id outer_frame_id
Definition: frame.c:666
bool has_stack_frames()
Definition: frame.c:1784
static bool inside_entry_func(frame_info_ptr this_frame)
Definition: frame.c:2474
CORE_ADDR get_frame_func(frame_info_ptr this_frame)
Definition: frame.c:1050
static frame_info * sentinel_frame
Definition: frame.c:55
static hashval_t frame_addr_hash(const void *ap)
Definition: frame.c:224
static void show_backtrace_past_entry(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
Definition: frame.c:360
void put_frame_register_bytes(frame_info_ptr frame, int regnum, CORE_ADDR offset, gdb::array_view< const gdb_byte > buffer)
Definition: frame.c:1521
frame_info_ptr get_selected_frame(const char *message)
Definition: frame.c:1813
static CORE_ADDR frame_unwind_pc(frame_info_ptr this_frame)
Definition: frame.c:920
frame_info_ptr frame_find_by_id(struct frame_id id)
Definition: frame.c:868
frame_id_status
Definition: frame.c:92
bool get_frame_register_bytes(frame_info_ptr frame, int regnum, CORE_ADDR offset, gdb::array_view< gdb_byte > buffer, int *optimizedp, int *unavailablep)
Definition: frame.c:1432
static frame_id selected_frame_id
Definition: frame.c:1675
static void show_backtrace_past_main(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
Definition: frame.c:348
static void frame_debug_got_null_frame(frame_info_ptr this_frame, const char *reason)
Definition: frame.c:2422
bool deprecated_frame_register_read(frame_info_ptr frame, int regnum, gdb_byte *myaddr)
Definition: frame.c:1416
static void show_backtrace_limit(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
Definition: frame.c:371
static struct cmd_list_element * show_backtrace_cmdlist
Definition: frame.c:3107
void set_frame_previous_pc_masked(frame_info_ptr frame)
Definition: frame.c:196
enum language get_frame_language(frame_info_ptr frame)
Definition: frame.c:2954
unsigned int get_frame_cache_generation()
Definition: frame.c:63
void frame_register_unwind(frame_info_ptr next_frame, int regnum, int *optimizedp, int *unavailablep, enum lval_type *lvalp, CORE_ADDR *addrp, int *realnump, gdb_byte *bufferp)
Definition: frame.c:1127
frame_info_ptr get_current_frame(void)
Definition: frame.c:1615
frame_info_ptr skip_tailcall_frames(frame_info_ptr frame)
Definition: frame.c:543
static void frame_register_unwind_location(frame_info_ptr this_frame, int regnum, int *optimizedp, enum lval_type *lvalp, CORE_ADDR *addrp, int *realnump)
Definition: frame.c:2041
static int selected_frame_level
Definition: frame.c:1676
CORE_ADDR get_frame_address_in_block(frame_info_ptr this_frame)
Definition: frame.c:2622
frame_info_ptr create_new_frame(CORE_ADDR addr, CORE_ADDR pc)
Definition: frame.c:1929
static htab_t frame_stash
Definition: frame.c:217
static frame_info_ptr get_prev_frame_maybe_check_cycle(frame_info_ptr this_frame)
Definition: frame.c:2085
static void lookup_selected_frame(struct frame_id a_frame_id, int frame_level)
Definition: frame.c:1720
struct frame_id get_frame_id(frame_info_ptr fi)
Definition: frame.c:607
bool safe_frame_unwind_memory(frame_info_ptr this_frame, CORE_ADDR addr, gdb::array_view< gdb_byte > buffer)
Definition: frame.c:2897
frame_info_ptr get_prev_frame(frame_info_ptr this_frame)
Definition: frame.c:2494
void put_frame_register(frame_info_ptr frame, int regnum, const gdb_byte *buf)
Definition: frame.c:1378
symtab_and_line find_frame_sal(frame_info_ptr frame)
Definition: frame.c:2701
struct gdbarch * frame_unwind_caller_arch(frame_info_ptr next_frame)
Definition: frame.c:2939
frame_info_ptr get_next_frame_sentinel_okay(frame_info_ptr this_frame)
Definition: frame.c:1981
CORE_ADDR get_frame_base(frame_info_ptr fi)
Definition: frame.c:2759
static int frame_addr_hash_eq(const void *a, const void *b)
Definition: frame.c:251
static frame_info * create_sentinel_frame(struct program_space *pspace, struct regcache *regcache)
Definition: frame.c:1572
@ SRC_AND_LOC
Definition: frame.h:594
void restore_selected_frame(frame_id frame_id, int frame_level) noexcept
Definition: frame.c:1695
frame_type
Definition: frame.h:176
@ ARCH_FRAME
Definition: frame.h:192
@ DUMMY_FRAME
Definition: frame.h:182
@ TAILCALL_FRAME
Definition: frame.h:187
@ SIGTRAMP_FRAME
Definition: frame.h:190
@ NORMAL_FRAME
Definition: frame.h:179
@ SENTINEL_FRAME
Definition: frame.h:195
@ INLINE_FRAME
Definition: frame.h:185
void save_selected_frame(frame_id *frame_id, int *frame_level) noexcept
Definition: frame.c:1685
#define frame_debug_printf(fmt,...)
Definition: frame.h:122
void print_stack_frame(frame_info_ptr, int print_level, enum print_what print_what, int set_current_sal)
Definition: stack.c:356
unwind_stop_reason
Definition: frame.h:436
#define FRAME_SCOPED_DEBUG_ENTER_EXIT
Definition: frame.h:127
frame_info_ptr find_relative_frame(frame_info_ptr, int *)
Definition: stack.c:2620
#define FRAME_OBSTACK_ZALLOC(TYPE)
Definition: frame.h:608
int gdbarch_pc_regnum(struct gdbarch *gdbarch)
Definition: gdbarch.c:2023
enum bfd_endian gdbarch_byte_order(struct gdbarch *gdbarch)
Definition: gdbarch.c:1370
CORE_ADDR gdbarch_unwind_pc(struct gdbarch *gdbarch, frame_info_ptr next_frame)
Definition: gdbarch.c:2954
CORE_ADDR gdbarch_unwind_sp(struct gdbarch *gdbarch, frame_info_ptr next_frame)
Definition: gdbarch.c:2971
int gdbarch_code_of_frame_writable(struct gdbarch *gdbarch, frame_info_ptr frame)
Definition: gdbarch.c:2279
int gdbarch_inner_than(struct gdbarch *gdbarch, CORE_ADDR lhs, CORE_ADDR rhs)
Definition: gdbarch.c:2695
const struct bfd_arch_info * gdbarch_bfd_arch_info(struct gdbarch *gdbarch)
Definition: gdbarch.c:1361
CORE_ADDR gdbarch_convert_from_func_ptr_addr(struct gdbarch *gdbarch, CORE_ADDR addr, struct target_ops *targ)
Definition: gdbarch.c:3070
static int gdbarch_num_cooked_regs(gdbarch *arch)
Definition: gdbarch.h:377
void validate_registers_access(void)
Definition: thread.c:930
@ THREAD_EXITED
Definition: gdbthread.h:79
struct thread_info * inferior_thread(void)
Definition: thread.c:83
unsigned dummy
Definition: go32-nat.c:8
size_t size
Definition: go32-nat.c:241
ptid_t inferior_ptid
Definition: infcmd.c:91
struct inferior * current_inferior(void)
Definition: inferior.c:54
int frame_inlined_callees(frame_info_ptr this_frame)
Definition: inline-frame.c:444
struct symbol * inline_skipped_symbol(thread_info *thread)
Definition: inline-frame.c:424
const struct language_defn * current_language
Definition: language.c:83
enum language set_language(enum language lang)
Definition: language.c:361
language_mode
Definition: language.h:700
@ language_mode_auto
Definition: language.h:701
struct bound_minimal_symbol lookup_minimal_symbol(const char *name, const char *sfile, struct objfile *objf)
Definition: minsyms.c:363
struct bound_minimal_symbol lookup_minimal_symbol_by_pc(CORE_ADDR pc)
Definition: minsyms.c:977
observable< struct target_ops * > target_changed
void add_setshow_cmds_for_options(command_class cmd_class, void *data, gdb::array_view< const option_def > options, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
Definition: cli-option.c:771
int entry_point_address_query(CORE_ADDR *entry_p)
Definition: objfiles.c:358
struct program_space * current_program_space
Definition: progspace.c:39
int register_size(struct gdbarch *gdbarch, int regnum)
Definition: regcache.c:170
struct regcache * get_current_regcache(void)
Definition: regcache.c:426
const struct frame_unwind sentinel_frame_unwind
void * sentinel_frame_cache(struct regcache *regcache)
struct symbol * symbol
Definition: symtab.h:1494
Definition: block.h:109
CORE_ADDR start() const
Definition: block.h:111
CORE_ADDR value_address() const
Definition: minsyms.h:41
struct minimal_symbol * minsym
Definition: minsyms.h:49
enum language language() const
Definition: symtab.c:408
frame_this_args_ftype * this_args
Definition: frame-base.h:65
frame_this_base_ftype * this_base
Definition: frame-base.h:63
frame_this_locals_ftype * this_locals
Definition: frame-base.h:64
const struct frame_unwind * unwind
Definition: frame-base.h:62
CORE_ADDR stack_addr
Definition: frame-id.h:68
CORE_ADDR code_addr
Definition: frame-id.h:83
std::string to_string() const
Definition: frame.c:383
unsigned int special_addr_p
Definition: frame-id.h:100
unsigned int code_addr_p
Definition: frame-id.h:99
bool operator==(const frame_id &r) const
Definition: frame.c:755
int artificial_depth
Definition: frame-id.h:106
__extension__ enum frame_id_stack_status stack_status
Definition: frame-id.h:98
CORE_ADDR special_addr
Definition: frame-id.h:95
cached_copy_status status
Definition: frame.c:152
struct program_space * pspace
Definition: frame.c:130
const char * stop_string
Definition: frame.c:190
CORE_ADDR value
Definition: frame.c:155
struct gdbarch * arch
Definition: frame.c:147
struct frame_info::@57 prev_func
struct frame_info::@58 this_id
frame_id_status p
Definition: frame.c:168
CORE_ADDR addr
Definition: frame.c:161
bool prev_p
Definition: frame.c:181
struct frame_info::@56 prev_pc
struct frame_info * next
Definition: frame.c:180
const struct frame_unwind * unwind
Definition: frame.c:141
struct frame_info * prev
Definition: frame.c:182
struct frame_info::@55 prev_arch
bool p
Definition: frame.c:146
const struct frame_base * base
Definition: frame.c:175
enum unwind_stop_reason stop_reason
Definition: frame.c:186
void * prologue_cache
Definition: frame.c:140
std::string to_string() const
Definition: frame.c:456
int level
Definition: frame.c:127
void * base_cache
Definition: frame.c:176
bool masked
Definition: frame.c:154
const address_space * aspace
Definition: frame.c:133
enum frame_type type
Definition: frame-unwind.h:164
frame_this_id_ftype * this_id
Definition: frame-unwind.h:168
frame_prev_arch_ftype * prev_arch
Definition: frame-unwind.h:173
frame_unwind_stop_reason_ftype * stop_reason
Definition: frame-unwind.h:167
const char * name
Definition: frame-unwind.h:161
frame_prev_register_ftype * prev_register
Definition: frame-unwind.h:169
const char * linkage_name() const
Definition: symtab.h:459
enum language la_language
Definition: language.h:275
struct objfile * symfile_object_file
Definition: progspace.h:353
bool backtrace_past_main
Definition: frame.h:832
bool backtrace_past_entry
Definition: frame.h:836
unsigned int backtrace_limit
Definition: frame.h:841
const block * value_block() const
Definition: symtab.h:1348
struct symtab * symtab
Definition: symtab.h:1414
unsigned short line() const
Definition: symtab.h:1295
struct symtab * symtab
Definition: symtab.h:2263
CORE_ADDR pc
Definition: symtab.h:2272
struct program_space * pspace
Definition: symtab.h:2261
Definition: gdbtypes.h:922
Definition: value.c:181
std::vector< range > unavailable
Definition: value.c:362
LONGEST offset
Definition: value.c:281
enum lval_type lval
Definition: value.c:210
struct compunit_symtab * find_pc_compunit_symtab(CORE_ADDR pc)
Definition: symtab.c:2954
struct block_symbol lookup_symbol(const char *name, const struct block *block, domain_enum domain, struct field_of_this_result *is_a_field_of_this)
Definition: symtab.c:1967
const char * main_name()
Definition: symtab.c:6309
struct symtab_and_line find_pc_line(CORE_ADDR pc, int notcurrent)
Definition: symtab.c:3297
@ VAR_DOMAIN
Definition: symtab.h:881
int target_has_stack()
Definition: target.c:178
int target_has_registers()
Definition: target.c:190
int target_has_memory()
Definition: target.c:166
int target_read_memory(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
Definition: target.c:1771
int get_traceframe_number(void)
Definition: tracepoint.c:2918
#define current_uiout
Definition: ui-out.h:40
const char * user_reg_map_regnum_to_name(struct gdbarch *gdbarch, int regnum)
Definition: user-regs.c:187
const char * paddress(struct gdbarch *gdbarch, CORE_ADDR addr)
Definition: utils.c:3114
void gdb_printf(struct ui_file *stream, const char *format,...)
Definition: utils.c:1865
void val_print_not_saved(struct ui_file *stream)
Definition: valprint.c:405
struct type * value_type(const struct value *value)
Definition: value.c:1109
int value_entirely_available(struct value *value)
Definition: value.c:408
gdb::array_view< const gdb_byte > value_contents_all(struct value *value)
Definition: value.c:1284
int value_lazy(const struct value *value)
Definition: value.c:1440
CORE_ADDR value_address(const struct value *value)
Definition: value.c:1607
gdb::array_view< gdb_byte > value_contents_raw(struct value *value)
Definition: value.c:1167
gdb::array_view< const gdb_byte > value_contents(struct value *value)
Definition: value.c:1464
gdb::array_view< gdb_byte > value_contents_writeable(struct value *value)
Definition: value.c:1473
LONGEST value_as_long(struct value *val)
Definition: value.c:2791
int value_optimized_out(struct value *value)
Definition: value.c:1481
value_ref_ptr release_value(struct value *val)
Definition: value.c:1714
#define VALUE_LVAL(val)
Definition: value.h:438
#define VALUE_REGNUM(val)
Definition: value.h:469