ULONGEST offset, LONGEST len)
{
client_state &cs = get_client_state ();
- static char *result = 0;
- static unsigned int result_length = 0;
+ static std::string result;
if (writebuf != NULL)
return -2;
if (offset == 0)
{
- struct buffer buffer;
-
/* When asked for data at offset 0, generate everything and
store into 'result'. Successive reads will be served off
'result'. */
- free (result);
+ result.clear ();
- buffer_init (&buffer);
-
- traceframe_read_info (cs.current_traceframe, &buffer);
-
- result = buffer_finish (&buffer);
- result_length = strlen (result);
- buffer_free (&buffer);
+ traceframe_read_info (cs.current_traceframe, &result);
}
- if (offset >= result_length)
+ if (offset >= result.length ())
{
/* We're out of data. */
- free (result);
- result = NULL;
- result_length = 0;
+ result.clear ();
return 0;
}
- if (len > result_length - offset)
- len = result_length - offset;
+ if (len > result.length () - offset)
+ len = result.length () - offset;
- memcpy (readbuf, result + offset, len);
+ memcpy (readbuf, result.c_str () + offset, len);
return len;
}
}
/* Callback for traceframe_walk_blocks. Builds a traceframe-info
- object. DATA is pointer to a struct buffer holding the
- traceframe-info object being built. */
+ object. DATA is pointer to a string holding the traceframe-info
+ object being built. */
static int
build_traceframe_info_xml (char blocktype, unsigned char *dataptr, void *data)
{
- struct buffer *buffer = (struct buffer *) data;
+ std::string *buffer = (std::string *) data;
switch (blocktype)
{
dataptr += sizeof (maddr);
memcpy (&mlen, dataptr, sizeof (mlen));
dataptr += sizeof (mlen);
- buffer_xml_printf (buffer,
- "<memory start=\"0x%s\" length=\"0x%s\"/>\n",
- paddress (maddr), phex_nz (mlen, sizeof (mlen)));
+ string_xml_appendf (*buffer,
+ "<memory start=\"0x%s\" length=\"0x%s\"/>\n",
+ paddress (maddr), phex_nz (mlen, sizeof (mlen)));
break;
}
case 'V':
int vnum;
memcpy (&vnum, dataptr, sizeof (vnum));
- buffer_xml_printf (buffer, "<tvar id=\"%d\"/>\n", vnum);
+ string_xml_appendf (*buffer, "<tvar id=\"%d\"/>\n", vnum);
break;
}
case 'R':
BUFFER. */
int
-traceframe_read_info (int tfnum, struct buffer *buffer)
+traceframe_read_info (int tfnum, std::string *buffer)
{
struct traceframe *tframe;
return 1;
}
- buffer_grow_str (buffer, "<traceframe-info>\n");
+ *buffer += "<traceframe-info>\n";
traceframe_walk_blocks (tframe->data, tframe->data_size,
tfnum, build_traceframe_info_xml, buffer);
- buffer_grow_str0 (buffer, "</traceframe-info>\n");
+ *buffer += "</traceframe-info>\n";
return 0;
}
unsigned char *buf, ULONGEST length,
ULONGEST *nbytes);
-int traceframe_read_info (int tfnum, struct buffer *buffer);
+int traceframe_read_info (int tfnum, std::string *buffer);
/* If a thread is determined to be collecting a fast tracepoint, this
structure holds the collect status. */