Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.python / py-framefilter-addr.py
1 # Copyright (C) 2021-2022 Free Software Foundation, Inc.
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.
23 class Function_Returns_Address(FrameDecorator):
24 def __init__(self, fobj):
25 super(Function_Returns_Address, self).__init__(fobj)
26 self._fobj = fobj
27
28 def function(self):
29 frame = self.inferior_frame()
30 return frame.pc()
31
32
33 class Frame_Filter:
34 def __init__(self):
35 self.name = "function_returns_address"
36 self.priority = 100
37 self.enabled = True
38 gdb.frame_filters[self.name] = self
39
40 def filter(self, frame_iter):
41 # Python 3.x moved the itertools.imap functionality to map(),
42 # so check if it is available.
43 if hasattr(itertools, "imap"):
44 frame_iter = itertools.imap(Function_Returns_Address, frame_iter)
45 else:
46 frame_iter = map(Function_Returns_Address, frame_iter)
47
48 return frame_iter
49
50
51 Frame_Filter()
This page took 0.02947 seconds and 4 git commands to generate.