- if (the_target->qxfer_spu != NULL
- && strncmp ("qXfer:spu:read:", own_buf, 15) == 0)
- {
- char *annex;
- int n;
- unsigned int len;
- CORE_ADDR ofs;
- unsigned char *spu_buf;
-
- require_running (own_buf);
- strcpy (own_buf, "E00");
- if (decode_xfer_read (own_buf + 15, &annex, &ofs, &len) < 0)
- return;
- if (len > PBUFSIZ - 2)
- len = PBUFSIZ - 2;
- spu_buf = malloc (len + 1);
- if (!spu_buf)
- return;
-
- n = (*the_target->qxfer_spu) (annex, spu_buf, NULL, ofs, len + 1);
- if (n < 0)
- write_enn (own_buf);
- else if (n > len)
- *new_packet_len_p = write_qxfer_response (own_buf, spu_buf, len, 1);
- else
- *new_packet_len_p = write_qxfer_response (own_buf, spu_buf, n, 0);
-
- free (spu_buf);
- return;
- }
-
- if (the_target->qxfer_spu != NULL
- && strncmp ("qXfer:spu:write:", own_buf, 16) == 0)
- {
- char *annex;
- int n;
- unsigned int len;
- CORE_ADDR ofs;
- unsigned char *spu_buf;
-
- require_running (own_buf);
- strcpy (own_buf, "E00");
- spu_buf = malloc (packet_len - 15);
- if (!spu_buf)
- return;
- if (decode_xfer_write (own_buf + 16, packet_len - 16, &annex,
- &ofs, &len, spu_buf) < 0)
- {
- free (spu_buf);
- return;
- }
-
- n = (*the_target->qxfer_spu)
- (annex, NULL, (unsigned const char *)spu_buf, ofs, len);
- if (n < 0)
- write_enn (own_buf);
- else
- sprintf (own_buf, "%x", n);
-
- free (spu_buf);
- return;
- }
-
- if (the_target->read_auxv != NULL
- && strncmp ("qXfer:auxv:read:", own_buf, 16) == 0)
- {
- unsigned char *data;
- int n;
- CORE_ADDR ofs;
- unsigned int len;
- char *annex;
-
- require_running (own_buf);
-
- /* Reject any annex; grab the offset and length. */
- if (decode_xfer_read (own_buf + 16, &annex, &ofs, &len) < 0
- || annex[0] != '\0')
- {
- strcpy (own_buf, "E00");
- return;
- }
-
- /* Read one extra byte, as an indicator of whether there is
- more. */
- if (len > PBUFSIZ - 2)
- len = PBUFSIZ - 2;
- data = malloc (len + 1);
- if (data == NULL)
- {
- write_enn (own_buf);
- return;
- }
- n = (*the_target->read_auxv) (ofs, data, len + 1);
- if (n < 0)
- write_enn (own_buf);
- else if (n > len)
- *new_packet_len_p = write_qxfer_response (own_buf, data, len, 1);
- else
- *new_packet_len_p = write_qxfer_response (own_buf, data, n, 0);
-
- free (data);
-
- return;
- }
-
- if (strncmp ("qXfer:features:read:", own_buf, 20) == 0)
- {
- CORE_ADDR ofs;
- unsigned int len, total_len;
- const char *document;
- char *annex;
-
- require_running (own_buf);
-
- /* Grab the annex, offset, and length. */
- if (decode_xfer_read (own_buf + 20, &annex, &ofs, &len) < 0)
- {
- strcpy (own_buf, "E00");
- return;
- }
-
- /* Now grab the correct annex. */
- document = get_features_xml (annex);
- if (document == NULL)
- {
- strcpy (own_buf, "E00");
- return;
- }
-
- total_len = strlen (document);
- if (len > PBUFSIZ - 2)
- len = PBUFSIZ - 2;
-
- if (ofs > total_len)
- write_enn (own_buf);
- else if (len < total_len - ofs)
- *new_packet_len_p = write_qxfer_response (own_buf, document + ofs,
- len, 1);
- else
- *new_packet_len_p = write_qxfer_response (own_buf, document + ofs,
- total_len - ofs, 0);
-
- return;
- }
-
- if (strncmp ("qXfer:libraries:read:", own_buf, 21) == 0)
- {
- CORE_ADDR ofs;
- unsigned int len, total_len;
- char *document, *p;
- struct inferior_list_entry *dll_ptr;
- char *annex;
-
- require_running (own_buf);
-
- /* Reject any annex; grab the offset and length. */
- if (decode_xfer_read (own_buf + 21, &annex, &ofs, &len) < 0
- || annex[0] != '\0')
- {
- strcpy (own_buf, "E00");
- return;
- }
-
- /* Over-estimate the necessary memory. Assume that every character
- in the library name must be escaped. */
- total_len = 64;
- for (dll_ptr = all_dlls.head; dll_ptr != NULL; dll_ptr = dll_ptr->next)
- total_len += 128 + 6 * strlen (((struct dll_info *) dll_ptr)->name);
-
- document = malloc (total_len);
- if (document == NULL)
- {
- write_enn (own_buf);
- return;
- }
- strcpy (document, "<library-list>\n");
- p = document + strlen (document);
-
- for (dll_ptr = all_dlls.head; dll_ptr != NULL; dll_ptr = dll_ptr->next)
- {
- struct dll_info *dll = (struct dll_info *) dll_ptr;
- char *name;
-
- strcpy (p, " <library name=\"");
- p = p + strlen (p);
- name = xml_escape_text (dll->name);
- strcpy (p, name);
- free (name);
- p = p + strlen (p);
- strcpy (p, "\"><segment address=\"");
- p = p + strlen (p);
- sprintf (p, "0x%lx", (long) dll->base_addr);
- p = p + strlen (p);
- strcpy (p, "\"/></library>\n");
- p = p + strlen (p);
- }
-
- strcpy (p, "</library-list>\n");
-
- total_len = strlen (document);
- if (len > PBUFSIZ - 2)
- len = PBUFSIZ - 2;
-
- if (ofs > total_len)
- write_enn (own_buf);
- else if (len < total_len - ofs)
- *new_packet_len_p = write_qxfer_response (own_buf, document + ofs,
- len, 1);
- else
- *new_packet_len_p = write_qxfer_response (own_buf, document + ofs,
- total_len - ofs, 0);
-
- free (document);
- return;
- }
-
- if (the_target->qxfer_osdata != NULL
- && strncmp ("qXfer:osdata:read:", own_buf, 18) == 0)
- {
- char *annex;
- int n;
- unsigned int len;
- CORE_ADDR ofs;
- unsigned char *workbuf;
-
- strcpy (own_buf, "E00");
- if (decode_xfer_read (own_buf + 18, &annex, &ofs, &len) < 0)
- return;
- if (len > PBUFSIZ - 2)
- len = PBUFSIZ - 2;
- workbuf = malloc (len + 1);
- if (!workbuf)
- return;
-
- n = (*the_target->qxfer_osdata) (annex, workbuf, NULL, ofs, len + 1);
- if (n < 0)
- write_enn (own_buf);
- else if (n > len)
- *new_packet_len_p = write_qxfer_response (own_buf, workbuf, len, 1);
- else
- *new_packet_len_p = write_qxfer_response (own_buf, workbuf, n, 0);
-
- free (workbuf);
- return;
- }
-
- if (the_target->qxfer_siginfo != NULL
- && strncmp ("qXfer:siginfo:read:", own_buf, 19) == 0)
- {
- unsigned char *data;
- int n;
- CORE_ADDR ofs;
- unsigned int len;
- char *annex;
-
- require_running (own_buf);
-
- /* Reject any annex; grab the offset and length. */
- if (decode_xfer_read (own_buf + 19, &annex, &ofs, &len) < 0
- || annex[0] != '\0')
- {
- strcpy (own_buf, "E00");
- return;
- }
-
- /* Read one extra byte, as an indicator of whether there is
- more. */
- if (len > PBUFSIZ - 2)
- len = PBUFSIZ - 2;
- data = malloc (len + 1);
- if (!data)
- return;
- n = (*the_target->qxfer_siginfo) (annex, data, NULL, ofs, len + 1);
- if (n < 0)
- write_enn (own_buf);
- else if (n > len)
- *new_packet_len_p = write_qxfer_response (own_buf, data, len, 1);
- else
- *new_packet_len_p = write_qxfer_response (own_buf, data, n, 0);
-
- free (data);
- return;
- }
-
- if (the_target->qxfer_siginfo != NULL
- && strncmp ("qXfer:siginfo:write:", own_buf, 20) == 0)
- {
- char *annex;
- int n;
- unsigned int len;
- CORE_ADDR ofs;
- unsigned char *data;
-
- require_running (own_buf);
-
- strcpy (own_buf, "E00");
- data = malloc (packet_len - 19);
- if (!data)
- return;
- if (decode_xfer_write (own_buf + 20, packet_len - 20, &annex,
- &ofs, &len, data) < 0)
- {
- free (data);
- return;
- }
-
- n = (*the_target->qxfer_siginfo)
- (annex, NULL, (unsigned const char *)data, ofs, len);
- if (n < 0)
- write_enn (own_buf);
- else
- sprintf (own_buf, "%x", n);
-
- free (data);
- return;
- }
-
- if (strncmp ("qXfer:threads:read:", own_buf, 19) == 0)
- {
- unsigned char *data;
- int n;
- CORE_ADDR ofs;
- unsigned int len;
- char *annex;
-
- require_running (own_buf);
-
- /* Reject any annex; grab the offset and length. */
- if (decode_xfer_read (own_buf + 19, &annex, &ofs, &len) < 0
- || annex[0] != '\0')
- {
- strcpy (own_buf, "E00");
- return;
- }
-
- /* Read one extra byte, as an indicator of whether there is
- more. */
- if (len > PBUFSIZ - 2)
- len = PBUFSIZ - 2;
- data = malloc (len + 1);
- if (!data)
- return;
- n = handle_threads_qxfer (annex, data, ofs, len + 1);
- if (n < 0)
- write_enn (own_buf);
- else if (n > len)
- *new_packet_len_p = write_qxfer_response (own_buf, data, len, 1);
- else
- *new_packet_len_p = write_qxfer_response (own_buf, data, n, 0);
-
- free (data);
- return;
- }
-
- if (strncmp ("qXfer:statictrace:read:", own_buf,
- sizeof ("qXfer:statictrace:read:") -1) == 0)
- {
- unsigned char *data;
- CORE_ADDR ofs;
- unsigned int len;
- char *annex;
- ULONGEST nbytes;
-
- require_running (own_buf);
-
- if (current_traceframe == -1)
- {
- write_enn (own_buf);
- return;
- }
-
- /* Reject any annex; grab the offset and length. */
- if (decode_xfer_read (own_buf + sizeof ("qXfer:statictrace:read:") -1,
- &annex, &ofs, &len) < 0
- || annex[0] != '\0')
- {
- strcpy (own_buf, "E00");
- return;
- }
-
- /* Read one extra byte, as an indicator of whether there is
- more. */
- if (len > PBUFSIZ - 2)
- len = PBUFSIZ - 2;
- data = malloc (len + 1);
- if (!data)
- return;
-
- if (traceframe_read_sdata (current_traceframe, ofs,
- data, len + 1, &nbytes))
- write_enn (own_buf);
- else if (nbytes > len)
- *new_packet_len_p = write_qxfer_response (own_buf, data, len, 1);
- else
- *new_packet_len_p = write_qxfer_response (own_buf, data, nbytes, 0);
-
- free (data);
- return;
- }
-