2003-07-15 Andrew Cagney <cagney@redhat.com>
[platform/upstream/binutils.git] / gdb / frame-base.h
1 /* Definitions for a frame base, for GDB, the GNU debugger.
2
3    Copyright 2003 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 #if !defined (FRAME_BASE_H)
23 #define FRAME_BASE_H 1
24
25 struct frame_info;
26 struct frame_id;
27 struct frame_unwind;
28 struct frame_base;
29 struct gdbarch;
30 struct regcache;
31
32 /* For compatibility.  */
33
34 typedef const struct frame_base *(frame_base_p_ftype) (CORE_ADDR pc);
35 extern void frame_base_append_predicate (struct gdbarch *gdbarch,
36                                          frame_base_p_ftype *p);
37
38 /* Assuming the frame chain: (outer) prev <-> this <-> next (inner);
39    and that this is a `normal frame'; use the NEXT frame, and its
40    register unwind method, to determine the address of THIS frame's
41    `base'.
42
43    The exact meaning of `base' is highly dependant on the type of the
44    debug info.  It is assumed that dwarf2, stabs, ... will each
45    provide their own methods.
46
47    A typical implmentation will return the same value for base,
48    locals-base and args-base.  That value, however, will likely be
49    different to the frame ID's stack address.  */
50
51 /* A generic base address.  */
52
53 typedef CORE_ADDR (frame_this_base_ftype) (struct frame_info *next_frame,
54                                            void **this_base_cache);
55
56 /* The base address of the frame's local variables.  */
57
58 typedef CORE_ADDR (frame_this_locals_ftype) (struct frame_info *next_frame,
59                                              void **this_base_cache);
60
61 /* The base address of the frame's arguments / parameters.  */
62
63 typedef CORE_ADDR (frame_this_args_ftype) (struct frame_info *next_frame,
64                                            void **this_base_cache);
65
66 struct frame_base
67 {
68   /* If non-NULL, a low-level unwinder that shares its implementation
69      with this high-level frame-base method.  */
70   const struct frame_unwind *unwind;
71   frame_this_base_ftype *this_base;
72   frame_this_locals_ftype *this_locals;
73   frame_this_args_ftype *this_args;
74 };
75
76 /* Given the NEXT frame, return the frame base methods for THIS frame,
77    or NULL if it can't handle THIS frame.  */
78
79 typedef const struct frame_base *(frame_base_sniffer_ftype) (struct frame_info *next_frame);
80
81 /* Append a frame base sniffer to the list.  The sniffers are polled
82    in the order that they are appended.  */
83
84 extern void frame_base_append_sniffer (struct gdbarch *gdbarch,
85                                        frame_base_sniffer_ftype *sniffer);
86
87 /* Set the default frame base.  If all else fails, this one is
88    returned.  If this isn't set, the default is to use legacy code
89    that uses things like the frame ID's base (ulgh!).  */
90
91 extern void frame_base_set_default (struct gdbarch *gdbarch,
92                                     const struct frame_base *def);
93
94 /* Iterate through the list of frame base handlers until one returns
95    an implementation.  */
96
97 extern const struct frame_base *frame_base_find_by_frame (struct frame_info *next_frame);
98
99 #endif