]>
Commit | Line | Data |
---|---|---|
4a94e368 | 1 | # Copyright (C) 2021-2022 Free Software Foundation, Inc. |
7807d76a AB |
2 | |
3 | # This program is free software; you can redistribute it and/or modify | |
4 | # it under the terms of the GNU General Public License as published by | |
5 | # the Free Software Foundation; either version 3 of the License, or | |
6 | # (at your option) any later version. | |
7 | # | |
8 | # This program is distributed in the hope that it will be useful, | |
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | # GNU General Public License for more details. | |
12 | # | |
13 | # You should have received a copy of the GNU General Public License | |
14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
15 | ||
16 | import gdb | |
17 | import itertools | |
18 | from gdb.FrameDecorator import FrameDecorator | |
19 | import copy | |
20 | ||
21 | # A FrameDecorator that just returns gdb.Frame.pc () from 'function'. | |
22 | # We want to ensure that GDB correctly handles this case. | |
13123da8 | 23 | class Function_Returns_Address(FrameDecorator): |
7807d76a | 24 | def __init__(self, fobj): |
13123da8 | 25 | super(Function_Returns_Address, self).__init__(fobj) |
7807d76a AB |
26 | self._fobj = fobj |
27 | ||
13123da8 SM |
28 | def function(self): |
29 | frame = self.inferior_frame() | |
30 | return frame.pc() | |
7807d76a | 31 | |
7807d76a | 32 | |
13123da8 SM |
33 | class Frame_Filter: |
34 | def __init__(self): | |
7807d76a AB |
35 | self.name = "function_returns_address" |
36 | self.priority = 100 | |
37 | self.enabled = True | |
13123da8 | 38 | gdb.frame_filters[self.name] = self |
7807d76a | 39 | |
13123da8 | 40 | def filter(self, frame_iter): |
7807d76a AB |
41 | # Python 3.x moved the itertools.imap functionality to map(), |
42 | # so check if it is available. | |
43 | if hasattr(itertools, "imap"): | |
13123da8 | 44 | frame_iter = itertools.imap(Function_Returns_Address, frame_iter) |
7807d76a AB |
45 | else: |
46 | frame_iter = map(Function_Returns_Address, frame_iter) | |
47 | ||
48 | return frame_iter | |
49 | ||
13123da8 | 50 | |
7807d76a | 51 | Frame_Filter() |