diff options
author | Luis Machado <luisgpm@br.ibm.com> | 2012-02-24 15:10:59 +0000 |
---|---|---|
committer | Luis Machado <luisgpm@br.ibm.com> | 2012-02-24 15:10:59 +0000 |
commit | b775012e845380ed4c7421a1b87caf7bfae39f5f (patch) | |
tree | ac2f84dfcd17de662a5608d8c8dd707c9567f8c7 /gdb/remote.c | |
parent | 3788aec75a91b4b6e10255f20aaa649ddbfdf78c (diff) | |
download | gdb-b775012e845380ed4c7421a1b87caf7bfae39f5f.zip gdb-b775012e845380ed4c7421a1b87caf7bfae39f5f.tar.gz gdb-b775012e845380ed4c7421a1b87caf7bfae39f5f.tar.bz2 |
2012-02-24 Luis Machado <lgustavo@codesourcery.com>
* remote.c (remote_supports_cond_breakpoints): New forward
declaration.
(remote_add_target_side_condition): New function.
(remote_insert_breakpoint): Add target-side breakpoint
conditional if supported.
(remote_insert_hw_breakpoint): Likewise.
(init_remote_ops): Set to_supports_evaluation_of_breakpoint_conditions
hook.
* target.c (update_current_target): Inherit
to_supports_evaluation_of_breakpoint_conditions.
Default to_supports_evaluation_of_breakpoint_conditions to return_zero.
* target.h (struct target_ops)
<to_supports_evaluation_of_breakpoint_conditions>: New field.
(target_supports_evaluation_of_breakpoint_conditions): New #define.
* breakpoint.c (get_first_locp_gte_addr): New forward declaration.
(condition_evaluation_both, condition_evaluation_auto,
condition_evaluation_host, condition_evaluation_target,
condition_evaluation_enums, condition_evaluation_mode_1,
condition_evaluation_mode): New static globals.
(translate_condition_evaluation_mode): New function.
(breakpoint_condition_evaluation_mode): New function.
(gdb_evaluates_breakpoint_condition_p): New function.
(ALL_BP_LOCATIONS_AT_ADDR): New helper macro.
(mark_breakpoint_modified): New function.
(mark_breakpoint_location_modified): New function.
(set_condition_evaluation_mode): New function.
(show_condition_evaluation_mode): New function.
(bp_location_compare_addrs): New function.
(get_first_location_gte_addr): New helper function.
(set_breakpoint_condition): Free condition bytecode if locations
has become unconditional. Call mark_breakpoint_modified (...).
(condition_command): Call update_global_location_list (1) for
breakpoints.
(breakpoint_xfer_memory): Use is_breakpoint (...).
(is_breakpoint): New function.
(parse_cond_to_aexpr): New function.
(build_target_condition_list): New function.
(insert_bp_location): Handle target-side conditional
breakpoints and call build_target_condition_list (...).
(update_inserted_breakpoint_locations): New function.
(insert_breakpoint_locations): Handle target-side conditional
breakpoints.
(bpstat_check_breakpoint_conditions): Add comment.
(bp_condition_evaluator): New function.
(bp_location_condition_evaluator): New function.
(print_breakpoint_location): Print information on where the condition
will be evaluated.
(print_one_breakpoint_location): Likewise.
(init_bp_location): Call mark_breakpoint_location_modified (...) for
breakpoint location.
(force_breakpoint_reinsertion): New functions.
(update_global_location_list): Handle target-side breakpoint
conditions.
Reinsert locations that are already inserted if conditions have
changed.
(bp_location_dtor): Free agent expression bytecode.
(disable_breakpoint): Call mark_breakpoint_modified (...).
Call update_global_location_list (...) with parameter 1 for breakpoints.
(disable_command): Call mark_breakpoint_location_modified (...).
Call update_global_location_list (...) with parameter 1 for breakpoints.
(enable_breakpoint_disp): Call mark_breakpoint_modified (...).
(enable_command): mark_breakpoint_location_modified (...).
(_initialize_breakpoint): Update documentation and add
condition-evaluation breakpoint subcommand.
* breakpoint.h: Include ax.h.
(condition_list): New data structure.
(condition_status): New enum.
(bp_target_info) <cond_list>: New field.
(bp_location) <condition_changed, cond_bytecode>: New fields.
(is_breakpoint): New prototype.
Diffstat (limited to 'gdb/remote.c')
-rw-r--r-- | gdb/remote.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/gdb/remote.c b/gdb/remote.c index e094917..68c8fd2 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -242,6 +242,8 @@ static int remote_read_description_p (struct target_ops *target); static void remote_console_output (char *msg); +static int remote_supports_cond_breakpoints (void); + /* The non-stop remote protocol provisions for one pending stop reply. This is where we keep it until it is acknowledged. */ @@ -7729,6 +7731,43 @@ extended_remote_create_inferior (struct target_ops *ops, } +/* Given a location's target info BP_TGT and the packet buffer BUF, output + the list of conditions (in agent expression bytecode format), if any, the + target needs to evaluate. The output is placed into the packet buffer + BUF. */ + +static int +remote_add_target_side_condition (struct gdbarch *gdbarch, + struct bp_target_info *bp_tgt, char *buf) +{ + struct agent_expr *aexpr = NULL; + int i, ix; + char *pkt; + char *buf_start = buf; + + if (VEC_empty (agent_expr_p, bp_tgt->conditions)) + return 0; + + buf += strlen (buf); + sprintf (buf, "%s", ";"); + buf++; + + /* Send conditions to the target and free the vector. */ + for (ix = 0; + VEC_iterate (agent_expr_p, bp_tgt->conditions, ix, aexpr); + ix++) + { + sprintf (buf, "X%x,", aexpr->len); + buf += strlen (buf); + for (i = 0; i < aexpr->len; ++i) + buf = pack_hex_byte (buf, aexpr->buf[i]); + *buf = '\0'; + } + + VEC_free (agent_expr_p, bp_tgt->conditions); + return 0; +} + /* Insert a breakpoint. On targets that have software breakpoint support, we ask the remote target to do the work; on targets which don't, we insert a traditional memory breakpoint. */ @@ -7748,6 +7787,7 @@ remote_insert_breakpoint (struct gdbarch *gdbarch, struct remote_state *rs; char *p; int bpsize; + struct condition_list *cond = NULL; gdbarch_remote_breakpoint_from_pc (gdbarch, &addr, &bpsize); @@ -7761,6 +7801,9 @@ remote_insert_breakpoint (struct gdbarch *gdbarch, p += hexnumstr (p, addr); sprintf (p, ",%d", bpsize); + if (remote_supports_cond_breakpoints ()) + remote_add_target_side_condition (gdbarch, bp_tgt, p); + putpkt (rs->buf); getpkt (&rs->buf, &rs->buf_size, 0); @@ -7986,6 +8029,9 @@ remote_insert_hw_breakpoint (struct gdbarch *gdbarch, p += hexnumstr (p, (ULONGEST) addr); sprintf (p, ",%x", bp_tgt->placed_size); + if (remote_supports_cond_breakpoints ()) + remote_add_target_side_condition (gdbarch, bp_tgt, p); + putpkt (rs->buf); getpkt (&rs->buf, &rs->buf_size, 0); @@ -10781,6 +10827,7 @@ Specify the serial device it is connected to\n\ remote_ops.to_fileio_readlink = remote_hostio_readlink; remote_ops.to_supports_enable_disable_tracepoint = remote_supports_enable_disable_tracepoint; remote_ops.to_supports_string_tracing = remote_supports_string_tracing; + remote_ops.to_supports_evaluation_of_breakpoint_conditions = remote_supports_cond_breakpoints; remote_ops.to_trace_init = remote_trace_init; remote_ops.to_download_tracepoint = remote_download_tracepoint; remote_ops.to_can_download_tracepoint = remote_can_download_tracepoint; |