This is the mail archive of the mailing list for the GDB project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[rfa] Detect __aeabi_read_tp even without symbols


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?



	* 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
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]