1 # Copyright (C) 2020 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 # A dummy stack unwinder used for testing the Python unwinders when we
17 # have inline frames. This unwinder will never claim any frames,
18 # instead, all it does it try to read all registers possible target
19 # registers as part of the frame sniffing process..
22 from gdb
.unwinder
import Unwinder
26 class dummy_unwinder (Unwinder
):
27 """ A dummy unwinder that looks at a bunch of registers as part of
28 the unwinding process."""
30 class frame_id (object):
31 """ Basic frame id."""
33 def __init__ (self
, sp
, pc
):
34 """ Create the frame id."""
39 """Create the unwinder."""
40 Unwinder
.__init
__ (self
, "dummy stack unwinder")
41 self
.void_ptr_t
= gdb
.lookup_type("void").pointer()
44 def get_regs (self
, pending_frame
):
45 """Return a list of register names that should be read. Only
46 gathers the list once, then caches the result."""
47 if (self
.regs
!= None):
50 # Collect the names of all registers to read.
51 self
.regs
= list (pending_frame
.architecture ()
56 def __call__ (self
, pending_frame
):
57 """Actually performs the unwind, or at least sniffs this frame
58 to see if the unwinder should claim it, which is never does."""
60 for r
in (self
.get_regs (pending_frame
)):
61 v
= pending_frame
.read_register (r
).cast (self
.void_ptr_t
)
63 print ("Dummy unwinder, exception")
68 # Register the ComRV stack unwinder.
69 gdb
.unwinder
.register_unwinder (None, dummy_unwinder (), True)
71 print ("Python script imported")
This page took 0.031597 seconds and 4 git commands to generate.