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