Straightforward fatal to internal_error conversions

This commit replaces most of the calls to fatal that represent
internal errors with calls to internal_error, either directly
or via gdb_assert and gdb_assert_not_reached.

gdb/gdbserver/ChangeLog:

	* inferiors.c (get_thread_process): Replace check with gdb_assert.
	* linux-low.c (linux_wait_for_event_filtered): Replace fatal with
	internal_error.
	(linux_resume_one_lwp): Likewise.
	* linux-x86-low.c (x86_siginfo_fixup): Replace checks with
	gdb_assert.
	* mem-break.c (raw_bkpt_type_to_target_hw_bp_type): Replace fatal
	with internal_error.
	* regcache.c (get_thread_regcache): Replace check with gdb_assert.
	(init_register_cache): Replace fatal with gdb_assert_not_reached.
	(find_register_by_name): Replace fatal with internal_error.
	(find_regno): Likewise.
	* tdesc.c (init_target_desc): Replace check with gdb_assert.
	* thread-db.c (thread_db_create_event): Likewise.
	(thread_db_load_search): Likewise.
	(try_thread_db_load_1): Likewise.
	* tracepoint.c (get_jump_space_head): Replace fatal with
	internal_error.
	(claim_trampoline_space): Likewise.
	(have_fast_tracepoint_trampoline_buffer): Likewise.
	(cmd_qtstart): Likewise.
	(stop_tracing): Likewise.
	(fast_tracepoint_collecting): Likewise.
	(target_malloc): Likewise.
	(download_tracepoint): Likewise.
	(download_trace_state_variables): Replace check with gdb_assert.
	(upload_fast_traceframes): Replace fatal with internal_error.
This commit is contained in:
Gary Benson 2014-08-06 11:56:25 +01:00
parent 6aefca7e49
commit 38e08fcac0
9 changed files with 117 additions and 52 deletions

View File

@ -1,3 +1,33 @@
2014-08-28 Gary Benson <gbenson@redhat.com>
* inferiors.c (get_thread_process): Replace check with gdb_assert.
* linux-low.c (linux_wait_for_event_filtered): Replace fatal with
internal_error.
(linux_resume_one_lwp): Likewise.
* linux-x86-low.c (x86_siginfo_fixup): Replace checks with
gdb_assert.
* mem-break.c (raw_bkpt_type_to_target_hw_bp_type): Replace fatal
with internal_error.
* regcache.c (get_thread_regcache): Replace check with gdb_assert.
(init_register_cache): Replace fatal with gdb_assert_not_reached.
(find_register_by_name): Replace fatal with internal_error.
(find_regno): Likewise.
* tdesc.c (init_target_desc): Replace check with gdb_assert.
* thread-db.c (thread_db_create_event): Likewise.
(thread_db_load_search): Likewise.
(try_thread_db_load_1): Likewise.
* tracepoint.c (get_jump_space_head): Replace fatal with
internal_error.
(claim_trampoline_space): Likewise.
(have_fast_tracepoint_trampoline_buffer): Likewise.
(cmd_qtstart): Likewise.
(stop_tracing): Likewise.
(fast_tracepoint_collecting): Likewise.
(target_malloc): Likewise.
(download_tracepoint): Likewise.
(download_trace_state_variables): Replace check with gdb_assert.
(upload_fast_traceframes): Replace fatal with internal_error.
2014-08-19 Tom Tromey <tromey@redhat.com> 2014-08-19 Tom Tromey <tromey@redhat.com>
Gary Benson <gbenson@redhat.com> Gary Benson <gbenson@redhat.com>

View File

@ -355,8 +355,6 @@ get_thread_process (struct thread_info *thread)
struct process_info * struct process_info *
current_process (void) current_process (void)
{ {
if (current_inferior == NULL) gdb_assert (current_inferior != NULL);
fatal ("Current inferior requested, but current_inferior is NULL\n");
return get_thread_process (current_inferior); return get_thread_process (current_inferior);
} }

View File

@ -2026,7 +2026,11 @@ linux_wait_for_event_filtered (ptid_t wait_ptid, ptid_t filter_ptid,
if (requested_child->suspended if (requested_child->suspended
&& requested_child->status_pending_p) && requested_child->status_pending_p)
fatal ("requesting an event out of a suspended child?"); {
internal_error (__FILE__, __LINE__,
"requesting an event out of a"
" suspended child?");
}
if (requested_child->status_pending_p) if (requested_child->status_pending_p)
{ {
@ -3432,8 +3436,11 @@ linux_resume_one_lwp (struct lwp_info *lwp,
if (can_hardware_single_step ()) if (can_hardware_single_step ())
step = 1; step = 1;
else else
fatal ("moving out of jump pad single-stepping" {
" not implemented on this target"); internal_error (__FILE__, __LINE__,
"moving out of jump pad single-stepping"
" not implemented on this target");
}
/* Postpone any pending signal. It was enqueued above. */ /* Postpone any pending signal. It was enqueued above. */
signal = 0; signal = 0;

View File

@ -1227,8 +1227,7 @@ x86_siginfo_fixup (siginfo_t *native, void *inf, int direction)
/* Is the inferior 32-bit? If so, then fixup the siginfo object. */ /* Is the inferior 32-bit? If so, then fixup the siginfo object. */
if (!is_64bit_tdesc ()) if (!is_64bit_tdesc ())
{ {
if (sizeof (siginfo_t) != sizeof (compat_siginfo_t)) gdb_assert (sizeof (siginfo_t) == sizeof (compat_siginfo_t));
fatal ("unexpected difference in siginfo");
if (direction == 0) if (direction == 0)
compat_siginfo_from_siginfo ((struct compat_siginfo *) inf, native); compat_siginfo_from_siginfo ((struct compat_siginfo *) inf, native);
@ -1240,8 +1239,7 @@ x86_siginfo_fixup (siginfo_t *native, void *inf, int direction)
/* No fixup for native x32 GDB. */ /* No fixup for native x32 GDB. */
else if (!is_elf64 && sizeof (void *) == 8) else if (!is_elf64 && sizeof (void *) == 8)
{ {
if (sizeof (siginfo_t) != sizeof (compat_x32_siginfo_t)) gdb_assert (sizeof (siginfo_t) == sizeof (compat_x32_siginfo_t));
fatal ("unexpected difference in siginfo");
if (direction == 0) if (direction == 0)
compat_x32_siginfo_from_siginfo ((struct compat_x32_siginfo *) inf, compat_x32_siginfo_from_siginfo ((struct compat_x32_siginfo *) inf,

View File

@ -189,7 +189,8 @@ raw_bkpt_type_to_target_hw_bp_type (enum raw_bkpt_type raw_type)
case raw_bkpt_type_access_wp: case raw_bkpt_type_access_wp:
return hw_access; return hw_access;
default: default:
fatal ("bad raw breakpoing type %d", (int) raw_type); internal_error (__FILE__, __LINE__,
"bad raw breakpoint type %d", (int) raw_type);
} }
} }

View File

@ -41,8 +41,7 @@ get_thread_regcache (struct thread_info *thread, int fetch)
{ {
struct process_info *proc = get_thread_process (thread); struct process_info *proc = get_thread_process (thread);
if (proc->tdesc == NULL) gdb_assert (proc->tdesc != NULL);
fatal ("no target description");
regcache = new_register_cache (proc->tdesc); regcache = new_register_cache (proc->tdesc);
set_inferior_regcache_data (thread, regcache); set_inferior_regcache_data (thread, regcache);
@ -126,7 +125,7 @@ init_register_cache (struct regcache *regcache,
regcache->register_status = xcalloc (1, tdesc->num_registers); regcache->register_status = xcalloc (1, tdesc->num_registers);
gdb_assert (REG_UNAVAILABLE == 0); gdb_assert (REG_UNAVAILABLE == 0);
#else #else
fatal ("init_register_cache: can't allocate memory from the heap"); gdb_assert_not_reached ("can't allocate memory from the heap");
#endif #endif
} }
else else
@ -239,8 +238,8 @@ find_register_by_name (const struct target_desc *tdesc, const char *name)
for (i = 0; i < tdesc->num_registers; i++) for (i = 0; i < tdesc->num_registers; i++)
if (strcmp (name, tdesc->reg_defs[i].name) == 0) if (strcmp (name, tdesc->reg_defs[i].name) == 0)
return &tdesc->reg_defs[i]; return &tdesc->reg_defs[i];
fatal ("Unknown register %s requested", name); internal_error (__FILE__, __LINE__, "Unknown register %s requested",
return 0; name);
} }
int int
@ -251,8 +250,8 @@ find_regno (const struct target_desc *tdesc, const char *name)
for (i = 0; i < tdesc->num_registers; i++) for (i = 0; i < tdesc->num_registers; i++)
if (strcmp (name, tdesc->reg_defs[i].name) == 0) if (strcmp (name, tdesc->reg_defs[i].name) == 0)
return i; return i;
fatal ("Unknown register %s requested", name); internal_error (__FILE__, __LINE__, "Unknown register %s requested",
return -1; name);
} }
struct reg * struct reg *

View File

@ -35,8 +35,7 @@ init_target_desc (struct target_desc *tdesc)
/* Make sure PBUFSIZ is large enough to hold a full register /* Make sure PBUFSIZ is large enough to hold a full register
packet. */ packet. */
if (2 * tdesc->registers_size + 32 > PBUFSIZ) gdb_assert (2 * tdesc->registers_size + 32 <= PBUFSIZ);
fatal ("Register packet size exceeds PBUFSIZ.");
} }
#ifndef IN_PROCESS_AGENT #ifndef IN_PROCESS_AGENT

View File

@ -193,8 +193,7 @@ thread_db_create_event (CORE_ADDR where)
struct lwp_info *lwp; struct lwp_info *lwp;
struct thread_db *thread_db = current_process ()->private->thread_db; struct thread_db *thread_db = current_process ()->private->thread_db;
if (thread_db->td_ta_event_getmsg_p == NULL) gdb_assert (thread_db->td_ta_event_getmsg_p != NULL);
fatal ("unexpected thread_db->td_ta_event_getmsg_p == NULL");
if (debug_threads) if (debug_threads)
debug_printf ("Thread creation event.\n"); debug_printf ("Thread creation event.\n");
@ -561,8 +560,7 @@ thread_db_load_search (void)
struct thread_db *tdb; struct thread_db *tdb;
struct process_info *proc = current_process (); struct process_info *proc = current_process ();
if (proc->private->thread_db != NULL) gdb_assert (proc->private->thread_db == NULL);
fatal ("unexpected: proc->private->thread_db != NULL");
tdb = xcalloc (1, sizeof (*tdb)); tdb = xcalloc (1, sizeof (*tdb));
proc->private->thread_db = tdb; proc->private->thread_db = tdb;
@ -607,8 +605,7 @@ try_thread_db_load_1 (void *handle)
struct thread_db *tdb; struct thread_db *tdb;
struct process_info *proc = current_process (); struct process_info *proc = current_process ();
if (proc->private->thread_db != NULL) gdb_assert (proc->private->thread_db == NULL);
fatal ("unexpected: proc->private->thread_db != NULL");
tdb = xcalloc (1, sizeof (*tdb)); tdb = xcalloc (1, sizeof (*tdb));
proc->private->thread_db = tdb; proc->private->thread_db = tdb;

View File

@ -2942,7 +2942,10 @@ get_jump_space_head (void)
{ {
if (read_inferior_data_pointer (ipa_sym_addrs.addr_gdb_jump_pad_buffer, if (read_inferior_data_pointer (ipa_sym_addrs.addr_gdb_jump_pad_buffer,
&gdb_jump_pad_head)) &gdb_jump_pad_head))
fatal ("error extracting jump_pad_buffer"); {
internal_error (__FILE__, __LINE__,
"error extracting jump_pad_buffer");
}
} }
return gdb_jump_pad_head; return gdb_jump_pad_head;
@ -2973,15 +2976,15 @@ claim_trampoline_space (ULONGEST used, CORE_ADDR *trampoline)
if (read_inferior_data_pointer (ipa_sym_addrs.addr_gdb_trampoline_buffer, if (read_inferior_data_pointer (ipa_sym_addrs.addr_gdb_trampoline_buffer,
&trampoline_buffer_tail)) &trampoline_buffer_tail))
{ {
fatal ("error extracting trampoline_buffer"); internal_error (__FILE__, __LINE__,
return 0; "error extracting trampoline_buffer");
} }
if (read_inferior_data_pointer (ipa_sym_addrs.addr_gdb_trampoline_buffer_end, if (read_inferior_data_pointer (ipa_sym_addrs.addr_gdb_trampoline_buffer_end,
&trampoline_buffer_head)) &trampoline_buffer_head))
{ {
fatal ("error extracting trampoline_buffer_end"); internal_error (__FILE__, __LINE__,
return 0; "error extracting trampoline_buffer_end");
} }
} }
@ -3016,8 +3019,8 @@ have_fast_tracepoint_trampoline_buffer (char *buf)
if (read_inferior_data_pointer (ipa_sym_addrs.addr_gdb_trampoline_buffer_end, if (read_inferior_data_pointer (ipa_sym_addrs.addr_gdb_trampoline_buffer_end,
&trampoline_end)) &trampoline_end))
{ {
fatal ("error extracting trampoline_buffer_end"); internal_error (__FILE__, __LINE__,
return 0; "error extracting trampoline_buffer_end");
} }
if (buf) if (buf)
@ -3027,8 +3030,8 @@ have_fast_tracepoint_trampoline_buffer (char *buf)
if (read_inferior_data_pointer (ipa_sym_addrs.addr_gdb_trampoline_buffer_error, if (read_inferior_data_pointer (ipa_sym_addrs.addr_gdb_trampoline_buffer_error,
&errbuf)) &errbuf))
{ {
fatal ("error extracting errbuf"); internal_error (__FILE__, __LINE__,
return 0; "error extracting errbuf");
} }
read_inferior_memory (errbuf, (unsigned char *) buf, 100); read_inferior_memory (errbuf, (unsigned char *) buf, 100);
@ -3370,14 +3373,25 @@ cmd_qtstart (char *packet)
if (agent_loaded_p ()) if (agent_loaded_p ())
{ {
if (write_inferior_integer (ipa_sym_addrs.addr_tracing, 1)) 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, if (write_inferior_data_pointer (ipa_sym_addrs.addr_stopping_tracepoint,
0)) 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)) 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_bkpt = set_breakpoint_at (ipa_sym_addrs.addr_stop_tracing,
stop_tracing_handler); stop_tracing_handler);
@ -3429,7 +3443,10 @@ stop_tracing (void)
if (agent_loaded_p ()) if (agent_loaded_p ())
{ {
if (write_inferior_integer (ipa_sym_addrs.addr_tracing, 0)) 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 (); tracing_stop_time = get_timestamp ();
@ -5607,17 +5624,29 @@ fast_tracepoint_collecting (CORE_ADDR thread_area,
if (read_inferior_data_pointer (ipa_sym_addrs.addr_gdb_jump_pad_buffer, if (read_inferior_data_pointer (ipa_sym_addrs.addr_gdb_jump_pad_buffer,
&ipa_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, if (read_inferior_data_pointer (ipa_sym_addrs.addr_gdb_jump_pad_buffer_end,
&ipa_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, if (read_inferior_data_pointer (ipa_sym_addrs.addr_gdb_trampoline_buffer,
&ipa_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, if (read_inferior_data_pointer (ipa_sym_addrs.addr_gdb_trampoline_buffer_end,
&ipa_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 if (ipa_gdb_jump_pad_buffer <= stop_pc
&& stop_pc < ipa_gdb_jump_pad_buffer_end) && stop_pc < ipa_gdb_jump_pad_buffer_end)
@ -5937,7 +5966,10 @@ target_malloc (ULONGEST size)
/* We have the pointer *address*, need what it points to. */ /* We have the pointer *address*, need what it points to. */
if (read_inferior_data_pointer (ipa_sym_addrs.addr_gdb_tp_heap_buffer, if (read_inferior_data_pointer (ipa_sym_addrs.addr_gdb_tp_heap_buffer,
&target_tp_heap)) &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; ptr = target_tp_heap;
@ -6161,7 +6193,10 @@ download_tracepoint (struct tracepoint *tpoint)
if (read_inferior_data_pointer (tp_prev->obj_addr_on_target if (read_inferior_data_pointer (tp_prev->obj_addr_on_target
+ offsetof (struct tracepoint, next), + offsetof (struct tracepoint, next),
&tp_prev_target_next_addr)) &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 */ /* tpoint->next = tp_prev->next */
write_inferior_data_ptr (tpoint->obj_addr_on_target write_inferior_data_ptr (tpoint->obj_addr_on_target
@ -6238,10 +6273,7 @@ download_trace_state_variables (void)
name_addr); name_addr);
} }
if (tsv->getter != NULL) gdb_assert (tsv->getter == NULL);
{
fatal ("what to do with these?");
}
} }
if (prev_ptr != 0) if (prev_ptr != 0)
@ -6414,9 +6446,13 @@ upload_fast_traceframes (void)
error ("Uploading: couldn't read traceframe at %s\n", paddress (tf)); error ("Uploading: couldn't read traceframe at %s\n", paddress (tf));
if (ipa_tframe.tpnum == 0) if (ipa_tframe.tpnum == 0)
fatal ("Uploading: No (more) fast traceframes, but " {
"ipa_traceframe_count == %u??\n", internal_error (__FILE__, __LINE__,
ipa_traceframe_write_count - ipa_traceframe_read_count); "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 /* Note that this will be incorrect for multi-location
tracepoints... */ tracepoints... */