From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4423 invoked by alias); 20 Feb 2006 21:49:22 -0000 Received: (qmail 4398 invoked by uid 22791); 20 Feb 2006 21:49:22 -0000 X-Spam-Check-By: sourceware.org Received: from nevyn.them.org (HELO nevyn.them.org) (66.93.172.17) by sourceware.org (qpsmtpd/0.31.1) with ESMTP; Mon, 20 Feb 2006 21:49:21 +0000 Received: from drow by nevyn.them.org with local (Exim 4.54) id 1FBIuE-0007bb-Cf; Mon, 20 Feb 2006 16:49:18 -0500 Date: Mon, 20 Feb 2006 22:03:00 -0000 From: Daniel Jacobowitz To: gdb-patches@sourceware.org Cc: Richard Earnshaw , Shaun Jackman Subject: RFC: Use the ARM CPSR as a fallback to determine ARM/Thumb Message-ID: <20060220214918.GA28798@nevyn.them.org> Mail-Followup-To: gdb-patches@sourceware.org, Richard Earnshaw , Shaun Jackman Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.8i X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2006-02/txt/msg00387.txt.bz2 I'm fishing for comments on this change. In arm_pc_is_thumb, if we can not find a symbol covering the supplied PC, we assume ARM mode; it seems that it would be strictly more useful to assume the current mode. This patch _should not be used_ as is! Paul Brook cleverly noticed that this will mess up breakpoint_from_pc when removing breakpoints, causing us to insert 2-byte breakpoints and remove 4-byte ones across a mode switch. I'm going to have to mess with the target_remove_breakpoint interface to fix that, so I wanted to get opinions on this patch first before I dig in. This is still a somewhat creepy thing to do. You can find quotes of me in the gdb@ list archives saying that this is "the way to madness". However, I've been debugging some code which jumps to Thumb-mode routines in ROM today, and my GDB doesn't yet have symbol information for the ROM code; so I'm well down the way to madness without this patch, and it's somewhat better with. Maybe there should be a "set" option for the default when no symbol is found, allowing the user to throttle this back to ARM-only if that works better for them? -- Daniel Jacobowitz CodeSourcery 2006-02-20 Daniel Jacobowitz * arm-tdep.c (arm_pc_is_thumb): Fall back to the CPSR. NOTE: NOT FOR COMMIT Index: src/gdb/arm-tdep.c =================================================================== --- src.orig/gdb/arm-tdep.c 2006-02-02 15:38:35.000000000 -0500 +++ src/gdb/arm-tdep.c 2006-02-20 16:11:02.000000000 -0500 @@ -184,13 +184,15 @@ arm_pc_is_thumb (CORE_ADDR memaddr) /* Thumb functions have a "special" bit set in minimal symbols. */ sym = lookup_minimal_symbol_by_pc (memaddr); if (sym) - { - return (MSYMBOL_IS_SPECIAL (sym)); - } - else - { - return 0; - } + return (MSYMBOL_IS_SPECIAL (sym)); + + /* If we couldn't find any symbol, but we're talking to a running + target, then trust the current value of $cpsr. */ + if (target_has_registers) + return (read_register (ARM_PS_REGNUM) & 0x20) != 0; + + /* Otherwise we're out of luck; we assume ARM. */ + return 0; } /* Remove useless bits from addresses in a running program. */