aboutsummaryrefslogtreecommitdiff
path: root/gdb/ctf.c
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2018-03-30 17:18:54 -0400
committerSimon Marchi <simon.marchi@polymtl.ca>2018-03-30 17:18:54 -0400
commita18ba4e4c9d64eeb2ea65e5315fbd8b4261a1756 (patch)
tree0305bf8d7650858d6095d28a0dd9c2d55e186562 /gdb/ctf.c
parenta7961323e2fce4f831e117cc43e20e5144192240 (diff)
downloadbinutils-a18ba4e4c9d64eeb2ea65e5315fbd8b4261a1756.zip
binutils-a18ba4e4c9d64eeb2ea65e5315fbd8b4261a1756.tar.gz
binutils-a18ba4e4c9d64eeb2ea65e5315fbd8b4261a1756.tar.bz2
Use std::vector in uploaded_tp
This patch changes the VEC(char_ptr) fields in uploaded_tp to use std::vector<char *>. At first, I wanted to creep in more changes, like using std::string, but it was making the patch too big and less focused, so I decided to keep it to just that. It also looks like the strings in those vectors are never free'd. If so, we can fix that in another patch. gdb/ChangeLog: * tracepoint.h (struct uploaded_tp): Initialize fields. <actions, step_actions, cmd_strings>: Change type to std::vector<char *>. * tracepoint.c (get_uploaded_tp): Allocate with new. (free_uploaded_tps): Free with delete. (parse_tracepoint_definition): Adjust to std::vector change. * breakpoint.c (read_uploaded_action): Likewise. (create_tracepoint_from_upload): Likewise. * ctf.c (ctf_write_uploaded_tp): Likewise. (SET_ARRAY_FIELD): Likewise. * tracefile-tfile.c (tfile_write_uploaded_tp): Likewise.
Diffstat (limited to 'gdb/ctf.c')
-rw-r--r--gdb/ctf.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/gdb/ctf.c b/gdb/ctf.c
index d589ed3..07ae93b 100644
--- a/gdb/ctf.c
+++ b/gdb/ctf.c
@@ -530,8 +530,6 @@ ctf_write_uploaded_tp (struct trace_file_writer *self,
int64_t int64;
uint32_t u32;
const gdb_byte zero = 0;
- int a;
- char *act;
/* Event Id. */
int32 = CTF_EVENT_ID_TP_DEF;
@@ -569,15 +567,15 @@ ctf_write_uploaded_tp (struct trace_file_writer *self,
ctf_save_write (&writer->tcs, &zero, 1);
/* actions */
- u32 = VEC_length (char_ptr, tp->actions);
+ u32 = tp->actions.size ();
ctf_save_align_write (&writer->tcs, (gdb_byte *) &u32, 4, 4);
- for (a = 0; VEC_iterate (char_ptr, tp->actions, a, act); ++a)
+ for (char *act : tp->actions)
ctf_save_write (&writer->tcs, (gdb_byte *) act, strlen (act) + 1);
/* step_actions */
- u32 = VEC_length (char_ptr, tp->step_actions);
+ u32 = tp->step_actions.size ();
ctf_save_align_write (&writer->tcs, (gdb_byte *) &u32, 4, 4);
- for (a = 0; VEC_iterate (char_ptr, tp->step_actions, a, act); ++a)
+ for (char *act : tp->step_actions)
ctf_save_write (&writer->tcs, (gdb_byte *) act, strlen (act) + 1);
/* at_string */
@@ -593,9 +591,9 @@ ctf_write_uploaded_tp (struct trace_file_writer *self,
ctf_save_write (&writer->tcs, &zero, 1);
/* cmd_strings */
- u32 = VEC_length (char_ptr, tp->cmd_strings);
+ u32 = tp->cmd_strings.size ();
ctf_save_align_write (&writer->tcs, (gdb_byte *) &u32, 4, 4);
- for (a = 0; VEC_iterate (char_ptr, tp->cmd_strings, a, act); ++a)
+ for (char *act : tp->cmd_strings)
ctf_save_write (&writer->tcs, (gdb_byte *) act, strlen (act) + 1);
}
@@ -992,8 +990,8 @@ ctf_read_tsv (struct uploaded_tsv **uploaded_tsvs)
const struct bt_definition *element \
= bt_ctf_get_index ((EVENT), def, i); \
\
- VEC_safe_push (char_ptr, (VAR)->ARRAY, \
- xstrdup (bt_ctf_get_string (element))); \
+ (VAR)->ARRAY.push_back \
+ (xstrdup (bt_ctf_get_string (element))); \
} \
} \
while (0)