aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2019-07-17Introduce tui_data_window::display_all_data methodTom Tromey7-9/+23
This changes tui_display_all_data to be a method on tui_data_window. This helps cluster uses of the TUI_DATA_WIN global. gdb/ChangeLog 2019-07-17 Tom Tromey <tom@tromey.com> * tui/tui-windata.h (tui_display_all_data): Don't declare. * tui/tui-windata.c (tui_data_window::display_all_data): Rename from tui_display_all_data. * tui/tui-win.c (tui_data_window::do_make_visible_with_new_height): Update. * tui/tui-regs.c (tui_show_registers): Update. * tui/tui-layout.c (tui_set_layout): Update. * tui/tui-data.h (struct tui_data_window) <display_all_data>: New method.
2019-07-17Remove tui_display_data_fromTom Tromey3-24/+18
tui_display_data_from is only called from a single place. Inlining it there lets us remove some uses of the TUI_DATA_WIN global. gdb/ChangeLog 2019-07-17 Tom Tromey <tom@tromey.com> * tui/tui-windata.h (tui_display_data_from): Don't declare. * tui/tui-windata.c (tui_display_data_from): Remove. (tui_data_window::refresh_all): Update.
2019-07-17Remove tui_display_data_from_lineTom Tromey5-37/+26
tui_display_data_from_line is just a wrapper for tui_display_registers_from_line, so remove it. Also, nothing passed 0 as the "force_display" parameter to tui_display_registers_from_line, so remove that parameter as well. gdb/ChangeLog 2019-07-17 Tom Tromey <tom@tromey.com> * tui/tui-windata.h (tui_display_data_from_line): Don't declare. * tui/tui-windata.c (tui_display_data_from_line): Remove. (tui_display_data_from, tui_data_window::do_scroll_vertical): Call tui_display_registers_from_line. * tui/tui-regs.h (tui_display_registers_from_line): Update. * tui/tui-regs.c (tui_display_registers_from_line): Remove "force_display" parameter.
2019-07-17Introduce tui_data_window::first_reg_element_no_inlineTom Tromey4-10/+22
This changes tui_first_reg_element_no_inline to be a method on tui_data_window. This again moves uses of the TUI_DATA_WIN global from this function into other functions that are already using the global. gdb/ChangeLog 2019-07-17 Tom Tromey <tom@tromey.com> * tui/tui-regs.h (tui_first_reg_element_no_inline): Don't declare. * tui/tui-regs.c (tui_data_window::first_reg_element_no_inline): Rename from tui_first_reg_element_no_inline. (tui_display_reg_element_at_line) (tui_display_registers_from_line): Update. * tui/tui-data.h (struct tui_data_window) <first_reg_element_no_inline>: New method.
2019-07-17Introduce tui_data_window::line_from_reg_element_no methodTom Tromey5-10/+23
This changes tui_line_from_reg_element_no to be a method on tui_data_window, allowing for the removal of some uses of the TUI_DATA_WIN global. (Actually, in this particular patch, the number of uses is not decreased, but rather the uses are moved to spots that are already using the global, i.e., increasing the clustering.) gdb/ChangeLog 2019-07-17 Tom Tromey <tom@tromey.com> * tui/tui-windata.c (tui_display_data_from) (tui_data_window::do_scroll_vertical): Update. * tui/tui-regs.h (tui_line_from_reg_element_no): Don't declare. * tui/tui-regs.c (tui_data_window::line_from_reg_element_no): Rename from tui_line_from_reg_element_no. (tui_display_registers_from_line): Update. * tui/tui-data.h (struct tui_data_window) <line_from_reg_element_no>: New method.
2019-07-17Introduce tui_data_window::last_regs_line_no methodTom Tromey4-10/+22
This changes tui_last_regs_line_no into a method on tui_data_window, allowing the removal of uses of the TUI_DATA_WIN global. gdb/ChangeLog 2019-07-17 Tom Tromey <tom@tromey.com> * tui/tui-regs.h (tui_last_regs_line_no): Don't declare. * tui/tui-regs.c (tui_data_window::last_regs_line_no): Rename from tui_last_regs_line_no. (tui_display_reg_element_at_line) (tui_display_registers_from_line): Update. * tui/tui-data.h (struct tui_data_window) <last_regs_line_no>: New method.
2019-07-17Remove deleted breakpoint from TUI displayTom Tromey4-22/+44
PR tui/24722 points out that deleting a breakpoint does not cause the "b" to be removed from the breakpoint display. The issue here was that the breakpoint still exists at the moment the breakpoint-deleted observer is notified. This fixes the problem by specially handling the case where a breakpoint is being removed. gdb/ChangeLog 2019-07-17 Tom Tromey <tom@tromey.com> PR tui/24722: * tui/tui-winsource.h (tui_update_all_breakpoint_info) (tui_update_breakpoint_info): Add "being_deleted" parameter. * tui/tui-winsource.c (tui_update_source_window_as_is): Update. (tui_update_all_breakpoint_info): Add "being_deleted" parameter. (tui_update_breakpoint_info): Likewise. * tui/tui-hooks.c (tui_event_create_breakpoint) (tui_event_delete_breakpoint, tui_event_modify_breakpoint): Update.
2019-07-17Consolidate "if"s in tui_show_frame_infoTom Tromey2-35/+31
tui_show_frame_info has two parallel "if"s with the same condition and no intervening code. The second "if" perhaps wasn't obviously identical, but earlier refactorings made it clearer, by pointing out that only source and disassembly windows can be handled here. This merges the two statements. gdb/ChangeLog 2019-07-17 Tom Tromey <tom@tromey.com> * tui/tui-stack.c (tui_show_frame_info): Consolidate "if"s.
2019-07-17Remove some uses of TUI_WIN_SRCTom Tromey4-27/+40
This adds a 'win_info' parameter to a couple of functions. This reduces the number of references to the TUI_WIN_SRC global. gdb/ChangeLog 2019-07-17 Tom Tromey <tom@tromey.com> * tui/tui-winsource.c (tui_update_source_window_as_is) (tui_update_source_windows_with_addr): Update. * tui/tui-source.h (tui_set_source_content) (tui_show_symtab_source): Add "win_info" parameter. * tui/tui-source.c (tui_set_source_content): Add "win_info" parameter. (tui_show_symtab_source): Likewise.
2019-07-17Check can_highlight in tui_check_and_display_highlight_if_neededTom Tromey2-1/+6
tui_check_and_display_highlight_if_needed currently checks the window's type; but this can be replaced with a check of "can_highlight", making it more polymorphically-correct. gdb/ChangeLog 2019-07-17 Tom Tromey <tom@tromey.com> * tui/tui-wingeneral.c (tui_check_and_display_highlight_if_needed): Check can_highlight.
2019-07-17Introduce can_scroll methodTom Tromey3-4/+21
This introduces a "can_scroll" method, removing a spot that explicitly checks a window's type. gdb/ChangeLog 2019-07-17 Tom Tromey <tom@tromey.com> * tui/tui-data.h (struct tui_win_info) <can_scroll>: New method. (struct tui_cmd_window) <can_scroll>: New method. * tui/tui-command.c (tui_dispatch_ctrl_char): Use can_scroll method.
2019-07-17Rename field_int to field_signedTom Tromey33-156/+220
This renames ui_out::field_int to field_signed, and field_fmt_int to field_fmt_signed; and changes the type of the "value" parameter from int to LONGEST. Tested by the buildbot. gdb/ChangeLog 2019-07-17 Tom Tromey <tromey@adacore.com> * ui-out.h (class ui_out) <field_signed, field_fmt_signed, do_field_signed>: Rename. Change type of "value". * ui-out.c (ui_out::field_signed): Rename from field_int. Change type of "value". (ui_out::field_fmt_signed): Rename from field_fmt_int. Change type of "value". * tui/tui-out.h (class tui_ui_out) <do_field_signed>: Rename from do_field_int. Change type of "value". * tui/tui-out.c (tui_ui_out::do_field_signed): Rename from do_field_int. Change type of "value". * tracepoint.c (trace_status_mi, tfind_1) (print_one_static_tracepoint_marker): Update. * thread.c (print_thread_info_1, print_selected_thread_frame): Update. * stack.c (print_frame, print_frame_info): Update. * spu-tdep.c (info_spu_signal_command, info_spu_dma_cmdlist): Update. * source.c (print_source_lines_base): Update. * skip.c (info_skip_command): Update. * record-btrace.c (btrace_ui_out_decode_error) (btrace_call_history_src_line): Update. * python/py-framefilter.c (py_print_single_arg, py_print_frame): Update. * progspace.c (print_program_space): Update. * mi/mi-symbol-cmds.c (mi_cmd_symbol_list_lines): Update. * mi/mi-out.h (class mi_ui_out) <do_field_signed>: Rename from do_field_int. Change type of "value". * mi/mi-out.c (mi_ui_out::do_table_begin) (mi_ui_out::do_table_header): Update. (mi_ui_out::do_field_signed): Rename from do_field_int. Change type of "value". * mi/mi-main.c (mi_cmd_thread_list_ids, print_one_inferior) (mi_cmd_data_list_changed_registers, output_register) (mi_cmd_data_read_memory, mi_load_progress) (mi_cmd_trace_frame_collected): Update. * mi/mi-interp.c (mi_on_normal_stop_1, mi_output_solib_attribs): Update. * mi/mi-cmd-var.c (print_varobj, mi_cmd_var_create) (mi_cmd_var_delete, mi_cmd_var_info_num_children) (mi_cmd_var_list_children, varobj_update_one): Update. * mi/mi-cmd-stack.c (mi_cmd_stack_info_depth) (mi_cmd_stack_list_args, list_arg_or_local): Update. * mi/mi-cmd-file.c (mi_cmd_file_list_exec_source_file): Update. * inferior.c (print_inferior): Update. * gdb_bfd.c (print_one_bfd): Update. * disasm.c (gdb_pretty_print_disassembler::pretty_print_insn): Update. * darwin-nat-info.c (darwin_debug_regions_recurse): Update. * cli-out.h (class cli_ui_out) <do_field_signed>: Rename from do_field_int. Change type of "value". * cli-out.c (cli_ui_out::do_field_signed): Rename from do_field_int. Change type of "value". * breakpoint.c (watchpoint_check, print_breakpoint_location) (print_one_breakpoint_location, print_it_catch_fork) (print_one_catch_fork, print_it_catch_vfork) (print_one_catch_vfork, print_it_catch_solib) (print_it_catch_exec, print_it_ranged_breakpoint) (print_mention_watchpoint, print_mention_masked_watchpoint) (bkpt_print_it, update_static_tracepoint): Update. * break-catch-throw.c (print_it_exception_catchpoint): Update. * break-catch-syscall.c (print_it_catch_syscall): Update. * ada-tasks.c (print_ada_task_info): Update. * ada-lang.c (print_it_exception, print_mention_exception): Update.
2019-07-17gdb: Remove a non-const reference parameterAndrew Burgess8-48/+43
Non-const reference parameter should be avoided according to the GDB coding standard: https://sourceware.org/gdb/wiki/Internals%20GDB-C-Coding-Standards#Avoid_non-const_reference_parameters.2C_use_pointers_instead This commit updates the gdbarch method gdbarch_stap_adjust_register, and the one implementation i386_stap_adjust_register to avoid using a non-const reference parameter. I've also removed the kfail from the testsuite for bug 24541, as this issue is now resolved. gdb/ChangeLog: PR breakpoints/24541 * gdbarch.c: Regenerate. * gdbarch.h: Regenerate. * gdbarch.sh: Adjust return type and parameter types for 'stap_adjust_register'. (i386_stap_adjust_register): Adjust signature and return new register name. * stap-probe.c (stap_parse_register_operand): Adjust use of 'gdbarch_stap_adjust_register'. gdb/testsuite/ChangeLog: PR breakpoints/24541 * gdb.mi/mi-catch-cpp-exceptions.exp: Remove kfail due to 24541.
2019-07-17Remove a VEC from s390-linux-nat.cTom Tromey2-48/+49
This removes a use of VEC fro s390-linux-nat.c, replacing it with std::vector. Tested using the Fedora-s390x-m64 buildbot builder. gdb/ChangeLog 2019-07-17 Tom Tromey <tromey@adacore.com> * s390-linux-nat.c (s390_watch_area): Remove typedef. Don't declare VEC. (struct s390_debug_reg_state) <watch_areas, break_areas>: Now std::vector. (struct s390_process_info): Add initializers. (s390_add_process): Use new. (s390_linux_nat_target::low_forget_process): Use delete. (s390_linux_nat_target::low_new_fork) (s390_linux_nat_target::stopped_by_watchpoint) (s390_linux_nat_target::low_prepare_to_resume) (s390_linux_nat_target::insert_watchpoint) (s390_linux_nat_target::insert_hw_breakpoint) (s390_linux_nat_target::remove_watchpoint) (s390_linux_nat_target::remove_hw_breakpoint): Update.
2019-07-17x86: replace "anymem" checks where possibleJan Beulich2-8/+22
Once operand parsing has completed, the simpler check of Operand_Mem can be used in places where i.types[] got passed to operand_type_check(). Note that this has shown a couple of omissions of adjusting i.flags[] when playing with i.op[] / i.types[] / i.tm.operand_types[]. Not all of them get added here, just all of the ones needed in process_operands().
2019-07-17x86: drop stale Mem enumeratorJan Beulich3-4/+24
This was supposed to also be removed by c48dadc9a8 ('x86: drop "mem" operand type attribute'). It's odd enough that this hasn't caused build issues, considering the careful use of OTunused (apparently to avoid "missing initializer" warnings). To avoid such happening again introduce compile time consistency checks.
2019-07-17Automatic date update in version.inGDB Administrator1-1/+1
2019-07-16x86: make RegMem an opcode modifierJan Beulich8-16499/+20448
... instead of an operand type bit: It's an insn property, not an operand one. There's just one actual change to be made to the templates: Most are now required to have the (unswapped) destination go into ModR/M.rm, so VMOVD template needs its opcode adjusted accordingly and its operands swapped. {,V}MOVS{S,D}, otoh, are left alone in this regard, as otherwise generated code would differ from what we've been producing so far (which I don't think is wanted). Take the opportunity and add a missing IgnoreSize to pextrb (leading to an error in 16-bit mode), and take the liberty to once again drop stray IgnoreSize attributes from lines changed and neighboring related ones.
2019-07-16x86: fold SReg{2,3}Jan Beulich15-24263/+13987
They're the only exception to there generally being no mix of register kinds possible in an insn operand template, and there being two bits per operand for their representation is also quite wasteful, considering the low number of uses. Fold both bits and deal with the little bit of fallout. Also take the liberty and drop dead code trying to set REX_B: No segment register has RegRex set on it. Additionally I was quite surprised that PUSH/POP with the permitted segment registers is not covered by the test cases. Add the missing pieces.
2019-07-15Fix build for aarch64, arm, and riscv FreeBSD native targets.John Baldwin4-24/+30
Remove unused gdbarch argument to helper functions originally copied from mips-fbsd-nat.c. Include regcache.h previously included from defs.h via gdbarch.h. gdb/ChangeLog: * aarch64-fbsd-nat.c: Include regcache.h. (getregs_supplies, getfpregs_supplies): Remove unused gdbarch argument. (aarch64_fbsd_nat_target::fetch_registers) (aarch64_fbsd_nat_target::store_registers): Remove gdbarch variable. * arm-fbsd-nat.c, riscv-fbsd-nat.c: Likewise.
2019-07-15Add include of gdbarch.h.John Baldwin2-0/+5
gdb/ChangeLog: * fbsd-nat.c: Include gdbarch.h.
2019-07-16Automatic date update in version.inGDB Administrator1-1/+1
2019-07-15Fix a FIXME in mi-out.cTom Tromey2-4/+5
This removes a FIXME comment from mi_ui_out::do_field_int, by replacing a printf with a use of plongest. 2019-07-15 Tom Tromey <tromey@adacore.com> * mi/mi-out.c (mi_ui_out::do_field_int): Use plongest.
2019-07-15Introduce field_unsignedTom Tromey10-18/+74
This adds field_unsigned and changes various places using field_fmt with "%u" to use this instead. This also replaces an existing equivalent helper function in record-btrace.c. 2019-07-15 Tom Tromey <tromey@adacore.com> * mi/mi-out.h (class mi_ui_out) <do_field_unsigned>: Declare. * mi/mi-out.c (mi_ui_out::do_field_unsigned): New method. * cli-out.h (class cli_ui_out) <do_field_unsigned>: Declare. * cli-out.c (cli_ui_out::do_field_int): New method. * ui-out.c (ui_out::field_unsigned): New method. * symfile.c (generic_load): Use field_unsigned. (print_transfer_performance): Likewise. * record-btrace.c (ui_out_field_uint): Remove. (btrace_call_history_insn_range, btrace_call_history): Use field_unsigned. * disasm.c (gdb_pretty_print_disassembler::pretty_print_insn): Use field_unsigned. * ui-out.h (class ui_out) <field_unsigned>: New method. <do_field_unsigned>: Likewise.
2019-07-15Use field_string in more placesTom Tromey8-13/+24
This replaces uses of field_fmt with a "%s" format string to use field_string instead. Also, one use of "%9lx" is replaced with a call to phex_nz; the '9' is dropped as it is implicit in the field width. 2019-07-15 Tom Tromey <tromey@adacore.com> * mi/mi-main.c (list_available_thread_groups): Use field_string. * mi/mi-interp.c (mi_memory_changed): Use field_string. * target.c (flash_erase_command): Use field_string. * infrun.c (print_signal_received_reason): Use field_string. * i386-tdep.c (i386_mpx_print_bounds): Use field_string. * breakpoint.c (maybe_print_thread_hit_breakpoint): Use field_string. * ada-tasks.c (print_ada_task_info): Use field_string.
2019-07-15Use field_core_addr in more placesTom Tromey5-8/+17
This changes a few spots that use field_fmt to use field_core_addr instead. gdb/ChangeLog 2019-07-15 Tom Tromey <tromey@adacore.com> * target.c (flash_erase_command): Use field_core_addr. * symfile.c (generic_load): Use field_core_addr. * sparc64-linux-tdep.c (sparc64_linux_handle_segmentation_fault): Use field_core_addr. * i386-linux-tdep.c (i386_linux_handle_segmentation_fault): Use field_core_addr.
2019-07-15cpu,opcodes,gas: fix explicit arguments to eBPF ldabs instructionsJose E. Marchesi11-127/+119
This patch fixes the eBPF CPU description in order to reflect the right explicit arguments passed to the ldabs{b,h,w,dw} instructions, updates the corresponding GAS tests, and updates the BPF section of the GAS manual. cpu/ChangeLog: 2019-07-15 Jose E. Marchesi <jose.marchesi@oracle.com> * bpf.cpu (dlabs): New pmacro. (dlind): Likewise. opcodes/ChangeLog: 2019-07-15 Jose E. Marchesi <jose.marchesi@oracle.com> * bpf-desc.c: Regenerate. * bpf-opc.c: Likewise. * bpf-opc.h: Likewise. gas/ChangeLog: 2019-07-15 Jose E. Marchesi <jose.marchesi@oracle.com> * testsuite/gas/bpf/mem.s: ldabs instructions do not take a `src' register as an argument. * testsuite/gas/bpf/mem.d: Updated accordingly. * testsuite/gas/bpf/mem-be.d: Likewise. * doc/c-bpf.texi (BPF Opcodes): Update to reflect the correct explicit arguments to ldabs and ldind instructions.
2019-07-15Fix __bss_start assertion failure in _bfd_elf_fix_symbol_flagsAlan Modra2-3/+15
> Building LLVM 6.0 on FreeBSD/powerpc (devel/llvm60 port) the assertion > in the subject trips (displays twice) when linking libLTO.so.1. The > issue has been filed in FreeBSD's bugzilla, at > https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=237068 . It appears > the 'llvm::hashing::detail::get_execution_seed()::seed@@JL_LLVM_6.0' > symbol is being weakly aliased to an indirect symbol > __bss_start@@JL_LLVM_6.0. Since __bss_start@@JL_LLVM_6.0 is an > indirect symbol, it fails the assertion. I haven't looked under a debugger at your testcase but I think I know what is going on here. You have a shared library with a weakly defined llvm::hashing::detail::get_execution_seed()::seed which happens to be at the same location as __bss_start in that library. At the time the linker loads symbols for that library, it sees they are both versioned and thus introduces non-versioned indirect symbols for them. The linker considers the symbols as possibly being aliases, setting up h->u.alias and h->is_weakalias such that __bss_start@@JL_LLVM_6.0 is the definition. No real problem so far, the definition is bfd_link_hash_defined, except that the zero size, no type __bss_start symbol possibly should not be considered an alias in the first place. Later, __bss_start as defined by the linker script is entered into the linker symbol table. This is similar to __bss_start being defined by a regular object file in that ELF symbol resolution rules say that the value of __bss_start in the library is overridden by __bss_start in the executable/library being produced. So to accomplish the override, ld flips __bss_start from being an indirect symbol pointing at __bss_start@@JL_LLVM_6.0 to __bss_start@@JL_LLVM_6.0 being an indirect symbol pointing at __bss_start. That's how we get an unexpected indirect symbol and hit the assert. What should happen I think, is for the def->def_regular code above the assert to run in this case. The symbols are no longer aliases. * elflink.c (_bfd_elf_fix_symbol_flags): If the def for an alias is no longer bfd_link_hash_defined, clear the alias.
2019-07-15Automatic date update in version.inGDB Administrator1-1/+1
2019-07-14cpu,opcodes,gas: fix arguments to ldabs and ldind eBPF instructionsJose E. Marchesi9-74/+91
The eBPF non-generic load instructions ldind{b,h,w,dw} and ldabs{b,h,w,dw} do not take an explicit destination register as an argument. Instead, they put the loaded value in %r0, implicitly. This patch fixes the CPU BPF description to not expect a 'dst' argument in these arguments, regenerates the corresponding files in opcodes, and updates the impacted GAS tests. Tested in a x86-64 host. cpu/ChangeLog: 2019-07-14 Jose E. Marchesi <jose.marchesi@oracle.com> * bpf.cpu (dlsi): ldabs and ldind instructions do not take an explicit 'dst' argument. opcodes/ChangeLog: 2019-07-14 Jose E. Marchesi <jose.marchesi@oracle.com> * bpf-desc.c: Regenerate. * bpf-opc.c: Likewise. gas/ChangeLog: 2019-07-14 Jose E. Marchesi <jose.marchesi@oracle.com> * testsuite/gas/bpf/mem.s: Do not use explicit arguments for ldabs and ldind instructions. * testsuite/gas/bpf/mem.d: Updated accordingly. * testsuite/gas/bpf/mem-be.d: Likewise.
2019-07-14[gdb/testsuite] Fix unterminated string in gdb.objc/basicclass.expTom de Vries2-1/+6
The test-case gdb.objc/basicclass.exp contains an unterminated string, introduced in refactoring commit fa43b1d7ca "after gdb_run_cmd, gdb_expect -> gdb_test_multiple/gdb_test". Fix the unterminated string. gdb/testsuite/ChangeLog: 2019-07-14 Tom de Vries <tdevries@suse.de> PR testsuite/24760 * gdb.objc/basicclass.exp: Fix unterminated string.
2019-07-13adjust src-release following the renaming of gdb/common/ to gdb/gdbsupport/Joel Brobecker2-0/+9
A recent change renamed the common/ directory into gdbsupport/ in gdb. This causes problems in the getver function in the src-release script which doesn't find the create-version.sh script anymore. As a result, it falls back on using the version.in file verbatim, meaning that the "DATE" placeholder doesn't get replaced with the snapshot date, and the "-git" suffix doesn't get stripped. More precisely, we get snapshots called "gdb-8.3.50-DATE-git.tar" instead of (e.g.) "gdb-8.3-20190712.tar". This commit fixes the issue by adding support for this situation. I left the support for $tool/common/create-version.sh, because the sim still uses that directory structure. ChangeLog: * src-release (getver): If $tool/gdbsupport/create-version.sh exists, use that to determine the version number.
2019-07-14Automatic date update in version.inGDB Administrator1-1/+1
2019-07-13Dynamic TLS section symbolsAlan Modra50-348/+427
It is possible to create shared libraries on PowerPC using -ftls-model=inital-exec or -ftls-model=local-exec. The first is half reasonable, getting you a shared library that can't be dlopen'd but otherwise is reasonable. The second is quite bad. Not only do you lose being able to dlopen, the library also has dynamic text relocations. Worse, the TPREL16_LO, TPREL16_HA and other TPREL16 dynamic relocs emitted were wrong, resulting in wrong values being applied by ld.so. Using the first TLS section symbol in dynamic relocations for local TLS symbols doesn't work. It's wrong because TLS symbols used by TLS relocs have values relative to the TLS segment, whereas the TLS section symbols are addresses. This patch instead uses a symbol index of zero which is used elsewhere by PowerPC on dynamic TLS relocs. It's not strictly ABI compliant to use a non-TLS symbol with TLS relocs but symbol index zero can be interpreted as "no symbol". Not using the first TLS section symbol means it doesn't need to be dynamic. The patch also fixes a further problem with PowerPC32 dynamic TPREL16* relocs, which shouldn't have the symbol value in the addend as we do for non-TLS symbols. bfd/ * elflink.c (_bfd_elf_omit_section_dynsym_default): Don't keep tls_sec. (_bfd_elf_init_1_index_section): Prefer not using TLS sections. (_bfd_elf_init_2_index_sections): Likewise. * elf64-ppc.c (ppc64_elf_relocate_section): When emitting dynamic relocations for local TLS symbols, use STN_UNDEF as the relocation symbol. * elf32-ppc.c (ppc_elf_relocate_section): Likewise, and don't leave TLS symbol value in the addend. ld/ * testsuite/ld-powerpc/tlsso.r: Update. * testsuite/ld-powerpc/tlsso32.g: Update. * testsuite/ld-powerpc/tlsso32.r: Update. * testsuite/ld-powerpc/tlstocso.r: Update. * testsuite/ld-cris/tls-dso-dtpoffd2.d: Update. * testsuite/ld-cris/tls-dso-dtpoffd4.d: Update. * testsuite/ld-cris/tls-dso-tpoffgotcomm1.d: Update. * testsuite/ld-cris/tls-gd-1.d: Update. * testsuite/ld-cris/tls-gd-1h.d: Update. * testsuite/ld-cris/tls-gd-2.d: Update. * testsuite/ld-cris/tls-gd-2h.d: Update. * testsuite/ld-cris/tls-ie-10.d: Update. * testsuite/ld-cris/tls-ie-11.d: Update. * testsuite/ld-cris/tls-ie-8.d: Update. * testsuite/ld-cris/tls-ie-9.d: Update. * testsuite/ld-cris/tls-js1.d: Update. * testsuite/ld-cris/tls-ld-4.d: Update. * testsuite/ld-cris/tls-ld-5.d: Update. * testsuite/ld-cris/tls-ld-6.d: Update. * testsuite/ld-cris/tls-ld-7.d: Update. * testsuite/ld-cris/tls-ldgd-14.d: Update. * testsuite/ld-cris/tls-ldgd-15.d: Update. * testsuite/ld-cris/tls-ldgdx-14.d: Update. * testsuite/ld-cris/tls-ldgdx-15.d: Update. * testsuite/ld-cris/tls-local-54.d: Update. * testsuite/ld-cris/tls-local-60.d: Update. * testsuite/ld-cris/tls-local-61.d: Update. * testsuite/ld-cris/tls-local-63.d: Update. * testsuite/ld-cris/tls-local-64.d: Update. * testsuite/ld-cris/tls-ok-30.d: Update. * testsuite/ld-cris/tls-ok-32.d: Update. * testsuite/ld-cris/tls-ok-34.d: Update. * testsuite/ld-mips-elf/tls-multi-got-1.got: Update. * testsuite/ld-mips-elf/tls-multi-got-1.r: Update. * testsuite/ld-mips-elf/tlsdyn-pie-o32.d: Update. * testsuite/ld-mips-elf/tlsdyn-pie-o32.got: Update. * testsuite/ld-mips-elf/tlslib-o32-hidden.got: Update. * testsuite/ld-mips-elf/tlslib-o32-ver.got: Update. * testsuite/ld-mips-elf/tlslib-o32.got: Update. * testsuite/ld-s390/tlspic.rd: Update. * testsuite/ld-s390/tlspic_64.rd: Update. * testsuite/ld-sparc/tlssunnopic32.rd: Update. * testsuite/ld-sparc/tlssunnopic64.rd: Update. * testsuite/ld-sparc/tlssunpic32.rd: Update. * testsuite/ld-sparc/tlssunpic64.rd: Update.
2019-07-13PR24786, wrong LMA if first section in overlay is emptyAlan Modra3-8/+21
This stops the first overlay section being ignored when empty, losing its LMA assignment PR 24786 * ldlang.h (enum section_type): Add first_overlay_section. * ldlang.c (lang_add_section): Adjust switch statement. (map_input_to_output_sections): Likewise. (lang_size_sections_1): Always set last_os for first overlay section. (lang_leave_overlay): Set sectype to first_overlay_section.
2019-07-13[GOLD] PowerPC R_PPC64_PCREL_OPT supportAlan Modra2-12/+177
* powerpc.cc (xlate_pcrel_opt): New function. (Target_powerpc::Relocate::relocate): Optimise PCREL34 and GOT_PCREL34 sequences marked with PCREL_OPT.
2019-07-13[GOLD] PowerPC got reloc optimisationAlan Modra2-11/+104
Note that gold won't remove unused GOT entries, in contrast to ld.bfd which will. * powerpc.cc (Powerpc_relobj::make_got_relative): New function. (relative_value_is_known): New functions. (Target_powerpc::Relocate::relocate): Edit code using GOT16_HA, GOT16_LO_DS, and GOT_PCREL34 relocs.
2019-07-13[GOLD] PowerPC relocations for prefix insnsAlan Modra4-12/+485
Also use pc-relative instructions for notoc stubs. elfcpp/ * powerpc.h (R_PPC64_PCREL_OPT, R_PPC64_D34, R_PPC64_D34_LO), (R_PPC64_D34_HI30, R_PPC64_D34_HA30, R_PPC64_PCREL34), (R_PPC64_GOT_PCREL34, R_PPC64_PLT_PCREL34, R_PPC64_PLT_PCREL34_NOTOC), (R_PPC64_ADDR16_HIGHER34, R_PPC64_ADDR16_HIGHERA34), (R_PPC64_ADDR16_HIGHEST34, R_PPC64_ADDR16_HIGHESTA34), (R_PPC64_REL16_HIGHER34, R_PPC64_REL16_HIGHERA34), (R_PPC64_REL16_HIGHEST34, R_PPC64_REL16_HIGHESTA34), (R_PPC64_D28, R_PPC64_PCREL28): Define. gold/ * powerpc.cc (Target_powerpc): Add powerxx_stubs_ and accessor functions. (Target_powerpc::maybe_skip_tls_get_addr_call): Handle PLT_PCREL34 and PLT_PCREL34_NOTOC relocs. (Powerpc_relocate_functions): Add addr34, addr34_hi, addr34_ha, addr28, addr16_higher34, addr16_highera34, addr16_highest34, addr16_highest34a functions. (li_11_0, ori_11_11_0, sldi_11_11_34): Define. (paddi_12_pc, pld_12_pc, pnop): Define. (d34, ha34): New inline functions. (Stub_table::add_plt_call_entry): Handle powerxx_stubs. (Stub_table::add_eh_frame): Likewise. (build_powerxx_offset): New function. (Stub_table::plt_call_size): Handle powerxx_stubs. (Stub_table::branch_stub_size): Likewise. (Stub_table::do_write): Likewise. (Target_powerpc::Scan::get_reference_flags): Handle new relocs. (Target_powerpc::Scan::reloc_needs_plt_for_ifunc: Likewise. (Target_powerpc::Scan::local, global, relocate): Likewise.
2019-07-13[GOLD] PowerPC notoc eh_frameAlan Modra6-117/+190
When generating notoc call and branch stubs without the benefit of pc-relative insns, the stubs need to use LR to access the run time PC. All LR changes must be described in .eh_frame if we're to support unwinding through asynchronous exceptions. That's what this patch does. The patch has gone through way too many iterations. At first I attempted to add multiple FDEs, one for each stub. That ran into difficulties with do_plt_fde_location which is only capable of setting the address of a single FDE per Output_data section, and with removing any FDEs added on a previous do_relax pass. Removing FDEs (git commit be897fb774) went overboard in matching the FDE contents. That means either stashing the contents created for add_eh_frame_for_plt to use when calling remove_eh_frame_for_plt, or recreating contents on the fly (*) just to remove FDEs. In fact, FDE content matching is quite unnecesary. FDEs added by a previous do_relax pass are those with u_.from_linker.post_map set. So they can easily be recognised just by looking at that flag. This patch keeps that part of the multiple FDE changes. In the end I went for just one FDE per stub group to describe the call stubs. That's reasonably efficient for the common case of only needing to describe the __tls_get_addr_opt call stub. We don't expect to be making many calls using notoc stubs without pc-relative insns. *) Which has it's own set of problems. The contents must be recreated using the old stub layout, but .eh_frame size can affect stub requirements so you need to temporarily keep the old .eh_frame size when creating new stubs, then reset .eh_frame size before adding new FDEs. * ehframe.cc (Fde::operator==): Delete. (Cie::remove_fde): Delete. (Eh_frame::remove_ehframe_for_plt): Delete fde_data and fde_length parameters. Remove all post-map plt FDEs. * ehframe.h (Fde:post_map): Make const, add variant to compare plt. (Fde::operator==): Delete. (Cie::remove_fde): Implement here. (Cie::last_fde): New accessor. (Eh_frame::remove_ehframe_for_plt): Update prototype. * layout.cc (Layout::remove_eh_frame_for_plt): Delete fde_data and fde_length parameters. * layout.h (Layout::remove_eh_frame_for_plt): Update prototype. * powerpc.cc (Stub_table::tls_get_addr_opt_bctrl_): Delete. (Stub_table::plt_fde_len_, plt_fde_, init_plt_fde): Delete. (Stub_table::add_plt_call_entry): Don't set tls_get_addr_opt_bctrl_. (eh_advance): New function. (stub_sort): New function. (Stub_table::add_eh_frame): Emit eh_frame for notoc plt calls and branches as well as __tls_get_addr_opt plt call stub. (Stub_table::remove_eh_frame): Update to suit.
2019-07-13[GOLD] PowerPC64 ELFv2 notoc supportAlan Modra4-261/+752
Calls from notoc functions via the PLT need different stubs. Even calls to local functions requiring a valid toc pointer must go via a stub. This patch provides the support in gold. elfcpp/ * powerpc.h (R_PPC64_PLTSEQ_NOTOC, R_PPC64_PLTCALL_NOTOC): Define. gold/ * powerpc.cc (Target_powerpc::maybe_skip_tls_get_addr_call): Handle notoc calls. (is_branch_reloc): Template on size. Return true for REL24_NOTOC. Update all callers. (max_branch_delta): Likewise. (Target_powerpc::Branch_info::make_stub): Add a stub for notoc calls to functions needing a valid toc pointer. (Target_powerpc::do_relax): Layout stubs again if any need resize. (add_12_11_12, addi_12_11, addis_12_11, ldx_12_11_12, ori_12_12_0), (oris_12_12_0, sldi_12_12_32): Define. (Stub_table::Plt_stub_ent): Add notoc_ and iter_ fields. (Stub_table::Branch_stub_key, Branch_stub_key_hash): Rename from Branch_stub_ent and Branch_stub_ent hash. Remove save_res_ from key. (Stub_table::Branch_stub_ent): New struct. (class Stub_table): Add need_resize and resizing vars. (Stub_table::need_resize, branch_size): New accessors. (Stub_table::set_resizing): New function. (Stub_table::add_plt_call_entry): Handle notoc calls and resizing on seeing such or a tocsave stubs after a normal stub using the same sym. (Stub_table::add_long_branch_entry): Similarly. (Stub_table::find_long_branch_entry): Return a Branch_stub_ent*. (Stub_table::define_stub_syms): Adjust (Stub_table::build_tls_opt_head, build_tls_opt_tail): New functions. (build_notoc_offset): New function. (Stub_table::plt_call_size): Move out of line. Handle notoc calls. (Stub_table::branch_stub_size): Similarly. (Stub_table::do_write): Separate loop for ELFv2 stubs, handling notoc calls. Simplify ELFv1 loop. Output notoc branch stubs. Use build_tls_opt_head and build_tls_opt_tail. (Target_powerpc::Scan::get_reference_flags): Handle REL24_NOTOC. (Target_powerpc::Scan::reloc_needs_plt_for_ifunc): Likewise, and PLTSEQ_NOTOC and PLTCALL_NOTOC. (Target_powerpc::Scan::local, global, relocate): Likewise.
2019-07-13Automatic date update in version.inGDB Administrator1-1/+1
2019-07-12gdb: Better support for dynamic properties with negative valuesAndrew Burgess7-0/+103
When the type of a property is smaller than the CORE_ADDR in which the property value has been placed, and if the property is signed, then sign extend the property value from its actual type up to the size of CORE_ADDR. gdb/ChangeLog: * dwarf2loc.c (dwarf2_evaluate_property): Sign extend property value if its desired type is smaller than a CORE_ADDR and signed. gdb/testsuite/ChangeLog: * gdb.fortran/vla-ptype.exp: Print array with negative bounds. * gdb.fortran/vla-sizeof.exp: Print the size of an array with negative bounds. * gdb.fortran/vla-value.exp: Print elements of an array with negative bounds. * gdb.fortran/vla.f90: Setup an array with negative bounds for testing.
2019-07-12gdb: Carry default property type around with dynamic propertiesAndrew Burgess4-50/+125
This commit is preparation for the next one, with the aim of better supporting signed dynamic properties on targets where the address size specified in the DWARF headers is smaller than a CORE_ADDR, for example debugging an i386 application on x86-64. Consider this small Fortran program 'bounds.f90': program test integer, allocatable :: array (:) allocate (array (-5:5)) array(3) = 1 end program test Compiled with 'gfortran -m32 -g3 -O0 -o bounds bounds.f90'. The DWARF for 'array' looks like this: <2><97>: Abbrev Number: 10 (DW_TAG_variable) <98> DW_AT_name : (indirect string, offset: 0x0): array <9c> DW_AT_decl_file : 1 <9d> DW_AT_decl_line : 2 <9e> DW_AT_type : <0xaf> <a2> DW_AT_location : 2 byte block: 91 58 (DW_OP_fbreg: -40) <2><a5>: Abbrev Number: 11 (DW_TAG_lexical_block) <a6> DW_AT_low_pc : 0x80485c3 <aa> DW_AT_high_pc : 0x8b <2><ae>: Abbrev Number: 0 <1><af>: Abbrev Number: 12 (DW_TAG_array_type) <b0> DW_AT_data_location: 2 byte block: 97 6 (DW_OP_push_object_address; DW_OP_deref) <b3> DW_AT_allocated : 4 byte block: 97 6 30 2e (DW_OP_push_object_address; DW_OP_deref; DW_OP_lit0; DW_OP_ne) <b8> DW_AT_type : <0x2a> <2><bc>: Abbrev Number: 13 (DW_TAG_subrange_type) <bd> DW_AT_lower_bound : 4 byte block: 97 23 10 6 (DW_OP_push_object_address; DW_OP_plus_uconst: 16; DW_OP_deref) <c2> DW_AT_upper_bound : 4 byte block: 97 23 14 6 (DW_OP_push_object_address; DW_OP_plus_uconst: 20; DW_OP_deref) <c7> DW_AT_byte_stride : 6 byte block: 97 23 c 6 34 1e (DW_OP_push_object_address; DW_OP_plus_uconst: 12; DW_OP_deref; DW_OP_lit4; DW_OP_mul) <2><ce>: Abbrev Number: 0 If we look at the DW_AT_lower_bound attribute, which will become a dynamic property that GDB evaluates when needed by calling dwarf2_evaluate_property. The process of evaluating a dynamic property requires GDB to execute each DW_OP_* operation, the results of these operations is held on a stack of 'struct value *'s. When the entire expression is evaluated the result is on top of the stack. If we look at DW_AT_lower_bound then the last operation is DW_OP_deref, this loads a signed address the size of which matches the DWARF address size, and so in our i386 on x86-64 situation, the top of the stack will be a signed 4-byte value. The problem is how these values are fetched from the stack. Currently they are always fetched by a call to dwarf_expr_context::fetch_address, which converts the value to an unsigned value with a length matching the values current length, before converting to a CORE_ADDR. This means we loose the signed nature of the property. I wonder if the best solution for dealing with signed properties will be to move away from an over reliance on fetch_address, and instead come up with a new solution that considers the current type of the value on the stack, and the type that the value needs to become; basically a solution built around casting rather than assuming we always want an address. However, before we can start to even think about moving away from fetch_address, there is a more urgent issue to fix, which is we don't currently know what type each property should be. We just hold the value of the property in a CORE_ADDR as returned by fetch_address, and rely on higher level code (outside of the DWARF expression evaluation code) to fix things up for us. This is what this patch aims to address. When creating a dynamic property (see attr_to_dynamic_prop in dwarf2read.c) we can sometimes figure out the type of a property; if the property is a reference to another DIE then it will have a DW_AT_type attribute. However, the DW_AT_lower_bound case above isn't a reference to another DIE, it's just a DWARF expression. We don't have any indication for what type the property should have. Luckily, the DWARF spec helps us out, for the lower and upper bounds 5.13 of the DWARFv5 spec tells us that without any other type information the bounds are signed integers the same size as a DWARF address. It is my belief that we can find a suitable default type for every dynamic property, either specified explicitly in the DWARF spec, or we can infer an obvious choice if the spec doesn't help us. This commit extends the creation of all dynamic properties to include suggesting a suitable default type, all dynamic properties now always carry their type around with them. In later commits we can use this property type to ensure that the value we extract from the DWARF stack is handled in a suitable manor to correctly maintain its sign extension. There should be no user visible changes from this commit. The actual fix to correctly support negative array bounds will come later. gdb/ChangeLog: * dwarf2loc.c (dwarf2_evaluate_property): Update to take account of changes to field names, and use new is_reference field to decide if a property is a reference or not. * dwarf2loc.h (struct dwarf2_locexpr_baton): Add 'is_reference' field. (struct dwarf2_property_baton): Update header comment, rename 'referenced_type' to 'property_type' and update comments. * dwarf2read.c (attr_to_dynamic_prop): Add extra parameter to hold default property type, store in property baton, update to take accound of renamed field. (read_func_scope): Update call to attr_to_dynamic_prop. (read_array_type): Likewise. (dwarf2_per_cu_addr_sized_int_type): New function. (read_subrange_index_type): Move type finding code to dwarf2_per_cu_addr_sized_int_type. (read_subrange_type): Update calls to attr_to_dynamic_prop. (dwarf2_per_cu_addr_type): New function. (set_die_type): Update calls to attr_to_dynamic_prop.
2019-07-12gdb/dwarf: Ensure the target type of ranges is not voidAndrew Burgess3-40/+63
If a DW_TAG_subrange_type DWARF entry has no DW_AT_type then a default type based on the size of an address on the current target is assumed. We store this type as the target type for GDB's range types. Currently GDB can create ranges for which the target type is VOID, this is incorrect but seems to cause no problems. I believe the reason this doesn't cause any issues is because the languages (for example Ada) that actually make use of a ranges target type also have compilers that generate DWARF that includes a DW_AT_type attribute. However, gfortran does not include a DW_AT_type, its DWARF instead relies on the default target type. This isn't currently a problem for GDB as gfortran doesn't make use of the target type when printing subranges, but it shouldn't hurt to fix this issue now. I've added an assert into create_range_type that will catch this issue if it comes up again. This was tested on an x86-64/GNU-Linux machine with both the Ada and gfortran compilers available with both '--target_board=unix' and '--target_board=unix/-m32'. There are no user visible changes after this commit. gdb/ChangeLog: * dwarf2read.c (read_subrange_index_type): New function. (read_subrange_type): Move code into new function and call it. * gdbtypes.c (create_range_type): Add some asserts.
2019-07-12gdb: Convert dwarf2_evaluate_property to return boolAndrew Burgess4-17/+23
Convert dwarf2_evaluate_property to return a bool, there should be no user visible change after this commit. gdb/ChangeLog: * dwarf2loc.c (dwarf2_evaluate_property): Change return type, and update return statements. * dwarf2loc.h (dwarf2_evaluate_property): Update return type on declaration, and update comment to match. * gdbtypes.c (resolve_dynamic_array): Update call to dwarf2_evaluate_property to match new return type.
2019-07-12gdb: Update type of lower bound in value_subscripted_rvalueAndrew Burgess3-2/+9
The dynamic lower (and upper) bounds of ranges are stored as type LONGEST (see union dynamic_prop_data in gdbtypes.h). In most places that range bounds are handled they are held in a LONGEST, however in value_subscripted_rvalue the bound is placed into an int. This commit changes value_subscripted_rvalue to use LONGEST, there should be no user visible changes after this commit. gdb/ChangeLog: * valarith.c (value_subscripted_rvalue): Change lowerbound parameter type from int to LONGEST. * value.h (value_subscripted_rvalue): Likewise in declaration.
2019-07-12[readline] Fix heap-buffer-overflow in update_lineTom de Vries2-0/+12
When: - building trunk gdb with '-fsanitize=address -lasan', - running gdb tests with "export ASAN_OPTIONS=detect_leaks=0", I run into a heap-buffer-overflow failure for gdb.base/utf8-identifiers.exp. In more detail, the libasan error report looks like this: ... ================================================================= ==22340==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x619000054a80 at pc 0x7fcd0306b4c9 bp 0x7fffb1a8d880 sp 0x7fffb1a8d030 READ of size 32766 at 0x619000054a80 thread T0 #0 0x7fcd0306b4c8 (/usr/lib64/libasan.so.4+0xae4c8) #1 0x15f12a1 in update_line /data/gdb_versions/devel/src/readline/display.c:1377 #2 0x15f03cb in rl_redisplay /data/gdb_versions/devel/src/readline/display.c:1204 #3 0x15bf932 in readline_internal_setup /data/gdb_versions/devel/src/readline/readline.c:394 #4 0x15fe723 in _rl_callback_newline /data/gdb_versions/devel/src/readline/callback.c:89 #5 0x15fe7ef in rl_callback_handler_install /data/gdb_versions/devel/src/readline/callback.c:102 #6 0xd7bce6 in gdb_rl_callback_handler_install(char const*) /data/gdb_versions/devel/src/gdb/event-top.c:319 #7 0xd7c0c6 in display_gdb_prompt(char const*) /data/gdb_versions/devel/src/gdb/event-top.c:409 #8 0xd7d6c1 in command_line_handler(std::unique_ptr<char, gdb::xfree_deleter<char> >&&) /data/gdb_versions/devel/src/gdb/event-top.c:776 #9 0xd7b92a in gdb_rl_callback_handler /data/gdb_versions/devel/src/gdb/event-top.c:217 #10 0x15ff479 in rl_callback_read_char /data/gdb_versions/devel/src/readline/callback.c:220 #11 0xd7b4d5 in gdb_rl_callback_read_char_wrapper_noexcept /data/gdb_versions/devel/src/gdb/event-top.c:175 #12 0xd7b6b5 in gdb_rl_callback_read_char_wrapper /data/gdb_versions/devel/src/gdb/event-top.c:192 #13 0xd7c8aa in stdin_event_handler(int, void*) /data/gdb_versions/devel/src/gdb/event-top.c:514 #14 0xd76ca7 in handle_file_event /data/gdb_versions/devel/src/gdb/event-loop.c:731 #15 0xd7751f in gdb_wait_for_event /data/gdb_versions/devel/src/gdb/event-loop.c:857 #16 0xd7547e in gdb_do_one_event() /data/gdb_versions/devel/src/gdb/event-loop.c:321 #17 0xd75526 in start_event_loop() /data/gdb_versions/devel/src/gdb/event-loop.c:370 #18 0x101b04c in captured_command_loop /data/gdb_versions/devel/src/gdb/main.c:331 #19 0x101de73 in captured_main /data/gdb_versions/devel/src/gdb/main.c:1173 #20 0x101df03 in gdb_main(captured_main_args*) /data/gdb_versions/devel/src/gdb/main.c:1188 #21 0x872dba in main /data/gdb_versions/devel/src/gdb/gdb.c:32 #22 0x7fcd00f2ff49 in __libc_start_main (/lib64/libc.so.6+0x20f49) #23 0x872bc9 in _start (/data/gdb_versions/devel/build/gdb/gdb+0x872bc9) 0x619000054a80 is located 0 bytes to the right of 1024-byte region [0x619000054680,0x619000054a80) allocated by thread T0 here: #0 0x7fcd03099510 in malloc (/usr/lib64/libasan.so.4+0xdc510) #1 0xae0078 in xmalloc /data/gdb_versions/devel/src/gdb/common/common-utils.c:44 #2 0x15eaccb in init_line_structures /data/gdb_versions/devel/src/readline/display.c:458 #3 0x15eb4d8 in rl_redisplay /data/gdb_versions/devel/src/readline/display.c:526 #4 0x15bf932 in readline_internal_setup /data/gdb_versions/devel/src/readline/readline.c:394 #5 0x15fe723 in _rl_callback_newline /data/gdb_versions/devel/src/readline/callback.c:89 #6 0x15fe7ef in rl_callback_handler_install /data/gdb_versions/devel/src/readline/callback.c:102 #7 0xd7bce6 in gdb_rl_callback_handler_install(char const*) /data/gdb_versions/devel/src/gdb/event-top.c:319 #8 0xd7c0c6 in display_gdb_prompt(char const*) /data/gdb_versions/devel/src/gdb/event-top.c:409 #9 0xaa041b in cli_interp_base::pre_command_loop() /data/gdb_versions/devel/src/gdb/cli/cli-interp.c:286 #10 0xf5342a in interp_pre_command_loop(interp*) /data/gdb_versions/devel/src/gdb/interps.c:320 #11 0x101b047 in captured_command_loop /data/gdb_versions/devel/src/gdb/main.c:328 #12 0x101de73 in captured_main /data/gdb_versions/devel/src/gdb/main.c:1173 #13 0x101df03 in gdb_main(captured_main_args*) /data/gdb_versions/devel/src/gdb/main.c:1188 #14 0x872dba in main /data/gdb_versions/devel/src/gdb/gdb.c:32 #15 0x7fcd00f2ff49 in __libc_start_main (/lib64/libc.so.6+0x20f49) SUMMARY: AddressSanitizer: heap-buffer-overflow (/usr/lib64/libasan.so.4+0xae4c8) Shadow bytes around the buggy address: 0x0c3280002900: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0c3280002910: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0c3280002920: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0c3280002930: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0c3280002940: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 =>0x0c3280002950:[fa]fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c3280002960: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c3280002970: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0c3280002980: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0c3280002990: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0c32800029a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 Shadow byte legend (one shadow byte represents 8 application bytes): Addressable: 00 Partially addressable: 01 02 03 04 05 06 07 Heap left redzone: fa Freed heap region: fd Stack left redzone: f1 Stack mid redzone: f2 Stack right redzone: f3 Stack after return: f5 Stack use after scope: f8 Global redzone: f9 Global init order: f6 Poisoned by user: f7 Container overflow: fc Array cookie: ac Intra object redzone: bb ASan internal: fe Left alloca redzone: ca Right alloca redzone: cb ==22340==ABORTING ... I've written an assert in rl_redisplay that formulates the error condition: ... @@ -1387,6 +1389,10 @@ rl_redisplay (void) cpos_adjusted = 0; + assert (last_lmargin + (_rl_screenwidth + visible_wrap_offset) + <= line_size); + assert (lmargin + (_rl_screenwidth + (lmargin ? 0 : wrap_offset)) + <= line_size); update_line (&visible_line[last_lmargin], &invisible_line[lmargin], 0, _rl_screenwidth + visible_wrap_offset, _rl_screenwidth + (lmargin ? 0 : wrap_offset), 0); ... which triggers without needing the address sanitizer (or even an executable), like this: ... $ TERM=dumb gdb -q -ex "set width 0" gdb: src/display.c:1393: rl_redisplay: Assertion `last_lmargin + (_rl_screenwidth + visible_wrap_offset) <= line_size' failed. Aborted (core dumped) ... The basic problem is this: visible_line and invisible_line have length line_size, but the update_line call assumes that line_size is at least _rl_screenwidth + 1. Executing "set width 0" sets _rl_screenwidth to 32766 but doesn't affect line_size, which is initialized to 1024. Fix this by ensuring in init_line_structures and rl_redisplay that line_size is at least _rl_screenwidth + 1. Tested on x86_64-linux. Reviewed by readline maintainer ( https://sourceware.org/ml/gdb-patches/2019-05/msg00566.html ). readline/ChangeLog.gdb: 2019-07-12 Tom de Vries <tdevries@suse.de> Chet Ramey <chet.ramey@case.edu> PR cli/24514 * readline/display.c (init_line_structures, rl_redisplay): Ensure line_size is at least _rl_screenwidth + 1.
2019-07-12Automatic date update in version.inGDB Administrator1-1/+1
2019-07-11gdb: Add command completers for some info commandsAndrew Burgess6-11/+64
Add command completion for info variables, functions, args, and locals. This completer only completes the command line options as these commands all take a regexp which GDB can't really offer completions for. gdb/ChangeLog: * cli/cli-utils.c (info_print_command_completer): New function. * cli/cli-utils.h: Add 'completer.h' include, and forward declaration for 'struct cmd_list_element'. (info_print_command_completer): Declare. * stack.c (_initialize_stack): Add completer for 'info locals' and 'info args'. * symtab.c (_initialize_symtab): Add completer for 'info variables' and 'info functions'. * NEWS: Mention completion for additional info commands.
2019-07-11gdb: Make use of gdb::option framework for some info commandsAndrew Burgess5-171/+99
Update the 'info variables', 'info functions', 'info locals', and 'info args' commands to make use of the gdb::options framework. There should be no user visible changes after this commit as I have left the help text generation using the existing mechanism, which already tries to customise the text for each of the commands. gdb/ChangeLog: * cli/cli-utils.c (extract_info_print_args): Delete. (extract_arg_maybe_quoted): Delete. (info_print_options_defs): New variable. (make_info_print_options_def_group): New function. (extract_info_print_options): Define new function. * cli/cli-utils.h (extract_info_print_args): Delete. (struct info_print_options): New structure. (extract_info_print_options): Declare new function. * stack.c (info_locals_command): Update to use new extract_info_print_options, also add a header comment. (info_args_command): Likewise. * symtab.c (info_variables_command): Likewise. (info_functions_command): Likewise.