56 def _is_limited_frame(frame):
57 """Internal utility to determine if the frame is special or
59 sal = frame.find_sal()
63 or not sal.symtab.filename
64 or frame.type() == gdb.DUMMY_FRAME
65 or frame.type() == gdb.SIGTRAMP_FRAME
81 """Return the name of the frame's function or an address of
82 the function of the frame. First determine if this is a
83 special frame. If not, try to determine filename from GDB's
84 frame internal function API. Finally, if a name cannot be
85 determined return the address. If this function returns an
86 address, GDB will attempt to determine the function name from
87 its internal minimal symbols store (for example, for inferiors
88 without debug-info)."""
90 # Both gdb.Frame, and FrameDecorator have a method called
91 # "function", so determine which object this is.
92 if not isinstance(self._base, gdb.Frame):
93 if hasattr(self._base, "function"):
94 # If it is not a gdb.Frame, and there is already a
95 # "function" method, use that.
96 return self._base.function()
98 frame = self.inferior_frame()
100 if frame.type() == gdb.DUMMY_FRAME:
101 return "<function called from gdb>"
102 elif frame.type() == gdb.SIGTRAMP_FRAME:
103 return "<signal handler called>"
105 func = frame.function()
107 # If we cannot determine the function name, return the
108 # address. If GDB detects an integer value from this function
109 # it will attempt to find the function name from minimal
110 # symbols via its own internal functions.
118 """Return the address of the frame's pc"""
120 if hasattr(self._base, "address"):
121 return self._base.address()
123 frame = self.inferior_frame()
127 """Return the filename associated with this frame, detecting
128 and returning the appropriate library name is this is a shared
131 if hasattr(self._base, "filename"):
132 return self._base.filename()
134 frame = self.inferior_frame()
135 sal = frame.find_sal()
136 if not sal.symtab or not sal.symtab.filename:
138 return gdb.solib_name(pc)
140 return sal.symtab.filename
142 def frame_args(self):
143 """Return an iterable of frame arguments for this frame, if
144 any. The iterable object contains objects conforming with the
145 Symbol/Value interface. If there are no frame arguments, or
146 if this frame is deemed to be a special case, return None."""
148 if hasattr(self._base, "frame_args"):
149 return self._base.frame_args()
151 frame = self.inferior_frame()
152 if self._is_limited_frame(frame):
155 args = FrameVars(frame)
156 return args.fetch_frame_args()
158 def frame_locals(self):
159 """Return an iterable of local variables for this frame, if
160 any. The iterable object contains objects conforming with the
161 Symbol/Value interface. If there are no frame locals, or if
162 this frame is deemed to be a special case, return None."""
164 if hasattr(self._base, "frame_locals"):
165 return self._base.frame_locals()
167 frame = self.inferior_frame()
168 if self._is_limited_frame(frame):
171 args = FrameVars(frame)
172 return args.fetch_frame_locals()
175 """Return line number information associated with the frame's
176 pc. If symbol table/line information does not exist, or if
177 this frame is deemed to be a special case, return None"""
179 if hasattr(self._base, "line"):
180 return self._base.line()
182 frame = self.inferior_frame()
183 if self._is_limited_frame(frame):
186 sal = frame.find_sal()
192 def inferior_frame(self):
193 """Return the gdb.Frame underpinning this frame decorator."""
195 # If 'base' is a frame decorator, we want to call its inferior
196 # frame method. If '_base' is a gdb.Frame, just return that.
197 if hasattr(self._base, "inferior_frame"):
198 return self._base.inferior_frame()