From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5200 invoked by alias); 25 Jan 2017 17:20:22 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 5176 invoked by uid 89); 25 Jan 2017 17:20:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=2.5 required=5.0 tests=AWL,BAYES_50,KAM_ASCII_DIVIDERS,RCVD_IN_DNSWL_LOW,SPF_PASS,UNSUBSCRIBE_BODY autolearn=no version=3.3.2 spammy=1700, 3340, 4700, 5100 X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0a-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.156.1) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 25 Jan 2017 17:19:50 +0000 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v0PHJDtl111139 for ; Wed, 25 Jan 2017 12:19:49 -0500 Received: from e36.co.us.ibm.com (e36.co.us.ibm.com [32.97.110.154]) by mx0a-001b2d01.pphosted.com with ESMTP id 286xtsm6w4-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 25 Jan 2017 12:19:45 -0500 Received: from localhost by e36.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 25 Jan 2017 10:19:44 -0700 Received: from d03dlp02.boulder.ibm.com (9.17.202.178) by e36.co.us.ibm.com (192.168.1.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 25 Jan 2017 10:19:38 -0700 Received: from b03cxnp08027.gho.boulder.ibm.com (b03cxnp08027.gho.boulder.ibm.com [9.17.130.19]) by d03dlp02.boulder.ibm.com (Postfix) with ESMTP id 1AB6A3E40067; Wed, 25 Jan 2017 10:19:38 -0700 (MST) Received: from b03ledav001.gho.boulder.ibm.com (b03ledav001.gho.boulder.ibm.com [9.17.130.232]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v0PHJbU69634110; Wed, 25 Jan 2017 10:19:37 -0700 Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E1F796E03A; Wed, 25 Jan 2017 10:19:37 -0700 (MST) Received: from otta.local (unknown [9.85.180.3]) by b03ledav001.gho.boulder.ibm.com (Postfix) with ESMTP id 1A1BF6E04E; Wed, 25 Jan 2017 10:19:35 -0700 (MST) Subject: Re: [PATCH 1/2] Add support for setting disassembler-options in GDB for POWER, ARM and S390 To: Alan Modra References: <83eg28dcjk.fsf@gnu.org> <019eaf5d-9ace-539e-8501-feb3cb0eed6c@vnet.ibm.com> <20170124015651.GH28669@bubble.grove.modra.org> <20170124033625.GI28669@bubble.grove.modra.org> <6962ef25-9722-f0f0-d0a2-209b10761311@vnet.ibm.com> <20170125043122.GL28669@bubble.grove.modra.org> Cc: Pedro Alves , Eli Zaretskii , nickc@redhat.com, gdb-patches@sourceware.org, uweigand@de.ibm.com, binutils@sourceware.org, Yao Qi From: Peter Bergner Date: Wed, 25 Jan 2017 17:20:00 -0000 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 MIME-Version: 1.0 In-Reply-To: <20170125043122.GL28669@bubble.grove.modra.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 17012517-0020-0000-0000-00000B2E043F X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00006496; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000200; SDB=6.00812569; UDB=6.00396298; IPR=6.00589988; BA=6.00005090; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00014044; XFM=3.00000011; UTC=2017-01-25 17:19:44 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17012517-0021-0000-0000-0000598610A4 Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-01-25_11:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=2 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1612050000 definitions=main-1701250164 X-IsSubscribed: yes X-SW-Source: 2017-01/txt/msg00543.txt.bz2 On 1/24/17 10:31 PM, Alan Modra wrote: > You're going to hate me, but this still doesn't keep the language > translations. If you regenerate opcodes/po/opcodes.pot you'll see > that lines like > > msgid " esa Disassemble in ESA architecture mode\n" > > have disappeared without being replaced by anything. I think you need > to wrap your new options[].description with N_() to let gettext know > they should be translated, like this: > > static const options_t options[] = > { > { "esa" , N_("Disassemble in ESA architecture mode") }, > { "zarch", N_("Disassemble in z/Architecture mode") }, > { "insnlength", N_("Print unknown instructions according to " > "length from first two bits") } > }; Done and opcodes/po/opcodes.pot regenerated and looking at the updated file, the strings are there. > The same thing needs to be done for regnames description in arm-dis.c. > > I also see this arm-dis.c hunk >> @@ -6855,7 +6889,7 @@ the -M switch:\n")); >> fprintf (stream, " reg-names-%s %*c%s\n", >> regnames[i].name, >> (int)(14 - strlen (regnames[i].name)), ' ', >> - regnames[i].description); >> + _(regnames[i].description)); >> >> fprintf (stream, " force-thumb Assume all insns are Thumb insns\n"); >> fprintf (stream, " no-force-thumb Examine preceding label to determine an insn's type\n\n"); > > showing missing _() for the last two lines. Bonus points for fixing > them in a way that uses exactly the same translatated strings as you > have in disassembler_options_desc_arm. Well those strings were never translated before my patch, so this is new support for arm-dis.c. That said, here is an updated patch that adds the translations along with your suggestion for using the same translated strings. This patch also fixes the gdb.texinfo issue Yao Qi found. Here is the updated patch. Peter include/ * dis-asm.h (parse_arm_disassembler_option): Remove prototype. (set_arm_regname_option): Likewise. (disassemble_init_s390): New prototype. (disassembler_options_names_powerpc): Likewise. (disassembler_options_names_arm): Likewise. (disassembler_options_desc_arm): Likewise. (disassembler_options_names_s390): Likewise. (disassembler_options_desc_s390): Likewise. opcodes/ * disassemble.c (disassemble_init_for_target): Handle s390 init. * ppc-dis.c: Include "libiberty.h". (ppc_opts): Add "32" and "64" entries. (parse_ppc_dis_option): New function. (disassembler_options_names_powerpc): Likewise. (powerpc_init_dialect): Use parse_ppc_dis_option(). Add break to switch statement. (print_ppc_disassembler_options): Remove printing of "32" and "64". * arm-dis.c: Include "libiberty.h". (struct arm_regname): Add 'long_name' field. (regnames): Initialize it. (set_arm_regname_option): Remove function. (parse_arm_disassembler_option): Make static. (disassembler_options_names_arm): New function. (disassembler_options_desc_arm): Likewise. (print_arm_disassembler_options): Use disassembler_options_names_arm() and disassembler_options_desc_arm(). * s390-dis.c: Include "libiberty.h". (struct options_t): New structure type. (options): New structure. (init_disasm): Rename from this... (disassemble_init_s390): ...to this. Add initializations for current_arch_mask and option_use_insn_len_bits_p. Remove init_flag. (disassembler_options_names_s390): New function. (disassembler_options_desc_s390): Likewise. (print_s390_disassembler_options): Print using information from struct 'options'. * po/opcodes.pot: Regenerate. gdb/ * NEWS: Mention new set/show disassembler-options commands. * doc/gdb.texinfo: Document new set/show disassembler-options commands. * gdbarch.sh (gdbarch_disassembler_options): New variable. (gdbarch_disassembler_options_names): Likewise. (gdbarch_disassembler_options_descriptions): Likewise. * gdbarch.c: Regenerate. * gdbarch.h: Likewise. * disasm.c: Include "arch-utils.h", "gdbcmd.h", "gdbcmd.h" and "safe-ctype.h". (gdb_disassemble_info): Initilize di.disassembler_options. (gdb_buffered_insn_length_init_dis): Initilize di->application_data and di->disassembler_options. (cleanup_disassembler_options): New function. (parse_disassembler_options): Likewise. (set_disassembler_options): Likewise. (show_disassembler_options): Likewise. (disassembler_options_completer): Likewise. (_initialize_disasm): Likewise. * disasm.h (set_disassembler_options): New prototype. (show_disassembler_options): Likewise. * rs6000-tdep.c (rs6000_gdbarch_init): Call set_gdbarch_disassembler_options_names. * arm-tdep.c: Include "disasm.h" and "cli/cli-decode.h". (disassembly_style): Delete static variable. (set_disassembly_style): Delete function and prototype. (show_disassembly_style_sfunc): New function. (set_disassembly_style_sfunc): Call set_disassembler_options. (arm_gdbarch_init): Call set_gdbarch_disassembler_options, set_gdbarch_disassembler_options_names and set_gdbarch_disassembler_options_descriptions. (_initialize_arm_tdep): New static variable 'disassembly_style'; Remove calls to parse_arm_disassembler_option & set_arm_regname_option. Pass show_disassembly_style_sfunc to the "disassembler" setshow command. * s390-tdep.c (s390_gdbarch_init): Call functions set_gdbarch_disassembler_options_names and set_gdbarch_disassembler_options_descriptions. gdb/testsuite/ * gdb.disasm/disassembler-options.exp: New test. * gdb.arch/powerpc-altivec.exp: Likewise. * gdb.arch/powerpc-altivec.s: Likewise. * gdb.arch/powerpc-altivec2.exp: Likewise. * gdb.arch/powerpc-altivec2.s: Likewise. * gdb.arch/powerpc-altivec3.exp: Likewise. * gdb.arch/powerpc-altivec3.s: Likewise. * gdb.arch/powerpc-power7.exp: Likewise. * gdb.arch/powerpc-power7.s: Likewise. * gdb.arch/powerpc-power8.exp: Likewise. * gdb.arch/powerpc-power8.s: Likewise. * gdb.arch/powerpc-power9.exp: Likewise. * gdb.arch/powerpc-power9.s: Likewise. * gdb.arch/powerpc-vsx.exp: Likewise. * gdb.arch/powerpc-vsx.s: Likewise. * gdb.arch/powerpc-vsx2.exp: Likewise. * gdb.arch/powerpc-vsx2.s: Likewise. * gdb.arch/powerpc-vsx3.exp: Likewise. * gdb.arch/powerpc-vsx3.s: Likewise. * gdb.arch/powerpc-power.exp: Delete test. * gdb.arch/powerpc-power.s: Likewise. diff --git a/gdb/NEWS b/gdb/NEWS index 21e8cd3..cac639e 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -68,6 +68,16 @@ flash-erase Erases all the flash memory regions reported by the target. This is equivalent to the CLI command flash-erase. +* New commands + +set disassembler-options +show disassembler-options + Controls the passing of target specific information to the disassembler. + If it is necessary to specify more than one disassembler option then + multiple options can be placed together into a comma separated list. + Default is ''. Currently, the only supported targets are ARM, PowerPC + and S/390. + *** Changes in GDB 7.12 * GDB and GDBserver now build with a C++ compiler by default. diff --git a/gdb/aclocal.m4 b/gdb/aclocal.m4 index 68a98d1..678310c 100644 --- a/gdb/aclocal.m4 +++ b/gdb/aclocal.m4 @@ -1,7 +1,7 @@ -# generated automatically by aclocal 1.11.1 -*- Autoconf -*- +# generated automatically by aclocal 1.14.1 -*- Autoconf -*- + +# Copyright (C) 1996-2013 Free Software Foundation, Inc. -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, -# 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -11,17 +11,18 @@ # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. +m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- -# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. +# Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets -# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to -# `$srcdir', `$srcdir/..', or `$srcdir/../..'. +# $ac_aux_dir to '$srcdir/foo'. In other projects, it is set to +# '$srcdir', '$srcdir/..', or '$srcdir/../..'. # # Of course, Automake must honor this variable whenever it calls a # tool from the auxiliary directory. The problem is that $srcdir (and @@ -40,7 +41,7 @@ # # The reason of the latter failure is that $top_srcdir and $ac_aux_dir # are both prefixed by $srcdir. In an in-source build this is usually -# harmless because $srcdir is `.', but things will broke when you +# harmless because $srcdir is '.', but things will broke when you # start a VPATH build or use an absolute $srcdir. # # So we could use something similar to $top_srcdir/$ac_aux_dir/missing, @@ -66,22 +67,19 @@ am_aux_dir=`cd $ac_aux_dir && pwd` # AM_CONDITIONAL -*- Autoconf -*- -# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008 -# Free Software Foundation, Inc. +# Copyright (C) 1997-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 9 - # AM_CONDITIONAL(NAME, SHELL-CONDITION) # ------------------------------------- # Define a conditional. AC_DEFUN([AM_CONDITIONAL], -[AC_PREREQ(2.52)dnl - ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], - [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl +[AC_PREREQ([2.52])dnl + m4_if([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], + [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl AC_SUBST([$1_TRUE])dnl AC_SUBST([$1_FALSE])dnl _AM_SUBST_NOTMAKE([$1_TRUE])dnl @@ -100,7 +98,7 @@ AC_CONFIG_COMMANDS_PRE( Usually this means the macro was only invoked conditionally.]]) fi])]) -# Copyright (C) 2001, 2003, 2005, 2008 Free Software Foundation, Inc. +# Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -119,25 +117,22 @@ if test x"${install_sh}" != xset; then install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi -AC_SUBST(install_sh)]) +AC_SUBST([install_sh])]) # Add --enable-maintainer-mode option to configure. -*- Autoconf -*- # From Jim Meyering -# Copyright (C) 1996, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2008 -# Free Software Foundation, Inc. +# Copyright (C) 1996-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 5 - # AM_MAINTAINER_MODE([DEFAULT-MODE]) # ---------------------------------- # Control maintainer-specific portions of Makefiles. -# Default is to disable them, unless `enable' is passed literally. -# For symmetry, `disable' may be passed as well. Anyway, the user +# Default is to disable them, unless 'enable' is passed literally. +# For symmetry, 'disable' may be passed as well. Anyway, the user # can override the default with the --enable/--disable switch. AC_DEFUN([AM_MAINTAINER_MODE], [m4_case(m4_default([$1], [disable]), @@ -145,13 +140,14 @@ AC_DEFUN([AM_MAINTAINER_MODE], [disable], [m4_define([am_maintainer_other], [enable])], [m4_define([am_maintainer_other], [enable]) m4_warn([syntax], [unexpected argument to AM@&t@_MAINTAINER_MODE: $1])]) -AC_MSG_CHECKING([whether to am_maintainer_other maintainer-specific portions of Makefiles]) +AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles]) dnl maintainer-mode's default is 'disable' unless 'enable' is passed AC_ARG_ENABLE([maintainer-mode], -[ --][am_maintainer_other][-maintainer-mode am_maintainer_other make rules and dependencies not useful - (and sometimes confusing) to the casual installer], - [USE_MAINTAINER_MODE=$enableval], - [USE_MAINTAINER_MODE=]m4_if(am_maintainer_other, [enable], [no], [yes])) + [AS_HELP_STRING([--]am_maintainer_other[-maintainer-mode], + am_maintainer_other[ make rules and dependencies not useful + (and sometimes confusing) to the casual installer])], + [USE_MAINTAINER_MODE=$enableval], + [USE_MAINTAINER_MODE=]m4_if(am_maintainer_other, [enable], [no], [yes])) AC_MSG_RESULT([$USE_MAINTAINER_MODE]) AM_CONDITIONAL([MAINTAINER_MODE], [test $USE_MAINTAINER_MODE = yes]) MAINT=$MAINTAINER_MODE_TRUE @@ -159,9 +155,7 @@ AC_MSG_CHECKING([whether to am_maintainer_other maintainer-specific portions of ] ) -AU_DEFUN([jm_MAINTAINER_MODE], [AM_MAINTAINER_MODE]) - -# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. +# Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -169,34 +163,32 @@ AU_DEFUN([jm_MAINTAINER_MODE], [AM_MAINTAINER_MODE]) # AM_PROG_INSTALL_STRIP # --------------------- -# One issue with vendor `install' (even GNU) is that you can't +# One issue with vendor 'install' (even GNU) is that you can't # specify the program used to strip binaries. This is especially # annoying in cross-compiling environments, where the build's strip # is unlikely to handle the host's binaries. # Fortunately install-sh will honor a STRIPPROG variable, so we -# always use install-sh in `make install-strip', and initialize +# always use install-sh in "make install-strip", and initialize # STRIPPROG with the value of the STRIP variable (set by the user). AC_DEFUN([AM_PROG_INSTALL_STRIP], [AC_REQUIRE([AM_PROG_INSTALL_SH])dnl -# Installed binaries are usually stripped using `strip' when the user -# run `make install-strip'. However `strip' might not be the right +# Installed binaries are usually stripped using 'strip' when the user +# run "make install-strip". However 'strip' might not be the right # tool to use in cross-compilation environments, therefore Automake -# will honor the `STRIP' environment variable to overrule this program. -dnl Don't test for $cross_compiling = yes, because it might be `maybe'. +# will honor the 'STRIP' environment variable to overrule this program. +dnl Don't test for $cross_compiling = yes, because it might be 'maybe'. if test "$cross_compiling" != no; then AC_CHECK_TOOL([STRIP], [strip], :) fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) -# Copyright (C) 2006, 2008 Free Software Foundation, Inc. +# Copyright (C) 2006-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 2 - # _AM_SUBST_NOTMAKE(VARIABLE) # --------------------------- # Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. @@ -204,7 +196,7 @@ AC_SUBST([INSTALL_STRIP_PROGRAM])]) AC_DEFUN([_AM_SUBST_NOTMAKE]) # AM_SUBST_NOTMAKE(VARIABLE) -# --------------------------- +# -------------------------- # Public sister of _AM_SUBST_NOTMAKE. AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index 2bdfa57..bd6fa72 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -27,6 +27,8 @@ #include "gdbcmd.h" #include "gdbcore.h" #include "dis-asm.h" /* For register styles. */ +#include "disasm.h" +#include "cli/cli-decode.h" #include "regcache.h" #include "reggroups.h" #include "doublest.h" @@ -210,14 +212,13 @@ static const char *const arm_register_names[] = /* Valid register name styles. */ static const char **valid_disassembly_styles; -/* Disassembly style to use. Default to "std" register names. */ -static const char *disassembly_style; - /* This is used to keep the bfd arch_info in sync with the disassembly style. */ static void set_disassembly_style_sfunc(char *, int, struct cmd_list_element *); -static void set_disassembly_style (void); +static void show_disassembly_style_sfunc (struct ui_file *, int, + struct cmd_list_element *, + const char *); static void convert_from_extended (const struct floatformat *, const void *, void *, int); @@ -8536,9 +8537,27 @@ arm_show_force_mode (struct ui_file *file, int from_tty, static void set_disassembly_style_sfunc (char *args, int from_tty, - struct cmd_list_element *c) + struct cmd_list_element *c) +{ + /* Convert the short style name into the long style name (eg, reg-names-*) + before calling the generic set_disassembler_options() function. */ + char long_name[256], *style = long_name; + snprintf (style, 256, "reg-names-%s", *(char **)c->var); + c->var = &style; + set_disassembler_options (args, from_tty, c); +} + +static void +show_disassembly_style_sfunc (struct ui_file *file, int from_tty, + struct cmd_list_element *c, const char *value) { - set_disassembly_style (); + struct gdbarch *gdbarch = get_current_arch (); + const char *style = gdbarch_disassembler_options (gdbarch); + if (style == NULL) + style = "default"; + else if (CONST_STRNEQ (style, "reg-names-")) + style += strlen ("reg-names-"); + fprintf_unfiltered (file, "The disassembly style is \"%s\".\n", style); } /* Return the ARM register name corresponding to register I. */ @@ -8579,21 +8598,6 @@ arm_register_name (struct gdbarch *gdbarch, int i) return arm_register_names[i]; } -static void -set_disassembly_style (void) -{ - int current; - - /* Find the style that the user wants. */ - for (current = 0; current < num_disassembly_options; current++) - if (disassembly_style == valid_disassembly_styles[current]) - break; - gdb_assert (current < num_disassembly_options); - - /* Synchronize the disassembler. */ - set_arm_regname_option (current); -} - /* Test whether the coff symbol specific value corresponds to a Thumb function. */ @@ -9553,6 +9557,12 @@ arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) user_reg_add (gdbarch, arm_register_aliases[i].name, value_of_arm_user_reg, &arm_register_aliases[i].regnum); + set_gdbarch_disassembler_options (gdbarch, xstrdup ("reg-names-std")); + set_gdbarch_disassembler_options_names (gdbarch, + disassembler_options_names_arm ()); + set_gdbarch_disassembler_options_descriptions + (gdbarch, disassembler_options_desc_arm ()); + return gdbarch; } @@ -9573,6 +9583,9 @@ extern initialize_file_ftype _initialize_arm_tdep; /* -Wmissing-prototypes */ void _initialize_arm_tdep (void) { + /* Disassembly style to use. Default to "std" register names. */ + static const char *disassembly_style; + struct ui_file *stb; long length; const char *setname; @@ -9619,9 +9632,6 @@ _initialize_arm_tdep (void) _("Various ARM-specific commands."), &showarmcmdlist, "show arm ", 0, &showlist); - /* Sync the opcode insn printer with our register viewer. */ - parse_arm_disassembler_option ("reg-names-std"); - /* Initialize the array that will be passed to add_setshow_enum_cmd(). */ valid_disassembly_styles = XNEWVEC (const char *, @@ -9633,13 +9643,6 @@ _initialize_arm_tdep (void) length = snprintf (rdptr, rest, "%s - %s\n", setname, setdesc); rdptr += length; rest -= length; - /* When we find the default names, tell the disassembler to use - them. */ - if (!strcmp (setname, "std")) - { - disassembly_style = setname; - set_arm_regname_option (i); - } } /* Mark the end of valid options. */ valid_disassembly_styles[num_disassembly_options] = NULL; @@ -9659,8 +9662,7 @@ _initialize_arm_tdep (void) _("Show the disassembly style."), helptext.c_str (), set_disassembly_style_sfunc, - NULL, /* FIXME: i18n: The disassembly style is - \"%s\". */ + show_disassembly_style_sfunc, &setarmcmdlist, &showarmcmdlist); add_setshow_boolean_cmd ("apcs32", no_class, &arm_apcs_32, diff --git a/gdb/configure b/gdb/configure index 6df88d9..15e3a84 100755 --- a/gdb/configure +++ b/gdb/configure @@ -1494,8 +1494,9 @@ Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] - --enable-maintainer-mode enable make rules and dependencies not useful - (and sometimes confusing) to the casual installer + --enable-maintainer-mode + enable make rules and dependencies not useful (and + sometimes confusing) to the casual installer --enable-plugins Enable support for plugins --disable-largefile omit support for large files --enable-targets=TARGETS @@ -4813,10 +4814,10 @@ if test x"${install_sh}" != xset; then esac fi -# Installed binaries are usually stripped using `strip' when the user -# run `make install-strip'. However `strip' might not be the right +# Installed binaries are usually stripped using 'strip' when the user +# run "make install-strip". However 'strip' might not be the right # tool to use in cross-compilation environments, therefore Automake -# will honor the `STRIP' environment variable to overrule this program. +# will honor the 'STRIP' environment variable to overrule this program. if test "$cross_compiling" != no; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. diff --git a/gdb/disasm.c b/gdb/disasm.c index f419501..a6355aa 100644 --- a/gdb/disasm.c +++ b/gdb/disasm.c @@ -18,13 +18,17 @@ along with this program. If not, see . */ #include "defs.h" +#include "arch-utils.h" #include "target.h" #include "value.h" #include "ui-out.h" #include "disasm.h" #include "gdbcore.h" +#include "gdbcmd.h" #include "dis-asm.h" +#include "cli/cli-decode.h" #include "source.h" +#include "safe-ctype.h" #include /* Disassemble functions. @@ -778,6 +782,7 @@ gdb_disassemble_info (struct gdbarch *gdbarch, struct ui_file *file) di.endian = gdbarch_byte_order (gdbarch); di.endian_code = gdbarch_byte_order_for_code (gdbarch); di.application_data = gdbarch; + di.disassembler_options = gdbarch_disassembler_options (gdbarch); disassemble_init_for_target (&di); return di; } @@ -894,6 +899,8 @@ gdb_buffered_insn_length_init_dis (struct gdbarch *gdbarch, di->endian = gdbarch_byte_order (gdbarch); di->endian_code = gdbarch_byte_order_for_code (gdbarch); + di->application_data = gdbarch; + di->disassembler_options = gdbarch_disassembler_options (gdbarch); disassemble_init_for_target (di); } @@ -910,3 +917,226 @@ gdb_buffered_insn_length (struct gdbarch *gdbarch, return gdbarch_print_insn (gdbarch, addr, &di); } + +/* Remove whitespace and consecutive commas from OPTIONS. */ + +char * +cleanup_disassembler_options (char *options) +{ + char *str; + size_t i, len; + + if (options == NULL) + return NULL; + + /* Strip off all trailing whitespace and commas. */ + for (len = strlen (options); len > 0; len--) + { + if (!ISSPACE (options[len - 1]) && options[len - 1] != ',') + break; + options[len - 1] = '\0'; + } + + /* Convert all remaining whitespace to commas. */ + for (i = 0; options[i] != '\0'; i++) + if (ISSPACE (options[i])) + options[i] = ','; + + /* Remove consecutive commas. */ + for (str = options; *str != '\0'; str++) + if (*str == ',' && *(str + 1) == ',') + { + char *next = str++; + while (*next == ',') + next++; + len = strlen (next); + memmove (str, next, len); + next[len - (size_t)(next - str)] = '\0'; + } + return (strlen (options) != 0) ? options : NULL; +} + +/* Parse OPTIONS looking for ',' seperated disassembler options and + verify each option is valid. Return NULL if all options are valid. + Otherwise, return a pointer to the first invalid disassembler option. */ + +static char * +parse_disassembler_options (const char *options, const char **valid_names) +{ + static char opt[256]; + size_t i; + + if (options == NULL) + return NULL; + + while (*options) + { + /* Copy the current disassembler option into OPT. */ + const char *separator = strchr (options, ','); + if (separator != NULL) + { + strncpy (opt, options, (size_t) (separator - options)); + opt[(size_t) (separator - options)] = 0; + options = separator; + /* Skip to the next disassembler option. */ + while (*options == ',') + options++; + } + else + options = stpcpy (opt, options); + + /* Verify OPT is a valid disassembler option. */ + for (i = 0; valid_names[i] != NULL; i++) + if (strcmp (opt, valid_names[i]) == 0) + break; + if (valid_names[i] == NULL) + return opt; + } + + return NULL; +} + +void +set_disassembler_options (char *args, int from_tty, struct cmd_list_element *c) +{ + struct gdbarch *gdbarch = get_current_arch (); + char *options = cleanup_disassembler_options (*(char **)c->var); + + if (options == NULL) + { + free (gdbarch_disassembler_options (gdbarch)); + set_gdbarch_disassembler_options (gdbarch, NULL); + return; + } + + const char **valid_names = gdbarch_disassembler_options_names (gdbarch); + if (valid_names == NULL) + { + fprintf_filtered (gdb_stdlog, _("\ +'set disassembler-options ...' is not supported on this architecture.\n")); + return; + } + + char *opt = parse_disassembler_options (options, valid_names); + if (opt != NULL) + { + fprintf_filtered (gdb_stdlog, + _("Invalid disassembler option value: '%s'.\n"), opt); + return; + } + + free (gdbarch_disassembler_options (gdbarch)); + set_gdbarch_disassembler_options (gdbarch, xstrdup (options)); +} + +void +show_disassembler_options (struct ui_file *file, int from_tty, + struct cmd_list_element *c, const char *value) +{ + struct gdbarch *gdbarch = get_current_arch (); + + const char *options = gdbarch_disassembler_options (gdbarch); + if (options == NULL) + options = ""; + + fprintf_filtered (file, _("The current disassembler options are '%s'\n"), + options); + + const char **names = gdbarch_disassembler_options_names (gdbarch); + const char **desc = gdbarch_disassembler_options_descriptions (gdbarch); + + if (names == NULL) + return; + + fprintf_filtered (file, _("\n\ +The following disassembler options are supported for use with\n\ +the 'set disassembler-options