ignore invalid DOF provider sections
[binutils-gdb.git] / gdb / testsuite / gdb.python / py-unwind-maint.py
blob288fe071b349873530ddc0ccd7fe28f4204954ce
1 # Copyright (C) 2015 Free Software Foundation, Inc.
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.
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.
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/>.
16 # This file is part of the GDB testsuite. It tests python unwinders.
18 import re
19 import gdb.types
20 from gdb.unwinder import Unwinder, register_unwinder
22 class TestGlobalUnwinder(Unwinder):
23 def __init__(self):
24 super(TestGlobalUnwinder, self).__init__("global_unwinder")
26 def __call__(self, unwinder_info):
27 print("%s called" % self.name)
28 return None
30 class TestProgspaceUnwinder(Unwinder):
31 def __init__(self, name):
32 super(TestProgspaceUnwinder, self).__init__("%s_ps_unwinder" % name)
34 def __call__(self, unwinder_info):
35 print("%s called" % self.name)
36 return None
38 class TestObjfileUnwinder(Unwinder):
39 def __init__(self, name):
40 super(TestObjfileUnwinder, self).__init__("%s_obj_unwinder" % name)
42 def __call__(self, unwinder_info):
43 print("%s called" % self.name)
44 return None
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")