diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2018-03-22 00:27:19 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@ericsson.com> | 2018-03-22 00:27:19 -0400 |
commit | 5d9310c4b88f807c1a3f1a0b4d7b6c10925dcaf7 (patch) | |
tree | b78fb98efc2bdab7fd374e0098bf8b7a426f0d4c /gdb/common | |
parent | 62c222b6d9fcce8adf65f48fca2e528f777afeeb (diff) | |
download | gdb-5d9310c4b88f807c1a3f1a0b4d7b6c10925dcaf7.zip gdb-5d9310c4b88f807c1a3f1a0b4d7b6c10925dcaf7.tar.gz gdb-5d9310c4b88f807c1a3f1a0b4d7b6c10925dcaf7.tar.bz2 |
Get rid of VEC(static_tracepoint_marker_p)
This patch replaces VEC(static_tracepoint_marker_p) with std::vector,
and does some c++ification around that. I thought a new overload of
hex2str was useful, so I added it as well as corresponding unit tests.
I also added an overload of ui_out::field_string that takes an
std::string directly.
gdb/ChangeLog:
* tracepoint.h (struct static_tracepoint_marker): Initialize
fields, define default constructor, move constructor and move
assignment, disable the rest.
<str_id, extra>: Make std::string.
(release_static_tracepoint_marker): Remove.
(free_current_marker): Remove.
* tracepoint.c (free_current_marker): Remove.
(parse_static_tracepoint_marker_definition): Adjust to
std::string, use new hex2str overload.
(release_static_tracepoint_marker): Remove.
(print_one_static_tracepoint_marker): Get marker by reference
and adjust to std::string.
(info_static_tracepoint_markers_command): Adjust to std::vector
changes
* target.h (static_tracepoint_marker_p): Remove typedef.
(DEF_VEC_P(static_tracepoint_marker_p)): Remove.
(struct target_ops) <to_static_tracepoint_marker_at>: Return
bool.
<to_static_tracepoint_markers_by_strid>: Return std::vector.
* target-debug.h
(target_debug_print_VEC_static_tracepoint_marker_p_p): Remove.
(target_debug_print_std_vector_static_tracepoint_marker): New.
(target_debug_print_struct_static_tracepoint_marker_p): Rename
to...
(target_debug_print_static_tracepoint_marker_p): ... this.
* target-delegates.c: Re-generate.
* breakpoint.h (struct tracepoint) <static_trace_marker_id>:
Make std::string.
* breakpoint.c (init_breakpoint_sal): Adjust to std::string.
(decode_static_tracepoint_spec): Adjust to std::vector.
(tracepoint_print_one_detail): Adjust to std::string.
(strace_marker_decode_location): Adjust to std::string.
(update_static_tracepoint): Adjust to std::string, remove call
to release_static_tracepoint_marker.
* linux-nat.c (linux_child_static_tracepoint_markers_by_strid):
Adjust to std::vector.
* remote.c (remote_static_tracepoint_marker_at): Return bool.
(remote_static_tracepoint_markers_by_strid): Adjust to
std::vector.
* common/rsp-low.h (hex2str): New overload with explicit count
of bytes.
* common/rsp-low.c (hex2str): New overload with explicit count
of bytes.
* unittests/rsp-low-selftests.c (test_hex2str): New function.
(_initialize_rsp_low_selftests): Add test_hex2str test.
* unittests/tracepoint-selftests.c
(test_parse_static_tracepoint_marker_definition): Adjust to
std::string.
Diffstat (limited to 'gdb/common')
-rw-r--r-- | gdb/common/rsp-low.c | 13 | ||||
-rw-r--r-- | gdb/common/rsp-low.h | 4 |
2 files changed, 14 insertions, 3 deletions
diff --git a/gdb/common/rsp-low.c b/gdb/common/rsp-low.c index 10ad9d87..7986063 100644 --- a/gdb/common/rsp-low.c +++ b/gdb/common/rsp-low.c @@ -148,11 +148,18 @@ hex2bin (const char *hex) std::string hex2str (const char *hex) { + return hex2str (hex, strlen (hex)); +} + +/* See rsp-low.h. */ + +std::string +hex2str (const char *hex, int count) +{ std::string ret; - size_t len = strlen (hex); - ret.reserve (len / 2); - for (size_t i = 0; i < len; ++i) + ret.reserve (count); + for (size_t i = 0; i < count; ++i) { if (hex[0] == '\0' || hex[1] == '\0') { diff --git a/gdb/common/rsp-low.h b/gdb/common/rsp-low.h index 068eabc..f01db37 100644 --- a/gdb/common/rsp-low.h +++ b/gdb/common/rsp-low.h @@ -62,6 +62,10 @@ gdb::byte_vector hex2bin (const char *hex); extern std::string hex2str (const char *hex); +/* Like hex2bin, but return a std::string. */ + +extern std::string hex2str (const char *hex, int count); + /* Convert some bytes to a hexadecimal representation. BIN holds the bytes to convert. COUNT says how many bytes to convert. The resulting characters are stored in HEX, followed by a NUL |