trad-frame.h revision 1.7 1 1.1 christos /* Traditional frame unwind support, for GDB the GNU Debugger.
2 1.1 christos
3 1.7 christos Copyright (C) 2003-2017 Free Software Foundation, Inc.
4 1.1 christos
5 1.1 christos This file is part of GDB.
6 1.1 christos
7 1.1 christos This program is free software; you can redistribute it and/or modify
8 1.1 christos it under the terms of the GNU General Public License as published by
9 1.1 christos the Free Software Foundation; either version 3 of the License, or
10 1.1 christos (at your option) any later version.
11 1.1 christos
12 1.1 christos This program is distributed in the hope that it will be useful,
13 1.1 christos but WITHOUT ANY WARRANTY; without even the implied warranty of
14 1.1 christos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 1.1 christos GNU General Public License for more details.
16 1.1 christos
17 1.1 christos You should have received a copy of the GNU General Public License
18 1.1 christos along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 1.1 christos
20 1.1 christos #ifndef TRAD_FRAME_H
21 1.1 christos #define TRAD_FRAME_H
22 1.1 christos
23 1.1 christos #include "frame.h" /* For "struct frame_id". */
24 1.1 christos
25 1.1 christos struct frame_info;
26 1.1 christos struct trad_frame_cache;
27 1.1 christos
28 1.1 christos /* A simple, or traditional frame cache.
29 1.1 christos
30 1.1 christos The entire cache is populated in a single pass and then generic
31 1.1 christos routines are used to extract the various cache values. */
32 1.1 christos
33 1.1 christos struct trad_frame_cache *trad_frame_cache_zalloc (struct frame_info *);
34 1.1 christos
35 1.1 christos /* This frame's ID. */
36 1.1 christos void trad_frame_set_id (struct trad_frame_cache *this_trad_cache,
37 1.1 christos struct frame_id this_id);
38 1.1 christos void trad_frame_get_id (struct trad_frame_cache *this_trad_cache,
39 1.1 christos struct frame_id *this_id);
40 1.1 christos void trad_frame_set_this_base (struct trad_frame_cache *this_trad_cache,
41 1.1 christos CORE_ADDR this_base);
42 1.1 christos CORE_ADDR trad_frame_get_this_base (struct trad_frame_cache *this_trad_cache);
43 1.1 christos
44 1.1 christos void trad_frame_set_reg_realreg (struct trad_frame_cache *this_trad_cache,
45 1.1 christos int regnum, int realreg);
46 1.1 christos void trad_frame_set_reg_addr (struct trad_frame_cache *this_trad_cache,
47 1.1 christos int regnum, CORE_ADDR addr);
48 1.1 christos void trad_frame_set_reg_value (struct trad_frame_cache *this_cache,
49 1.1 christos int regnum, LONGEST val);
50 1.1 christos
51 1.1 christos struct value *trad_frame_get_register (struct trad_frame_cache *this_trad_cache,
52 1.1 christos struct frame_info *this_frame,
53 1.1 christos int regnum);
54 1.1 christos
55 1.1 christos /* A traditional saved regs table, indexed by REGNUM, encoding where
56 1.1 christos the value of REGNUM for the previous frame can be found in this
57 1.1 christos frame.
58 1.1 christos
59 1.1 christos The table is initialized with an identity encoding (ADDR == -1,
60 1.1 christos REALREG == REGNUM) indicating that the value of REGNUM in the
61 1.1 christos previous frame can be found in register REGNUM (== REALREG) in this
62 1.1 christos frame.
63 1.1 christos
64 1.1 christos The initial encoding can then be changed:
65 1.1 christos
66 1.1 christos Modify ADDR (REALREG >= 0, ADDR != -1) to indicate that the value
67 1.1 christos of register REGNUM in the previous frame can be found in memory at
68 1.1 christos ADDR in this frame (addr_p, !realreg_p, !value_p).
69 1.1 christos
70 1.1 christos Modify REALREG (REALREG >= 0, ADDR == -1) to indicate that the
71 1.1 christos value of register REGNUM in the previous frame is found in register
72 1.1 christos REALREG in this frame (!addr_p, realreg_p, !value_p).
73 1.1 christos
74 1.1 christos Call trad_frame_set_value (REALREG == -1) to indicate that the
75 1.1 christos value of register REGNUM in the previous frame is found in ADDR
76 1.1 christos (!addr_p, !realreg_p, value_p).
77 1.1 christos
78 1.1 christos Call trad_frame_set_unknown (REALREG == -2) to indicate that the
79 1.1 christos register's value is not known. */
80 1.1 christos
81 1.1 christos struct trad_frame_saved_reg
82 1.1 christos {
83 1.1 christos LONGEST addr; /* A CORE_ADDR fits in a longest. */
84 1.1 christos int realreg;
85 1.1 christos };
86 1.1 christos
87 1.1 christos /* Encode REGNUM value in the trad-frame. */
88 1.1 christos void trad_frame_set_value (struct trad_frame_saved_reg this_saved_regs[],
89 1.1 christos int regnum, LONGEST val);
90 1.1 christos
91 1.1 christos /* Mark REGNUM as unknown. */
92 1.1 christos void trad_frame_set_unknown (struct trad_frame_saved_reg this_saved_regs[],
93 1.1 christos int regnum);
94 1.1 christos
95 1.1 christos /* Convenience functions, return non-zero if the register has been
96 1.1 christos encoded as specified. */
97 1.1 christos int trad_frame_value_p (struct trad_frame_saved_reg this_saved_regs[],
98 1.1 christos int regnum);
99 1.1 christos int trad_frame_addr_p (struct trad_frame_saved_reg this_saved_regs[],
100 1.1 christos int regnum);
101 1.1 christos int trad_frame_realreg_p (struct trad_frame_saved_reg this_saved_regs[],
102 1.1 christos int regnum);
103 1.1 christos
104 1.1 christos
105 1.1 christos /* Return a freshly allocated (and initialized) trad_frame array. */
106 1.1 christos struct trad_frame_saved_reg *trad_frame_alloc_saved_regs (struct frame_info *);
107 1.7 christos struct trad_frame_saved_reg *trad_frame_alloc_saved_regs (struct gdbarch *);
108 1.1 christos
109 1.1 christos /* Given the trad_frame info, return the location of the specified
110 1.1 christos register. */
111 1.1 christos struct value *trad_frame_get_prev_register (struct frame_info *this_frame,
112 1.1 christos struct trad_frame_saved_reg this_saved_regs[],
113 1.1 christos int regnum);
114 1.1 christos
115 1.1 christos #endif
116