public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [rfa] Detect __aeabi_read_tp even without symbols
@ 2010-10-20  0:02 Ulrich Weigand
  2010-10-26 15:17 ` Daniel Jacobowitz
  2010-10-31 15:49 ` [rfa] " Mark Kettenis
  0 siblings, 2 replies; 7+ messages in thread
From: Ulrich Weigand @ 2010-10-20  0:02 UTC (permalink / raw)
  To: gdb-patches, rearnsha

Hello,

even with the exception unwinder, there are still a couple of extra failures
on ARM when libc symbol information is missing.

One set of failures is related to the skip_prologue_function routine, which
is used to detect helper routines that are called *during* a function prologue,
so that the prologue parser should not stop when encountering a call to one
of these special routines (as opposed to regular function calls).

However, skip_prologue_function works by identifying the routine by *name*.
If no symbol information is present for libc, this may not work.

One case where this problem happens is in calls to __aeabi_read_tp early
in the prologue of certain glibc routines (like abort).  This causes a
number of test case failures.

However, the __aeabi_read_tp implementation in glibc is actually easy to
recognize even in the absence of a function name: its *contents* are just
two ARM instructions, which are hard-coded as assembler in glibc and seem
unlikely to change (they just forward to the kernel-provided code in the
vector page).

The following patch uses this idea to work around the issue.  This fixes
these failures when running without libc symbol info:
FAIL: gdb.base/corefile.exp: print func2::coremaker_local
FAIL: gdb.base/corefile.exp: backtrace in corefile.exp
FAIL: gdb.base/relativedebug.exp: pause found in backtrace

Tested on armv7l-linux-gnueabi with no regressions.

OK for mainline?

Bye,
Ulrich


ChangeLog:

	* arm-tdep.c (thumb_analyze_prologue): Skip in-prologue calls to glibc
	__aeabi_read_tp implementation even if no symbols are available.


Index: gdb/arm-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/arm-tdep.c,v
retrieving revision 1.310
diff -u -p -r1.310 arm-tdep.c
--- gdb/arm-tdep.c	12 Oct 2010 08:46:15 -0000	1.310
+++ gdb/arm-tdep.c	15 Oct 2010 14:11:40 -0000
@@ -822,7 +826,23 @@ thumb_analyze_prologue (struct gdbarch *
 	      if (bit (inst2, 12) == 0)
 		nextpc = nextpc & 0xfffffffc;
 
-	      if (!skip_prologue_function (nextpc))
+	      if (skip_prologue_function (nextpc))
+		;
+	      /* If we run against a stripped glibc, skip_prologue_function
+		 might not have been able to identify the special functions
+		 by name.  Check for one important case, __aeabi_read_tp,
+		 by comparing the *code* against the default implementation
+		 (this is hand-written ARM assembler in glibc, therefore we
+		 need to check for BLX here).  */
+	      else if (bit (inst2, 12) == 0
+		       && read_memory_unsigned_integer (nextpc, 4,
+							byte_order_for_code)
+			   == 0xe3e00a0f /* mov r0, #0xffff0fff */
+		       && read_memory_unsigned_integer (nextpc + 4, 4,
+							byte_order_for_code)
+			   == 0xe240f01f) /* sub pc, r0, #31 */
+		;
+	      else
 		break;
 	    }
 
-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-02-02 19:50 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-20  0:02 [rfa] Detect __aeabi_read_tp even without symbols Ulrich Weigand
2010-10-26 15:17 ` Daniel Jacobowitz
2010-12-01 16:05   ` [rfa v2] " Ulrich Weigand
2010-12-06 21:50     ` Daniel Jacobowitz
2011-01-11 17:59       ` [ping] " Ulrich Weigand
2011-02-02 19:50     ` Ulrich Weigand
2010-10-31 15:49 ` [rfa] " Mark Kettenis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).