119370Spst/* Data structures associated with breakpoints in GDB.
2130803Smarcel   Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
3130803Smarcel   2002, 2003, 2004
498944Sobrien   Free Software Foundation, Inc.
519370Spst
698944Sobrien   This file is part of GDB.
719370Spst
898944Sobrien   This program is free software; you can redistribute it and/or modify
998944Sobrien   it under the terms of the GNU General Public License as published by
1098944Sobrien   the Free Software Foundation; either version 2 of the License, or
1198944Sobrien   (at your option) any later version.
1219370Spst
1398944Sobrien   This program is distributed in the hope that it will be useful,
1498944Sobrien   but WITHOUT ANY WARRANTY; without even the implied warranty of
1598944Sobrien   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1698944Sobrien   GNU General Public License for more details.
1719370Spst
1898944Sobrien   You should have received a copy of the GNU General Public License
1998944Sobrien   along with this program; if not, write to the Free Software
2098944Sobrien   Foundation, Inc., 59 Temple Place - Suite 330,
2198944Sobrien   Boston, MA 02111-1307, USA.  */
2219370Spst
2319370Spst#if !defined (BREAKPOINT_H)
2419370Spst#define BREAKPOINT_H 1
2519370Spst
2619370Spst#include "frame.h"
2719370Spst#include "value.h"
2819370Spst
2998944Sobrien#include "gdb-events.h"
3098944Sobrien
3198944Sobrienstruct value;
32130803Smarcelstruct block;
3398944Sobrien
3419370Spst/* This is the maximum number of bytes a breakpoint instruction can take.
3519370Spst   Feel free to increase it.  It's just used in a few places to size
3619370Spst   arrays that should be independent of the target architecture.  */
3719370Spst
3819370Spst#define	BREAKPOINT_MAX	16
3919370Spst
4019370Spst/* Type of breakpoint. */
4119370Spst/* FIXME In the future, we should fold all other breakpoint-like things into
4219370Spst   here.  This includes:
4319370Spst
4419370Spst   * single-step (for machines where we have to simulate single stepping)
4598944Sobrien   (probably, though perhaps it is better for it to look as much as
4698944Sobrien   possible like a single-step to wait_for_inferior).  */
4719370Spst
4898944Sobrienenum bptype
4998944Sobrien  {
5098944Sobrien    bp_none = 0,		/* Eventpoint has been deleted. */
5198944Sobrien    bp_breakpoint,		/* Normal breakpoint */
5298944Sobrien    bp_hardware_breakpoint,	/* Hardware assisted breakpoint */
5398944Sobrien    bp_until,			/* used by until command */
5498944Sobrien    bp_finish,			/* used by finish command */
5598944Sobrien    bp_watchpoint,		/* Watchpoint */
5698944Sobrien    bp_hardware_watchpoint,	/* Hardware assisted watchpoint */
5798944Sobrien    bp_read_watchpoint,		/* read watchpoint, (hardware assisted) */
5898944Sobrien    bp_access_watchpoint,	/* access watchpoint, (hardware assisted) */
5998944Sobrien    bp_longjmp,			/* secret breakpoint to find longjmp() */
6098944Sobrien    bp_longjmp_resume,		/* secret breakpoint to escape longjmp() */
6119370Spst
6298944Sobrien    /* Used by wait_for_inferior for stepping over subroutine calls, for
6398944Sobrien       stepping over signal handlers, and for skipping prologues.  */
6498944Sobrien    bp_step_resume,
6519370Spst
6698944Sobrien    /* Used by wait_for_inferior for stepping over signal handlers.  */
6798944Sobrien    bp_through_sigtramp,
6819370Spst
6998944Sobrien    /* Used to detect when a watchpoint expression has gone out of
7098944Sobrien       scope.  These breakpoints are usually not visible to the user.
7119370Spst
7298944Sobrien       This breakpoint has some interesting properties:
7319370Spst
7419370Spst       1) There's always a 1:1 mapping between watchpoints
7519370Spst       on local variables and watchpoint_scope breakpoints.
7619370Spst
7719370Spst       2) It automatically deletes itself and the watchpoint it's
7819370Spst       associated with when hit.
7919370Spst
8019370Spst       3) It can never be disabled.  */
8198944Sobrien    bp_watchpoint_scope,
8219370Spst
8398944Sobrien    /* The breakpoint at the end of a call dummy.  */
8498944Sobrien    /* FIXME: What if the function we are calling longjmp()s out of the
8598944Sobrien       call, or the user gets out with the "return" command?  We currently
8698944Sobrien       have no way of cleaning up the breakpoint in these (obscure) situations.
8798944Sobrien       (Probably can solve this by noticing longjmp, "return", etc., it's
8898944Sobrien       similar to noticing when a watchpoint on a local variable goes out
8998944Sobrien       of scope (with hardware support for watchpoints)).  */
9098944Sobrien    bp_call_dummy,
9119370Spst
9298944Sobrien    /* Some dynamic linkers (HP, maybe Solaris) can arrange for special
9398944Sobrien       code in the inferior to run when significant events occur in the
9498944Sobrien       dynamic linker (for example a library is loaded or unloaded).
9519370Spst
9698944Sobrien       By placing a breakpoint in this magic code GDB will get control
9798944Sobrien       when these significant events occur.  GDB can then re-examine
9898944Sobrien       the dynamic linker's data structures to discover any newly loaded
9998944Sobrien       dynamic libraries.  */
10098944Sobrien    bp_shlib_event,
10146283Sdfr
10298944Sobrien    /* Some multi-threaded systems can arrange for a location in the
10398944Sobrien       inferior to be executed when certain thread-related events occur
10498944Sobrien       (such as thread creation or thread death).
10519370Spst
10698944Sobrien       By placing a breakpoint at one of these locations, GDB will get
10798944Sobrien       control when these events occur.  GDB can then update its thread
10898944Sobrien       lists etc.  */
10998944Sobrien
11098944Sobrien    bp_thread_event,
11198944Sobrien
11298944Sobrien    /* On the same principal, an overlay manager can arrange to call a
11398944Sobrien       magic location in the inferior whenever there is an interesting
11498944Sobrien       change in overlay status.  GDB can update its overlay tables
11598944Sobrien       and fiddle with breakpoints in overlays when this breakpoint
11698944Sobrien       is hit.  */
11798944Sobrien
11898944Sobrien    bp_overlay_event,
11998944Sobrien
12098944Sobrien    /* These breakpoints are used to implement the "catch load" command
12198944Sobrien       on platforms whose dynamic linkers support such functionality.  */
12298944Sobrien    bp_catch_load,
12398944Sobrien
12498944Sobrien    /* These breakpoints are used to implement the "catch unload" command
12598944Sobrien       on platforms whose dynamic linkers support such functionality.  */
12698944Sobrien    bp_catch_unload,
12798944Sobrien
12898944Sobrien    /* These are not really breakpoints, but are catchpoints that
12998944Sobrien       implement the "catch fork", "catch vfork" and "catch exec" commands
13098944Sobrien       on platforms whose kernel support such functionality.  (I.e.,
13198944Sobrien       kernels which can raise an event when a fork or exec occurs, as
13298944Sobrien       opposed to the debugger setting breakpoints on functions named
13398944Sobrien       "fork" or "exec".) */
13498944Sobrien    bp_catch_fork,
13598944Sobrien    bp_catch_vfork,
13698944Sobrien    bp_catch_exec,
13798944Sobrien
13898944Sobrien    /* These are catchpoints to implement "catch catch" and "catch throw"
13998944Sobrien       commands for C++ exception handling. */
14098944Sobrien    bp_catch_catch,
14198944Sobrien    bp_catch_throw
14298944Sobrien
14398944Sobrien
14498944Sobrien  };
14598944Sobrien
14619370Spst/* States of enablement of breakpoint. */
14719370Spst
14898944Sobrienenum enable_state
14998944Sobrien  {
15098944Sobrien    bp_disabled,	/* The eventpoint is inactive, and cannot trigger. */
15198944Sobrien    bp_enabled,		/* The eventpoint is active, and can trigger. */
15298944Sobrien    bp_shlib_disabled,	/* The eventpoint's address is in an unloaded solib.
15398944Sobrien			   The eventpoint will be automatically enabled
15498944Sobrien			   and reset when that solib is loaded. */
15598944Sobrien    bp_call_disabled,	/* The eventpoint has been disabled while a call
15698944Sobrien			   into the inferior is "in flight", because some
15798944Sobrien			   eventpoints interfere with the implementation of
15898944Sobrien			   a call on some targets.  The eventpoint will be
15998944Sobrien			   automatically enabled and reset when the call
16098944Sobrien			   "lands" (either completes, or stops at another
16198944Sobrien			   eventpoint). */
16298944Sobrien    bp_permanent	/* There is a breakpoint instruction hard-wired into
16398944Sobrien			   the target's code.  Don't try to write another
16498944Sobrien			   breakpoint instruction on top of it, or restore
16598944Sobrien			   its value.  Step over it using the architecture's
16698944Sobrien			   SKIP_INSN macro.  */
16798944Sobrien  };
16819370Spst
16946283Sdfr
17019370Spst/* Disposition of breakpoint.  Ie: what to do after hitting it. */
17119370Spst
17298944Sobrienenum bpdisp
17398944Sobrien  {
17498944Sobrien    disp_del,			/* Delete it */
17598944Sobrien    disp_del_at_next_stop,	/* Delete at next stop, whether hit or not */
17698944Sobrien    disp_disable,		/* Disable it */
17798944Sobrien    disp_donttouch		/* Leave it alone */
17898944Sobrien  };
17919370Spst
18098944Sobrienenum target_hw_bp_type
18198944Sobrien  {
18298944Sobrien    hw_write   = 0, 		/* Common  HW watchpoint */
18398944Sobrien    hw_read    = 1, 		/* Read    HW watchpoint */
18498944Sobrien    hw_access  = 2, 		/* Access  HW watchpoint */
18598944Sobrien    hw_execute = 3		/* Execute HW breakpoint */
18698944Sobrien  };
18798944Sobrien
188130803Smarcel/* GDB maintains two types of information about each breakpoint (or
189130803Smarcel   watchpoint, or other related event).  The first type corresponds
190130803Smarcel   to struct breakpoint; this is a relatively high-level structure
191130803Smarcel   which contains the source location(s), stopping conditions, user
192130803Smarcel   commands to execute when the breakpoint is hit, and so forth.
193130803Smarcel
194130803Smarcel   The second type of information corresponds to struct bp_location.
195130803Smarcel   Each breakpoint has one or (eventually) more locations associated
196130803Smarcel   with it, which represent target-specific and machine-specific
197130803Smarcel   mechanisms for stopping the program.  For instance, a watchpoint
198130803Smarcel   expression may require multiple hardware watchpoints in order to
199130803Smarcel   catch all changes in the value of the expression being watched.  */
200130803Smarcel
201130803Smarcelenum bp_loc_type
202130803Smarcel{
203130803Smarcel  bp_loc_software_breakpoint,
204130803Smarcel  bp_loc_hardware_breakpoint,
205130803Smarcel  bp_loc_hardware_watchpoint,
206130803Smarcel  bp_loc_other			/* Miscellaneous...  */
207130803Smarcel};
208130803Smarcel
209130803Smarcelstruct bp_location
210130803Smarcel{
211130803Smarcel  /* Chain pointer to the next breakpoint location.  */
212130803Smarcel  struct bp_location *next;
213130803Smarcel
214130803Smarcel  /* Type of this breakpoint location.  */
215130803Smarcel  enum bp_loc_type loc_type;
216130803Smarcel
217130803Smarcel  /* Each breakpoint location must belong to exactly one higher-level
218130803Smarcel     breakpoint.  This and the DUPLICATE flag are more straightforward
219130803Smarcel     than reference counting.  */
220130803Smarcel  struct breakpoint *owner;
221130803Smarcel
222130803Smarcel  /* Nonzero if this breakpoint is now inserted.  */
223130803Smarcel  char inserted;
224130803Smarcel
225130803Smarcel  /* Nonzero if this is not the first breakpoint in the list
226130803Smarcel     for the given address.  */
227130803Smarcel  char duplicate;
228130803Smarcel
229130803Smarcel  /* If we someday support real thread-specific breakpoints, then
230130803Smarcel     the breakpoint location will need a thread identifier.  */
231130803Smarcel
232130803Smarcel  /* Data for specific breakpoint types.  These could be a union, but
233130803Smarcel     simplicity is more important than memory usage for breakpoints.  */
234130803Smarcel
235130803Smarcel  /* Note that zero is a perfectly valid code address on some platforms
236130803Smarcel     (for example, the mn10200 (OBSOLETE) and mn10300 simulators).  NULL
237130803Smarcel     is not a special value for this field.  Valid for all types except
238130803Smarcel     bp_loc_other.  */
239130803Smarcel  CORE_ADDR address;
240130803Smarcel
241130803Smarcel  /* For any breakpoint type with an address, this is the BFD section
242130803Smarcel     associated with the address.  Used primarily for overlay debugging.  */
243130803Smarcel  asection *section;
244130803Smarcel
245130803Smarcel  /* "Real" contents of byte where breakpoint has been inserted.
246130803Smarcel     Valid only when breakpoints are in the program.  Under the complete
247130803Smarcel     control of the target insert_breakpoint and remove_breakpoint routines.
248130803Smarcel     No other code should assume anything about the value(s) here.
249130803Smarcel     Valid only for bp_loc_software_breakpoint.  */
250130803Smarcel  char shadow_contents[BREAKPOINT_MAX];
251130803Smarcel
252130803Smarcel  /* Address at which breakpoint was requested, either by the user or
253130803Smarcel     by GDB for internal breakpoints.  This will usually be the same
254130803Smarcel     as ``address'' (above) except for cases in which
255130803Smarcel     ADJUST_BREAKPOINT_ADDRESS has computed a different address at
256130803Smarcel     which to place the breakpoint in order to comply with a
257130803Smarcel     processor's architectual constraints.  */
258130803Smarcel  CORE_ADDR requested_address;
259130803Smarcel};
260130803Smarcel
261130803Smarcel/* This structure is a collection of function pointers that, if available,
262130803Smarcel   will be called instead of the performing the default action for this
263130803Smarcel   bptype.  */
264130803Smarcel
265130803Smarcelstruct breakpoint_ops
266130803Smarcel{
267130803Smarcel  /* The normal print routine for this breakpoint, called when we
268130803Smarcel     hit it.  */
269130803Smarcel  enum print_stop_action (*print_it) (struct breakpoint *);
270130803Smarcel
271130803Smarcel  /* Display information about this breakpoint, for "info breakpoints".  */
272130803Smarcel  void (*print_one) (struct breakpoint *, CORE_ADDR *);
273130803Smarcel
274130803Smarcel  /* Display information about this breakpoint after setting it (roughly
275130803Smarcel     speaking; this is called from "mention").  */
276130803Smarcel  void (*print_mention) (struct breakpoint *);
277130803Smarcel};
278130803Smarcel
27919370Spst/* Note that the ->silent field is not currently used by any commands
28019370Spst   (though the code is in there if it was to be, and set_raw_breakpoint
28119370Spst   does set it to 0).  I implemented it because I thought it would be
28219370Spst   useful for a hack I had to put in; I'm going to leave it in because
28319370Spst   I can see how there might be times when it would indeed be useful */
28419370Spst
28519370Spst/* This is for a breakpoint or a watchpoint.  */
28619370Spst
28719370Spststruct breakpoint
28898944Sobrien  {
28998944Sobrien    struct breakpoint *next;
29098944Sobrien    /* Type of breakpoint. */
29198944Sobrien    enum bptype type;
29298944Sobrien    /* Zero means disabled; remember the info but don't break here.  */
29398944Sobrien    enum enable_state enable_state;
29498944Sobrien    /* What to do with this breakpoint after we hit it. */
29598944Sobrien    enum bpdisp disposition;
29698944Sobrien    /* Number assigned to distinguish breakpoints.  */
29798944Sobrien    int number;
29819370Spst
299130803Smarcel    /* Location(s) associated with this high-level breakpoint.  */
300130803Smarcel    struct bp_location *loc;
30119370Spst
30298944Sobrien    /* Line number of this address.  */
30319370Spst
30498944Sobrien    int line_number;
30519370Spst
30698944Sobrien    /* Source file name of this address.  */
30719370Spst
30898944Sobrien    char *source_file;
30919370Spst
31098944Sobrien    /* Non-zero means a silent breakpoint (don't print frame info
31198944Sobrien       if we stop here). */
31298944Sobrien    unsigned char silent;
31398944Sobrien    /* Number of stops at this breakpoint that should
31498944Sobrien       be continued automatically before really stopping.  */
31598944Sobrien    int ignore_count;
31698944Sobrien    /* Chain of command lines to execute when this breakpoint is hit.  */
31798944Sobrien    struct command_line *commands;
31898944Sobrien    /* Stack depth (address of frame).  If nonzero, break only if fp
31998944Sobrien       equals this.  */
320130803Smarcel    struct frame_id frame_id;
32198944Sobrien    /* Conditional.  Break only if this expression's value is nonzero.  */
32298944Sobrien    struct expression *cond;
32319370Spst
32498944Sobrien    /* String we used to set the breakpoint (malloc'd).  */
32598944Sobrien    char *addr_string;
32698944Sobrien    /* Language we used to set the breakpoint.  */
32798944Sobrien    enum language language;
32898944Sobrien    /* Input radix we used to set the breakpoint.  */
32998944Sobrien    int input_radix;
33098944Sobrien    /* String form of the breakpoint condition (malloc'd), or NULL if there
33198944Sobrien       is no condition.  */
33298944Sobrien    char *cond_string;
33398944Sobrien    /* String form of exp (malloc'd), or NULL if none.  */
33498944Sobrien    char *exp_string;
33519370Spst
33698944Sobrien    /* The expression we are watching, or NULL if not a watchpoint.  */
33798944Sobrien    struct expression *exp;
33898944Sobrien    /* The largest block within which it is valid, or NULL if it is
33998944Sobrien       valid anywhere (e.g. consists just of global symbols).  */
34098944Sobrien    struct block *exp_valid_block;
34198944Sobrien    /* Value of the watchpoint the last time we checked it.  */
34298944Sobrien    struct value *val;
34319370Spst
34498944Sobrien    /* Holds the value chain for a hardware watchpoint expression.  */
34598944Sobrien    struct value *val_chain;
34619370Spst
34798944Sobrien    /* Holds the address of the related watchpoint_scope breakpoint
34898944Sobrien       when using watchpoints on local variables (might the concept
34998944Sobrien       of a related breakpoint be useful elsewhere, if not just call
35098944Sobrien       it the watchpoint_scope breakpoint or something like that. FIXME).  */
35198944Sobrien    struct breakpoint *related_breakpoint;
35219370Spst
353130803Smarcel    /* Holds the frame address which identifies the frame this
354130803Smarcel       watchpoint should be evaluated in, or `null' if the watchpoint
355130803Smarcel       should be evaluated on the outermost frame.  */
356130803Smarcel    struct frame_id watchpoint_frame;
35719370Spst
35898944Sobrien    /* Thread number for thread-specific breakpoint, or -1 if don't care */
35998944Sobrien    int thread;
36019370Spst
36198944Sobrien    /* Count of the number of times this breakpoint was taken, dumped
36298944Sobrien       with the info, but not used for anything else.  Useful for
36398944Sobrien       seeing how many times you hit a break prior to the program
36498944Sobrien       aborting, so you can back up to just before the abort.  */
36598944Sobrien    int hit_count;
36619370Spst
36798944Sobrien    /* Filename of a dynamically-linked library (dll), used for
36898944Sobrien       bp_catch_load and bp_catch_unload (malloc'd), or NULL if any
36998944Sobrien       library is significant.  */
37098944Sobrien    char *dll_pathname;
37198944Sobrien
37298944Sobrien    /* Filename of a dll whose state change (e.g., load or unload)
37398944Sobrien       triggered this catchpoint.  This field is only valid immediately
37498944Sobrien       after this catchpoint has triggered.  */
37598944Sobrien    char *triggered_dll_pathname;
37698944Sobrien
37798944Sobrien    /* Process id of a child process whose forking triggered this
37898944Sobrien       catchpoint.  This field is only valid immediately after this
37998944Sobrien       catchpoint has triggered.  */
38098944Sobrien    int forked_inferior_pid;
38198944Sobrien
38298944Sobrien    /* Filename of a program whose exec triggered this catchpoint.
38398944Sobrien       This field is only valid immediately after this catchpoint has
38498944Sobrien       triggered.  */
38598944Sobrien    char *exec_pathname;
38698944Sobrien
387130803Smarcel    /* Methods associated with this breakpoint.  */
388130803Smarcel    struct breakpoint_ops *ops;
389130803Smarcel
390130803Smarcel    /* Was breakpoint issued from a tty?  Saved for the use of pending breakpoints.  */
391130803Smarcel    int from_tty;
392130803Smarcel
393130803Smarcel    /* Flag value for pending breakpoint.
394130803Smarcel       first bit  : 0 non-temporary, 1 temporary.
395130803Smarcel       second bit : 0 normal breakpoint, 1 hardware breakpoint. */
396130803Smarcel    int flag;
397130803Smarcel
398130803Smarcel    /* Is breakpoint pending on shlib loads?  */
399130803Smarcel    int pending;
40098944Sobrien  };
40119370Spst
40298944Sobrien/* The following stuff is an abstract data type "bpstat" ("breakpoint
40398944Sobrien   status").  This provides the ability to determine whether we have
40498944Sobrien   stopped at a breakpoint, and what we should do about it.  */
40519370Spst
40619370Spsttypedef struct bpstats *bpstat;
40719370Spst
40819370Spst/* Interface:  */
40919370Spst/* Clear a bpstat so that it says we are not at any breakpoint.
41019370Spst   Also free any storage that is part of a bpstat.  */
41198944Sobrienextern void bpstat_clear (bpstat *);
41219370Spst
41319370Spst/* Return a copy of a bpstat.  Like "bs1 = bs2" but all storage that
41419370Spst   is part of the bpstat is copied as well.  */
41598944Sobrienextern bpstat bpstat_copy (bpstat);
41619370Spst
417130803Smarcelextern bpstat bpstat_stop_status (CORE_ADDR pc, ptid_t ptid);
41819370Spst
41919370Spst/* This bpstat_what stuff tells wait_for_inferior what to do with a
42019370Spst   breakpoint (a challenging task).  */
42119370Spst
42298944Sobrienenum bpstat_what_main_action
42398944Sobrien  {
42498944Sobrien    /* Perform various other tests; that is, this bpstat does not
42598944Sobrien       say to perform any action (e.g. failed watchpoint and nothing
42698944Sobrien       else).  */
42798944Sobrien    BPSTAT_WHAT_KEEP_CHECKING,
42819370Spst
42998944Sobrien    /* Rather than distinguish between noisy and silent stops here, it
43098944Sobrien       might be cleaner to have bpstat_print make that decision (also
43198944Sobrien       taking into account stop_print_frame and source_only).  But the
43298944Sobrien       implications are a bit scary (interaction with auto-displays, etc.),
43398944Sobrien       so I won't try it.  */
43419370Spst
43598944Sobrien    /* Stop silently.  */
43698944Sobrien    BPSTAT_WHAT_STOP_SILENT,
43719370Spst
43898944Sobrien    /* Stop and print.  */
43998944Sobrien    BPSTAT_WHAT_STOP_NOISY,
44019370Spst
44198944Sobrien    /* Remove breakpoints, single step once, then put them back in and
44298944Sobrien       go back to what we were doing.  It's possible that this should be
44398944Sobrien       removed from the main_action and put into a separate field, to more
44498944Sobrien       cleanly handle BPSTAT_WHAT_CLEAR_LONGJMP_RESUME_SINGLE.  */
44598944Sobrien    BPSTAT_WHAT_SINGLE,
44619370Spst
44798944Sobrien    /* Set longjmp_resume breakpoint, remove all other breakpoints,
44898944Sobrien       and continue.  The "remove all other breakpoints" part is required
44998944Sobrien       if we are also stepping over another breakpoint as well as doing
45098944Sobrien       the longjmp handling.  */
45198944Sobrien    BPSTAT_WHAT_SET_LONGJMP_RESUME,
45219370Spst
45398944Sobrien    /* Clear longjmp_resume breakpoint, then handle as
45498944Sobrien       BPSTAT_WHAT_KEEP_CHECKING.  */
45598944Sobrien    BPSTAT_WHAT_CLEAR_LONGJMP_RESUME,
45619370Spst
45798944Sobrien    /* Clear longjmp_resume breakpoint, then handle as BPSTAT_WHAT_SINGLE.  */
45898944Sobrien    BPSTAT_WHAT_CLEAR_LONGJMP_RESUME_SINGLE,
45919370Spst
46098944Sobrien    /* Clear step resume breakpoint, and keep checking.  */
46198944Sobrien    BPSTAT_WHAT_STEP_RESUME,
46219370Spst
46398944Sobrien    /* Clear through_sigtramp breakpoint, muck with trap_expected, and keep
46498944Sobrien       checking.  */
46598944Sobrien    BPSTAT_WHAT_THROUGH_SIGTRAMP,
46619370Spst
46798944Sobrien    /* Check the dynamic linker's data structures for new libraries, then
46898944Sobrien       keep checking.  */
46998944Sobrien    BPSTAT_WHAT_CHECK_SHLIBS,
47046283Sdfr
47198944Sobrien    /* Check the dynamic linker's data structures for new libraries, then
47298944Sobrien       resume out of the dynamic linker's callback, stop and print.  */
47398944Sobrien    BPSTAT_WHAT_CHECK_SHLIBS_RESUME_FROM_HOOK,
47419370Spst
47598944Sobrien    /* This is just used to keep track of how many enums there are.  */
47698944Sobrien    BPSTAT_WHAT_LAST
47798944Sobrien  };
47819370Spst
47998944Sobrienstruct bpstat_what
48098944Sobrien  {
48198944Sobrien    enum bpstat_what_main_action main_action;
48219370Spst
48398944Sobrien    /* Did we hit a call dummy breakpoint?  This only goes with a main_action
48498944Sobrien       of BPSTAT_WHAT_STOP_SILENT or BPSTAT_WHAT_STOP_NOISY (the concept of
48598944Sobrien       continuing from a call dummy without popping the frame is not a
48698944Sobrien       useful one).  */
48798944Sobrien    int call_dummy;
48898944Sobrien  };
48998944Sobrien
49098944Sobrien/* The possible return values for print_bpstat, print_it_normal,
49198944Sobrien   print_it_done, print_it_noop. */
49298944Sobrienenum print_stop_action
49398944Sobrien  {
49498944Sobrien    PRINT_UNKNOWN = -1,
49598944Sobrien    PRINT_SRC_AND_LOC,
49698944Sobrien    PRINT_SRC_ONLY,
49798944Sobrien    PRINT_NOTHING
49898944Sobrien  };
49998944Sobrien
50019370Spst/* Tell what to do about this bpstat.  */
50198944Sobrienstruct bpstat_what bpstat_what (bpstat);
50219370Spst
50319370Spst/* Find the bpstat associated with a breakpoint.  NULL otherwise. */
50498944Sobrienbpstat bpstat_find_breakpoint (bpstat, struct breakpoint *);
50519370Spst
50646283Sdfr/* Find a step_resume breakpoint associated with this bpstat.
50746283Sdfr   (If there are multiple step_resume bp's on the list, this function
50846283Sdfr   will arbitrarily pick one.)
50946283Sdfr
51046283Sdfr   It is an error to use this function if BPSTAT doesn't contain a
51146283Sdfr   step_resume breakpoint.
51246283Sdfr
51346283Sdfr   See wait_for_inferior's use of this function.
51498944Sobrien */
51598944Sobrienextern struct breakpoint *bpstat_find_step_resume_breakpoint (bpstat);
51646283Sdfr
51719370Spst/* Nonzero if a signal that we got in wait() was due to circumstances
51819370Spst   explained by the BS.  */
51919370Spst/* Currently that is true if we have hit a breakpoint, or if there is
52019370Spst   a watchpoint enabled.  */
52119370Spst#define bpstat_explains_signal(bs) ((bs) != NULL)
52219370Spst
52319370Spst/* Nonzero if we should step constantly (e.g. watchpoints on machines
52419370Spst   without hardware support).  This isn't related to a specific bpstat,
52519370Spst   just to things like whether watchpoints are set.  */
52698944Sobrienextern int bpstat_should_step (void);
52719370Spst
52846283Sdfr/* Nonzero if there are enabled hardware watchpoints. */
52998944Sobrienextern int bpstat_have_active_hw_watchpoints (void);
53046283Sdfr
53119370Spst/* Print a message indicating what happened.  Returns nonzero to
53219370Spst   say that only the source line should be printed after this (zero
53319370Spst   return means print the frame as well as the source line).  */
53498944Sobrienextern enum print_stop_action bpstat_print (bpstat);
53519370Spst
53619370Spst/* Return the breakpoint number of the first breakpoint we are stopped
53719370Spst   at.  *BSP upon return is a bpstat which points to the remaining
53819370Spst   breakpoints stopped at (but which is not guaranteed to be good for
53919370Spst   anything but further calls to bpstat_num).
54019370Spst   Return 0 if passed a bpstat which does not indicate any breakpoints.  */
54198944Sobrienextern int bpstat_num (bpstat *);
54219370Spst
54319370Spst/* Perform actions associated with having stopped at *BSP.  Actually, we just
54419370Spst   use this for breakpoint commands.  Perhaps other actions will go here
54519370Spst   later, but this is executed at a late time (from the command loop).  */
54698944Sobrienextern void bpstat_do_actions (bpstat *);
54719370Spst
54819370Spst/* Modify BS so that the actions will not be performed.  */
54998944Sobrienextern void bpstat_clear_actions (bpstat);
55019370Spst
55146283Sdfr/* Given a bpstat that records zero or more triggered eventpoints, this
55246283Sdfr   function returns another bpstat which contains only the catchpoints
55346283Sdfr   on that first list, if any.
55498944Sobrien */
55598944Sobrienextern void bpstat_get_triggered_catchpoints (bpstat, bpstat *);
55698944Sobrien
55719370Spst/* Implementation:  */
55898944Sobrien
55998944Sobrien/* Values used to tell the printing routine how to behave for this bpstat. */
56098944Sobrienenum bp_print_how
56198944Sobrien  {
56298944Sobrien    /* This is used when we want to do a normal printing of the reason
56398944Sobrien       for stopping. The output will depend on the type of eventpoint
56498944Sobrien       we are dealing with. This is the default value, most commonly
56598944Sobrien       used. */
56698944Sobrien    print_it_normal,
56798944Sobrien    /* This is used when nothing should be printed for this bpstat entry.  */
56898944Sobrien    print_it_noop,
56998944Sobrien    /* This is used when everything which needs to be printed has
57098944Sobrien       already been printed.  But we still want to print the frame.  */
57198944Sobrien    print_it_done
57298944Sobrien  };
57398944Sobrien
57419370Spststruct bpstats
57598944Sobrien  {
57698944Sobrien    /* Linked list because there can be two breakpoints at the same
57798944Sobrien       place, and a bpstat reflects the fact that both have been hit.  */
57898944Sobrien    bpstat next;
57998944Sobrien    /* Breakpoint that we are at.  */
58098944Sobrien    struct breakpoint *breakpoint_at;
58198944Sobrien    /* Commands left to be done.  */
58298944Sobrien    struct command_line *commands;
58398944Sobrien    /* Old value associated with a watchpoint.  */
58498944Sobrien    struct value *old_val;
58519370Spst
58698944Sobrien    /* Nonzero if this breakpoint tells us to print the frame.  */
58798944Sobrien    char print;
58819370Spst
58998944Sobrien    /* Nonzero if this breakpoint tells us to stop.  */
59098944Sobrien    char stop;
59119370Spst
59298944Sobrien    /* Tell bpstat_print and print_bp_stop_message how to print stuff
59398944Sobrien       associated with this element of the bpstat chain.  */
59498944Sobrien    enum bp_print_how print_it;
59598944Sobrien  };
59646283Sdfr
59746283Sdfrenum inf_context
59898944Sobrien  {
59998944Sobrien    inf_starting,
60098944Sobrien    inf_running,
60198944Sobrien    inf_exited
60298944Sobrien  };
60346283Sdfr
60498944Sobrien/* The possible return values for breakpoint_here_p.
60598944Sobrien   We guarantee that zero always means "no breakpoint here".  */
60698944Sobrienenum breakpoint_here
60798944Sobrien  {
60898944Sobrien    no_breakpoint_here = 0,
60998944Sobrien    ordinary_breakpoint_here,
61098944Sobrien    permanent_breakpoint_here
61198944Sobrien  };
61219370Spst
61398944Sobrien
61419370Spst/* Prototypes for breakpoint-related functions.  */
61519370Spst
61698944Sobrienextern enum breakpoint_here breakpoint_here_p (CORE_ADDR);
61719370Spst
61898944Sobrienextern int breakpoint_inserted_here_p (CORE_ADDR);
61946283Sdfr
620130803Smarcelextern int software_breakpoint_inserted_here_p (CORE_ADDR);
62119370Spst
622130803Smarcel/* FIXME: cagney/2002-11-10: The current [generic] dummy-frame code
623130803Smarcel   implements a functional superset of this function.  The only reason
624130803Smarcel   it hasn't been removed is because some architectures still don't
625130803Smarcel   use the new framework.  Once they have been fixed, this can go.  */
626130803Smarcelstruct frame_info;
627130803Smarcelextern int deprecated_frame_in_dummy (struct frame_info *);
628130803Smarcel
62998944Sobrienextern int breakpoint_thread_match (CORE_ADDR, ptid_t);
63019370Spst
631130803Smarcelextern void until_break_command (char *, int, int);
63219370Spst
63398944Sobrienextern void breakpoint_re_set (void);
63419370Spst
63598944Sobrienextern void breakpoint_re_set_thread (struct breakpoint *);
63619370Spst
63798944Sobrienextern int ep_is_exception_catchpoint (struct breakpoint *);
63846283Sdfr
63919370Spstextern struct breakpoint *set_momentary_breakpoint
640130803Smarcel  (struct symtab_and_line, struct frame_id, enum bptype);
64119370Spst
64298944Sobrienextern void set_ignore_count (int, int, int);
64319370Spst
64498944Sobrienextern void set_default_breakpoint (int, CORE_ADDR, struct symtab *, int);
64519370Spst
64698944Sobrienextern void mark_breakpoints_out (void);
64719370Spst
64898944Sobrienextern void breakpoint_init_inferior (enum inf_context);
64919370Spst
65098944Sobrienextern struct cleanup *make_cleanup_delete_breakpoint (struct breakpoint *);
65119370Spst
65298944Sobrienextern struct cleanup *make_exec_cleanup_delete_breakpoint (struct breakpoint *);
65319370Spst
65498944Sobrienextern void delete_breakpoint (struct breakpoint *);
65519370Spst
65698944Sobrienextern void breakpoint_auto_delete (bpstat);
65719370Spst
65898944Sobrienextern void breakpoint_clear_ignore_counts (void);
65946283Sdfr
66098944Sobrienextern void break_command (char *, int);
66119370Spst
66298944Sobrienextern void hbreak_command_wrapper (char *, int);
66398944Sobrienextern void thbreak_command_wrapper (char *, int);
66498944Sobrienextern void rbreak_command_wrapper (char *, int);
66598944Sobrienextern void watch_command_wrapper (char *, int);
66698944Sobrienextern void awatch_command_wrapper (char *, int);
66798944Sobrienextern void rwatch_command_wrapper (char *, int);
66898944Sobrienextern void tbreak_command (char *, int);
66919370Spst
67098944Sobrienextern int insert_breakpoints (void);
67198944Sobrien
67298944Sobrienextern int remove_breakpoints (void);
67398944Sobrien
67446283Sdfr/* This function can be used to physically insert eventpoints from the
67546283Sdfr   specified traced inferior process, without modifying the breakpoint
67646283Sdfr   package's state.  This can be useful for those targets which support
67746283Sdfr   following the processes of a fork() or vfork() system call, when both
67846283Sdfr   of the resulting two processes are to be followed.  */
67998944Sobrienextern int reattach_breakpoints (int);
68046283Sdfr
68146283Sdfr/* This function can be used to update the breakpoint package's state
68246283Sdfr   after an exec() system call has been executed.
68346283Sdfr
68446283Sdfr   This function causes the following:
68546283Sdfr
68698944Sobrien   - All eventpoints are marked "not inserted".
68798944Sobrien   - All eventpoints with a symbolic address are reset such that
68898944Sobrien   the symbolic address must be reevaluated before the eventpoints
68998944Sobrien   can be reinserted.
69098944Sobrien   - The solib breakpoints are explicitly removed from the breakpoint
69198944Sobrien   list.
69298944Sobrien   - A step-resume breakpoint, if any, is explicitly removed from the
69398944Sobrien   breakpoint list.
69498944Sobrien   - All eventpoints without a symbolic address are removed from the
69598944Sobrien   breakpoint list. */
69698944Sobrienextern void update_breakpoints_after_exec (void);
69746283Sdfr
69846283Sdfr/* This function can be used to physically remove hardware breakpoints
69946283Sdfr   and watchpoints from the specified traced inferior process, without
70046283Sdfr   modifying the breakpoint package's state.  This can be useful for
70146283Sdfr   those targets which support following the processes of a fork() or
70246283Sdfr   vfork() system call, when one of the resulting two processes is to
70346283Sdfr   be detached and allowed to run free.
70498944Sobrien
70546283Sdfr   It is an error to use this function on the process whose id is
70698944Sobrien   inferior_ptid.  */
70798944Sobrienextern int detach_breakpoints (int);
70819370Spst
70998944Sobrienextern void enable_longjmp_breakpoint (void);
71098944Sobrienextern void disable_longjmp_breakpoint (void);
71198944Sobrienextern void enable_overlay_breakpoints (void);
71298944Sobrienextern void disable_overlay_breakpoints (void);
71319370Spst
714130803Smarcelextern void set_longjmp_resume_breakpoint (CORE_ADDR, struct frame_id);
71546283Sdfr/* These functions respectively disable or reenable all currently
71646283Sdfr   enabled watchpoints.  When disabled, the watchpoints are marked
71746283Sdfr   call_disabled.  When reenabled, they are marked enabled.
71846283Sdfr
719130803Smarcel   The intended client of these functions is call_function_by_hand.
72046283Sdfr
72146283Sdfr   The inferior must be stopped, and all breakpoints removed, when
72246283Sdfr   these functions are used.
72346283Sdfr
72446283Sdfr   The need for these functions is that on some targets (e.g., HP-UX),
72546283Sdfr   gdb is unable to unwind through the dummy frame that is pushed as
72646283Sdfr   part of the implementation of a call command.  Watchpoints can
72746283Sdfr   cause the inferior to stop in places where this frame is visible,
72846283Sdfr   and that can cause execution control to become very confused.
72946283Sdfr
73098944Sobrien   Note that if a user sets breakpoints in an interactively called
73146283Sdfr   function, the call_disabled watchpoints will have been reenabled
73246283Sdfr   when the first such breakpoint is reached.  However, on targets
73346283Sdfr   that are unable to unwind through the call dummy frame, watches
73446283Sdfr   of stack-based storage may then be deleted, because gdb will
73546283Sdfr   believe that their watched storage is out of scope.  (Sigh.) */
73698944Sobrienextern void disable_watchpoints_before_interactive_call_start (void);
73746283Sdfr
73898944Sobrienextern void enable_watchpoints_after_interactive_call_stop (void);
73946283Sdfr
74019370Spst
74198944Sobrienextern void clear_breakpoint_hit_counts (void);
74298944Sobrien
74398944Sobrienextern int get_number (char **);
74498944Sobrien
74598944Sobrienextern int get_number_or_range (char **);
74698944Sobrien
74719370Spst/* The following are for displays, which aren't really breakpoints, but
74819370Spst   here is as good a place as any for them.  */
74919370Spst
75098944Sobrienextern void disable_current_display (void);
75119370Spst
75298944Sobrienextern void do_displays (void);
75319370Spst
75498944Sobrienextern void disable_display (int);
75519370Spst
75698944Sobrienextern void clear_displays (void);
75719370Spst
75898944Sobrienextern void disable_breakpoint (struct breakpoint *);
75919370Spst
76098944Sobrienextern void enable_breakpoint (struct breakpoint *);
76119370Spst
76298944Sobrienextern void make_breakpoint_permanent (struct breakpoint *);
76319370Spst
76498944Sobrienextern struct breakpoint *create_solib_event_breakpoint (CORE_ADDR);
76519370Spst
76698944Sobrienextern struct breakpoint *create_thread_event_breakpoint (CORE_ADDR);
76746283Sdfr
76898944Sobrienextern void remove_solib_event_breakpoints (void);
76919370Spst
77098944Sobrienextern void remove_thread_event_breakpoints (void);
77146283Sdfr
77298944Sobrienextern void disable_breakpoints_in_shlibs (int silent);
77398944Sobrien
77498944Sobrienextern void re_enable_breakpoints_in_shlibs (void);
77598944Sobrien
77698944Sobrienextern void create_solib_load_event_breakpoint (char *, int, char *, char *);
77798944Sobrien
77898944Sobrienextern void create_solib_unload_event_breakpoint (char *, int,
77998944Sobrien						  char *, char *);
78098944Sobrien
78198944Sobrienextern void create_fork_event_catchpoint (int, char *);
78298944Sobrien
78398944Sobrienextern void create_vfork_event_catchpoint (int, char *);
78498944Sobrien
78598944Sobrienextern void create_exec_event_catchpoint (int, char *);
78698944Sobrien
78746283Sdfr/* This function returns TRUE if ep is a catchpoint. */
78898944Sobrienextern int ep_is_catchpoint (struct breakpoint *);
78998944Sobrien
79046283Sdfr/* This function returns TRUE if ep is a catchpoint of a
79146283Sdfr   shared library (aka dynamically-linked library) event,
79246283Sdfr   such as a library load or unload. */
79398944Sobrienextern int ep_is_shlib_catchpoint (struct breakpoint *);
79446283Sdfr
79598944Sobrienextern struct breakpoint *set_breakpoint_sal (struct symtab_and_line);
79698944Sobrien
79798944Sobrien/* Enable breakpoints and delete when hit.  Called with ARG == NULL
79898944Sobrien   deletes all breakpoints. */
79998944Sobrienextern void delete_command (char *arg, int from_tty);
80098944Sobrien
80198944Sobrien/* Pull all H/W watchpoints from the target. Return non-zero if the
80298944Sobrien   remove fails. */
80398944Sobrienextern int remove_hw_watchpoints (void);
80498944Sobrien
80519370Spst#endif /* !defined (BREAKPOINT_H) */
806