This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[rfc] Fix a corner case on sparc software single-step
- From: Daniel Jacobowitz <drow at false dot org>
- To: gdb-patches at sources dot redhat dot com
- Date: Sat, 13 Nov 2004 17:57:04 -0500
- Subject: [rfc] Fix a corner case on sparc software single-step
A Debian user noticed that GDB has an internal error when stepping over a
call to a NULL function pointer. The problem was some code in sparc-tdep.c
which uses 0 to mean "don't insert a breakpoint". This patch handles only
the 0 case specially, by not inserting any breakpoint and trusting to
receive a fault when we reach 0; this code would need a larger rewrite to
handle an OS where code can validly live at address zero.
Comments? Otherwise, I'll plan to commit this in a couple of days.
--
Daniel Jacobowitz
2004-11-13 Daniel Jacobowitz <dan@debian.org>
* sparc-tdep.c (sparc_software_single_step): Handle stepping to NULL.
Index: gdb-6.3/gdb/sparc-tdep.c
===================================================================
--- gdb-6.3.orig/gdb/sparc-tdep.c 2004-06-06 22:02:55.000000000 -0400
+++ gdb-6.3/gdb/sparc-tdep.c 2004-11-13 17:06:05.000000000 -0500
@@ -1026,10 +1026,10 @@
if (insert_breakpoints_p)
{
- CORE_ADDR pc;
+ CORE_ADDR pc, orig_npc;
pc = sparc_address_from_register (tdep->pc_regnum);
- npc = sparc_address_from_register (tdep->npc_regnum);
+ orig_npc = npc = sparc_address_from_register (tdep->npc_regnum);
/* Analyze the instruction at PC. */
nnpc = sparc_analyze_control_transfer (pc, &npc);
@@ -1039,9 +1039,10 @@
target_insert_breakpoint (nnpc, nnpc_save);
/* Assert that we have set at least one breakpoint, and that
- they're not set at the same spot. */
- gdb_assert (npc != 0 || nnpc != 0);
- gdb_assert (nnpc != npc);
+ they're not set at the same spot - unless we're going
+ from here straight to NULL, i.e. a call or jump to 0. */
+ gdb_assert (npc != 0 || nnpc != 0 || orig_npc == 0);
+ gdb_assert (nnpc != npc || orig_npc == 0);
}
else
{