aboutsummaryrefslogtreecommitdiff
path: root/gdb/unittests
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2018-03-22 00:27:19 -0400
committerSimon Marchi <simon.marchi@ericsson.com>2018-03-22 00:27:19 -0400
commit5d9310c4b88f807c1a3f1a0b4d7b6c10925dcaf7 (patch)
treeb78fb98efc2bdab7fd374e0098bf8b7a426f0d4c /gdb/unittests
parent62c222b6d9fcce8adf65f48fca2e528f777afeeb (diff)
downloadgdb-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/unittests')
-rw-r--r--gdb/unittests/rsp-low-selftests.c12
-rw-r--r--gdb/unittests/tracepoint-selftests.c12
2 files changed, 18 insertions, 6 deletions
diff --git a/gdb/unittests/rsp-low-selftests.c b/gdb/unittests/rsp-low-selftests.c
index 74d106e..3d19500 100644
--- a/gdb/unittests/rsp-low-selftests.c
+++ b/gdb/unittests/rsp-low-selftests.c
@@ -48,6 +48,16 @@ static void test_hex2bin_byte_vector ()
SELF_CHECK (bv[1] == 0x23);
}
+static void test_hex2str ()
+{
+ SELF_CHECK (hex2str ("666f6f") == "foo");
+ SELF_CHECK (hex2str ("666f6fa") == "foo");
+ SELF_CHECK (hex2str ("666f6f", 2) == "fo");
+ SELF_CHECK (hex2str ("666", 2) == "f");
+ SELF_CHECK (hex2str ("666", 6) == "f");
+ SELF_CHECK (hex2str ("") == "");
+}
+
} /* namespace rsp_low */
} /* namespace selftests */
@@ -56,4 +66,6 @@ _initialize_rsp_low_selftests ()
{
selftests::register_test ("hex2bin_byte_vector",
selftests::rsp_low::test_hex2bin_byte_vector);
+ selftests::register_test ("hex2str",
+ selftests::rsp_low::test_hex2str);
}
diff --git a/gdb/unittests/tracepoint-selftests.c b/gdb/unittests/tracepoint-selftests.c
index 21ca3d0..d5a884c 100644
--- a/gdb/unittests/tracepoint-selftests.c
+++ b/gdb/unittests/tracepoint-selftests.c
@@ -37,24 +37,24 @@ test_parse_static_tracepoint_marker_definition ()
parse_static_tracepoint_marker_definition (start, &end, &marker);
SELF_CHECK (marker.address == 0x1234);
- SELF_CHECK (strcmp (marker.str_id, "marker1") == 0);
- SELF_CHECK (strcmp (marker.extra, "extra stuff") == 0);
+ SELF_CHECK (marker.str_id == "marker1");
+ SELF_CHECK (marker.extra == "extra stuff");
SELF_CHECK (end == strchr (start, ','));
start = end + 1;
parse_static_tracepoint_marker_definition (start, &end, &marker);
SELF_CHECK (marker.address == 0xabba);
- SELF_CHECK (strcmp (marker.str_id, "marker2") == 0);
- SELF_CHECK (strcmp (marker.extra, "") == 0);
+ SELF_CHECK (marker.str_id == "marker2");
+ SELF_CHECK (marker.extra == "");
SELF_CHECK (end == strchr (start, ','));
start = end + 1;
parse_static_tracepoint_marker_definition (start, &end, &marker);
SELF_CHECK (marker.address == 0xcafe);
- SELF_CHECK (strcmp (marker.str_id, "marker3") == 0);
- SELF_CHECK (strcmp (marker.extra, "morestuff") == 0);
+ SELF_CHECK (marker.str_id == "marker3");
+ SELF_CHECK (marker.extra == "morestuff");
SELF_CHECK (end == def + strlen (def));
}