aboutsummaryrefslogtreecommitdiff
path: root/gdb
AgeCommit message (Collapse)AuthorFilesLines
2019-01-23Remove cleanup from stop_all_threadsTom Tromey2-12/+7
This removes the cleanup from stop_all_threads, replacing it with a scope_exit. gdb/ChangeLog: 2019-01-23 Tom Tromey <tom@tromey.com> Pedro Alves <palves@redhat.com> * infrun.c (disable_thread_events): Delete. (stop_all_threads): Use SCOPE_EXIT.
2019-01-23Remove clear_symtab_users_cleanupTom Tromey2-14/+22
This removes clear_symtab_users_cleanup, replacing it with uses of forward_scope_exit. gdb/ChangeLog: 2019-01-23 Tom Tromey <tom@tromey.com> Pedro Alves <palves@redhat.com> * symfile.c: Include forward-scope-exit.h. (clear_symtab_users_cleanup): Replace forward declaration with a FORWARD_SCOPE_EXIT. (syms_from_objfile_1): Use the forward_scope_exit and gdb::optional instead of cleanup_function. (reread_symbols): Use the forward_scope_exit instead of cleanup_function. (clear_symtab_users_cleanup): Remove function.
2019-01-23Remove cleanup from linux-nat.cTom Tromey2-15/+11
This removes a cleanup from linux-nat.c, replacing it with a scope_exit. gdb/ChangeLog: 2019-01-23 Tom Tromey <tom@tromey.com> Pedro Alves <palves@redhat.com> * linux-nat.c: Include scope-exit.h. (cleanup_target_stop): Remove. (linux_nat_target::static_tracepoint_markers_by_strid): Use SCOPE_EXIT.
2019-01-23Remove cleanup_delete_std_terminate_breakpointTom Tromey2-11/+8
This removes cleanup_delete_std_terminate_breakpoint, replacing it with a use of SCOPE_EXIT. gdb/ChangeLog: 2019-01-23 Tom Tromey <tom@tromey.com> Pedro Alves <palves@redhat.com> * infcall.c (cleanup_delete_std_terminate_breakpoint): Remove. (call_function_by_hand_dummy): Use SCOPE_EXIT.
2019-01-23Remove make_bpstat_clear_actions_cleanupTom Tromey6-27/+20
This removes make_bpstat_clear_actions_cleanup, replacing it with uses of scope_exit. gdb/ChangeLog: 2019-01-23 Tom Tromey <tom@tromey.com> Andrew Burgess <andrew.burgess@embecosm.com> Pedro Alves <palves@redhat.com> * infrun.c (fetch_inferior_event): Use scope_exit. * utils.h (make_bpstat_clear_actions_cleanup): Don't declare. * top.c (execute_command): Use scope_exit. * breakpoint.c (bpstat_do_actions): Use scope_exit. * utils.c (do_bpstat_clear_actions_cleanup) (make_bpstat_clear_actions_cleanup): Remove.
2019-01-23Remove delete_just_stopped_threads_infrun_breakpoints_cleanupTom Tromey2-16/+13
v3: sorted earlier in the series, and replaces the cleanup in fetch_inferior_event here too instead of in some other patch. This removes delete_just_stopped_threads_infrun_breakpoints_cleanup, replacing it with uses of scope_exit. gdb/ChangeLog: 2019-01-23 Tom Tromey <tom@tromey.com> Pedro Alves <palves@redhat.com> * infrun.c: Include "common/scope-exit.h" (delete_just_stopped_threads_infrun_breakpoints_cleanup): Remove. (wait_for_inferior): Use SCOPE_EXIT. (fetch_inferior_event): Use scope_exit.
2019-01-23Remove remaining cleanup from gdb/breakpoint.cTom Tromey2-12/+5
In v3: remove the "have BKPT_CHAIN already discarded" comment too. The remaining null cleanup in breakpoint.c does not seem to protect anything, so remove it. gdb/ChangeLog: 2019-01-23 Tom Tromey <tom@tromey.com> Pedro Alves <palves@redhat.com> * breakpoint.c (create_breakpoint): Remove cleanup.
2019-01-23Replace delete_longjmp_breakpoint_cleanup with a forward_scope_exit typeTom Tromey4-16/+15
This removes delete_longjmp_breakpoint_cleanup in favor of forward_scope_exit. gdb/ChangeLog: 2019-01-23 Tom Tromey <tom@tromey.com> Andrew Burgess <andrew.burgess@embecosm.com> Pedro Alves <palves@redhat.com> * breakpoint.c (until_break_command): Use delete_longjmp_breakpoint_cleanup class. * infcmd.c (delete_longjmp_breakpoint_cleanup): Remove function. (until_next_command): Use delete_longjmp_breakpoint_cleanup class. * inferior.h: Include forward-scope-exit.h. (delete_longjmp_breakpoint_cleanup): Replace function declaration with FORWARD_SCOPE_EXIT type.
2019-01-23Use SCOPE_EXIT in gdbarch-selftest.cPedro Alves2-7/+5
Replace the custom local class with a SCOPE_EXIT. gdb/ChangeLog: 2019-01-23 Pedro Alves <palves@redhat.com> * gdbarch-selftests.c (struct on_exit): Use SCOPE_EXIT.
2019-01-23Use forward_scope_exit for scoped_finish_thread_statePedro Alves2-25/+10
This reimplements the manually-written scoped_finish_thread_state class as a forward_scope_exit instantiation. forward_scope_exit has the same interface as scoped_finish_thread_state, so nothing else has to change. A forward_scope_exit is preferred over make_scope_exit here because infrun.c:normal_stop needs to wrap scoped_finish_thread_state in a gdb::optional. Since we need the type there, might as well use it everywhere. gdb/ChangeLog: 2019-01-23 Pedro Alves <palves@redhat.com> Andrew Burgess <andrew.burgess@embecosm.com> * gdbthread.h: Include "common/forward-scope-exit.h". (scoped_finish_thread_state): Redefine custom class in terms of forward_scope_exit.
2019-01-23Introduce forward_scope_exitPedro Alves2-0/+128
This adds a template that can be used to automatically instantiate scope_exit-like types that wrap some cleanup function. The instantiated type has a ctor that has the same interface as the wrapped function. While the "magic" is just straight C++11, the intended use is via the FORWARD_SCOPE_EXIT macro, which is a minimal macro that avoids spelling out the wrapped function name more than once: void some_function (int foo, object *bar); using some_function_fce = FORWARD_SCOPE_EXIT (some_function); some_function_fce cleanup (some_int, some_obj_ptr); The above runs: some_function (some_int, some_obj_ptr); at scope exit. This is mainly useful as opposed to a simpler SCOPE_EXIT when you need to: - cancel the scope_exit, in which case you need the object's name - wrap the scope_exit in a gdb::optional, in which case you need the scope_exit's type in advance. More details in the code comments. gdb/ChangeLog: 2019-01-23 Pedro Alves <palves@redhat.com> Andrew Burgess <andrew.burgess@embecosm.com> * common/forward-scope-exit.h: New file.
2019-01-23Introduce scope_exitPedro Alves2-0/+192
This add a new template class scope_exit. scope_exit is a general-purpose scope guard that calls its exit function at the end of the current scope. A scope_exit may be canceled by calling the "release" method. The API is modeled on P0052R5 - Generic Scope Guard and RAII Wrapper for the Standard Library, which is itself based on Andrej Alexandrescu's ScopeGuard/SCOPE_EXIT. The main advantage of scope_exit is avoiding writing single-use RAII classes and its boilerplate. Following patches will remove a few of such classes. There are two forms available: - The "make_scope_exit" form allows canceling the scope guard. Use it like this: auto cleanup = make_scope_exit ( <function, function object, lambda> ); ... cleanup.release (); // cancel - If you don't need to cancel the guard, you can use the SCOPE_EXIT macro, like this: SCOPE_EXIT { /* any code you like here. */ } Note: scope_exit instances do not allocate anything on the heap. gdb/ChangeLog: 2019-01-23 Pedro Alves <palves@redhat.com> Andrew Burgess <andrew.burgess@embecosm.com> Tom Tromey <tom@tromey.com> * common/scope-exit.h: New file.
2019-01-23Rename ESC -> ESC_PARENSPedro Alves3-10/+17
A following patch will include common/preprocessor.h in some .c file that also includes readline.h, and that revealed a conflict -- ESC is defined by readline.h as well (actually readline's chardefs.h) with a completely unrelated meaning: #define ESC CTRL('[') Rename our version to avoid the conflict. gdb/ChangeLog: 2019-01-23 Pedro Alves <palves@redhat.com> * common/preprocessor.h (ESC): Rename to ... (ESC_PARENS): ... this. * common/valid-expr.h (CHECK_VALID_EXPR_1, CHECK_VALID_EXPR_2) (CHECK_VALID_EXPR_3, CHECK_VALID_EXPR_4): Adjust.
2019-01-23Remove a warning from symtab.cTom Tromey2-1/+11
When building symtab.c, I get: ../../binutils-gdb/gdb/language.h: In function ‘void print_symbol_info(search_domain, symbol*, int, const char*)’: ../../binutils-gdb/gdb/language.h:738:20: warning: ‘*((void*)& l +4)’ may be used uninitialized in this function [-Wmaybe-uninitialized] set_language (m_lang); ~~~~~~~~~~~~~^~~~~~~~ ../../binutils-gdb/gdb/symtab.c:4613:41: note: ‘*((void*)& l +4)’ was declared here scoped_switch_to_sym_language_if_auto l (sym); ^ This is another instance of the std::optional problem, see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80635. However, it seemed straightforward and inexpensive to me to silence this one, which is what this patch does. gdb/ChangeLog 2019-01-23 Tom Tromey <tom@tromey.com> * language.h (class scoped_switch_to_sym_language_if_auto): Initialize m_lang in both cases.
2019-01-23AArch64: Ensure lwp info is created zeroedAlan Hayward2-1/+6
The code to not set empty hardware BPs/WPs on new threads will only work if the newly allocated struct is empty. Ensure the structure is created zeroed. This patch removes the remaining racy behaviour on gdb.threads tests when run on AArch64 Ubuntu. gdb/ChangeLog: * nat/aarch64-linux.c (aarch64_linux_new_thread): Replace XNEW with XCNEW.
2019-01-22corelow.c does not need sys/file.hTom Tromey2-3/+4
I did not see any reason that corelow.c should include <sys/file.h>. The provided explanatory comment seems to be wrong. This patch removes the include. 2019-01-22 Tom Tromey <tom@tromey.com> * corelow.c: Do not include sys/file.h.
2019-01-22Include gdb_curses.h in tui-wingeneral.hTom Tromey2-0/+6
tui-wingeneral.h uses WINDOW, which is defined by curses. So, include gdb_curses.h from tui-wingeneral.h. 2019-01-22 Tom Tromey <tom@tromey.com> * tui/tui-wingeneral.h: Include gdb_curses.h.
2019-01-22Rename "lines" parameter in source-cache.hTom Tromey2-5/+10
A compile in the TUI somehow had "lines" defined as a macro. This caused a compile error when including source-cache.h after whatever header did that. I tracked this down to a #define in /usr/include/term.h, so I just changed source-cache.h to avoid the clash. gdb/ChangeLog 2019-01-22 Tom Tromey <tom@tromey.com> * source-cache.h (class source_cache) <get_source_lines, get_plain_source_lines, extract_lines>: Rename "lines" parameter.
2019-01-22Declare remote_target in remote-fileio.hTom Tromey2-0/+5
remote-fileio.h refers to remote_target, so forward-declare it. gdb/ChangeLog 2019-01-22 Tom Tromey <tom@tromey.com> * remote-fileio.h (struct remote_target): Declare.
2019-01-22Do not include py-ref.h in most filesTom Tromey27-26/+29
py-ref.h can really only be included from a specific spot in python-internal.h. The other includes are not useful, and cause compilation errors if the includes are ever sorted. So, remove these includes. Arguably, py-ref.h should simply not be a separate header. gdb/ChangeLog 2019-01-22 Tom Tromey <tom@tromey.com> * python/py-arch.c: Do not include py-ref.h. * python/py-bpevent.c: Do not include py-ref.h. * python/py-cmd.c: Do not include py-ref.h. * python/py-continueevent.c: Do not include py-ref.h. * python/py-event.h: Do not include py-ref.h. * python/py-evtregistry.c: Do not include py-ref.h. * python/py-finishbreakpoint.c: Do not include py-ref.h. * python/py-frame.c: Do not include py-ref.h. * python/py-framefilter.c: Do not include py-ref.h. * python/py-function.c: Do not include py-ref.h. * python/py-infevents.c: Do not include py-ref.h. * python/py-linetable.c: Do not include py-ref.h. * python/py-objfile.c: Do not include py-ref.h. * python/py-param.c: Do not include py-ref.h. * python/py-prettyprint.c: Do not include py-ref.h. * python/py-progspace.c: Do not include py-ref.h. * python/py-symbol.c: Do not include py-ref.h. * python/py-symtab.c: Do not include py-ref.h. * python/py-type.c: Do not include py-ref.h. * python/py-unwind.c: Do not include py-ref.h. * python/py-utils.c: Do not include py-ref.h. * python/py-value.c: Do not include py-ref.h. * python/py-varobj.c: Do not include py-ref.h. * python/py-xmethods.c: Do not include py-ref.h. * python/python.c: Do not include py-ref.h. * varobj.c: Do not include py-ref.h.
2019-01-22Use "struct bcache" in objfiles.hTom Tromey2-2/+7
If objfiles.h is included after bcache.h, then the "bcache" function will cause a compiler error because "bcache" will be seen as a function, not a type. Fix this error by using the "struct" keyword. gdb/ChangeLog 2019-01-22 Tom Tromey <tom@tromey.com> * objfiles.h (struct objfile_per_bfd_storage): Use "struct" keyword for bcache.
2019-01-22Remove a comment in compile/compile-cplus-types.cTom Tromey2-2/+5
The include sorter can't handle multi-line comments on the same line as a #include. This patch removes the only such comment. In general I think these sorts of comments do not provide much value: more often than not, I find that the comment is obsolete in one way or another, and so the include sorter removes them in most cases. gdb/ChangeLog 2019-01-22 Tom Tromey <tom@tromey.com> * compile/compile-cplus-types.c: Remove a comment by #include.
2019-01-22Include compile-internal.h in gcc-c-plugin.hTom Tromey2-0/+6
gcc-c-plugin.h refers to some types defined in compile-internal.h. This patch changes the former to include the latter. gdb/ChangeLog 2019-01-22 Tom Tromey <tom@tromey.com> * compile/gcc-c-plugin.h: Include compile-internal.h.
2019-01-22Remove the EXTERN define from stabsread.hTom Tromey3-27/+34
This removes the EXTERN define from stabsread.h. This is the only spot that still uses this approach, and it interfered with sorting the includes in stabsread.c. Tested by rebuilding. gdb/ChangeLog 2019-01-22 Tom Tromey <tom@tromey.com> * stabsread.c (EXTERN): Do not define. (symnum, next_symbol_text_func, processing_gcc_compilation) (within_function, global_sym_chain, global_stabs) (previous_stab_code, this_object_header_files) (n_this_object_header_files) (n_allocated_this_object_header_files): Define. * stabsread.h (EXTERN): Never define. Use "extern".
2019-01-21Fix leak in event-top.c history expansionPhilippe Waroquiers2-10/+13
E.g. in gdb.base/default.exp, valgrind detects leaks such as ==17663== 1,438 bytes in 101 blocks are definitely lost in loss record 2,804 of 2,884 ==17663== at 0x4C2BE6D: malloc (vg_replace_malloc.c:309) ==17663== by 0x418A17: xmalloc (common-utils.c:44) ==17663== by 0x4E6F19C: history_expand (histexpand.c:1061) ==17663== by 0x4B4490: handle_line_of_input(buffer*, char const*, int, char const*) (event-top.c:685) ==17663== by 0x4B4562: command_line_handler(std::unique_ptr<char, gdb::xfree_deleter<char> >&&) (event-top.c:753) ... Fix the leak by using an unique_xmalloc_ptr for history_value. gdb/ChangeLog 2019-01-22 Philippe Waroquiers <philippe.waroquiers@skynet.be> * event-top.c (handle_line_of_input): use unique_xmalloc_ptr for history_value.
2019-01-21Remove duplicate or commented-out #includesTom Tromey20-18/+26
I wrote a little script to detect duplicate or commented-out #includes and ran it on gdb. This patch is the result. Tested by rebuilding. gdb/ChangeLog 2019-01-21 Tom Tromey <tom@tromey.com> * ui-out.c: Fix includes. * tui/tui-source.c: Fix includes. * target.c: Fix includes. * remote.c: Fix includes. * regcache.c: Fix includes. * python/py-block.c: Fix includes. * printcmd.c: Fix includes. * or1k-tdep.c: Fix includes. * mi/mi-main.c: Fix includes. * m32r-tdep.c: Fix includes. * csky-tdep.c: Fix includes. * compile/compile-cplus-types.c: Fix includes. * cli/cli-interp.c: Fix includes. gdb/gdbserver/ChangeLog 2019-01-21 Tom Tromey <tom@tromey.com> * tracepoint.c: Fix includes. * remote-utils.c: Fix includes. * linux-x86-low.c: Fix includes. gdb/stubs/ChangeLog 2019-01-21 Tom Tromey <tom@tromey.com> * ia64vms-stub.c: Fix includes.
2019-01-21AArch64 AAPCS: Empty structs have non zero size in C++Alan Hayward4-13/+61
When gdb.base/infcall-nested-structs.c is complied as C++, the compiler will not pass structs containing empty structs via float arguments. This is because structs in C++ have a minimum size of 1, causing padding in the struct once compiled. The AAPCS does not allow structs with padding to be passed in float arguments. Add padding checks to AArch64 and add C++ compile variant to the test. Some of the tests fail on X86_64. This has been raised as bug gdb/24104. gdb/ChangeLog: * aarch64-tdep.c (aapcs_is_vfp_call_or_return_candidate_1): Check for padding. gdb/testsuite/ChangeLog: * gdb.base/infcall-nested-structs.exp: Test C++ in addition to C.
2019-01-21Testsuite: Ensure stack protection is off for GCCAlan Hayward5-3/+124
Using -fstack-protector-strong will cause GDB to break on the wrong line when placing a breakpoint on a function. This is due to inadequate dwarf line numbering, and is being tracked by the GCC bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88432 GCC (and Clang) provided by Debian/Ubuntu default to stack protector being enabled. Ensure that when running the GDB testsuite, stack protector is always turned off for GCC 4.1.0 (when stack protector was added) and above. Ensure that this does not cause infinite recursion due to test_compiler_info having to compile a file itself. Add a test to explicitly test breakpoints with various levels of stack protection on both GCC and Clang, with xfail for the known errors. Restore change in ovldbreak.exp which worked around the issue. gdb/testsuite/ChangeLog: 2019-01-18 Alan Hayward <alan.hayward@arm.com> * gdb.base/stack-protector.c: New test. * gdb.base/stack-protector.exp: New file. * gdb.cp/ovldbreak.exp: Only allow a single break line. * lib/gdb.exp (get_compiler_info): Use getting_compiler_info option. (gdb_compile): Remove stack protector for GCC and prevent recursion.
2019-01-17Make minimal symbol range adapter a method on objfileTom Tromey10-82/+113
This removes class objfile_msymbols in favor of a method on the objfile. 2019-01-16 Tom Tromey <tom@tromey.com> * objfiles.h (struct minimal_symbol_iterator): Rename. Move earlier. (struct objfile) <msymbols_range>: Move from top level. <msymbols>: New method. (class objfile_msymbols): Remove. * symtab.c (default_collect_symbol_completion_matches_break_on): Update. * symmisc.c (dump_msymbols): Update. * stabsread.c (scan_file_globals): Update. * objc-lang.c (info_selectors_command, info_classes_command) (find_methods): Update. * minsyms.c (find_solib_trampoline_target): Update. * hppa-tdep.c (hppa_lookup_stub_minimal_symbol): Update. * coffread.c (coff_symfile_read): Update. * ada-lang.c (ada_lookup_simple_minsym) (ada_collect_symbol_completion_matches): Update.
2019-01-17Simplify minsym iterationTom Tromey2-19/+14
This simplifies the minimal symbol iterator, by using minimal_symbol_count and just doing a somewhat ordinary array-like iteration. array_view is nearly usable, except that it is more convenient for this iterator to return pointers rather than references. gdb/ChangeLog 2019-01-16 Tom Tromey <tom@tromey.com> * objfiles.h (class objfile_msymbols) <iterator>: Change argument type. Remove no-argument constructor. <iterator::operator++>: Simplify. <begin>: Update. <end>: Use minimal_symbol_count.
2019-01-17Make psymtab range adapter a method on objfileTom Tromey6-21/+38
This removes the objfile_psymtabs class in favor of a method on objfile and on psymtab_storage. 2019-01-16 Tom Tromey <tom@tromey.com> * objfiles.h (struct objfile) <psymtabs>: New method. (class objfile_psymtabs): Remove. * psymtab.h (class psymtab_storage) <partial_symtab_range>: New typedef. <range>: New method. (require_partial_symbols): Change return type. * psymtab.c (require_partial_symbols) (psym_expand_symtabs_matching): Update. * mdebugread.c (parse_partial_symbols): Update. * dbxread.c (dbx_end_psymtab): Update.
2019-01-17Add compunits range adapter to objfileTom Tromey12-44/+67
This removes the objfile_compunits range adapter in favor of using a method on objfile. 2019-01-15 Tom Tromey <tom@tromey.com> * symtab.c (lookup_objfile_from_block) (lookup_symbol_in_objfile_symtabs) (basic_lookup_transparent_type_1, find_pc_sect_compunit_symtab) (find_line_symtab, info_sources_command) (default_collect_symbol_completion_matches_break_on) (make_source_files_completion_list): Update. * symmisc.c (print_objfile_statistics, dump_objfile) (maintenance_print_symbols, maintenance_info_symtabs) (maintenance_check_symtabs, maintenance_info_line_tables): Update. * source.c (select_source_symtab) (forget_cached_source_info_for_objfile): Update. * objfiles.h (class objfile_compunits): Remove. (struct objfile) <compunits_range>: New typedef. (compunits): New method. * objfiles.c (objfile_relocate1): Update. * mi/mi-cmd-file.c (mi_cmd_file_list_exec_source_files): Update. * maint.c (count_symtabs_and_blocks): Update. * linespec.c (iterate_over_all_matching_symtabs): Update. * cp-support.c (add_symbol_overload_list_qualified): Update. * coffread.c (coff_symtab_read): Update. * ada-lang.c (add_nonlocal_symbols) (ada_collect_symbol_completion_matches) (ada_add_global_exceptions): Update.
2019-01-17Change all_objfiles_safe adapter to be a method on program_spaceTom Tromey5-28/+33
This changes the all_objfiles_safe range adapter to be a method on the program space, and fixes up all the users. gdb/ChangeLog 2019-01-15 Tom Tromey <tom@tromey.com> * progspace.h (program_space) <objfiles_safe_range>: New typedef. <objfiles_safe>: New method. * objfiles.h (class all_objfiles_safe): Remove. * objfiles.c (free_all_objfiles, objfile_purge_solibs): Update. * jit.c (jit_inferior_exit_hook): Update.
2019-01-17Change all_objfiles adapter to be a method on program_spaceTom Tromey42-137/+219
This changes the all_objfiles range adapter to be a method on the program space, and fixes up all the users. gdb/ChangeLog 2019-01-17 Tom Tromey <tom@tromey.com> * progspace.h (program_space) <objfiles_range>: New typedef. <objfiles>: New method. <objfiles_head>: Rename from objfiles. (object_files): Update. * guile/scm-progspace.c (gdbscm_progspace_objfiles): Update. * guile/scm-pretty-print.c (ppscm_find_pretty_printer_from_objfiles): Update. * guile/scm-objfile.c (gdbscm_objfiles): Update. * python/py-xmethods.c (gdbpy_get_matching_xmethod_workers): Update. * python/py-progspace.c (pspy_get_objfiles): Update. * python/py-prettyprint.c (find_pretty_printer_from_objfiles): Update. * python/py-objfile.c (objfpy_lookup_objfile_by_name) (objfpy_lookup_objfile_by_build_id): Update. * mi/mi-cmd-file.c (mi_cmd_file_list_exec_source_files): Update. * windows-tdep.c (windows_iterate_over_objfiles_in_search_order): Update. * symtab.c (iterate_over_symtabs, matching_obj_sections) (expand_symtab_containing_pc, lookup_objfile_from_block) (lookup_static_symbol, basic_lookup_transparent_type) (find_pc_sect_compunit_symtab, find_symbol_at_address) (find_line_symtab, info_sources_command) (default_collect_symbol_completion_matches_break_on) (make_source_files_completion_list, find_main_name): Update. * symmisc.c (print_symbol_bcache_statistics) (print_objfile_statistics, maintenance_print_symbols) (maintenance_print_msymbols, maintenance_print_objfiles) (maintenance_info_symtabs, maintenance_check_symtabs) (maintenance_expand_symtabs, maintenance_info_line_tables): Update. * symfile.c (remove_symbol_file_command, overlay_invalidate_all) (find_pc_overlay, find_pc_mapped_section, list_overlays_command) (map_overlay_command, unmap_overlay_command) (simple_overlay_update, expand_symtabs_matching) (map_symbol_filenames): Update. * symfile-debug.c (set_debug_symfile): Update. * spu-tdep.c (spu_overlay_update, spu_objfile_from_frame): Update. * source.c (select_source_symtab, forget_cached_source_info): Update. * solib.c (solib_read_symbols): Update. * solib-spu.c (append_ocl_sos): Update. * psymtab.c (maintenance_print_psymbols) (maintenance_info_psymtabs, maintenance_check_psymtabs): Update. * probe.c (parse_probes_in_pspace, find_probe_by_pc): Update. * printcmd.c (info_symbol_command): Update. * ppc-linux-tdep.c (ppc_linux_spe_context_inferior_created): Update. * objfiles.h (class all_objfiles): Remove. * objfiles.c (have_partial_symbols, have_full_symbols) (have_minimal_symbols, qsort_cmp, update_section_map) (shared_objfile_contains_address_p) (default_iterate_over_objfiles_in_search_order): Update. * objc-lang.c (info_selectors_command, info_classes_command) (find_methods): Update. * minsyms.c (find_solib_trampoline_target): Update. * maint.c (maintenance_info_sections) (maintenance_translate_address, count_symtabs_and_blocks): Update. * main.c (captured_main_1): Update. * linux-thread-db.c (try_thread_db_load_from_pdir) (has_libpthread): Update. * linespec.c (iterate_over_all_matching_symtabs) (search_minsyms_for_name): Update. * jit.c (jit_find_objf_with_entry_addr): Update. * hppa-tdep.c (find_unwind_entry) (hppa_lookup_stub_minimal_symbol): Update. * gcore.c (gcore_create_callback, objfile_find_memory_regions): Update. * elfread.c (elf_gnu_ifunc_resolve_by_cache) (elf_gnu_ifunc_resolve_by_got): Update. * dwarf2-frame.c (dwarf2_frame_find_fde): Update. * dwarf-index-write.c (save_gdb_index_command): Update. * cp-support.c (add_symbol_overload_list_qualified): Update. * breakpoint.c (create_overlay_event_breakpoint) (create_longjmp_master_breakpoint) (create_std_terminate_master_breakpoint) (create_exception_master_breakpoint): Update. * blockframe.c (find_pc_partial_function): Update. * ada-lang.c (ada_lookup_simple_minsym, add_nonlocal_symbols) (ada_collect_symbol_completion_matches) (ada_add_global_exceptions): Update.
2019-01-17Remove cleanups from solib-target.cTom Tromey2-46/+34
This removes the remaining cleanups from solib-target.c, plus a VEC, by using std::vector and std::unique_ptr. Tested by the buildbot. gdb/ChangeLog 2019-01-17 Tom Tromey <tom@tromey.com> * solib-target.c (lm_info_target_p): Remove typedef. Don't declare VEC. (solib_target_parse_libraries): Change return type. (library_list_start_segment, library_list_start_section) (library_list_end_library, library_list_start_library); Update. (solib_target_free_library_list): Remove. (solib_target_parse_libraries): Remove cleanup. Change return type. (solib_target_current_sos): Update.
2019-01-17Replace "the the" with "the"Tom Tromey11-10/+21
This replaces "the the" with "the" in various comments. Tested by rebuilding. This didn't test the solib-dsbt.c change, but it looks harmless. gdb/ChangeLog 2019-01-17 Tom Tromey <tromey@bapiya> * valprint.c: Replace "the the" with "the". * symtab.c: Replace "the the" with "the". * solib.c: Replace "the the" with "the". * solib-dsbt.c: Replace "the the" with "the". * linespec.c: Replace "the the" with "the". * dwarf2loc.h: Replace "the the" with "the". * amd64-windows-tdep.c: Replace "the the" with "the". * aarch64-tdep.c: Replace "the the" with "the".
2019-01-16Introduce dwarf2_cu::get_builderKeith Seitz4-116/+393
This patch is an attempt to deal with a variety of bugs reported where GDB segfaults attempting to access a dwarf2_cu's builder. In certain circumstances, this builder can be NULL. This is especially common when inheriting DIEs via inlined subroutines in other CUs. The test case demonstrates one such situation reported by users. See gdb/23773, rhbz1638798, and dups for other concrete examples. The approach taken here is to save the ancestor CU into the dwarf2_cu of all CUs with DIEs that are "imported." This can happen whenever follow_die_offset and friends are called. This essentially introduces a chain of CUs that caused the importation of a DIE from a CU. Whenever a builder is requested of a CU that has none, the ancestors are searched for the first one with a builder. A design side effect of this is that the builder can now only be accessed by getter and setter methods because the builder itself is private. The bulk of the patch is relatively mindless text conversion from "cu->builder" to "cu->get_builder ()". I've included one test which was derived from one (of the many) bugs reported on the issue in both sourceware and Fedora bugzillas. gdb/ChangeLog: PR gdb/23773 * dwarf2read.c (dwarf2_cu) <ancestor>: New field. <builder>: Rename to .. <m_builder>: ... this and make private. (dwarf2_cu::get_builder): New method. Change all users of `builder' to use this method. (dwarf2_start_symtab): Move to ... (dwarf2_cu::start_symtab): ... here. Update all callers (setup_type_unit_groups): Move to ... (dwarf2_cu::setup_type_unit_groups): ... here. Update all callers. (dwarf2_cu::reset_builder): New method. (process_full_compunit, process_full_type_unit): Use dwarf2_cu::reset_builder. (follow_die_offset): Record the ancestor CU if it is different from the followed DIE's CU. (follow_die_sig_1): Likewise. gdb/testsuite/ChangeLog: PR gdb/23773 * gdb.dwarf2/inlined_subroutine-inheritance.exp: New file.
2019-01-16doc: Add table of MI versionsSimon Marchi2-11/+53
This patch adds a table summarizing the history or MI versions: - The version number - Which GDB version introduced it - Breaking changes compared to the previous version The goal of the table is to help writers of front ends know which version of MI they can use with a given GDB version. It will also help them update their code to work against a newer MI version. Right now, we just have 1 and 2, but we expect to add an entry for 3 soon. I did a bit of archelogy and reverse engineering of the code to come up with the breaking changes for MI 2. I did some changes to the text around it, some things that I thought needed to be clarified, seemed a bit dated or seemed just wrong (especially "Apart from mi0, new versions of @value{GDBN} will not support old versions of MI"). gdb/doc/ChangeLog: * gdb.texinfo (GDB/MI Development and Front Ends): Add table of MI versions. Update text around it.
2019-01-15Remove cleanup from remote.cTom Tromey2-418/+440
This removes the remaining cleanup from remote.c, by changing remote_state::buf to be a gdb::char_vector, and then fixing up all the fallout. The resulting patch is somewhat ugly, but on the other hand, it eliminates some possibilities for mistakes. Regression tested using the Fedora-x86_64-native-extended-gdbserver-m64 builder on the buildbot. gdb/ChangeLog 2019-01-15 Tom Tromey <tom@tromey.com> * remote.c (class remote_state) <buf>: Now a char_vector. <buf_size>: Remove. (remote_target::getpkt): Change type of buf. Remove sizeof_buf parameter. (remote_target::getpkt_or_notif_sane_1) (remote_target::getpkt_sane) (remote_target::getpkt_or_notif_sane): Likewise. (class remote_target) <putpkt>: New overload. (remote_target::read_frame): Change type of "buf_p". Remove sizeof_p parameter. (packet_ok): New overload. (packet_check_result): New overload. Update all uses.
2019-01-14Constify some remote-notif functionsTom Tromey4-12/+25
This constifies the "buf" arguments to various remote-notif functions and updates the users. gdb/ChangeLog 2019-01-14 Tom Tromey <tom@tromey.com> * remote-notif.c (handle_notification, remote_notif_ack) (remote_notif_parse): Make "buf" const. * remote-notif.h (struct notif_client) <parse, ack>: Make "buf" const. (remote_notif_parse, remote_notif_ack, handle_notification): Likewise. * remote.c (remote_notif_stop_parse): Make "buf" const. (remote_target::remote_parse_stop_reply): Make "buf" const. (remote_notif_stop_ack): Make "buf" const.
2019-01-14Constify remote_console_outputTom Tromey2-3/+7
This constifies the parameter to remote_console_output. gdb/ChangeLog 2019-01-14 Tom Tromey <tom@tromey.com> * remote.c (remote_console_output): Make parameter const.
2019-01-14Constify target_pass_signals and target_program_signalsTom Tromey10-27/+45
This constifies the final parameter to target_pass_signals and target_program_signals and updates the rest of gdb. Note that I have no way to test the nto-procfs.c change. gdb/ChangeLog 2019-01-14 Tom Tromey <tom@tromey.com> * target-debug.h (target_debug_print_signals): Constify. * nto-procfs.c (nto_procfs_target::pass_signals): Update. * procfs.c (procfs_target::pass_signals): Update. * linux-nat.c (linux_nat_target::pass_signals): Update. * linux-nat.h (class linux_nat_target) <pass_signals>: Update. * target-delegates.c: Rebuild. * remote.c (remote_target::program_signals): Update. (remote_target::pass_signals): Update. * target.c (target_pass_signals): Constify argument. (target_program_signals): Likewise. * target.h (struct target_ops) <pass_signals, program_signals>: Constify argument. (target_pass_signals, target_program_signals): Constify argument.
2019-01-14Fix placement of output in TUI modeTom Tromey2-0/+11
The fix for PR tui/28819 regressed gdb command output a bit. In "nonl" mode, pressing the Enter key will result in a newline not being echoed properly, so that gdb output for the command will begin on the same line as the input. This patch changes gdb_wgetch to echo the newline. I have only tested this interactively, as the TUI doesn't have automated tests in general. gdb/ChangeLog 2019-01-14 Tom Tromey <tom@tromey.com> PR tui/28819: * tui/tui-io.c (gdb_wgetch): Print \r when needed.
2019-01-14[PowerPC] Aliases for vector registersPedro Franco de Carvalho10-5/+279
This patch defines pseudo-registers "v0" through "v31" as aliases that map to the corresponding raw "vr0" through "vr31" vector registers for Power. The motivation behind this is that although GDB defines these registers as "vrX", the disassembler prints them as "vX", e.g. as the operands in instructions such as "vaddubm v2,v1,v1". This can be confusing to users trying to print out the values of the operands while inspecting the disassembled code. The new aliases are made not to belong to any register group, to avoid duplicated values in "info register vector" and "info register all". The arch-specific rs6000_pseudo_register_reggroup_p function had previously been removed since the other pseudo-registers could have their groups inferred by their type. It restored with this patch to handle the aliases. Membership for the other pseudo-registers is still determined using the default function. A new tests checks that GDB prints the expected values of vector registers after they are filled by the inferior, by using both the raw names and the aliases. Two other existing tests are modified to also test the aliases. gdb/ChangeLog: 2019-01-14 Pedro Franco de Carvalho <pedromfc@linux.ibm.com> * ppc-tdep.h (struct gdbarch_tdep) <ppc_v0_alias_regnum>: New field. * rs6000-tdep.c: Include reggroups.h. (IS_V_ALIAS_PSEUDOREG): Define. (rs6000_register_name): Return names for the "vX" aliases. (rs6000_pseudo_register_type): Return type for the "vX" aliases. (rs6000_pseudo_register_reggroup_p): Restore. Handle "vX" aliases. Call default_register_reggroup_p for all other pseudo-registers. (v_alias_pseudo_register_read, v_alias_pseudo_register_write): New functions. (rs6000_pseudo_register_read, rs6000_pseudo_register_write): Handle "vX" aliases. (v_alias_pseudo_register_collect): New function. (rs6000_ax_pseudo_register_collect): Handle "vX" aliases. (rs6000_gdbarch_init): Initialize "vX" aliases as pseudo-registers. Restore registration of rs6000_pseudo_register_reggroup_p with set_tdesc_pseudo_register_reggroup_p. gdb/testsuite/ChangeLog: 2019-01-14 Pedro Franco de Carvalho <pedromfc@linux.ibm.com> * gdb.arch/vsx-regs.exp: Add tests that use the vector register aliases. * gdb.arch/altivec-regs.exp: Likewise. Fix indentation of two tests. * gdb.arch/powerpc-vector-regs.c: New file. * gdb.arch/powerpc-vector-regs.exp: New file. gdb/doc/ChangeLog: 2019-01-14 Pedro Franco de Carvalho <pedromfc@linux.ibm.com> * gdb.texinfo (PowerPC Features): Document the alias pseudo-registers for the org.gnu.gdb.power.altivec feature.
2019-01-14[PowerPC] Fix "info vector" test in gdb.arch/altivec-regs.expPedro Franco de Carvalho2-38/+10
This patch fixes one of the tests in gdb.arch/altivec-regs.exp that was passing an incorrect list to gdb_expect_list, which always matched. gdb/testsuite/ChangeLog: 2019-01-14 Pedro Franco de Carvalho <pedromfc@linux.ibm.com> * gdb.arch/altivec-regs.exp: Fix the list passed to gdb_expect_list when testing "info vector".
2019-01-13gdb: xtensa: fix register counters for xtensa-linuxMax Filippov2-1/+13
Commit 37d9e0623102 ("gdb: xtensa: handle privileged registers") changed how the tdep->num_regs and tdep->num_pseudo_regs are calculated, but didn't update these numbers in the gdbarch for the xtensa-linux target. As a result xtensa-linux-gdb behaves as xtensa-elf-gdb and cannot communicate with the linux gdbserver. Fix tdep->num_pseudo_regs calculation and call set_gdbarch_num_regs and set_gdbarch_num_pseudo_regs in xtensa_linux_init_abi. gdb/ 2019-01-13 Max Filippov <jcmvbkbc@gmail.com> * xtensa-linux-tdep.c (xtensa_linux_init_abi): Update tdep->num_pseudo_regs. Add calls to set_gdbarch_num_regs and set_gdbarch_num_pseudo_regs.
2019-01-12Implement help/show values for 'set|show style'.Philippe Waroquiers3-54/+74
Currently, the behaviour is: (gdb) show style (gdb) set style (gdb) show style address (gdb) set style address (gdb) With this patch, the behaviour is: (gdb) show style style address background: The "address" background color is: none style address foreground: The "address" foreground color is: blue style address intensity: The "address" display intensity is: normal enabled: CLI output styling is enabled. style filename background: The "filename" background color is: none style filename foreground: The "filename" foreground color is: green style filename intensity: The "filename" display intensity is: normal style function background: The "function" background color is: none style function foreground: The "function" foreground color is: yellow style function intensity: The "function" display intensity is: normal style variable background: The "variable" background color is: none style variable foreground: The "variable" foreground color is: cyan style variable intensity: The "variable" display intensity is: normal (gdb) set style "set style" must be followed by an appropriate subcommand. List of set style subcommands: set style address -- Address display styling set style enabled -- Set whether CLI styling is enabled set style filename -- Filename display styling set style function -- Function name display styling set style variable -- Variable name display styling Type "help set style" followed by set style subcommand name for full documentation. Type "apropos word" to search for commands related to "word". Command name abbreviations are allowed if unambiguous. (gdb) show style address background: The "filename" background color is: none foreground: The "filename" foreground color is: green intensity: The "filename" display intensity is: normal (gdb) set style address List of set style address subcommands: set style address background -- Set the background color for this property set style address foreground -- Set the foreground color for this property set style address intensity -- Set the display intensity color for this property Type "help set style address" followed by set style address subcommand name for full documentation. Type "apropos word" to search for commands related to "word". Command name abbreviations are allowed if unambiguous. (gdb) gdb/ChangeLog * cli/cli-style.h (class cli_style_option): <add_setshow_commands> Remove arg prefixname, add do_set and do_show. Add member functions set_list and show_list. * cli/cli-style.c (class cli_style_option): Update accordingly. (style_set_list): Move to file scope. (style_show_list): Likewise. (set_style): Call help_list. (show_style): Call cmd_show_list. (_initialize_cli_style): New macro STYLE_ADD_SETSHOW_COMMANDS. Update to use the new macro.
2019-01-12expand a bit the in-GDB help for the "catch exception" help textJoel Brobecker2-1/+13
One of our users remarked that the help doesn't mention the fact that the "catch exception" supports the special argument "unhandled" to catch exceptions which do not have a handler. This patch changes the output of... | (gdb) help catch exception | Catch Ada exceptions, when raised. | With an argument, catch only exceptions with the given name. ... to ... | (gdb) help catch exception | Catch Ada exceptions, when raised. | Usage: catch exception [ ARG ] | | Without any argument, stop when any Ada exception is raised. | If ARG is "unhandled" (without the quotes), only stop when the exception | being raised does not have a handler (and will therefore lead to the task's | termination). | Otherwise, the catchpoint only stops when the name of the exception being | raised is the same as ARG. gdb/ChangeLog: * ada-lang.c (_initialize_ada_language): Expand the help text for the "catch exception" command. Tested on x86_64-linux, no regression.
2019-01-12gdb/testsuite: Don't allow paths to appear in test nameAndrew Burgess2-0/+5
Having paths in the test names makes it harder to compare results between two runs in different directories. Give the test a name so that the path doesn't appear. gdb/ChangeLog: * gdb.base/style.exp: Don't include path in testname.
2019-01-12Fix 'obj' may be used uninitialized warning in symtab.c:matching_obj_sections.Philippe Waroquiers2-1/+6
Fix warning: gdb/symtab.c: In function ‘int matching_obj_sections(obj_section*, obj_section*)’: gdb/symtab.c:1024:12: warning: ‘obj’ may be used uninitialized in this function [-Wmaybe-uninitialized] if (obj->separate_debug_objfile_backlink != NULL 2019-01-12 Philippe Waroquiers <philippe.waroquiers@skynet.be> * symtab.c (matching_obj_sections): Initialize obj, declare it closer to its usage.