aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.arch
AgeCommit message (Collapse)AuthorFilesLines
2019-02-14Updating test caseWeimin Pan2-13/+9
gdb.arch/aarch64-dbreg-contents.exp: * Replaced "run" with "runto_main + continue". * Replaced "gdb_compile + clean_restart" with "prepare_for_testing". * Added comment for case "exited with code 01". gdb.arch/aarch64-dbreg-contents.c: * Removed SET_WATCHPOINT marco. * Removed redundent cleanup (). * Cleaned up comment.
2019-02-13Adding a test caseWeimin Pan2-0/+179
gdb/testsuite/ChangeLog 2019-02-12 Weimin Pan <weimin.pan@oracle.com> PR breakpoints/21870 * gdb.arch/aarch64-dbreg-contents.exp: New file. * gdb.arch/aarch64-dbreg-contents.c: New file.
2019-01-14[PowerPC] Aliases for vector registersPedro Franco de Carvalho4-2/+128
This patch defines pseudo-registers "v0" through "v31" as aliases that map to the corresponding raw "vr0" through "vr31" vector registers for Power. The motivation behind this is that although GDB defines these registers as "vrX", the disassembler prints them as "vX", e.g. as the operands in instructions such as "vaddubm v2,v1,v1". This can be confusing to users trying to print out the values of the operands while inspecting the disassembled code. The new aliases are made not to belong to any register group, to avoid duplicated values in "info register vector" and "info register all". The arch-specific rs6000_pseudo_register_reggroup_p function had previously been removed since the other pseudo-registers could have their groups inferred by their type. It restored with this patch to handle the aliases. Membership for the other pseudo-registers is still determined using the default function. A new tests checks that GDB prints the expected values of vector registers after they are filled by the inferior, by using both the raw names and the aliases. Two other existing tests are modified to also test the aliases. gdb/ChangeLog: 2019-01-14 Pedro Franco de Carvalho <pedromfc@linux.ibm.com> * ppc-tdep.h (struct gdbarch_tdep) <ppc_v0_alias_regnum>: New field. * rs6000-tdep.c: Include reggroups.h. (IS_V_ALIAS_PSEUDOREG): Define. (rs6000_register_name): Return names for the "vX" aliases. (rs6000_pseudo_register_type): Return type for the "vX" aliases. (rs6000_pseudo_register_reggroup_p): Restore. Handle "vX" aliases. Call default_register_reggroup_p for all other pseudo-registers. (v_alias_pseudo_register_read, v_alias_pseudo_register_write): New functions. (rs6000_pseudo_register_read, rs6000_pseudo_register_write): Handle "vX" aliases. (v_alias_pseudo_register_collect): New function. (rs6000_ax_pseudo_register_collect): Handle "vX" aliases. (rs6000_gdbarch_init): Initialize "vX" aliases as pseudo-registers. Restore registration of rs6000_pseudo_register_reggroup_p with set_tdesc_pseudo_register_reggroup_p. gdb/testsuite/ChangeLog: 2019-01-14 Pedro Franco de Carvalho <pedromfc@linux.ibm.com> * gdb.arch/vsx-regs.exp: Add tests that use the vector register aliases. * gdb.arch/altivec-regs.exp: Likewise. Fix indentation of two tests. * gdb.arch/powerpc-vector-regs.c: New file. * gdb.arch/powerpc-vector-regs.exp: New file. gdb/doc/ChangeLog: 2019-01-14 Pedro Franco de Carvalho <pedromfc@linux.ibm.com> * gdb.texinfo (PowerPC Features): Document the alias pseudo-registers for the org.gnu.gdb.power.altivec feature.
2019-01-14[PowerPC] Fix "info vector" test in gdb.arch/altivec-regs.expPedro Franco de Carvalho1-38/+5
This patch fixes one of the tests in gdb.arch/altivec-regs.exp that was passing an incorrect list to gdb_expect_list, which always matched. gdb/testsuite/ChangeLog: 2019-01-14 Pedro Franco de Carvalho <pedromfc@linux.ibm.com> * gdb.arch/altivec-regs.exp: Fix the list passed to gdb_expect_list when testing "info vector".
2019-01-01Update copyright year range in all GDB files.Joel Brobecker262-262/+262
This commit applies all changes made after running the gdb/copyright.py script. Note that one file was flagged by the script, due to an invalid copyright header (gdb/unittests/basic_string_view/element_access/char/empty.cc). As the file was copied from GCC's libstdc++-v3 testsuite, this commit leaves this file untouched for the time being; a patch to fix the header was sent to gcc-patches first. gdb/ChangeLog: Update copyright year range in all GDB files.
2018-12-21Fix various tests to use -no-pie linker flag when neededJan Vrany5-6/+6
Various tests use test code written in i386 / x86_64 assembly that cannot be used to create PIE executables. Therefore compilation of test programs failed on systems where the compiler default is to create PIE executable. The solution is to use -no-pie linker flag, however, such flag may not (is not) supported by all compilers GDB needs to support (e.g. gcc 4.8). To handle this, introduce a new flag to gdb_compile - nopie - which inserts -no-pie linker flag where supported and is no-op where it is not. By default, -no-pie flag is inserted since most modern compiler do support it.
2018-11-08x86-64: fix ZMM register state trackingJan Beulich2-0/+17
The three AVX512 state components are entirely independent - one being in its "init state" has no implication whatsoever on either of the other two. Fully separate X86_XSTATE_ZMM_H and X86_XSTATE_ZMM handling, to prevent upper halves of the upper 16 ZMM registers to display as if they were zero (when they aren't) after e.g. VZEROALL/VZEROUPPER.
2018-11-08gdb/riscv: Update test to support targets without FP hardwareAndrew Burgess1-6/+18
Update gdb.arch/riscv-reg-aliases.exp test to support targets without floating point registers. gdb/testsuite/ChangeLog: * gdb.arch/riscv-reg-aliases.exp: Handle targets without floating point hardware.
2018-11-01Reading signal handler frame in AIXSangamesh Mallayya2-0/+78
In AIX if gdb is debugging an application which has a signal handler and reaches the signal handler frame, then we need to read the back chain address from sigcontext saved on the stack, similarly the LR. As backchain at an offset 0 will be 0, because we will have a sigconext saved after the minimum stack size. So the correct backchain will be at an offset after minimum stack and the LR at an offset 8 will be of the signal millicode address. If the back chain pointer is NULL and the LR field is in the kernel segment(ex. 0x00004a14) then we can probably assume we are in a signal handler. sample output (gdb) bt 0 sig_handle_aix (signo=11) at aix-sighandle.c:7 1 0x0000000000004a94 in ?? () (gdb) expected output (gdb) bt 0 sig_handle_aix (signo=11) at aix-sighandle.c:7 1 <signal handler called> 2 0x0000000100000748 in foo () at aix-sighandle.c:14 3 0x000000010000079c in main () at aix-sighandle.c:19 gdb/ChangeLog: 2018-11-01 Sangamesh Mallayya <sangamesh.swamy@in.ibm.com> * rs6000-aix-tdep.c: Include "trad-frame.h" and "frame-unwind.h". (SIG_FRAME_LR_OFFSET64): New define. (SIG_FRAME_FP_OFFSET64): New define. (aix_sighandle_frame_cache): New Function. (aix_sighandle_frame_this_id): New Function. (aix_sighandle_frame_prev_register): New Function. (aix_sighandle_frame_sniffer): New Function. (aix_sighandle_frame_unwind): New global variable. (rs6000_aix_init_osabi): Install new frame unwinder. gdb/testsuite/ChangeLog: 2018-11-01 Sangamesh Mallayya <sangamesh.swamy@in.ibm.com> * gdb.arch/aix-sighandle.c: New file. * gdb.arch/aix-sighandle.exp: New file.
2018-10-31gdb/riscv: Fix failures on rv64 in gdb.arch/riscv-reg-aliases.exp testAndrew Burgess1-66/+116
The gdb.arch/riscv-reg-aliases.exp test didn't take into account that on RV64 (and RV128) the floating point registers are represented as a union. This patch updates the test to handle this. Tested against RV32 and RV64. gdb/testsuite/ChangeLog: * gdb.arch/riscv-reg-aliases.exp: Rewrite to take account of float registers being unions.
2018-10-27Remove a bunch of usages of gdb_suppress_tests in 'runto_main'.Philippe Waroquiers18-22/+49
In the 'info -q -t' patch series, I started a new test from gdb.threads/threadapply.exp, that uses an obsolete way to do runto_main. This patch changes all occurrences of runto_main using gdb_suppress_tests to use instead fail+return. Note that there are still about 220 occurrences of gdb_suppress_tests but unclear (to me) if these can be similarly trivially be replaced by a fail+return. Further cleanup can be done in follow-up patches. Tests run on Debian/x86_64. gdb/testsuite/ChangeLog 2018-10-27 Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.arch/altivec-regs.exp: Do not use gdb_suppress_tests in runto_main, use fail + return instead. gdb.arch/amd64-byte.exp: Likewise. gdb.arch/amd64-dword.exp: Likewise. gdb.arch/amd64-word.exp: Likewise. gdb.arch/e500-abi.exp: Likewise. gdb.arch/e500-regs.exp: Likewise. gdb.arch/gdb1291.exp: Likewise. gdb.arch/gdb1431.exp: Likewise. gdb.arch/i386-avx.exp: Likewise. gdb.arch/i386-byte.exp: Likewise. gdb.arch/i386-prologue.exp: Likewise. gdb.arch/i386-sse.exp: Likewise. gdb.arch/i386-word.exp: Likewise. gdb.arch/iwmmxt-regs.exp: Likewise. gdb.arch/pa-nullify.exp: Likewise. gdb.arch/powerpc-prologue.exp: Likewise. gdb.arch/s390-tdbregs.exp: Likewise. gdb.arch/vsx-regs.exp: Likewise. gdb.asm/asm-source.exp: Likewise. gdb.base/auxv.exp: Likewise. gdb.base/bigcore.exp: Likewise. gdb.base/overlays.exp: Likewise. gdb.base/savedregs.exp: Likewise. gdb.base/setshow.exp: Likewise. gdb.base/sigaltstack.exp: Likewise. gdb.base/sigbpt.exp: Likewise. gdb.base/siginfo-addr.exp: Likewise. gdb.base/siginfo-obj.exp: Likewise. gdb.base/siginfo-thread.exp: Likewise. gdb.base/siginfo.exp: Likewise. gdb.base/signull.exp: Likewise. gdb.base/sigrepeat.exp: Likewise. gdb.base/structs2.exp: Likewise. gdb.threads/threadapply.exp: Likewise. gdb.threads/watchthreads.exp: Likewise. gdb.threads/watchthreads2.exp: Likewise.
2018-10-26[PowerPC] Add support for HTM registersEdjunior Barbosa Machado2-0/+367
This patch adds support for Hardware Transactional Memory registers for the powerpc linux native and core file targets, and for the pwoerpc linux server stub. These registers include both the HTM special-purpose registers (TFHAR, TEXASR and TFIAR) as well as the set of registers that are checkpointed (saved) when a transaction is initiated, which the processor restores in the event of a transaction failure. The set of checkpointed general-purpose registers is returned by the linux kernel in the same format as the regular general-purpose registers, defined in struct pt_regs. However, the architecture specifies that only some of the registers present in pt_regs are checkpointed (GPRs 0-31, CR, XER, LR and CTR). The kernel fills the slots for MSR and NIP with other info. The other fields usually don't have meaningful values. GDB doesn't define registers that are not checkpointed in the architecture, but when generating a core file, GDB fills the slot for the checkpointed MSR with the regular MSR. These are usually similar, although some bits might be different, and in some cases the checkpointed MSR will have a value of 0 in a kernel-generated core-file. The checkpointed NIP is filled with TFHAR by GDB in the core-file, which is what the kernel does. The other fields are set to 0 by GDB. Core files generated by the kernel have a note section for checkpointed GPRs with the same size for both 32-bit and 64-bit threads, and the values for the registers of a 32-bit thread are squeezed in the first half, with no useful data in the second half. GDB generates a smaller note section for 32-bit threads, but can read both sizes. The checkpointed XER is required to be 32-bit in the target description documentation, even though the more recent ISAs define it as 64-bit wide, since the high-order 32-bits are reserved, and because in Linux there is no way to get a 64-bit checkpointed XER for 32-bit threads. If this changes in the future, the target description feature requirement can be relaxed to allow for a 64-bit checkpointed XER. Access to the checkpointed CR (condition register) can be confusing. The architecture only specifies that CR fields 1 to 7 (the 24 least significant bits) are checkpointed, but the kernel provides all 8 fields (32 bits). The value of field 0 is not masked by ptrace, so it will sometimes show the result of some kernel operation, probably treclaim., which sets this field. The checkpointed registers are marked not to be saved and restored. Inferior function calls during an active transaction don't work well, and it's unclear what should be done in this case. TEXASR and TFIAR can be altered asynchronously, during transaction failure recording, so they are also not saved and restored. For consistency neither is TFHAR. Record and replay also doesn't work well when transactions are involved. This patch doesn't address this, so the values of the HTM SPRs will sometimes be innacurate when the record/relay target is enabled. For instance, executing a "tbegin." alters TFHAR and TEXASR, but these changes are not currently recorded. Because the checkpointed registers are only available when a transaction is active (or suspended), ptrace can return ENODATA when gdb tries to read these registers and the inferior is not in a transactional state. The registers are set to the unavailable state when this happens. When gbd tries to write to one of these registers, and it is unavailable, an error is raised. The "fill" functions for checkpointed register sets in the server stub are not implemented for the same reason as for the EBB register set, since ptrace can also return ENODATA for checkpointed regsets. The same issues with 'G' packets apply here. Just like for the EBB registers, tracepoints will not mark the checkpointed registers as unavailable if the inferior was not in a transaction, so their content will also show 0 instead of <unavailable> when inspecting trace data. The new tests record the values of the regular registers before stepping the inferior through a "tbegin." instruction to start a transaction, then the checkpointed registers are checked against the recorded pre-transactional values. New values are written to the checkpointed registers and recorded, the inferior continues until the transaction aborts (which is usually immediately when it is resumed), and the regular registers are checked against the recorded values, because the abort should have reverted the registers to these values. Like for the EBB registers, target_store_registers will ignore the checkpointed registers when called with -1 as the regno argument (store all registers in one go). gdb/ChangeLog: 2018-10-26 Edjunior Barbosa Machado <emachado@linux.vnet.ibm.com> Pedro Franco de Carvalho <pedromfc@linux.ibm.com> * arch/ppc-linux-tdesc.h (tdesc_powerpc_isa207_htm_vsx32l) (tdesc_powerpc_isa207_htm_vsx64l): Declare. * arch/ppc-linux-common.h (PPC_LINUX_SIZEOF_TM_SPRREGSET) (PPC32_LINUX_SIZEOF_CGPRREGSET, PPC64_LINUX_SIZEOF_CGPRREGSET) (PPC_LINUX_SIZEOF_CFPRREGSET, PPC_LINUX_SIZEOF_CVMXREGSET) (PPC_LINUX_SIZEOF_CVSXREGSET, PPC_LINUX_SIZEOF_CPPRREGSET) (PPC_LINUX_SIZEOF_CDSCRREGSET, PPC_LINUX_SIZEOF_CTARREGSET): Define. (struct ppc_linux_features) <htm>: New field. (ppc_linux_no_features): Add initializer for htm field. * arch/ppc-linux-common.c (ppc_linux_match_description): Return new tdescs. * nat/ppc-linux.h (PPC_FEATURE2_HTM, NT_PPC_TM_CGPR) (NT_PPC_TM_CFPR, NT_PPC_TM_CVMX, NT_PPC_TM_CVSX) (NT_PPC_TM_SPR, NT_PPC_TM_CTAR, NT_PPC_TM_CPPR, NT_PPC_TM_CDSCR): Define if not already defined. * features/Makefile (WHICH): Add rs6000/powerpc-isa207-htm-vsx32l and rs6000/powerpc-isa207-htm-vsx64l. (XMLTOC): Add rs6000/powerpc-isa207-htm-vsx32l.xml and rs6000/powerpc-isa207-htm-vsx64l.xml. * features/rs6000/power-htm-spr.xml: New file. * features/rs6000/power-htm-core.xml: New file. * features/rs6000/power64-htm-core.xml: New file. * features/rs6000/power-htm-fpu.xml: New file. * features/rs6000/power-htm-altivec.xml: New file. * features/rs6000/power-htm-vsx.xml: New file. * features/rs6000/power-htm-ppr.xml: New file. * features/rs6000/power-htm-dscr.xml: New file. * features/rs6000/power-htm-tar.xml: New file. * features/rs6000/powerpc-isa207-htm-vsx32l.xml: New file. * features/rs6000/powerpc-isa207-htm-vsx64l.xml: New file. * features/rs6000/powerpc-isa207-htm-vsx32l.c: Generate. * features/rs6000/powerpc-isa207-htm-vsx64l.c: Generate. * regformats/rs6000/powerpc-isa207-htm-vsx32l.dat: Generate. * regformats/rs6000/powerpc-isa207-htm-vsx64l.dat: Generate. * ppc-linux-nat.c (fetch_register, fetch_ppc_registers): Call fetch_regset with HTM regsets. (store_register, store_ppc_registers): Call store_regset with HTM regsets. (ppc_linux_nat_target::read_description): Set htm field in the features struct if needed. * ppc-linux-tdep.c: Include features/rs6000/powerpc-isa207-htm-vsx32l.c and features/rs6000/powerpc-isa207-htm-vsx64l.c. (ppc32_regmap_tm_spr, ppc32_regmap_cgpr, ppc64_le_regmap_cgpr) (ppc64_be_regmap_cgpr, ppc32_regmap_cfpr, ppc32_le_regmap_cvmx) (ppc32_be_regmap_cvmx, ppc32_regmap_cvsx, ppc32_regmap_cppr) (ppc32_regmap_cdscr, ppc32_regmap_ctar): New globals. (ppc32_linux_tm_sprregset, ppc32_linux_cgprregset) (ppc64_be_linux_cgprregset, ppc64_le_linux_cgprregset) (ppc32_linux_cfprregset, ppc32_le_linux_cvmxregset) (ppc32_be_linux_cvmxregset, ppc32_linux_cvsxregset) (ppc32_linux_cpprregset, ppc32_linux_cdscrregset) (ppc32_linux_ctarregset): New globals. (ppc_linux_cgprregset, ppc_linux_cvmxregset): New functions. (ppc_linux_collect_core_cpgrregset): New function. (ppc_linux_iterate_over_regset_sections): Call back with the htm regsets. (ppc_linux_core_read_description): Check if the tm spr section is present and set htm in the features struct. (_initialize_ppc_linux_tdep): Call initialize_tdesc_powerpc_isa207_htm_vsx32l and initialize_tdesc_powerpc_isa207_htm_vsx64l. * ppc-linux-tdep.h (ppc_linux_cgprregset, ppc_linux_cvmxregset): Declare. (ppc32_linux_tm_sprregset, ppc32_linux_cfprregset) (ppc32_linux_cvsxregset, ppc32_linux_cpprregset) (ppc32_linux_cdscrregset, ppc32_linux_ctarregset): Declare. * ppc-tdep.h (struct gdbarch_tdep) <have_htm_spr, have_htm_core>: New fields. <have_htm_fpu, have_htm_altivec, have_htm_vsx>: Likewise. <ppc_cppr_regnum, ppc_cdscr_regnum, ppc_ctar_regnum>: Likewise. <ppc_cdl0_regnum, ppc_cvsr0_regnum, ppc_cefpr0_regnum>: Likewise. (enum) <PPC_TFHAR_REGNUM, PPC_TEXASR_REGNUM, PPC_TFIAR_REGNUM>: New enum fields. <PPC_CR0_REGNUM, PPC_CCR_REGNUM, PPC_CXER_REGNUM>: Likewise. <PPC_CLR_REGNUM, PPC_CCTR_REGNUM, PPC_CF0_REGNUM>: Likewise. <PPC_CFPSCR_REGNUM, PPC_CVR0_REGNUM, PPC_CVSCR_REGNUM>: Likewise. <PPC_CVRSAVE_REGNUM, PPC_CVSR0_UPPER_REGNUM>: Likewise. <PPC_CPPR_REGNUM, PPC_CDSCR_REGNUM>: Likewise. <PPC_CTAR_REGNUM>: Likewise. (PPC_IS_TMSPR_REGNUM, PPC_IS_CKPTGP_REGNUM, PPC_IS_CKPTFP_REGNUM) (PPC_IS_CKPTVMX_REGNUM, PPC_IS_CKPTVSX_REGNUM): Define. * rs6000-tdep.c (IS_CDFP_PSEUDOREG, IS_CVSX_PSEUDOREG) (IS_CEFP_PSEUDOREG): Define. (rs6000_register_name): Hide the upper halves of checkpointed VSX registers. Return names for the checkpointed DFP, VSX, and EFP pseudo registers. (rs6000_pseudo_register_type): Remove initial assert and raise an internal error in the else clause instead. Return types for the checkpointed DFP, VSX, and EFP pseudo registers. (dfp_pseudo_register_read, dfp_pseudo_register_write): Handle checkpointed DFP pseudo registers. (vsx_pseudo_register_read, vsx_pseudo_register_write): Handle checkpointed VSX pseudo registers. (efp_pseudo_register_read, efp_pseudo_register_write): Rename from efpr_pseudo_register_read and efpr_pseudo_register_write. Handle checkpointed EFP pseudo registers. (rs6000_pseudo_register_read, rs6000_pseudo_register_write): Handle checkpointed DFP, VSX, and EFP registers. (dfp_ax_pseudo_register_collect, vsx_ax_pseudo_register_collect) (efp_ax_pseudo_register_collect): New functions. (rs6000_ax_pseudo_register_collect): Move DFP, VSX and EFP pseudo register logic to new functions. Handle checkpointed DFP, VSX, and EFP pseudo registers. (rs6000_gdbarch_init): Look for and validate the htm features. Include checkpointed DFP, VSX and EFP pseudo-registers. * NEWS: Mention access to PPR, DSCR, TAR, EBB/PMU registers and HTM registers. gdb/gdbserver/ChangeLog: 2018-10-26 Pedro Franco de Carvalho <pedromfc@linux.ibm.com> * configure.srv (ipa_ppc_linux_regobj): Add powerpc-isa207-htm-vsx32l-ipa.o and powerpc-isa207-htm-vsx64l-ipa.o. (powerpc*-*-linux*): Add powerpc-isa207-htm-vsx32l.o and powerpc-isa207-htm-vsx64l.o to srv_regobj. Add rs6000/power-htm-spr.xml, rs6000/power-htm-core.xml, rs6000/power64-htm-core.xml, rs6000/power-htm-fpu.xml, rs6000/power-htm-altivec.xml, rs6000/power-htm-vsx.xml, rs6000/power-htm-ppr.xml, rs6000/power-htm-dscr.xml, rs6000/power-htm-tar.xml, rs6000/powerpc-isa207-htm-vsx32l.xml, and rs6000/powerpc-isa207-htm-vsx64l.xml to srv_xmlfiles. * linux-ppc-tdesc-init.h (enum ppc_linux_tdesc) <PPC_TDESC_ISA207_HTM_VSX>: New enum value. (init_registers_powerpc_isa207_htm_vsx32l) (init_registers_powerpc_isa207_htm_vsx64l): Declare. * linux-ppc-low.c (ppc_fill_tm_sprregset, ppc_store_tm_sprregset) (ppc_store_tm_cgprregset, ppc_store_tm_cfprregset) (ppc_store_tm_cvrregset, ppc_store_tm_cvsxregset) (ppc_store_tm_cpprregset, ppc_store_tm_cdscrregset) (ppc_store_tm_ctarregset): New functions. (ppc_regsets): Add entries for HTM regsets. (ppc_arch_setup): Set htm in features struct when needed. Set sizes for the HTM regsets. (ppc_get_ipa_tdesc_idx): Return PPC_TDESC_ISA207_HTM_VSX. (initialize_low_arch): Call init_registers_powerpc_isa207_htm_vsx32l and init_registers_powerpc_isa207_htm_vsx64l. * linux-ppc-ipa.c (get_ipa_tdesc): Handle PPC_TDESC_ISA207_HTM_VSX. (initialize_low_tracepoint): Call init_registers_powerpc_isa207_htm_vsx32l and init_registers_powerpc_isa207_htm_vsx64l. gdb/testsuite/ChangeLog: 2018-10-26 Pedro Franco de Carvalho <pedromfc@linux.ibm.com> * gdb.arch/powerpc-htm-regs.c: New file. * gdb.arch/powerpc-htm-regs.exp: New file. gdb/doc/ChangeLog: 2018-10-26 Pedro Franco de Carvalho <pedromfc@linux.ibm.com> * gdb.texinfo (PowerPC Features): Describe new features "org.gnu.gdb.power.htm.spr", "org.gnu.gdb.power.htm.core", "org.gnu.gdb.power.htm.fpu", "org.gnu.gdb.power.htm.altivec", "org.gnu.gdb.power.htm.vsx", "org.gnu.gdb.power.htm.ppr", "org.gnu.gdb.power.htm.dscr", "org.gnu.gdb.power.htm.tar".
2018-10-26[PowerPC] Add support for TAREdjunior Barbosa Machado2-0/+155
This patch adds support for the Target Address Register for powerpc linux native and core file targets, and in the powerpc linux server stub. gdb/ChangeLog: 2018-10-26 Edjunior Barbosa Machado <emachado@linux.vnet.ibm.com> Pedro Franco de Carvalho <pedromfc@linux.ibm.com> * arch/ppc-linux-tdesc.h (tdesc_powerpc_isa207_vsx32l) (tdesc_powerpc_isa207_vsx64l): Declare. * arch/ppc-linux-common.h (PPC_LINUX_SIZEOF_TARREGSET): Define. (struct ppc_linux_features) <isa207>: New field. (ppc_linux_no_features): Add initializer for isa207 field. * arch/ppc-linux-common.c (ppc_linux_match_description): Return new tdescs. * nat/ppc-linux.h (PPC_FEATURE2_ARCH_2_07, PPC_FEATURE2_TAR) (NT_PPC_TAR): Define if not already defined. * features/Makefile (WHICH): Add rs6000/powerpc-isa207-vsx32l and rs6000/powerpc-isa207-vsx64l. (XMLTOC): Add rs6000/powerpc-isa207-vsx32l.xml and rs6000/powerpc-isa207-vsx64l.xml. * features/rs6000/power-tar.xml: New file. * features/rs6000/powerpc-isa207-vsx32l.xml: New file. * features/rs6000/powerpc-isa207-vsx64l.xml: New file. * features/rs6000/powerpc-isa207-vsx32l.c: Generate. * features/rs6000/powerpc-isa207-vsx64l.c: Generate. * regformats/rs6000/powerpc-isa207-vsx32l.dat: Generate. * regformats/rs6000/powerpc-isa207-vsx64l.dat: Generate. * ppc-linux-nat.c (fetch_register, fetch_ppc_registers): Call fetch_regset with the TAR regset. (store_register, store_ppc_registers): Call store_regset with the TAR regset. (ppc_linux_nat_target::read_description): Set isa207 field in the features struct if needed. * ppc-linux-tdep.c: Include features/rs6000/powerpc-isa207-vsx32l.c and features/rs6000/powerpc-isa207-vsx64l.c. (ppc32_regmap_tar, ppc32_linux_tarregset): New globals. (ppc_linux_iterate_over_regset_sections): Call back with the tar regset. (ppc_linux_core_read_description): Check if the tar section is present and set isa207 in the features struct. (_initialize_ppc_linux_tdep): Call initialize_tdesc_powerpc_isa207_vsx32l and initialize_tdesc_powerpc_isa207_vsx64l. * ppc-linux-tdep.h (ppc32_linux_tarregset): Declare. * ppc-tdep.h (gdbarch_tdep) <ppc_tar_regnum>: New field. (enum) <PPC_TAR_REGNUM>: New enum value. * rs6000-tdep.c (rs6000_gdbarch_init): Look for and validate tar feature. (ppc_process_record_op31): Record changes to TAR. gdb/gdbserver/ChangeLog: 2018-10-26 Pedro Franco de Carvalho <pedromfc@linux.ibm.com> * configure.srv (ipa_ppc_linux_regobj): Add powerpc-isa207-vsx64l-ipa.o and powerpc-isa207-vsx32l-ipa.o. (powerpc*-*-linux*): Add powerpc-isa207-vsx32l.o and powerpc-isa207-vsx64l.o to srv_regobj, add rs6000/power-tar.xml, rs6000/powerpc-isa207-vsx32l.xml, and rs6000/powerpc-isa207-vsx64l.xml to srv_xmlfiles. * linux-ppc-tdesc-init.h (enum ppc_linux_tdesc) <PPC_TDESC_ISA207_VSX>: New enum value. (init_registers_powerpc_isa207_vsx32l): Declare. (init_registers_powerpc_isa207_vsx64l): Declare. * linux-ppc-low.c (ppc_fill_tarregset): New function. (ppc_store_tarregset): New function. (ppc_regsets): Add entry for the TAR regset. (ppc_arch_setup): Set isa207 in features struct when needed. Set size for the TAR regsets. (ppc_get_ipa_tdesc_idx): Return PPC_TDESC_ISA207_VSX. (initialize_low_arch): Call init_registers_powerpc_isa207_vsx32l and init_registers_powerpc_isa207_vsx64l. * linux-ppc-ipa.c (get_ipa_tdesc): Handle PPC_TDESC_ISA207_VSX. (initialize_low_tracepoint): Call init_registers_powerpc_isa207_vsx32l and init_registers_powerpc_isa207_vsx64l. gdb/testsuite/ChangeLog: 2018-10-26 Pedro Franco de Carvalho <pedromfc@linux.ibm.com> * gdb.arch/powerpc-tar.c: New file. * gdb.arch/powerpc-tar.exp: New file. gdb/doc/ChangeLog: 2018-10-26 Pedro Franco de Carvalho <pedromfc@linux.ibm.com> * gdb.texinfo (PowerPC Features): Describe new feature "org.gnu.gdb.power.tar".
2018-10-26[PowerPC] Add support for PPR and DSCREdjunior Barbosa Machado2-0/+154
This patch adds gdb support for the Program Priorty Register and the Data Stream Control Register, for the powerpc linux native and core file targets, and for the powerpc linux server stub. gdb/ChangeLog: 2018-10-26 Edjunior Barbosa Machado <emachado@linux.vnet.ibm.com> Pedro Franco de Carvalho <pedromfc@linux.ibm.com> * arch/ppc-linux-tdesc.h (tdesc_powerpc_isa205_ppr_dscr_vsx32l) (tdesc_powerpc_isa205_ppr_dscr_vsx64l): Declare. * arch/ppc-linux-common.h (PPC_LINUX_SIZEOF_PPRREGSET) (PPC_LINUX_SIZEOF_DSCRREGSET): Define. (struct ppc_linux_features) <ppr_dscr>: New field. (ppc_linux_no_features): Add initializer for ppr_dscr field. * arch/ppc-linux-common.c (ppc_linux_match_description): Return new tdescs. * nat/ppc-linux.h (PPC_FEATURE2_DSCR, NT_PPC_PPR, NT_PPC_DSCR): Define if not already defined. * features/Makefile (WHICH): Add rs6000/powerpc-isa205-ppr-dscr-vsx32l and rs6000/powerpc-isa205-ppr-dscr-vsx64l. (XMLTOC): Add rs6000/powerpc-isa205-ppr-dscr-vsx32l.xml and rs6000/powerpc-isa205-ppr-dscr-vsx64l.xml. * features/rs6000/power-dscr.xml: New file. * features/rs6000/power-ppr.xml: New file. * features/rs6000/powerpc-isa205-ppr-dscr-vsx32l.xml: New file. * features/rs6000/powerpc-isa205-ppr-dscr-vsx64l.xml: New file. * features/rs6000/powerpc-isa205-ppr-dscr-vsx32l.c: Generate. * features/rs6000/powerpc-isa205-ppr-dscr-vsx64l.c: Generate. * regformats/rs6000/powerpc-isa205-ppr-dscr-vsx32l.dat: Generate. * regformats/rs6000/powerpc-isa205-ppr-dscr-vsx64l.dat: Generate. * ppc-linux-nat.c: Include <sys/uio.h>. (fetch_regset, store_regset, check_regset): New functions. (fetch_register, fetch_ppc_registers): Call fetch_regset with DSCR and PPR regsets. (store_register, store_ppc_registers): Call store_regset with DSCR and PPR regsets. (ppc_linux_get_hwcap2): New function. (ppc_linux_nat_target::read_description): Call ppc_linux_get_hwcap2 and check_regset, set ppr_dscr field in the features struct if needed. * ppc-linux-tdep.c: Include features/rs6000/powerpc-isa205-ppr-dscr-vsx32l.c and features/rs6000/powerpc-isa205-ppr-dscr-vsx64l.c. (ppc32_regmap_ppr, ppc32_regmap_dscr, ppc32_linux_pprregset) (ppc32_linux_dscrregset): New globals. (ppc_linux_iterate_over_regset_sections): Call back with the ppr and dscr regsets. (ppc_linux_core_read_description): Check if the ppr and dscr sections are present and set ppr_dscr in the features struct. (_initialize_ppc_linux_tdep): Call initialize_tdesc_powerpc_isa205_ppr_dscr_vsx32l and initialize_tdesc_powerpc_isa205_ppr_dscr_vsx64l. * ppc-linux-tdep.h (ppc32_linux_pprregset) (ppc32_linux_dscrregset): Declare. * ppc-tdep.h (struct gdbarch_tdep) <ppc_ppr_regnum>: New field. <ppc_dscr_regnum>: New field. (enum) <PPC_PPR_REGNUM, PPC_DSCR_REGNUM>: New enum values. * rs6000-tdep.c (rs6000_gdbarch_init): Look for and validate ppr and dscr features. (ppc_process_record_op31): Record changes to PPR and DSCR. gdb/gdbserver/ChangeLog: 2018-10-26 Edjunior Barbosa Machado <emachado@linux.vnet.ibm.com> Pedro Franco de Carvalho <pedromfc@linux.ibm.com> * configure.srv (ipa_ppc_linux_regobj): Add powerpc-isa205-ppr-dscr-vsx32l-ipa.o and powerpc-isa205-ppr-dscr-vsx64l-ipa.o. (powerpc*-*-linux*): Add powerpc-isa205-ppr-dscr-vsx32l.o and powerpc-isa205-ppr-dscr-vsx64l.o to srv_regobj, add rs6000/power-dscr.xml, rs6000/power-ppr.xml, rs6000/powerpc-isa205-ppr-dscr-vsx32l.xml and rs6000/powerpc-isa205-ppr-dscr-vsx64l.xml to srv_xmlfiles. * linux-ppc-tdesc-init.h (enum ppc_linux_tdesc) <PPC_TDESC_ISA205_PPR_DSCR_VSX>: New enum value. (init_registers_powerpc_isa205_ppr_dscr_vsx32l) (init_registers_powerpc_isa205_ppr_dscr_vsx64l): Declare. * linux-ppc-low.c: Include "elf/common.h" and <sys/uio.h>. (ppc_hwcap): Add comment. (ppc_hwcap2): New global. (ppc_check_regset, ppc_fill_pprregset, ppc_store_pprregset) (ppc_fill_dscrregset, ppc_store_dscrregset): New functions. (ppc_regsets): Add entries for the DSCR and PPR regsets. (ppc_arch_setup): Get AT_HWCAP2. Set ppr_dscr in features struct when needed. Set sizes for the the DSCR and PPR regsets. (ppc_get_ipa_tdesc_idx): Return PPC_TDESC_ISA205_PPR_DSCR_VSX. (initialize_low_arch): Call init_registers_powerpc_isa205_ppr_dscr_vsx32l and init_registers_powerpc_isa205_ppr_dscr_vsx64l. * linux-ppc-ipa.c (get_ipa_tdesc): Handle PPC_TDESC_ISA205_PPR_DSCR_VSX. (initialize_low_tracepoint): Call init_registers_powerpc_isa205_ppr_dscr_vsx32l and init_registers_powerpc_isa205_ppr_dscr_vsx64l. gdb/testsuite/ChangeLog: 2018-10-26 Pedro Franco de Carvalho <pedromfc@linux.ibm.com> * gdb.arch/powerpc-ppr-dscr.c: New file. * gdb.arch/powerpc-ppr-dscr.exp: New file. gdb/doc/ChangeLog: 2018-10-26 Pedro Franco de Carvalho <pedromfc@linux.ibm.com> * gdb.texinfo (PowerPC Features): Describe new features "org.gnu.gdb.power.ppr" and "org.gnu.gdb.power.dscr".
2018-10-23gdb/riscv: Fix register access for register aliasesAndrew Burgess2-0/+152
Some confusion over how the register names and aliases are setup in riscv means that we currently can't access registers through their architectural name. This commit fixes this issue, and moves some of the csr register handling out of the alias handling code and deals with it separately. This has the benefit that we can now directly access some arrays rather than having to iterate over them. A new test is added to ensure that register aliases now work correctly. gdb/ChangeLog: * riscv-tdep.c (riscv_gdb_reg_names): Update comment, and all register names. (struct register_alias): Rename to... (struct riscv_register_alias): ...this, and update comment. (riscv_register_aliases): Update type, and alias names. Remove CSR names from this list. (riscv_register_name): Use riscv_gdb_reg_names for int and float register names. Add an extra assertion. (riscv_is_regnum_a_named_csr): New function. (riscv_register_reggroup_p): Use riscv_is_regnum_a_named_csr. gdb/testsuite/ChangeLog: * gdb.arch/riscv-reg-aliases.c: New file. * gdb.arch/riscv-reg-aliases.exp: New file.
2018-10-18[gdb/testsuite] Fix capitalized test namesTom de Vries2-2/+2
At https://sourceware.org/gdb/wiki/GDBTestcaseCookbook\ #Follow_the_test_name_convention we find: .. Test names should start with a lower case and don't need to end with a period (they are not sentences). ... Fix some capitalized test names. Tested on x86_64-linux. 2018-10-18 Tom de Vries <tdevries@suse.de> * gdb.ada/bp_inlined_func.exp: Fix capitalized test name. * gdb.ada/excep_handle.exp: Same. * gdb.ada/mi_string_access.exp: Same. * gdb.ada/mi_var_union.exp: Same. * gdb.arch/arc-analyze-prologue.exp: Same. * gdb.arch/arc-decode-insn.exp: Same. * gdb.base/readnever.exp: Same. * gdb.fortran/printing-types.exp: Same. * gdb.guile/scm-lazy-string.exp: Same.
2018-10-01Fix is_amd64_regs_target check in i386-avx512.expSimon Marchi1-2/+2
As reported by Jan here: https://sourceware.org/ml/gdb-patches/2018-09/msg00831.html the check that sets the number of available registers is backwards. gdb/testsuite/ChangeLog: * gdb.arch/i386-avx512.exp: Fix setting of nr_regs based on is_amd64_regs_target.
2018-10-01Add aarch64-sighandler-regs.exp testAlan Hayward2-0/+336
Add Aarch64 test to check register values of a previous frame can be shown correctly across a signal. gdb/testsuite/ChangeLog: * gdb.arch/aarch64-sighandler-regs.c: New test. * gdb.arch/aarch64-sighandler-regs.exp: New file. * lib/gdb.exp (skip_aarch64_sve_tests): New proc.
2018-09-18Expect optional "arch=" when executing "-stack-list-frames" on ↵Sergio Durigan Junior1-2/+2
gdb.arch/amd64-invalid-stack-top.exp Another case of incomplete regexp. The problem is very similar to the one happening with gdb.arch/amd64-invalid-stack-middle.exp. The output when GDB is compiled with "--enable-targets" is: (gdb) interpreter-exec mi "-stack-list-frames" ^done,stack=[frame={level="0",addr="0x00000000004005e7",func="func2",arch="i386:x86-64"}] While the output when "--enable-targets" is not specified is: (gdb) interpreter-exec mi "-stack-list-frames" ^done,stack=[frame={level="0",addr="0x00000000004005e7",func="func2"}] The fix is, again, to extend the current regexp and expect for the optional "arch=" part. With this patch, the test now passes on both scenarios. OK? gdb/testsuite/ChangeLog: 2018-09-18 Sergio Durigan Junior <sergiodj@redhat.com> * gdb.arch/amd64-invalid-stack-top.exp: Expect optional "arch=" keyword when executing "-stack-list-frames".
2018-09-18Expect optional "arch=" when executing "-stack-list-frames" on ↵Sergio Durigan Junior1-2/+2
gdb.arch/amd64-invalid-stack-middle.exp While regression-testing GDB on Fedora Rawhide, I saw the following output when running gdb.arch/amd64-invalid-stack-middle.exp's "-stack-list-frames" test: (gdb) interpreter-exec mi "-stack-list-frames" ^done,stack=[frame={level="0",addr="0x000000000040115a",func="breakpt",file="amd64-invalid-stack-middle.c",fullname="/home/sergio/fedora/gdb/master/gdb-8.2.50.20180917/gdb/testsuite/gdb.arch/amd64-invalid-stack-middle.c",line="27",arch="i386:x86-64"},frame={level="1",addr="0x000000000040116a",func="func5",file="amd64-invalid-stack-middle.c",fullname="/home/sergio/fedora/gdb/master/gdb-8.2.50.20180917/gdb/testsuite/gdb.arch/amd64-invalid-stack-middle.c",line="32",arch="i386:x86-64"},frame={level="2",addr="0x000000000040117a",func="func4",file="amd64-invalid-stack-middle.c",fullname="/home/sergio/fedora/gdb/master/gdb-8.2.50.20180917/gdb/testsuite/gdb.arch/amd64-invalid-stack-middle.c",line="38",arch="i386:x86-64"},frame={level="3",addr="0x000000000040118a",func="func3",file="amd64-invalid-stack-middle.c",fullname="/home/sergio/fedora/gdb/master/gdb-8.2.50.20180917/gdb/testsuite/gdb.arch/amd64-invalid-stack-middle.c",line="44",arch="i386:x86-64"}] This test is currently failing on Rawhide. However, this output is almost the same as I get on my local Fedora 28 machine (where the test is passing): (gdb) interpreter-exec mi "-stack-list-frames" ^done,stack=[frame={level="0",addr="0x00000000004005da",func="breakpt",file="amd64-invalid-stack-middle.c",fullname="/home/sergio/work/src/git/binutils-gdb/binutils-gdb/gdb/testsuite/gdb.arch/amd64-invalid-stack-middle.c",line="27"},frame={level="1",addr="0x00000000004005ea",func="func5",file="amd64-invalid-stack-middle.c",fullname="/home/sergio/work/src/git/binutils-gdb/binutils-gdb/gdb/testsuite/gdb.arch/amd64-invalid-stack-middle.c",line="32"},frame={level="2",addr="0x00000000004005fa",func="func4",file="amd64-invalid-stack-middle.c",fullname="/home/sergio/work/src/git/binutils-gdb/binutils-gdb/gdb/testsuite/gdb.arch/amd64-invalid-stack-middle.c",line="38"},frame={level="3",addr="0x000000000040060a",func="func3",file="amd64-invalid-stack-middle.c",fullname="/home/sergio/work/src/git/binutils-gdb/binutils-gdb/gdb/testsuite/gdb.arch/amd64-invalid-stack-middle.c",line="44"}] With the exception that there's an "arch=" keyword on Fedora Rawhide's version. This is because, on Rawhide, I've compiled GDB with "--enable-targets=xyz,kqp,etc.", while locally I haven't. This is easy to fix: we just have to extend the regexp and expect for the optional "arch=" keyword there. It's what this patch does. With it applied, the test now passes everywhere. OK? gdb/testsuite/ChangeLog: 2018-09-18 Sergio Durigan Junior <sergiodj@redhat.com> * gdb.arch/amd64-invalid-stack-middle.exp: Expect optional "arch=" keyword when executing "-stack-list-frames".
2018-08-17Fix asm in testsuite/gdb.arch/aarch64-fp.cAlan Hayward1-5/+11
Cannot assume result of first and third ldr will go into x0. Rewrite asm to be clearer. gdb/testsuite/ PR gdb/18931: * gdb.arch/aarch64-fp.c (main): Fix asm registers.
2018-07-02GDB PR tdep/8282: MIPS: Wire in `set disassembler-options'Maciej W. Rozycki2-0/+88
Implement MIPS target support for passing options to the disassembler, complementing commit 65b48a81404c ("GDB: Add support for the new set/show disassembler-options commands."). This includes options that expect an argument, so adjust the generic code and data structures used so as to handle such options. So as to give backends syntax flexibility no specific delimiter has been defined to separate options from their respective arguments, so it has to be included as the last character of the option name. Completion code however has not been adjusted and consequently option arguments cannot be completed at this time. Also the MIPS target has non-empty defaults for the options, so that ABI names for the general-purpose registers respect our `set mips abi ...' setting rather than always being determined from the ELF headers of the binary file selected. Handle these defaults as implicit options, never shown to the user and always prepended to the user-specified options, so that the latters can override the defaults. The resulting output for the MIPS target is as follows: (gdb) show disassembler-options The current disassembler options are '' The following disassembler options are supported for use with the 'set disassembler-options <option>[,<option>...]' command: no-aliases Use canonical instruction forms. msa Recognize MSA instructions. virt Recognize the virtualization ASE instructions. xpa Recognize the eXtended Physical Address (XPA) ASE instructions. ginv Recognize the Global INValidate (GINV) ASE instructions. gpr-names=ABI Print GPR names according to specified ABI. Default: based on binary being disassembled. fpr-names=ABI Print FPR names according to specified ABI. Default: numeric. cp0-names=ARCH Print CP0 register names according to specified architecture. Default: based on binary being disassembled. hwr-names=ARCH Print HWR names according to specified architecture. Default: based on binary being disassembled. reg-names=ABI Print GPR and FPR names according to specified ABI. reg-names=ARCH Print CP0 register and HWR names according to specified architecture. For the options above, the following values are supported for "ABI": numeric 32 n32 64 For the options above, the following values are supported for "ARCH": numeric r3000 r3900 r4000 r4010 vr4100 vr4111 vr4120 r4300 r4400 r4600 r4650 r5000 vr5400 vr5500 r5900 r6000 rm7000 rm9000 r8000 r10000 r12000 r14000 r16000 mips5 mips32 mips32r2 mips32r3 mips32r5 mips32r6 mips64 mips64r2 mips64r3 mips64r5 mips64r6 interaptiv-mr2 sb1 loongson2e loongson2f loongson3a octeon octeon+ octeon2 octeon3 xlr xlp (gdb) which corresponds to what `objdump --help' used to print for the MIPS target, with minor formatting changes, most notably option argument lists being wrapped, but also the amount of white space separating options from the respective descriptions. The relevant part the new code is now also used by `objdump --help', which means these formatting changes apply to both outputs, except for argument list wrapping, which is GDB-specific. This also adds a separating new line between the heading and option lists where descriptions are provided, hence: (gdb) set architecture s390:31-bit (gdb) show disassembler-options The current disassembler options are '' The following disassembler options are supported for use with the 'set disassembler-options <option>[,<option>...]' command: esa Disassemble in ESA architecture mode zarch Disassemble in z/Architecture mode insnlength Print unknown instructions according to length from first two bits (gdb) but: (gdb) set architecture powerpc:common (gdb) show disassembler-options The current disassembler options are '' The following disassembler options are supported for use with the 'set disassembler-options <option>[,<option>...]' command: 403, 405, 440, 464, 476, 601, 603, 604, 620, 7400, 7410, 7450, 7455, 750cl, 821, 850, 860, a2, altivec, any, booke, booke32, cell, com, e200z4, e300, e500, e500mc, e500mc64, e5500, e6500, e500x2, efs, efs2, power4, power5, power6, power7, power8, power9, ppc, ppc32, 32, ppc64, 64, ppc64bridge, ppcps, pwr, pwr2, pwr4, pwr5, pwr5x, pwr6, pwr7, pwr8, pwr9, pwrx, raw, spe, spe2, titan, vle, vsx (gdb) Existing affected target backends have been adjusted accordingly. This has been verified manually with: (gdb) set architecture arm (gdb) set architecture powerpc:common (gdb) set architecture s390:31-bit to cause no issues with the `show disassembler-options' and `set disassembler-options' commands. A test case for the MIPS target has also been provided, covering the default settings with ABI overrides as well as disassembler option overrides. 2018-07-02 Maciej W. Rozycki <macro@mips.com> Simon Marchi <simon.marchi@polymtl.ca> include/ PR tdep/8282 * dis-asm.h (disasm_option_arg_t): New typedef. (disasm_options_and_args_t): Likewise. (disasm_options_t): Add `arg' member, document members. (disassembler_options_mips): New prototype. (disassembler_options_arm, disassembler_options_powerpc) (disassembler_options_s390): Update prototypes. opcodes/ PR tdep/8282 * mips-dis.c (mips_option_arg_t): New enumeration. (mips_options): New variable. (disassembler_options_mips): New function. (print_mips_disassembler_options): Reimplement in terms of `disassembler_options_mips'. * arm-dis.c (disassembler_options_arm): Adapt to using the `disasm_options_and_args_t' structure. * ppc-dis.c (disassembler_options_powerpc): Likewise. * s390-dis.c (disassembler_options_s390): Likewise. gdb/ PR tdep/8282 * disasm.h (gdb_disassembler): Add `m_disassembler_options_holder'. member * disasm.c (get_all_disassembler_options): New function. (gdb_disassembler::gdb_disassembler): Use it. (gdb_buffered_insn_length_init_dis): Likewise. (gdb_buffered_insn_length): Adjust accordingly. (set_disassembler_options): Handle options with arguments. (show_disassembler_options_sfunc): Likewise. Add a leading new line if showing options with descriptions. (disassembler_options_completer): Adapt to using the `disasm_options_and_args_t' structure. * mips-tdep.c (mips_disassembler_options): New variable. (mips_disassembler_options_o32): Likewise. (mips_disassembler_options_n32): Likewise. (mips_disassembler_options_n64): Likewise. (gdb_print_insn_mips): Don't set `disassembler_options'. (gdb_print_insn_mips_n32, gdb_print_insn_mips_n64): Remove functions. (mips_gdbarch_init): Always set `gdbarch_print_insn' to `gdb_print_insn_mips'. Set `gdbarch_disassembler_options', `gdbarch_disassembler_options_implicit' and `gdbarch_valid_disassembler_options'. * arm-tdep.c (_initialize_arm_tdep): Adapt to using the `disasm_options_and_args_t' structure. * gdbarch.sh (disassembler_options_implicit): New `gdbarch' method. (valid_disassembler_options): Switch from `disasm_options_t' to the `disasm_options_and_args_t' structure. * NEWS: Document `set disassembler-options' support for the MIPS target. * gdbarch.h: Regenerate. * gdbarch.c: Regenerate. gdb/doc/ PR tdep/8282 * gdb.texinfo (Source and Machine Code): Document `set disassembler-options' support for the MIPS target. gdb/testsuite/ PR tdep/8282 * gdb.arch/mips-disassembler-options.exp: New test. * gdb.arch/mips-disassembler-options.s: New test source.
2018-05-25MIPS/Linux: Correct o32 core file FGR interpretationMaciej W. Rozycki2-0/+236
Our interpretation of the layout of floating-point general registers (FGRs) in o32 MIPS/Linux core files is different from how the kernel makes them, affecting the CP0 Status.FR=0 aka FP32 mode (we don't currently support the CP0 Status.FR=1 aka FP64 mode with the o32 ABI). In the FP32 mode pairs of consecutive even/odd-numbered 32-bit registers are placed together as 64-bit values in even-indexed 64-bit slots corresponding to the even index, leaving the odd-indexed 64-bit slots unused. These 64-bit values are stored according to the endianness in effect, which is how the MIPS II SDC1 instruction would store them. It has always been like that with the Linux kernel for MIPS II and higher ISA processors, which are the vast majority ever supported, as it is indeed SDC1 that the kernel uses to store FGRs in a floating-point context. With MIPS I processors, which lack the SDC1 instruction, a layout that we expect used to be used long ago, but it was corrected for consistency with newer processors back in 2002, with `linux-mips.org' (LMO) commit 42533948caac ("Major pile of FP emulator changes."), the fix corrected with LMO commit 849fa7a50dff ("R3k FPU ptrace() handling fixes."), and then broken and fixed over and over again, until last time fixed with commit 80cbfad79096 ("MIPS: Correct MIPS I FP context layout"). Consequently the values we see in FP32 core files or produce with the `gcore' command are different from those obtained from the same FP context of a live process, e.g. with a big-endian configuration these live values: (gdb) info registers float f0: 0x4b5c6d7e flt: 14445950 dbl: 1.7446153562345001e-274 f1: 0x0718293a flt: 1.14473244e-34 f2: 0xc3d4e5f6 flt: -425.79657 dbl: -1.046160437414959e-233 f3: 0x8f90a1b2 flt: -1.42617791e-29 f4: 0x4c5d6e7f flt: 58046972 dbl: 1.1908587841220294e-269 f5: 0x08192a3b flt: 4.60914044e-34 f6: 0xc4d5e6f7 flt: -1711.21765 dbl: -6.2784661835068965e-306 f7: 0x8091a2b3 flt: -1.33745124e-38 f8: 0x45566778 flt: 3430.4668 dbl: 1.6530355595710607e-303 f9: 0x01122334 flt: 2.68412219e-38 f10: 0xcddeeff0 flt: -467533312 dbl: -2.1174864564135575e-262 f11: 0x899aabbc flt: -3.72356497e-33 f12: 0x46576879 flt: 13786.1182 dbl: 1.143296486773654e-298 f13: 0x02132435 flt: 1.08102453e-37 f14: 0xcedfe0f1 flt: -1.87803046e+09 dbl: -1.4399511533369862e-257 f15: 0x8a9bacbd flt: -1.4990934e-32 f16: 0x4758697a flt: 55401.4766 dbl: 7.8856820439568725e-294 f17: 0x03142536 flt: 4.3536007e-37 f18: 0xcfd0e1f2 flt: -7.00893696e+09 dbl: -9.7791926757340559e-253 f19: 0x8b9cadbe flt: -6.03504325e-32 f20: 0x48596a7b flt: 222633.922 dbl: 5.4255001483306113e-289 f21: 0x04152637 flt: 1.75324132e-36 f22: 0xc0d1e2f3 flt: -6.55895376 dbl: -6.6332401002310683e-248 f23: 0x8c9daebf flt: -2.42948516e-31 f24: 0x495a6b7c flt: 894647.75 dbl: 3.7244369058749787e-284 f25: 0x05162738 flt: 7.06016945e-36 f26: 0xc1d2e3f4 flt: -26.3613052 dbl: -4.4941535759306202e-243 f27: 0x8d9eafb0 flt: -9.77979703e-31 f28: 0x4a5b6c7d flt: 3595039.25 dbl: 2.5514593711161396e-279 f29: 0x06172839 flt: 2.84294945e-35 f30: 0xc2d3e4f5 flt: -105.947182 dbl: -3.035646690850097e-238 f31: 0x8e9fa0b1 flt: -3.93512664e-30 fcsr: 0x0 fir: 0xf30000 (gdb) show up in a core file as these: (gdb) info registers float f0: 0x0718293a flt: 1.14473244e-34 dbl: nan f1: 0x7ff80000 flt: nan f2: 0x8f90a1b2 flt: -1.42617791e-29 dbl: nan f3: 0x7ff80000 flt: nan f4: 0x08192a3b flt: 4.60914044e-34 dbl: nan f5: 0x7ff80000 flt: nan f6: 0x8091a2b3 flt: -1.33745124e-38 dbl: nan f7: 0x7ff80000 flt: nan f8: 0x01122334 flt: 2.68412219e-38 dbl: nan f9: 0x7ff80000 flt: nan f10: 0x899aabbc flt: -3.72356497e-33 dbl: nan f11: 0x7ff80000 flt: nan f12: 0x02132435 flt: 1.08102453e-37 dbl: nan f13: 0x7ff80000 flt: nan f14: 0x8a9bacbd flt: -1.4990934e-32 dbl: nan f15: 0x7ff80000 flt: nan f16: 0x03142536 flt: 4.3536007e-37 dbl: nan f17: 0x7ff80000 flt: nan f18: 0x8b9cadbe flt: -6.03504325e-32 dbl: nan f19: 0x7ff80000 flt: nan f20: 0x04152637 flt: 1.75324132e-36 dbl: nan f21: 0x7ff80000 flt: nan f22: 0x8c9daebf flt: -2.42948516e-31 dbl: nan f23: 0x7ff80000 flt: nan f24: 0x05162738 flt: 7.06016945e-36 dbl: nan f25: 0x7ff80000 flt: nan f26: 0x8d9eafb0 flt: -9.77979703e-31 dbl: nan f27: 0x7ff80000 flt: nan f28: 0x06172839 flt: 2.84294945e-35 dbl: nan f29: 0x7ff80000 flt: nan f30: 0x8e9fa0b1 flt: -3.93512664e-30 dbl: nan f31: 0x7ff80000 flt: nan (gdb) Notice how values from odd-numbered registers are shown in corresponding even-numbered registers and how dummy 0x7ff80000 NaN values, which the kernel places in unused slots, are reported in odd-numbered registers. Correct our intepretation then, to match the kernel's. As it happens the o32 FGR core file representation matches that used by the `ptrace' PTRACE_GETFPREGS request, which means our 64-bit handlers can be readily used, as they already correctly handle the differences between o32 FP32 mode vs n32/n64 representations. Adjust comments accordingly throughout, in particular remove a reference to the r3000/tx39 MIPS I processor peculiarity, long irrelevant. Add a test case to verify correctness. Avoid GCC bugs and limitations in the test case where possible; the test case still fails to build with GCC 8 and the o32 FP64 mode (i.e. with `-mips32r2 -mfp64' options) giving: mips-fpregset-core.c: In function 'main': mips-fpregset-core.c:66:3: error: inconsistent operand constraints in an 'asm' asm ( ^~~ (GCC PR target/85909), but that is not a concern for us as yet, because as noted above we do not currently support the o32 FP64 mode anyway. gdb/ * mips-linux-tdep.h (mips_supply_fpregset, mips_fill_fpregset): Remove prototypes. * mips-linux-nat.c (supply_fpregset): Always call `mips64_supply_fpregset' rather than `mips_supply_fpregset'. (fill_fpregset): Always call `mips64_fill_fpregset' rather than `mips_fill_fpregset'. * mips-linux-tdep.c (mips_supply_fpregset) (mips_supply_fpregset_wrapper, mips_fill_fpregset) (mips_fill_fpregset_wrapper): Remove functions. (mips64_supply_fpregset, mips64_fill_fpregset): Update comments. (mips_linux_fpregset): Remove variable. (mips_linux_iterate_over_regset_sections): Use `mips64_linux_fpregset' in place of `mips_linux_fpregset'. (mips_linux_o32_sigframe_init): Remove comment. gdb/testsuite/ * gdb.arch/mips-fpregset-core.exp: New test. * gdb.arch/mips-fpregset-core.c: New test source.
2018-05-22[PowerPC] Recognize isa205 in linux core filesPedro Franco de Carvalho1-0/+93
Currently the ppc linux core file target doesn't return target descriptions with the lager FPSCR introduced in isa205. This patch changes the core file target so that the auxv is read from the core file to determine the size of FPSCR, so that the appropriate target description is selected. gdb/ChangeLog: 2018-05-22 Pedro Franco de Carvalho <pedromfc@linux.vnet.ibm.com> * arch/ppc-linux-common.c (ppc_linux_has_isa205): Change the parameter type to CORE_ADDR. * arch/ppc-linux-common.h (ppc_linux_has_isa205): Change the parameter type in declaration to CORE_ADDR. * ppc-linux-tdep.c (ppc_linux_core_read_description): Call target_auxv_search to get AT_HWCAP and use the result to get the target description. * ppc-linux-nat.c (ppc_linux_get_hwcap): Change the return type to CORE_ADDR. Remove the cast of the return value to unsigned long. Fix error predicate of target_auxv_search. (ppc_linux_nat_target::read_description): Change the type of the hwcap variable to CORE_ADDR. gdb/testsuite/ChangeLog: 2018-05-22 Pedro Franco de Carvalho <pedromfc@linux.vnet.ibm.com> * gdb.arch/powerpc-fpscr-gcore.exp: New file.
2018-05-22[PowerPC] Fix VSX registers in linux core filesPedro Franco de Carvalho1-0/+90
The functions used by the VSX regset to collect and supply registers from core files where incorrect. This patch changes the regset to use the standard regset collect/supply functions to fix this. The native target is also changed to use the same regset. gdb/ChangeLog: 2018-05-22 Pedro Franco de Carvalho <pedromfc@linux.vnet.ibm.com> * ppc-linux-tdep.c (ppc_linux_vsxregset): New function. (ppc32_linux_vsxregmap): New global. (ppc32_linux_vsxregset): Initialize with ppc32_linux_vsxregmap, regcache_supply_regset, and regcache_collect_regset. * ppc-linux-tdep.h (ppc_linux_vsxregset): Declare. * ppc-linux-nat.c (supply_vsxregset, fill_vsxregset): Remove. (fetch_vsx_register, store_vsx_register): Remove. (fetch_vsx_registers): Add regno parameter. Get regset using ppc_linux_vsxregset. Use regset to supply registers. (store_vsx_registers): Add regno parameter. Get regset using ppc_linux_vsxregset. Use regset to collect registers. (fetch_register): Call fetch_vsx_registers instead of fetch_vsx_register. (store_register): Call store_vsx_registers instead of store_vsx_register. (fetch_ppc_registers): Call fetch_vsx_registers with -1 for the new regno parameter. (store_ppc_registers): Call store_vsx_registers with -1 for the new regno parameter. * rs6000-tdep.c (ppc_vsx_support_p, ppc_supply_vsxreget) (ppc_collect_vsxregset): Remove. gdb/testsuite/ChangeLog: 2018-05-22 Pedro Franco de Carvalho <pedromfc@linux.vnet.ibm.com> * gdb.arch/powerpc-vsx-gcore.exp: New file.
2018-05-08gdb/x86: Handle kernels using compact xsave formatAndrew Burgess2-0/+206
For GNU/Linux on x86-64, if the target is using the xsave format for passing the floating-point information from the inferior then there currently exists a bug relating to the x87 control registers, and the mxcsr register. The xsave format allows different floating-point features to be lazily enabled, a bit in the xsave format tells GDB which floating-point features have been enabled, and which have not. Currently in GDB, when reading the floating point state, we check the xsave bit flags, if the feature is enabled then we read the feature from the xsave buffer, and if the feature is not enabled, then we supply the default value from within GDB. Within GDB, when writing the floating point state, we first fetch the xsave state from the target and then, for any feature that is not yet enabled, we write the default values into the xsave buffer. Next we compare the regcache value with the value in the xsave buffer, and, if the value has changed we update the value in the xsave buffer, and mark the feature enabled in the xsave bit flags. The problem then, is that the x87 control registers were not following this pattern. We assumed that these registers were always written out by the kernel, and we always wrote them out to the xsave buffer (but didn't enabled the feature). The result of this is that if the kernel had not yet enabled the x87 feature then within GDB we would see random values for the x87 floating point control registers, and if the user tried to modify one of these register, that modification would be lost. Finally, the mxcsr register was also broken in the same way as the x87 control registers. The added complexity with this case is that the mxcsr register is part of both the avx and sse floating point feature set. When reading or writing this register we need to check that at least one of these features is enabled. This bug was present in native GDB, and within gdbserver. Both are fixed with this commit. gdb/ChangeLog: * common/x86-xstate.h (I387_FCTRL_INIT_VAL): New constant. (I387_MXCSR_INIT_VAL): New constant. * amd64-tdep.c (amd64_supply_xsave): Only read state from xsave buffer if it was supplied by the inferior. * i387-tdep.c (i387_supply_fsave): Use I387_MXCSR_INIT_VAL. (i387_xsave_get_clear_bv): New function. (i387_supply_xsave): Only read x87 control registers from the xsave buffer if the feature is enabled, and the state will have been written, otherwise, provide a suitable default. (i387_collect_xsave): Pre-clear all registers in xsave buffer, including x87 control registers. Update control registers if they have changed from the default value, and mark features as enabled as required. * i387-tdep.h (i387_xsave_get_clear_bv): Declare. gdb/gdbserver/ChangeLog: * i387-fp.c (i387_cache_to_xsave): Only write x87 control registers to the cache if their values have changed. (i387_xsave_to_cache): Provide default values for x87 control registers when these features are available, but disabled. * regcache.c (supply_register_by_name_zeroed): New function. * regcache.h (supply_register_by_name_zeroed): Declare new function. gdb/testsuite/ChangeLog: * gdb.arch/amd64-init-x87-values.S: New file. * gdb.arch/amd64-init-x87-values.exp: New file.
2018-04-07Fix generation of x86-64 gdbarch with osabi none (PR 22979)Simon Marchi1-0/+43
When a 64-bits (x86-64) gdbarch is created, it is first born as a 32-bits gdbarch in i386_gdbarch_init. The call gdbarch_init_osabi will call the handler register for the selected (arch, osabi) pair, such as amd64_linux_init_abi. The various amd64 handlers call amd64_init_abi, which turns the gdbarch into a 64-bits one. When selecting the i386:x86-64 architecture with no osabi, no such handler is ever called, so the gdbarch stays (wrongfully) a 32-bits one. My first idea was to manually call amd64_init_abi & al in i386_gdbarch_init when the osabi is GDB_OSABI_NONE. However, this doesn't work in a build of GDB where i386 is included as a target but not amd64. My next option (implemented in this patch), is to allow registering handlers for GDB_OSABI_NONE. I added two such handlers in amd64-tdep.c, so now it works the same as for the "normal" osabis. It required re-ordering things in gdbarch_init_osabi to allow running handlers for GDB_OSABI_NONE. Without this patch applied (but with the previous one*) : (gdb) set osabi none (gdb) set architecture i386:x86-64 The target architecture is assumed to be i386:x86-64 (gdb) p sizeof(void*) $1 = 4 and now: (gdb) set osabi none (gdb) set architecture i386:x86-64 The target architecture is assumed to be i386:x86-64 (gdb) p sizeof(void*) $1 = 8 * Before the previous patch, which fixed "set osabi none", this bug was hidden because we didn't actually try to generate a gdbarch for no osabi, it would always fall back on Linux. Generating the gdbarch for amd64/linux did work. gdb/ChangeLog: PR gdb/22979 * amd64-tdep.c (amd64_none_init_abi): New function. (amd64_x32_none_init_abi): New function. (_initialize_amd64_tdep): Register handlers for x86-64 and x64_32 with GDB_OSABI_NONE. * osabi.c (gdbarch_init_osabi): Allow running handlers for the GDB_OSABI_NONE osabi. gdb/testsuite/ChangeLog: PR gdb/22979 * gdb.arch/amd64-osabi.exp: New file.
2018-03-23gdb: Fix testsuite issue in gdb.arch/amd64-disp-step-avx.expAndrew Burgess2-8/+24
This test starts up and confirms that $xmm0 has the value 0, it then modifies $xmm0 (in the inferior) and confirms that the new value can be read (in GDB). On some machines I was noticing that this test would occasionally fail, and on investigation I believe that the reason for this is that the test is linked as a dynamically linked executable and makes use of the system libraries during startup. The reason that this causes problems is that both the runtime linker and the startup code run before main can, and do (on at least some platforms) make use of the XMM registers. In this commit I modify the test program slightly to allow it to be linked statically, without using the startup libraries. Now by the time GDB reaches the symbol main we have only executed one 'nop' instruction, and the XMM registers should all have the value 0. I've extended the test script to confirm that $xmm0 to $xmm15 are all initially 0, and I also check that at the point after $xmm0 has been modified, all the other XMM registers ($xmm1 to $xmm15) are still 0. The test program is still linked against libc in order that we can call the exit function, however, we now call _exit rather than exit in order to avoid all of the usual cleanup that exit does. This clean up tries to tear down things that are usually setup during the startup code, but now this isn't called calling exit will just result in a crash. gdb/testsuite/ChangeLog: * gdb.arch/amd64-disp-step-avx.S: Add '_start' label. (done): Call '_exit' not 'exit' to avoid atexit handlers. * gdb.arch/amd64-disp-step-avx.exp: Pass -static, and -nostartfiles when compiling the test. Confirm that all registers xmm0 to xmm15 are initially 0, and that xmm1 to xmm15 are 0 after.
2018-03-23gdb: Minor cleanup in some gdb.arch/* testsAndrew Burgess5-33/+5
A small number of tests incorrectly tried to pass -Wa,-g through to GCC as an extra compile time flag, either to gdb_compile or prepare_for_testing. The problem is that the syntax used for passing the flags was incorrect, and as a result these extra flags were being ignored. Luckily, the 'debug' flag was being passed in each case anyway, which means that the '-g' flag would already be added. Given that all these tests pass 'debug', and the invalid flag has been ignored for some time, I'm just removing the flags in this commit. I've also changed the tests from using gdb_compile to prepare_for_testing, which allows some extra code to be removed from a couple of tests scripts. There should be no change in the test results after this commit. gdb/testsuite/ChangeLog: * gdb.arch/amd64-disp-step-avx.exp: Remove unneeded assembler flag option, syntax was wrong anyway. * gdb.arch/arm-disp-step.exp: Likewise. * gdb.arch/sparc64-regs.exp: Likewise. * gdb.arch/amd64-disp-step.exp: Remove unneeded assembler flag option, syntax was wrong anyway, switch to use prepare_for_testing. * gdb.arch/i386-disp-step.exp: Likewise.
2018-02-21Fix a typo.John Baldwin1-1/+1
gdb/testsuite/ChangeLog: * gdb.arch/amd64-i386-address.exp: Fix a typo.
2018-01-31Fix for prologue processing on PowerPCNikola Prica3-0/+104
One of conditions in skip_prologue() was never visited if there was mflr instruction that moves the link register to a register different than r0. This condition expects non shifted value of `lr_reg`. Previously offset of link register was never saved for registers different than r0. gdb/ChangeLog: 2018-01-31 Nikola Prica <nikola.prica@rt-rk.com> * rs6000-tdep.c (skip_prologue): Remove shifting for lr_reg and assign shifted lr_reg to fdata->lr_register when lr_reg is set. gdb/testsuite/ChangeLog: 2018-01-31 Nikola Prica <nikola.prica@rt-rk.com> * gdb.arch/powerpc-prologue-frame.s: New file. * gdb.arch/powerpc-prologue-frame.c: Likewise. * gdb.arch/powerpc-prologue-frame.exp: Likewise.
2018-01-21gdb: Add test for some error cases of @entry usageAndrew Burgess1-0/+8
Adds a test that using @entry for a non-parameter, or for an unknown symbol, both give the expected error. This error message was previously untested. gdb/testsuite/ChangeLog: * gdb.arch/amd64-entry-value.exp: Test using @entry on a non-parameter, and on an unknown symbol.
2018-01-19S390: Fix infcalls in s390-vregs test caseAndreas Arnez1-2/+2
GDB used to assume that functions without debug info return int. It accepted an expression containing such a function call and silently interpreted the function's return value as int. But nowadays GDB yields an error message instead, see https://sourceware.org/ml/gdb-patches/2017-07/msg00139.html This affects the s390-vregs test case, because it contains calls to setrlimit64 and chdir. When no glibc debug info is installed, these lead to unnecessary FAILs. Fix this by adding appropriate casts to the inferior function calls. gdb/testsuite/ChangeLog: * gdb.arch/s390-vregs.exp: Explicitly cast the return values of setrlimit and chdir to int.
2018-01-19S390: Improve comments for s390-tdbregs test caseAndreas Arnez2-2/+13
This adds more explanation as to why the test case must be compiled with the -msoft-float option. It also documents the my_tbegin and my_tend functions. gdb/testsuite/ChangeLog: * gdb.arch/s390-tdbregs.c (my_tbegin): Add comment documenting the function. (my_tend): Likewise. * gdb.arch/s390-tdbregs.exp: Enhance comment; explain the rationale of avoiding FP- and vector instructions.
2018-01-19Make tests expect [ \t]+ pattern instead of \t for "info reg" commandRuslan Kabatsayev3-7/+7
This will allow to format output of "info reg" command as we wish, without breaking the tests. In particular, it'll let us correctly align raw and natural values of the registers using spaces instead of current badly-working approach with tabs. This change is forwards- and backwards-compatible, so that the amended tests will work in the same way before and after reformatting patches (unless the tests check formatting, of course, but I've not come across any such tests). Some tests already used this expected pattern, so they didn't even have to be modified. Others are changed by this patch. I've checked this on a i386 system, with no noticeable differences in test results, so at least on i386 nothing seems to be broken by this. gdb/testsuite/ChangeLog: * gdb.arch/powerpc-d128-regs.exp: Replace expected "\[\t\]*" from "info reg" with "\[ \t\]*". * gdb.arch/altivec-regs.exp: Replace expected "\t" from "info reg" with "\[ \t\]+". * gdb.arch/s390-multiarch.exp: Ditto. * gdb.base/pc-fp.exp: Ditto. * gdb.reverse/i386-precsave.exp: Ditto. * gdb.reverse/i386-reverse.exp: Ditto. * gdb.reverse/i387-env-reverse.exp: Ditto. * gdb.reverse/i387-stack-reverse.exp: Ditto.
2018-01-18S390: Use soft float in s390-tdbregs test caseAndreas Arnez1-1/+4
The GDB test case s390-tdbregs.exp verifies GDB's handling of the "transaction diagnostic block". For simplicity, the test case uses the "transaction begin" (TBEGIN) instruction with the "allow floating-point operation" flag set to zero. But some GCC versions may indeed emit floating point or vector instructions for this test case. If this happens in the transaction, it aborts, and an endless loop results. This change tells the compiler to produce a soft-float binary, so no floating-point or vector registers are touched. gdb/testsuite/ChangeLog: * gdb.arch/s390-tdbregs.exp: Add the compile option -msoft-float.
2018-01-02Update copyright year range in all GDB filesJoel Brobecker238-238/+238
gdb/ChangeLog: Update copyright year range in all GDB files
2017-12-08Clear non-significant bits of address in watchpointYao Qi2-0/+15
Nowadays, GDB can't set watchpoint on tagged address on AArch64, (gdb) p p2 $1 = (int *) 0xf000fffffffff474 (gdb) watch *((int *) 0xf000fffffffff474) Hardware watchpoint 2: *((int *) 0xf000fffffffff474) (gdb) c Continuing. main () at binutils-gdb/gdb/testsuite/gdb.arch/aarch64-tagged-pointer.c:45 45 void (*func_ptr) (void) = foo; Unexpected error setting hardware debug registers This patch is about setting watchpoint on a tagged address. Unlike breakpoint, watchpoint record the expression rather than the address, and when a watchpoint is fired, GDB checks the expression value changed instead of matching address, so we can mask the watchpoint address by getting rid of non-significant bits of address. gdb: 2017-12-08 Yao Qi <yao.qi@linaro.org> * breakpoint.c (update_watchpoint): Call address_significant. gdb/testsuite: 2017-12-08 Yao Qi <yao.qi@linaro.org> * gdb.arch/aarch64-tagged-pointer.c (main): Update. * gdb.arch/aarch64-tagged-pointer.exp: Add tests for watchpoint.
2017-12-08Adjust breakpoint address by clearing non-significant bitsYao Qi2-0/+32
Tag in tagged address on AArch64 is treated as a non-significant bits of address, which can be got by gdbarch method significant_addr_bit, and gdb can clear these bits. With this patch, when user sets a breakpoint on tagged address on AArch64, GDB will drop the top byte of address, and put breakpoint at the new place, as shown below, (gdb) hbreak *func_ptr warning: Breakpoint address adjusted from 0xf000000000400690 to 0x00400690. Hardware assisted breakpoint 2 at 0x400690 (gdb) break *func_ptr warning: Breakpoint address adjusted from 0xf000000000400690 to 0x00400690. Breakpoint 3 at 0x400690 When program hits a breakpoint, the stopped pc reported by Linux kernel is the address *without* tag, so it is better the address recorded in breakpoint location is the one without tag too, so we can still match breakpoint location address and stopped pc reported by Linux kernel, by simple compare. gdb: 2017-12-08 Yao Qi <yao.qi@linaro.org> * breakpoint.c (adjust_breakpoint_address): Call address_significant. gdb/testsuite: 2017-12-08 Yao Qi <yao.qi@linaro.org> * gdb.arch/aarch64-tagged-pointer.c (main): Update. * gdb.arch/aarch64-tagged-pointer.exp: Add test for breakpoint.
2017-12-08Clear non-significant bits of address on memory accessYao Qi2-0/+115
ARMv8 supports tagged address, that is, the top one byte in address is ignored. It is always enabled on aarch64-linux. See https://www.kernel.org/doc/Documentation/arm64/tagged-pointers.txt The tag in the tagged address is modeled as non-significant bits in address, so this patch adds a new gdbarch method significant_addr_bit and clear the non-significant bits (the top byte in ARMv8) of the virtual address at the point before passing address to target cache layer. IOW, the address used in the target cache layer is already cleared. Before this patch, (gdb) x/x 0x0000000000411030 0x411030 <global>: 0x00000000 (gdb) x/x 0xf000000000411030 0xf000000000411030: Cannot access memory at address 0xf000000000411030 After this patch, (gdb) x/x 0x0000000000411030 0x411030 <global>: 0x00000000 (gdb) x/x 0xf000000000411030 0xf000000000411030: 0x00000000 Note that I used address_significant in paddress, but it causes a regression gdb.base/long_long.exp, because gdb clears the non-significant bits in address, but test still expects them. p/a val.oct^M $24 = 0x2ee53977053977^M (gdb) FAIL: gdb.base/long_long.exp: p/a val.oct so I defer the change there. gdb: 2017-12-08 Yao Qi <yao.qi@linaro.org> * aarch64-tdep.c (aarch64_gdbarch_init): Install gdbarch significant_addr_bit. * gdbarch.sh (significant_addr_bit): New. * gdbarch.c, gdbarch.h: Re-generated. * target.c (memory_xfer_partial): Call address_significant. * utils.c (address_significant): New function. * utils.h (address_significant): Declare. 2017-12-08 Yao Qi <yao.qi@linaro.org> gdb/testsuite: * gdb.arch/aarch64-tagged-pointer.c: New file. * gdb.arch/aarch64-tagged-pointer.exp: New file.
2017-12-08Adjust gdb.arch/i386-sse-stack-align.exp print statementSergio Durigan Junior1-1/+1
Since: commit 7022349d5c86bae74b49225515f42d2e221bd368 Author: Pedro Alves <palves@redhat.com> Date: Mon Sep 4 20:21:13 2017 +0100 Stop assuming no-debug-info functions return int We now have to explicitly tell GDB the type of the non-debug-info function we want to print (by casting). This commit adjusts the "print" statement on gdb.arch/i386-sse-stack-align.exp to do the proper cast, fixing a failure that started to happen after the mentioned commit. gdb/testsuite/ChangeLog: 2017-12-08 Sergio Durigan Junior <sergiodj@redhat.com> * gdb.arch/i386-sse-stack-align.exp: Cast "print" function call "int".
2017-12-06remote: Make qXfer packets respect corresponding "set remote foo-packet"Pedro Alves1-0/+25
I've noticed that "set remote target-features-packet off" before connecting has no effect -- GDB still fetches a target description anyway. The problem is that while most "set remote foo-packet" commands were fixed by: From 4082afcc3d1af9d8063d1c8e02deb34a8b97a489 Mon Sep 17 00:00:00 2001 From: Pedro Alves <palves@redhat.com> Date: Fri, 25 Apr 2014 18:07:02 +0100 Subject: [PATCH] Fix several "set remote foo-packet on/off" commands. <https://sourceware.org/ml/gdb-patches/2014-04/msg00006.html> the "qXfer" packets where missed. This commit fixes that. I've changed remote_search_memory too for consistency (seems like those are the last direct references to packet->support), though the difference is not observable because the qSearch:memory packet is auto probed. Note gdb.base/find-unmapped.exp already exercises explicit "set remote search-memory-packet off". gdb/ChangeLog: 2017-12-06 Pedro Alves <palves@redhat.com> * remote.c (remote_query_supported): Don't send "xmlRegisters=" if "qXfer:features:read"" is disabled. (remote_write_qxfer, remote_read_qxfer, remote_search_memory): Check packet_config_support instead of packet->support directly. gdb/testsuite/ChangeLog: 2017-12-06 Pedro Alves <palves@redhat.com> * gdb.arch/i386-avx.exp: If testing with a RSP target, check force-disabling XML descriptions. -- gdb/remote.c | 16 +++++++++------- gdb/testsuite/gdb.arch/i386-avx.exp | 25 +++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 7 deletions(-)
2017-12-04Fix displaced-stepping RIP-relative VEX-encoded instructions (AVX) (PR ↵Pedro Alves2-0/+209
gdb/22499) PR gdb/22499 is about a latent bug exposed by the switch to "maint set target-non-stop on" by default on x86-64 GNU/Linux, a while ago. With that on, GDB is also preferring to use displaced-stepping by default. The testcase in the bug is failing because GDB ends up incorrectly displaced-stepping over a RIP-relative VEX-encoded instruction, like this: 0x00000000004007f5 <+15>: c5 fb 10 05 8b 01 00 00 vmovsd 0x18b(%rip),%xmm0 # 0x400988 While RIP-relative instructions need adjustment when relocated to the scratch pad, GDB ends up just copying VEX-encoded instructions to the scratch pad unmodified, with the end result that the inferior ends up executing an instruction that fetches/writes memory from the wrong address... This patch teaches GDB about the VEX-encoding prefixes, fixing the problem, and adds a testcase that fails without the GDB fix. I think we may need a similar treatment for EVEX-encoded instructions, but I didn't address that simply because I couldn't find any EVEX-encoded RIP-relative instruction in the gas testsuite. In any case, this commit is forward progress as-is already. gdb/ChangeLog: 2017-12-04 Pedro Alves <palves@redhat.com> PR gdb/22499 * amd64-tdep.c (amd64_insn::rex_offset): Rename to... (amd64_insn::enc_prefix_offset): ... this, and tweak comment. (vex2_prefix_p, vex3_prefix_p): New functions. (amd64_get_insn_details): Adjust to rename. Also skip VEX2 and VEX3 prefixes. (fixup_riprel): Set VEX3.!B. gdb/testsuite/ChangeLog: 2017-12-04 Pedro Alves <palves@redhat.com> PR gdb/22499 * gdb.arch/amd64-disp-step-avx.S: New file. * gdb.arch/amd64-disp-step-avx.exp: New file.
2017-12-01Replace mail address with the URL in copyright headerYao Qi4-8/+4
The copyright header in most of GDB files were changed from mail address to the URL in the conversion to GPLv3 in Aug 2007. However, some files still use mail address instead of the URL. This patch fixes them. gdb/testsuite: 2017-12-01 Yao Qi <yao.qi@linaro.org> * gdb.arch/aarch64-atomic-inst.exp: Replace mail address with the URL in copyright header. * gdb.arch/aarch64-fp.exp: Likewise. * gdb.arch/ppc64-atomic-inst.exp: Likewise. * gdb.arch/ppc64-isa207-atomic-inst.exp: Likewise. * gdb.base/expand-psymtabs.exp: Likewise. * gdb.cp/expand-psymtabs-cxx.exp: Likewise. * gdb.fortran/common-block.exp: Likewise. * gdb.fortran/common-block.f90: Likewise. * gdb.fortran/logical.exp: Likewise. * gdb.fortran/vla-datatypes.f90: Likewise. * gdb.fortran/vla-sub.f90: Likewise.
2017-11-26[spu] Fix various test casesUlrich Weigand3-38/+26
The SPU-specific test cases were not modified to use standard_output_file and therefore all were no longer being executed. Fixing this exposed a few other bugs in spu-info noticed by using a more recent compiler, which are also fixed here. gdb/testsuite/ChangeLog: 2017-11-26 Ulrich Weigand <uweigand@de.ibm.com> * gdb.arch/spu-info.c: Include <unistd.h>. (do_signal_test): Fix broken calls to write. * gdb.arch/spu-info.exp: Use prepare_for_testing. Fix checks for empty mailboxes. Update signal tests for corrected do_signal_test routine. Allow nonzero event status.
2017-11-22Target FP: Refactor use of host floating-point arithmeticUlrich Weigand1-6/+6
Prepare for using MPFR to implement floating-point arithmetic by refactoring the way host floating-point arithmetic is currently used. In particular, fix the following two problems that cause different (and incorrect) results due to using host arithmetic: - Current processing always uses host "long double", and then converts back to the actual target format. This may introduce rounding errors. - Conversion of FP values to LONGEST simply does a host C++ type cast. However the result of such a cast is undefined if the source value is outside the representable range. MPFR always has defined behavior here (returns the minimum or maximum representable value). To fix the first issue, I've now created not just one set of routines using host FP arithmetic (on long double), but instead three different sets of routines, one each for host float, double, and long double. Operations can then be performed in the desired type directly, avoiding the extra rounding step. Using C++ templates, the three sets can all share the same source code without duplication. To fix the second issue, I'm simply enforcing the same conversion rule (which makes sense anyway) when converting out-of-range values from FP to LONGEST. To contain the code complexity with the variety of options now possible, I've created a new class "target_float_ops". There are a total of five separate implementations of this: host_float_ops<float> Implemented via host FP in given type host_float_ops<double> host_float_ops<long double> mpfr_float_ops Implemented via MPFR if available decimal_float_ops Implemented via libdecnumber Note instead of using the DOUBLEST define, this always just uses the "long double" data type. But since we now require C++11 anyway, this type must in any case be avaialble unconditionally. Most target floating-point operations simply dispatch to a (virtual) member routine of this class. Which implementation to choose is determined from the target types involved, and whether they match some host type or not. E.g. any operation on a single type that matches a host type is performed in that type. Operations involving two types that both match host types are performed in the larger one (according to C/C++ implicit conversion rules). Operations that involve any type that does not match a host type are performed using MPFR. (And of course operations involving decimal FP are performed using libdecnumber.) This first patch implements the refactoring of target-float.c as described above, introduing the host_float_ops and decimal_float_ops classes, and using them. Use of MPFR is introduced in the second patch. A bit of special-case handling code is moved around to as to avoid code duplication between host_float_ops and mpfr_float_ops. Note that due to the changes mentioned above, I've had to update (fix) the floating-point register values tested in the gdb.arch/vsx-regs.exp test case. (The new values now work both with host arithmetic and MPFR.) gdb/ChangeLog: 2017-11-22 Ulrich Weigand <uweigand@de.ibm.com> * target-float.c: Do not include <math.h>. Include <cmath> and <limits>. (DOUBLEST): Do not define. (class target_float_ops): New type. (class host_float_ops): New templated type. (class decimal_float_ops): New type. (floatformat_to_doublest): Rename to ... (host_float_ops<T>::from_target): ... this. Use template type T instead of DOUBLEST. Use C++ math routines. Update recursive calls. (host_float_ops<T>::from_target): New overload using a type argument. (floatformat_from_doublest): Rename to ... (host_float_ops<T>::to_target): ... this. Use template type T instead of DOUBLEST. Use C++ math routines. Update recursive calls. (host_float_ops<T>::to_target): New overload using a type argument. (floatformat_printf_format): New function. (struct printf_length_modifier): New templated type. (floatformat_to_string): Rename to ... (host_float_ops<T>::to_string): ... this. Use type instead of floatformat argument. Use floatformat_printf_format and printf_length_modifier. Remove special handling of invalid numbers, infinities and NaN (moved to target_float_to_string). (struct scanf_length_modifier): New templated type. (floatformat_from_string): Rename to ... (host_float_ops<T>::from_string): ... this. Use type instead of floatformat argument. Use scanf_length_modifier. (floatformat_to_longest): Rename to ... (host_float_ops<T>::to_longest): ... this. Use type instead of floatformat argument. Handle out-of-range values deterministically. (floatformat_from_longest): Rename to ... (host_float_ops<T>::from_longest): ... this. Use type instead of floatformat argument. (floatformat_from_ulongest): Rename to ... (host_float_ops<T>::from_ulongest): ... this. Use type instead of floatformat argument. (floatformat_to_host_double): Rename to ... (host_float_ops<T>::to_host_double): ... this. Use type instead of floatformat argument. (floatformat_from_host_double): Rename to ... (host_float_ops<T>::from_host_double): ... this. Use type instead of floatformat argument. (floatformat_convert): Rename to ... (host_float_ops<T>::convert): ... this. Use type instead of floatformat arguments. Remove handling of no-op conversions. (floatformat_binop): Rename to ... (host_float_ops<T>::binop): ... this. Use type instead of floatformat arguments. (floatformat_compare): Rename to ... (host_float_ops<T>::compare): ... this. Use type instead of floatformat arguments. (match_endianness): Use type instead of length/byte_order arguments. (set_decnumber_context): Likewise. (decimal_from_number): Likewise. Update calls. (decimal_to_number): Likewise. (decimal_is_zero): Likewise. Update calls. Move to earlier in file. (decimal_float_ops::to_host_double): New dummy function. (decimal_float_ops::from_host_double): Likewise. (decimal_to_string): Rename to ... (decimal_float_ops::to_string): ... this. Use type instead of length/byte_order arguments. Update calls. (decimal_from_string): Rename to ... (decimal_float_ops::from_string): ... this. Use type instead of length/byte_order arguments. Update calls. (decimal_from_longest): Rename to ... (decimal_float_ops::from_longest): ... this. Use type instead of length/byte_order arguments. Update calls. (decimal_from_ulongest): Rename to ... (decimal_float_ops::from_ulongest): ... this. Use type instead of length/byte_order arguments. Update calls. (decimal_to_longest): Rename to ... (decimal_float_ops::to_longest): ... this. Use type instead of length/byte_order arguments. Update calls. (decimal_binop): Rename to ... (decimal_float_ops::binop): ... this. Use type instead of length/byte_order arguments. Update calls. (decimal_compare): Rename to ... (decimal_float_ops::compare): ... this. Use type instead of length/byte_order arguments. Update calls. (decimal_convert): Rename to ... (decimal_float_ops::convert): ... this. Use type instead of length/byte_order arguments. Update calls. (target_float_same_category_p): New function. (target_float_same_format_p): Likewise. (target_float_format_length): Likewise. (enum target_float_ops_kind): New type. (get_target_float_ops_kind): New function. (get_target_float_ops): Three new overloaded functions. (target_float_is_zero): Update call. (target_float_to_string): Add special handling of invalid numbers, infinities and NaN (moved from floatformat_to_string). Use target_float_ops callback. (target_float_from_string): Use target_float_ops callback. (target_float_to_longest): Likewise. (target_float_from_longest): Likewise. (target_float_from_ulongest): Likewise. (target_float_to_host_double): Likewise. (target_float_from_host_double): Likewise. (target_float_convert): Add special case for no-op conversions. Use target_float_ops callback. (target_float_binop): Use target_float_ops callback. (target_float_compare): Likewise. gdb/testsuite/ChangeLog: 2017-11-22 Ulrich Weigand <uweigand@de.ibm.com> * gdb.arch/vsx-regs.exp: Update register content checks.
2017-11-21[PowerPC] Detect different long double floating-point formatsUlrich Weigand2-0/+96
Current versions of GCC support switching the format used for "long double" to either IBM double double or IEEE-128. The resulting binary is marked via different setting of the Tag_GNU_Power_ABI_FP GNU attribute. This patch checks this attribute to detect the format of the default "long double" type and sets GDB's notion of the format accordingly. The patch also adds support for the "__ibm128" type, which always uses IBM double double format independent of the format used for "long double". A new test case verifies that all three types, "long double", "__float128", and "__ibm128" are correctly detected in all three compiler settings, the default setting, -mabi=ieeelongdouble, and -mabi=ibmlongdouble. gdb/ChangeLog: 2017-11-21 Ulrich Weigand <uweigand@de.ibm.com> * ppc-tdep.h (enum powerpc_long_double_abi): New data type. (struct gdbarch_tdep): New member long_double_abi. * rs6000-tdep.c (rs6000_gdbarch_init): Initialize long_double_abi member of tdep struct based on Tag_GNU_Power_ABI_FP attribute. * ppc-linux-tdep.c (ppc_linux_init_abi): Install long double data format depending on long_double_abi tdep member. (ppc_floatformat_for_type): Handle __ibm128 type. gdb/testsuite/ChangeLog: 2017-11-21 Ulrich Weigand <uweigand@de.ibm.com> * gdb.arch/ppc-longdouble.exp: New file. * gdb.arch/ppc-longdouble.c: Likewise.
2017-10-27[AArch64] Mark LR clobbered by BL in inline asmYao Qi1-1/+2
LR is a caller-save register, so, if inline asm does BL (which touches LR), we should mark LR clobbered. gdb/testsuite: 2017-10-27 Yao Qi <yao.qi@linaro.org> * gdb.arch/insn-reloc.c (can_relocate_bl): Mark "x30" clobbered.
2017-10-24Fix unstable test names in gdb.arch/arc-tdesc-cpu.expPedro Alves1-4/+4
Currently if you diff testsuite/gdb.sum of two builds built from different source trees you see this spurious hunk: -PASS: gdb.arch/arc-tdesc-cpu.exp: set tdesc filename /home/pedro/gdb1/src/gdb/testsuite/gdb.arch/arc-tdesc-cpu.xml +PASS: gdb.arch/arc-tdesc-cpu.exp: set tdesc filename /home/pedro/gdb2/src/gdb/testsuite/gdb.arch/arc-tdesc-cpu.xml After this commit we'll show this instead in gdb.sum: PASS: gdb.arch/arc-tdesc-cpu.exp: set tdesc filename $srcdir/gdb.arch/arc-tdesc-cpu.xml gdb/testsuite/ChangeLog: 2017-10-24 Pedro Alves <palves@redhat.com> * gdb.arch/arc-tdesc-cpu.exp ('set tdesc filename'): Use gdb_test with explicit test name.
2017-10-11arc: Pass proper CPU value to the disassemblerAnton Kolesov2-0/+101
There was a problem with generation of the disassembler options for ARC in GDB, because a BFD architecture name was used as a CPU name, but they have different meaning even if some architectures have same name as respective CPUs. Target description specifies a BFD architecture, which is different from ARC CPU, as accepted by the disassembler (and most other ARC tools), because CPU values are much more fine grained - there can be multiple CPU values per single BFD architecture. As a result this code should translate architecture to some CPU value. Since there is no info on exact CPU configuration, it is best to use the most feature-rich CPU, so that the disassembler will recognize all instructions available to the specified architecture. gdb/ChangeLog yyyy-mm-dd Anton Kolesov <Anton.Kolesov@synopsys.com> * arc-tdep.c (arc_gdbarch_init): Pass proper cpu value to disassembler. * arc-tdep.h (arc_arch_is_em): New function. (arc_arch_is_hs): Likewise. gdb/testsuite/ChangeLog yyyy-mm-dd Anton Kolesov <Anton.Kolesov@synopsys.com> * gdb.arch/arc-tdesc-cpu.exp: New file. * gdb.arch/arc-tdesc-cpu.xml: Likewise.