aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2020-06-25Add memory tagging testcasesusers/luisgpm/aarch64-mte-v2Luis Machado5-0/+547
Add an AArch64-specific test and a more generic memory tagging test that other architectures can run. Even though architectures not supporting memory tagging can run the memory tagging tests, the runtime check will make the tests bail out early, as it would make no sense to proceed without proper support. gdb/testsuite/ChangeLog: YYYY-MM-DD Luis Machado <luis.machado@linaro.org> * gdb.arch/aarch64-mte.c: New file. * gdb.arch/aarch64-mte.exp: New test. * gdb.base/memtag.c: New file. * gdb.base/memtag.exp: New test. * lib/gdb.exp (supports_memtag): New function.
2020-06-25Add NEWS entry.Luis Machado1-0/+32
Mention the new packets and memory tagging features. gdb/ChangeLog: YYYY-MM-DD Luis Machado <luis.machado@linaro.org> * NEWS: Mention memory tagging changes.
2020-06-25Document new "x" and "print" memory tagging extensionsLuis Machado1-3/+31
Document the changes to the "print" and "x" commands to support memory tagging. gdb/doc/ChangeLog: YYYY-MM-DD Luis Machado <luis.machado@linaro.org> * gdb.texinfo (Data): Document memory tagging changes to the "print" command. (Examining Memory): Document memory tagging changes to the "x" command. (Memory Tagging): Update with more information on changes to the "x" and "print" commands.
2020-06-25Extend "x" and "print" commands to support memory taggingLuis Machado2-1/+83
Extend the "x" and "print" commands to make use of memory tagging functionality, if supported by the architecture. The "print" command will point out any possible tag mismatches it finds when dealing with pointers, in case such a pointer is tagged. No additional modifiers are needed. Suppose we have a pointer "p" with value 0x1234 (logical tag 0x0) and that we have an allocation tag of 0x1 for that particular area of memory. This is the expected output: (gdb) p/x p Logical tag (0x0) does not match the allocation tag (0x1). $1 = 0x1234 The "x" command has a new 'm' modifier that will enable displaying of allocation tags alongside the data dump. It will display one allocation tag per line. AArch64 has a tag granule of 16 bytes, which means we can have one tag for every 16 bytes of memory. In this case, this is what the "x" command will display with the new 'm' modifier: (gdb) x/32bxm p <Allocation Tag 0x1 for range [0x1230,0x1240)> 0x1234: 0x01 0x02 0x00 0x00 0x00 0x00 0x00 0x00 0x123c: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 <Allocation Tag 0x1 for range [0x1240,0x1250)> 0x1244: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x124c: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 (gdb) x/4gxm a <Allocation Tag 0x1 for range [0x1230,0x1240)> 0x1234: 0x0000000000000201 0x0000000000000000 <Allocation Tag 0x1 for range [0x1240,0x1250)> 0x1244: 0x0000000000000000 0x0000000000000000 gdb/ChangeLog: YYYY-MM-DD Luis Machado <luis.machado@linaro.org> * printcmd.c (decode_format): Handle the 'm' modifier. (do_examine): Display allocation tags when required/supported. (should_validate_memtags): New function. (print_command_1): Display memory tag mismatches. * valprint.h (struct format_data) <print_tags>: New field.
2020-06-25Documentation for the new mtag commandsLuis Machado1-0/+56
Document the new "mtag" command prefix and all of its subcommands. gdb/doc/ChangeLog: YYYY-MM-DD Luis Machado <luis.machado@linaro.org> * gdb.textinfo (Memory Tagging): New subsection. (AArch64 Memory Tagging Extension): New subsection.
2020-06-25New mtag commandsLuis Machado2-13/+342
Add new commands under the "mtag" prefix to allow users to inspect, modify and check memory tags in different ways. The available subcommands are the following: - mtag showltag <address>: Shows the logical tag for a particular address. - mtag setltag <address> <tag>: Prints the address tagged with the logical tag <tag> - mtag showatag <address>: Shows the allocation tag for a particular address. - mtag setatag <address> <length> <tags>: Sets one or more allocation tags to the specified tags. - mtag check <address>: Check if the logical tag in <address> matches its allocation tag. These commands make use of the memory tagging gdbarch methods, and are still available, but disabled, when memory tagging is not supported by the architecture. gdb/ChangeLog: YYYY-MM-DD Luis Machado <luis.machado@linaro.org> * printcmd.c: Include gdbsupport/rsp-low.h. (mtaglist): New static global. (process_print_command_args): Factored out of print_command_1. (print_command_1): Use process_print_command_args. (show_addr_not_tagged, show_memtag_unsupported, mtag_command) (mtag_showtag_command, mtag_showltag_command, mtag_showatag_command) (parse_setltag_input, mtag_setltag_command, parse_setatag_input) (mtag_setatag_command, mtag_check_command): New functions. (_initialize_printcmd): Add "mtag" prefix and subcommands. gdbsupport/ChangeLog: YYYY-MM-DD Luis Machado <luis.machado@linaro.org> * rsp-low.cc (fromhex): Change error message text to not be RSP-specific.
2020-06-25AArch64: Add gdbserver MTE supportLuis Machado3-0/+56
Adds the AArch64-specific memory tagging support (MTE) by implementing the required hooks and checks. gdbserver/ChangeLog: YYYY-MM-DD Luis Machado <luis.machado@linaro.org> * Makefile.in (SFILES): Add /../gdb/nat/aarch64-mte-linux-ptrace.c. * configure.srv (aarch64*-*-linux*): Add arch/aarch64-mte-linux.o and nat/aarch64-mte-linux-ptrace.o. * linux-aarch64-low.cc: Include nat/aarch64-mte-linux-ptrace.h. (class aarch64_target) <supports_memory_tagging> <fetch_memtags, store_memtags>: New method overrides. (aarch64_target::supports_memory_tagging) (aarch64_target::fetch_memtags) (aarch64_target::store_memtags): New methods.
2020-06-25AArch64: Report tag violation error informationLuis Machado2-0/+60
Whenever a memory tag violation occurs, we get a SIGSEGV. Additional information can be obtained through the siginfo data structure. For AArch64 the Linux kernel may expose the fault address and tag information, if we have a synchronous event. Otherwise there is not fault address available. gdb/ChangeLog: YYYY-MM-DD Luis Machado <luis.machado@linaro.org> * aarch64-linux-tdep.c (aarch64_linux_handle_segmentation_fault): New function. (aarch64_linux_init_abi): Register aarch64_linux_handle_segmentation_fault as segmentation fault hook. * arch/aarch64-linux.h (SEGV_MTEAERR): Define. (SEGV_MTESERR): Define.
2020-06-25AArch64: Add unit testing for logical tag set/get operationsLuis Machado1-0/+31
Add some unit testing to exercise setting/getting logical tags in the AArch64 implementation. gdb/ChangeLog: YYYY-MM-DD Luis Machado <luis.machado@linaro.org> * aarch64-linux-tdep.c: Include gdbsupport/selftest.h. (aarch64_linux_ltag_tests): New function. (_initialize_aarch64_linux_tdep): Register aarch64_linux_ltag_tests.
2020-06-25AArch64: Implement the memory tagging gdbarch hooksLuis Machado3-0/+264
This patch implements the memory tagging gdbarch hooks for AArch64, for the MTE feature. gdb/ChangeLog: YYYY-MM-DD Luis Machado <luis.machado@linaro.org> * aarch64-linux-tdep.c: Include target.h, arch-utils.h, value.h. (aarch64_linux_get_atag, aarch64_linux_tagged_address_p) (aarch64_linux_memtag_mismatch_p, aarch64_linux_set_memtags) (aarch64_linux_get_memtag, aarch64_linux_memtag_to_string): New functions. (aarch64_linux_init_abi): Initialize MTE-related gdbarch hooks. * arch/aarch64-mte-linux.c (make_ltag_bits, make_ltag) (aarch64_linux_set_ltag, aarch64_linux_get_ltag): New functions. * arch/aarch64-mte-linux.h (MTE_LOGICAL_TAG_START_BIT) (MTE_LOGICAL_MAX_VALUE): Define. (make_ltag_bits, make_ltag, aarch64_linux_set_ltag) (aarch64_linux_get_ltag): New prototype.
2020-06-25Refactor parsing of /proc/<pid>/smapsLuis Machado2-120/+240
The Linux kernel exposes the information about MTE-protected pages via the proc filesystem, more specifically through the smaps file. What we're looking for is a mapping with the 'mt' flag, which tells us that mapping was created with a PROT_MTE flag and, thus, is capable of using memory tagging. We already parse that file for other purposes (core file generation/filtering), so this patch refactors the code to make the parsing of the smaps file reusable for memory tagging. The function linux_address_in_memtag_page uses the refactored code to allow querying for memory tag support in a particular address, and it gets used in the next patch. gdb/ChangeLog: YYYY-MM-DD Luis Machado <luis.machado@linaro.org> * linux-tdep.c (struct smaps_vmflags) <memory_tagging>: New flag bit. (struct smaps_data): New struct. (decode_vmflags): Handle the 'mt' flag. (parse_smaps_data): New function, refactored from linux_find_memory_regions_full. (linux_address_in_memtag_page): New function. (linux_find_memory_regions_full): Refactor into parse_smaps_data. * linux-tdep.h (linux_address_in_memtag_page): New prototype.
2020-06-25AArch64: Implement memory tagging target methods for AArch64Luis Machado8-1/+302
The patch implements the memory tagging target hooks for AArch64, so we can handle MTE. gdb/ChangeLog: YYYY-MM-DD Luis Machado <luis.machado@linaro.org> * Makefile.in (ALL_64_TARGET_OBS): Add arch/aarch64-mte-linux.o. (HFILES_NO_SRCDIR): Add arch/aarch64-mte-linux.h and nat/aarch64-mte-linux-ptrace.h. * aarch64-linux-nat.c: Include nat/aarch64-mte-linux-ptrace.h. (aarch64_linux_nat_target) <supports_memory_tagging>: New method override. <fetch_memtags>: New method override. <store_memtags>: New method override. (aarch64_linux_nat_target::supports_memory_tagging): New method. (aarch64_linux_nat_target::fetch_memtags): New method. (aarch64_linux_nat_target::store_memtags): New method. * arch/aarch64-mte-linux.c: New file. * arch/aarch64-mte-linux.h: Include gdbsupport/common-defs.h. (MTE_GRANULE_SIZE): Define. (get_tag_granules): New prototype. * configure.nat (NATDEPFILES): Add nat/aarch64-mte-linux-ptrace.o. * configure.tgt (aarch64*-*-linux*): Add arch/aarch64-mte-linux.o. * nat/aarch64-mte-linux-ptrace.c: New file. * nat/aarch64-mte-linux-ptrace.h: New file.
2020-06-25AArch64: Add MTE ptrace requestsLuis Machado2-0/+34
This patch adds the required ptrace request definitions into a new include file that will be used by the next patches. gdb/ChangeLog: YYYY-MM-DD Luis Machado <luis.machado@linaro.org> * Makefile.in (HFILES_NO_SRCDIR): Add nat/aarch64-mte-linux-ptrace.h. * nat/aarch64-mte-linux-ptrace.h: New file.
2020-06-25AArch64: Add MTE register set support for GDB and gdbserverLuis Machado7-5/+125
AArch64 MTE support in the Linux kernel exposes a couple new read-only registers through ptrace. This patch adds the required code to support them. include/ChangeLog: YYYY-MM-DD Luis Machado <luis.machado@linaro.org> * elf/common.h (NT_ARM_MTE): Define. gdb/ChangeLog: YYYY-MM-DD Luis Machado <luis.machado@linaro.org> * aarch64-linux-nat.c (fetch_mte_from_thread): New function. (aarch64_linux_nat_target::fetch_registers): Update to call fetch_mte_from_thread. * aarch64-linux-tdep.c (aarch64_linux_iterate_over_regset_sections): Handle MTE register section. * aarch64-tdep.c (aarch64_mte_register_names): New struct. (aarch64_cannot_store_register): Handle MTE registers. (aarch64_gdbarch_init): Initialize and setup MTE registers. * aarch64-tdep.h (gdbarch_tdep) <mte_reg_base>: New field. <has_mte>: New method. * arch/aarch64-linux.h (AARCH64_LINUX_SIZEOF_MTE): Define. gdbserver/ChangeLog: YYYY-MM-DD Luis Machado <luis.machado@linaro.org> * linux-aarch64-low.cc (aarch64_store_mteregset): New function. (aarch64_regsets): Add MTE register set entry. (aarch64_sve_regsets): Add MTE register set entry.
2020-06-25AArch64: Add target description/feature for MTE registersLuis Machado13-25/+75
This patch adds a target description and feature "mte" for aarch64. It includes a couple registers: sctlr and gcr. Both 64-bit in size. The patch also adjusts the code that creates the target descriptions at runtime based on CPU feature checks. gdb/ChangeLog: YYYY-MM-DD Luis Machado <luis.machado@linaro.org> * aarch64-linux-nat.c (aarch64_linux_nat_target::read_description): Take MTE flag into account. Slight refactor to hwcap flag checking. * aarch64-linux-tdep.c (aarch64_linux_core_read_description): Likewise. * aarch64-tdep.c (tdesc_aarch64_list): Add one more dimension for MTE. (aarch64_read_description): Add mte_p parameter and update to use it. Update the documentation. (aarch64_gdbarch_init): Update call to aarch64_read_description. * aarch64-tdep.h (aarch64_read_description): Add mte_p parameter. * arch/aarch64.c: Include ../features/aarch64-mte.c. (aarch64_create_target_description): Add mte_p parameter and update the code to use it. * arch/aarch64.h (aarch64_create_target_description): Add mte_p parameter. * features/Makefile (FEATURE_XMLFILES): Add aarch64-mte.xml. * features/aarch64-mte.c: New file, generated. * features/aarch64-mte.xml: New file. gdbserver/ChangeLog: YYYY-MM-DD Luis Machado <luis.machado@linaro.org> * linux-aarch64-ipa.cc (get_ipa_tdesc): Update call to aarch64_linux_read_description. (initialize_low_tracepoint): Likewise. * linux-aarch64-low.cc (aarch64_target::low_arch_setup): Take MTE flag into account. * linux-aarch64-tdesc.cc (tdesc_aarch64_list): Add one more dimension for MTE. (aarch64_linux_read_description): Add mte_p parameter and update to use it. * linux-aarch64-tdesc.h (aarch64_linux_read_description): Add mte_p parameter.
2020-06-25AArch64: Add MTE CPU feature check supportLuis Machado5-0/+34
This patch is a preparation for the next patches implementing MTE. It just adds a HWCAP2 constant for MTE, creates a new generic arch/aarch64-mte-linux.h file and includes that file in the source files that will use it. gdb/ChangeLog: YYYY-MM-DD Luis Machado <luis.machado@linaro.org> * Makefile.in (HFILES_NO_SRCDIR): Add arch/aarch64-mte-linux.h. * aarch64-linux-nat.c: Include arch/aarch64-mte-linux.h. * aarch64-linux-tdep.c: Likewise * arch/aarch64-mte-linux.h: New file. gdbserver/ChangeLog: YYYY-MM-DD Luis Machado <luis.machado@linaro.org> * linux-aarch64-low.cc: Include arch/aarch64-mte-linux.h.
2020-06-25Documentation for memory tagging remote packetsLuis Machado1-0/+84
Document the remote packet changes to support memory tagging. gdb/doc/ChangeLog: YYYY-MM-DD Luis Machado <luis.machado@linaro.org> * gdb.texinfo (General Query Packets): Document qMemTags and QMemTags. Document the "memory-tagging" feature.
2020-06-25Unit tests for gdbserver memory tagging remote packetsLuis Machado1-0/+88
Add some unit testing to exercise the functions handling the qMemTags and QMemTags packets as well as feature support. gdbserver/ChangeLog: YYYY-MM-DD Luis Machado <luis.machado@linaro.org> * server.cc (test_memory_tagging_functions): New function. (captured_main): Register test_memory_tagging_functions.
2020-06-25GDBserver remote packet support for memory taggingLuis Machado6-22/+186
This patch adds the generic remote bits to gdbserver so it can check for memory tagging support and handle fetch tags and store tags requests. gdbserver/ChangeLog: YYYY-MM-DD Luis Machado <luis.machado@linaro.org> * remote-utils.cc (decode_m_packet_params): Renamed from ... (decode_m_packet): ... this, which now calls decode_m_packet_params. (decode_M_packet): Use decode_m_packet_params. * remote-utils.h (decode_m_packet_params): New prototype. * server.cc (create_fmemtags_reply, parse_smemtags_request): New functions. (handle_general_set): Handle the QMemTags packet. (parse_fmemtags_request): New function. (handle_query): Handle the qMemTags packet and advertise memory tagging support. (captured_main): Initialize memory tagging flag. * server.h (struct client_state): Initialize memory tagging flag. * target.cc (process_stratum_target::supports_memory_tagging) (process_stratum_target::fetch_memtags) (process_stratum_target::store_memtags): New methods. * target.h: Include gdbsupport/byte-vector.h. (class process_stratum_target) <supports_memory_tagging> <fetch_memtags, store_memtags>: New class virtual methods. (target_supports_memory_tagging): Define.
2020-06-25Unit testing for GDB-side remote memory tagging handlingLuis Machado1-0/+89
Include some unit testing for the functions handling the new qMemTags and QMemTags packets. gdb/ChangeLog: YYYY-MM-DD Luis Machado <luis.machado@linaro.org> * remote: Include gdbsupport/selftest.h. (test_memory_tagging_functions): New function. (_initialize_remote): Register test_memory_tagging_functions.
2020-06-25Add GDB-side remote target support for memory taggingLuis Machado1-1/+106
This patch adds memory tagging support to GDB's remote side, with packet string checks, new packet support and an implementation of the two new tags methods fetch_atags and store_atags. gdb/ChangeLog: YYYY-MM-DD Luis Machado <luis.machado@linaro.org> * remote.c (PACKET_memory_tagging_feature): New enum. (remote_memory_tagging_p): New function. (remote_protocol_features): New "memory-tagging" entry. (remote_target::remote_query_supported): Handle memory tagging support. (remote_target::supports_memory_tagging): Implement. (create_fmemtags_request, parse_fmemtags_reply) (create_smemtags_request): New functions. (remote_target::fetch_memtags): Implement. (remote_target::store_memtags): Implement. (_initialize_remote): Add new "memory-tagging-feature" config command.
2020-06-25New gdbarch memory tagging hooksLuis Machado5-0/+299
This patch adds a couple gdbarch hooks: gdbarch_tagged_address_p checks if a particular address is tagged or not. gdbarch_address_tag returns the tag for a particular address, if tagged. I've used struct value as opposed to straight CORE_ADDR so other architectures can use the infrastructure without having to rely on fixed types. gdb/ChangeLog: YYYY-MM-DD Luis Machado <luis.machado@linaro.org> * arch-utils.c (default_memtag_to_string, +default_tagged_address_p) (default_memtag_mismatch_p, default_set_memtags) (default_get_memtag): New functions. * arch-utils.h (default_memtag_to_string, default_tagged_address_p) (default_memtag_mismatch_p, default_set_memtags) (default_get_memtag): New prototypes. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate. * gdbarch.sh (memtag_to_string, tagged_address_p, memtag_mismatch_p) (set_memtags, get_memtag, memtag_granule_size): New gdbarch hooks. (enum memtag_type): New enum.
2020-06-25New target methods for memory tagging supportLuis Machado4-0/+173
This patch starts adding some of the generic pieces to accomodate memory tagging. We have three new target methods: - supports_memory_tagging: Checks if the target supports memory tagging. This defaults to false for targets that don't support memory tagging. - fetch_memtags: Fetches the allocation tags associated with a particular memory range [address, address + length). The default is to return 1 without returning any tags. This should only be called if memory tagging is supported. - store_memtags: Stores a set of allocation tags for a particular memory range [address, address + length). The default is to return 1, which indicates an error. This should only be called if memory tagging is supported. It also adds a control option for enabling/disabling memory tagging manually: set memory-tagging on/off. The default is "on", with GDB making its use conditional to the architecture supporting memory tagging. gdb/ChangeLog: YYYY-MM-DD Luis Machado <luis.machado@linaro.org> * printcmd.c (memtag): New static global. (show_memtag): New function. (_initialize_printcmd): Add set/show memory-tagging command. * remote.c (remote_target) <supports_memory_tagging>: New method override. <fetch_memtags>: New method override. <store_memtags>: New method override. (remote_target::supports_memory_tagging): New method. (remote_target::fetch_memtags): New method. (remote_target::store_memtags): New method. * target-delegates.c (dummy_target) <supports_memory_tagging>: New method override. <fetch_memtags>: New method override. <store_memtags>: New method override. (debug_target) <supports_memory_tagging>: New method override. <fetch_memtags>: New method override. <store_memtags>: New method override. (target_ops::supports_memory_tagging): New method. (target_ops::fetch_memtags): New method. (target_ops::store_memtags): New method. (dummy_target::supports_memory_tagging): New method. (dummy_target::fetch_memtags): New method. (dummy_target::store_memtags): New method. (debug_target::supports_memory_tagging): New method. (debug_target::fetch_memtags): New method. (debug_target::store_memtags): New method. * target.h (struct target_ops) <supports_memory_tagging>: New virtual method. <fetch_memtags: New virtual method. <store_memtags>: New virtual method. (target_supports_memory_tagging): Define. (target_fetch_memtags): Define. (target_store_memtags): Define.
2020-06-25Remove obsolete gdbarch_static_transform_nameRainer Orth9-144/+18
gdbarch_static_transform_name is completely Solaris-specific or rather specific to the Studio compilers. Studio cc has deprecated Stabs support in the 12.4 release back in 2015, GCC has defaulted to DWARF-2 on Solaris 7+ since 2004 and Stabs themselves are pretty much obsolete, so the whole code can go. Tested on sparcv9-sun-solaris2.11 and x86_64-pc-linux-gnu with --enable-targets=all. * sol2-tdep.c (sol2_static_transform_name): Remove. (sol2_init_abi): Don't register it. * gdbarch.sh (static_transform_name): Remove. * gdbarch.c, gdbarch.h: Regenerate. * dbxread.c (read_dbx_symtab) <'S'>: Remove call to gdbarch_static_transform_name. * mdebugread.c (parse_partial_symbols) <'S'>: Likewise. * stabsread.c (define_symbol) <'X'>: Remove. (define_symbol) <'S'>: Remove gdbarch_static_transform_name handling. <'V'>: Likewise. * xcoffread.c (scan_xcoff_symtab): Remove gdbarch. <'S'>: Remove call to gdbarch_static_transform_name.
2020-06-25Use fork instead of vfork on SolarisRainer Orth2-1/+13
The gdb.mi/mi-exec-run.exp test never completed/timed out on Solaris for quite some time: FAIL: gdb.mi/mi-exec-run.exp: inferior-tty=main: mi=main: force-fail=1: run failure detected (timeout) This is for gdb trying to exec mi-exec-run.nox, a copy of mi-exec-run with execute permissions removed. The process tree at this point looks like this: 21254 /vol/gcc/bin/expect -- /vol/gcc/share/dejagnu/runtest.exp GDB_PARALLEL=yes --outdir=outputs/gdb.mi/mi-exec-run-vfork gdb.mi/mi-exec-run.exp 21300 <defunct> 21281 <defunct> 21294 $obj/gdb/testsuite/../../gdb/gdb -nw -nx -data-directory $obj/gdb/testsuite/../data-directory -i=mi 21297 $obj/gdb/testsuite/../../gdb/gdb -nw -nx -data-directory $obj/gdb/testsuite/../data-directory -i=mi The parent gdb hangs here: 21294: $obj/gdb/testsuite/../../gdb/gdb -nw ------------ lwp# 1 / thread# 1 --------------- 0000000000000000 SYS#0 () 0000000000daeccd procfs_target::create_inferior(char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char**, int) () + 97 (procfs.c:2853) 0000000000ca63a7 run_command_1(char const*, int, run_how) () + 349 (basic_string.h:187) 0000000000ca6516 start_command(char const*, int) () + 26 (infcmd.c:584) 0000000000b3ca8e do_const_cfunc(cmd_list_element*, char const*, int) () + f (cli-decode.c:96) 0000000000b3ed77 cmd_func(cmd_list_element*, char const*, int) () + 32 (cli-decode.c:2113) 0000000000f2d219 execute_command(char const*, int) () + 455 (top.c:657) 0000000000d4ad77 mi_execute_cli_command(char const*, int, char const*) () + 242 (basic_string.h:187) 0000000000d4ae80 mi_cmd_exec_run(char const*, char**, int) () + ba (mi-main.c:473) with these process flags 21294: $obj/gdb/testsuite/../../gdb/gdb -nw data model = _LP64 flags = VFORKP|ORPHAN|MSACCT|MSFORK sigpend = 0x00004103,0x00000000,0x00000000 /1: flags = 0 sigmask = 0xffbffeff,0xffffffff,0x000000ff cursig = SIGKILL /2: flags = DETACH|STOPPED|ASLEEP lwp_park(0x0,0x0,0x0) why = PR_SUSPENDED sigmask = 0x000a2002,0x00000000,0x00000000 [...] while the child sits at 21297: $obj/gdb/testsuite/../../gdb/gdb -nw 00007fffbf078a0b execve (7fffbffff756, 7fffbfffec58, 7fffbfffec90, 0) 00007fffbef84cf6 execvpex () + f6 00007fffbef84f45 execvp () + 15 0000000000d60a44 fork_inferior(char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char**, void (*)(), gdb::function_view<void (int)>, void (*)(), char const*, void (*)(char const*, char* const*, char* const*)) () + 47f (fork-inferior.c:423) 0000000000daeccd procfs_target::create_inferior(char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char**, int) () + 97 (procfs.c:2853) 0000000000ca63a7 run_command_1(char const*, int, run_how) () + 349 (basic_string.h:187) 0000000000ca6516 start_command(char const*, int) () + 26 (infcmd.c:584) 0000000000b3ca8e do_const_cfunc(cmd_list_element*, char const*, int) () + f (cli-decode.c:96) 0000000000b3ed77 cmd_func(cmd_list_element*, char const*, int) () + 32 (cli-decode.c:2113) 0000000000f2d219 execute_command(char const*, int) () + 455 (top.c:657) 0000000000d4ad77 mi_execute_cli_command(char const*, int, char const*) () + 242 (basic_string.h:187) 0000000000d4ae80 mi_cmd_exec_run(char const*, char**, int) () + ba (mi-main.c:473) with 21297: $obj/gdb/testsuite/../../gdb/gdb -nw data model = _LP64 flags = MSACCT|MSFORK exitset = 0x00000000 0x04000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 /1: flags = STOPPED|ISTOP execve(0x7fffbffff756,0x7fffbfffec58,0x7fffbfffec90,0x0) why = PR_SYSEXIT what = execve We have a deadlock here: the execve in the child cannot return until the parent has handled the PR_SYSEXIT while the parent cannot run with a vfork'ed child as documented in proc(4): The child of a vfork(2) borrows the parent's address space. When a vfork(2) is executed by a traced process, all watched areas established for the parent are suspended until the child terminates or performs an exec(2). Any watched areas established independently in the child are cancelled when the parent resumes after the child's termination or exec(2). PCWATCH fails with EBUSY if applied to the parent of a vfork(2) before the child has terminated or performed an exec(2). The PR_VFORKP flag is set in the pstatus structure for such a parent process. In that situation, the parent cannot be killed even with SIGKILL (as runtest will attempt once the timeout occurs; the pending signal can be seen in the pflags output above), so the whole test hangs until one manually kills the child process. Fortunately, there's an easy way out: when using fork instead of vfork, the problem doesn't occur, and this is what the current patch does: it calls fork_inferior with a dummy pre_trace_fun arg. Tested on amd64-pc-solaris2.11 and sparcv9-sun-solaris2.11. * procfs.c (procfs_pre_trace): New function. (procfs_target::create_inferior): Pass it to fork_inferior.
2020-06-25Don't include *sol2-tdep.o on Linux/sparc*Rainer Orth6-12/+17
Linux/sparc* currently links Solaris-specific files (sparc-sol2-tdep.o, sparc64-sol2-tdep.o, sol2-tdep.o) for no apparent reason. It has no business doing so, and none of the functions/variables defined there are used explicitly. If support for the Solaris OSABI were desired, this should be done using --enable-targets instead. Since neither sparc{32,64}_sol2_init_abi currently declared in common headers (sparc*-tdep.h) are used outside their source files, they are made static and the declarations removed. Tested on sparcv9-sun-solaris2.11 and sparc64-unknown-linux-gnu. * configure.tgt <sparc-*-linux*> (gdb_target_obs): Remove sparc-sol2-tdep.o, sol2-tdep.o, sparc64-sol2-tdep.o. <sparc64-*-linux*> (gdb_target_obs): Remove sparc64-sol2-tdep.o, sol2-tdep.o, sparc-sol2-tdep.o. * sparc-sol2-tdep.c (sparc32_sol2_init_abi): Make static. * sparc-tdep.h (sparc32_sol2_init_abi): Remove. * sparc64-sol2-tdep.c (sparc64_sol2_init_abi): Make static. * sparc64-tdep.h (sparc64_sol2_init_abi): Remove.
2020-06-25Move common handlers to sol2_init_abiRainer Orth8-180/+158
There's some overlap and duplication between 32 and 64-bit Solaris/SPARC and x86 tdep files, in particular sol2_core_pid_to_str *_sol2_sigtramp_p sol2_skip_solib_resolver *_sol2_static_transform_name (forgotten on amd64) set_gdbarch_sofun_address_maybe_missing (likewise) This patch avoids this by centralizing common code in sol2-tdep.c. While sparc_sol2_pc_in_sigtramp and sparc_sol2_static_transform_name were declared in the shared sparc-tdep.h, they were only used in Solaris files. Tested on amd64-pc-solaris2.11, i386-pc-solaris2.11, sparcv9-sun-solaris2.11, and sparc-sun-solaris2.11, and sparc64-unknown-linux-gnu. * amd64-sol2-tdep.c (amd64_sol2_sigtramp_p): Remove. (amd64_sol2_init_abi): Use sol2_sigtramp_p. Call sol2_init_abi. Remove calls to set_gdbarch_skip_solib_resolver, set_gdbarch_core_pid_to_str. * i386-sol2-tdep.c (i386_sol2_sigtramp_p): Remove. (i386_sol2_static_transform_name): Remove. (i386_sol2_init_abi): Call sol2_init_abi. Remove calls to set_gdbarch_sofun_address_maybe_missing, set_gdbarch_static_transform_name, set_gdbarch_skip_solib_resolver, set_gdbarch_core_pid_to_str. Use sol2_sigtramp_p. * sol2-tdep.c (sol2_pc_in_sigtramp): New function. (sol2_sigtramp_p): New function. (sol2_static_transform_name): New function. (sol2_skip_solib_resolver, sol2_core_pid_to_str): Make static. (sol2_init_abi): New function. * sol2-tdep.h (sol2_sigtramp_p, sol2_init_abi): Declare. (sol2_skip_solib_resolver, sol2_core_pid_to_str): Remove. * sparc-sol2-tdep.c (sparc_sol2_pc_in_sigtramp): Remove. (sparc32_sol2_sigtramp_frame_sniffer): Just call sol2_sigtramp_p. (sparc_sol2_static_transform_name): Remove. (sparc32_sol2_init_abi): Call sol2_init_abi. Remove calls to set_gdbarch_sofun_address_maybe_missing, set_gdbarch_static_transform_name, set_gdbarch_skip_solib_resolver, set_gdbarch_core_pid_to_str. * sparc-tdep.h (sparc_sol2_pc_in_sigtramp) (sparc_sol2_static_transform_name): Remove * sparc64-sol2-tdep.c (sparc64_sol2_sigtramp_frame_sniffer): Just call sol2_sigtramp_p. (sparc64_sol2_init_abi): Call sol2_init_abi. Remove calls to set_gdbarch_sofun_address_maybe_missing, set_gdbarch_static_transform_name, set_gdbarch_skip_solib_resolver, set_gdbarch_core_pid_to_str.
2020-06-25Update the Swedish translation in the gprof/ subdirectory.Nick Clifton2-27/+31
* po/sv.po: Updated Swedish translation.
2020-06-25Remove the use of the register keyword in the libiberty.h header file - it ↵Nick Clifton2-3/+8
is deprecated and incompatible with C++17. * libiberty.h (bsearch_r): Remove use of the register keyword from the prototype.
2020-06-25Stop the assembler from generating R_ARM_THM_JMP11 relocations as these are ↵Nick Clifton3-8/+12
not supported by the kernel. PR 26141 * config/tc-arm.c (arm_force_relocation): Force resolution of BFD_RELOC_THUMB_PCREL_BRANCH12 relocations. * testsuite/gas/arm/plt-1.d: Adjust expected disassembly.
2020-06-25x86: make J disassembler macro available for new useJan Beulich2-12/+13
There's clearly a shortage of available macro characters, as can be seen from the various two-character macros that had to be introduced. Don't waste characters for things that can be expressed differently. In the case of J this alternative is {l|}.
2020-06-25x86: drop left-over 4-way alternative disassembler templatesJan Beulich2-2/+6
Commit 7c52e0e8658a, dropping the general concept of 4-way alternatives, for whatever reason, omitted cleaning up these two instances.
2020-06-25x86: move ImmExt processingJan Beulich2-5/+9
With abuses of ImmExt gone, all templates using it have operands. Move its main invocation into process_operands(), matching its secondary one for the SSE2AVX case.
2020-06-25x86: operand sizing prefixes can disambiguate insnsJan Beulich13-447/+1193
Use of an explicit data size or REX.W prefix is sufficient indication of the intended operation when operand size can't be derived from suffix or register operands. Avoid the ambiguity warning and make in particular immediate handling (sizing) cope with explicitly specified prefixes. Extending/reusing the noreg16 test made me notice a few cases of unintentional 32-bit addressing, which gets corrected at the same time.
2020-06-25x86: fix SYSRET disassembly, improve {,V}CVTSI2S{S,D} and PTWRITEJan Beulich19-231/+254
SYSRET can't use the same macro as IRET, since there's no 16-bit operand size form of it. Re-use LQ for it instead. Doing so made obvious that outside of 64-bit mode {,V}CVTSI2S{S,D} and PTWRITE should have an 'l' suffix printed only in suffix-always mode.
2020-06-25x86-64: REX prefix is invalid with VEX etcJan Beulich6-15/+29
Just like for the data size prefix (see commit 7a8655d2bbdc ["x86: don't abort() upon DATA16 prefix on (E)VEX encoded insn"]), any form of REX prefix is invalid with VEX/XOP/EVEX.
2020-06-25x86-64: honor REX prefixes for SSE2AVXJan Beulich4-29/+112
Legacy encoded insns do so, and their automatic conversion to AVX ones ought to produce functionally identical code. Therefore explicit REX prefixes cannot simply be ignored. This is in particular relevant because at least PCMPESTR{I,M}'s 64-bit forms couldn't be expressed in older gas by other than using a REX64 prefix.
2020-06-25x86: also refuse data size prefix on SIMD insnsJan Beulich8-14/+37
The data size prefix alters the meaning of legacy encoded SIMD insns, and hence shouldn't be accepted there. Use of it also leads to inconsistencies in SSE2AVX mode. Don't match insns with data size prefix against SSE2AVX templates.
2020-06-25x86: drop stray assignment from build_evex_prefix()Jan Beulich2-1/+5
Unlike in build_vex_prefix() this is not needed here.
2020-06-25Automatic date update in version.inGDB Administrator1-1/+1
2020-06-24Sync config, include and libiberty with GCCH.J. Lu12-279/+812
config/ 2020-06-24 H.J. Lu <hongjiu.lu@intel.com> Sync with GCC 2020-05-29 H.J. Lu <hjl.tools@gmail.com> PR bootstrap/95413 * cet.m4: Replace save_CFLAGS and save_LDFLAGS with cet_save_CFLAGS and cet_save_LDFLAGS. include/ 2020-06-24 H.J. Lu <hongjiu.lu@intel.com> Sync with GCC 2020-06-23 Nick Alcock <nick.alcock@oracle.com> * libiberty.h (bsearch_r): New. 2020-04-17 Martin Liska <mliska@suse.cz> Jonathan Yong <10walls@gmail.com> PR gcov-profile/94570 * filenames.h (defined): Do not define HAVE_DOS_BASED_FILE_SYSTEM for CYGWIN. libiberty/ 2020-06-23 Nick Alcock <nick.alcock@oracle.com> * bsearch_r.c: New file. * Makefile.in (CFILES): Add bsearch_r.c. (REQUIRED_OFILES): Add bsearch_r.o. * functions.texi: Regenerate. 2020-05-29 H.J. Lu <hjl.tools@gmail.com> PR bootstrap/95413 * configure: Regenerated. 2020-05-15 Iain Buclaw <ibuclaw@gdcproject.org> * d-demangle.c (dlang_attributes): Add @live attribute. * testsuite/d-demangle-expected: Add new tests. 2020-05-14 Rainer Schuetze <r.sagitario@gmx.de> Iain Buclaw <ibuclaw@gdcproject.org> * d-demangle.c (enum dlang_symbol_kinds): Remove enum. (struct dlang_info): New struct (dlang_decode_backref): New function. (dlang_backref): New function. (dlang_symbol_backref): New function. (dlang_type_backref): New function. (dlang_symbol_name_p): New function. (dlang_function_type_noreturn): New function. (dlang_function_type): Add 'info' parameter. Decode function type with dlang_function_type_noreturn. (dlang_function_args): Add 'info' parameter. (dlang_type): Add 'info' parameter. Handle back referenced types. (dlang_identifier): Replace 'kind' parameter with 'info'. Handle back referenced symbols. Split off decoding of plain identifiers to... (dlang_lname): ...here. (dlang_parse_mangle): Replace 'kind' parameter with 'info'. Decode function type and return with dlang_type. (dlang_parse_qualified): Replace 'kind' parameter with 'info', add 'suffix_modifier' parameter. Decode function type with dlang_function_type_noreturn. (dlang_parse_tuple): Add 'info' parameter. (dlang_template_symbol_param): New function. (dlang_template_args): Add 'info' parameter. Decode symbol parameter with dlang_template_symbol_param. Handle back referenced values, and externally mangled parameters. (dlang_parse_template): Add 'info' parameter. (dlang_demangle_init_info): New function. (dlang_demangle): Initialize and pass 'info' parameter. * testsuite/d-demangle-expected: Add new tests.
2020-06-24W/ Clang, compile/link C++ test programs with "-x c++"Pedro Alves4-12/+21
Some testcases want to compile .c files with a C++ compiler. So they pass the "c++" option to gdb_compile. That works fine with GCC, but with Clang, it results in: gdb compile failed, clang-5.0: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated] and the testcase is skipped with UNTESTED. A previous patch fixed a case like that in gdb.compile/compile-cplus.exp, by adding -Wno-deprecated to the build options. However, there are other testcases that use the same pattern, and all fail for the same reason. For example: gdb.base/info-types-c++.exp gdb.base/max-depth-c++.exp gdb.base/msym-lang.exp gdb.base/whatis-ptype-typedefs.exp gdb.btrace/rn-dl-bind.exp Fix this in a central place, within gdb_compile, by passing "-x c++" to the compiler driver when we're compiling/linking C++. This revealed that gdb.compile/compile-cplus.exp and gdb.arch/amd64-entry-value-paramref.exp tests are compiling an assembly file with the "c++" option, which would now fail to compile, with the C++ compiler not grokking the assembly, of course. We just need to not pass "c++" and all the other related C++ options when compiling an assembly file. gdb/testsuite/ChangeLog: 2020-06-24 Pedro Alves <palves@redhat.com> * gdb.arch/amd64-entry-value-paramref.exp: Use prepare_for_testing_full and don't pass "c++" for the .S file build spec. * gdb.compile/compile-cplus.exp: Don't compile $srcfile3 with $options, since it's an assembly file. Remove -Wno-deprecated. * lib/gdb.exp (gdb_compile): Pass "-x c++" explicitly when compiling C++ programs.
2020-06-24W/ Clang, compile C/C++ testcases with -Wno-unknown-warning-optionPedro Alves2-1/+24
Some C/C++ testcases unconditionally pass -Wno-foo as additional options to disable some warning. That is OK with GCC, because GCC accepts -Wno-foo silently even if it doesn't support -Wfoo. This is a feature which allows disabling warnings with newer compilers without breaking builds with older compilers. Clang however warns about unknown -Wno-foo by default, unless you pass -Wno-unknown-warning-option as well: $ gcc -Wno-foo test.c * nothing, compiles successfuly * $ clang -Wno-foo test.c warning: unknown warning option '-Wno-foo [-Wunknown-warning-option] This commit adds -Wunknown-warning-option centrally in gdb_compile, so that individual testcases don't have to worry about breaking older Clangs. IOW, this avoids this problematic scenario: #1 - A testcase compiles successfully with Clang version X. #2 - Clang version "X + 1" adds a new warning, enabled by default, which breaks the test. #3 - We add -Wno-newwarning to the testcase, fixing the testcase with clang "X + 1". #4 - Now building the test with Clang version X no longer works, due to "unknown warning option". gdb/testsuite/ChangeLog: 2020-06-24 Pedro Alves <palves@redhat.com> * lib/gdb.exp (gdb_compile): Update intro comment. If C/C++ with Clang, add "-Wno-unknown-warning-option" to the options.
2020-06-24Fixes PR 25475: ensure exec-file-mismatch "ask" always asks in case of mismatch.Philippe Waroquiers4-5/+24
As explained in https://sourceware.org/bugzilla/show_bug.cgi?id=25475, when the currently loaded file has no debug symbol, symbol_file_add_with_addrs does not ask a confirmation to the user before loading the new symbol file. The behaviour is not consistent when symbol_file_add_with_addrs is called due to exec-file-mismatch "ask" setting. The PR discusses several solutions/approaches. The preferred approach (suggested by Joel) is to ensure that GDB always asks a confirmation when it loads a new symbol file due to exec-file-mismatch, using a new SYMFILE add-flag. I tested this manually. If OK, we can remove the bypass introduced by Tom in 6b9374f1, in order to always answer to the 'load' question. gdb/ChangeLog 2020-06-24 Philippe Waroquiers <philippe.waroquiers@skynet.be> * symfile-add-flags.h: New flag SYMFILE_ALWAYS_CONFIRM. * exec.c (validate_exec_file): If from_tty, set both SYMFILE_VERBOSE (== from_tty) and SYMFILE_ALWAYS_CONFIRM. * symfile.c (symbol_file_add_with_addrs): if always_confirm and from_tty, unconditionally ask a confirmation.
2020-06-24bfd/riscv: tighten matching rules in riscv_scanAndrew Burgess2-4/+19
The following GDB behaviour was observed: (gdb) x/1i 0x0001014a 0x1014a <main+8>: jal 0x10132 <foo> (gdb) show architecture The target architecture is set automatically (currently riscv:rv32) (gdb) set architecture riscv:rv32 The target architecture is assumed to be riscv:rv32 (gdb) x/1i 0x0001014a 0x1014a <main+8>: 0x37e5 (gdb) Notice that initially we can disassemble the instruction (it's a compressed jal instruction), but after setting the architecture we can no longer disassemble the instruction. This is particularly puzzling as GDB initially thought the architecture was 'riscv:rv32', but when we force the architecture to be that, the disassembly stops working. This issue was introduced with this commit: commit c35d018b1a5ec604e49a807402c4205530b25ca8 Date: Mon Jan 27 15:19:30 2020 -0800 RISC-V: Fix gdbserver problem with handling arch strings. In this commit we try to make riscv_scan handle cases where we see architecture strings like 'riscv:rv32imc' (for example). Normally this wouldn't match as bfd_default_scan requires an exact match, so we extended riscv_scan to ignore trailing characters. Unfortunately the default riscv arch is called 'riscv', is 64-bit, and has its mach type set to 0, which I think is intended to pair with code is riscv-dis.c:riscv_disassemble_insn that tries to guess if we are 32 or 64 bit. What happens then is that 'riscv:rv32' is first tested against 'riscv' using bfd_default_scan, this doesn't match, we then compare this to 'riscv', but allowing trailing characters to be ignored, this matches, and our 'riscv:rv32' matches against the default (64-bit) architecture. The solution I propose is to prevent the default architecture from taking part in this "ignore trailing characters" extra match case, only the more specific 'riscv:rv32' and 'riscv:rv64' get this extra matching. bfd/ChangeLog: * cpu-riscv.c (riscv_scan): Don't allow shorter matches using the default architecture.
2020-06-24Fix a potential use of an uninitialised variable error in gold.Nick Clifton2-1/+6
* target-reloc.h (issue_discarded_error): Initialise the key_symndx variable.
2020-06-24ld: Correct --dependency-file orderH.J. Lu2-2/+7
Change ld --help output to -d, -dc, -dp Force common symbols to be defined --dependency-file FILE Write dependency file instead of -d, -dc Force common symbols to be defined --dependency-file FILE, -dp Write dependency file PR ld/26165 * lexsup.c (ld_options): Correct --dependency-file order.
2020-06-24csky: Don't generate unnecessary dynamic tagsH.J. Lu5-51/+16
Dynamic tags, DT_JMPREL, PLTREL and PLTRELSZ, are needed only if there are relocation entries for PLT. Don't generate them if there are no relocation entries for PLT. bfd/ PR ld/26083 * elf32-csky.c (csky_elf_size_dynamic_sections): Call _bfd_elf_add_dynamic_tags. ld/ PR ld/26083 * testsuite/ld-csky/tls-ie-v1.d: Updated. * testsuite/ld-csky/tls-ie.d: Likewise.
2020-06-24cris: Don't generate unnecessary dynamic tagsH.J. Lu7-58/+49
Dynamic tags, DT_JMPREL, PLTREL and PLTRELSZ, are needed only if there are relocation entries for PLT. Don't generate them if there are no relocation entries for PLT. bfd/ PR ld/26083 * elf32-cris.c (elf_cris_size_dynamic_sections): Call _bfd_elf_add_dynamic_tags. ld/ PR ld/26083 * testsuite/ld-cris/libdso-15b.d: Updated. * testsuite/ld-cris/libdso-1c.d: Likewise. * testsuite/ld-cris/libdso-1d.d: Likewise. * testsuite/ld-cris/libdso-15c.d: New file.
2020-06-24ld: Set non_ir_ref_regular on source for assignmentH.J. Lu5-3/+52
We need to set non_ir_ref_regular on the source for assignment to get the correct LTO resolution: 190 a27be7f4ad90c5ce PREVAILING_DEF real_g instead of 190 30c3b2d8f967f5ea PREVAILING_DEF_IRONLY real_g PR ld/26163 * ldexp.c (exp_fold_tree_1): Set non_ir_ref_regular on the source for assignment. * testsuite/ld-plugin/lto.exp: Run ld/26163 test. * testsuite/ld-plugin/pr26163a.c: New file. * testsuite/ld-plugin/pr26163b.c: Likewise.