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