Commit Graph

103521 Commits

Author SHA1 Message Date
Tom Tromey
f800b00e51 Add attribute::value_as_string method
The full DIE reader checks that an attribute has a "string" form in
some spots, but the partial DIE reader does not.  This patch brings
the two readers in sync for one specific case, namely when examining
the linkage name.  This avoids regressions in an existing DWARF test
case.

A full fix for this problem would be preferable.  An accessor like
DW_STRING should always check the form.  However, I haven't attempted
that in this series.

Also the fact that the partial and full readers can disagree like this
is a design flaw.

gdb/ChangeLog
2020-09-29  Tom Tromey  <tom@tromey.com>

	* dwarf2/read.c (partial_die_info::read) <case
	DW_AT_linkage_name>: Use value_as_string.
	(dwarf2_string_attr): Use value_as_string.
	* dwarf2/attribute.h (struct attribute) <value_as_string>: Declare
	method.
	* dwarf2/attribute.c (attribute::value_as_string): New method.
2020-09-29 20:29:06 -06:00
GDB Administrator
9dc318a3e5 Automatic date update in version.in 2020-09-30 00:00:06 +00:00
Pedro Alves
de38d64ad2 Tweak gdbsupport/valid-expr.h for GCC 6, fix build
With GCC 6.4 and 6.5 (at least), unit tests that use
gdbsupport/valid-expr.h's CHECK_VALID fail to compile, with:

 In file included from src/gdb/unittests/offset-type-selftests.c:24:0:
 src/gdb/unittests/offset-type-selftests.c: In substitution of 'template<class Expected, template<class ...> class Op, class ... Args> using is_detected_exact = std::is_same<Expected, typename gdb::detection_detail::detector<gdb::nonesuch, void, Op, Args ...>::type> [with Expected = selftests::offset_type::off_A&; Op = selftests::offset_type::check_valid_expr75::archetype; Args = {selftests::offset_type::off_A, selftests::offset_type::off_B}]':
 src/gdb/unittests/offset-type-selftests.c:75:1:   required from here
 src/gdb/../gdbsupport/valid-expr.h:65:20: error: type/value mismatch at argument 2 in template parameter list for 'template<class Expected, template<class ...> class Op, class ... Args> using is_detected_exact = std::is_same<Expected, typename gdb::detection_detail::detector<gdb::nonesuch, void, Op, Args ...>::type>'
     archetype, TYPES>::value == VALID,   \
		     ^

The important part is the "error: type/value mismatch" error.  Seems
like that GCC doesn't understand that archetype is an alias template,
and is being strict in requiring a template class.

The fix here is then to make archetype a template class, to pacify
GCC.  The resulting code looks like this:

  template <TYPENAMES, typename = decltype (EXPR)>
  struct archetype
  {
  };

  static_assert (gdb::is_detected_exact<archetype<TYPES, EXPR_TYPE>,
 		 archetype, TYPES>::value == VALID, "");

is_detected_exact<Expected, Op, Args> checks whether Op<Args> is type
Expected:

 - For Expected, we pass the explicit EXPR_TYPE, overriding the
   default parameter type of archetype.

 - For Args we don't pass the last template parameter, so archtype
   defaults to the EXPR's decltype.

So in essence, we're really checking whether EXPR_TYPE is the same as
decltype(EXPR).

We need to do the decltype in a template context in order to trigger
SFINAE instead of failing to compile.


The hunk in unittests/enum-flags-selftests.c becomes necessary,
because unlike with the current alias template version, this new
version makes GCC trigger -Wenum-compare warnings as well:

 src/gdb/unittests/enum-flags-selftests.c:328:33: error: comparison between 'enum selftests::enum_flags_tests::RE' and 'enum selftests::enum_flags_tests::RE2' [-Werror=enum-compare]
  CHECK_VALID (true,  bool, RE () != RE2 ())
				  ^
 src/gdb/../gdbsupport/valid-expr.h:61:45: note: in definition of macro 'CHECK_VALID_EXPR_INT'
    template <TYPENAMES, typename = decltype (EXPR)>   \
					      ^

Build-tested with:

 - GCC {4.8.5, 6.4, 6.5, 7.3.1, 9.3.0, 11.0.0-20200910}
 - Clang 10.0.0

gdbsupport/ChangeLog:

	* valid-expr.h (CHECK_VALID_EXPR_INT): Make archetype a template
	class instead of an alias template and adjust static_assert.

gdb/ChangeLog:

	* unittests/enum-flags-selftests.c: Check whether __GNUC__ is
	defined before using '#pragma GCC diagnostic' instead of checking
	__clang__.
2020-09-29 23:48:04 +01:00
Przemyslaw Wirkus
aeaccbf4c5 Add a note about recent changes to the AArch64 assembler: TRBE, ETE and ETMv4 system registers and Cortex-X1 enablement.
gas	* NEWS: TRBE, ETE, ETMv4 and Cortex-X1 news updates.
2020-09-29 16:43:57 +01:00
Mark Wielaard
1c9f770d16 binutils: dwarf.c handle DWARF5 DW_LLE_start_end and DW_LLE_start_length.
display_loclists_list only handled DW_LLE_offset_pair as bounded
location description. Also handle DW_LLE_start_end and DW_LLE_start_lenght.
These don't use the base_address.

binutils/ChangeLog:

      * dwarf.c (display_loclists_list): Handle DW_LLE_start_end and
      DW_LLE_start_length. Only add base_address for DW_LLE_offset_pair.
2020-09-29 14:08:51 +02:00
Tom Tromey
9aed480c3a Turn target_have_steppable_watchpoint into function
This changes the object-like macro target_have_steppable_watchpoint
into an inline function.

gdb/ChangeLog
2020-09-28  Tom Tromey  <tom@tromey.com>

	* infrun.c (displaced_step_fixup, thread_still_needs_step_over)
	(handle_signal_stop): Update.
	* procfs.c (procfs_target::insert_watchpoint): Update.
	* target.h (target_have_steppable_watchpoint): Now a function.
2020-09-28 19:52:21 -06:00
Tom Tromey
8a3ecb79b0 Turn target_can_lock_scheduler into a function
This changes the object-like macro target_can_lock_scheduler into an
inline function.

gdb/ChangeLog
2020-09-28  Tom Tromey  <tom@tromey.com>

	* infrun.c (set_schedlock_func): Update.
	* target.h (target_can_lock_scheduler): Now a function.
2020-09-28 19:52:21 -06:00
Tom Tromey
55f6301ac0 Remove target_has_execution macro
This removes the object-like macro target_has_execution, replacing it
with a function call.  target_has_execution_current is also now
handled by this function.

gdb/ChangeLog
2020-09-28  Tom Tromey  <tom@tromey.com>

	* inferior.h (class inferior) <has_execution>: Update.
	* windows-tdep.c (windows_solib_create_inferior_hook): Update.
	* valops.c (find_function_in_inferior)
	(value_allocate_space_in_inferior): Update.
	* top.c (kill_or_detach): Update.
	* target.c (target_preopen, set_target_permissions): Update.
	(target_has_execution_current): Remove.
	* sparc64-tdep.c (adi_examine_command, adi_assign_command):
	Update.
	* solib.c (update_solib_list, reload_shared_libraries): Update.
	* solib-svr4.c (svr4_solib_create_inferior_hook): Update.
	* solib-dsbt.c (enable_break): Update.
	* score-tdep.c (score7_fetch_inst): Update.
	* rs6000-nat.c (rs6000_nat_target::xfer_shared_libraries):
	Update.
	* remote.c (remote_target::start_remote)
	(remote_target::remote_check_symbols, remote_target::open_1)
	(remote_target::remote_detach_1, remote_target::verify_memory)
	(remote_target::xfer_partial, remote_target::read_description)
	(remote_target::get_min_fast_tracepoint_insn_len): Update.
	* record-full.c (record_full_open_1): Update.
	* record-btrace.c (record_btrace_target_open): Update.
	* objc-lang.c (lookup_objc_class, lookup_child_selector)
	(value_nsstring): Update.
	* linux-thread-db.c (add_thread_db_info)
	(thread_db_find_new_threads_silently, check_thread_db_callback)
	(try_thread_db_load_1, record_thread): Update.
	* linux-tdep.c (linux_info_proc, linux_vsyscall_range_raw):
	Update.
	* linux-fork.c (checkpoint_command): Update.
	* infrun.c (set_non_stop, set_observer_mode)
	(check_multi_target_resumption, for_each_just_stopped_thread)
	(maybe_remove_breakpoints, normal_stop)
	(class infcall_suspend_state): Update.
	* infcmd.c (ERROR_NO_INFERIOR, kill_if_already_running)
	(info_program_command, attach_command): Update.
	* infcall.c (call_function_by_hand_dummy): Update.
	* inf-loop.c (inferior_event_handler): Update.
	* gcore.c (gcore_command, derive_heap_segment): Update.
	* exec.c (exec_file_command): Update.
	* eval.c (evaluate_subexp): Update.
	* compile/compile.c (compile_to_object): Update.
	* cli/cli-dump.c (restore_command): Update.
	* breakpoint.c (update_watchpoint)
	(update_inserted_breakpoint_locations)
	(insert_breakpoint_locations, get_bpstat_thread): Update.
	* target.h (target_has_execution): Remove macro.
	(target_has_execution_current): Don't declare.
	(target_has_execution): Rename from target_has_execution_1.  Add
	argument default.
2020-09-28 19:52:21 -06:00
Tom Tromey
05374cfd90 Turn target_can_execute_reverse into function
This changes target_can_execute_reverse from an object-like macro to
an inline function.

gdb/ChangeLog
2020-09-28  Tom Tromey  <tom@tromey.com>

	* mi/mi-main.c (exec_reverse_continue)
	(mi_cmd_list_target_features): Update.
	* infrun.c (set_exec_direction_func): Update.
	* target.c (default_execution_direction): Update.
	* reverse.c (exec_reverse_once): Update.
	* target.h (target_can_execute_reverse): Now a function.
2020-09-28 19:52:21 -06:00
Tom Tromey
9dccd06e8a Remove target_has_registers macro
This removes the target_has_registers object-like macro, replacing it
with the underlying function.

gdb/ChangeLog
2020-09-28  Tom Tromey  <tom@tromey.com>

	* tui/tui-regs.c (tui_get_register)
	(tui_data_window::show_registers): Update.
	* thread.c (scoped_restore_current_thread::restore)
	(scoped_restore_current_thread::scoped_restore_current_thread):
	Update.
	* regcache-dump.c (regcache_print): Update.
	* python/py-finishbreakpoint.c (bpfinishpy_detect_out_scope_cb):
	Update.
	* mi/mi-main.c (mi_cmd_data_write_register_values): Update.
	* mep-tdep.c (current_me_module, current_options): Update.
	* linux-thread-db.c (thread_db_load): Update.
	* infcmd.c (registers_info, info_vector_command)
	(info_float_command): Update.
	* ia64-tdep.c (ia64_frame_prev_register)
	(ia64_sigtramp_frame_prev_register): Update.
	* ia64-libunwind-tdep.c (libunwind_frame_prev_register): Update.
	* gcore.c (derive_stack_segment): Update.
	* frame.c (get_current_frame, has_stack_frames): Update.
	* findvar.c (language_defn::read_var_value): Update.
	* arm-tdep.c (arm_pc_is_thumb): Update.
	* target.c (target_has_registers): Rename from
	target_has_registers_1.
	* target.h (target_has_registers): Remove macro.
	(target_has_registers): Rename from target_has_registers_1.
2020-09-28 19:52:21 -06:00
Tom Tromey
841de12014 Remove target_has_stack macro
This removes the target_has_stack object-like macro, replacing it with
the underlying function.

gdb/ChangeLog
2020-09-28  Tom Tromey  <tom@tromey.com>

	* windows-tdep.c (tlb_make_value): Update.
	* tui/tui-regs.c (tui_data_window::show_registers): Update.
	* thread.c (scoped_restore_current_thread::restore)
	(scoped_restore_current_thread::scoped_restore_current_thread)
	(thread_command): Update.
	* stack.c (backtrace_command_1, frame_apply_level_command)
	(frame_apply_all_command, frame_apply_command): Update.
	* infrun.c (siginfo_make_value, restore_infcall_control_state):
	Update.
	* gcore.c (derive_stack_segment): Update.
	* frame.c (get_current_frame, has_stack_frames): Update.
	* auxv.c (info_auxv_command): Update.
	* ada-tasks.c (ada_build_task_list): Update.
	* target.c (target_has_stack): Rename from target_has_stack_1.
	* target.h (target_has_stack): Remove macro.
	(target_has_stack): Rename from target_has_stack_1.
2020-09-28 19:52:21 -06:00
Tom Tromey
a739972c7c Remove target_has_memory macro
This removes the target_has_memory object-like macro, replacing it
with the underlying function.

gdb/ChangeLog
2020-09-28  Tom Tromey  <tom@tromey.com>

	* target.c (target_has_memory): Rename from target_has_memory_1.
	* tui/tui-regs.c (tui_data_window::show_registers): Update.
	* thread.c (scoped_restore_current_thread::restore)
	(scoped_restore_current_thread::scoped_restore_current_thread):
	Update.
	* frame.c (get_current_frame, has_stack_frames): Update.
	* target.h (target_has_memory): Remove macro.
	(target_has_memory): Rename from target_has_memory_1.
2020-09-28 19:52:21 -06:00
Tom Tromey
5b8a477608 Remove target_has_all_memory
target_has_all_memory isn't used anywhere, so this patch removes it.

gdb/ChangeLog
2020-09-28  Tom Tromey  <tom@tromey.com>

	* target.c (target_has_all_memory_1): Remove.
	* target.h (target_has_all_memory): Remove define.
	(target_has_all_memory_1): Don't declare.
2020-09-28 19:52:21 -06:00
GDB Administrator
2714a459f8 Automatic date update in version.in 2020-09-29 00:00:07 +00:00
Simon Marchi
bd356ec6c0 gdb: fix formatting of serial::async_state's enumerators
The comments related to these enumerators are placed under the
corresponding enumerator.  This is quite unusual and confusing.  Change
it to have the comments above, as usual.

gdb/ChangeLog:

	* ser-base.c: Adjust comments formatting.

Change-Id: If2ea143a7d5217efa5ac088102ddb1933fbcb16a
2020-09-28 14:21:24 -04:00
Przemyslaw Wirkus
394e9bf642 This patch adds support for Cortex-X1 for ARM.
bfd	* cpu-arm.c: (processors) Add Cortex-X1.

gas	* config/tc-arm.c: (arm_cpus): Add Cortex-X1.
	* doc/c-arm.texi: Document -mcpu=cortex-x1.
	* testsuite/gas/arm/cpu-cortex-x1.d: New test.
2020-09-28 15:52:24 +01:00
Przemyslaw Wirkus
12e35da62f This patch introduces ETMv4 (Embedded Trace Macrocell) system registers for the AArch64 architecture.
gas           * testsuite/gas/aarch64/etm-ro-invalid.d: New test.
              * testsuite/gas/aarch64/etm-ro-invalid.l: New test.
              * testsuite/gas/aarch64/etm-ro-invalid.s: New test.
              * testsuite/gas/aarch64/etm-ro.s: New test.
              * testsuite/gas/aarch64/etm-wo-invalid.d: New test.
              * testsuite/gas/aarch64/etm-wo-invalid.l: New test.
              * testsuite/gas/aarch64/etm-wo-invalid.s: New test.
              * testsuite/gas/aarch64/etm-wo.s: New test.
              * testsuite/gas/aarch64/etm.s: New test.
              * testsuite/gas/aarch64/sysreg.d: system register s2_1_c0_c3_0 disassembled
              now to trcstatr.

opcodes       * aarch64-opc.c: Added ETMv4 system registers TRCACATRn, TRCACVRn,
              TRCAUTHSTATUS, TRCAUXCTLR, TRCBBCTLR, TRCCCCTLR, TRCCIDCCTLR0, TRCCIDCCTLR1,
              TRCCIDCVRn, TRCCIDR0, TRCCIDR1, TRCCIDR2, TRCCIDR3, TRCCLAIMCLR, TRCCLAIMSET,
              TRCCNTCTLRn, TRCCNTRLDVRn, TRCCNTVRn, TRCCONFIGR, TRCDEVAFF0, TRCDEVAFF1,
              TRCDEVARCH, TRCDEVID, TRCDEVTYPE, TRCDVCMRn, TRCDVCVRn, TRCEVENTCTL0R,
              TRCEVENTCTL1R, TRCEXTINSELR, TRCIDR0, TRCIDR1, TRCIDR2, TRCIDR3, TRCIDR4,
              TRCIDR5, TRCIDR6, TRCIDR7, TRCIDR8, TRCIDR9, TRCIDR10, TRCIDR11, TRCIDR12,
              TRCIDR13, TRCIMSPEC0, TRCIMSPECn, TRCITCTRL, TRCLAR WOTRCLSR, TRCOSLAR
              WOTRCOSLSR, TRCPDCR, TRCPDSR, TRCPIDR0, TRCPIDR1, TRCPIDR2, TRCPIDR3,
              TRCPIDR4, TRCPIDR[5,6,7], TRCPRGCTLR, TRCP,CSELR, TRCQCTLR, TRCRSCTLRn,
              TRCSEQEVRn, TRCSEQRSTEVR, TRCSEQSTR, TRCSSCCRn, TRCSSCSRn, TRCSSPCICRn,
              TRCSTALLCTLR, TRCSTATR, TRCSYNCPR, TRCTRACEIDR,  TRCTSCTLR, TRCVDARCCTLR,
              TRCVDCTLR, TRCVDSACCTLR, TRCVICTLR, TRCVIIECTLR, TRCVIPCSSCTLR, TRCVISSCTLR,
              TRCVMIDCCTLR0, TRCVMIDCCTLR1 and TRCVMIDCVRn.
2020-09-28 15:49:11 +01:00
Przemyslaw Wirkus
47e1f9deaa This patch adds support for Cortex-X1
gas	* config/tc-aarch64.c: (aarch64_cpus): Add Cortex-X1.
	* doc/c-aarch64.texi: Document -mcpu=cortex-x1.
2020-09-28 15:43:51 +01:00
Przemyslaw Wirkus
3454861d89 This patch introduces ETE (Embedded Trace Extension) system registers for the AArch64 architecture.
gas           * testsuite/gas/aarch64/ete.d: New test.
              * testsuite/gas/aarch64/ete.s: New test.

opcodes       * aarch64-opc.c: Add ETE system registers TRCEXTINSELR<0-3> and TRCRSR.
2020-09-28 15:41:23 +01:00
Przemyslaw Wirkus
1ff8e40105 This patch introduces TRBE (Trace Buffer Extension) system registers for the AArch64 architecture.
gas           * testsuite/gas/aarch64/trbe-invalid.d: New test.
              * testsuite/gas/aarch64/trbe-invalid.l: New test.
              * testsuite/gas/aarch64/trbe-invalid.s: New test.
              * testsuite/gas/aarch64/trbe.d: New test.
              * testsuite/gas/aarch64/trbe.s: New test.

opcodes       * aarch64-opc.c: Add TRBE system registers TRBIDR_EL1 , TRBBASER_EL1 ,
              TRBLIMITR_EL1 , TRBMAR_EL1 , TRBPTR_EL1, TRBSR_EL1 and TRBTRG_EL1.
2020-09-28 15:37:50 +01:00
Alex Coplan
9bede61ce5 arm: Add missing Neoverse V1 feature
This simple follow-on patch adds a feature bit (FP16) that was missing
from the initial Neoverse V1 support.

gas/ChangeLog:

	* config/tc-arm.c (arm_cpus): Add FP16 to Neoverse V1.
2020-09-28 13:57:09 +01:00
Alex Coplan
c769fd6a32 aarch64: Neoverse V1 tweaks
This simple follow-on patch groups the Neoverse cores together and adds
a missing feature bit (F16) to the entry for Neoverse V1.

gas/ChangeLog:

	* config/tc-aarch64.c (aarch64_cpus): Group Neoverse cores
	together, add missing F16 bit to Neoverse V1.
2020-09-28 13:55:08 +01:00
Alan Modra
f243e458cd PR26656 testcases
* testsuite/ld-powerpc/tlsget.d,
	* testsuite/ld-powerpc/tlsget.s,
	* testsuite/ld-powerpc/tlsget.wf,
	* testsuite/ld-powerpc/tlsget2.d.
	* testsuite/ld-powerpc/tlsget2.wf: New testcases.
	* testsuite/ld-powerpc/powerpc.exp: Run them.
2020-09-28 19:36:35 +09:30
Tom Tromey
2c72d5e58a Rewrite tui_puts
This rewrites tui_puts.  It now writes as many bytes as possible in a
call to waddnstr, letting curses handle multi-byte sequences properly.

Note that tui_puts_internal remains.  It is needed to handle computing
the start line of the readline prompt, which is difficult to do
properly in the case where redisplaying can also cause the command
window to scroll.  This might be possible to implement by reverting to
single "character" output, by using mbsrtowcs for its side effects to
find character boundaries in the input.  I have not attempted this.

gdb/ChangeLog
2020-09-27  Tom Tromey  <tom@tromey.com>

	PR tui/25342:
	* tui/tui-io.c (tui_puts): Rewrite.  Move earlier.
2020-09-27 20:30:33 -06:00
Tom Tromey
35a982372f Use ISCNTRL in tui_copy_source_line
This changes tui_copy_source_line to use ISCNTRL.  This lets it work
more nicely with UTF-8 input.  Note that this still won't work for
stateful multi-byte encodings; for that much more work would be
required.  However, I think this patch does not make gdb any worse in
this scenario.

gdb/ChangeLog
2020-09-27  Tom Tromey  <tom@tromey.com>

	PR tui/25342:
	* tui/tui-winsource.c (tui_copy_source_line): Use ISNCTRL.
2020-09-27 20:30:32 -06:00
Tom Tromey
9e820dec13 Use a curses pad for source and disassembly windows
This changes the TUI source and disassembly windows to use a curses
pad for their text.  This is an important step toward properly
handling non-ASCII characters, because it makes it easy to scroll
horizontally without needing gdb to also understand multi-byte
character boundaries -- this can be wholly delegated to curses.
Horizontal scrolling is probably also faster now, because no
re-rendering is required.

gdb/ChangeLog
2020-09-27  Tom Tromey  <tom@tromey.com>

	* unittests/tui-selftests.c: Update.
	* tui/tui-winsource.h (struct tui_source_window_base)
	<extra_margin, show_line_number, refresh_pad>: New methods.
	<m_max_length, m_pad>: New members.
	(tui_copy_source_line): Update.
	* tui/tui-winsource.c (tui_copy_source_line): Remove line_no,
	first_col, line_width, ndigits parameters.  Add length.
	(tui_source_window_base::show_source_line): Write to pad.  Line
	number now 0-based.
	(tui_source_window_base::refresh_pad): New method.
	(tui_source_window_base::show_source_content): Write to pad.  Call
	refresh_pad.
	(tui_source_window_base::do_scroll_horizontal): Call refresh_pad,
	not refill.
	(tui_source_window_base::update_exec_info): Call
	show_line_number.
	* tui/tui-source.h (struct tui_source_window) <extra_margin>: New
	method.
	<m_digits>: New member.
	* tui/tui-source.c (tui_source_window::set_contents): Set m_digits
	and m_max_length.
	(tui_source_window::show_line_number): New method.
	* tui/tui-io.h (tui_puts): Fix comment.
	* tui/tui-disasm.c (tui_disasm_window::set_contents): Set
	m_max_length.
2020-09-27 20:30:32 -06:00
Tom Tromey
c15c15c8d9 Remove a call to show_source_line from TUI
This removes a call to show_source_line from tui_source_window_base.
This call isn't needed because this function already calls the
'refill' method if the state changed.

gdb/ChangeLog
2020-09-27  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.c
	(tui_source_window_base::set_is_exec_point_at): Don't call
	show_source_line.
2020-09-27 20:30:31 -06:00
Tom Tromey
149830c137 Use an inner window in tui_py_window
This changes tui_py_window to create an inner curses window.  This
greatly simplifies tui_py_window::output, beacuse it no longer needs
to be careful to avoid overwriting the window's border.  This patch
also makes it a bit easier for a later patch to rewrite
tui_copy_source_line.

gdb/ChangeLog
2020-09-27  Tom Tromey  <tom@tromey.com>

	* python/py-tui.c (class tui_py_window) <refresh_window>: New
	method.
	<erase>: Update.
	<cursor_x, cursor_y>: Remove.
	<m_inner_window>: New member.
	(tui_py_window::rerender): Create inner window.
	(tui_py_window::output): Write to inner window.
2020-09-27 20:30:31 -06:00
Tom Tromey
5f278258cc Remove test duplicate from gdb.tui
I noticed a duplicated test in gdb.tui.  This patch removes it by
wrapping a test in with_test_prefix.

gdb/testsuite/ChangeLog
2020-09-27  Tom Tromey  <tom@tromey.com>

	* gdb.tui/new-layout.exp: Use with_test_prefix.
2020-09-27 20:30:30 -06:00
Alan Modra
12cf8b93da Re: PR26656, power10 libstdc++.so segfault in __cxxabiv1::__cxa_throw
Some missing NULL checks meant a stub for a local symbol used a stub
looking like the __tls_get_addr_opt stub.

	PR 26656
	* elf64-ppc.c (ppc_build_one_stub, ppc_size_one_stub): Check for
	NULL stub_entry->h before calling is_tls_get_addr.
2020-09-28 09:35:20 +09:30
GDB Administrator
5ecafd7020 Automatic date update in version.in 2020-09-28 00:00:07 +00:00
GDB Administrator
31f327a6c8 Automatic date update in version.in 2020-09-27 00:00:06 +00:00
Gareth Rees
8f9929bb97 gdb: Fix from_tty argument to gdb.execute in Python.
Prior to commit 56bcdbea2b, the from_tty keyword argument to the
Python function gdb.execute controlled whether the command took input
from the terminal. When from_tty=True, "starti" and similar commands
prompted the user:

    (gdb) python gdb.execute("starti", from_tty=True)
    The program being debugged has been started already.
    Start it from the beginning? (y or n) y
    Starting program: /bin/true

    Program stopped.

When from_tty=False, these commands did not prompt the user, and "yes"
was assumed:

    (gdb) python gdb.execute("starti", from_tty=False)

    Program stopped.

However, after commit 56bcdbea2b, the from_tty keyword argument no
longer had this effect. For example, as of commit 7ade7fba75:

    (gdb) python gdb.execute("starti", from_tty=True)
    The program being debugged has been started already.
    Start it from the beginning? (y or n) [answered Y; input not from terminal]
    Starting program: /bin/true

    Program stopped.

Note the "[answered Y; input not from terminal]" in the output even
though from_tty=True was requested.

Looking at commit 56bcdbea2b, it seems that the behaviour of the
from_tty argument was changed accidentally. The commit message said:

    Let gdb.execute handle multi-line commands

    This changes the Python API so that gdb.execute can now handle
    multi-line commands, like "commands" or "define".

and there was no mention of changing the effect of the from_tty
argument. It looks as though the code for setting the instream to
nullptr was accidentally moved from execute_user_command() to
execute_control_commands() along with the other scoped restores.

Accordingly, the simplest way to fix this is to partially reverse
commit 56bcdbea2b by moving the code for setting the instream to
nullptr back to execute_user_command() where it was to begin with.

Additionally, add a test case to reduce the risk of similar breakage
in future.

gdb/ChangeLog:

	PR python/26586
	* cli/cli-script.c (execute_control_commands): don't set
	instream to nullptr here as this breaks the from_tty argument
	to gdb.execute in Python.
	(execute_user_command): set instream to nullptr here instead.

gdb/testsuite/ChangeLog:

	PR python/26586
	* gdb.python/python.exp: add test cases for the from_tty
	argument to gdb.execute.
2020-09-26 11:01:45 -07:00
Alan Modra
63e5eea234 [GOLD] PPC64_OPT_LOCALENTRY is incompatible with tail calls
Gold version of commit 3cd7c7d7ef.

	* powerpc.cc (Target_powerpc): Rename power10_stubs_ to
	power10_relocs_.
	(Target_powerpc::set_power10_relocs): New accessor.
	(Target_powerpc::set_power10_stubs): Delete.
	(Target_powerpc::power10_stubs): Adjust.
	(Target_powerpc::has_localentry0): New accessor.
	(ld_0_11): New constant.
	(glink_eh_frame_fde_64v1, glink_eh_frame_fde_64v2): Adjust.
	(glink_eh_frame_fde_64v2_localentry0): New.
	(Output_data_glink::pltresolve_size): Update.
	(Output_data_glink::add_eh_frame): Use localentry0 version eh_frame.
	(Output_data_glink::do_write): Move r2 save to start of ELFv2 stub
	and only emit for has_localentry0.  Don't use r2 in the stub.
	(Target_powerpc::Scan::local, global): Adjust for
	set_power10_relocs renaming.
	(Target_powerpc::scan_relocs): Warn and reset plt_localentry0_.
2020-09-26 20:34:55 +09:30
Alan Modra
3cd7c7d7ef PPC64_OPT_LOCALENTRY is incompatible with tail calls
The save of r2 in __glink_PLTresolve is the culprit.  Remove it,
unless we know we need it for --plt-localentry.  --plt-localentry
should not be used with power10 pc-relative code that makes tail
calls.

The patch also removes use of r2 as a scratch reg in the ELFv2
__glink_PLTresolve.  Using r2 isn't a problem, this is just reducing
the number of scratch regs.

bfd/
	* elf64-ppc.c (GLINK_PLTRESOLVE_SIZE): Depend on has_plt_localentry0.
	(LD_R0_0R11, ADD_R11_R0_R11): Define.
	(ppc64_elf_tls_setup): Disable params->plt_localentry0 when power10
	code detected.
	(ppc64_elf_size_stubs): Update __glink_PLTresolve eh_frame.
	(ppc64_elf_build_stubs): Move r2 save to start of __glink_PLTresolve,
	and only emit for has_plt_localentry0.  Don't use r2 in the stub.
ld/
	* testsuite/ld-powerpc/elfv2so.d,
	* testsuite/ld-powerpc/notoc2.d,
	* testsuite/ld-powerpc/tlsdesc.wf,
	* testsuite/ld-powerpc/tlsdesc2.d,
	* testsuite/ld-powerpc/tlsdesc2.wf,
	* testsuite/ld-powerpc/tlsopt5.d,
	* testsuite/ld-powerpc/tlsopt5.wf,
	* testsuite/ld-powerpc/tlsopt6.d,
	* testsuite/ld-powerpc/tlsopt6.wf: Update __glink_PLTresolve.
2020-09-26 19:03:02 +09:30
Alan Modra
0be2fe677c ubsan: opcodes/csky-opc.h:929 shift exponent 536870912
opcodes/
	* csky-opc.h: Formatting.
	(GENERAL_REG_BANK): Correct spelling.  Update use throughout file.
	(get_register_name): Mask arch with CSKY_ARCH_MASK for shift,
	and shift 1u.
	(get_register_number): Likewise.
	* csky-dis.c (get_gr_name, get_cr_name): Don't mask mach_flag.
gas/
	* config/tc-csky.c (parse_type_ctrlreg): Don't mask mach_flag
	for csky_get_control_regno.
	(csky_get_reg_val): Likewise when calling csky_get_general_regno.
2020-09-26 15:28:22 +09:30
GDB Administrator
0919fa3c46 Automatic date update in version.in 2020-09-26 00:00:06 +00:00
Simon Marchi
956bdb595b gdb: fix formatting of _debug_printf macros
The do/while in these macros are not formatted with proper GNU style,
fix that.

gdb/ChangeLog:

	* infrun.h (infrun_debug_printf): Fix formatting.
	* linux-nat.c (linux_nat_debug_printf): Fix formatting.

Change-Id: I3a723663c76d9091f785941923c2b6cf67459629
2020-09-25 14:54:16 -04:00
Saagar Jha
3b93626be9 Add a missing munmap_list move constructor
compile_module attempts to request a move constructor, but because
munmap_list doesn't have one it gets implicitly deleted. This is an
warning on clang under -Wdefaulted-function-deleted (which is enabled by
default):

In file included from compile/compile-object-load.c:21:
compile/compile-object-load.h:56:3: error: explicitly defaulted move constructor is implicitly deleted [-Werror,-Wdefaulted-function-deleted]
  compile_module (compile_module &&other) = default;
  ^
compile/compile-object-load.h:86:22: note: move constructor of 'compile_module' is implicitly deleted because field 'munmap_list' has a deleted move constructor
  struct munmap_list munmap_list;
                     ^
compile/compile-object-load.h:30:28: note: 'munmap_list' has been explicitly marked deleted here
  DISABLE_COPY_AND_ASSIGN (munmap_list);
                           ^

gdb/ChangeLog:

	* compile/compile-object-load.h: Give munmap_list a move
	constructor.

Change-Id: I300c52e27da70087f18c7e359773c2b984073d8b
2020-09-25 10:57:06 -04:00
Simon Marchi
ee1b8b9477 Import mklog.py from gcc repo
I've been using the mklog utility from the gcc repo for a while to
generate skeleton of ChangeLog entries.  It recently got a rewrite as a
Python script.  Unfortunately, to find the repository root, and
eventually to find in which ChangeLog file each entry goes, the new
script assumes it is located in the same git repository that it
generates ChangeLog entries for.

This means that if you make a change in the gcc source tree and run
mklog.py from that same source tree, it works.  But if you make changes
in your ~/src/binutils-gdb tree and run ~/src/gcc/contrib/mklog.py, it
won't work.

IIRC, the old script required that you ran it with the project's root
directory as the CWD.

The simplest way to fix this is to import the script in binutils-gdb and
use it from there.  It's also nice because we can use it without having
a clone of the gcc repo.

I also thought of adding a "--root" switch to the script to override the
project's base directory.  However:

1) It is more work.
2) If the script still lives in the gcc repo, it's less convenient than
   having it in binutils-gdb.

This patch imports contrib/mklog.py from the gcc repo, revision
c560591408440f441b8b327f5b41f9328d20b67b.

contrib/ChangeLog:

	* mklog.py: New file, imported from gcc.

Note: the ChangeLog entry above was generated using
`git show | ./mklog.py`!

Change-Id: I955592ce6397681986dc82a09593c32d8b8de54f
2020-09-25 10:24:44 -04:00
Simon Marchi
e851246a2a gdb: fix whitespaces in ChangeLog
Change-Id: Ie5accb8915341cf9b4ed23162f9503d7ef947fcf
2020-09-25 10:20:32 -04:00
Gary Benson
c20c017b2c Fix gdb.base/infcall-nested-structs-c++.exp with Clang
gdb.base/infcall-nested-structs-c++.exp failed to build using Clang
with many variations on the following error:

  gdb compile failed, /gdbtest/src/gdb/testsuite/gdb.base/infcall-nested-structs.c:207:46:
    warning: self-comparison always evaluates to true [-Wtautological-compare]

This commit builds this testcase with -Wno-tautological-compare when
using Clang, to avoid this failure.

gdb/testsuite/ChangeLog:

	* gdb.base/infcall-nested-structs.exp.tcl: Add
	additional_flags=-Wno-tautological-compare for C++
	tests when compiling using Clang.
2020-09-25 14:44:07 +01:00
Gary Benson
68d654afdf Fix compilation of .c files as C++ when using Clang
In commit 221db974e6, this patch:

    2020-06-24  Pedro Alves  <palves@redhat.com>

    * lib/gdb.exp (gdb_compile): Pass "-x c++" explicitly when
    compiling C++ programs.

attempted to fix problems with testcases that compile .c files
with the C++ compiler.  They pass the "c++" option to gdb_compile,
resulting in the following error when using Clang:

    gdb compile failed, clang-10: warning: treating 'c' input as 'c++'
    when in C++ mode, this behavior is deprecated [-Wdeprecated]

This fix did not work for gdb.base/infcall-nested-structs-c++.exp,
however: the "-x c++" appeared in the compiler's commandline after
the .c file, so the option was not enabled for that file.

The previous files fixed all used build_executable_from_specs, which
compiles and links in separate steps, using gdb_compile: the compile
step passes $type=object to gdb_compile, while the link step passes
$type=executable.

gdb.base/infcall-nested-structs-c++.exp uses gdb_compile directly
instead, and it passes $type=executable to compile and link all in
one step.  Pedro found that DejaGnu's default_target_compile adds
the sources at the end when $type=object, but at the beginning when
$type=executable:

    # This is obscure: we put SOURCES at the end when building an
    # object, because otherwise, in some situations, libtool will
    # become confused about the name of the actual source file.
    if {$type == "object"} {
        set opts "$add_flags $sources"
    } else {
        set opts "$sources $add_flags"
    }

This commit moves the "-x c++" earlier in the compiler's commandline.
Unfortunately this then broke the testcase that required the original
fix, gdb.compile/compile-cplus.exp: the "-x c++" was being parsed for
the linker pass, causing the compiler to attempt to parse the .o files
as C++.  This commit makes passing "-x c++" conditional on the source
being a .c file.

gdb/testsuite/ChangeLog:

	* lib/gdb.exp (gdb_compile): Pass "-x c++" earlier, and only
	for .c files.
2020-09-25 14:29:35 +01:00
Alan Modra
5a805384b8 asan: readelf buffer overflow and abort
* elfcomm.c (byte_put_little_endian, byte_put_big_endian): Support
	more field sizes.
	* readelf.c (target_specific_reloc_handling <MSP430>): Limit
	allowed reloc_size.  Don't read_leb128 outside of section.
2020-09-25 11:55:01 +09:30
Alan Modra
cc9ea2c21c Re: Sync libiberty and include with GCC for get_DW_UT_name
* dwarf.h (DW_FIRST_UT, DW_UT, DW_END_UT): Define.
2020-09-25 11:55:00 +09:30
Cui,Lili
09d7303523 Put together MOD_VEX_0F38* in i386-dis.c,
There are 11 MOD_VEX_0F38* inserted in MOD_0F38* group,
which should be placed in MOD_VEX_0F38* group.

opcode/
	PR 26654
	*i386-dis.c (enum): Put MOD_VEX_0F38* together.
2020-09-25 09:39:00 +08:00
GDB Administrator
bee4644aff Automatic date update in version.in 2020-09-25 00:00:09 +00:00
Jim Wilson
743f5cfc00 RISC-V: Error for relaxable branch in absolute section.
Emit an error instead of crashing in frag_new, handling this same as the
i386 port.

gas/
	PR 26400
	* config/tc-riscv.c (append_insn): If in absolute section, emit
	error before add_relaxed_insn call.
	* testsuite/gas/riscv/absolute-sec.d: New.
	* testsuite/gas/riscv/absolute-sec.l: New.
	* testsuite/gas/riscv/absolute-sec.s: New.
2020-09-24 15:16:54 -07:00
Mark Wielaard
debd1a62c4 readelf: Show Unit Type for DWARF5
binutils/ChangeLog:

	* dwarf.c (process_debug_info): Print Unit Type for DWARF5.
	* testsuite/binutils-all/dw5.W: Adjust expected output.
	* testsuite/binutils-all/dwarf-attributes.W: Likewise.

gas/ChangeLog:

	* testsuite/gas/elf/dwarf-5-cu.d: Adjust expected output.
2020-09-24 23:13:13 +02:00
Mark Wielaard
d7b477c541 Sync libiberty and include with GCC for get_DW_UT_name.
This adds a get_DW_UT_name function to dwarfnames using dwarf2.def
for use in binutils readelf to show the unit types in a DWARF5 header.

include/ChangeLog:

	Sync with GCC
	* dwarf2.def: Add DWARF5 Unit type header encoding macros
	DW_UT_FIRST, DW_UT and DW_UT_END.
	* dwarf2.h (enum dwarf_unit_type): Removed and define using
	DW_UT_FIRST, DW_UT and DW_UT_END macros.
	(get_DW_UT_name): New function declaration.

libiberty/ChangeLog:

	Sync with GCC
	* dwarfnames.c (get_DW_UT_name): Define using DW_UT_FIRST, DW_UT
	and DW_UT_END.
2020-09-24 22:55:24 +02:00