#include <fcntl.h>
#include <unistd.h>
#include <sys/time.h>
-#include <stddef.h>
#include <inttypes.h>
#include <stdint.h>
{
if (read_inferior_data_pointer (ipa_sym_addrs.addr_gdb_jump_pad_buffer,
&gdb_jump_pad_head))
- fatal ("error extracting jump_pad_buffer");
+ {
+ internal_error (__FILE__, __LINE__,
+ "error extracting jump_pad_buffer");
+ }
}
return gdb_jump_pad_head;
if (read_inferior_data_pointer (ipa_sym_addrs.addr_gdb_trampoline_buffer,
&trampoline_buffer_tail))
{
- fatal ("error extracting trampoline_buffer");
- return 0;
+ internal_error (__FILE__, __LINE__,
+ "error extracting trampoline_buffer");
}
if (read_inferior_data_pointer (ipa_sym_addrs.addr_gdb_trampoline_buffer_end,
&trampoline_buffer_head))
{
- fatal ("error extracting trampoline_buffer_end");
- return 0;
+ internal_error (__FILE__, __LINE__,
+ "error extracting trampoline_buffer_end");
}
}
if (read_inferior_data_pointer (ipa_sym_addrs.addr_gdb_trampoline_buffer_end,
&trampoline_end))
{
- fatal ("error extracting trampoline_buffer_end");
- return 0;
+ internal_error (__FILE__, __LINE__,
+ "error extracting trampoline_buffer_end");
}
if (buf)
if (read_inferior_data_pointer (ipa_sym_addrs.addr_gdb_trampoline_buffer_error,
&errbuf))
{
- fatal ("error extracting errbuf");
- return 0;
+ internal_error (__FILE__, __LINE__,
+ "error extracting errbuf");
}
read_inferior_memory (errbuf, (unsigned char *) buf, 100);
if (agent_loaded_p ())
{
if (write_inferior_integer (ipa_sym_addrs.addr_tracing, 1))
- fatal ("Error setting tracing variable in lib");
+ {
+ internal_error (__FILE__, __LINE__,
+ "Error setting tracing variable in lib");
+ }
if (write_inferior_data_pointer (ipa_sym_addrs.addr_stopping_tracepoint,
0))
- fatal ("Error clearing stopping_tracepoint variable in lib");
+ {
+ internal_error (__FILE__, __LINE__,
+ "Error clearing stopping_tracepoint variable"
+ " in lib");
+ }
if (write_inferior_integer (ipa_sym_addrs.addr_trace_buffer_is_full, 0))
- fatal ("Error clearing trace_buffer_is_full variable in lib");
+ {
+ internal_error (__FILE__, __LINE__,
+ "Error clearing trace_buffer_is_full variable"
+ " in lib");
+ }
stop_tracing_bkpt = set_breakpoint_at (ipa_sym_addrs.addr_stop_tracing,
stop_tracing_handler);
if (agent_loaded_p ())
{
if (write_inferior_integer (ipa_sym_addrs.addr_tracing, 0))
- fatal ("Error clearing tracing variable in lib");
+ {
+ internal_error (__FILE__, __LINE__,
+ "Error clearing tracing variable in lib");
+ }
}
tracing_stop_time = get_timestamp ();
run_inferior_command (packet, strlen (packet) + 1);
}
+/* Helper for gdb_agent_about_to_close.
+ Return non-zero if thread ENTRY is in the same process in DATA. */
+
+static int
+same_process_p (struct inferior_list_entry *entry, void *data)
+{
+ int *pid = data;
+
+ return ptid_get_pid (entry->id) == *pid;
+}
+
/* Sent the agent a command to close it. */
void
if (!maybe_write_ipa_not_loaded (buf))
{
struct thread_info *save_inferior;
- struct inferior_list_entry *inf = all_threads.head;
save_inferior = current_inferior;
- /* Find a certain thread which belongs to process PID. */
- while (inf != NULL)
- {
- if (ptid_get_pid (inf->id) == pid)
- break;
- inf = inf->next;
- }
-
- current_inferior = (struct thread_info *) inf;
+ /* Find any thread which belongs to process PID. */
+ current_inferior = (struct thread_info *)
+ find_inferior (&all_threads, same_process_p, &pid);
strcpy (buf, "close");
if (read_inferior_data_pointer (ipa_sym_addrs.addr_gdb_jump_pad_buffer,
&ipa_gdb_jump_pad_buffer))
- fatal ("error extracting `gdb_jump_pad_buffer'");
+ {
+ internal_error (__FILE__, __LINE__,
+ "error extracting `gdb_jump_pad_buffer'");
+ }
if (read_inferior_data_pointer (ipa_sym_addrs.addr_gdb_jump_pad_buffer_end,
&ipa_gdb_jump_pad_buffer_end))
- fatal ("error extracting `gdb_jump_pad_buffer_end'");
+ {
+ internal_error (__FILE__, __LINE__,
+ "error extracting `gdb_jump_pad_buffer_end'");
+ }
if (read_inferior_data_pointer (ipa_sym_addrs.addr_gdb_trampoline_buffer,
&ipa_gdb_trampoline_buffer))
- fatal ("error extracting `gdb_trampoline_buffer'");
+ {
+ internal_error (__FILE__, __LINE__,
+ "error extracting `gdb_trampoline_buffer'");
+ }
if (read_inferior_data_pointer (ipa_sym_addrs.addr_gdb_trampoline_buffer_end,
&ipa_gdb_trampoline_buffer_end))
- fatal ("error extracting `gdb_trampoline_buffer_end'");
+ {
+ internal_error (__FILE__, __LINE__,
+ "error extracting `gdb_trampoline_buffer_end'");
+ }
if (ipa_gdb_jump_pad_buffer <= stop_pc
&& stop_pc < ipa_gdb_jump_pad_buffer_end)
/* We have the pointer *address*, need what it points to. */
if (read_inferior_data_pointer (ipa_sym_addrs.addr_gdb_tp_heap_buffer,
&target_tp_heap))
- fatal ("could get target heap head pointer");
+ {
+ internal_error (__FILE__, __LINE__,
+ "couldn't get target heap head pointer");
+ }
}
ptr = target_tp_heap;
if (read_inferior_data_pointer (tp_prev->obj_addr_on_target
+ offsetof (struct tracepoint, next),
&tp_prev_target_next_addr))
- fatal ("error reading `tp_prev->next'");
+ {
+ internal_error (__FILE__, __LINE__,
+ "error reading `tp_prev->next'");
+ }
/* tpoint->next = tp_prev->next */
write_inferior_data_ptr (tpoint->obj_addr_on_target
name_addr);
}
- if (tsv->getter != NULL)
- {
- fatal ("what to do with these?");
- }
+ gdb_assert (tsv->getter == NULL);
}
if (prev_ptr != 0)
error ("Uploading: couldn't read traceframe at %s\n", paddress (tf));
if (ipa_tframe.tpnum == 0)
- fatal ("Uploading: No (more) fast traceframes, but "
- "ipa_traceframe_count == %u??\n",
- ipa_traceframe_write_count - ipa_traceframe_read_count);
+ {
+ internal_error (__FILE__, __LINE__,
+ "Uploading: No (more) fast traceframes, but"
+ " ipa_traceframe_count == %u??\n",
+ ipa_traceframe_write_count
+ - ipa_traceframe_read_count);
+ }
/* Note that this will be incorrect for multi-location
tracepoints... */
#endif /* HAVE_UST */
#include <sys/syscall.h>
-#include <stdlib.h>
static void
gdb_agent_remove_socket (void)
sigfillset (&new_mask);
res = pthread_sigmask (SIG_SETMASK, &new_mask, &orig_mask);
if (res)
- fatal ("pthread_sigmask (1) failed: %s", strerror (res));
+ perror_with_name ("pthread_sigmask (1)");
res = pthread_create (&thread,
NULL,
res = pthread_sigmask (SIG_SETMASK, &orig_mask, NULL);
if (res)
- fatal ("pthread_sigmask (2) failed: %s", strerror (res));
+ perror_with_name ("pthread_sigmask (2)");
while (helper_thread_id == 0)
usleep (1);
pagesize = sysconf (_SC_PAGE_SIZE);
if (pagesize == -1)
- fatal ("sysconf");
+ perror_with_name ("sysconf");
gdb_tp_heap_buffer = xmalloc (5 * 1024 * 1024);
}
if (addr == 0)
- fatal ("\
-initialize_tracepoint: mmap'ing jump pad buffer failed with %s",
- strerror (errno));
+ perror_with_name ("mmap");
gdb_jump_pad_buffer_end = gdb_jump_pad_buffer + pagesize * SCRATCH_BUFFER_NPAGES;
}