diff options
author | Pedro Alves <palves@redhat.com> | 2011-06-22 17:11:30 +0000 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2011-06-22 17:11:30 +0000 |
commit | 346774a91ffaa367db6982f19cc9b5bcafaa3686 (patch) | |
tree | a3172632d335fefc92dca0413f859266cf3d9ccb /gdb/breakpoint.c | |
parent | e366eeae1287622a7ed40c75ec1e7980cc5f71ac (diff) | |
download | gdb-346774a91ffaa367db6982f19cc9b5bcafaa3686.zip gdb-346774a91ffaa367db6982f19cc9b5bcafaa3686.tar.gz gdb-346774a91ffaa367db6982f19cc9b5bcafaa3686.tar.bz2 |
2011-06-22 Pedro Alves <pedro@codesourcery.com>
* breakpoint.c (add_to_breakpoint_chain)
(init_raw_breakpoint_without_location): New functions, factored
out from ...
(set_raw_breakpoint_without_location): ... this one.
(init_raw_breakpoint): New function, factored out from
set_raw_breakpoint and adjusted to use
init_raw_breakpoint_without_location.
(set_raw_breakpoint): Adjust.
(init_catchpoint): New function, factored out from
create_catchpoint_without_mention and adjusted to use
init_raw_breakpoint.
(create_catchpoint_without_mention): Adjust.
Diffstat (limited to 'gdb/breakpoint.c')
-rw-r--r-- | gdb/breakpoint.c | 158 |
1 files changed, 108 insertions, 50 deletions
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 3281748..fd5890c 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -5785,18 +5785,34 @@ decref_bp_location (struct bp_location **blp) *blp = NULL; } -/* Helper to set_raw_breakpoint below. Creates a breakpoint that has - type BPTYPE and has no locations as yet. */ -/* This function is used in gdbtk sources and thus can not be made - static. */ +/* Add breakpoint B at the end of the global breakpoint chain. */ -static struct breakpoint * -set_raw_breakpoint_without_location (struct gdbarch *gdbarch, - enum bptype bptype) +static void +add_to_breakpoint_chain (struct breakpoint *b) { - struct breakpoint *b, *b1; + struct breakpoint *b1; - b = (struct breakpoint *) xmalloc (sizeof (struct breakpoint)); + /* Add this breakpoint to the end of the chain so that a list of + breakpoints will come out in order of increasing numbers. */ + + b1 = breakpoint_chain; + if (b1 == 0) + breakpoint_chain = b; + else + { + while (b1->next) + b1 = b1->next; + b1->next = b; + } +} + +/* Initializes breakpoint B with type BPTYPE and no locations yet. */ + +static void +init_raw_breakpoint_without_location (struct breakpoint *b, + struct gdbarch *gdbarch, + enum bptype bptype) +{ memset (b, 0, sizeof (*b)); b->type = bptype; @@ -5818,18 +5834,22 @@ set_raw_breakpoint_without_location (struct gdbarch *gdbarch, b->py_bp_object = NULL; b->related_breakpoint = b; - /* Add this breakpoint to the end of the chain so that a list of - breakpoints will come out in order of increasing numbers. */ + add_to_breakpoint_chain (b); +} + +/* Helper to set_raw_breakpoint below. Creates a breakpoint + that has type BPTYPE and has no locations as yet. */ +/* This function is used in gdbtk sources and thus can not be made + static. */ + +static struct breakpoint * +set_raw_breakpoint_without_location (struct gdbarch *gdbarch, + enum bptype bptype) +{ + struct breakpoint *b = XNEW (struct breakpoint); + + init_raw_breakpoint_without_location (b, gdbarch, bptype); - b1 = breakpoint_chain; - if (b1 == 0) - breakpoint_chain = b; - else - { - while (b1->next) - b1 = b1->next; - b1->next = b; - } return b; } @@ -5890,30 +5910,29 @@ get_sal_arch (struct symtab_and_line sal) return NULL; } -/* set_raw_breakpoint is a low level routine for allocating and - partially initializing a breakpoint of type BPTYPE. The newly - created breakpoint's address, section, source file name, and line - number are provided by SAL. The newly created and partially - initialized breakpoint is added to the breakpoint chain and - is also returned as the value of this function. +/* Low level routine for partially initializing a breakpoint of type + BPTYPE. The newly created breakpoint's address, section, source + file name, and line number are provided by SAL. The newly created + and partially initialized breakpoint is added to the breakpoint + chain. It is expected that the caller will complete the initialization of the newly created breakpoint struct as well as output any status information regarding the creation of a new breakpoint. In - particular, set_raw_breakpoint does NOT set the breakpoint - number! Care should be taken to not allow an error to occur - prior to completing the initialization of the breakpoint. If this - should happen, a bogus breakpoint will be left on the chain. */ + particular, init_raw_breakpoint does NOT set the breakpoint number! + Care should be taken to not allow an error to occur prior to + completing the initialization of the breakpoint. If this should + happen, a bogus breakpoint will be left on the chain. */ -struct breakpoint * -set_raw_breakpoint (struct gdbarch *gdbarch, - struct symtab_and_line sal, enum bptype bptype) +static void +init_raw_breakpoint (struct breakpoint *b, struct gdbarch *gdbarch, + struct symtab_and_line sal, enum bptype bptype) { - struct breakpoint *b = set_raw_breakpoint_without_location (gdbarch, - bptype); CORE_ADDR adjusted_address; struct gdbarch *loc_gdbarch; + init_raw_breakpoint_without_location (b, gdbarch, bptype); + loc_gdbarch = get_sal_arch (sal); if (!loc_gdbarch) loc_gdbarch = b->gdbarch; @@ -5951,7 +5970,30 @@ set_raw_breakpoint (struct gdbarch *gdbarch, sal.explicit_pc || sal.explicit_line); breakpoints_changed (); +} +/* set_raw_breakpoint is a low level routine for allocating and + partially initializing a breakpoint of type BPTYPE. The newly + created breakpoint's address, section, source file name, and line + number are provided by SAL. The newly created and partially + initialized breakpoint is added to the breakpoint chain and + is also returned as the value of this function. + + It is expected that the caller will complete the initialization of + the newly created breakpoint struct as well as output any status + information regarding the creation of a new breakpoint. In + particular, set_raw_breakpoint does NOT set the breakpoint + number! Care should be taken to not allow an error to occur + prior to completing the initialization of the breakpoint. If this + should happen, a bogus breakpoint will be left on the chain. */ + +struct breakpoint * +set_raw_breakpoint (struct gdbarch *gdbarch, + struct symtab_and_line sal, enum bptype bptype) +{ + struct breakpoint *b = XNEW (struct breakpoint); + + init_raw_breakpoint (b, gdbarch, sal, bptype); return b; } @@ -6737,28 +6779,25 @@ syscall_catchpoint_p (struct breakpoint *b) return (b->ops == &catch_syscall_breakpoint_ops); } -/* Create a new breakpoint of the bp_catchpoint kind and return it, - but does NOT mention it nor update the global location list. - This is useful if you need to fill more fields in the - struct breakpoint before calling mention. - - If TEMPFLAG is non-zero, then make the breakpoint temporary. - If COND_STRING is not NULL, then store it in the breakpoint. - OPS, if not NULL, is the breakpoint_ops structure associated - to the catchpoint. */ +/* Initialize a new breakpoint of the bp_catchpoint kind. If TEMPFLAG + is non-zero, then make the breakpoint temporary. If COND_STRING is + not NULL, then store it in the breakpoint. OPS, if not NULL, is + the breakpoint_ops structure associated to the catchpoint. */ -static struct breakpoint * -create_catchpoint_without_mention (struct gdbarch *gdbarch, int tempflag, - char *cond_string, - struct breakpoint_ops *ops) +static void +init_catchpoint (struct breakpoint *b, + struct gdbarch *gdbarch, int tempflag, + char *cond_string, + struct breakpoint_ops *ops) { struct symtab_and_line sal; - struct breakpoint *b; + + memset (b, 0, sizeof (*b)); init_sal (&sal); sal.pspace = current_program_space; - b = set_raw_breakpoint (gdbarch, sal, bp_catchpoint); + init_raw_breakpoint (b, gdbarch, sal, bp_catchpoint); set_breakpoint_count (breakpoint_count + 1); b->number = breakpoint_count; @@ -6768,7 +6807,26 @@ create_catchpoint_without_mention (struct gdbarch *gdbarch, int tempflag, b->enable_state = bp_enabled; b->disposition = tempflag ? disp_del : disp_donttouch; b->ops = ops; +} + +/* Create a new breakpoint of the bp_catchpoint kind and return it, + but does NOT mention it nor update the global location list. + This is useful if you need to fill more fields in the + struct breakpoint before calling mention. + + If TEMPFLAG is non-zero, then make the breakpoint temporary. + If COND_STRING is not NULL, then store it in the breakpoint. + OPS, if not NULL, is the breakpoint_ops structure associated + to the catchpoint. */ + +static struct breakpoint * +create_catchpoint_without_mention (struct gdbarch *gdbarch, int tempflag, + char *cond_string, + struct breakpoint_ops *ops) +{ + struct breakpoint *b = XNEW (struct breakpoint); + init_catchpoint (b, gdbarch, tempflag, cond_string, ops); return b; } |