xref: /dflybsd-src/contrib/gdb-7/gdb/trad-frame.h (revision de8e141f24382815c10a4012d209bbbf7abf1112)
15796c8dcSSimon Schubert /* Traditional frame unwind support, for GDB the GNU Debugger.
25796c8dcSSimon Schubert 
3*ef5ccd6cSJohn Marino    Copyright (C) 2003-2013 Free Software Foundation, Inc.
45796c8dcSSimon Schubert 
55796c8dcSSimon Schubert    This file is part of GDB.
65796c8dcSSimon Schubert 
75796c8dcSSimon Schubert    This program is free software; you can redistribute it and/or modify
85796c8dcSSimon Schubert    it under the terms of the GNU General Public License as published by
95796c8dcSSimon Schubert    the Free Software Foundation; either version 3 of the License, or
105796c8dcSSimon Schubert    (at your option) any later version.
115796c8dcSSimon Schubert 
125796c8dcSSimon Schubert    This program is distributed in the hope that it will be useful,
135796c8dcSSimon Schubert    but WITHOUT ANY WARRANTY; without even the implied warranty of
145796c8dcSSimon Schubert    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
155796c8dcSSimon Schubert    GNU General Public License for more details.
165796c8dcSSimon Schubert 
175796c8dcSSimon Schubert    You should have received a copy of the GNU General Public License
185796c8dcSSimon Schubert    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
195796c8dcSSimon Schubert 
205796c8dcSSimon Schubert #ifndef TRAD_FRAME_H
215796c8dcSSimon Schubert #define TRAD_FRAME_H
225796c8dcSSimon Schubert 
235796c8dcSSimon Schubert #include "frame.h"		/* For "struct frame_id".  */
245796c8dcSSimon Schubert 
255796c8dcSSimon Schubert struct frame_info;
265796c8dcSSimon Schubert struct trad_frame_cache;
275796c8dcSSimon Schubert 
285796c8dcSSimon Schubert /* A simple, or traditional frame cache.
295796c8dcSSimon Schubert 
305796c8dcSSimon Schubert    The entire cache is populated in a single pass and then generic
315796c8dcSSimon Schubert    routines are used to extract the various cache values.  */
325796c8dcSSimon Schubert 
33c50c785cSJohn Marino struct trad_frame_cache *trad_frame_cache_zalloc (struct frame_info *);
345796c8dcSSimon Schubert 
355796c8dcSSimon Schubert /* This frame's ID.  */
365796c8dcSSimon Schubert void trad_frame_set_id (struct trad_frame_cache *this_trad_cache,
375796c8dcSSimon Schubert 			struct frame_id this_id);
385796c8dcSSimon Schubert void trad_frame_get_id (struct trad_frame_cache *this_trad_cache,
395796c8dcSSimon Schubert 			struct frame_id *this_id);
405796c8dcSSimon Schubert void trad_frame_set_this_base (struct trad_frame_cache *this_trad_cache,
415796c8dcSSimon Schubert 			       CORE_ADDR this_base);
425796c8dcSSimon Schubert CORE_ADDR trad_frame_get_this_base (struct trad_frame_cache *this_trad_cache);
435796c8dcSSimon Schubert 
445796c8dcSSimon Schubert void trad_frame_set_reg_realreg (struct trad_frame_cache *this_trad_cache,
455796c8dcSSimon Schubert 				 int regnum, int realreg);
465796c8dcSSimon Schubert void trad_frame_set_reg_unknown (struct trad_frame_cache *this_trad_cache,
475796c8dcSSimon Schubert 				 int regnum, CORE_ADDR addr);
485796c8dcSSimon Schubert void trad_frame_set_reg_addr (struct trad_frame_cache *this_trad_cache,
495796c8dcSSimon Schubert 			      int regnum, CORE_ADDR addr);
505796c8dcSSimon Schubert void trad_frame_set_reg_value (struct trad_frame_cache *this_cache,
515796c8dcSSimon Schubert 			       int regnum, LONGEST val);
525796c8dcSSimon Schubert 
535796c8dcSSimon Schubert struct value *trad_frame_get_register (struct trad_frame_cache *this_trad_cache,
545796c8dcSSimon Schubert 				       struct frame_info *this_frame,
555796c8dcSSimon Schubert 				       int regnum);
565796c8dcSSimon Schubert 
575796c8dcSSimon Schubert /* A traditional saved regs table, indexed by REGNUM, encoding where
585796c8dcSSimon Schubert    the value of REGNUM for the previous frame can be found in this
595796c8dcSSimon Schubert    frame.
605796c8dcSSimon Schubert 
615796c8dcSSimon Schubert    The table is initialized with an identity encoding (ADDR == -1,
625796c8dcSSimon Schubert    REALREG == REGNUM) indicating that the value of REGNUM in the
635796c8dcSSimon Schubert    previous frame can be found in register REGNUM (== REALREG) in this
645796c8dcSSimon Schubert    frame.
655796c8dcSSimon Schubert 
665796c8dcSSimon Schubert    The initial encoding can then be changed:
675796c8dcSSimon Schubert 
685796c8dcSSimon Schubert    Modify ADDR (REALREG >= 0, ADDR != -1) to indicate that the value
695796c8dcSSimon Schubert    of register REGNUM in the previous frame can be found in memory at
705796c8dcSSimon Schubert    ADDR in this frame (addr_p, !realreg_p, !value_p).
715796c8dcSSimon Schubert 
725796c8dcSSimon Schubert    Modify REALREG (REALREG >= 0, ADDR == -1) to indicate that the
735796c8dcSSimon Schubert    value of register REGNUM in the previous frame is found in register
745796c8dcSSimon Schubert    REALREG in this frame (!addr_p, realreg_p, !value_p).
755796c8dcSSimon Schubert 
765796c8dcSSimon Schubert    Call trad_frame_set_value (REALREG == -1) to indicate that the
775796c8dcSSimon Schubert    value of register REGNUM in the previous frame is found in ADDR
785796c8dcSSimon Schubert    (!addr_p, !realreg_p, value_p).
795796c8dcSSimon Schubert 
805796c8dcSSimon Schubert    Call trad_frame_set_unknown (REALREG == -2) to indicate that the
815796c8dcSSimon Schubert    register's value is not known.  */
825796c8dcSSimon Schubert 
835796c8dcSSimon Schubert struct trad_frame_saved_reg
845796c8dcSSimon Schubert {
855796c8dcSSimon Schubert   LONGEST addr; /* A CORE_ADDR fits in a longest.  */
865796c8dcSSimon Schubert   int realreg;
875796c8dcSSimon Schubert };
885796c8dcSSimon Schubert 
895796c8dcSSimon Schubert /* Encode REGNUM value in the trad-frame.  */
905796c8dcSSimon Schubert void trad_frame_set_value (struct trad_frame_saved_reg this_saved_regs[],
915796c8dcSSimon Schubert 			   int regnum, LONGEST val);
925796c8dcSSimon Schubert 
935796c8dcSSimon Schubert /* Mark REGNUM as unknown.  */
945796c8dcSSimon Schubert void trad_frame_set_unknown (struct trad_frame_saved_reg this_saved_regs[],
955796c8dcSSimon Schubert 			     int regnum);
965796c8dcSSimon Schubert 
975796c8dcSSimon Schubert /* Convenience functions, return non-zero if the register has been
985796c8dcSSimon Schubert    encoded as specified.  */
995796c8dcSSimon Schubert int trad_frame_value_p (struct trad_frame_saved_reg this_saved_regs[],
1005796c8dcSSimon Schubert 			int regnum);
1015796c8dcSSimon Schubert int trad_frame_addr_p (struct trad_frame_saved_reg this_saved_regs[],
1025796c8dcSSimon Schubert 		       int regnum);
1035796c8dcSSimon Schubert int trad_frame_realreg_p (struct trad_frame_saved_reg this_saved_regs[],
1045796c8dcSSimon Schubert 			  int regnum);
1055796c8dcSSimon Schubert 
1065796c8dcSSimon Schubert 
1075796c8dcSSimon Schubert /* Return a freshly allocated (and initialized) trad_frame array.  */
108c50c785cSJohn Marino struct trad_frame_saved_reg *trad_frame_alloc_saved_regs (struct frame_info *);
1095796c8dcSSimon Schubert 
1105796c8dcSSimon Schubert /* Given the trad_frame info, return the location of the specified
1115796c8dcSSimon Schubert    register.  */
1125796c8dcSSimon Schubert struct value *trad_frame_get_prev_register (struct frame_info *this_frame,
1135796c8dcSSimon Schubert 					    struct trad_frame_saved_reg this_saved_regs[],
1145796c8dcSSimon Schubert 					    int regnum);
1155796c8dcSSimon Schubert 
1165796c8dcSSimon Schubert #endif
117