]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.python/py-unwind-maint.py
Update copyright year range in all GDB files
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.python / py-unwind-maint.py
CommitLineData
3666a048 1# Copyright (C) 2015-2021 Free Software Foundation, Inc.
d11916aa
SS
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# This file is part of the GDB testsuite. It tests python unwinders.
17
18import re
19import gdb.types
20from gdb.unwinder import Unwinder, register_unwinder
21
22class TestGlobalUnwinder(Unwinder):
23 def __init__(self):
24 super(TestGlobalUnwinder, self).__init__("global_unwinder")
25
26 def __call__(self, unwinder_info):
40d2f8d6 27 print("%s called" % self.name)
d11916aa
SS
28 return None
29
30class TestProgspaceUnwinder(Unwinder):
31 def __init__(self, name):
32 super(TestProgspaceUnwinder, self).__init__("%s_ps_unwinder" % name)
33
34 def __call__(self, unwinder_info):
40d2f8d6 35 print("%s called" % self.name)
d11916aa
SS
36 return None
37
38class TestObjfileUnwinder(Unwinder):
39 def __init__(self, name):
40 super(TestObjfileUnwinder, self).__init__("%s_obj_unwinder" % name)
41
42 def __call__(self, unwinder_info):
40d2f8d6 43 print("%s called" % self.name)
d11916aa
SS
44 return None
45
46
47
48gdb.unwinder.register_unwinder(None, TestGlobalUnwinder())
49saw_runtime_error = False
50try:
51 gdb.unwinder.register_unwinder(None, TestGlobalUnwinder(), replace=False)
52except RuntimeError:
53 saw_runtime_error = True
54if not saw_runtime_error:
55 raise RuntimeError("Missing runtime error from register_unwinder.")
56gdb.unwinder.register_unwinder(None, TestGlobalUnwinder(), replace=True)
57gdb.unwinder.register_unwinder(gdb.current_progspace(),
58 TestProgspaceUnwinder("py_unwind_maint"))
40d2f8d6 59print("Python script imported")