GNU Binutils with patches for OS216
Revisão | 3cde5c42d1c1ddcf8bbde5c47233c644370c959c (tree) |
---|---|
Hora | 2016-11-09 00:26:47 |
Autor | Pedro Alves <palves@redh...> |
Commiter | Pedro Alves |
Eliminate agent_expr_p; VEC -> std::vector in struct bp_target_info
After the previous patch, we end up with these two types with quite
similar, and potentially confusing names:
The latter is only necessary to put agent_expr pointers in VECs. So
just eliminate it and use std::vector instead.
gdb/ChangeLog:
2016-11-08 Pedro Alves <palves@redhat.com>
* ax.h (agent_expr_p): Delete.
(DEF_VEC_P (agent_expr_p)): Delete.
* breakpoint.c (build_target_condition_list)
(build_target_command_list): Adjust to use of std::vector.
(bp_location_dtor): Remove now unnecessary VEC_free calls.
* breakpoint.h: Include <vector>.
(struct bp_target_info) <conditions, tcommands>: Now
std::vector's.
* remote.c (remote_add_target_side_condition): bp_tgt->conditions
is now a std::vector; adjust.
(remote_add_target_side_commands, remote_insert_breakpoint):
bp_tgt->tcommands is now a std::vector; adjust.
@@ -1,5 +1,20 @@ | ||
1 | 1 | 2016-11-08 Pedro Alves <palves@redhat.com> |
2 | 2 | |
3 | + * ax.h (agent_expr_p): Delete. | |
4 | + (DEF_VEC_P (agent_expr_p)): Delete. | |
5 | + * breakpoint.c (build_target_condition_list) | |
6 | + (build_target_command_list): Adjust to use of std::vector. | |
7 | + (bp_location_dtor): Remove now unnecessary VEC_free calls. | |
8 | + * breakpoint.h: Include <vector>. | |
9 | + (struct bp_target_info) <conditions, tcommands>: Now | |
10 | + std::vector's. | |
11 | + * remote.c (remote_add_target_side_condition): bp_tgt->conditions | |
12 | + is now a std::vector; adjust. | |
13 | + (remote_add_target_side_commands, remote_insert_breakpoint): | |
14 | + bp_tgt->tcommands is now a std::vector; adjust. | |
15 | + | |
16 | +2016-11-08 Pedro Alves <palves@redhat.com> | |
17 | + | |
3 | 18 | * ax-gdb.c (is_nontrivial_conversion): Use agent_expr_up. |
4 | 19 | (gen_trace_for_var, gen_trace_for_expr, gen_eval_for_expr) |
5 | 20 | (gen_trace_for_return_address, gen_printf): Use and return an |
@@ -170,12 +170,6 @@ struct agent_expr | ||
170 | 170 | /* An agent_expr owning pointer. */ |
171 | 171 | typedef gdb::unique_ptr<agent_expr> agent_expr_up; |
172 | 172 | |
173 | -/* Pointer to an agent_expr structure. */ | |
174 | -typedef struct agent_expr *agent_expr_p; | |
175 | - | |
176 | -/* Vector of pointers to agent expressions. */ | |
177 | -DEF_VEC_P (agent_expr_p); | |
178 | - | |
179 | 173 | /* The actual values of the various bytecode operations. */ |
180 | 174 | |
181 | 175 | enum agent_op |
@@ -2298,7 +2298,7 @@ build_target_condition_list (struct bp_location *bl) | ||
2298 | 2298 | struct bp_location *loc; |
2299 | 2299 | |
2300 | 2300 | /* Release conditions left over from a previous insert. */ |
2301 | - VEC_free (agent_expr_p, bl->target_info.conditions); | |
2301 | + bl->target_info.conditions.clear (); | |
2302 | 2302 | |
2303 | 2303 | /* This is only meaningful if the target is |
2304 | 2304 | evaluating conditions and if the user has |
@@ -2371,10 +2371,11 @@ build_target_condition_list (struct bp_location *bl) | ||
2371 | 2371 | && loc->pspace->num == bl->pspace->num |
2372 | 2372 | && loc->owner->enable_state == bp_enabled |
2373 | 2373 | && loc->enabled) |
2374 | - /* Add the condition to the vector. This will be used later to send the | |
2375 | - conditions to the target. */ | |
2376 | - VEC_safe_push (agent_expr_p, bl->target_info.conditions, | |
2377 | - loc->cond_bytecode.get ()); | |
2374 | + { | |
2375 | + /* Add the condition to the vector. This will be used later | |
2376 | + to send the conditions to the target. */ | |
2377 | + bl->target_info.conditions.push_back (loc->cond_bytecode.get ()); | |
2378 | + } | |
2378 | 2379 | } |
2379 | 2380 | |
2380 | 2381 | return; |
@@ -2481,8 +2482,8 @@ build_target_command_list (struct bp_location *bl) | ||
2481 | 2482 | int modified = bl->needs_update; |
2482 | 2483 | struct bp_location *loc; |
2483 | 2484 | |
2484 | - /* Release commands left over from a previous insert. */ | |
2485 | - VEC_free (agent_expr_p, bl->target_info.tcommands); | |
2485 | + /* Clear commands left over from a previous insert. */ | |
2486 | + bl->target_info.tcommands.clear (); | |
2486 | 2487 | |
2487 | 2488 | if (!target_can_run_breakpoint_commands ()) |
2488 | 2489 | return; |
@@ -2565,10 +2566,11 @@ build_target_command_list (struct bp_location *bl) | ||
2565 | 2566 | && loc->pspace->num == bl->pspace->num |
2566 | 2567 | && loc->owner->enable_state == bp_enabled |
2567 | 2568 | && loc->enabled) |
2568 | - /* Add the command to the vector. This will be used later | |
2569 | - to send the commands to the target. */ | |
2570 | - VEC_safe_push (agent_expr_p, bl->target_info.tcommands, | |
2571 | - loc->cmd_bytecode.get ()); | |
2569 | + { | |
2570 | + /* Add the command to the vector. This will be used later | |
2571 | + to send the commands to the target. */ | |
2572 | + bl->target_info.tcommands.push_back (loc->cmd_bytecode.get ()); | |
2573 | + } | |
2572 | 2574 | } |
2573 | 2575 | |
2574 | 2576 | bl->target_info.persist = 0; |
@@ -12888,9 +12890,6 @@ static void | ||
12888 | 12890 | bp_location_dtor (struct bp_location *self) |
12889 | 12891 | { |
12890 | 12892 | xfree (self->function_name); |
12891 | - | |
12892 | - VEC_free (agent_expr_p, self->target_info.conditions); | |
12893 | - VEC_free (agent_expr_p, self->target_info.tcommands); | |
12894 | 12893 | } |
12895 | 12894 | |
12896 | 12895 | static const struct bp_location_ops bp_location_ops = |
@@ -26,6 +26,7 @@ | ||
26 | 26 | #include "command.h" |
27 | 27 | #include "break-common.h" |
28 | 28 | #include "probe.h" |
29 | +#include <vector> | |
29 | 30 | |
30 | 31 | struct value; |
31 | 32 | struct block; |
@@ -264,13 +265,13 @@ struct bp_target_info | ||
264 | 265 | packets. */ |
265 | 266 | int kind; |
266 | 267 | |
267 | - /* Vector of conditions the target should evaluate if it supports target-side | |
268 | - breakpoint conditions. */ | |
269 | - VEC(agent_expr_p) *conditions; | |
268 | + /* Conditions the target should evaluate if it supports target-side | |
269 | + breakpoint conditions. These are non-owning pointers. */ | |
270 | + std::vector<agent_expr *> conditions; | |
270 | 271 | |
271 | - /* Vector of commands the target should evaluate if it supports | |
272 | - target-side breakpoint commands. */ | |
273 | - VEC(agent_expr_p) *tcommands; | |
272 | + /* Commands the target should evaluate if it supports target-side | |
273 | + breakpoint commands. These are non-owning pointers. */ | |
274 | + std::vector<agent_expr *> tcommands; | |
274 | 275 | |
275 | 276 | /* Flag that is true if the breakpoint should be left in place even |
276 | 277 | when GDB is not connected. */ |
@@ -9623,10 +9623,7 @@ remote_add_target_side_condition (struct gdbarch *gdbarch, | ||
9623 | 9623 | struct bp_target_info *bp_tgt, char *buf, |
9624 | 9624 | char *buf_end) |
9625 | 9625 | { |
9626 | - struct agent_expr *aexpr = NULL; | |
9627 | - int i, ix; | |
9628 | - | |
9629 | - if (VEC_empty (agent_expr_p, bp_tgt->conditions)) | |
9626 | + if (bp_tgt->conditions.empty ()) | |
9630 | 9627 | return 0; |
9631 | 9628 | |
9632 | 9629 | buf += strlen (buf); |
@@ -9634,13 +9631,13 @@ remote_add_target_side_condition (struct gdbarch *gdbarch, | ||
9634 | 9631 | buf++; |
9635 | 9632 | |
9636 | 9633 | /* Send conditions to the target and free the vector. */ |
9637 | - for (ix = 0; | |
9638 | - VEC_iterate (agent_expr_p, bp_tgt->conditions, ix, aexpr); | |
9639 | - ix++) | |
9634 | + for (int ix = 0; ix < bp_tgt->conditions.size (); ix++) | |
9640 | 9635 | { |
9636 | + struct agent_expr *aexpr = bp_tgt->conditions[ix]; | |
9637 | + | |
9641 | 9638 | xsnprintf (buf, buf_end - buf, "X%x,", aexpr->len); |
9642 | 9639 | buf += strlen (buf); |
9643 | - for (i = 0; i < aexpr->len; ++i) | |
9640 | + for (int i = 0; i < aexpr->len; ++i) | |
9644 | 9641 | buf = pack_hex_byte (buf, aexpr->buf[i]); |
9645 | 9642 | *buf = '\0'; |
9646 | 9643 | } |
@@ -9651,10 +9648,7 @@ static void | ||
9651 | 9648 | remote_add_target_side_commands (struct gdbarch *gdbarch, |
9652 | 9649 | struct bp_target_info *bp_tgt, char *buf) |
9653 | 9650 | { |
9654 | - struct agent_expr *aexpr = NULL; | |
9655 | - int i, ix; | |
9656 | - | |
9657 | - if (VEC_empty (agent_expr_p, bp_tgt->tcommands)) | |
9651 | + if (bp_tgt->tcommands.empty ()) | |
9658 | 9652 | return; |
9659 | 9653 | |
9660 | 9654 | buf += strlen (buf); |
@@ -9664,13 +9658,13 @@ remote_add_target_side_commands (struct gdbarch *gdbarch, | ||
9664 | 9658 | |
9665 | 9659 | /* Concatenate all the agent expressions that are commands into the |
9666 | 9660 | cmds parameter. */ |
9667 | - for (ix = 0; | |
9668 | - VEC_iterate (agent_expr_p, bp_tgt->tcommands, ix, aexpr); | |
9669 | - ix++) | |
9661 | + for (int ix = 0; ix < bp_tgt->tcommands.size (); ix++) | |
9670 | 9662 | { |
9663 | + struct agent_expr *aexpr = bp_tgt->tcommands[ix]; | |
9664 | + | |
9671 | 9665 | sprintf (buf, "X%x,", aexpr->len); |
9672 | 9666 | buf += strlen (buf); |
9673 | - for (i = 0; i < aexpr->len; ++i) | |
9667 | + for (int i = 0; i < aexpr->len; ++i) | |
9674 | 9668 | buf = pack_hex_byte (buf, aexpr->buf[i]); |
9675 | 9669 | *buf = '\0'; |
9676 | 9670 | } |
@@ -9735,7 +9729,7 @@ remote_insert_breakpoint (struct target_ops *ops, | ||
9735 | 9729 | |
9736 | 9730 | /* If this breakpoint has target-side commands but this stub doesn't |
9737 | 9731 | support Z0 packets, throw error. */ |
9738 | - if (!VEC_empty (agent_expr_p, bp_tgt->tcommands)) | |
9732 | + if (!bp_tgt->tcommands.empty ()) | |
9739 | 9733 | throw_error (NOT_SUPPORTED_ERROR, _("\ |
9740 | 9734 | Target doesn't support breakpoints that have target side commands.")); |
9741 | 9735 |