+2018-03-22 Simon Marchi <simon.marchi@polymtl.ca>
+
+ * 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.
+
2018-03-22 Simon Marchi <simon.marchi@polymtl.ca>
* tracepoint.c (parse_static_tracepoint_marker_definition):
const char *p
= &event_location_to_string (b->location.get ())[3];
const char *endp;
- char *marker_str;
p = skip_spaces (p);
endp = skip_to_space (p);
- marker_str = savestring (p, endp - p);
- t->static_trace_marker_id = marker_str;
+ t->static_trace_marker_id.assign (p, endp - p);
printf_filtered (_("Probed static tracepoint "
"marker \"%s\"\n"),
- t->static_trace_marker_id);
+ t->static_trace_marker_id.c_str ());
}
else if (target_static_tracepoint_marker_at (sal.pc, &marker))
{
- t->static_trace_marker_id = xstrdup (marker.str_id);
- release_static_tracepoint_marker (&marker);
+ t->static_trace_marker_id = std::move (marker.str_id);
printf_filtered (_("Probed static tracepoint "
"marker \"%s\"\n"),
- t->static_trace_marker_id);
+ t->static_trace_marker_id.c_str ());
}
else
warning (_("Couldn't determine the static "
static std::vector<symtab_and_line>
decode_static_tracepoint_spec (const char **arg_p)
{
- VEC(static_tracepoint_marker_p) *markers = NULL;
const char *p = &(*arg_p)[3];
const char *endp;
- int i;
p = skip_spaces (p);
std::string marker_str (p, endp - p);
- markers = target_static_tracepoint_markers_by_strid (marker_str.c_str ());
- if (VEC_empty(static_tracepoint_marker_p, markers))
+ std::vector<static_tracepoint_marker> markers
+ = target_static_tracepoint_markers_by_strid (marker_str.c_str ());
+ if (markers.empty ())
error (_("No known static tracepoint marker named %s"),
marker_str.c_str ());
std::vector<symtab_and_line> sals;
- sals.reserve (VEC_length(static_tracepoint_marker_p, markers));
+ sals.reserve (markers.size ());
- for (i = 0; i < VEC_length(static_tracepoint_marker_p, markers); i++)
+ for (const static_tracepoint_marker &marker : markers)
{
- struct static_tracepoint_marker *marker;
-
- marker = VEC_index (static_tracepoint_marker_p, markers, i);
-
- symtab_and_line sal = find_pc_line (marker->address, 0);
- sal.pc = marker->address;
+ symtab_and_line sal = find_pc_line (marker.address, 0);
+ sal.pc = marker.address;
sals.push_back (sal);
-
- release_static_tracepoint_marker (marker);
- }
+ }
*arg_p = endp;
return sals;
struct ui_out *uiout)
{
struct tracepoint *tp = (struct tracepoint *) self;
- if (tp->static_trace_marker_id)
+ if (!tp->static_trace_marker_id.empty ())
{
gdb_assert (self->type == bp_static_tracepoint);
return sals;
}
else
- error (_("marker %s not found"), tp->static_trace_marker_id);
+ error (_("marker %s not found"), tp->static_trace_marker_id.c_str ());
}
static struct breakpoint_ops strace_marker_breakpoint_ops;
if (target_static_tracepoint_marker_at (pc, &marker))
{
- if (strcmp (tp->static_trace_marker_id, marker.str_id) != 0)
+ if (tp->static_trace_marker_id != marker.str_id)
warning (_("static tracepoint %d changed probed marker from %s to %s"),
- b->number,
- tp->static_trace_marker_id, marker.str_id);
+ b->number, tp->static_trace_marker_id.c_str (),
+ marker.str_id.c_str ());
- xfree (tp->static_trace_marker_id);
- tp->static_trace_marker_id = xstrdup (marker.str_id);
- release_static_tracepoint_marker (&marker);
+ tp->static_trace_marker_id = std::move (marker.str_id);
return sal;
}
if (!sal.explicit_pc
&& sal.line != 0
&& sal.symtab != NULL
- && tp->static_trace_marker_id != NULL)
+ && !tp->static_trace_marker_id.empty ())
{
- VEC(static_tracepoint_marker_p) *markers;
-
- markers
- = target_static_tracepoint_markers_by_strid (tp->static_trace_marker_id);
+ std::vector<static_tracepoint_marker> markers
+ = target_static_tracepoint_markers_by_strid
+ (tp->static_trace_marker_id.c_str ());
- if (!VEC_empty(static_tracepoint_marker_p, markers))
+ if (!markers.empty ())
{
struct symbol *sym;
struct static_tracepoint_marker *tpmarker;
struct ui_out *uiout = current_uiout;
struct explicit_location explicit_loc;
- tpmarker = VEC_index (static_tracepoint_marker_p, markers, 0);
+ tpmarker = &markers[0];
- xfree (tp->static_trace_marker_id);
- tp->static_trace_marker_id = xstrdup (tpmarker->str_id);
+ tp->static_trace_marker_id = std::move (tpmarker->str_id);
warning (_("marker for static tracepoint %d (%s) not "
"found at previous line number"),
- b->number, tp->static_trace_marker_id);
+ b->number, tp->static_trace_marker_id.c_str ());
symtab_and_line sal2 = find_pc_line (tpmarker->address, 0);
sym = find_pc_sect_function (tpmarker->address, NULL);
/* Might be nice to check if function changed, and warn if
so. */
-
- release_static_tracepoint_marker (tpmarker);
}
}
return sal;
ULONGEST traceframe_usage;
/* The static tracepoint marker id, if known. */
- char *static_trace_marker_id;
+ std::string static_trace_marker_id;
/* LTTng/UST allow more than one marker with the same ID string,
although it unadvised because it confuses tools. When setting
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')
{
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
target_continue_no_signal (*ptid);
}
-static VEC(static_tracepoint_marker_p) *
+static std::vector<static_tracepoint_marker>
linux_child_static_tracepoint_markers_by_strid (struct target_ops *self,
const char *strid)
{
char s[IPA_CMD_BUF_SIZE];
struct cleanup *old_chain;
int pid = ptid_get_pid (inferior_ptid);
- VEC(static_tracepoint_marker_p) *markers = NULL;
- struct static_tracepoint_marker *marker = NULL;
+ std::vector<static_tracepoint_marker> markers;
const char *p = s;
ptid_t ptid = ptid_build (pid, 0, 0);
+ static_tracepoint_marker marker;
/* Pause all */
target_stop (ptid);
agent_run_command (pid, s, strlen (s) + 1);
- old_chain = make_cleanup (free_current_marker, &marker);
- make_cleanup (cleanup_target_stop, &ptid);
+ old_chain = make_cleanup (cleanup_target_stop, &ptid);
while (*p++ == 'm')
{
- if (marker == NULL)
- marker = XCNEW (struct static_tracepoint_marker);
-
do
{
- parse_static_tracepoint_marker_definition (p, &p, marker);
+ parse_static_tracepoint_marker_definition (p, &p, &marker);
- if (strid == NULL || strcmp (strid, marker->str_id) == 0)
- {
- VEC_safe_push (static_tracepoint_marker_p,
- markers, marker);
- marker = NULL;
- }
- else
- {
- release_static_tracepoint_marker (marker);
- memset (marker, 0, sizeof (*marker));
- }
+ if (strid == NULL || marker.str_id == strid)
+ markers.push_back (std::move (marker));
}
while (*p++ == ','); /* comma-separated list */
}
\f
-static int
+static bool
remote_static_tracepoint_marker_at (struct target_ops *self, CORE_ADDR addr,
struct static_tracepoint_marker *marker)
{
if (*p++ == 'm')
{
parse_static_tracepoint_marker_definition (p, NULL, marker);
- return 1;
+ return true;
}
- return 0;
+ return false;
}
-static VEC(static_tracepoint_marker_p) *
+static std::vector<static_tracepoint_marker>
remote_static_tracepoint_markers_by_strid (struct target_ops *self,
const char *strid)
{
struct remote_state *rs = get_remote_state ();
- VEC(static_tracepoint_marker_p) *markers = NULL;
- struct static_tracepoint_marker *marker = NULL;
- struct cleanup *old_chain;
+ std::vector<static_tracepoint_marker> markers;
const char *p;
+ static_tracepoint_marker marker;
/* Ask for a first packet of static tracepoint marker
definition. */
if (*p == 'E')
error (_("Remote failure reply: %s"), p);
- old_chain = make_cleanup (free_current_marker, &marker);
-
while (*p++ == 'm')
{
- if (marker == NULL)
- marker = XCNEW (struct static_tracepoint_marker);
-
do
{
- parse_static_tracepoint_marker_definition (p, &p, marker);
+ parse_static_tracepoint_marker_definition (p, &p, &marker);
- if (strid == NULL || strcmp (strid, marker->str_id) == 0)
- {
- VEC_safe_push (static_tracepoint_marker_p,
- markers, marker);
- marker = NULL;
- }
- else
- {
- release_static_tracepoint_marker (marker);
- memset (marker, 0, sizeof (*marker));
- }
+ if (strid == NULL || marker.str_id == strid)
+ markers.push_back (std::move (marker));
}
while (*p++ == ','); /* comma-separated list */
/* Ask for another packet of static tracepoint definition. */
p = rs->buf;
}
- do_cleanups (old_chain);
return markers;
}
target_debug_do_print (host_address_to_string (X))
#define target_debug_print_std_vector_mem_region(X) \
target_debug_do_print (host_address_to_string (X.data ()))
-#define target_debug_print_VEC_static_tracepoint_marker_p_p(X) \
- target_debug_do_print (host_address_to_string (X))
+#define target_debug_print_std_vector_static_tracepoint_marker(X) \
+ target_debug_do_print (host_address_to_string (X.data ()))
#define target_debug_print_const_struct_target_desc_p(X) \
target_debug_do_print (host_address_to_string (X))
#define target_debug_print_struct_bp_location_p(X) \
target_debug_do_print (host_address_to_string (X))
#define target_debug_print_struct_uploaded_tsv_pp(X) \
target_debug_do_print (host_address_to_string (X))
-#define target_debug_print_struct_static_tracepoint_marker_p(X) \
+#define target_debug_print_static_tracepoint_marker_p(X) \
target_debug_do_print (host_address_to_string (X))
#define target_debug_print_struct_traceframe_info_p(X) \
target_debug_do_print (host_address_to_string (X))
fputs_unfiltered (")\n", gdb_stdlog);
}
-static int
-delegate_static_tracepoint_marker_at (struct target_ops *self, CORE_ADDR arg1, struct static_tracepoint_marker *arg2)
+static bool
+delegate_static_tracepoint_marker_at (struct target_ops *self, CORE_ADDR arg1, static_tracepoint_marker *arg2)
{
self = self->beneath;
return self->to_static_tracepoint_marker_at (self, arg1, arg2);
}
-static int
-tdefault_static_tracepoint_marker_at (struct target_ops *self, CORE_ADDR arg1, struct static_tracepoint_marker *arg2)
+static bool
+tdefault_static_tracepoint_marker_at (struct target_ops *self, CORE_ADDR arg1, static_tracepoint_marker *arg2)
{
- return 0;
+ return false;
}
-static int
-debug_static_tracepoint_marker_at (struct target_ops *self, CORE_ADDR arg1, struct static_tracepoint_marker *arg2)
+static bool
+debug_static_tracepoint_marker_at (struct target_ops *self, CORE_ADDR arg1, static_tracepoint_marker *arg2)
{
- int result;
+ bool result;
fprintf_unfiltered (gdb_stdlog, "-> %s->to_static_tracepoint_marker_at (...)\n", debug_target.to_shortname);
result = debug_target.to_static_tracepoint_marker_at (&debug_target, arg1, arg2);
fprintf_unfiltered (gdb_stdlog, "<- %s->to_static_tracepoint_marker_at (", debug_target.to_shortname);
fputs_unfiltered (", ", gdb_stdlog);
target_debug_print_CORE_ADDR (arg1);
fputs_unfiltered (", ", gdb_stdlog);
- target_debug_print_struct_static_tracepoint_marker_p (arg2);
+ target_debug_print_static_tracepoint_marker_p (arg2);
fputs_unfiltered (") = ", gdb_stdlog);
- target_debug_print_int (result);
+ target_debug_print_bool (result);
fputs_unfiltered ("\n", gdb_stdlog);
return result;
}
-static VEC(static_tracepoint_marker_p) *
+static std::vector<static_tracepoint_marker>
delegate_static_tracepoint_markers_by_strid (struct target_ops *self, const char *arg1)
{
self = self->beneath;
return self->to_static_tracepoint_markers_by_strid (self, arg1);
}
-static VEC(static_tracepoint_marker_p) *
+static std::vector<static_tracepoint_marker>
tdefault_static_tracepoint_markers_by_strid (struct target_ops *self, const char *arg1)
{
tcomplain ();
}
-static VEC(static_tracepoint_marker_p) *
+static std::vector<static_tracepoint_marker>
debug_static_tracepoint_markers_by_strid (struct target_ops *self, const char *arg1)
{
- VEC(static_tracepoint_marker_p) * result;
+ std::vector<static_tracepoint_marker> result;
fprintf_unfiltered (gdb_stdlog, "-> %s->to_static_tracepoint_markers_by_strid (...)\n", debug_target.to_shortname);
result = debug_target.to_static_tracepoint_markers_by_strid (&debug_target, arg1);
fprintf_unfiltered (gdb_stdlog, "<- %s->to_static_tracepoint_markers_by_strid (", debug_target.to_shortname);
fputs_unfiltered (", ", gdb_stdlog);
target_debug_print_const_char_p (arg1);
fputs_unfiltered (") = ", gdb_stdlog);
- target_debug_print_VEC_static_tracepoint_marker_p_p (result);
+ target_debug_print_std_vector_static_tracepoint_marker (result);
fputs_unfiltered ("\n", gdb_stdlog);
return result;
}
extern const char *
target_xfer_status_to_string (enum target_xfer_status status);
-typedef struct static_tracepoint_marker *static_tracepoint_marker_p;
-DEF_VEC_P(static_tracepoint_marker_p);
-
typedef enum target_xfer_status
target_xfer_partial_ftype (struct target_ops *ops,
enum target_object object,
TARGET_DEFAULT_IGNORE ();
/* Look for a static tracepoint marker at ADDR, and fill in MARKER
- with its details. Return 1 on success, 0 on failure. */
- int (*to_static_tracepoint_marker_at) (struct target_ops *, CORE_ADDR,
- struct static_tracepoint_marker *marker)
- TARGET_DEFAULT_RETURN (0);
+ with its details. Return true on success, false on failure. */
+ bool (*to_static_tracepoint_marker_at) (struct target_ops *, CORE_ADDR,
+ static_tracepoint_marker *marker)
+ TARGET_DEFAULT_RETURN (false);
/* Return a vector of all tracepoints markers string id ID, or all
markers if ID is NULL. */
- VEC(static_tracepoint_marker_p) *(*to_static_tracepoint_markers_by_strid) (struct target_ops *, const char *id)
+ std::vector<static_tracepoint_marker>
+ (*to_static_tracepoint_markers_by_strid) (struct target_ops *,
+ const char *id)
TARGET_DEFAULT_NORETURN (tcomplain ());
/* Return a traceframe info object describing the current
utsv->name = xstrdup (buf);
}
-void
-free_current_marker (void *arg)
-{
- struct static_tracepoint_marker **marker_p
- = (struct static_tracepoint_marker **) arg;
-
- if (*marker_p != NULL)
- {
- release_static_tracepoint_marker (*marker_p);
- xfree (*marker_p);
- }
- else
- *marker_p = NULL;
-}
-
/* Given a line of text defining a static tracepoint marker, parse it
into a "static tracepoint marker" object. Throws an error is
parsing fails. If PP is non-null, it points to one past the end of
void
parse_static_tracepoint_marker_definition (const char *line, const char **pp,
- struct static_tracepoint_marker *marker)
+ static_tracepoint_marker *marker)
{
const char *p, *endp;
ULONGEST addr;
- int end;
p = line;
p = unpack_varlen_hex (p, &addr);
if (endp == NULL)
error (_("bad marker definition: %s"), line);
- marker->str_id = (char *) xmalloc (endp - p + 1);
- end = hex2bin (p, (gdb_byte *) marker->str_id, (endp - p + 1) / 2);
- marker->str_id[end] = '\0';
+ marker->str_id = hex2str (p, (endp - p) / 2);
- p += 2 * end;
- p++; /* skip a colon */
+ p = endp;
+ p++; /* skip a colon */
/* This definition may be followed by another one, separated by a comma. */
int hex_len;
else
hex_len = strlen (p);
- marker->extra = (char *) xmalloc (hex_len / 2 + 1);
- end = hex2bin (p, (gdb_byte *) marker->extra, hex_len / 2);
- marker->extra[end] = '\0';
+ marker->extra = hex2str (p, hex_len / 2);
- if (pp)
+ if (pp != nullptr)
*pp = p + hex_len;
}
-/* Release a static tracepoint marker's contents. Note that the
- object itself isn't released here. There objects are usually on
- the stack. */
-
-void
-release_static_tracepoint_marker (struct static_tracepoint_marker *marker)
-{
- xfree (marker->str_id);
- marker->str_id = NULL;
-}
-
/* Print MARKER to gdb_stdout. */
static void
print_one_static_tracepoint_marker (int count,
- struct static_tracepoint_marker *marker)
+ const static_tracepoint_marker &marker)
{
struct symbol *sym;
VEC(breakpoint_p) *tracepoints;
symtab_and_line sal;
- sal.pc = marker->address;
+ sal.pc = marker.address;
- tracepoints = static_tracepoints_here (marker->address);
+ tracepoints = static_tracepoints_here (marker.address);
ui_out_emit_tuple tuple_emitter (uiout, "marker");
identifier! */
uiout->field_int ("count", count);
- uiout->field_string ("marker-id", marker->str_id);
+ uiout->field_string ("marker-id", marker.str_id.c_str ());
uiout->field_fmt ("enabled", "%c",
!VEC_empty (breakpoint_p, tracepoints) ? 'y' : 'n');
strcpy (wrap_indent, " ");
- if (gdbarch_addr_bit (marker->gdbarch) <= 32)
+ if (gdbarch_addr_bit (marker.gdbarch) <= 32)
strcat (wrap_indent, " ");
else
strcat (wrap_indent, " ");
strcpy (extra_field_indent, " ");
- uiout->field_core_addr ("addr", marker->gdbarch, marker->address);
+ uiout->field_core_addr ("addr", marker.gdbarch, marker.address);
- sal = find_pc_line (marker->address, 0);
- sym = find_pc_sect_function (marker->address, NULL);
+ sal = find_pc_line (marker.address, 0);
+ sym = find_pc_sect_function (marker.address, NULL);
if (sym)
{
uiout->text ("in ");
uiout->text ("\n");
uiout->text (extra_field_indent);
uiout->text (_("Data: \""));
- uiout->field_string ("extra-data", marker->extra);
+ uiout->field_string ("extra-data", marker.extra.c_str ());
uiout->text ("\"\n");
if (!VEC_empty (breakpoint_p, tracepoints))
static void
info_static_tracepoint_markers_command (const char *arg, int from_tty)
{
- VEC(static_tracepoint_marker_p) *markers;
- struct cleanup *old_chain;
- struct static_tracepoint_marker *marker;
struct ui_out *uiout = current_uiout;
- int i;
+ std::vector<static_tracepoint_marker> markers
+ = target_static_tracepoint_markers_by_strid (NULL);
/* We don't have to check target_can_use_agent and agent's capability on
static tracepoint here, in order to be compatible with older GDBserver.
uiout->table_body ();
- markers = target_static_tracepoint_markers_by_strid (NULL);
- old_chain = make_cleanup (VEC_cleanup (static_tracepoint_marker_p), &markers);
-
- for (i = 0;
- VEC_iterate (static_tracepoint_marker_p,
- markers, i, marker);
- i++)
- {
- print_one_static_tracepoint_marker (i + 1, marker);
- release_static_tracepoint_marker (marker);
- }
-
- do_cleanups (old_chain);
+ for (int i = 0; i < markers.size (); i++)
+ print_one_static_tracepoint_marker (i + 1, markers[i]);
}
/* The $_sdata convenience variable is a bit special. We don't know
struct static_tracepoint_marker
{
- struct gdbarch *gdbarch;
- CORE_ADDR address;
+ DISABLE_COPY_AND_ASSIGN (static_tracepoint_marker);
+
+ static_tracepoint_marker () = default;
+ static_tracepoint_marker (static_tracepoint_marker &&) = default;
+ static_tracepoint_marker &operator= (static_tracepoint_marker &&) = default;
+
+ struct gdbarch *gdbarch = NULL;
+ CORE_ADDR address = 0;
/* The string ID of the marker. */
- char *str_id;
+ std::string str_id;
/* Extra target reported info associated with the marker. */
- char *extra;
+ std::string extra;
};
struct memrange
std::vector<std::string> m_computed;
};
-extern void parse_static_tracepoint_marker_definition
- (const char *line, const char **pp,
- struct static_tracepoint_marker *marker);
-extern void release_static_tracepoint_marker (struct static_tracepoint_marker *);
-extern void free_current_marker (void *arg);
+extern void
+ parse_static_tracepoint_marker_definition (const char *line, const char **pp,
+ static_tracepoint_marker *marker);
/* A hook used to notify the UI of tracepoint operations. */
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 */
{
selftests::register_test ("hex2bin_byte_vector",
selftests::rsp_low::test_hex2bin_byte_vector);
+ selftests::register_test ("hex2str",
+ selftests::rsp_low::test_hex2str);
}
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));
}