From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5810 invoked by alias); 2 Mar 2006 22:14:52 -0000 Received: (qmail 5801 invoked by uid 22791); 2 Mar 2006 22:14:50 -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; Thu, 02 Mar 2006 22:14:49 +0000 Received: from drow by nevyn.them.org with local (Exim 4.54) id 1FEw4M-0005S2-6k; Thu, 02 Mar 2006 17:14:46 -0500 Date: Thu, 02 Mar 2006 22:23:00 -0000 From: Daniel Jacobowitz To: Richard Earnshaw , gdb-patches@sourceware.org, Shaun Jackman Subject: Re: RFC: Use the ARM CPSR as a fallback to determine ARM/Thumb Message-ID: <20060302221446.GA18830@nevyn.them.org> Mail-Followup-To: Richard Earnshaw , gdb-patches@sourceware.org, Shaun Jackman References: <20060220214918.GA28798@nevyn.them.org> <1140519913.27380.29.camel@pc960.cambridge.arm.com> <20060221153601.GA21183@nevyn.them.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20060221153601.GA21183@nevyn.them.org> 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-03/txt/msg00057.txt.bz2 On Tue, Feb 21, 2006 at 10:36:01AM -0500, Daniel Jacobowitz wrote: > What I had in mind for this was: > > set arm fallback-mode [arm|thumb|auto] > > That is, continue to honor symbol information, but change the fallback > when we don't have symbols to arm, thumb, or current cpsr. > > And maybe augment that with: > > set arm force-mode [arm|thumb|auto] > > This would also override symbol information. > > This is basically the same as your first option, but spread out over > two variables. How does that sound? Something like the attached; look OK? For correctness this needs the massive remove_breakpoint patch I'm posting next. -- Daniel Jacobowitz CodeSourcery 2006-03-02 Daniel Jacobowitz * arm-tdep.c (arm_mode_strings, arm_fallback_mode_string) (arm_force_mode_string, arm_show_fallback_mode) (arm_show_force_mode): New. (arm_pc_is_thumb): Honor fallback-mode and force-mode. Fall back to the CPSR. (_initialize_arm_tdep): Add "set arm fallback-mode" and "set arm force-mode". 2006-03-02 Daniel Jacobowitz * gdb.texinfo (ARM): Document set/show arm fallback-mode and set/show arm force-mode. Index: src/gdb/arm-tdep.c =================================================================== --- src.orig/gdb/arm-tdep.c 2006-03-02 15:58:19.000000000 -0500 +++ src/gdb/arm-tdep.c 2006-03-02 17:13:17.000000000 -0500 @@ -99,6 +99,17 @@ static const char *arm_abi_strings[] = static enum arm_abi_kind arm_abi_global = ARM_ABI_AUTO; static const char *arm_abi_string = "auto"; +/* The execution mode to assume. */ +static const char *arm_mode_strings[] = + { + "auto", + "arm", + "thumb" + }; + +static const char *arm_fallback_mode_string = "auto"; +static const char *arm_force_mode_string = "auto"; + /* Number of different reg name sets (options). */ static int num_disassembly_options; @@ -181,16 +192,30 @@ arm_pc_is_thumb (CORE_ADDR memaddr) if (IS_THUMB_ADDR (memaddr)) return 1; + /* If the user wants to override the symbol table, let him. */ + if (strcmp (arm_force_mode_string, "arm") == 0) + return 0; + if (strcmp (arm_force_mode_string, "thumb") == 0) + return 1; + /* 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 the user wants to override the fallback mode, let them. */ + if (strcmp (arm_fallback_mode_string, "arm") == 0) + return 0; + if (strcmp (arm_fallback_mode_string, "thumb") == 0) + return 1; + + /* 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. */ @@ -2458,6 +2483,28 @@ The current ARM ABI is \"auto\" (current arm_abi_string); } +static void +arm_show_fallback_mode (struct ui_file *file, int from_tty, + struct cmd_list_element *c, const char *value) +{ + struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); + + fprintf_filtered (file, _("\ +The current execution mode assumed (when symbols are unavailable) is \"%s\".\n"), + arm_fallback_mode_string); +} + +static void +arm_show_force_mode (struct ui_file *file, int from_tty, + struct cmd_list_element *c, const char *value) +{ + struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); + + fprintf_filtered (file, _("\ +The current execution mode assumed (even when symbols are available) is \"%s\".\n"), + arm_force_mode_string); +} + /* If the user changes the register disassembly style used for info register and other commands, we have to also switch the style used in opcodes for disassembly output. This function is run in the "set @@ -2970,6 +3017,21 @@ vfp - VFP co-processor."), NULL, arm_set_abi, arm_show_abi, &setarmcmdlist, &showarmcmdlist); + /* Add two commands to allow the user to force the assumed + execution mode. */ + add_setshow_enum_cmd ("fallback-mode", class_support, + arm_mode_strings, &arm_fallback_mode_string, + _("Set the mode assumed when symbols are unavailable."), + _("Show the mode assumed when symbols are unavailable."), + NULL, NULL, arm_show_fallback_mode, + &setarmcmdlist, &showarmcmdlist); + add_setshow_enum_cmd ("force-mode", class_support, + arm_mode_strings, &arm_force_mode_string, + _("Set the mode assumed even when symbols are available."), + _("Show the mode assumed even when symbols are available."), + NULL, NULL, arm_show_force_mode, + &setarmcmdlist, &showarmcmdlist); + /* Debugging flag. */ add_setshow_boolean_cmd ("arm", class_maintenance, &arm_debug, _("Set ARM debugging."), Index: src/gdb/doc/gdb.texinfo =================================================================== --- src.orig/gdb/doc/gdb.texinfo 2006-02-22 15:02:33.000000000 -0500 +++ src/gdb/doc/gdb.texinfo 2006-03-02 17:11:02.000000000 -0500 @@ -14010,6 +14010,24 @@ This command forces @value{GDBN} to use @item show arm abi Show the currently used ABI. +@item set arm fallback-mode +This command sets the mode (ARM versus Thumb) which @value{GDBN} will +assume for code without a symbol table. The default is @samp{auto}, +which causes @value{GDBN} to use the mode associated with the current +CPSR. + +@item show arm fallback-mode +Show the current fallback execution mode. + +@item set arm force-mode +This command sets the mode (ARM versus Thumb) which @value{GDBN} will +assume for all code, even when a symbol table is present. The default +is @samp{auto}, which causes @value{GDBN} to use the symbol table +and fall back to the value of @samp{set arm fallback-mode}. + +@item show arm force-mode +Show the currently forced execution mode. + @item set debug arm Toggle whether to display ARM-specific debugging messages from the ARM target support subsystem.