to as much of DATA/LEN as we could fit. IS_MORE controls
the first character of the response. */
static int
-write_qxfer_response (char *buf, const void *data, int len, int is_more)
+write_qxfer_response (char *buf, const gdb_byte *data, int len, int is_more)
{
int out_len;
? search_space_len
: search_buf_size);
- found_ptr = memmem (search_buf, nr_search_bytes, pattern, pattern_len);
+ found_ptr = (gdb_byte *) memmem (search_buf, nr_search_bytes, pattern,
+ pattern_len);
if (found_ptr != NULL)
{
char ptid_s[100];
int core = target_core_of_thread (ptid);
char core_s[21];
+ const char *name = target_thread_name (ptid);
write_ptid (ptid_s, ptid);
+ buffer_xml_printf (buffer, "<thread id=\"%s\"", ptid_s);
+
if (core != -1)
{
sprintf (core_s, "%d", core);
- buffer_xml_printf (buffer, "<thread id=\"%s\" core=\"%s\"/>\n",
- ptid_s, core_s);
- }
- else
- {
- buffer_xml_printf (buffer, "<thread id=\"%s\"/>\n",
- ptid_s);
+ buffer_xml_printf (buffer, " core=\"%s\"", core_s);
}
+
+ if (name != NULL)
+ buffer_xml_printf (buffer, " name=\"%s\"", name);
+
+ buffer_xml_printf (buffer, "/>\n");
}
/* Helper for handle_qxfer_threads. */
if (strcmp ("qSymbol::", own_buf) == 0)
{
+ struct thread_info *save_thread = current_thread;
+
+ /* For qSymbol, GDB only changes the current thread if the
+ previous current thread was of a different process. So if
+ the previous thread is gone, we need to pick another one of
+ the same process. This can happen e.g., if we followed an
+ exec in a non-leader thread. */
+ if (current_thread == NULL)
+ {
+ current_thread
+ = find_any_thread_of_pid (ptid_get_pid (general_thread));
+
+ /* Just in case, if we didn't find a thread, then bail out
+ instead of crashing. */
+ if (current_thread == NULL)
+ {
+ write_enn (own_buf);
+ current_thread = save_thread;
+ return;
+ }
+ }
+
/* GDB is suggesting new symbols have been loaded. This may
mean a new shared library has been detected as loaded, so
take the opportunity to check if breakpoints we think are
if (current_thread != NULL && the_target->look_up_symbols != NULL)
(*the_target->look_up_symbols) ();
+ current_thread = save_thread;
+
strcpy (own_buf, "OK");
return;
}
char *p = &own_buf[10];
int gdb_supports_qRelocInsn = 0;
- /* Start processing qSupported packet. */
- target_process_qsupported (NULL);
-
/* Process each feature being provided by GDB. The first
feature will follow a ':', and latter features will follow
';'. */
{
char **qsupported = NULL;
int count = 0;
+ int unknown = 0;
int i;
/* Two passes, to avoid nested strtok calls in
else if (strcmp (p, "vContSupported+") == 0)
vCont_supported = 1;
else
- target_process_qsupported (p);
-
- free (p);
+ {
+ /* Move the unknown features all together. */
+ qsupported[i] = NULL;
+ qsupported[unknown] = p;
+ unknown++;
+ }
}
+ /* Give the target backend a chance to process the unknown
+ features. */
+ target_process_qsupported (qsupported, unknown);
+
+ for (i = 0; i < count; i++)
+ free (qsupported[i]);
free (qsupported);
}
goto err;
p = q;
- if (!gdb_signal_to_host_p (sig))
+ if (!gdb_signal_to_host_p ((enum gdb_signal) sig))
goto err;
- resume_info[i].sig = gdb_signal_to_host (sig);
+ resume_info[i].sig = gdb_signal_to_host ((enum gdb_signal) sig);
}
else if (p[0] == 'r')
{
case 'C':
require_running (own_buf);
hex2bin (own_buf + 1, &sig, 1);
- if (gdb_signal_to_host_p (sig))
- signal = gdb_signal_to_host (sig);
+ if (gdb_signal_to_host_p ((enum gdb_signal) sig))
+ signal = gdb_signal_to_host ((enum gdb_signal) sig);
else
signal = 0;
myresume (own_buf, 0, signal);
case 'S':
require_running (own_buf);
hex2bin (own_buf + 1, &sig, 1);
- if (gdb_signal_to_host_p (sig))
- signal = gdb_signal_to_host (sig);
+ if (gdb_signal_to_host_p ((enum gdb_signal) sig))
+ signal = gdb_signal_to_host ((enum gdb_signal) sig);
else
signal = 0;
myresume (own_buf, 1, signal);