static_cast<int> (memtag_type::allocation)))
{
warning (_("Failed to read MTE tags from memory range [%s,%s)."),
- phex_nz (start_address, sizeof (start_address)),
- phex_nz (end_address, sizeof (end_address)));
+ phex_nz (start_address),
+ phex_nz (end_address));
return false;
}
CORE_ADDR tag = value_as_address (tag_value);
- return string_printf ("0x%s", phex_nz (tag, sizeof (tag)));
+ return string_printf ("0x%s", phex_nz (tag));
}
/* See aarch64-tdep.h. */
}
gdb_printf (fp, " %s mask 0x%s", exp_string.get (),
- phex (hw_wp_mask, sizeof (CORE_ADDR)));
+ phex (hw_wp_mask));
print_recreate_thread (fp);
}
if (ptid.tid () != 0)
return string_printf ("process %d, thread 0x%s",
ptid.pid (),
- phex_nz (ptid.tid (), sizeof (ULONGEST)));
+ phex_nz (ptid.tid ()));
return normal_pid_to_str (ptid);
}
bfd_size_type size = sectp->size;
warning (_("Discarding section %s which has an invalid size (%s) "
"[in module %s]"),
- bfd_section_name (sectp), phex_nz (size, sizeof (size)),
+ bfd_section_name (sectp), phex_nz (size),
this->filename ());
}
else if (names.info.matches (sectp->name))
return beneath ()->pid_to_str (ptid);
return string_printf ("Ravenscar Thread 0x%s",
- phex_nz (ptid.tid (), sizeof (ULONGEST)));
+ phex_nz (ptid.tid ()));
}
CORE_ADDR
i = snprintf (rs->buf.data (), max_size,
"qXfer:%s:write:%s:%s:",
object_name, annex ? annex : "",
- phex_nz (offset, sizeof offset));
+ phex_nz (offset));
max_size -= (i + 1);
/* Escape as much data as fits into rs->buf. */
snprintf (rs->buf.data (), get_remote_packet_size () - 4,
"qXfer:%s:read:%s:%s,%s",
object_name, annex ? annex : "",
- phex_nz (offset, sizeof offset),
- phex_nz (n, sizeof n));
+ phex_nz (offset),
+ phex_nz (n));
i = putpkt (rs->buf);
if (i < 0)
return TARGET_XFER_E_IO;
i = snprintf (rs->buf.data (), max_size,
"qSearch:memory:%s;%s;",
phex_nz (start_addr, addr_size),
- phex_nz (search_space_len, sizeof (search_space_len)));
+ phex_nz (search_space_len));
max_size -= (i + 1);
/* Escape as much data as fits into rs->buf. */
encode_actions_rsp (loc, &tdp_actions, &stepping_actions);
tpaddr = loc->address;
- strcpy (addrbuf, phex (tpaddr, sizeof (CORE_ADDR)));
+ strcpy (addrbuf, phex (tpaddr));
ret = snprintf (buf.data (), buf.size (), "QTDP:%x:%s:%c:%lx:%x",
b->number, addrbuf, /* address */
(b->enable_state == bp_enabled ? 'E' : 'D'),
xsnprintf (rs->buf.data (), get_remote_packet_size (), "QTEnable:%x:%s",
location->owner->number,
- phex (location->address, sizeof (CORE_ADDR)));
+ phex (location->address));
putpkt (rs->buf);
remote_get_noisy_reply ();
if (rs->buf[0] == '\0')
xsnprintf (rs->buf.data (), get_remote_packet_size (), "QTDisable:%x:%s",
location->owner->number,
- phex (location->address, sizeof (CORE_ADDR)));
+ phex (location->address));
putpkt (rs->buf);
remote_get_noisy_reply ();
if (rs->buf[0] == '\0')
*obuf_p++ = ';';
obuf_p += xsnprintf (obuf_p, obuf_endp - obuf_p, "%s",
- phex_nz (options, sizeof (options)));
+ phex_nz (options));
if (tp->ptid != magic_null_ptid)
{
*obuf_p++ = ':';
std::string request = string_printf ("qMemTags:%s,%s:%s",
phex_nz (address, addr_size),
- phex_nz (len, sizeof (len)),
- phex_nz (type, sizeof (type)));
+ phex_nz (len),
+ phex_nz (type));
strcpy (packet.data (), request.c_str ());
}
/* Put together the main packet, address and length. */
std::string request = string_printf ("QMemTags:%s,%s:%s:",
phex_nz (address, addr_size),
- phex_nz (len, sizeof (len)),
- phex_nz (type, sizeof (type)));
+ phex_nz (len),
+ phex_nz (type));
request += bin2hex (tags.data (), tags.size ());
/* Check if we have exceeded the maximum packet size. */
/* Unknown key=value pairs are ignored by the gdbstub. */
xsnprintf (annex, sizeof (annex), "lmid=%s;start=%s;prev=%s",
- phex_nz (debug_base, sizeof (debug_base)),
- phex_nz (lm, sizeof (lm)),
- phex_nz (prev_lm, sizeof (prev_lm)));
+ phex_nz (debug_base),
+ phex_nz (lm),
+ phex_nz (prev_lm));
if (!svr4_current_sos_via_xfer_libraries (&library_list, annex))
return 0;
if (ts->start_time)
{
fprintf (writer->fp, ";starttime:%s",
- phex_nz (ts->start_time, sizeof (ts->start_time)));
+ phex_nz (ts->start_time));
}
if (ts->stop_time)
{
fprintf (writer->fp, ";stoptime:%s",
- phex_nz (ts->stop_time, sizeof (ts->stop_time)));
+ phex_nz (ts->stop_time));
}
if (ts->notes != NULL)
{
char buf[MAX_TRACE_UPLOAD];
fprintf (writer->fp, "tp T%x:%s:%c:%x:%x",
- utp->number, phex_nz (utp->addr, sizeof (utp->addr)),
+ utp->number, phex_nz (utp->addr),
(utp->enabled ? 'E' : 'D'), utp->step, utp->pass);
if (utp->type == bp_fast_tracepoint)
fprintf (writer->fp, ":F%x", utp->orig_size);
fprintf (writer->fp, "\n");
for (const auto &act : utp->actions)
fprintf (writer->fp, "tp A%x:%s:%s\n",
- utp->number, phex_nz (utp->addr, sizeof (utp->addr)), act.get ());
+ utp->number, phex_nz (utp->addr), act.get ());
for (const auto &act : utp->step_actions)
fprintf (writer->fp, "tp S%x:%s:%s\n",
- utp->number, phex_nz (utp->addr, sizeof (utp->addr)), act.get ());
+ utp->number, phex_nz (utp->addr), act.get ());
if (utp->at_string)
{
encode_source_string (utp->number, utp->addr,
fprintf (writer->fp, "tp Z%s\n", buf);
}
fprintf (writer->fp, "tp V%x:%s:%x:%s\n",
- utp->number, phex_nz (utp->addr, sizeof (utp->addr)),
+ utp->number, phex_nz (utp->addr),
utp->hit_count,
phex_nz (utp->traceframe_usage,
sizeof (utp->traceframe_usage)));
if (80 + strlen (srctype) > buf_size)
error (_("Buffer too small for source encoding"));
sprintf (buf, "%x:%s:%s:%x:%x:",
- tpnum, phex_nz (addr, sizeof (addr)),
+ tpnum, phex_nz (addr),
srctype, 0, (int) strlen (src));
if (strlen (buf) + strlen (src) * 2 >= buf_size)
error (_("Source string too long for buffer"));
{
char *end_buf = own_buf + strlen (own_buf);
sprintf (end_buf, ";QThreadOptions=%s",
- phex_nz (supported_options, sizeof (supported_options)));
+ phex_nz (supported_options));
}
strcat (own_buf, ";QThreadEvents+");
else if (ptid.tid () != 0)
return string_printf("Thread %d.0x%s",
ptid.pid (),
- phex_nz (ptid.tid (), sizeof (ULONGEST)));
+ phex_nz (ptid.tid ()));
else if (ptid.lwp () != 0)
return string_printf("LWP %d.%ld",
ptid.pid (), ptid.lwp ());
free_space (), phex_nz (trace_buffer_hi - trace_buffer_lo, 0),
circular_trace_buffer,
disconnected_tracing,
- phex_nz (tracing_start_time, sizeof (tracing_start_time)),
- phex_nz (tracing_stop_time, sizeof (tracing_stop_time)),
+ phex_nz (tracing_start_time),
+ phex_nz (tracing_stop_time),
buf1, buf2);
}
dataptr += sizeof (mlen);
string_xml_appendf (*buffer,
"<memory start=\"0x%s\" length=\"0x%s\"/>\n",
- paddress (maddr), phex_nz (mlen, sizeof (mlen)));
+ paddress (maddr), phex_nz (mlen));
break;
}
case 'V':
const char *
paddress (CORE_ADDR addr)
{
- return phex_nz (addr, sizeof (CORE_ADDR));
+ return phex_nz (addr);
}
/* See print-utils.h. */
const char *
-phex (ULONGEST l, int sizeof_l)
+phex_ulongest (ULONGEST l, int sizeof_l)
{
char *str;
xsnprintf (str, PRINT_CELL_SIZE, "%02x", (unsigned short) (l & 0xff));
break;
default:
- return phex (l, sizeof (l));
+ return phex (l);
break;
}
/* See print-utils.h. */
const char *
-phex_nz (ULONGEST l, int sizeof_l)
+phex_nz_ulongest (ULONGEST l, int sizeof_l)
{
char *str;
xsnprintf (str, PRINT_CELL_SIZE, "%x", (unsigned short) (l & 0xff));
break;
default:
- return phex_nz (l, sizeof (l));
+ return phex_nz (l);
break;
}
{
char *result = get_print_cell ();
- xsnprintf (result, PRINT_CELL_SIZE, "0x%s", phex_nz (num, sizeof (num)));
+ xsnprintf (result, PRINT_CELL_SIZE, "0x%s", phex_nz (num));
return result;
}
{
char *result = get_print_cell ();
char *result_end = result + PRINT_CELL_SIZE - 1;
- const char *hex = phex_nz (num, sizeof (num));
+ const char *hex = phex_nz (num);
int hex_len = strlen (hex);
if (hex_len > width)
char *str = get_print_cell ();
strcpy (str, "0x");
- strcat (str, phex (addr, sizeof (addr)));
+ strcat (str, phex (addr));
return str;
}
char *str = get_print_cell ();
strcpy (str, "0x");
- strcat (str, phex_nz (addr, sizeof (addr)));
+ strcat (str, phex_nz (addr));
return str;
}
extern const char *plongest (LONGEST l);
-/* Convert a ULONGEST into a HEX string, like %lx, with leading zeros.
+/* Convert L (of type ULONGEST) into a hex string, like %lx, with leading
+ zeros. The result is stored in a circular static buffer, NUMCELLS
+ deep. */
+
+extern const char *phex_ulongest (ULONGEST l, int sizeof_l);
+
+/* Convert L into a HEX string, like %lx, with leading zeros.
The result is stored in a circular static buffer, NUMCELLS deep. */
-extern const char *phex (ULONGEST l, int sizeof_l);
+template<typename T>
+const char *phex (T l, int sizeof_l = sizeof (T))
+{
+ return phex_ulongest (l, sizeof_l);
+}
+
+/* Convert L (of type ULONGEST) into a hex string, like %lx, without leading
+ zeros. The result is stored in a circular static buffer, NUMCELLS
+ deep. */
-/* Convert a ULONGEST into a HEX string, like %lx, without leading zeros.
- The result is stored in a circular static buffer, NUMCELLS deep. */
+extern const char *phex_nz_ulongest (ULONGEST l, int sizeof_l);
+
+/* Convert L into a hex string, like %lx, without leading zeros.
+ The result is stored in a circular static buffer, NUMCELLS deep. */
-extern const char *phex_nz (ULONGEST l, int sizeof_l);
+template<typename T>
+const char *phex_nz (T l, int sizeof_l = sizeof (T))
+{
+ return phex_nz_ulongest (l, sizeof_l);
+}
/* Converts a LONGEST to a C-format hexadecimal literal and stores it
in a static string. Returns a pointer to this string. */