If you want to use catch_errors with a function with parameters, then
currently you have to manually write a "capture" struct wrapping the
arguments and marshall/unmarshall that.
https://sourceware.org/ml/gdb-patches/2017-09/msg00834.html proposed
adjusting catch_errors to use gdb::function_view, which would allow
passing lambdas with automatic captures. However, it seems like using
TRY/CATCH directly instead ends up producing clearer and easier to
debug code. This is what this commit does.
Note that removing catch_errors exposes further cleanup opportunities
around no longer having to follow catch_errors callback type, and also
removes a few cleanups.
I didn't do anything to save/restore current_uiout because I think
that should be the responsibility of the code that changes
current_uiout in the first place.
(Another approach could be to make catch_errors a variadic template
like:
template<typename Function, typename... Args>
int catch_errors (const char *errstring, return_mask mask,
Function &&func, Args... args);
and then with:
extern void function_with_args (int, int);
extern void function_with_no_args ();
calls to the above functions would be wrapped like this:
catch_errors ("some error happened", RETURN_MASK_ERROR,
function_with_args, arg1, arg2);
catch_errors ("some error happened", RETURN_MASK_ERROR,
function_with_no_args);
but I'm thinking that that doesn't improve much if at all either.)
gdb/ChangeLog
2017-10-10 Pedro Alves <palves@redhat.com>
Tom Tromey <tom@tromey.com>
* breakpoint.c (breakpoint_cond_eval): Change return type to bool
and reverse logic.
(WP_DELETED, WP_VALUE_CHANGED, WP_VALUE_NOT_CHANGED, WP_IGNORE):
No longer macros. Instead ...
(enum wp_check_result): They're now values of this new
enumeration.
(watchpoint_check): Change return type to wp_check_result and
parameter type to bpstat.
(bpstat_check_watchpoint): Use TRY/CATCH instead of catch_errors.
(bpstat_check_breakpoint_conditions): Use TRY/CATCH instead of
catch_errors. Reverse logic of watchpoint_check call.
(breakpoint_re_set_one): Now returns void and takes a breakpoint
pointer as parameter.
(breakpoint_re_set): Use TRY/CATCH instead of catch_errors.
* common/common-exceptions.c (throw_exception_sjlj): Update
comments to avoid mentioning catch_errors.
* exceptions.c (catch_errors): Delete.
* exceptions.h: Update comments to avoid mentioning catch_errors.
(catch_errors_ftype, catch_errors): Delete.
* infrun.c (normal_stop): Use TRY/CATCH instead of catch_errors.
(hook_stop_stub): Delete.
(restore_selected_frame): Change return type to void, and
parameter type to const frame_id &.
(restore_infcall_control_state): Use TRY/CATCH instead of
catch_errors.
* main.c (captured_command_loop): Return void and remove
parameter. Remove references to catch_errors.
(captured_main): Use TRY/CATCH instead of catch_errors.
* objc-lang.c (objc_submethod_helper_data)
(find_objc_msgcall_submethod_helper): Delete.
(find_objc_msgcall_submethod): Use TRY/CATCH instead of
catch_errors.
* record-full.c (record_full_message): Return void.
(record_full_message_args, record_full_message_wrapper): Delete.
(record_full_message_wrapper_safe): Return bool and use TRY/CATCH
instead of catch_errors.
* solib-aix.c (solib_aix_open_symbol_file_object): Change
parameter type to int.
* solib-darwin.c (open_symbol_file_object): Ditto.
* solib-dsbt.c (open_symbol_file_object): Ditto.
* solib-frv.c (open_symbol_file_object): Ditto.
* solib-svr4.c (open_symbol_file_object): Ditto.
* solib-target.c (solib_target_open_symbol_file_object): Ditto.
* solib.c (update_solib_list): Use TRY/CATCH instead of
catch_errors.
* solist.h (struct target_so_ops) <open_symbol_file_object>:
Change type.
* symmisc.c (struct print_symbol_args): Remove.
(dump_symtab_1): Use TRY/CATCH instead of catch_errors.
(print_symbol): Change type.
* windows-nat.c (handle_load_dll, handle_unload_dll): Return void
and remove parameters.
(catch_errors): New.
(get_windows_debug_event): Adjust.
gdb/testsuite/ChangeLog:
2017-10-10 Pedro Alves <palves@redhat.com>
* lib/selftest-support.exp (selftest_setup): Update for
captured_command_loop's prototype change.
Similar as aarch64 backend, arm backend only overrides the decision on undefined
weak symbols. arm backend part already emits necessary relative relocation for
this case.
bfd/
PR ld/21402
* elf32-arm.c (allocate_dynrelocs_for_symbol): Only make undefined weak
symbols into dynamic.
ld/
PR ld/21402
* testsuite/ld-arm/tls-app.d: Update address.
* testsuite/ld-arm/tls-app.r: Remove relocations.
* testsuite/ld-arm/unresolved-1-dyn.d: Update.
Cache the max alignment of output sections instead of scanning all
output sections for each input section, which can take a very long
time if there are millions of input/output sections.
PR ld/22274
* elfnn-riscv.c (riscv_elf_link_hash_table): Add max_alignment.
(riscv_elf_link_hash_table_create): Initialize max_alignment to
(bfd_vma) -1.
(_bfd_riscv_relax_section): Cache the max alignment of output
sections if possible.
check_relocs was setting up some data used by the --gc-sections
gc_mark_hook. If we change ld to run check_relocs after gc_sections
that data needs to be set up elsewhere. Done by this patch in the
backend check_directives function (ppc64_elf_before_check_relocs).
* elf64-ppc.c (ppc64_elf_before_check_relocs): Set sec_type for
.opd whenever .opd is present and non-zero size. Move code
setting abiversion to/from output file earlier. Only set
u.opd.func_sec when --gc-sections. Read relocs and set up
u.opd.func_sec values here..
(ppc64_elf_check_relocs): ..rather than here. Simplify opd
section tests.
(ppc64_elf_edit_opd): Don't set sec_type for .opd here.
There were two copies of earmelf_fuchsia.c dependencies.
* Makefile.am (earmelfb_fuchsia.c): Rename rule from earmelf_fuchsia.c.
* Makefile.in: Regenerate.
One spot in gdb uses a cleanup to free a splay tree. This patch
introduces a unique_ptr specialization for this case.
ChangeLog
2017-10-09 Tom Tromey <tom@tromey.com>
* mi/mi-main.c (free_splay_tree): Remove.
(list_available_thread_groups): Use splay_tree_up.
* common/gdb_splay_tree.h: New file.
The do_nothing function in mi-main.c is used as a splay tree
key-deleting function; but NULL serves the same purpose and is used
elsewhere in gdb. This patch removes the unneeded function.
ChangeLog
2017-10-09 Tom Tromey <tom@tromey.com>
* mi/mi-main.c (do_nothing): Remove.
(list_available_thread_groups): Update.
Since ELF linker may cache internal symbol table in init_reloc_cookie,
we should check if it is cached, before free it.
* elf-m10300.c (mn10300_elf_check_relocs): Don't free cached
isymbuf.
Don't create the .interp section with "ld --no-dynamic-linker". This
fixed:
FAIL: PR ld/20828 forcibly exported symbol version without section GC
FAIL: PR ld/20828 forcibly exported symbol version with section GC
FAIL: readelf version information
* elf32-bfin.c (bfin_size_dynamic_sections): Don't create the
.interp section with "ld --no-dynamic-linker".
The gdb.multi/multi-arch-exec.exp testcase currently tests execing
from -m64 to -m32, but does not test the other direction. For
thoroughness, this commit fixes that. Without the fix in the previous
commit for example ("Multi-arch exec, more register reading
avoidance"), on x86_64 we would get different symptoms depending on
"execing direction". Vis:
Continuing.
Truncated register 50 in remote 'g' packet
Truncated register 50 in remote 'g' packet
(gdb) FAIL: gdb.multi/multi-arch-exec.exp: first_arch=1: selected_thread=2: follow_exec_mode=same: continue across exec that changes architecture
Vs:
Continuing.
Remote 'g' packet reply is too long (expected 440 bytes, got 816 bytes): daffffffffffffff0000[snip]
Remote 'g' packet reply is too long (expected 440 bytes, got 816 bytes): daffffffffffffff0000[snip]
(gdb) FAIL: gdb.multi/multi-arch-exec.exp: first_arch=2: selected_thread=2: follow_exec_mode=same: continue across exec that changes architecture
gdb/testsuite/ChangeLog:
2017-10-09 Pedro Alves <palves@redhat.com>
Test both arch1=>arch2 and arch2=>arch1.
* gdb.multi/multi-arch-exec.exp (exec1, srcfile1, binfile1, exec2)
(srcfile2, binfile2, march1, march2): Remove globals. Largely
factored out to...
(append_arch1_options, append_arch2_options, append_arch_options)
(build_executables): New procedures.
(do_test): New 'first_arch' parameter. Use it to define 'from_exec'
local.
(top level): Add new 'first_arch' testing axis.
As mentioned in commit bf93d7ba99 ("Add thread after updating
gdbarch when exec'ing"), we should avoid doing register reads after a
process does an exec and before we've updated that inferior's gdbarch.
Otherwise, we may interpret the registers using the wrong
architecture.
There's still (at least) one case where we still read registers
post-exec with the pre-exec architecture. That's when infrun decides
it needs to switch context to the exec'ing thread. I.e., if the exec
event is processed at a time when the current thread is not already
the exec'ing thread, then we get (with the test added by this commit):
continue
Continuing.
Truncated register 50 in remote 'g' packet
Truncated register 50 in remote 'g' packet
(gdb) FAIL: gdb.multi/multi-arch-exec.exp: selected_thread=2: follow_exec_mode=same: continue across exec that changes architecture
The fix is to avoid reading registers when switching context in this
case.
(I'd be nice to get rid of the constant stop_pc reading when switching
threads, but that'd be a deeper change.)
gdb/ChangeLog:
2017-10-09 Pedro Alves <palves@redhat.com>
* infrun.c (handle_inferior_event_1) <TARGET_WAITKIND_EXECD>: Skip
reading registers when switching context.
gdb/testsuite/ChangeLog:
2017-10-09 Pedro Alves <palves@redhat.com>
* gdb.multi/multi-arch-exec.c: Include <pthread.h> and <assert.h>.
(barrier): New.
(thread_start, all_started): New functions.
(main): Spawn new thread and wait until it is scheduled.
* gdb.multi/multi-arch-exec.exp: Build $srcfile1 with the pthreads
option.
(do_test): Add 'selected_thread' parameter. Run to all_started
instead of main. Explicitly set the breakpoint at main. Switch
to the SELECTED_THREAD thread.
(top level): Test handling the exec event with either the main
thread or the second thread selected.
FreeBSD architectures are either ILP32 or LP64 resulting in two
different layouts for siginfo_t. Previously, the 'bits_per_word'
member of bfd_arch_info was used to determine the layout to use for a
given FreeBSD architecture. However, mipsn32 architectures inherit
from a 64-bit mips architecture where bits_per_word is 64. As a
result, $_siginfo was not properly extracted from FreeBSD/mipsn32 core
dumps. Fix this by using gdbarch_long_bit instead of 'bits_per_word'
to determine if a FreeBSD architecture is ILP32 or LP64.
gdb/ChangeLog:
* fbsd-nat.c (fbsd_siginfo_size): Use gdbarch_long_bit.
(fbsd_convert_siginfo): Likewise.
* fbsd-tdep.c (fbsd_core_xfer_siginfo): Likewise.
GDB currently doesn't build with Guile 2.2 (see PR 21104). If one has
both Guile 2.2 and 2.0 installed, GDB will pick up Guile 2.2 first and
fail building. Until somebody does the work of adapting the GDB code to
Guile 2.2, we should not try using it. This patch therefore removes it
from configure.
gdb/ChangeLog:
* configure.ac (try_guile_versions): Remove guile-2.2.
* configure: Regenerate.
prno, tpei, and irbm are missing in the optable.
gas/ChangeLog:
2017-10-09 Andreas Krebbel <krebbel@linux.vnet.ibm.com>
* testsuite/gas/s390/zarch-arch12.d (prno, tpei, irbm): New
instructions added.
* testsuite/gas/s390/zarch-arch12.s: Likewise.
* testsuite/gas/s390/zarch-z13.d: Rename ppno to prno.
opcodes/ChangeLog:
2017-10-09 Andreas Krebbel <krebbel@linux.vnet.ibm.com>
* s390-opc.txt (prno, tpei, irbm): New instructions added.
The recent POP adjusted a few of the instruction formats. This patch
adjusts our optable accordingly. No user visible change - hopefully.
opcodes/ChangeLog:
2017-10-09 Heiko Carstens <heiko.carstens@de.ibm.com>
* s390-opc.c (INSTR_SI_RD): New macro.
(INSTR_S_RD): Adjust example instruction.
* s390-opc.txt (lpsw, ssm, ts): Change S_RD instruction format to
SI_RD.
Commit f38307f5 changed COMPILE.post and POSTCOMPILE to remove
$(basename) from the dependency file name computation. However, it
did not update the `-include' at the end of the Makefile.in; this in
effect disabled automatic dependency tracking.
This patch restores the $(basename) wrapper so that the dependency
files are named "file.Po" rather than "file.o.Po".
I also tested the non-gcc3 dependency mode, which pointed out that
this case hadn't been working since the switch to C++. This is also
fixed in this patch.
Tested by rebuilding.
ChangeLog
2017-10-09 Tom Tromey <tom@tromey.com>
* Makefile.in (COMPILE.post, POSTCOMPILE): Restore $(basename).
(COMPILE.pre): Use $(CXX).
Use the type system instead of callers needing to know how the
returned string's memory is supposed to be managed.
gdb/ChangeLog:
2017-10-09 Pedro Alves <palves@redhat.com>
* cp-support.c (cp_remove_params): Return a gdb::unique_xmalloc_ptr.
Use bool.
(overload_list_add_symbol): Adjust to use gdb::unique_xmalloc_ptr.
* cp-support.h (cp_remove_params): Now returns a
gdb::unique_xmalloc_ptr.
* dwarf2read.c (find_slot_in_mapped_hash): Now returns bool.
Adjust to cp_remove_params returning a gdb::unique_xmalloc_ptr.
* psymtab.c (psymtab_search_name): Adjust to cp_remove_params
returning a gdb::unique_xmalloc_ptr.
(lookup_partial_symbol): Adjust to use gdb::unique_xmalloc_ptr.
* stack.c (find_frame_funname): Adjust to cp_remove_params
returning a gdb::unique_xmalloc_ptr.
Fix a typo introduced in commit c56e7c4390 ("Make ctxobj.exp and
print-file-var.exp work on all platforms.").
This doesn't really affect the outcome of the testcase. I only
noticed the typo because I stepped through the program manually.
To avoid such problems if the test is extended, this moves the STOP
marker until after the program self-validates the values. With the
typo in place, this alone would have resulted in a test FAIL. I.e.,
it'd have caught the typo.
gdb/testsuite/ChangeLog:
2017-10-09 Pedro Alves <palves@redhat.com>
* gdb.base/print-file-var-main.c: Fix get_version_2 value check
logic. Move STOP marker after the value checks.
* gdb.base/print-file-var.exp (continue to STOP marker): Tighten
regexp.
Don't allow '~' as the first character in symbol name in linker script.
PR ld/22267
* ldlex.l (SYMBOLNAMECHAR1) New.
(DEFSYMEXP): Replace FILENAMECHAR1 with SYMBOLNAMECHAR1.
(EXPRESSION): Likewise.
* testsuite/ld-scripts/expr.exp: Run pr22267.
* testsuite/ld-scripts/pr22267.d: New file.
* testsuite/ld-scripts/pr22267.s: Likewise.
* testsuite/ld-scripts/pr22267.t: Likewise.
This removes a number of cleanups from dwarf2read.c in a
straightforward way.
Note that some places in dwarf2read create dangling cleanups. I don't
believe any of the changes in this patch interact with those spots.
Regression tested by the buildbot.
gdb/ChangeLog
2017-10-08 Tom Tromey <tom@tromey.com>
* dwarf2read.c (dwarf2_get_dwz_file): Use
gdb::unique_xmalloc_ptr.
(find_slot_in_mapped_hash): Likewise.
(dwarf2_physname): Likewise.
(create_dwo_unit_in_dwp_v1): Use std::string.
(create_dwo_unit_in_dwp_v2): Likewise.
(lookup_dwo_cutu): Likewise.
(inherit_abstract_dies): Use std::vector.
(read_array_type): Likewise.
(dwarf_decode_macros): Remove unused declaration.
(unsigned_int_compar): Remove.
(dwarf2_build_psymtabs_hard): Use scoped_restore.
(psymtabs_addrmap_cleanup): Remove.
Currently frame_prepare_for_sniffer returns a cleanup. This patch
changes it to return void, and exposes frame_cleanup_after_sniffer to
the caller.
Normally I would write an RAII class for this sort of thing; but
because there was just a single caller of frame_prepare_for_sniffer,
and because this caller is already using try/catch, I thought it
seemed ok to require explicit calls in this instance.
Regression tested by the buildbot.
gdb/ChangeLog
2017-10-08 Tom Tromey <tom@tromey.com>
* frame-unwind.c (frame_unwind_try_unwinder): Update.
* frame.h (frame_cleanup_after_sniffer): Declare.
(frame_prepare_for_sniffer): Return void.
* frame.c (frame_cleanup_after_sniffer): No longer static. Change
type of argument.
(frame_prepare_for_sniffer): Return void.
This removes make_cleanup_value_free, in favor of a unique_ptr
specialization.
Regression tested by the buildbot.
gdb/ChangeLog
2017-10-08 Tom Tromey <tom@tromey.com>
* utils.h (make_cleanup_value_free): Remove.
* utils.c (do_value_free, struct cleanup): Remove.
* dwarf2loc.c (dwarf2_evaluate_loc_desc_full) <DWARF_VALUE_STACK>:
Use gdb_value_up.
* value.h (struct value_deleter): New.
(gdb_value_up): New typedef.
This changes search_symbols to return a std::vector, replacing the
previous linked list approach. This allows the removal of some
cleanups, as well as the use of std::sort and std::unique, saving some
code and extra allocations in sort_search_symbols_remove_dups.
Regression tested by the buildbot.
gdb/ChangeLog
2017-10-08 Tom Tromey <tom@tromey.com>
* symtab.c (free_search_symbols, do_free_search_symbols_cleanup)
(make_cleanup_free_search_symbols): Remove.
(search_symbols): Return std::vector.
(symbol_search::compare_search_syms): Now member of
symbol_search. Change arguments.
(sort_search_symbols_remove_dups): Change arguments. Rewrite.
(symtab_symbol_info, rbreak_command): Update.
* symtab.h (struct symbol_search) <next>: Remove.
Add constructors.
(symbol_search::operator<): New function.
(symbol_search::operator==): New function.
(search_symbols): Remove std::vector.
(free_search_symbols, make_cleanup_free_search_symbols): Remove.
(symbol_search::compare_search_syms): Declare.
Dump dynamic relocation info to the map file when generating dynamic
relocation in read-only section relocations if -Map is used.
* elf32-sh.c (readonly_dynrelocs): Dump dynamic relocation
in read-only section with minfo.
(sh_elf_size_dynamic_sections): Likewise.
Dump dynamic relocation info to the map file when generating dynamic
relocation in read-only section relocations if -Map is used.
* elfxx-sparc.c (readonly_dynrelocs): Dump dynamic relocation
in read-only section with minfo.
(_bfd_sparc_elf_size_dynamic_sections): Likewise.
Replace has_got_reloc and has_non_got_reloc in elf_x86_link_hash_entry
with zero_undefweak:
Bit 0: Symbol has no GOT nor PLT relocations.
Bit 1: Symbol has non-GOT/non-PLT relocations in text sections.
zero_undefweak is initialized to 1 and undefined weak symbol should be
resolved to 0 if zero_undefweak > 0.
* elf32-i386.c (elf_i386_check_relocs): Replace has_got_reloc
and has_non_got_reloc with zero_undefweak.
* elf64-x86-64.c (elf_x86_64_check_relocs): Likewise.
* elfxx-x86.c (_bfd_x86_elf_link_hash_newfunc): Initialize
zero_undefweak to 1.
(_bfd_x86_elf_copy_indirect_symbol): Replace has_got_reloc and
has_non_got_reloc with zero_undefweak.
* elfxx-x86.h (UNDEFINED_WEAK_RESOLVED_TO_ZERO): Replace
has_got_reloc and has_non_got_reloc with zero_undefweak.
(elf_x86_link_hash_entry): Likewise.
Add a new ELF backend method to grok FreeBSD NT_PRSTATUS core dump
notes. Define a method for MIPS N32 to override the default
elfcore_grok_freebsd_prstatus that accounts for additional padding
between pr_pid and pr_reg that is not present in other 32-bit FreeBSD
platforms.
* elf-bfd.h (struct elf_backend_data): Add
`elf_backend_grok_freebsd_prstatus'.
* elf.c (elfcore_grok_freebsd_note): Call
`elf_backend_grok_freebsd_prstatus' to handle NT_PRSTATUS if
present.
* elfn32-mips.c (elf_n32_mips_grok_freebsd_prstatus): New
function.
(elf_backend_grok_freebsd_prstatus): Define.
* elfxx-target.h (elf_backend_grok_freebsd_prstatus): Define.
(elfNN_bed): Initialize `elf_backend_grok_freebsd_prstatus'.
This patch moves aarch64-insn.o to arch/aarch64-insn.o. Then, all
arch/*.c are built to arch/*.o, so we don't need a Makefile rule to build
*.o from arch/*.c. This patch removes it too.
gdb:
2017-10-06 Yao Qi <yao.qi@linaro.org>
* Makefile.in (ALL_64_TARGET_OBS): Replace aarch64-insn.o with
arch/aarch64-insn.o.
Remove one rule.
* configure.tgt: Replace aarch64-insn.o with arch/aarch64-insn.o.
It is tested by building GDB for some targets, arm-elf, arm-netbsd,
arm-linux, and aarch64-linux.
gdb:
2017-10-06 Yao Qi <yao.qi@linaro.org>
* Makefile.in (ALL_TARGET_OBS): Replace arm.o, arm-get-next-pcs.o,
and arm-linux.o with arch/arm.o, arch/arm-get-next-pcs.o and
arch/arm-linux.o respectively.
* configure.tgt: Likewise.
This patch changes the build that arch/i386.c is built to arch/i386.o,
instead of i386.o.
gdb:
2017-10-06 Yao Qi <yao.qi@linaro.org>
* Makefile.in (ALL_TARGET_OBS): Rename i386.o to arch/i386.o.
* configure.tgt (i386_tobjs): Replace i386.o with arch/i386.o.
I see a build error when building GDB under msys+mingw gcc 32bit:
g++ -x c++ -std=gnu++11 -g -O2 -I. -I../../../binutils-gdb/gdb/gdbserver -I../../../binutils-gdb/gdb/gdbserver/../common -I../../../binutils-gdb/gdb/gdbserver/../regformats -I../../../binutils-gdb/gdb/gdbserver/.. -I../../../binutils-gdb/gdb/gdbserver/../../include -I../../../binutils-gdb/gdb/gdbserver/../gnulib/import -Ibuild-gnulib-gdbserver/import -Wall -Wpointer-arith -Wno-unused -Wunused-value -Wunused-function -Wno-switch -Wno-char-subscripts -Wempty-body -Wunused-but-set-parameter -Wunused-but-set-variable -Wno-sign-compare -Wno-narrowing -Wno-error=maybe-uninitialized -Wno-format -Werror -DGDBSERVER -c -o win32-low.o -MT win32-low.o -MMD -MP -MF .deps/win32-low.Tpo ../../../binutils-gdb/gdb/gdbserver/win32-low.c
../../../binutils-gdb/gdb/gdbserver/win32-low.c: In function 'BOOL create_process(const char*, char*, DWORD, PROCESS_INFORMATION*)':
../../../binutils-gdb/gdb/gdbserver/win32-low.c:566:48: error: 'get_inferior_cwd' was not declared in this scope
const char *inferior_cwd = get_inferior_cwd ();
^
make[4]: *** [win32-low.o] Error 1
It can be fixed by simply including the right header file.
gdb/gdbserver/ChangeLog:
2017-10-06 Yuanhui Zhang <asmwarrior@gmail.com>
* win32-low.c: Include "common-inferior.h".