xref: /openbsd-src/gnu/usr.bin/binutils/gdb/tramp-frame.h (revision 11efff7f3ac2b3cfeff0c0cddc14294d9b3aca4f)
1*11efff7fSkettenis /* Signal trampoline unwinder, for GDB the GNU Debugger.
2*11efff7fSkettenis 
3*11efff7fSkettenis    Copyright 2004 Free Software Foundation, Inc.
4*11efff7fSkettenis 
5*11efff7fSkettenis    This file is part of GDB.
6*11efff7fSkettenis 
7*11efff7fSkettenis    This program is free software; you can redistribute it and/or modify
8*11efff7fSkettenis    it under the terms of the GNU General Public License as published by
9*11efff7fSkettenis    the Free Software Foundation; either version 2 of the License, or
10*11efff7fSkettenis    (at your option) any later version.
11*11efff7fSkettenis 
12*11efff7fSkettenis    This program is distributed in the hope that it will be useful,
13*11efff7fSkettenis    but WITHOUT ANY WARRANTY; without even the implied warranty of
14*11efff7fSkettenis    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15*11efff7fSkettenis    GNU General Public License for more details.
16*11efff7fSkettenis 
17*11efff7fSkettenis    You should have received a copy of the GNU General Public License
18*11efff7fSkettenis    along with this program; if not, write to the Free Software
19*11efff7fSkettenis    Foundation, Inc., 59 Temple Place - Suite 330,
20*11efff7fSkettenis    Boston, MA 02111-1307, USA.  */
21*11efff7fSkettenis 
22*11efff7fSkettenis #ifndef TRAMP_FRAME_H
23*11efff7fSkettenis #define TRAMP_FRAME_H
24*11efff7fSkettenis 
25*11efff7fSkettenis #include "frame.h"		/* For "enum frame_type".  */
26*11efff7fSkettenis 
27*11efff7fSkettenis struct trad_frame;
28*11efff7fSkettenis struct frame_info;
29*11efff7fSkettenis struct trad_frame_cache;
30*11efff7fSkettenis 
31*11efff7fSkettenis /* A trampoline consists of a small sequence of instructions placed at
32*11efff7fSkettenis    an unspecified location in the inferior's address space.  The only
33*11efff7fSkettenis    identifying attribute of the trampoline's address is that it does
34*11efff7fSkettenis    not fall inside an object file's section.
35*11efff7fSkettenis 
36*11efff7fSkettenis    The only way to identify a trampoline is to perform a brute force
37*11efff7fSkettenis    examination of the instructions at and around the PC.
38*11efff7fSkettenis 
39*11efff7fSkettenis    This module provides a convent interface for performing that
40*11efff7fSkettenis    operation.  */
41*11efff7fSkettenis 
42*11efff7fSkettenis /* A trampoline descriptor.  */
43*11efff7fSkettenis 
44*11efff7fSkettenis /* Magic instruction that to mark the end of the signal trampoline
45*11efff7fSkettenis    instruction sequence.  */
46*11efff7fSkettenis #define TRAMP_SENTINEL_INSN ((LONGEST) -1)
47*11efff7fSkettenis 
48*11efff7fSkettenis struct tramp_frame
49*11efff7fSkettenis {
50*11efff7fSkettenis   /* The trampoline's type, some a signal trampolines, some are normal
51*11efff7fSkettenis      call-frame trampolines (aka thunks).  */
52*11efff7fSkettenis   enum frame_type frame_type;
53*11efff7fSkettenis   /* The trampoline's entire instruction sequence.  It consists of a
54*11efff7fSkettenis      bytes/mask pair.  Search for this in the inferior at or around
55*11efff7fSkettenis      the frame's PC.  It is assumed that the PC is INSN_SIZE aligned,
56*11efff7fSkettenis      and that each element of TRAMP contains one INSN_SIZE
57*11efff7fSkettenis      instruction.  It is also assumed that INSN[0] contains the first
58*11efff7fSkettenis      instruction of the trampoline and hence the address of the
59*11efff7fSkettenis      instruction matching INSN[0] is the trampoline's "func" address.
60*11efff7fSkettenis      The instruction sequence is terminated by
61*11efff7fSkettenis      TRAMP_SENTINEL_INSN.  */
62*11efff7fSkettenis   int insn_size;
63*11efff7fSkettenis   struct
64*11efff7fSkettenis   {
65*11efff7fSkettenis     ULONGEST bytes;
66*11efff7fSkettenis     ULONGEST mask;
67*11efff7fSkettenis   } insn[8];
68*11efff7fSkettenis   /* Initialize a trad-frame cache corresponding to the tramp-frame.
69*11efff7fSkettenis      FUNC is the address of the instruction TRAMP[0] in memory.  */
70*11efff7fSkettenis   void (*init) (const struct tramp_frame *self,
71*11efff7fSkettenis 		struct frame_info *next_frame,
72*11efff7fSkettenis 		struct trad_frame_cache *this_cache,
73*11efff7fSkettenis 		CORE_ADDR func);
74*11efff7fSkettenis };
75*11efff7fSkettenis 
76*11efff7fSkettenis void tramp_frame_prepend_unwinder (struct gdbarch *gdbarch,
77*11efff7fSkettenis 				   const struct tramp_frame *tramp);
78*11efff7fSkettenis 
79*11efff7fSkettenis #endif
80