aboutsummaryrefslogtreecommitdiff
path: root/gdb
AgeCommit message (Collapse)AuthorFilesLines
2018-05-17Fix for dwz-related crashTom Tromey2-34/+67
PR symtab/23010 reports a crash that occurs when using -readnow on a dwz-generated debuginfo file. The crash occurs because the DWARF has a partial CU with no language set, and then a full CU that references this partial CU using DW_AT_abstract_origin. In this case, the partial CU is read by dw2_expand_all_symtabs using language_minimal; but then this conflicts with the creation of the block's symbol table in the C++ CU. This patch fixes the problem by arranging for partial CUs not to be read by -readnow. I tend to think that it doesn't make sense to read a partial CU in isolation -- they should only be read when imported into some other CU. In conjunction with some other patches I am going to post, this also fixes the Rust -readnow crash that Jan reported. There are two problems with this patch: 1. It is difficult to reason about. There are many cases where I've patched the code to call init_cutu_and_read_dies with the flag set to "please do read partial units" -- but I find it difficult to be sure that this is always correct. 2. It is still missing a standalone test case. This seemed hard. 2018-05-17 Tom Tromey <tom@tromey.com> PR symtab/23010: * dwarf2read.c (load_cu, dw2_do_instantiate_symtab) (dw2_instantiate_symtab): Add skip_partial parameter. (dw2_find_last_source_symtab, dw2_map_expand_apply) (dw2_lookup_symbol, dw2_expand_symtabs_for_function) (dw2_expand_all_symtabs, dw2_expand_symtabs_with_fullname) (dw2_expand_symtabs_matching_one) (dw2_find_pc_sect_compunit_symtab) (dw2_debug_names_lookup_symbol) (dw2_debug_names_expand_symtabs_for_function): Update. (init_cutu_and_read_dies): Add skip_partial parameter. (process_psymtab_comp_unit, build_type_psymtabs_1) (process_skeletonless_type_unit, load_partial_comp_unit) (psymtab_to_symtab_1): Update. (load_full_comp_unit): Add skip_partial parameter. (process_imported_unit_die, dwarf2_read_addr_index) (follow_die_offset, dwarf2_fetch_die_loc_sect_off) (dwarf2_fetch_constant_bytes, dwarf2_fetch_die_type_sect_off) (read_signatured_type): Update.
2018-05-17value.c: Remove unused variablesSimon Marchi2-6/+7
Obvious patch to remove unused local variables (found by adding -Wunused). I didn't touch this one in value_fetch_lazy, because check_typedef could have a desired side-effect. 3743 struct type *type = check_typedef (value_type (val)); gdb/ChangeLog: * value.c (release_value): Remove unused variable. (record_latest_value): Likewise. (access_value_history): Likewise. (preserve_values): Likewise.
2018-05-17Initialize py_type_printers in ext_lang_type_printersTom Tromey2-1/+6
When running gdb in the build directory without passing --data-directory, I noticed I could provoke a crash by: $ ./gdb -nx ./gdb (gdb) ptype/o struct dwarf2_per_objfile ... and then trying to "q" out at the pagination prompt. valgrind complained about an uninitialized use of py_type_printers. Initializing this member fixes the bug. I believe this bug can occur even when the gdb Python libraries are available, for example if get_type_recognizers fails. Tested by hand on x86-64 Fedora 26. No test case because it seemed difficult to guarantee failures. gdb/ChangeLog 2018-05-17 Tom Tromey <tom@tromey.com> * extension.h (struct ext_lang_type_printers) <py_type_printers>: Initialize.
2018-05-16PR gdb/22286: linux-nat-trad: Support arbitrary register widthsMaciej W. Rozycki2-10/+26
Update `fetch_register' and `store_register' code to support arbitrary register widths rather than only ones that are a multiply of the size of the `ptrace' data type used with PTRACE_PEEKUSR and PTRACE_POKEUSR requests to access registers. Remove associated assertions, correcting an issue with accessing the DSPControl (`$dspctl') register on n64 MIPS native targets: (gdb) print /x $dspctl .../gdb/linux-nat-trad.c:50: internal-error: void linux_nat_trad_target::fetch_register(regcache*, int): Assertion `(size % sizeof (PTRACE_TYPE_RET)) == 0' failed. A problem internal to GDB has been detected, further debugging may prove unreliable. Quit this debugging session? (y or n) n This is a bug, please report it. For instructions, see: <http://www.gnu.org/software/gdb/bugs/>. .../gdb/linux-nat-trad.c:50: internal-error: void linux_nat_trad_target::fetch_register(regcache*, int): Assertion `(size % sizeof (PTRACE_TYPE_RET)) == 0' failed. A problem internal to GDB has been detected, further debugging may prove unreliable. Create a core file of GDB? (y or n) n Command aborted. (gdb) All registers are now reported correctly and their architectural hardware widths respected: (gdb) print /x $dspctl $1 = 0x55aa33cc (gdb) info registers zero at v0 v1 R0 0000000000000000 0000000000000001 000000fff7ffeb20 0000000000000000 a0 a1 a2 a3 R4 0000000000000001 000000ffffffeaf8 000000ffffffeb08 0000000000000000 a4 a5 a6 a7 R8 000000fff7ee3800 000000fff7ede8f0 000000ffffffeaf0 2f2f2f2f2f2f2f2f t0 t1 t2 t3 R12 0000000000000437 0000000000000002 000000fff7ffd000 0000000120000ad0 s0 s1 s2 s3 R16 000000fff7ee2068 0000000120000e60 0000000000000000 0000000000000000 s4 s5 s6 s7 R20 0000000000521ec8 0000000000522608 0000000000000000 0000000000000000 t8 t9 k0 k1 R24 0000000000000000 0000000120000d9c 0000000000000000 0000000000000000 gp sp s8 ra R28 0000000120019030 000000ffffffe990 000000ffffffe990 000000fff7d5b88c status lo hi badvaddr 0000000000109cf3 0000000000005ea5 0000000000000211 000000fff7fc6fe0 cause pc 0000000000800024 0000000120000dbc fcsr fir hi1 lo1 00000000 00f30000 0000000000000000 0101010101010101 hi2 lo2 hi3 lo3 0202020202020202 0303030303030303 0404040404040404 0505050505050505 dspctl restart 55aa33cc 0000000000000000 (gdb) NB due to the lack of access to 64-bit DSP hardware all DSP register values in the dumps are artificial and have been created with a debug change applied to the kernel handler of the `ptrace' syscall. The use of `store_unsigned_integer' and `extract_unsigned_integer' unconditionally in all cases rather than when actual data occupies a part of the data quantity exchanged with `ptrace' makes code perhaps marginally slower, however I think avoiding it is not worth code obfuscation it would cause. If this turns out unfounded, then there should be no problem with optimizing this code later. gdb/ PR gdb/22286 * linux-nat-trad.c (linux_nat_trad_target::fetch_register): Also handle registers whose width is not a multiple of PTRACE_TYPE_RET. (linux_nat_trad_target::store_register): Likewise.
2018-05-16Make "cbfd" a gdb_bfd_ref_ptrTom Tromey4-5/+13
This changes program_space::cbfd to be a gdb_bfd_ref_ptr. This makes it somewhat less error-prone to use, because now it manages the reference counting automatically. Tested by the buildbot. 2018-05-16 Tom Tromey <tom@tromey.com> * gdbcore.h (core_bfd): Redefine. * corelow.c (core_target::close): Update. (core_target_open): Update. * progspace.h (struct program_space) <cbfd>: Now a gdb_bfd_ref_ptr.
2018-05-16Use a distinguishing name for minidebug objfileTom Tromey4-5/+25
One part of PR cli/19551 is that the mini debug info objfile reuses the name of the main objfile from which it comes. This can be seen because gdb claims to be reading symbols from the same file two times, like: Reading symbols from /bin/gdb...Reading symbols from /bin/gdb...(no debugging symbols found)...done. I think this would be less confusing if the minidebug objfile were given a different name. That is what this patch implements. It also arranges for the minidebug objfile to be marked OBJF_NOT_FILENAME. After this patch the output looks like: Reading symbols from /bin/gdb...Reading symbols from .gnu_debugdata for /usr/libexec/gdb...(no debugging symbols found)...done. Tested by the buildbot. gdb/ChangeLog 2018-05-16 Tom Tromey <tom@tromey.com> PR cli/19551: * symfile-add-flags.h (enum symfile_add_flags) <SYMFILE_NOT_FILENAME>: New constant. * symfile.c (read_symbols): Use SYMFILE_NOT_FILENAME. Get objfile name from BFD. (symbol_file_add_with_addrs): Check SYMFILE_NOT_FILENAME. * minidebug.c (find_separate_debug_file_in_section): Put ".gnu_debugdata" into BFD's file name.
2018-05-16regcache.c: Remove unused typedefsSimon Marchi2-5/+5
gdb/ChangeLog: * regcache.c (regcache_read_ftype, regcache_write_ftype): Remove.
2018-05-15Modify AArch64 Assembly and disassembly functions to be able to fail and ↵Tamar Christina2-4/+11
report why. This patch if the first patch in a series to add the ability to add constraints to system registers that an instruction must adhere to in order for the register to be usable with that instruction. These constraints can also be used to disambiguate between registers with the same encoding during disassembly. This patch adds a new flags entry in the sysreg structures and ensures it is filled in and read out during assembly/disassembly. It also adds the ability for the assemble and disassemble functions to be able to gracefully fail and re-use the existing error reporting infrastructure. The return type of these functions are changed to a boolean to denote success or failure and the error structure is passed around to them. This requires aarch64-gen changes so a lot of the changes here are just mechanical. gas/ PR binutils/21446 * config/tc-aarch64.c (parse_sys_reg): Return register flags. (parse_operands): Fill in register flags. gdb/ PR binutils/21446 * aarch64-tdep.c (aarch64_analyze_prologue, aarch64_software_single_step, aarch64_displaced_step_copy_insn): Indicate not interested in errors. include/ PR binutils/21446 * opcode/aarch64.h (aarch64_opnd_info): Change sysreg to struct. (aarch64_decode_insn): Accept error struct. opcodes/ PR binutils/21446 * aarch64-asm.h (aarch64_insert_operand, aarch64_##x): Return boolean and take error struct. * aarch64-asm.c (aarch64_ext_regno, aarch64_ins_reglane, aarch64_ins_reglist, aarch64_ins_ldst_reglist, aarch64_ins_ldst_reglist_r, aarch64_ins_ldst_elemlist, aarch64_ins_advsimd_imm_shift, aarch64_ins_imm, aarch64_ins_imm_half, aarch64_ins_advsimd_imm_modified, aarch64_ins_fpimm, aarch64_ins_imm_rotate1, aarch64_ins_imm_rotate2, aarch64_ins_fbits, aarch64_ins_aimm, aarch64_ins_limm_1, aarch64_ins_limm, aarch64_ins_inv_limm, aarch64_ins_ft, aarch64_ins_addr_simple, aarch64_ins_addr_regoff, aarch64_ins_addr_offset, aarch64_ins_addr_simm, aarch64_ins_addr_simm10, aarch64_ins_addr_uimm12, aarch64_ins_simd_addr_post, aarch64_ins_cond, aarch64_ins_sysreg, aarch64_ins_pstatefield, aarch64_ins_sysins_op, aarch64_ins_barrier, aarch64_ins_prfop, aarch64_ins_hint, aarch64_ins_reg_extended, aarch64_ins_reg_shifted, aarch64_ins_sve_addr_ri_s4xvl, aarch64_ins_sve_addr_ri_s6xvl, aarch64_ins_sve_addr_ri_s9xvl, aarch64_ins_sve_addr_ri_s4, aarch64_ins_sve_addr_ri_u6, aarch64_ins_sve_addr_rr_lsl, aarch64_ins_sve_addr_rz_xtw, aarch64_ins_sve_addr_zi_u5, aarch64_ext_sve_addr_zz, aarch64_ins_sve_addr_zz_lsl, aarch64_ins_sve_addr_zz_sxtw, aarch64_ins_sve_addr_zz_uxtw, aarch64_ins_sve_aimm, aarch64_ins_sve_asimm, aarch64_ins_sve_index, aarch64_ins_sve_limm_mov, aarch64_ins_sve_quad_index, aarch64_ins_sve_reglist, aarch64_ins_sve_scale, aarch64_ins_sve_shlimm, aarch64_ins_sve_shrimm, aarch64_ins_sve_float_half_one, aarch64_ins_sve_float_half_two, aarch64_ins_sve_float_zero_one, aarch64_opcode_encode): Likewise. * aarch64-dis.h (aarch64_extract_operand, aarch64_##x): Likewise. * aarch64-dis.c (aarch64_ext_regno, aarch64_ext_reglane, aarch64_ext_reglist, aarch64_ext_ldst_reglist, aarch64_ext_ldst_reglist_r, aarch64_ext_ldst_elemlist, aarch64_ext_advsimd_imm_shift, aarch64_ext_imm, aarch64_ext_imm_half, aarch64_ext_advsimd_imm_modified, aarch64_ext_fpimm, aarch64_ext_imm_rotate1, aarch64_ext_imm_rotate2, aarch64_ext_fbits, aarch64_ext_aimm, aarch64_ext_limm_1, aarch64_ext_limm, decode_limm, aarch64_ext_inv_limm, aarch64_ext_ft, aarch64_ext_addr_simple, aarch64_ext_addr_regoff, aarch64_ext_addr_offset, aarch64_ext_addr_simm, aarch64_ext_addr_simm10, aarch64_ext_addr_uimm12, aarch64_ext_simd_addr_post, aarch64_ext_cond, aarch64_ext_sysreg, aarch64_ext_pstatefield, aarch64_ext_sysins_op, aarch64_ext_barrier, aarch64_ext_prfop, aarch64_ext_hint, aarch64_ext_reg_extended, aarch64_ext_reg_shifted, aarch64_ext_sve_addr_ri_s4xvl, aarch64_ext_sve_addr_ri_s6xvl, aarch64_ext_sve_addr_ri_s9xvl, aarch64_ext_sve_addr_ri_s4, aarch64_ext_sve_addr_ri_u6, aarch64_ext_sve_addr_rr_lsl, aarch64_ext_sve_addr_rz_xtw, aarch64_ext_sve_addr_zi_u5, aarch64_ext_sve_addr_zz, aarch64_ext_sve_addr_zz_lsl, aarch64_ext_sve_addr_zz_sxtw, aarch64_ext_sve_addr_zz_uxtw, aarch64_ext_sve_aimm, aarch64_ext_sve_asimm, aarch64_ext_sve_index, aarch64_ext_sve_limm_mov, aarch64_ext_sve_quad_index, aarch64_ext_sve_reglist, aarch64_ext_sve_scale, aarch64_ext_sve_shlimm, aarch64_ext_sve_shrimm, aarch64_ext_sve_float_half_one, aarch64_ext_sve_float_half_two, aarch64_ext_sve_float_zero_one, aarch64_opcode_decode): Likewise. (determine_disassembling_preference, aarch64_decode_insn, print_insn_aarch64_word, print_insn_data): Take errors struct. (print_insn_aarch64): Use errors. * aarch64-asm-2.c: Regenerate. * aarch64-dis-2.c: Regenerate. * aarch64-gen.c (print_operand_inserter): Use errors and change type to boolean in aarch64_insert_operan. (print_operand_extractor): Likewise. * aarch64-opc.c (aarch64_print_operand): Use sysreg struct.
2018-05-15MIPS/Linux/native: Supply $zero for the !PTRACE_GETREGS caseMaciej W. Rozycki2-1/+12
With native MIPS/Linux targets the $zero register is inaccessible, with its supposed context slot provided by the OS occupied by the $restart register. The PTRACE_GETREGS path takes care of it by artificially supplying the hardwired contents of $zero in `mips_supply_gregset' or `mips64_supply_gregset', as applicable, however the PTRACE_PEEKUSER fallback does not, making the register unavailable, e.g.: (gdb) info registers zero at v0 v1 a0 a1 a2 a3 R0 <unavl> 00000001 00000001 d2f1a9fc 00000000 00000000 00417158 00417150 t0 t1 t2 t3 t4 t5 t6 t7 R8 00000004 00000000 fffffff8 00000000 00000000 00000000 00000001 00000007 s0 s1 s2 s3 s4 s5 s6 s7 R16 00000000 00405e30 00000000 00500000 00000000 0052ec08 00000000 00000000 t8 t9 k0 k1 gp sp s8 ra R24 00000000 00417008 00000000 00000000 0041e220 7fff4ce0 7fff4ce0 00405d0c status lo hi badvaddr cause pc <unavl> 00441cf1 00000017 00417004 00800024 00405d10 fcsr fir restart 00800000 00f30000 00000000 (gdb) or (under certain circumstances): (gdb) stepi Register 0 is not available (gdb) This is specifically because `mips_linux_register_addr' and `mips64_linux_register_addr', both correctly return -1 for MIPS_ZERO_REGNUM, and therefore `linux_nat_trad_target::fetch_registers' faithfully marks this register as unavailable. Supply this register artificially then in the PTRACE_PEEKUSER case as well, correcting this issue. gdb/ * mips-linux-nat.c (mips_linux_nat_target::fetch_registers): Supply the MIPS_ZERO_REGNUM register.
2018-05-15MIPS: Make `mask_address_var' staticMaciej W. Rozycki2-1/+5
Make the `mask_address_var' variable static, it is not used outside mips-tdep.c and having no target name embedded within it causes a risk of a namespace clash. gdb/ * mips-tdep.c (mask_address_var): Make variable static.
2018-05-15testsuite: Fix a `server_pid' access crash in gdb.server/server-kill.expMaciej W. Rozycki2-1/+7
Fix a commit f90183d7e31b ("Get GDBserver pid on remote target") bug and correctly handle the case where the PID of `gdbserver' could not have been retrieved. If that happens, $server_pid is unset causing: FAIL: gdb.server/server-kill.exp: p server_pid ERROR: tcl error sourcing .../gdb/testsuite/gdb.server/server-kill.exp. ERROR: can't read "server_pid": no such variable while executing "if {$server_pid == "" } { return -1 }" (file ".../gdb/testsuite/gdb.server/server-kill.exp" line 49) invoked from within "source .../gdb/testsuite/gdb.server/server-kill.exp" ("uplevel" body line 1) invoked from within "uplevel #0 source .../gdb/testsuite/gdb.server/server-kill.exp" invoked from within "catch "uplevel #0 source $test_file_name"" Verify that the variable exists then rather than trying to access it. gdb/testsuite/ * gdb.server/server-kill.exp: Verify whether `server_pid' exists rather then trying to access it in determining whether the PID of `gdbserver' could have been retrieved.
2018-05-14Clear rust_unions in rust_union_quirksTom Tromey2-0/+6
It turns out that a dwarf2_cu can remain allocated after psymtab expansion is done, and so it makes sense to clear rust_unions when done processing it. Tested on x86-64 Fedora 27. 2018-05-14 Tom Tromey <tom@tromey.com> * dwarf2read.c (rust_union_quirks): Clear rust_unions.
2018-05-11gdb/x86: Fix write out of mxcsr register for xsave targetsAndrew Burgess2-2/+7
In commit: commit 8ee22052f690c007556b97eed59f49350ece5ca9 Author: Andrew Burgess <andrew.burgess@embecosm.com> Date: Thu May 3 17:46:14 2018 +0100 gdb/x86: Handle kernels using compact xsave format in two places FXSAVE_ADDR was used instead of FXSAVE_MXCSR_ADDR to get the address of the mxcsr register within the xsave buffer. This will mean we are potentially accessing the wrong location within the xsave buffer. There are no tests included with this patch. The first mistake would only trigger an issue if/when the user tries to manually set the mxcsr register to a value that matches the random (value off stack) value that is in the xsave buffer, in this case the change by the user will go unnoticed by GDB, and the default value of mxcsr will be preserved. The second mistake only happens on the code path where all x87 registers are being written out of the register cache. I'm not sure how to trigger that code path. gdb/ChangeLog: * i387-tdep.c (i387_collect_xsave): Use FXSAVE_MXCSR_ADDR not FXSAVE_ADDR for the mxcsr register.
2018-05-11gdb: xtensa: drop gdb_target definitionMax Filippov2-1/+5
gdb_target definitions were removed from configure.tgt in 2007, before xtensa port was merged. Remove it from the xtensa target as well. gdb/ 2018-05-11 Max Filippov <jcmvbkbc@gmail.com> * configure.tgt (xtensa*-*-linux*): Drop gdb_target definition.
2018-05-11Fix email address in ChangeLog entryPedro Alves1-1/+1
tromey@redhat.com -> palves@redhat.com
2018-05-11Heap-allocate core_target instancesPedro Alves3-121/+184
This gets rid of the core_ops global, and replaces it with heap-allocated core_target instances. In practice, there will only be one such instance, though that will change further ahead as more pieces of multi-target support are merged. Notice that this replaces one heap-allocated object for another, the number of allocations is the same. Specifically, currently we heap-allocate the 'core_data' object, which holds the core's section table. With this patch, that object is made a field of the core_target class, and no longer allocated separately. Note that this bit: - /* Looks semi-reasonable. Toss the old core file and work on the - new. */ - - unpush_target (&core_ops); does not need a replacement, because by the time we get here, the target_preopen call at the top of core_target_open has already unpushed any previous target. gdb/ChangeLog: 2018-05-11 Pedro Alves <palves@redhat.com> * corelow.c (core_target) <core_target>: No longer inline. Initialize m_core_gdbarch, m_core_vec and build the section table here. <~core_target>: New. <core_gdbarch, get_core_register_section>: New methods. <m_core_section_table, m_core_vec, m_core_gdbarch>: New fields, factored out from ... <core_data, core_vec, core_gdbarch>: ... these deleted globals. (core_ops): Delete. (sniff_core_bfd): Add gdbarch parameter. (core_close): Delete, merged into ... (core_target::close): ... here. Delete self. (core_close_cleanup): Delete. (core_target_open): Allocate a core_target on the heap. Use a unique_ptr instead of a cleanup. Bits moved into the core_target ctor. Adjust to use core_target methods instead of globals. (get_core_register_section): Rename to ... (core_target::get_core_register_section): ... this and adjust. (struct get_core_registers_cb_data): New. (get_core_registers_cb): Use it. Use bool. (core_target::fetch_registers, core_target::files_info) (core_target::xfer_partial, core_target::read_description) (core_target::pid_to, core_target::thread_name): Adjust to reference class fields instead of globals. * target.h (struct target_ops_deleter, target_ops_up): New.
2018-05-11Eliminate the 'the_core_target' globalPedro Alves4-33/+43
(previously called 'core_target', but since renamed because 'core_target' is the name of the target_ops class now.) This eliminates the "the_core_target" global, as preparation for being able to have more than one core loaded. When we get there, we will instantiate one core_target object per core instead. Essentially, this replaces the reference to the_core_target in core_file_command by a reference to core_bfd, which is per program_space. Currently, core_file_command calls 'the_core_target->detach()' even if the core target is not open and pushed on the target stack. If it is indeed not open, then the practical effect is that core_target::detach() prints "No core file now.". That is preserved by printing that directly from within core_file_command if not debugging a core. gdb/ChangeLog: 2018-05-11 Pedro Alves <palves@redhat.com> * corefile.c (core_file_command): Move to corelow.c. * corelow.c (the_core_target): Delete. (core_file_command): Moved from corefile.c. Check exec_bfd instead of the_core_target. Use target_detach instead of calling into the_core_target directly. (maybe_say_no_core_file_now): New. (core_target::detach): Use it. (_initialize_corelow): Remove references to the_core_target. * gdbcore.h (the_core_target): Delete.
2018-05-11Move core_bfd to program spaceTom Tromey4-5/+11
This moves the core_bfd global to be a field of the program space. It then replaces core_bfd with a macro to avoid a massive patch -- the same approach taken for various other program space fields. This is a basic transformation for multi-target work. 2018-05-11 Tom Tromey <tromey@redhat.com> Pedro Alves <tromey@redhat.com> * corefile.c (core_bfd): Remove. * gdbcore.h (core_bfd): Now a macro. * progspace.h (struct program_space) <cbfd>: New field.
2018-05-11Remove cleanups from mdebugread.cTom Tromey2-30/+20
This removes the remaining cleanups from mdebugread.c, replacing them with gdb::def_vector. Tested by the buildbot, though I doubt this exercises mdebugread. gdb/ChangeLog 2018-05-11 Tom Tromey <tom@tromey.com> * mdebugread.c (parse_partial_symbols, psymtab_to_symtab_1): Use gdb::def_vector.
2018-05-10x86 LynxOS-178: Adjust floating-point context structureJoel Brobecker2-1/+46
The floating point context structure on x86 LynxOS-178 is not the same as on LynxOS 5.x. As a consequence, trying to print the return value of a function returning a float, for instance, yields incorrect results. This patch fixes the issue by providing an updated definition for LynxOS-178 (the reason why we cannot access the actual definition provided by the system still remains true). gdb/gdbserver/ChangeLog: * lynx-i386-low.c (LYNXOS_178): New macro. [LYNXOS_178] (usr_fcontext_t): Provide a definition that matches the layout on LynxOS-178. (lynx_i386_fill_fpregset, lynx_i386_store_fpregset): Do not handle floating point registers that are not supported by LynxOS-178.
2018-05-10Fix the clang buildTom Tromey5-3/+12
Simon pointed out that gdb would not build with clang, due to the addition of -Wimplicit-fallthrough. This patch fixes the problem by using -Wimplicit-fallthrough=3 -- this does not work with clang, bypassing the issue. Tested by rebuilding with both gcc and clang; and also by verifying that -Wimplicit-fallthrough=3 is used in the gcc build. I will file a follow-up bug to convert the fall-through comments to a form that can be used by both clang and gcc. gdb/ChangeLog 2018-05-10 Tom Tromey <tom@tromey.com> * configure: Rebuild. * warning.m4 (AM_GDB_WARNINGS): Use -Wimplicit-fallthrough=3. gdb/gdbserver/ChangeLog 2018-05-10 Tom Tromey <tom@tromey.com> * configure: Rebuild.
2018-05-10gdbserver/Windows: crash during connection establishment phaseJoel Brobecker12-28/+81
On Windows, starting a new process with GDBserver seems to work, in the sense that the program does get started, and GDBserver confirms that it is listening for GDB to connect. However, as soon as GDB establishes the connection with GDBserver, and starts discussing with it, GDBserver crashes, with a SEGV. This SEGV occurs in remote-utils.c::prepare_resume_reply... | regp = current_target_desc ()->expedite_regs; | [...] | while (*regp) ... because, in our case, REGP is NULL. This patches fixes the issues by adding a parameter to init_target_desc, in order to make sure that we always provide the list of registers when we initialize a target description. gdb/ChangeLog: PR server/23158: * regformats/regdat.sh: Adjust script, following the addition of the new expedite_regs parameter to init_target_desc. gdb/gdbserver/ChangeLog: PR server/23158: * tdesc.h (init_target_desc) <expedite_regs>: New parameter. * tdesc.c (init_target_desc) <expedite_regs>: New parameter. Use it to set the expedite_regs field in the given tdesc. * x86-tdesc.h: New file. * linux-aarch64-tdesc.c (aarch64_linux_read_description): Adjust following the addition of the new expedite_regs parameter to init_target_desc. * linux-tic6x-low.c (tic6x_read_description): Likewise. * linux-x86-tdesc.c: #include "x86-tdesc.h". (i386_linux_read_description, amd64_linux_read_description): Adjust following the addition of the new expedite_regs parameter to init_target_desc. * lynx-i386-low.c: #include "x86-tdesc.h". (lynx_i386_arch_setup): Adjust following the addition of the new expedite_regs parameter to init_target_desc. * nto-x86-low.c: #include "x86-tdesc.h". (nto_x86_arch_setup): Adjust following the addition of the new expedite_regs parameter to init_target_desc. * win32-i386-low.c: #include "x86-tdesc.h". (i386_arch_setup): Adjust following the addition of the new expedite_regs parameter to init_target_desc.
2018-05-10gdbserver/Windows: Fix "no program to debug" errorJoel Brobecker2-0/+10
Trying to start a program with GDBserver on Windows yields the following error: $ gdbserver.exe --once :4444 simple_main.exe Killing process(es): 5008 No program to debug Exiting The error itself comes from the following code shortly after create_inferior gets called (in server.c::main): /* Wait till we are at first instruction in program. */ create_inferior (program_path.get (), program_args); [...] if (last_status.kind == TARGET_WAITKIND_EXITED || last_status.kind == TARGET_WAITKIND_SIGNALLED) was_running = 0; else was_running = 1; if (!was_running && !multi_mode) error ("No program to debug"); What happens is that the "last_status" global starts initialized as zeroes, which means last_status.kind == TARGET_WAITKIND_EXITED, and we expect create_inferior to be waiting for the inferior to start until reaching the SIGTRAP, and to set the "last_status" global to match that last event we received. I suspect this is an unintended side-effect of the following change... commit 2090129c36c7e582943b7d300968d19b46160d84 Date: Thu Dec 22 21:11:11 2016 -0500 Subject: Share fork_inferior et al with gdbserver ... which removes some code in server.c that was responsible for starting the inferior in a functin that was named start_inferior, and looked like this: signal_pid = create_inferior (new_argv[0], &new_argv[0]); [...] /* Wait till we are at 1st instruction in program, return new pid (assuming success). */ last_ptid = mywait (pid_to_ptid (signal_pid), &last_status, 0, 0); The code has been transitioned to using fork_inferior, but sadly, only for the targets that support it. On Windows, the calls to wait setting "last_status" simply disappeared. This patch adds it back in the Windows-specific implementation of create_inferior. gdb/gdbserver/ChangeLog: PR server/23158: * win32-low.c (win32_create_inferior): Add call to my_wait setting last_status global.
2018-05-10[gdbserver/win32] fatal "glob could not process pattern '(null)'" errorJoel Brobecker2-2/+11
Trying to start GDBserver on Windows currently yields the following error... $ gdbserver.exe --once :4444 simple_main.exe glob could not process pattern '(null)'. Exiting ... after which GDB terminates with a nonzero status. This is because create_process in win32-low.c calls gdb_tilde_expand with the result of a call to get_inferior_cwd without verifying that the returned directory is not NULL: | static BOOL | create_process (const char *program, char *args, | DWORD flags, PROCESS_INFORMATION *pi) | { | const char *inferior_cwd = get_inferior_cwd (); | std::string expanded_infcwd = gdb_tilde_expand (inferior_cwd); This patch avoids this by only calling gdb_tilde_expand when INFERIOR_CWD is not NULL, which is similar to what is done on GNU/Linux for instance. gdb/gdbserver/ChangeLog: PR server/23158: * win32-low.c (create_process): Only call gdb_tilde_expand if inferior_cwd is not NULL.
2018-05-10Fix tagged pointer supportOmair Javaid4-10/+23
This patch fixes tagged pointer support for AArch64 GDB. Linux kernel debugging failure was reported after tagged pointer support was committed. After a discussion around best path forward to manage tagged pointers on GDB side we are going to disable tagged pointers support for aarch64-none-elf-gdb because for non-linux applications we cant be sure if tagged pointers will be used by MMU or not. Also for aarch64-linux-gdb we are going to sign extend user-space address after clearing tag bits. This will help debug both kernel and user-space addresses based on information from linux kernel documentation given below: According to AArch64 memory map: https://www.kernel.org/doc/Documentation/arm64/memory.txt "User addresses have bits 63:48 set to 0 while the kernel addresses have the same bits set to 1." According to AArch64 tagged pointers document: https://www.kernel.org/doc/Documentation/arm64/tagged-pointers.txt The kernel configures the translation tables so that translations made via TTBR0 (i.e. userspace mappings) have the top byte (bits 63:56) of the virtual address ignored by the translation hardware. This frees up this byte for application use. Running gdb testsuite after applying this patch introduces no regressions and tagged pointer test cases still pass. gdb/ChangeLog: 2018-05-10 Omair Javaid <omair.javaid@linaro.org> PR gdb/23127 * aarch64-linux-tdep.c (aarch64_linux_init_abi): Add call to set_gdbarch_significant_addr_bit. * aarch64-tdep.c (aarch64_gdbarch_init): Remove call to set_gdbarch_significant_addr_bit. * utils.c (address_significant): Update to sign extend addr.
2018-05-09gdb: xtensa: handle privileged registersMax Filippov3-8/+19
xtensa GDB may be used with both bare-metal and linux-based applications. In case of bare-metal application gdbserver is able to provide information about all CPU registers: both unprivileged and privileged. In case of linux-based application only a small subset of privileged state is available. Currently xtensa GDB only expects unprivileged registers in 'g' packets and it fails to communicate with server that sends both privileged and unprivileged registers. Allow bare-metal xtensa GDB to deal with both privileged and unprivileged registers by initializing tdep->num_regs with the total number of target CPU registers. Keep linux-based xtensa GDB functionality as is by copying tdep->num_nopriv_regs to tdep->num_regs. gdb/ 2018-05-09 Max Filippov <jcmvbkbc@gmail.com> * xtensa-linux-tdep.c (xtensa-tdep.h): New include. (xtensa_linux_init_abi): Limit tdep->num_regs by tdep->num_nopriv_regs. * xtensa-tdep.c (xtensa_derive_tdep): Calculate tdep->num_nopriv_regs and only copy it to tdep->num_regs if it's not initialized.
2018-05-08Define GNULIB_NAMESPACE in unittests/string_view-selftests.cSimon Marchi2-0/+6
When building with x86_64-w64-mingw32-g++ (to test cross-compiling for Windows), I get this error: unittests/string_view-selftests.o: In function `selftests::string_view::inserters_2::test05(unsigned long long)': /home/emaisin/src/binutils-gdb/gdb/unittests/basic_string_view/inserters/char/2.cc:60: undefined reference to `std::basic_ofstream<char, std::char_traits<char> >::rpl_close()' This is caused by gnulib redefining "close" as "rpl_close", and therefore messing up the declaration of basic_ofstream in the libstdc++ header. The solution would be to use gnulib namespaces [1]. Until we use them across GDB, we can use them locally in files that are problematic, like this one. gdb/ChangeLog: * unittests/string_view-selftests.c: Define GNULIB_NAMESPACE.
2018-05-08gdb/x86: Handle kernels using compact xsave formatAndrew Burgess12-400/+872
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-05-08watchpoint-unaligned.exp: Use skip_hw_watchpoint_testsJan Kratochvil2-0/+8
gdb/testsuite/ChangeLog 2018-05-08 Jan Kratochvil <jan.kratochvil@redhat.com> * gdb.base/watchpoint-unaligned.exp: Use skip_hw_watchpoint_tests.
2018-05-08[spu] Fix "info spu event" output formattingUlrich Weigand2-3/+9
The formatting of the output of the "info spu event" command changed, causing spurious test suite failures. Use phex instead of phex_nz to get back the expected format, and fix emission of new line characters. gdb/ChangeLog: 2018-05-08 Ulrich Weigand <uweigand@de.ibm.com> * spu-tdep.c (info_spu_event_command): Fix output formatting.
2018-05-07Add -Wduplicated-condTom Tromey5-3/+15
This adds -Wduplicated-cond to warnings.m4. This caught one bug. I tried adding -Wduplicated-branches as well, but it results in some spurious failures from code like this in cgen.h: #define CGEN_ATTR_TYPE(n) \ struct { unsigned int bool_; \ CGEN_ATTR_VALUE_TYPE nonbool[(n) ? (n) : 1]; } This will trigger a warning if passed n==1, which seems like a perfectly valid thing to do; and there were other issues like this as well. ChangeLog 2018-05-07 Tom Tromey <tom@tromey.com> * configure: Rebuild. * warning.m4 (AM_GDB_WARNINGS): Add -Wduplicated-cond. gdbserver/ChangeLog 2018-05-07 Tom Tromey <tom@tromey.com> * configure: Rebuild.
2018-05-07Fix decoding of ARM VFP instructionsTom Tromey2-2/+9
-Wduplicated-cond pointed out that arm_record_vfp_data_proc_insn checks "opc1 == 0x0b" twice. I filed this a while ago as PR tdep/20362. Based on the ARM instruction manual at https://www.scss.tcd.ie/~waldroj/3d1/arm_arm.pdf, I think the instruction decoding in this function has two bugs. First, opc1 is computed as: opc1 = bits (arm_insn_r->arm_insn, 20, 23); [...] opc1 = opc1 & 0x04; This means that tests like: else if (opc1 == 0x01) can never be true. In the ARM manual, "opc1" corresponds to these bits: name bit r 20 q 21 D 22 p 23 ... where the D bit is not used for VFP instruction decoding. So, I believe this code should use ~0x04 instead. Second, VDIV is recognized by the bits "pqrs" being equal to "1000". This tranlates to opc1 == 0x08 -- not 0x0b. Note that pqrs==1001 is an undefined encoding, which is probably why opc2 is not checked here; this code doesn't seem to really deal with undefined encodings in general, so I've left that as is. I don't have an ARM machine or any reasonable way to test this. ChangeLog 2018-05-07 Tom Tromey <tom@tromey.com> PR tdep/20362: * arm-tdep.c (arm_record_vfp_data_proc_insn): Properly mask off D bit. Use correct value for VDIV.
2018-05-04Add -Wimplicit-fallthroughTom Tromey5-3/+15
This adds -Wimplicit-fallthrough to the set of default warnings. 2018-05-04 Tom Tromey <tom@tromey.com> * configure: Rebuild. * warning.m4 (AM_GDB_WARNINGS): Add -Wimplicit-fallthrough. gdbserver/ChangeLog 2018-05-04 Tom Tromey <tom@tromey.com> * configure: Rebuild.
2018-05-04Add a missing break in record_linux_system_callTom Tromey2-0/+6
This adds a "break" at the end of the RECORD_SYS_RECVFROM case in record_linux_system_call. This seemed correct to me. 2018-05-04 Tom Tromey <tom@tromey.com> * linux-record.c (record_linux_system_call) <case RECORD_SYS_RECVFROM>: Add "break".
2018-05-04Add missing "breaks"Tom Tromey3-0/+9
This adds a "break" to a couple of spots where it was erroneously omitted. I think these are the two (potential) real bugs caught by this series. 2018-05-04 Tom Tromey <tom@tromey.com> * mi/mi-main.c (mi_cmd_trace_frame_collected) <REGISTERS_FORMAT>: Add missing "break". * mi/mi-cmd-stack.c (mi_cmd_stack_list_locals) <NO_FRAME_FILTERS>: Add missing "break".
2018-05-04Add two fall-through comments in rs6000-tdep.cTom Tromey2-0/+7
This adds two fall-through comments in rs6000-tdep.c. I looked at the PPC instruction manual and convinced myself that this was correct. And, this isn't a semantic change. However, close review would still be good. 2018-05-04 Tom Tromey <tom@tromey.com> * rs6000-tdep.c (ppc_process_record_op4) (ppc_process_record_op63): Add fall-through comment.
2018-05-04Add fall-through comment to i386-tdep.cTom Tromey2-0/+5
This adds a fall-through comment in i386-tdep.c. I was not sure what to do here, so I elected to preserve the status quo. In review, John Baldwin pointed out that: "I believe this is correct based on the diff that added the special cases for xgetbv and xsetbv as previously ldgt and lidt were treated the same". gdb/ChangeLog 2018-05-04 Tom Tromey <tom@tromey.com> * i386-tdep.c (i386_process_record): Add fall-through comment.
2018-05-04Add a fall-through comment to stabsread.cTom Tromey2-0/+6
This adds a fall-through comment to stabsread.c. I skimmed the stabs manual a bit and it seems that 'p' and 'P' are similar enough that this makes sense. Also, stabs is mostly deprecated, and the code has been this way for a long time, so it seemed safest to keep the status quo. ChangeLog 2018-05-04 Tom Tromey <tom@tromey.com> * stabsread.c (define_symbol) <case 'p'>: Add fall-through comment.
2018-05-04Fix "obvious" fall-through warningsTom Tromey6-0/+16
This patch fixes the subset of -Wimplicit-fallthrough warnings that I considered obvious. In most cases it was obvious from context that falling through was desired; here I added the appropriate comment. In a couple of cases it seemed clear that a "break" was missing. ChangeLog 2018-05-04 Tom Tromey <tom@tromey.com> * riscv-tdep.c (riscv_isa_xlen): Add fall-through comment. * utils.c (can_dump_core) <LIMIT_CUR>: Add fall-through comment. * eval.c (fetch_subexp_value) <MEMORY_ERROR>: Add fall-through comment. * d-valprint.c (d_val_print) <TYPE_CODE_STRUCT>: Add fall-through comment. * coffread.c (coff_symtab_read) <C_LABEL>: Add fall-through comment.
2018-05-04Add missing ATTRIBUTE_NORETURNsTom Tromey2-1/+5
This patch adds a missing ATTRIBUTE_NORETURN. This lets -Wimplicit-fallthrough recognize that a given case does not fall through. ChangeLog 2018-05-04 Tom Tromey <tom@tromey.com> * dwarf2loc.c (unimplemented): Add ATTRIBUTE_NORETURN.
2018-05-04Fix "fall through" commentsTom Tromey21-24/+63
This patch updates existing "fall through" comments so that they can be recognized by gcc's -Wimplicit-fallthrough comment-parsing heuristic. ChangeLog 2018-05-04 Tom Tromey <tom@tromey.com> * s390-tdep.c (s390_process_record): Fix fall-through comments. * xcoffread.c (scan_xcoff_symtab): Move comment later. * symfile.c (section_is_mapped): Fix fall-through comment. * stabsread.c (define_symbol, read_member_functions): Fix fall-through comment. * s390-linux-tdep.c (s390_process_record): Fix fall-through comment. * remote.c (remote_wait_as): Fix fall-through comment. * p-exp.y (yylex): Fix fall-through comment. * nat/x86-dregs.c (x86_length_and_rw_bits): Fix fall-through comment. * msp430-tdep.c (msp430_gdbarch_init): Fix fall-through comment. * mdebugread.c (parse_partial_symbols): Fix fall-through comment. * jv-exp.y (yylex): Fix fall-through comment. * go-exp.y (lex_one_token): Fix fall-through comment. * gdbtypes.c (get_discrete_bounds, rank_one_type): Fix fall-through comment. * f-exp.y (yylex): Fix fall-through comment. * dwarf2read.c (process_die): Fix fall-through comments. * dbxread.c (process_one_symbol): Fix fall-through comment. * d-exp.y (lex_one_token): Fix fall-through comment. * cp-name-parser.y (yylex): Fix fall-through comment. * coffread.c (coff_symtab_read): Fix fall-through comment. * c-exp.y (lex_one_token): Fix fall-through comment. * arm-tdep.c (arm_decode_miscellaneous): Fix fall-through comment. * arch/arm.c (arm_instruction_changes_pc): Fix fall-through comment.
2018-05-04Let gdb.execute handle multi-line commandsTom Tromey8-32/+123
This changes the Python API so that gdb.execute can now handle multi-line commands, like "commands" or "define". ChangeLog 2018-05-04 Tom Tromey <tom@tromey.com> PR python/22730: * NEWS: Mention gdb.execute change. * gdbcmd.h (execute_control_command): Don't declare. * python/python.c (execute_gdb_command): Use read_command_lines_1, execute_control_commands, execute_control_commands_to_string. * cli/cli-script.h (execute_control_commands) (execute_control_commands_to_string): Declare. (execute_control_command): Add from_tty parameter. * cli/cli-script.c (execute_control_commands) (execute_control_commands_to_string): New functions. (execute_user_command): Use execute_control_commands. (execute_control_command_1): Add "from_tty" parameter. Update. (execute_control_command): Likewise. testsuite/ChangeLog 2018-05-04 Tom Tromey <tom@tromey.com> PR python/22730: * gdb.python/python.exp: Test multi-line execute.
2018-05-04Allow breakpoint commands to be set from PythonTom Tromey7-3/+75
This changes the Python API so that breakpoint commands can be set by writing to the "commands" attribute. ChangeLog 2018-05-04 Tom Tromey <tom@tromey.com> PR python/22731: * NEWS: Mention that breakpoint commands are writable. * python/py-breakpoint.c (bppy_set_commands): New function. (breakpoint_object_getset) <"commands">: Use it. doc/ChangeLog 2018-05-04 Tom Tromey <tom@tromey.com> PR python/22731: * python.texi (Breakpoints In Python): Mention that "commands" is writable. testsuite/ChangeLog 2018-05-04 Tom Tromey <tom@tromey.com> PR python/22731: * gdb.python/py-breakpoint.exp: Test setting breakpoint commands.
2018-05-04Use function_view in cli-script.cTom Tromey7-74/+79
This changes some functions in cli-script.c to use function_view rather than a function pointer and closure argument. This simplifies the code a bit and is useful in a subsequent patch. ChangeLog 2018-05-04 Tom Tromey <tom@tromey.com> * tracepoint.c (actions_command): Update. * mi/mi-cmd-break.c (mi_command_line_array) (mi_command_line_array_cnt, mi_command_line_array_ptr) (mi_read_next_line): Remove. (mi_cmd_break_commands): Update. * cli/cli-script.h (read_command_lines, read_command_lines_1): Use function_view. * cli/cli-script.c (get_command_line): Update. (process_next_line): Use function_view. Constify. (recurse_read_control_structure, read_command_lines) (read_command_lines_1): Change argument types to function_view. (do_define_command, document_command): Update. * breakpoint.h (check_tracepoint_command): Don't declare. * breakpoint.c (check_tracepoint_command): Remove. (commands_command_1, create_tracepoint_from_upload): Update.
2018-05-04Allow defining a user command inside a user commandTom Tromey6-12/+75
PR gdb/11750 concerns defining a command inside a user commnad, like: define outer define inner echo hi\n end end This patch adds this capability to gdb. ChangeLog 2018-05-04 Tom Tromey <tom@tromey.com> PR gdb/11750: * cli/cli-script.h (enum command_control_type) <define_control>: New constant. * cli/cli-script.c (multi_line_command_p): Handle define_control. (build_command_line, execute_control_command_1) (process_next_line): Likewise. (do_define_command): New function, extracted from define_command. (define_command): Use it. testsuite/ChangeLog 2018-05-04 Tom Tromey <tom@tromey.com> PR gdb/11750: * gdb.base/define.exp: Test defining a user command inside a user command. * gdb.base/commands.exp (define_if_without_arg_test): Test "define".
2018-05-04Constify prompt argument to read_command_linesTom Tromey5-15/+23
The prompt argument to read_command_lines can be const. This patch makes this change, and also removes some fixed-sized buffers in favor of using string_printf. ChangeLog 2018-05-04 Tom Tromey <tom@tromey.com> * tracepoint.c (actions_command): Update. * cli/cli-script.h (read_command_lines): Update. * cli/cli-script.c (read_command_lines): Constify prompt_arg. (MAX_TMPBUF): Remove define. (define_command): Use string_printf. (document_command): Likewise. * breakpoint.c (commands_command_1): Update.
2018-05-04Make print_command_trace varargsTom Tromey4-14/+21
I noticed some code in execute_control_command_1 that could be simplified by making print_command_trace a printf-like function. This patch makes this change. ChangeLog 2018-05-04 Tom Tromey <tom@tromey.com> * top.c (execute_command): Update. * cli/cli-script.h (print_command_lines): Now varargs. * cli/cli-script.c (print_command_lines): Now varargs. (execute_control_command_1) <case while_control, case if_control>: Update.
2018-05-04Use counted_command_line everywhereTom Tromey12-243/+183
Currently command lines are reference counted using shared_ptr only when attached to breakpoints. This patch changes gdb to use shared_ptr in commands as well. This allows for the removal of copy_command_lines. Note that the change to execute_user_command explicitly makes a new reference to the command line. This will be used in a later patch. This simplifies struct command_line based on the observation that a given command can have at most two child bodies: an "if" can have both "then" and "else" parts. Perhaps the names I've chosen for the replacements here are not very good -- your input requested. ChangeLog 2018-05-04 Tom Tromey <tom@tromey.com> * tracepoint.c (all_tracepoint_actions): Rename from all_tracepoint_actions_and_cleanup. Change return type. (actions_command, encode_actions_1, encode_actions) (trace_dump_actions, tdump_command): Update. * remote.c (remote_download_command_source): Update. * python/python.c (gdbpy_eval_from_control_command) (python_command, python_interactive_command): Update. * mi/mi-cmd-break.c (mi_cmd_break_commands): Update. * guile/guile.c (guile_command) (gdbscm_eval_from_control_command, guile_command): Update. * compile/compile.c (compile_code_command) (compile_print_command, compile_to_object): Update. * cli/cli-script.h (struct command_lines_deleter): New. (counted_command_line): New typedef. (struct command_line): Add constructor, destructor. <body_list>: Remove. <body_list_0, body_list_1>: New members. (command_line_up): Remove typedef. (read_command_lines, read_command_lines_1, get_command_line): Update. (copy_command_lines): Don't declare. * cli/cli-script.c (build_command_line): Use "new". (get_command_line): Return counted_command_line. (print_command_lines, execute_user_command) (execute_control_command_1, while_command, if_command): Update. (realloc_body_list): Remove. (process_next_line, recurse_read_control_structure): Update. (read_command_lines, read_command_lines_1): Return counted_command_line. (free_command_lines): Use "delete". (copy_command_lines): Remove. (define_command, document_command, show_user_1): Update. * cli/cli-decode.h (struct cmd_list_element) <user_commands>: Now a counted_command_line. * breakpoint.h (counted_command_line): Remove typedef. (breakpoint_set_commands): Update. * breakpoint.c (check_no_tracepoint_commands) (validate_commands_for_breakpoint): Update. (breakpoint_set_commands): Change commands to be a counted_command_line. (commands_command_1, update_dprintf_command_list) (create_tracepoint_from_upload): Update.
2018-05-04Allocate cmd_list_element with newTom Tromey3-55/+62
This adds a constructor and destructor to cmd_list_element and changes it to be allocated with new. This will be useful in a subsequent patch. ChangeLog 2018-05-04 Tom Tromey <tom@tromey.com> * cli/cli-decode.h (cmd_list_element): New constructor. (~cmd_list_element): New destructor. (struct cmd_list_element): Add initializers. * cli/cli-decode.c (do_add_cmd): Use "new". (delete_cmd): Use "delete".
2018-05-04aarch64: PR 19806: watchpoints: false negatives + PR 20207 contiguous onesJan Kratochvil14-128/+657
Some unaligned watchpoints were currently missed. On old kernels as specified in kernel RFE: aarch64: ptrace: BAS: Support any contiguous range (edit) https://sourceware.org/bugzilla/show_bug.cgi?id=20207 after this patch some other unaligned watchpoints will get reported as false positives. With new kernels all the watchpoints should work exactly. There may be a regresion that it now less merges watchpoints so that with multiple overlapping watchpoints it may run out of the 4 hardware watchpoint registers. But as discussed in the original thread GDB needs some generic watchpoints merging framework to be used by all the target specific code. Even current FSF GDB code does not merge it perfectly. Also with the more precise watchpoints one can technically merge them less. And I do not think it matters too much to improve mergeability only for old kernels. Still even on new kernels some better merging logic would make sense. There remains one issue: kernel-4.15.14-300.fc27.armv7hl FAIL: gdb.base/watchpoint-unaligned.exp: continue FAIL: gdb.base/watchpoint-unaligned.exp: continue (gdb) continue Continuing. Unexpected error setting watchpoint: Invalid argument. (gdb) FAIL: gdb.base/watchpoint-unaligned.exp: continue But that looks as a kernel bug to me. (1) It is not a regression by this patch. (2) It is unrelated to this patch. gdb/ChangeLog 2018-05-04 Jan Kratochvil <jan.kratochvil@redhat.com> Pedro Alves <palves@redhat.com> PR breakpoints/19806 and support for PR external/20207. * NEWS: Mention Aarch64 watchpoint improvements. * aarch64-linux-nat.c (aarch64_linux_stopped_data_address): Fix missed watchpoints and PR external/20207 watchpoints. * nat/aarch64-linux-hw-point.c (kernel_supports_any_contiguous_range): New. (aarch64_watchpoint_offset): New. (aarch64_watchpoint_length): Support PR external/20207 watchpoints. (aarch64_point_encode_ctrl_reg): New parameter offset, new asserts. (aarch64_point_is_aligned): Support PR external/20207 watchpoints. (aarch64_align_watchpoint): New parameters aligned_offset_p and next_addr_orig_p. Support PR external/20207 watchpoints. (aarch64_downgrade_regs): New. (aarch64_dr_state_insert_one_point): New parameters offset and addr_orig. (aarch64_dr_state_remove_one_point): Likewise. (aarch64_handle_breakpoint): Update caller. (aarch64_handle_aligned_watchpoint): Likewise. (aarch64_handle_unaligned_watchpoint): Support addr_orig and aligned_offset. (aarch64_linux_set_debug_regs): Remove const from state. Call aarch64_downgrade_regs. (aarch64_show_debug_reg_state): Print also dr_addr_orig_wp. * nat/aarch64-linux-hw-point.h (DR_CONTROL_LENGTH): Rename to ... (DR_CONTROL_MASK): ... this. (struct aarch64_debug_reg_state): New field dr_addr_orig_wp. (unsigned int aarch64_watchpoint_offset): New prototype. (aarch64_linux_set_debug_regs): Remove const from state. * utils.c (align_up, align_down): Move to ... * common/common-utils.c (align_up, align_down): ... here. * utils.h (align_up, align_down): Move to ... * common/common-utils.h (align_up, align_down): ... here. gdb/gdbserver/ChangeLog 2018-05-04 Jan Kratochvil <jan.kratochvil@redhat.com> Pedro Alves <palves@redhat.com> * linux-aarch64-low.c (aarch64_stopped_data_address): Likewise. gdb/testsuite/ChangeLog 2018-05-04 Jan Kratochvil <jan.kratochvil@redhat.com> Pedro Alves <palves@redhat.com> PR breakpoints/19806 and support for PR external/20207. * gdb.base/watchpoint-unaligned.c: New file. * gdb.base/watchpoint-unaligned.exp: New file.