Automatic date update in version.in
[binutils-gdb.git] / gdb / frame-id.h
blob0d03b476aef214ad021e7c976339b23f310e1b6e
1 /* Definitions for dealing with stack frames, for GDB, the GNU debugger.
3 Copyright (C) 1986-2024 Free Software Foundation, Inc.
5 This file is part of GDB.
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.
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.
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/>. */
20 #ifndef GDB_FRAME_ID_H
21 #define GDB_FRAME_ID_H 1
23 /* Status of a given frame's stack. */
25 enum frame_id_stack_status
27 /* Stack address is invalid. */
28 FID_STACK_INVALID = 0,
30 /* Stack address is valid, and is found in the stack_addr field. */
31 FID_STACK_VALID = 1,
33 /* Sentinel frame. */
34 FID_STACK_SENTINEL = 2,
36 /* Outer frame. Since a frame's stack address is typically defined as the
37 value the stack pointer had prior to the activation of the frame, an outer
38 frame doesn't have a stack address. The frame ids of frames inlined in the
39 outer frame are also of this type. */
40 FID_STACK_OUTER = 3,
42 /* Stack address is unavailable. I.e., there's a valid stack, but
43 we don't know where it is (because memory or registers we'd
44 compute it from were not collected). */
45 FID_STACK_UNAVAILABLE = -1
48 /* The frame object's ID. This provides a per-frame unique identifier
49 that can be used to relocate a `struct frame_info' after a target
50 resume or a frame cache destruct. It of course assumes that the
51 inferior hasn't unwound the stack past that frame. */
53 struct frame_id
55 /* The frame's stack address. This shall be constant through out
56 the lifetime of a frame. Note that this requirement applies to
57 not just the function body, but also the prologue and (in theory
58 at least) the epilogue. Since that value needs to fall either on
59 the boundary, or within the frame's address range, the frame's
60 outer-most address (the inner-most address of the previous frame)
61 is used. Watch out for all the legacy targets that still use the
62 function pointer register or stack pointer register. They are
63 wrong.
65 This field is valid only if frame_id.stack_status is
66 FID_STACK_VALID. It will be 0 for other
67 FID_STACK_... statuses. */
68 CORE_ADDR stack_addr;
70 /* The frame's code address. This shall be constant through out the
71 lifetime of the frame. While the PC (a.k.a. resume address)
72 changes as the function is executed, this code address cannot.
73 Typically, it is set to the address of the entry point of the
74 frame's function (as returned by get_frame_func).
76 For inlined functions (INLINE_DEPTH != 0), this is the address of
77 the first executed instruction in the block corresponding to the
78 inlined function.
80 This field is valid only if code_addr_p is true. Otherwise, this
81 frame is considered to have a wildcard code address, i.e. one that
82 matches every address value in frame comparisons. */
83 CORE_ADDR code_addr;
85 /* The frame's special address. This shall be constant through out the
86 lifetime of the frame. This is used for architectures that may have
87 frames that do not change the stack but are still distinct and have
88 some form of distinct identifier (e.g. the ia64 which uses a 2nd
89 stack for registers). This field is treated as unordered - i.e. will
90 not be used in frame ordering comparisons.
92 This field is valid only if special_addr_p is true. Otherwise, this
93 frame is considered to have a wildcard special address, i.e. one that
94 matches every address value in frame comparisons. */
95 CORE_ADDR special_addr;
97 /* Flags to indicate the above fields have valid contents. */
98 ENUM_BITFIELD(frame_id_stack_status) stack_status : 3;
99 unsigned int code_addr_p : 1;
100 unsigned int special_addr_p : 1;
102 /* True if this frame was created from addresses given by the user (see
103 create_new_frame) rather than through unwinding. */
104 unsigned int user_created_p : 1;
106 /* It is non-zero for a frame made up by GDB without stack data
107 representation in inferior, such as INLINE_FRAME or TAILCALL_FRAME.
108 Caller of inlined function will have it zero, each more inner called frame
109 will have it increasingly one, two etc. Similarly for TAILCALL_FRAME. */
110 int artificial_depth;
112 /* Return a string representation of this frame id. */
113 std::string to_string () const;
115 /* Returns true when this frame_id and R identify the same
116 frame. */
117 bool operator== (const frame_id &r) const;
119 /* Inverse of ==. */
120 bool operator!= (const frame_id &r) const
122 return !(*this == r);
126 /* Methods for constructing and comparing Frame IDs. */
128 /* For convenience. All fields are zero. This means "there is no frame". */
129 extern const struct frame_id null_frame_id;
131 /* This means "there is no frame ID, but there is a frame". It should be
132 replaced by best-effort frame IDs for the outermost frame, somehow.
133 The implementation is only special_addr_p set. */
134 extern const struct frame_id outer_frame_id;
136 /* Return true if ID represents a sentinel frame. */
137 static inline bool
138 is_sentinel_frame_id (frame_id id)
140 return id.stack_status == FID_STACK_SENTINEL;
143 #endif /* ifdef GDB_FRAME_ID_H */