]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.python/py-framefilter-addr.py
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.python / py-framefilter-addr.py
CommitLineData
1d506c26 1# Copyright (C) 2021-2024 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
16import gdb
17import itertools
18from gdb.FrameDecorator import FrameDecorator
19import copy
20
09de95fb 21
7807d76a
AB
22# A FrameDecorator that just returns gdb.Frame.pc () from 'function'.
23# We want to ensure that GDB correctly handles this case.
13123da8 24class Function_Returns_Address(FrameDecorator):
7807d76a 25 def __init__(self, fobj):
13123da8 26 super(Function_Returns_Address, self).__init__(fobj)
7807d76a
AB
27 self._fobj = fobj
28
13123da8
SM
29 def function(self):
30 frame = self.inferior_frame()
31 return frame.pc()
7807d76a 32
7807d76a 33
13123da8
SM
34class Frame_Filter:
35 def __init__(self):
7807d76a
AB
36 self.name = "function_returns_address"
37 self.priority = 100
38 self.enabled = True
13123da8 39 gdb.frame_filters[self.name] = self
7807d76a 40
13123da8 41 def filter(self, frame_iter):
7807d76a
AB
42 # Python 3.x moved the itertools.imap functionality to map(),
43 # so check if it is available.
44 if hasattr(itertools, "imap"):
13123da8 45 frame_iter = itertools.imap(Function_Returns_Address, frame_iter)
7807d76a
AB
46 else:
47 frame_iter = map(Function_Returns_Address, frame_iter)
48
49 return frame_iter
50
13123da8 51
7807d76a 52Frame_Filter()