From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25155 invoked by alias); 23 Jan 2012 13:29:37 -0000 Received: (qmail 25145 invoked by uid 22791); 23 Jan 2012 13:29:36 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL,BAYES_00,MSGID_FROM_MTA_HEADER,TW_OV,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from e06smtp15.uk.ibm.com (HELO e06smtp15.uk.ibm.com) (195.75.94.111) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 23 Jan 2012 13:29:22 +0000 Received: from /spool/local by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 23 Jan 2012 13:29:21 -0000 Received: from d06nrmr1806.portsmouth.uk.ibm.com (9.149.39.193) by e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 23 Jan 2012 13:29:19 -0000 Received: from d06av02.portsmouth.uk.ibm.com (d06av02.portsmouth.uk.ibm.com [9.149.37.228]) by d06nrmr1806.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q0NDTIBo2781350 for ; Mon, 23 Jan 2012 13:29:18 GMT Received: from d06av02.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q0NDTILN004361 for ; Mon, 23 Jan 2012 06:29:18 -0700 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with SMTP id q0NDTGAR004332; Mon, 23 Jan 2012 06:29:17 -0700 Message-Id: <201201231329.q0NDTGAR004332@d06av02.portsmouth.uk.ibm.com> Received: by tuxmaker.boeblingen.de.ibm.com (sSMTP sendmail emulation); Mon, 23 Jan 2012 14:29:16 +0100 Subject: Re: ARM EABI Linux, breakpoints cause SIGILL and target dies To: n.sherlock@gmail.com (Nicholas Sherlock) Date: Mon, 23 Jan 2012 13:29:00 -0000 From: "Ulrich Weigand" Cc: gdb@sourceware.org In-Reply-To: from "Nicholas Sherlock" at Jan 23, 2012 02:28:34 PM MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit x-cbid: 12012313-0342-0000-0000-000000B21755 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/msg00067.txt.bz2 Nicholas Sherlock wrote: > So, I patched this line in infrun.c which is supposed to check that > the SIGILL was caused by a breakpoint: > > if (breakpoint_inserted_here_p (get_regcache_aspace (regcache), > regcache_read_pc (regcache))) > > And changed it to: > > if (ecs->ws.value.sig == TARGET_SIGNAL_ILL || > breakpoint_inserted_here_p (get_regcache_aspace (regcache), > regcache_read_pc (regcache))) > > Now the signal is corrected reinterpreted as SIGTRAP: > > Program received signal SIGTRAP, Trace/breakpoint trap. > 0x000081f6 in main () at test.c:4 > 4 printf("Hello, world!\n"); > > But the break address is incorrect, it's halfway through the code for > calling printf: > > 81f4: f24b 60a4 movw r0, #46756 ; 0xb6a4 > 81f8: f2c0 0004 movt r0, #4 > 81fc: f000 fce8 bl 8bd0 <_IO_puts> This is quite odd; it reports a breakpoint in the middle of a Thumb-2 instruction. On ARM, the *kernel* is supposed to adjust the PC so that it points to the start of the breakpoint instructions. If this does not work correctly for some reason, this would explain both why GDB doesn't recognize the situation *and* also why the kernel doesn't recognize the breakpoint instruction to convert the signal into a SIGTRAP. > So now I'm trying to fix the code for adjusting the PC after the trap. GDB is not supposed to do any adjusting on ARM, this is done by the kernel; see e.g. arch/arm/traps.c: asmlinkage void __exception do_undefinstr(struct pt_regs *regs) { unsigned int correction = thumb_mode(regs) ? 2 : 4; unsigned int instr; siginfo_t info; void __user *pc; /* * According to the ARM ARM, PC is 2 or 4 bytes ahead, * depending whether we're in Thumb mode or not. * Correct this offset. */ regs->ARM_pc -= correction; Do you see any differences either here in traps.c, or in one of the entry-*.S assembler files, between your two kernels? Bye, Ulrich -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com