binutils-gdb/gdb/testsuite/gdb.arch/powerpc-altivec.exp
Peter Bergner 65b48a8140 GDB: Add support for the new set/show disassembler-options commands.
This commit adds support to GDB so that it can modify the disassembler-options
value that is passed to the disassembler, similar to objdump's -M option.
Currently, the only supported targets are ARM, PowerPC and S/390, but
adding support for a new target(s) is not difficult.

include/
	* dis-asm.h (disasm_options_t): New typedef.
	(parse_arm_disassembler_option): Remove prototype.
	(set_arm_regname_option): Likewise.
	(get_arm_regnames): Likewise.
	(get_arm_regname_num_options): Likewise.
	(disassemble_init_s390): New prototype.
	(disassembler_options_powerpc): Likewise.
	(disassembler_options_arm): Likewise.
	(disassembler_options_s390): Likewise.
	(remove_whitespace_and_extra_commas): Likewise.
	(disassembler_options_cmp): Likewise.
	(next_disassembler_option): New inline function.
	(FOR_EACH_DISASSEMBLER_OPTION): New macro.

opcodes/
	* disassemble.c Include "safe-ctype.h".
	(disassemble_init_for_target): Handle s390 init.
	(remove_whitespace_and_extra_commas): New function.
	(disassembler_options_cmp): Likewise.
	* arm-dis.c: Include "libiberty.h".
	(NUM_ELEM): Delete.
	(regnames): Use long disassembler style names.
	Add force-thumb and no-force-thumb options.
	(NUM_ARM_REGNAMES): Rename from this...
	(NUM_ARM_OPTIONS): ...to this.  Use ARRAY_SIZE.
	(get_arm_regname_num_options): Delete.
	(set_arm_regname_option): Likewise.
	(get_arm_regnames): Likewise.
	(parse_disassembler_options): Likewise.
	(parse_arm_disassembler_option): Rename from this...
	(parse_arm_disassembler_options): ...to this.  Make static.
	Use new FOR_EACH_DISASSEMBLER_OPTION macro to scan over options.
	(print_insn): Use parse_arm_disassembler_options.
	(disassembler_options_arm): New function.
	(print_arm_disassembler_options): Handle updated regnames.
	* ppc-dis.c: Include "libiberty.h".
	(ppc_opts): Add "32" and "64" entries.
	(ppc_parse_cpu): Use ARRAY_SIZE and disassembler_options_cmp.
	(powerpc_init_dialect): Add break to switch statement.
	Use new FOR_EACH_DISASSEMBLER_OPTION macro.
	(disassembler_options_powerpc): New function.
	(print_ppc_disassembler_options): Use ARRAY_SIZE.
	Remove printing of "32" and "64".
	* s390-dis.c: Include "libiberty.h".
	(init_flag): Remove unneeded variable.
	(struct s390_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.
	(print_insn_s390): Delete call to init_disasm.
	(disassembler_options_s390): New function.
	(print_s390_disassembler_options): Print using information from
	struct 'options'.
	* po/opcodes.pot: Regenerate.

binutils/
	* objdump.c (main): Use remove_whitespace_and_extra_commas.

gdb/
	* NEWS: Mention new set/show disassembler-options commands.
	* doc/gdb.texinfo: Document new set/show disassembler-options commands.
	* disasm.c: Include "arch-utils.h", "gdbcmd.h" and "safe-ctype.h".
	(prospective_options): New static variable.
	(gdb_disassembler::gdb_disassembler): Initialize
	m_di.disassembler_options.
	(gdb_buffered_insn_length_init_dis): Initilize di->disassembler_options.
	(get_disassembler_options): New function.
	(set_disassembler_options): Likewise.
	(set_disassembler_options_sfunc): Likewise.
	(show_disassembler_options_sfunc): Likewise.
	(disassembler_options_completer): Likewise.
	(_initialize_disasm): Likewise.
	* disasm.h (get_disassembler_options): New prototype.
	(set_disassembler_options): Likewise.
	* gdbarch.sh (gdbarch_disassembler_options): New variable.
	(gdbarch_verify_disassembler_options): Likewise.
	* gdbarch.c: Regenerate.
	* gdbarch.h: Likewise.
	* arm-tdep.c (num_disassembly_options): Delete.
	(set_disassembly_style): Likewise.
	(arm_disassembler_options): New static variable.
	(set_disassembly_style_sfunc): Convert short style name into long
	option name.  Call set_disassembler_options.
	(show_disassembly_style_sfunc): New function.
	(arm_gdbarch_init): Call set_gdbarch_disassembler_options and
	set_gdbarch_verify_disassembler_options.
	(_initialize_arm_tdep): Delete regnames variable and update callers.
	(arm_disassembler_options): Initialize.
	(disasm_options): New variable.
	(num_disassembly_options): Rename from this...
	(num_disassembly_styles): ...to this.  Compute by scanning through
	disasm_options.
	(valid_disassembly_styles): Initialize using disasm_options.
	Remove calls to parse_arm_disassembler_option, get_arm_regnames and
	set_arm_regname_option.
	Pass show_disassembly_style_sfunc to the "disassembler" setshow command.
	* rs6000-tdep.c (powerpc_disassembler_options): New static variable.
	(rs6000_gdbarch_init): Call set_gdbarch_disassembler_options and
	set_gdbarch_verify_disassembler_options.
	* s390-tdep.c (s390_disassembler_options): New static variable.
	(s390_gdbarch_init):all set_gdbarch_disassembler_options and
	set_gdbarch_verify_disassembler_options.

gdb/testsuite/
	* gdb.arch/powerpc-power.exp: Delete test.
	* gdb.arch/powerpc-power.s: Likewise.
	* 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/arm-disassembler-options.exp: Likewise.
	* gdb.arch/powerpc-disassembler-options.exp: Likewise.
	* gdb.arch/s390-disassembler-options.exp: Likewise.
2017-02-28 12:32:07 -06:00

262 lines
7.9 KiB
Plaintext

# Copyright 2014-2017 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# This file is part of the gdb testsuite.
# Test PowerPC instructions disassembly.
standard_testfile .s
set objfile [standard_output_file ${testfile}.o]
if {![istarget "powerpc*-*-*"]} then {
verbose "Skipping PowerPC instructions disassembly."
return
}
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${objfile}" object {debug}] != "" } {
untested "PowerPC instructions disassembly"
return -1
}
clean_restart ${objfile}
# Disassemble the function.
set func ""
gdb_test "set disassembler-options altivec"
set test "disass func"
gdb_test_multiple $test $test {
-re "\r\nDump of assembler code for function func:(\r\n.*\r\n)End of assembler dump.\r\n$gdb_prompt $" {
set func $expect_out(1,string)
pass $test
}
}
proc instr_to_patt {instr} {
global decimal hex
# 0x0000000000000018 <+24>: stxvd2x vs43,r4,r5
return "\[ \t\]*$hex <\\+$decimal>:\[ \t\]*[string_to_regexp $instr]"
}
proc func_check {instr} {
global func
set test "found: '$instr'"
set peb [instr_to_patt $instr]
if [regexp -nocase -line [instr_to_patt $instr] $func] {
pass $test
} else {
fail $peb
}
}
func_check "dss 3"
func_check "dssall"
func_check "dst r5,r4,1"
func_check "dstt r8,r7,0"
func_check "dstst r5,r6,3"
func_check "dststt r4,r5,2"
func_check "lvebx v30,r22,r24"
func_check "lvebx v21,0,r24"
func_check "lvehx v10,r16,r2"
func_check "lvehx v20,0,r23"
func_check "lvewx v17,r4,r18"
func_check "lvewx v23,0,r8"
func_check "lvsl v6,0,r25"
func_check "lvsl v2,0,r6"
func_check "lvsr v22,r16,r12"
func_check "lvsr v0,0,r29"
func_check "lvxl v15,r5,r13"
func_check "lvxl v19,0,r23"
func_check "lvx v22,r1,r2"
func_check "lvx v18,0,r17"
func_check "mfvrsave r31"
func_check "mfvscr v24"
func_check "mtvrsave r10"
func_check "mtvscr v25"
func_check "stvebx v18,r27,r10"
func_check "stvebx v16,0,r6"
func_check "stvehx v17,r13,r16"
func_check "stvehx v23,0,r20"
func_check "stvewx v11,r19,r31"
func_check "stvewx v31,0,r1"
func_check "stvxl v26,r21,r17"
func_check "stvxl v13,0,r22"
func_check "stvx v11,r31,r31"
func_check "stvx v30,0,r16"
func_check "vaddcuw v24,v7,v28"
func_check "vaddfp v3,v30,v11"
func_check "vaddsbs v8,v28,v9"
func_check "vaddshs v7,v5,v4"
func_check "vaddsws v22,v26,v27"
func_check "vaddubm v16,v14,v28"
func_check "vaddubs v6,v1,v25"
func_check "vadduhm v2,v4,v6"
func_check "vadduhs v26,v21,v8"
func_check "vadduwm v29,v31,v1"
func_check "vadduws v23,v13,v4"
func_check "vandc v30,v16,v9"
func_check "vand v3,v13,v27"
func_check "vavgsb v4,v6,v17"
func_check "vavgsh v23,v28,v19"
func_check "vavgsw v8,v15,v31"
func_check "vavgub v6,v7,v25"
func_check "vavguh v25,v22,v10"
func_check "vavguw v3,v23,v29"
func_check "vctsxs v14,v2,6"
func_check "vctuxs v9,v31,20"
func_check "vcfsx v24,v30,3"
func_check "vcfux v17,v21,29"
func_check "vcmpbfp v18,v28,v0"
func_check "vcmpbfp. v19,v26,v3"
func_check "vcmpeqfp v16,v2,v11"
func_check "vcmpeqfp. v23,v13,v13"
func_check "vcmpequb v25,v19,v10"
func_check "vcmpequb. v18,v11,v2"
func_check "vcmpequh v9,v25,v7"
func_check "vcmpequh. v14,v24,v21"
func_check "vcmpequw v24,v12,v5"
func_check "vcmpequw. v19,v16,v1"
func_check "vcmpgefp v23,v17,v16"
func_check "vcmpgefp. v19,v29,v17"
func_check "vcmpgtfp v16,v28,v13"
func_check "vcmpgtfp. v14,v24,v7"
func_check "vcmpgtsb v16,v22,v6"
func_check "vcmpgtsb. v2,v12,v14"
func_check "vcmpgtsh v28,v3,v29"
func_check "vcmpgtsh. v16,v19,v13"
func_check "vcmpgtsw v15,v0,v5"
func_check "vcmpgtsw. v21,v13,v0"
func_check "vcmpgtub v5,v10,v30"
func_check "vcmpgtub. v7,v13,v10"
func_check "vcmpgtuh v24,v15,v16"
func_check "vcmpgtuh. v25,v21,v27"
func_check "vcmpgtuw v17,v27,v6"
func_check "vcmpgtuw. v8,v21,v27"
func_check "vcfsx v1,v1,14"
func_check "vctsxs v4,v15,25"
func_check "vctuxs v28,v23,14"
func_check "vcfux v6,v6,0"
func_check "vexptefp v0,v8"
func_check "vlogefp v22,v27"
func_check "vmaddfp v23,v18,v5,v18"
func_check "vmaxfp v13,v13,v27"
func_check "vmaxsb v8,v23,v14"
func_check "vmaxsh v19,v17,v0"
func_check "vmaxsw v19,v3,v22"
func_check "vmaxub v23,v30,v28"
func_check "vmaxuh v9,v20,v23"
func_check "vmaxuw v21,v19,v1"
func_check "vmhaddshs v22,v13,v5,v22"
func_check "vmhraddshs v31,v0,v3,v18"
func_check "vminfp v2,v21,v24"
func_check "vminsb v20,v6,v10"
func_check "vminsh v18,v27,v26"
func_check "vminsw v3,v4,v1"
func_check "vminub v7,v0,v13"
func_check "vminuh v0,v12,v6"
func_check "vminuw v6,v3,v1"
func_check "vmladduhm v3,v29,v3,v26"
func_check "vmrghb v21,v5,v31"
func_check "vmrghh v21,v24,v0"
func_check "vmrghw v16,v0,v22"
func_check "vmrglb v1,v17,v16"
func_check "vmrglh v14,v8,v15"
func_check "vmrglw v31,v21,v5"
func_check "vmr v24,v9"
func_check "vmr v24,v9"
func_check "vmsummbm v0,v24,v15,v23"
func_check "vmsumshm v1,v4,v7,v25"
func_check "vmsumshs v9,v8,v13,v31"
func_check "vmsumubm v23,v31,v12,v30"
func_check "vmsumuhm v29,v0,v26,v21"
func_check "vmsumuhs v27,v14,v25,v5"
func_check "vmulesb v10,v25,v14"
func_check "vmulesh v1,v18,v8"
func_check "vmuleub v17,v14,v9"
func_check "vmuleuh v5,v26,v9"
func_check "vmulosb v21,v18,v6"
func_check "vmulosh v4,v5,v8"
func_check "vmuloub v2,v9,v19"
func_check "vmulouh v29,v5,v4"
func_check "vnmsubfp v8,v2,v6,v5"
func_check "vnor v31,v9,v10"
func_check "vnot v25,v31"
func_check "vnot v25,v31"
func_check "vor v23,v7,v2"
func_check "vperm v0,v28,v22,v25"
func_check "vpkpx v16,v25,v17"
func_check "vpkshss v12,v16,v17"
func_check "vpkshus v1,v19,v23"
func_check "vpkswss v25,v7,v13"
func_check "vpkswus v4,v24,v10"
func_check "vpkuhum v9,v27,v12"
func_check "vpkuhus v22,v10,v25"
func_check "vpkuwum v30,v18,v0"
func_check "vpkuwus v7,v3,v22"
func_check "vrefp v24,v28"
func_check "vrfim v17,v19"
func_check "vrfin v24,v25"
func_check "vrfip v3,v5"
func_check "vrfiz v8,v10"
func_check "vrlb v26,v18,v30"
func_check "vrlh v16,v17,v25"
func_check "vrlw v23,v30,v9"
func_check "vrsqrtefp v2,v18"
func_check "vsel v20,v14,v18,v10"
func_check "vslb v25,v25,v12"
func_check "vsldoi v9,v9,v12,7"
func_check "vslh v14,v2,v11"
func_check "vslo v30,v5,v6"
func_check "vsl v22,v30,v9"
func_check "vslw v26,v26,v3"
func_check "vspltb v1,v20,6"
func_check "vsplth v16,v18,3"
func_check "vspltisb v25,-13"
func_check "vspltish v22,10"
func_check "vspltisw v13,13"
func_check "vspltw v9,v18,2"
func_check "vsrab v14,v22,v0"
func_check "vsrah v12,v12,v18"
func_check "vsraw v2,v2,v13"
func_check "vsrb v7,v27,v5"
func_check "vsrh v7,v11,v29"
func_check "vsro v18,v30,v31"
func_check "vsr v2,v9,v28"
func_check "vsrw v0,v25,v0"
func_check "vsubcuw v24,v2,v10"
func_check "vsubfp v22,v24,v20"
func_check "vsubsbs v10,v22,v13"
func_check "vsubshs v24,v17,v28"
func_check "vsubsws v10,v26,v0"
func_check "vsububm v16,v11,v24"
func_check "vsububs v11,v21,v1"
func_check "vsubuhm v6,v12,v24"
func_check "vsubuhs v30,v11,v9"
func_check "vsubuwm v19,v20,v13"
func_check "vsubuws v18,v25,v6"
func_check "vsum2sws v25,v10,v18"
func_check "vsum4sbs v13,v16,v21"
func_check "vsum4shs v23,v8,v4"
func_check "vsum4ubs v28,v13,v30"
func_check "vsumsws v22,v10,v8"
func_check "vupkhpx v24,v14"
func_check "vupkhsb v2,v22"
func_check "vupkhsh v16,v2"
func_check "vupklpx v10,v26"
func_check "vupklsb v15,v28"
func_check "vupklsh v8,v8"
func_check "vxor v25,v0,v3"