aboutsummaryrefslogtreecommitdiff
path: root/gdb
AgeCommit message (Collapse)AuthorFilesLines
2020-09-29Remove DW_UNSNDTom Tromey3-89/+102
This removes DW_UNSND, replacing uses with either as_unsigned or constant_value, depending primarily on whether or not the form is already known to be appropriate. gdb/ChangeLog 2020-09-29 Tom Tromey <tom@tromey.com> * dwarf2/read.c (lookup_dwo_id, get_type_unit_group) (read_file_scope, dwarf2_get_pc_bounds) (dwarf2_record_block_ranges, dwarf2_add_field, get_alignment) (read_structure_type, handle_struct_member_die) (read_enumeration_type, read_array_type, read_set_type) (read_tag_pointer_type, read_tag_reference_type) (read_subroutine_type, read_base_type, read_subrange_type) (read_full_die_1, partial_die_info::read) (partial_die_info::read, by, new_symbol) (dwarf2_const_value_data, dwarf2_const_value_attr) (dump_die_shallow, dwarf2_fetch_constant_bytes) (prepare_one_comp_unit): Update. * dwarf2/attribute.h (DW_UNSND): Remove.
2020-09-29Add attribute::as_boolean methodTom Tromey4-15/+40
This adds a new attribute::as_boolean method, and updates the reader to use it. The main benefit of this change is that now the code will respect the attribute's form. gdb/ChangeLog 2020-09-29 Tom Tromey <tom@tromey.com> * dwarf2/read.c (read_func_scope, prototyped_function_p) (read_subroutine_type, partial_die_info::read) (dwarf2_flag_true_p, new_symbol, dump_die_shallow) (dwarf2_add_member_fn): Update. * dwarf2/attribute.h (struct attribute) <as_boolean>: Declare. * dwarf2/attribute.c (attribute::as_boolean): New method.
2020-09-29Add attribute::as_virtuality methodTom Tromey4-2/+37
This adds a new attribute::as_virtuality method and changes the DWARF reader to use it. This also ensures that the attibute's form will now be respected. gdb/ChangeLog 2020-09-29 Tom Tromey <tom@tromey.com> * dwarf2/read.c (dwarf2_add_field, dwarf2_add_member_fn): Update. * dwarf2/attribute.h (struct attribute) <as_virtuality>: New method. * dwarf2/attribute.c (attribute::as_virtuality): New method.
2020-09-29Change die_info methods to check the attribute's formTom Tromey2-5/+22
This changes two die_info methods to check the form of the attribute before using it. gdb/ChangeLog 2020-09-29 Tom Tromey <tom@tromey.com> * dwarf2/die.h (struct die_info) <addr_base, ranges_base>: Check the attribute's form.
2020-09-29Change is_valid_DW_AT_defaulted to a method on attributeTom Tromey4-21/+40
This changes is_valid_DW_AT_defaulted to be a method on struct attribute. Now it correctly respects the form of the attribute. gdb/ChangeLog 2020-09-29 Tom Tromey <tom@tromey.com> * dwarf2/read.c (is_valid_DW_AT_defaulted): Move to attribute.c. (dwarf2_add_member_fn): Update. * dwarf2/attribute.h (struct attribute) <defaulted>: Declare. * dwarf2/attribute.c (attribute::defaulted): New method, from is_valid_DW_AT_defaulted.
2020-09-29Add attribute::as_unsigned methodTom Tromey3-12/+31
This introduces a new attribute::as_unsigned method and changes a few spots to use it. gdb/ChangeLog 2020-09-29 Tom Tromey <tom@tromey.com> * dwarf2/read.c (dw2_get_file_names_reader) (dwarf2_build_include_psymtabs, handle_DW_AT_stmt_list) (dwarf2_cu::setup_type_unit_groups, fill_in_loclist_baton) (dwarf2_symbol_mark_computed): Use as_unsigned. * dwarf2/attribute.h (struct attribute) <as_unsigned>: New method. <form_is_section_offset>: Update comment.
2020-09-29Change how accessibility is handled in dwarf2/read.cTom Tromey2-22/+26
dwarf2/read.c uses dwarf2_default_access_attribute to check for the default access attribute. This patch simplifies the code by moving more of the access processing into this function, changing its name to reflect the difference. This also ensures that the attribute's form is respected, by changing to code to use the constant_value method. gdb/ChangeLog 2020-09-29 Tom Tromey <tom@tromey.com> * dwarf2/read.c (dwarf2_access_attribute): Rename from dwarf2_default_access_attribute. Look up attribute. (dwarf2_add_field, dwarf2_add_type_defn, dwarf2_add_member_fn): Update.
2020-09-29Change how reprocessing is doneTom Tromey3-32/+47
Currently gdb keeps a vector of attributes that require reprocessing. However, now that there is a reprocessing flag in the attribute, we can remove the vector and instead simply loop over attributes a second time. Normally there are not many attributes, so this should be reasonably cheap. gdb/ChangeLog 2020-09-29 Tom Tromey <tom@tromey.com> * dwarf2/read.c (skip_one_die): Update. (read_full_die_1): Change how reprocessing is done. (partial_die_info::read): Update. (read_attribute_value): Remove need_reprocess parameter. (read_attribute): Likewise. * dwarf2/attribute.h (struct attribute) <requires_reprocessing_p>: New method.
2020-09-29Remove DW_ADDRTom Tromey4-9/+37
This removes DW_ADDR in favor of accessor methods. gdb/ChangeLog 2020-09-29 Tom Tromey <tom@tromey.com> * dwarf2/read.c (read_attribute_reprocess, read_attribute_value) (dwarf2_const_value_attr, dump_die_shallow) (dwarf2_fetch_constant_bytes): Update. * dwarf2/attribute.h (struct attribute) <form_is_ref>: Update comment. <set_address>: New method. (DW_ADDR): Remove. * dwarf2/attribute.c (attribute::form_is_ref): Update comment. (attribute::as_string, attribute::as_address): Add assert.
2020-09-29Add reprocessing flag to struct attributeTom Tromey4-6/+71
Some forms require "reprocessing" -- a second pass to update their value appropriately. In this case, we'll set the unsigned value on the attribute, and then later set it to the correct value. To handle this, we introduce a reprocessing flag to attribute. Then, we manage this flag to ensure that setting and unsetting is done properly. gdb/ChangeLog 2020-09-29 Tom Tromey <tom@tromey.com> * dwarf2/read.c (read_cutu_die_from_dwo): Use OBSTACK_ZALLOC. (read_attribute_reprocess, read_attribute_value): Update. (read_attribute): Clear requires_reprocessing. * dwarf2/attribute.h (struct attribute) <as_unsigned_reprocess, form_requires_reprocessing>: New methods. <string_init>: Clear requires_reprocessing. <set_unsigned_reprocess>: New method. <name>: Shrink by one bit. <requires_reprocessing>: New member. * dwarf2/attribute.c (attribute::form_requires_reprocessing): New method.
2020-09-29Use setter for attribute's unsigned valueTom Tromey4-26/+66
This adds form_is_unsigned and an unsigned setter method to struct attribute, and updates the remaining code. Now DW_UNSND is no longer used as an lvalue. gdb/ChangeLog 2020-09-29 Tom Tromey <tom@tromey.com> * dwarf2/read.c (read_attribute_value): Update. * dwarf2/attribute.h (struct attribute) <form_is_unsigned, set_unsigned>: New methods. * dwarf2/attribute.c (attribute::form_is_unsigned): New method.
2020-09-29Remove DW_SNDTom Tromey3-9/+36
This removes DW_SND in favor of accessors on struct attribute. These accessors check that the form is appropriate. gdb/ChangeLog 2020-09-29 Tom Tromey <tom@tromey.com> * dwarf2/read.c (get_alignment, read_array_order) (read_attribute_value, dwarf2_const_value_attr) (dump_die_shallow, dwarf2_fetch_constant_bytes): Update. * dwarf2/attribute.h (struct attribute) <as_signed, set_signed>: New methods. (DW_SND): Remove.
2020-09-29Remove DW_SIGNATURETom Tromey3-6/+29
This removes DW_SIGNATURE in favor of methods on struct attribute. As usual, the methods check the form, which DW_SIGNATURE did not do. gdb/ChangeLog 2020-09-29 Tom Tromey <tom@tromey.com> * dwarf2/read.c (read_attribute_value, lookup_die_type) (dump_die_shallow, follow_die_sig, get_DW_AT_signature_type): Update. * dwarf2/attribute.h (struct attribute) <as_signature, set_signature>: New methods. (DW_SIGNATURE): Remove.
2020-09-29Remove DW_BLOCKTom Tromey4-74/+124
This removes the DW_BLOCK accessor in favor of methods on struct attribute. The methods, unlike the access, check the form. Note that DW_FORM_data16 had to be handled by form_is_block, because in practice that is how we store values of this form. gdb/ChangeLog 2020-09-29 Tom Tromey <tom@tromey.com> * dwarf2/read.c (read_call_site_scope) (handle_data_member_location, dwarf2_add_member_fn) (mark_common_block_symbol_computed, attr_to_dynamic_prop) (partial_die_info::read, read_attribute_value) (var_decode_location, dwarf2_const_value_attr, dump_die_shallow) (dwarf2_fetch_die_loc_sect_off, dwarf2_fetch_constant_bytes) (dwarf2_symbol_mark_computed): Update. * dwarf2/attribute.h (struct attribute) <as_block, set_block>: New methods. (DW_BLOCK): Remove. * dwarf2/attribute.c (attribute::form_is_block): Add DW_FORM_data16.
2020-09-29Remove DW_STRING and DW_STRING_IS_CANONICALTom Tromey4-49/+81
This removes DW_STRING and DW_STRING_IS_CANONICAL, replacing them with accessor methods on struct attribute. The new code ensures that a string value will only ever be used when the form allows it. gdb/ChangeLog 2020-09-29 Tom Tromey <tom@tromey.com> * dwarf2/read.c (read_cutu_die_from_dwo) (read_attribute_reprocess, read_attribute_value, read_attribute) (dwarf2_const_value_attr, dwarf2_name, dump_die_shallow) (dwarf2_fetch_constant_bytes): Update. * dwarf2/attribute.h (struct attribute) <form_is_string>: Declare. <set_string_noncanonical, set_string_canonical>: New methods. <string_is_canonical>: Update comment. <canonical_string_p>: Add assert. (DW_STRING, DW_STRING_IS_CANONICAL): Remove. * dwarf2/attribute.c (attribute::form_is_string): New method. (attribute::string): Use it.
2020-09-29Remove some uses of DW_STRING_IS_CANONICALTom Tromey3-4/+21
This removes the rvalue uses of DW_STRING_IS_CANONICAL, replacing them with an accessor method. gdb/ChangeLog 2020-09-29 Tom Tromey <tom@tromey.com> * dwarf2/read.c (anonymous_struct_prefix, dwarf2_name) (dump_die_shallow): Use canonical_string_p. * dwarf2/attribute.h (struct attribute) <canonical_string_p>: New method.
2020-09-29Change some uses of DW_STRING to string methodTom Tromey2-28/+43
This changes some of the simpler spots to use attribute::string rather than DW_STRING. gdb/ChangeLog 2020-09-29 Tom Tromey <tom@tromey.com> * dwarf2/read.c (partial_die_info::read) (dwarf2_const_value_attr, anonymous_struct_prefix, ) (dwarf2_name, dwarf2_fetch_constant_bytes): Use attribute::as_string.
2020-09-29Avoid using DW_* macros in dwarf2/attribute.cTom Tromey2-5/+13
There's no need to use the DW_* accessor macros in dwarf2/attribute.c, and this is a necessary step toward our goal of removing them entirely. gdb/ChangeLog 2020-09-29 Tom Tromey <tom@tromey.com> * dwarf2/attribute.c (attribute::address): Don't use DW_UNSND or DW_ADDR. (attribute::string): Don't use DW_STRING. (attribute::get_ref_die_offset): Don't use DW_UNSND. (attribute::constant_value): Don't use DW_UNSND or DW_SND.
2020-09-29Rename struct attribute accessorsTom Tromey4-16/+26
This removes the "value_" prefix from the struct value accessors. This seemed unnecessarily wordy to me. gdb/ChangeLog 2020-09-29 Tom Tromey <tom@tromey.com> * dwarf2/read.c (dwarf2_find_base_address, read_call_site_scope) (dwarf2_get_pc_bounds, dwarf2_record_block_ranges) (partial_die_info::read, dwarf2_string_attr, new_symbol): Update. * dwarf2/attribute.h (struct attribute): Rename methods. * dwarf2/attribute.c (attribute::as_address): Rename from value_as_address. (attribute::as_string): Rename from value_as_string.
2020-09-29Add attribute::value_as_string methodTom Tromey2-5/+9
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-29Tweak gdbsupport/valid-expr.h for GCC 6, fix buildPedro Alves2-7/+23
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-28Turn target_have_steppable_watchpoint into functionTom Tromey4-6/+16
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-28Turn target_can_lock_scheduler into a functionTom Tromey3-3/+12
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-28Remove target_has_execution macroTom Tromey30-79/+124
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-28Turn target_can_execute_reverse into functionTom Tromey6-7/+19
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-28Remove target_has_registers macroTom Tromey17-25/+52
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-28Remove target_has_stack macroTom Tromey12-19/+37
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-28Remove target_has_memory macroTom Tromey6-8/+18
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-28Remove target_has_all_memoryTom Tromey3-17/+6
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-28gdb: fix formatting of serial::async_state's enumeratorsSimon Marchi2-6/+11
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-27Rewrite tui_putsTom Tromey2-12/+68
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-27Use ISCNTRL in tui_copy_source_lineTom Tromey2-3/+9
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-27Use a curses pad for source and disassembly windowsTom Tromey8-71/+140
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-27Remove a call to show_source_line from TUITom Tromey2-1/+6
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-27Use an inner window in tui_py_windowTom Tromey2-27/+42
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-27Remove test duplicate from gdb.tuiTom Tromey2-4/+10
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-26gdb: Fix from_tty argument to gdb.execute in Python.Gareth Rees4-4/+32
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-25gdb: fix formatting of _debug_printf macrosSimon Marchi3-8/+17
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-25Add a missing munmap_list move constructorSaagar Jha2-0/+6
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-25gdb: fix whitespaces in ChangeLogSimon Marchi1-3/+3
Change-Id: Ie5accb8915341cf9b4ed23162f9503d7ef947fcf
2020-09-25Fix gdb.base/infcall-nested-structs-c++.exp with ClangGary Benson2-0/+13
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-25Fix compilation of .c files as C++ when using ClangGary Benson2-2/+8
In commit 221db974e653659edb280787af1b3efdd1615083, 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-24Don't let TUI focus on locatorTom Tromey6-8/+52
PR tui/26638 notes that the C-x o binding can put the focus on the locator window. However, this is not useful and did not happen historically. This patch changes the TUI to skip this window when switching focus. gdb/ChangeLog 2020-09-24 Tom Tromey <tromey@adacore.com> PR tui/26638: * tui/tui-stack.h (struct tui_locator_window) <can_focus>: New method. * tui/tui-data.h (struct tui_win_info) <can_focus>: New method. * tui/tui-data.c (tui_next_win): Exclude non-focusable windows. (tui_prev_win): Rewrite. gdb/testsuite/ChangeLog 2020-09-24 Tom Tromey <tromey@adacore.com> PR tui/26638: * gdb.tui/list.exp: Check output of "focus next".
2020-09-24Handle 64bit breakpoints of WOW64 processes as SIGINTHannes Domani4-1/+24
When a WOW64 process triggers a breakpoint exception in 64bit code (which happens when a 64bit gdb calls DebugBreakProcess for a 32bit target), gdb ignores the breakpoint (because Wow64GetThreadContext can only report the pc of 32bit code, and there is not int3 at this location). But if these 64bit breakpoint exceptions are handled as SIGINT, gdb doesn't check for int3, and always stops the target. gdb/ChangeLog: 2020-09-23 Hannes Domani <ssbssa@yahoo.de> * nat/windows-nat.c (handle_exception): Handle 64bit breakpoints in WOW64 processes as SIGINT. * nat/windows-nat.h: Make wow64_process a shared variable. * windows-nat.c: Remove static wow64_process variable. gdbserver/ChangeLog: 2020-09-23 Hannes Domani <ssbssa@yahoo.de> * win32-low.cc: Remove local wow64_process variable. * win32-low.h: Remove local wow64_process variable.
2020-09-23Handle bit offset and bit size in base typesTom Tromey9-7/+406
PR symtab/25470 points out that the Zig programming language allows integers of various bit sizes (including zero), not just sizes that are a multiple of 8. This is supported in DWARF by applying both a byte size and a DW_AT_bit_size. This patch adds support for this feature to integer and boolean types. Other base types are not handled -- for floating-point types, this didn't seem to make sense, and for character types I didn't see much need. (These can be added later if desired.) I've also added support for DW_AT_data_bit_offset at the same time. I don't know whether the Zig compiler requires this, but it was described in the same section in the DWARF standard and was easy to add. A new test case is supplied, using the DWARF assembler. gdb/ChangeLog 2020-09-23 Tom Tromey <tom@tromey.com> PR symtab/25470: * value.c (unpack_long, pack_long, pack_unsigned_long): Handle bit offset and bit size. * printcmd.c (print_scalar_formatted): Handle zero-length integer. (print_scalar_formatted): Use bit_size_differs_p. * gdbtypes.h (enum type_specific_kind) <TYPE_SPECIFIC_INT>: New constant. (union type_specific): <int_stuff>: New member. (struct type) <bit_size_differs_p, bit_size, bit_offset>: New methods. * gdbtypes.c (init_integer_type, init_boolean_type): Initialize TYPE_SPECIFIC_FIELD. (recursive_dump_type, copy_type_recursive): Update. * dwarf2/read.c (read_base_type): Handle DW_AT_bit_size and DW_AT_data_bit_offset. gdb/testsuite/ChangeLog 2020-09-23 Tom Tromey <tom@tromey.com> * gdb.dwarf2/intbits.exp: New file. * gdb.dwarf2/intbits.c: New file.
2020-09-23Avoid manual memory management of argv arrays in gdb/compileTom Tromey3-58/+73
This changes gdb/compile to use gdb_argv directly, rather than manually managing the arrays itself. A few new helpers are added to gdb_argv. gdb/ChangeLog 2020-09-23 Tom Tromey <tom@tromey.com> * utils.h (class gdb_argv): Add move operators. <append>: New methods. * compile/compile.c (build_argc_argv): Remove. (compile_args_argc): Remove. (compile_args_argv): Change type. (set_compile_args): Simplify. (append_args): Remove. (filter_args): Remove argcp parameter. (get_args): Return gdb_argv. Simplify. (compile_to_object): Update.
2020-09-23Simplify compile_module cleanupTom Tromey4-56/+83
This simplifies compile_module cleanup by removing the need to explicitly free anything. struct setup_sections_data is also cleaned up a bit. gdb/ChangeLog 2020-09-23 Tom Tromey <tom@tromey.com> * compile/compile-object-run.c (do_module_cleanup) <~do_module_cleanup> :Remove. (do_module_cleanup): Update. * compile/compile-object-load.h (struct munmap_list): Add move assignment operator. <source_file>: Now a std::string. <munmap_list>: Rename. No longer a pointer. * compile/compile-object-load.c (struct setup_sections_data): Add constructor. <setup_one_section>: Declare. <munmap_list>: Move earlier. <m_bfd>: New member. <m_last_size, m_last_section_first, m_last_prot, m_last_max_alignment>: Rename, add initializers where needed. (setup_sections_data::setup_one_section): Rename from setup_sections. Update. (compile_object_load): Update. Don't use bfd_map_over_sections.
2020-09-23Transfer module ownership to do_module_cleanupTom Tromey2-42/+38
This changes the do_module_cleanup structure to simply hold on to the module itself. This lets us remove most members from do_module_cleanup. gdb/ChangeLog 2020-09-23 Tom Tromey <tom@tromey.com> * compile/compile-object-run.c (struct do_module_cleanup): Add parameters to constructor. Update destructor. <source_file, scope, scope_data, out_value_type, out_value_addr, munmap_list_head, objfile_name_string>: Remove. <module>: New member. (do_module_cleanup): Update. (compile_object_run): Update.
2020-09-23Introduce and use compile_module_upTom Tromey6-12/+32
This introduces compile_module_up, a unique pointer for compile_module, and changes a few spots to use it. gdb/ChangeLog 2020-09-23 Tom Tromey <tom@tromey.com> * compile/compile.c (eval_compile_command): Update. * compile/compile-object-run.h (compile_object_run): Take a compile_module_up. * compile/compile-object-run.c (compile_object_run): Take a compile_module_up. * compile/compile-object-load.h (struct compile_module): Add constructor, destructor. (compile_module_up): New typedef. (compile_object_load): Return compile_object_up. * compile/compile-object-load.c (compile_object_load): Return compile_module_up.
2020-09-23Use new/delete for do_module_cleanupTom Tromey2-10/+26
This changes do_module_cleanup to use new and delete. It also removes the use of the struct hack from this object -- this requires more allocations for now, but this will be removed in a subsequent patch. gdb/ChangeLog 2020-09-23 Tom Tromey <tom@tromey.com> * compile/compile-object-run.c (struct do_module_cleanup): Add constructor, destructor. <objfile_name_string>: Don't use struct hack. (do_module_cleanup): Use delete. (compile_object_run): Use new.