1130803Smarcel/* Code dealing with dummy stack frames, for GDB, the GNU debugger.
2130803Smarcel
3130803Smarcel   Copyright 2002 Free Software Foundation, Inc.
4130803Smarcel
5130803Smarcel   This file is part of GDB.
6130803Smarcel
7130803Smarcel   This program is free software; you can redistribute it and/or modify
8130803Smarcel   it under the terms of the GNU General Public License as published by
9130803Smarcel   the Free Software Foundation; either version 2 of the License, or
10130803Smarcel   (at your option) any later version.
11130803Smarcel
12130803Smarcel   This program is distributed in the hope that it will be useful,
13130803Smarcel   but WITHOUT ANY WARRANTY; without even the implied warranty of
14130803Smarcel   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15130803Smarcel   GNU General Public License for more details.
16130803Smarcel
17130803Smarcel   You should have received a copy of the GNU General Public License
18130803Smarcel   along with this program; if not, write to the Free Software
19130803Smarcel   Foundation, Inc., 59 Temple Place - Suite 330,
20130803Smarcel   Boston, MA 02111-1307, USA.  */
21130803Smarcel
22130803Smarcel#if !defined (DUMMY_FRAME_H)
23130803Smarcel#define DUMMY_FRAME_H 1
24130803Smarcel
25130803Smarcelstruct frame_info;
26130803Smarcelstruct regcache;
27130803Smarcelstruct frame_unwind;
28130803Smarcelstruct frame_id;
29130803Smarcel
30130803Smarcel/* GENERIC DUMMY FRAMES
31130803Smarcel
32130803Smarcel   The following code serves to maintain the dummy stack frames for
33130803Smarcel   inferior function calls (ie. when gdb calls into the inferior via
34130803Smarcel   call_function_by_hand).  This code saves the machine state before
35130803Smarcel   the call in host memory, so we must maintain an independent stack
36130803Smarcel   and keep it consistant etc.  I am attempting to make this code
37130803Smarcel   generic enough to be used by many targets.
38130803Smarcel
39130803Smarcel   The cheapest and most generic way to do CALL_DUMMY on a new target
40130803Smarcel   is probably to define CALL_DUMMY to be empty,
41130803Smarcel   DEPRECATED_CALL_DUMMY_LENGTH to zero, and CALL_DUMMY_LOCATION to
42130803Smarcel   AT_ENTRY.  Then you must remember to define PUSH_RETURN_ADDRESS,
43130803Smarcel   because no call instruction will be being executed by the target.
44130803Smarcel   Also DEPRECATED_FRAME_CHAIN_VALID as
45130803Smarcel   generic_{file,func}_frame_chain_valid and do not set
46130803Smarcel   DEPRECATED_FIX_CALL_DUMMY.  */
47130803Smarcel
48130803Smarcel/* If the PC falls in a dummy frame, return a dummy frame
49130803Smarcel   unwinder.  */
50130803Smarcel
51130803Smarcelextern const struct frame_unwind *dummy_frame_sniffer (struct frame_info *next_frame);
52130803Smarcel
53130803Smarcel/* Does the PC fall in a dummy frame?
54130803Smarcel
55130803Smarcel   This function is used by "frame.c" when creating a new `struct
56130803Smarcel   frame_info'.
57130803Smarcel
58130803Smarcel   Note that there is also very similar code in breakpoint.c (where
59130803Smarcel   the bpstat stop reason is computed).  It is looking for a PC
60130803Smarcel   falling on a dummy_frame breakpoint.  Perhaphs this, and that code
61130803Smarcel   should be combined?
62130803Smarcel
63130803Smarcel   Architecture dependant code, that has access to a frame, should not
64130803Smarcel   use this function.  Instead (get_frame_type() == DUMMY_FRAME)
65130803Smarcel   should be used.
66130803Smarcel
67130803Smarcel   Hmm, but what about threads?  When the dummy-frame code tries to
68130803Smarcel   relocate a dummy frame's saved registers it definitly needs to
69130803Smarcel   differentiate between threads (otherwize it will do things like
70130803Smarcel   clean-up the wrong threads frames).  However, when just trying to
71130803Smarcel   identify a dummy-frame that shouldn't matter.  The wost that can
72130803Smarcel   happen is that a thread is marked as sitting in a dummy frame when,
73130803Smarcel   in reality, its corrupted its stack, to the point that a PC is
74130803Smarcel   pointing into a dummy frame.  */
75130803Smarcel
76130803Smarcelextern int pc_in_dummy_frame (CORE_ADDR pc);
77130803Smarcel
78130803Smarcel/* Return the regcache that belongs to the dummy-frame identifed by PC
79130803Smarcel   and FP, or NULL if no such frame exists.  */
80130803Smarcel/* FIXME: cagney/2002-11-08: The function only exists because of
81130803Smarcel   deprecated_generic_get_saved_register.  Eliminate that function and
82130803Smarcel   this, to, can go.  */
83130803Smarcel
84130803Smarcelextern struct regcache *deprecated_find_dummy_frame_regcache (CORE_ADDR pc,
85130803Smarcel							      CORE_ADDR fp);
86130803Smarcel#endif /* !defined (DUMMY_FRAME_H)  */
87