aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2017-09-06Cast char constant to int in sizeof.expTom Tromey2-1/+6
PR gdb/22010 concerns a regression I introduced with the scalar printing changes. The bug is that this code in sizeof.exp: set signof_byte [get_integer_valueof "'\\377'" -1] can incorrectly compute sizeof_byte. One underlying problem here is that gdb's C parser doesn't treat a char constant as an int (this is PR 19973). However, it seems good to have an immediate fix for the regression. The simplest is to cast to an int here. testsuite/ChangeLog 2017-09-05 Tom Tromey <tom@tromey.com> PR gdb/22010: * gdb.base/sizeof.exp (check_valueof): Cast char constant to int.
2017-09-06Correct shell compatibility issue detected with pkgsrc.Kamil Rytarowski2-1/+5
String comparison of in a POSIX bourne shell must be done with '=', not '=='. For example the NetBSD sh(1) does not support it. gdb/ChangeLog 2017-09-06 Kamil Rytarowski <n54@gmx.com> * config/djgpp/djconfig.sh: Correct shell portability issue.
2017-09-06Fix calls in gdb.arch/thumb2-it.expThomas Preud'homme2-2/+6
Tests in gdb.arch/thumb2-it.exp call functions defined in assembly without type debugging information. Since 7022349d5c86bae74b49225515f42d2e221bd368 ("Stop assuming no-debug-info functions return int") this triggers an error which leads to many tests to FAIL. This patch cast the call to indicate the return type of the functions when calling them. 2017-09-06 Thomas Preud'homme <thomas.preudhomme@arm.com> gdb/testsuite/ * gdb.arch/thumb2-it.exp: Cast call to assembly defined function.
2017-09-06Define HAVE_NATIVE_GCORE_HOST on NetBSDKamil Rytarowski2-0/+5
NetBSD ships with gcore(1) againg since the version 2.0. This tool is functional and actively maintained. gdb/ChangeLog 2017-09-06 Kamil Rytarowski <n54@gmx.com> * configure.nat: Define HAVE_NATIVE_GCORE_HOST on NetBSD.
2017-09-06Add native target for FreeBSD/aarch64.John Baldwin6-0/+148
gdb/ChangeLog: * Makefile.in (ALLDEPFILES): Add mips-fbsd-nat.c. * NEWS: Mention new FreeBSD/mips native configuration. * configure.host: Add aarch64*-*-freebsd*. * configure.nat: Likewise. * aarch64-fbsd-nat.c: New file.
2017-09-06Add FreeBSD/aarch64 architecture.John Baldwin6-0/+258
Support for collecting and supplying general purpose and floating point register sets is provided along with signal frame unwinding. gdb/ChangeLog: * Makefile.in (ALL_64_TARGET_OBS): Add aarch64-fbsd-tdep.o. (ALLDEPFILES): Add aarch64-fbsd-tdep.c. * NEWS: Mention new FreeBSD/aarch64 target. * configure.tgt: Add aarch64*-*-freebsd*. * aarch64-fbsd-tdep.c: New file. * aarch64-fbsd-tdep.h: New file.
2017-09-06Add myself as a write-after-approval GDB maintainer.Kamil Rytarowski2-0/+5
gdb/ChangeLog: 2017-09-06 Kamil Rytarowski <n54@gmx.com> * MAINTAINERS (Write After Approval): Add Kamil Rytarowski.
2017-09-06x86-64: Add R_X86_64_converted_reloc_bitH.J. Lu8-22/+58
Add R_X86_64_converted_reloc_bit to relocation type to indicate if a relocation is converted from a GOTPCREL relocation. Linker now generates failed to convert GOTPCREL relocation; relink with --no-relax for all cases, including relocations against local symbols. bfd/ * elf64-x86-64.c (R_X86_64_converted_reloc_bit): New. (elf_x86_64_info_to_howto): Get the real relocation type by masking out R_X86_64_converted_reloc_bit. (elf_x86_64_check_tls_transition): Get the real relocation type by masking out R_X86_64_converted_reloc_bit. (elf_x86_64_convert_load_reloc): Set R_X86_64_converted_reloc_bit instead of setting converted_reloc. (elf_x86_64_relocate_section): Check R_X86_64_converted_reloc_bit instead of converted_reloc. Get the real relocation type by masking out R_X86_64_converted_reloc_bit. (elf_x86_64_link_setup_gnu_properties): Verify that the value of R_X86_64_converted_reloc_bit is valid. * elfxx-x86.h (converted_reloc): Removed. ld/ * testsuite/ld-x86-64/pr19609-2a.d: Updated. * testsuite/ld-x86-64/pr19609-2b.d: Likewise. * testsuite/ld-x86-64/pr19609-4a.d: Likewise. * testsuite/ld-x86-64/pr19609-4c.d: Likewise.
2017-09-06x86: Don't change r_type when performing TLS transitionsH.J. Lu3-25/+36
Don't change r_type when performing TLS transitions to avoid getting the relocation type with ELF32_R_TYPE again. * elf32-i386.c (elf_i386_relocate_section): Don't change r_type when calling elf_i386_tls_transition. Don't use ELF32_R_TYPE to get the relocation type again. * elf64-x86-64.c (elf_x86_64_relocate_section): Don't change r_type when calling elf_x86_64_tls_transition. Don't use ELF32_R_TYPE to get the relocation type again.
2017-09-06Fix accessing TLS variables with no debug infoJan Kratochvil5-2/+77
Since 2273f0ac95a7 ("change minsyms not to be relocated at read-time"), printing TLS symbols of objfiles with a non-zero base address, without debug info, fails. E.g., with: $ mv /usr/lib/debug /usr/lib/debug-x to get debug info out of the way, we get: $ echo 'int main(){}' | gcc -pthread -x c - $ ./gdb -q -ex start -ex 'p (int) errno' ./a.out Cannot access memory at address 0xffffef7c0698 instead of the expected: $1 = 0 The regression is not visible with glibc debuginfo installed. The problem is that we compute the address of TLS minsyms incorrectly. To trigger the problem, it is important that the variable is in an objfile with a non-zero base address. While glibc is a shared library for 'errno', it's easier for the testcase to use PIE instead of a shlib. For TLS variables in PT_EXEC the regression obviously does not happen. gdb/ChangeLog 2017-09-06 Jan Kratochvil <jan.kratochvil@redhat.com> * parse.c (find_minsym_type_and_address): Don't relocate addresses of TLS symbols. gdb/testsuite/ChangeLog 2017-09-06 Jan Kratochvil <jan.kratochvil@redhat.com> * gdb.threads/tls-nodebug-pie.c: New file. * gdb.threads/tls-nodebug-pie.exp: New file.
2017-09-06Automatic date update in version.inGDB Administrator1-1/+1
2017-09-05x86-64: Properly set converted_relocH.J. Lu6-4/+15
Linker now generates failed to convert GOTPCREL relocation; relink with --no-relax for more cases. bfd/ * elf64-x86-64.c (elf_x86_64_convert_load_reloc): Properly set converted_reloc. ld/ * testsuite/ld-x86-64/pr19609-5d.d: Updated. * testsuite/ld-x86-64/pr19609-7a.d: Likewise. * testsuite/ld-x86-64/pr19609-7c.d: Likewise.
2017-09-05Fix leak of auto_obstack objfile_per_bfd_storage->storage_obstack;Philippe Waroquiers2-1/+5
commit 23732b1e32dd58f7c731d9aee56ff0b22a645d53 Author: Pedro Alves <palves@redhat.com> Date: Tue Jun 27 16:22:08 2017 +0100 changed objfile_per_bfd_storage->storage_obstack from 'struct obstack storage_obstack;' to 'auto_obstack storage_obstack;' So the obstack is auto allocated when the objfile_per_bfd_storage ctor is manually called by get_objfile_bfd_data). However, the ctor call was still followed by a manual call to obstack_init (&storage->storage_obstack); This results in a bunch of leaks detected by valgrind, such as: ==24665== 4,064 bytes in 1 blocks are definitely lost in loss record 11,469 of 11,590 ==24665== at 0x4C27BF5: malloc (vg_replace_malloc.c:299) ==24665== by 0x5437B7: xmalloc (common-utils.c:44) ==24665== by 0x77CAA7: _obstack_begin_worker (obstack.c:141) ==24665== by 0x60168F: auto_obstack (gdb_obstack.h:70) ==24665== by 0x60168F: get_objfile_bfd_data(objfile*, bfd*) (objfiles.h:188) ==24665== by 0x601DB6: allocate_objfile(bfd*, char const*, enum_flags<objfile_flag>) (objfiles.c:423) ==24665== by 0x647753: symbol_file_add_with_addrs(bfd*, char const*, enum_flags<symfile_add_flag>, section_addr_info*, enum_flags<objfile_flag>, objfile*) (symfile.c:1158) ==24665== by 0x647C7B: symbol_file_add_separate(bfd*, char const*, enum_flags<symfile_add_flag>, objfile*) (symfile.c:1252) ==24665== by 0x4C7D79: elf_symfile_read(objfile*, enum_flags<symfile_add_flag>) (elfread.c:1270) ==24665== by 0x647CB4: read_symbols(objfile*, enum_flags<symfile_add_flag>) (symfile.c:861) ==24665== by 0x647809: syms_from_objfile_1 (symfile.c:1062) -> remove the manual call to obstack_init. Reg-tested on Debian 8/amd64, tests results are the same before/after the patch. valgrind still show some leaks, but less. gdb/ChangeLog 2017-09-05 Philippe Waroquiers <philippe.waroquiers@skynet.be> * objfiles.c (get_objfile_bfd_data): Remove useless obstack_init call.
2017-09-05x86-64: Improve GOTPCREL relocation conversionH.J. Lu6-110/+49
When GOTPCREL relocation conversion leads to relocation overflow, we may get a mysterious linker message, like relocation truncated to fit: R_X86_64_32S against symbol `foo' This patch changes the linker message to failed to convert GOTPCREL relocation; relink with --no-relax bfd/ * elf64-x86-64.c (elf_x86_64_convert_load_reloc): Remove the sec argument. Don't check relocation overflow. Avoid relocation overflow if --no-relax is used. Set converted_reloc on symbol if a GOTPCREL relocation is converted. (elf_x86_64_relocate_section): Issue a fatal error and suggest --no-relax if GOTPCREL relocation conversion leads to relocation overflow. * elfxx-x86.h (elf_x86_link_hash_entry): Add converted_reloc. ld/ * testsuite/ld-x86-64/pr19609-4e.d: Updated. * testsuite/ld-x86-64/pr19609-6a.d: Likewise.
2017-09-05Don't use -fdiagnostics-color=never for rustcTom Tromey2-1/+11
I noticed that the gdb.rust tests fail because the test suite passes -fdiagnostics-color=never to rustc. This is not a recognized rustc option, and the test suite already handles passing the appropriate option to the Rust compiler. This patch fixes the problem. testsuite/ChangeLog 2017-09-05 Tom Tromey <tom@tromey.com> * lib/gdb.exp (gdb_compile): Don't use universal_compile_options for rust.
2017-09-05Test different follow-exec-mode settings in gdb.multi/multi-arch-exec.expSimon Marchi2-7/+23
Using follow-exec-mode "new" takes a different code path than "same", so it's interesting to test this path in combination with a change in architecture of the inferior. This test fails if you remove the previous patch. gdb/testsuite/ChangeLog: * gdb.multi/multi-arch-exec.exp: Test with different "follow-exec-mode" settings. (do_test): New procedure.
2017-09-05Add thread after updating gdbarch when exec'ingSimon Marchi2-1/+10
As mentioned in the previous patch, we should avoid doing register reads after a process does an exec and before we've updated that inferior's gdbarch. Otherwise, we may interpret the registers using the wrong architecture. When a process does an exec with "follow-exec-mode new", a new inferior is added by follow_exec. The gdbarch of that new inferior is at first set to some default value, probably specific to the gdb build (I get "i386" here), which may not be the right one. It is updated later by the call to target_find_description. Before that point, if we try to read the inferior's registers, we may not interpret them correctly. This has been exposed by a failure in gdb.base/foll-exec-mode.exp after the previous patch, with: Remote 'g' packet reply is too long (expected 312 bytes, got 816 bytes) The call to "add_thread" done just after adding the inferior is problematic, because it ends up reading the registers (because the ptid is re-used, we end up doing a switch_to_thread to it, which tries to update stop_pc). The registers returned by gdbserver are the x86-64 ones, while we try to interpret them using the "i386" gdbarch. Postponing the call to add_thread to until the target description/gdbarch has been updated seems to fix the issue. As to why this issue was uncovered by the previous patch: what I think happened before that patch is that since we were updating stop_pc before switching to the new inferior, we were filling the regcache associated to the ptid (this worked fine as long as the architectures of the previous and new process images were the same). The call to switch_to_thread then worked, because the register read hit the regcache. Now, it triggers a register read, while the gdbarch is not set correctly, leading to the "reply is too long" error. If this is right, it sounds wrong that we delete and re-add a thread with the same ptid, and are able to access the registers from the deleted thread. When we delete a thread, should we clear the regcache associated to that ptid, so that the new thread starts with a fresh/empty regcache? gdb/ChangeLog: * infrun.c (follow_exec): Call add_thread after target_find_description.
2017-09-05Read stop_pc after updating the gdbarch when exec'ingSimon Marchi2-2/+7
When an inferior execs and changes architecture (e.g. 64 bits to 32 bits), the gdbarch associated to the inferior is updated by the follow_exec call in handle_inferior_event_1. We should avoid doing any register read before that point, because the registers sent by the remote side will be those of the new architecture, but we would interpret them using the old architecture. We do just that by setting stop_pc during this window, which obviously requires reading the registers. This results in gdb.multi/multi-arch-exec.exp failing, GDB outputting the following error: Truncated register 50 in remote 'g' packet This patch fixes that by postponing the setting of stop_pc to after we've updated the inferior gdbarch. This bug was hiding another problem, and as such introduces some failures in gdb.base/foll-exec-mode.exp. The following patch takes care of that. gdb/ChangeLog: * infrun.c (handle_inferior_event_1): When exec'ing, read stop_pc after follow_exec.
2017-09-05Improve "'g' reply is is to long" error messageSimon Marchi2-1/+6
... by adding the expected size, and the received size. I found this useful when debugging gdbarch/remote issues, since it gives a hint of what gdb expects and what the remote sent. gdb/ChangeLog: * remote.c (process_g_packet): Update error message.
2017-09-05Add i386.o to gdb_target_obs for x86_64-* targetsYao Qi2-7/+13
This patch fixes the build failure caused by 22916b0 (Convert the rest x86 target descriptions). gdb: 2017-09-05 Yao Qi <yao.qi@linaro.org> * configure.tgt (gdb_target_obs): Add i386.o for x86_64-* targets.
2017-09-05eval.c:evaluate_subexp_standard: Factor out function call handlingPedro Alves2-451/+482
While working on the no-debug-info debugging improvements, I found evaluate_subexp_standard's function call code unnecessarily long and hard to navigate and debug. The use of goto doesn't help either. This commit tries to improve things by factoring out the function-call-related code to separate helper functions. gdb/ChangeLog: 2017-09-05 Pedro Alves <palves@redhat.com> * eval.c (eval_call, evaluate_funcall): New functions, factored out from ... (evaluate_subexp_standard): ... this.
2017-09-05Fix a buffer overrun when parsing a corrupt MIPS ELF binary.Nick Clifton2-3/+9
PR 21995 * readelf.c (process_mips_specific): Add checks for a NULL data pointer.
2017-09-05Convert the rest x86 target descriptionsYao Qi30-2568/+203
This patch changes the rest of x86 target descriptions in GDB and GDBserver. gdb: 2017-09-05 Yao Qi <yao.qi@linaro.org> * amd64-tdep.c (amd64_target_description): Create target descriptions. (_initialize_amd64_tdep): Don't call functions initialize_tdesc_amd64_*. Add self tests. * arch/amd64.c (amd64_create_target_description): Add parameter is_linux. Call set_tdesc_osabi if is_linux is true. * arch/amd64.h (amd64_create_target_description): Update the declaration. * arch/i386.c (i386_create_target_description): Add parameter is_linux. Call set_tdesc_osabi if is_linux is true. * arch/i386.h (i386_create_target_description): Update declaration. * configure.tgt: Add i386.o to gdb_target_obs. * features/Makefile (XMLTOC): Remove i386/*.xml. * features/i386/amd64-avx-avx512.c: Remove. * features/i386/amd64-avx-mpx-avx512-pku.c: Remove. * features/i386/amd64-avx-mpx.c: Remove. * features/i386/amd64-avx.c: Remove. * features/i386/amd64-mpx.c: Remove. * features/i386/amd64.c: Remove. * features/i386/i386-avx-avx512.c: Remove. * features/i386/i386-avx-mpx-avx512-pku.c: Remove. * features/i386/i386-avx-mpx.c: Remove. * features/i386/i386-avx.c: Remove. * features/i386/i386-mmx.c: Remove. * features/i386/i386-mpx.c: Remove. * features/i386/i386.c: Remove. * i386-tdep.c: Don't include features/i386/i386*.c., include target-descriptions.h and arch/i386.h. (i386_target_description): Create target descriptions. (i386_gdbarch_init): Don't call initialize_tdesc_i386_* functions. Do self tests. gdb/gdbserver: 2017-09-05 Yao Qi <yao.qi@linaro.org> * configure.srv (srv_i386_regobj): Remove. (srv_amd64_regobj): Remove. (srv_regobj): Set it to "" for x86 non-linux targets. * linux-x86-tdesc.c (i386_linux_read_description): * lynx-i386-low.c: Include x86-xstate.h and arch/i386.h. (init_registers_i386): Remove the declaration. (tdesc_i386): Remove the declaration. (lynx_i386_arch_setup): Call i386_create_target_description. * nto-x86-low.c: Likewise. * win32-i386-low.c [__x86_64__]: include arch/amd64.h. [!__x86_64__]: include arch/i386.h. (i386_arch_setup) [__x86_64__]: Call amd64_create_target_description.
2017-09-05Remove features/i386/amd64-*linux.c and features/i386/x32-*linux.cYao Qi11-1998/+13
gdb: 2017-09-05 Yao Qi <yao.qi@linaro.org> * features/Makefile (XMLTOC): Remove i386/amd64XXX-linux.xml. * features/i386/amd64-avx-avx512-linux.c: Removed. * features/i386/amd64-avx-linux.c: Removed. * features/i386/amd64-avx-mpx-avx512-pku-linux.c: Removed. * features/i386/amd64-avx-mpx-linux.c: Removed. * features/i386/amd64-linux.c: Removed. * features/i386/amd64-mpx-linux.c: Removed. * features/i386/x32-avx-avx512-linux.c: Removed. * features/i386/x32-avx-linux.c: Removed. * features/i386/x32-linux.c: Removed.
2017-09-05[GDBserver] Shorten srv_amd64_linux_xmlfilesYao Qi2-1/+6
GDBserver now is able to generate target descriptions from features, so don't need to remember these target description files. Note that it should be i386/amd64-avx-avx512-linux.xml instead of i386/amd64-avx-avx512.xml in $srv_amd64_linux_xmlfiles. This patch removes it anyway. gdb/gdbserver: 2017-09-05 Yao Qi <yao.qi@linaro.org> * configure.srv (srv_amd64_linux_xmlfiles): Remove i386/amd64-XXX-linux from it.
2017-09-05[GDBserver] Use pre-generated amd64-linux tdesc as testYao Qi2-9/+10
Now, all these amd64-linux pre-generated tdesc can be used as test, so don't need to build them if $development is false. gdb/gdbserver: 2017-09-05 Yao Qi <yao.qi@linaro.org> * configure.srv: Empty srv_amd64_linux_regobj if $development is false. (ipa_amd64_linux_regobj): Remove. (ipa_x32_linux_regobj): Remove.
2017-09-05Convert amd64-linux target descriptionsYao Qi14-210/+375
This patch changes amd64-linux target descriptions so that they can be dynamically generated in both GDB and GDBserver. gdb/gdbserver: 2017-09-05 Yao Qi <yao.qi@linaro.org> * Makefile.in (arch-amd64.o): New rule. * configure.srv: Append arch-amd64.o. * linux-amd64-ipa.c: Include common/x86-xstate.h. (get_ipa_tdesc): Call amd64_linux_read_description. (initialize_low_tracepoint): Don't call init_registers_x32_XXX and init_registers_amd64_XXX. * linux-x86-low.c (x86_linux_read_description): Call amd64_linux_read_description. (x86_get_ipa_tdesc_idx): Call amd64_get_ipa_tdesc_idx. (initialize_low_arch): Don't call init_registers_x32_XXX and init_registers_amd64_XXX. * linux-x86-tdesc-selftest.c: Declare init_registers_amd64_XXX and tdesc_amd64_XXX. [__x86_64__] (amd64_tdesc_test): New function. (initialize_low_tdesc) [__x86_64__]: Call init_registers_x32_XXX and init_registers_amd64_XXX. * linux-x86-tdesc.c: Include arch/amd64.h. (xcr0_to_tdesc_idx): New function. (i386_linux_read_description): New function. (amd64_get_ipa_tdesc_idx): New function. * linux-x86-tdesc.h (amd64_get_ipa_tdesc_idx): Declare. (amd64_get_ipa_tdesc): Declare. gdb: 2017-09-05 Yao Qi <yao.qi@linaro.org> * amd64-linux-tdep.c: Include arch/amd64.h. Don't include features/i386/*.c. (amd64_linux_read_description): Call amd64_create_target_description. * arch/amd64.c: New file. * arch/amd64.h: New file. * configure.tgt (x86_64-*-linux*): Append amd64.o. * Makefile.in (ALL_64_TARGET_OBS): Append amd64.o.
2017-09-05Lazily and dynamically create amd64-linux target descriptionsYao Qi13-54/+599
This patch starts to use the generate c feature files to dynamically create amd64-linux target descriptions. gdb: 2017-09-05 Yao Qi <yao.qi@linaro.org> * amd64-linux-tdep.c: Don't include amd64-XXX-linux and x32-XXX-linux.c. Include 64bit-XX.c and x32-XX.c. (amd64_linux_read_description): Create target descriptions. (_initialize_amd64_linux_tdep): Don't call initialize_tdesc_XXX functions. Add unit tests. * features/Makefile (FEATURE_XMLFILES): Append 64bit-XXX.xml and x32-core.xml. * features/i386/64bit-avx.c: Generated. * features/i386/64bit-avx512.c: Generated. * features/i386/64bit-core.c: Generated. * features/i386/64bit-linux.c: Generated. * features/i386/64bit-mpx.c: Generated. * features/i386/64bit-pkeys.c: Generated. * features/i386/64bit-segments.c: Generated. * features/i386/64bit-sse.c: Generated. * features/i386/x32-core.c: Generated. * target-descriptions.c (maint_print_c_tdesc_cmd): Print feature c files for amd64-linux and x32-linux.
2017-09-05Centralize amd64-linux target descriptionsYao Qi4-52/+47
This patch adds a new function amd64_linux_read_description, which creates amd64-linux target descriptions according to its two arguments, xcr0 and is_x32. gdb: 2017-09-05 Yao Qi <yao.qi@linaro.org> * amd64-linux-tdep.c (amd64_linux_read_description): New function. (amd64_linux_core_read_description): Call amd64_linux_read_description. (amd64_linux_init_abi): Likewise. (amd64_x32_linux_init_abi): Likewise. * amd64-linux-tdep.h (amd64_linux_read_description): Declare. * x86-linux-nat.c (x86_linux_read_description): Call amd64_linux_read_description.
2017-09-05Update comments in amd64_linux_core_read_descriptionYao Qi2-3/+8
gdb: 2017-09-05 Yao Qi <yao.qi@linaro.org> * amd64-linux-tdep.c (amd64_linux_core_read_description): Update comments.
2017-09-05[GDBserver] Shorten srv_i386_linux_xmlfilesYao Qi2-1/+6
GDBserver now is able to generate target descriptions from features, so don't need to remember these target description files. gdb/gdbserver: 2017-09-05 Yao Qi <yao.qi@linaro.org> * configure.srv (srv_i386_linux_xmlfiles): Remove i386/i386-XXX-linux.xml from it.
2017-09-05[GDBserver] Use pre-generated tdesc as testYao Qi6-87/+114
Now, these *-generate.c files are only used in GDBserver for unit test. If $development is false (in release), these *-generate.c files won't be used at all. gdb/gdbserver: 2017-09-05 Yao Qi <yao.qi@linaro.org> * configure.srv: Set srv_i386_linux_regobj empty if $development is false. * linux-i386-ipa.c (initialize_low_tracepoint): Don't call initialize_low_tdesc. * linux-x86-low.c (initialize_low_arch): Wrap initialize_low_tdesc with #if initialize_low_tdesc. * linux-x86-tdesc-selftest.c: New file. * linux-x86-tdesc.c: Move code to linux-x86-tdesc-selftest.c.
2017-09-05Remove features/i386/i386-*linux.cYao Qi9-1118/+11
Now, features/i386/i386-XXX-linux.c are not used, remove them. gdb: 2017-09-05 Yao Qi <yao.qi@linaro.org> * features/Makefile (XMLTOC): Remove i386/i386-XX-linux.xml. * features/i386/i386-avx-avx512-linux.c: Remove. * features/i386/i386-avx-linux.c: Remove. * features/i386/i386-avx-mpx-avx512-pku-linux.c: Remove. * features/i386/i386-avx-mpx-linux.c: Remove. * features/i386/i386-linux.c: Remove. * features/i386/i386-mmx-linux.c: Remove. * features/i386/i386-mpx-linux.c: Remove.
2017-09-05Share i386-linux target description between GDB and GDBserverYao Qi15-77/+178
The code on creating i386-linux target descriptions are quite similar between GDB and GDBserver, so this patch moves them into a shared file arch/i386.c. I didn't name it as i386-linux.c, because I want to reuse it to create other i386 non-linux target descriptions later. gdb: 2017-09-05 Yao Qi <yao.qi@linaro.org> * Makefile.in (ALL_TARGET_OBS): Add i386.o. (SFILES): Add arch/i386.c. (HFILES_NO_SRCDIR): Add arch/i386.h. * arch/i386.c: New file. * arch/i386.h: New file. * arch/tdesc.h (allocate_target_description): Declare. (set_tdesc_architecture): Declare. (set_tdesc_osabi): Declare. * configure.tgt (i[34567]86-*-linux*): Add i386.o. * i386-linux-tdep.c: Don't include ../features/i386/32bit-XXX.c. include arch/i386.h. (i386_linux_read_description): Remove code and call i386_create_target_description. (set_tdesc_architecture): New function. (set_tdesc_osabi): New function. * target-descriptions.h (allocate_target_description): Remove. gdb/gdbserver: 2017-09-05 Yao Qi <yao.qi@linaro.org> * Makefile.in (arch-i386.o): New rule. * configure.srv (i[34567]86-*-linux*): Add arch-i386.o. (x86_64-*-linux*): Likewise. * linux-x86-tdesc.c: Don't include ../features/i386/32bit-XXX.c, include arch/i386.h. (i386_linux_read_description): Remove code and call i386_create_target_description. * tdesc.c (allocate_target_description): New function. * tdesc.h (set_tdesc_architecture): Remove declaration. (set_tdesc_osabi): Likewise.
2017-09-05Dynamically composite xml in reply to GDBYao Qi15-39/+150
GDBserver still uses pre-generated target descriptions in order to reply to GDB's query on target description (see xml-builtin-generated.c in GDBserver build directory). This patch teaches GDBserver to create XML contents according to the target descriptions rather than using pre-generated ones. First, change target feature c files to pass the feature xml file name to tdesc_create_feature, so that target description in GDBserver can record them, and create XML contents from these features in buffer, like ... <xi:include href="$FEATURE1_XML_NAME"/> <xi:include href="$FEATURE2_XML_NAME"/> ... and send this buffer back to GDB. Note that this patch reuses target_desc.xmltarget a little bit, which is to hold the XML contents dynamically generated in tdesc_get_features_xml. However, it is not xfree'ed in ~target_desc, because we can't tell it is from xstrdup or a literal string. Since we don't delete target_desc, there is no memory leak yet. After we change all target descriptions to the new style, target_desc.xmltarget is from xstrdup, then, we can safely xfree it in ~target_desc. gdb: 2017-09-05 Yao Qi <yao.qi@linaro.org> * arch/tdesc.h (tdesc_create_feature): Add an argument xml. * target-descriptions.c (tdesc_create_feature): Likewise, and adjust code. * features/i386/32bit-avx.c: Re-generated. * features/i386/32bit-avx512.c: Re-generated. * features/i386/32bit-core.c: Re-generated. * features/i386/32bit-linux.c: Re-generated. * features/i386/32bit-mpx.c: Re-generated. * features/i386/32bit-pkeys.c: Re-generated. * features/i386/32bit-sse.c: Re-generated. gdb/gdbserver: 2017-09-05 Yao Qi <yao.qi@linaro.org> * linux-x86-tdesc.c: Don't include <inttypes.h>. (i386_linux_read_description) [!IN_PROCESS_AGENT]: Call set_tdesc_architecture and set_tdesc_osabi. Remove code setting .xmltarget. * server.c (get_features_xml): Call tdesc_get_features_xml. * tdesc.c (set_tdesc_architecture): New function. (set_tdesc_osabi): New function. (tdesc_get_features_xml): New function. (tdesc_create_feature): Add an argument. * tdesc.h (struct target_desc) <features>: New field. <arch, osabi>: New field. (~target_desc): xfree features, arch, and osabi. (target_desc::oerator==): Don't compare .xmltarget. [!IN_PROCESS_AGENT] (set_tdesc_architecture): Declare. (set_tdesc_osabi): Likewise. (tdesc_get_features_xml): Likewise.
2017-09-05[GDBserver] unit test to i386_tdescYao Qi5-1/+102
This patch adds a unit test in GDBserver to test dynamically created target descriptions equal these pre-generated ones. gdb/gdbserver: 2017-09-05 Yao Qi <yao.qi@linaro.org> * linux-x86-tdesc.c: Include selftest.h. (i386_tdesc_test): New function. (initialize_low_tdesc): Call selftests::register_test. * tdesc.h: Include regdef.h. (target_desc): Override operator == and !=. gdb: 2017-09-05 Yao Qi <yao.qi@linaro.org> * regformats/regdef.h (struct reg): Override operator == and !=.
2017-09-05[GDBserver] Centralize tdesc for i386-linuxYao Qi21-166/+491
tdesc_i386_XXX_linux is used in many places in linux-x86-low.c and this patch adds a new function i386_linux_read_description to return the right tdesc according to xcr0. i386_linux_read_description is quite similar to the counterpart in GDB, and the following patch will share the duplicated code, so this patch adds arch/tdesc.h includes the declarations of various tdesc apis which are used by the shared code. The generated c feature files can include arch/tdesc.h only. gdb/gdbserver: 2017-09-05 Yao Qi <yao.qi@linaro.org> * configure.srv (srv_tgtobj): Append linux-x86-tdesc.o. (ipa_obj): Likewise. * linux-i386-ipa.c: Include common/x86-xstate.h (get_ipa_tdesc): Call i386_linux_read_description. (initialize_low_tracepoint): Don't call init_registers_XXX functions, call initialize_low_tdesc instead. * linux-x86-low.c (x86_linux_read_description): Call i386_linux_read_description. (initialize_low_arch): Don't call init_registers_i386_XXX functions, call initialize_low_tdesc. * linux-x86-tdesc.c: New file. * linux-x86-tdesc.h (x86_linux_tdesc): New X86_TDESC_LAST. (i386_get_ipa_tdesc_idx): Declare. (i386_get_ipa_tdesc): Declare. (initialize_low_tdesc): Declare. gdb: 2017-09-05 Yao Qi <yao.qi@linaro.org> * arch/tdesc.h: New file. * regformats/regdat.sh: Generate code using tdesc_create_reg. * target-descriptions.c: Update comments. * target-descriptions.h: Include "arch/tdesc.h". Remove the declarations. * features/i386/32bit-avx.c: Re-generated. * features/i386/32bit-avx512.c: Re-generated. * features/i386/32bit-core.c: Re-generated. * features/i386/32bit-linux.c: Re-generated. * features/i386/32bit-mpx.c: Re-generated. * features/i386/32bit-pkeys.c: Re-generated. * features/i386/32bit-sse.c: Re-generated.
2017-09-05Return X86_TDESC_MMX in x86_get_ipa_tdesc_idxYao Qi2-1/+7
gdb/gdbserver: 2017-09-05 Yao Qi <yao.qi@linaro.org> * linux-x86-low.c (x86_get_ipa_tdesc_idx): Use X86_TDESC_MMX instead of 0.
2017-09-05Use VEC for target_desc.reg_defsYao Qi7-32/+61
Nowadays, target_desc.reg_defs is a pointer points to a pre-generated array, which is not flexible. This patch changes it from an array to a VEC so that GDBserver can create target descriptions dynamically later. Instead of using pre-generated array, the -generated.c calls VEC_safe_push to add each register to vector. Since target_desc.reg_defs is used in IPA, we need to build common/vec.c for IPA too. gdb/gdbserver: 2017-09-05 Yao Qi <yao.qi@linaro.org> * Makefile.in (IPA_OBJS): Add vec-ipa.o * regcache.c (get_thread_regcache): Use VEC_length. (init_register_cache): Likewise. (regcache_cpy): Likewise. (registers_to_string): Iterate reg_defs via VEC_iterate. (find_regno): Likewise. (find_register_by_number): Use VEC_index. (register_size): Call find_register_by_number. (register_data): Call find_register_by_number. (supply_regblock): Use VEC_length. (regcache_raw_read_unsigned): Likewise. * tdesc.c (init_target_desc): Iterate reg_defs via VEC_iterate. (default_description): Update initializer. (copy_target_description): Don't update field num_registers. * tdesc.h (struct target_desc) <reg_defs>: Change it to VEC. <num_registers>: Remove. gdb: 2017-09-05 Yao Qi <yao.qi@linaro.org> * regformats/regdat.sh: Update generated code.
2017-09-05Adjust code generated by regformats/regdat.shYao Qi2-8/+13
regformats/regdat.sh generate some *-generated.c files when GDBserver is built. Each .c file has some static variables, which are only used within function init_registers_XXX, like this, static struct reg regs_i386_linux[] = { { "eax", 0, 32 }, { "ecx", 32, 32 }, ... }; static const char *expedite_regs_i386_linux[] = { "ebp", "esp", "eip", 0 }; static const char *xmltarget_i386_linux = "i386-linux.xml"; void init_registers_i386_linux (void) { ... } This patch moves these static variables' definitions to function init_registers_XXX, so the generated files look like this, void init_registers_i386_linux (void) { static struct target_desc tdesc_i386_linux_s; struct target_desc *result = &tdesc_i386_linux_s; static struct reg regs_i386_linux[] = { ... }; static const char *expedite_regs_i386_linux[] = { "ebp", "esp", "eip", 0 }; static const char *xmltarget_i386_linux = "i386-linux.xml"; ... } We want GDBserver create target descriptions dynamically in each init_registers_XXXX functions, so this patch moves all the related code into function init_registers_XXXX, so that the following patch can easily change function init_registers_XXXX to create target description dynamically, rather than using current pre-generated array. gdb: 2017-09-05 Yao Qi <yao.qi@linaro.org> * regformats/regdat.sh: Adjust code order.
2017-09-05expprint: Fix format string warningSimon Marchi2-1/+6
My compiler (gcc 5.4.0, clang 3.8) gives this warning: /home/emaisin/src/binutils-gdb/gdb/expprint.c: In lambda function: /home/emaisin/src/binutils-gdb/gdb/expprint.c:1055:35: error: format not a string literal and no format arguments [-Werror=format-security] fprintf_filtered (stream, mod); ^ Fix it by not using the passed string as the format string. gdb/ChangeLog: * expprint.c (dump_subexp_body_standard): Use constant format string in fprintf_filtered call.
2017-09-04Define an error function in the PPC simulator library.John Baldwin2-0/+15
Previously this used the error function from GDB directly when linked against GDB instead of the error method in the host callbacks structure. This was exposed via a link error when GDB was converted to C++. The error function invokes the error callback similar to sim_io_error. Note that there are also error functions in sim/ppc/main.c and sim/ppc/misc.c. The ppc libsim.a expects each consumer to provide several symbols used by the library including "error". sim-calls.c provides these symbols when the library is linked into gdb. The dgen, igen, tmp-filter, tmp-ld-decode, tmp-ld-cache, and tmp-ld-insn programs use the functions from misc.c. psim uses the functions from main.c. sim/ppc/ChangeLog: PR sim/20863 * sim_calls.c (error): New function.
2017-09-04Enable support for x86 debug registers on NetBSD.John Baldwin3-6/+17
NetBSD recently added PT_GETDBREGS and PT_SETDBREGS ptrace operations that match the existing ones supported by x86-bsd-nat.c. NetBSD's headers do not provide the DBREG_DRX helper macro, so define a local version in x86-bsd-nat.c. In addition, add the x86-nat.o and x86-dregs.o object files to the native NetBSD x86 build targets. gdb/ChangeLog: * configure.nat: Add "x86-nat.o x86-dregs.o" for NetBSD/amd64 and NetBSD/i386. * x86-bsd-nat.c [!DBREG_DRX && __NetBSD__]: Define DBREG_DRX.
2017-09-04Make <sys/user.h> include in bsd-kvm.c conditional on HAVE_SYS_USER_H.John Baldwin2-0/+6
NetBSD has recently removed <sys/user.h>. gdb/ChangeLog: * bsd-kvm.c: Make <sys/user.h> conditional on HAVE_SYS_USER_H.
2017-09-04Define _KMEMUSER before including BSD kernel headers.John Baldwin4-0/+9
Recent versions of NetBSD hide certain kernel structures needed by the KVM target from userland unless this macro is defined. gdb/ChangeLog: * bsd-kvm.o: Define _KMEMUSER. * configure.ac: Define _KMEMUSER when checking for "struct lwp". * configure: Regenerate.
2017-09-04Include "x86-xstate.h" for X86_XSTATE_* constants.John Baldwin3-0/+7
gdb/ChangeLog: * amd64-fbsd-nat.c: Add include of "x86-xstate.h". * i386-fbsd-nat.c: Likewise.
2017-09-05Automatic date update in version.inGDB Administrator1-1/+1
2017-09-05Missing relocation R_PPC_VLE_ADDR20 and add VLE flag to details in readelfAlexander Fedotov-B5561310-2/+101
include/ * elf/ppc.h (R_PPC_VLE_ADDR20): New relocation. bfd/ * elf32-ppc.c (ppc_elf_howto_raw): Add R_PPC_VLE_ADDR20. (ppc_elf_check_relocs): Handle it. (ppc_elf_vle_split20): New function. (ppc_elf_relocate_section): Handle R_PPC_VLE_ADDR20. binutils/ * readelf.c (get_elf_section_flags): Add VLE. (process_section_headers): Add VLE key to details. gas/ * config/tc-ppc.c (md_parse_option): Handle "mno-vle" flag. (ppc_elf_section_letter): New function. * config/tc-ppc.h (md_elf_section_letter): New. * testsuite/gas/elf/section10.d: Adjust for VLE.
2017-09-04Explicitly include <array> for std::array<>.John Baldwin2-0/+5
gdb/ChangeLog: * unittests/array-view-selftests.c: Add include of <array>.
2017-09-04Catch up to recent changes to call_function_by_hand().John Baldwin2-1/+6
gdb/ChangeLog: * spu-tdep.c (flush_ea_cache): Add missing argument to call_function_by_hand.