From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17175 invoked by alias); 20 Jan 2012 02:45:48 -0000 Received: (qmail 17162 invoked by uid 22791); 20 Jan 2012 02:45:46 -0000 X-SWARE-Spam-Status: No, hits=1.4 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,TW_BJ,TW_CX,TW_DC,TW_FP,TW_GX,TW_JL,TW_SW,TW_VF X-Spam-Check-By: sourceware.org Received: from mail-qy0-f169.google.com (HELO mail-qy0-f169.google.com) (209.85.216.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 20 Jan 2012 02:45:33 +0000 Received: by qcsf14 with SMTP id f14so65734qcs.0 for ; Thu, 19 Jan 2012 18:45:32 -0800 (PST) Received: by 10.229.76.149 with SMTP id c21mr10416223qck.5.1327027532242; Thu, 19 Jan 2012 18:45:32 -0800 (PST) MIME-Version: 1.0 Received: by 10.229.100.14 with HTTP; Thu, 19 Jan 2012 18:45:11 -0800 (PST) In-Reply-To: References: From: Nicholas Sherlock Date: Fri, 20 Jan 2012 02:45:00 -0000 Message-ID: Subject: ARM EABI Linux, breakpoints cause SIGILL and target dies To: gdb@sourceware.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2012-01/txt/msg00062.txt.bz2 Hey all, I have Ubuntu's userspace code running inside a chroot on top of Android's Linux kernel on my phone. Using this, I've built GDB 7.3 from Ubuntu's source package. Here's the system details: # uname -a Linux localhost 2.6.35.13 #4 PREEMPT Wed Jan 18 20:25:06 PST 2012 armv7l armv7l armv7l GNU/Linux # cat /proc/cpuinfo Processor =C2=A0 =C2=A0 =C2=A0 : ARMv7 Processor rev 2 (v7l) BogoMIPS =C2=A0 =C2=A0 =C2=A0 =C2=A0: 163.57 Features =C2=A0 =C2=A0 =C2=A0 =C2=A0: swp half thumb fastmult vfp edsp thum= bee neon vfpv3 CPU implementer : 0x51 CPU architecture: 7 CPU variant =C2=A0 =C2=A0 : 0x1 CPU part =C2=A0 =C2=A0 =C2=A0 =C2=A0: 0x00f CPU revision =C2=A0 =C2=A0: 2 Hardware =C2=A0 =C2=A0 =C2=A0 =C2=A0: runnymede Revision =C2=A0 =C2=A0 =C2=A0 =C2=A0: 0002 EngineerID =C2=A0 =C2=A0 =C2=A0: 0001 Serial =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0: 0000000000000000 Here's my source file test.c: #include int main(void) { =C2=A0 printf("Hello, world!\n"); =C2=A0 printf("Goodbye, world!\n"); =C2=A0 return 0; } I'm building it on my target with this GCC: # gcc -v Using built-in specs. COLLECT_GCC=3Dgcc COLLECT_LTO_WRAPPER=3D/usr/lib/arm-linux-gnueabi/gcc/arm-linux-gnueabi/4.5.= 2/lto-wrapper Target: arm-linux-gnueabi Configured with: ../src/configure -v --with-pkgversion=3D'Ubuntu/Linaro 4.5.2-8ubuntu4' --with-bugurl=3Dfile:///usr/share/doc/gcc-4.5/README.Bugs --enable-languages=3Dc,c++,fortran,objc,obj-c++ --prefix=3D/usr --program-suffix=3D-4.5 --enable-shared --enable-multiarch --with-multiarch-defaults=3Darm-linux-gnueabi --enable-linker-build-id --with-system-zlib --libexecdir=3D/usr/lib/arm-linux-gnueabi --without-included-gettext --enable-threads=3Dposix --with-gxx-include-dir=3D/usr/include/c++/4.5 --libdir=3D/usr/lib/arm-linux-gnueabi --enable-nls --with-sysroot=3D/ --enable-clocale=3Dgnu --enable-libstdcxx-debug --enable-libstdcxx-time=3Dyes --enable-plugin --enable-gold --enable-ld=3Ddefault --with-plugin-ld=3Dld.gold --enable-objc-gc --disable-sjlj-exceptions --with-arch=3Darmv7-a --with-float=3Dsoftfp --with-fpu=3Dvfpv3-d16 --with-mode=3Dthumb --disable-werror --enable-checking=3Drelease --build=3Darm-linux-gnueabi --host=3Darm-linux-gnueabi --target=3Darm-linux-gnueabi Thread model: posix gcc version 4.5.2 (Ubuntu/Linaro 4.5.2-8ubuntu4) And this command line: gcc -g3 -static -o a.out test.c Running a.out alone or with GDB works fine, but any operation that causes GDB to set a breakpoint results in the target being killed by SIGILL: # gdb a.out GNU gdb (Ubuntu/Linaro 7.3.1-2011.12-0ubuntu2) 7.3-2011.12 Copyright (C) 2011 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. =C2=A0Type "show copy= ing" and "show warranty" for details. This GDB was configured as "arm-linux-gnueabi". For bug reporting instructions, please see: ... Reading symbols from /root/a.out...done. (gdb) run Starting program: /root/a.out Hello, world! Goodbye, world! [Inferior 1 (process 14296) exited normally] (gdb) start Temporary breakpoint 1 at 0x81f4: file test.c, line 4. Starting program: /root/a.out Program received signal SIGILL, Illegal instruction. 0x000081f6 in main () at test.c:4 4 =C2=A0 =C2=A0 =C2=A0 =C2=A0 printf("Hello, world!\n"); (gdb) next Program terminated with signal SIGILL, Illegal instruction. The program no longer exists. I noticed that this patch was supposed to add support for SIGILL breakpoint= s: http://old.nabble.com/RFC%3A-Updates-support-for-breakpoints-that-generate-= SIGILL-p27363713.html And the target-specific code says that it tries to generate a SIGILL (arm-linux-tdep.c): /* However, the EABI syscall interface (new in Nov. 2005) does not look at =C2=A0 =C2=A0the operand of the swi if old-ABI compatibility is disabled. = =C2=A0Therefore, =C2=A0 =C2=A0use an undefined instruction instead. =C2=A0This is supported = as of kernel =C2=A0 =C2=A0version 2.5.70 (May 2003), so should be a safe assumption for = EABI =C2=A0 =C2=A0binaries. =C2=A0*/ So I would expect that this would work. Another piece of the puzzle, I have a different phone here running a different Linux kernel, but the same Ubuntu usermode binaries, where GDB breakpoints work perfectly: $ uname -a Linux localhost 2.6.37.6-cyanogenmod-01509-g8913be8 #1 PREEMPT Wed Jul 27 21:31:24 EDT 2011 armv7l GNU/Linux $ cat /proc/cpuinfo Processor=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 : ARMv7 Processor rev 2 (v7l) BogoMIPS: 662.40 Features: swp half thumb fastmult vfp edsp thumbee neon CPU implementer : 0x51 CPU architecture: 7 CPU variant=C2=A0=C2=A0=C2=A0=C2=A0 : 0x0 CPU part: 0x00f CPU revision=C2=A0=C2=A0=C2=A0 : 2 Hardware: mahimahi Revision: 0081 Serial=C2=A0 : 0000000000000000 How do I begin to debug this problem? I have the source code available for both kernels if there is something to investigate there. Thanks, Nicholas Sherlock