Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.python / py-unwind-maint.py
CommitLineData
88b9d363 1# Copyright (C) 2015-2022 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
13123da8 22
d11916aa
SS
23class TestGlobalUnwinder(Unwinder):
24 def __init__(self):
25 super(TestGlobalUnwinder, self).__init__("global_unwinder")
26
27 def __call__(self, unwinder_info):
40d2f8d6 28 print("%s called" % self.name)
d11916aa
SS
29 return None
30
13123da8 31
d11916aa
SS
32class TestProgspaceUnwinder(Unwinder):
33 def __init__(self, name):
34 super(TestProgspaceUnwinder, self).__init__("%s_ps_unwinder" % name)
35
36 def __call__(self, unwinder_info):
40d2f8d6 37 print("%s called" % self.name)
d11916aa
SS
38 return None
39
13123da8 40
d11916aa
SS
41class TestObjfileUnwinder(Unwinder):
42 def __init__(self, name):
43 super(TestObjfileUnwinder, self).__init__("%s_obj_unwinder" % name)
44
45 def __call__(self, unwinder_info):
40d2f8d6 46 print("%s called" % self.name)
d11916aa
SS
47 return None
48
49
d11916aa
SS
50gdb.unwinder.register_unwinder(None, TestGlobalUnwinder())
51saw_runtime_error = False
52try:
53 gdb.unwinder.register_unwinder(None, TestGlobalUnwinder(), replace=False)
54except RuntimeError:
55 saw_runtime_error = True
56if not saw_runtime_error:
57 raise RuntimeError("Missing runtime error from register_unwinder.")
58gdb.unwinder.register_unwinder(None, TestGlobalUnwinder(), replace=True)
13123da8
SM
59gdb.unwinder.register_unwinder(
60 gdb.current_progspace(), TestProgspaceUnwinder("py_unwind_maint")
61)
40d2f8d6 62print("Python script imported")
This page took 0.773941 seconds and 4 git commands to generate.