H.J. Lu [Fri, 21 Apr 2017 19:03:14 +0000 (12:03 -0700)]
i386: Avoid dynamic symbol with GOT reference in PIE
GOT reference to global symbol in PIE will lead to dynamic symbol. It
becomes a problem when "time" or "times" is defined as a variable in
an executable, clashing with functions of the same name in libc. If
a symbol isn't undefined weak symbol, don't make it dynamic in PIE and
generate R_386_RELATIVE relocation.
bfd/
PR ld/21402
* elf32-i386.c (elf_i386_link_hash_entry): Add
no_finish_dynamic_symbol.
(elf_i386_link_hash_newfunc): Set no_finish_dynamic_symbol to 0.
(elf_i386_allocate_dynrelocs): If a symbol isn't undefined weak
symbol, don't make it dynamic in PIE.
(elf_i386_relocate_section): If a symbol isn't dynamic in PIE,
set no_finish_dynamic_symbol and generate R_386_RELATIVE
relocation for R_386_GOT32
(elf_i386_finish_dynamic_symbol): Abort if no_finish_dynamic_symbol
isn't 0.
ld/
PR ld/21402
* testsuite/ld-elf/indirect.exp: Don't skip PIE indirect5 and
indirect6 tests on i386.
H.J. Lu [Fri, 21 Apr 2017 19:00:55 +0000 (12:00 -0700)]
Require --no-dynamic-linker with -static -E/--dynamic-list
When -static -E/--dynamic-list are passed to linker, linker may create
executable with dynamic sections which aren't supported by run-time.
We require --no-dynamic-linker together with -static -E/--dynamic-list
before adding dynamic symbol table to static executable.
bfd/
PR ld/19617
PR ld/21086
* elflink.c (elf_link_add_object_symbols): Require
--no-dynamic-linker with -E/--dynamic-list when creating
dynamic sections.
ld/
PR ld/19617
PR ld/21086
* testsuite/ld-elf/pr19617a.d: Pass --no-dynamic-linker to ld.
* testsuite/ld-elf/pr19617b.d: Likewise.
* testsuite/ld-elf/pr19617c.d: Likewise.
*testsuite/ld-i386/pr19636-4d.d: Likewise.
* testsuite/ld-elf/readelf.exp: Pass --no-dynamic-linker to ld
with --export-dynamic.
* testsuite/ld-elf/shared.exp: Pass --no-dynamic-linker to ld
with -E.
Jan Kratochvil [Fri, 21 Apr 2017 14:14:37 +0000 (16:14 +0200)]
release branch: Fix: --enable-werror
gdb-8.0-branch
./configure --enable-werror --enable-targets=all
aarch64-tdep.c:3045:13: error: ‘void selftests::aarch64_process_record_test()’ declared ‘static’ but never defined [-Werror=unused-function]
arm-tdep.c:9601:13: error: ‘void selftests::arm_record_test()’ declared ‘static’ but never defined [-Werror=unused-function]
gdb/ChangeLog
2017-04-21 Jan Kratochvil <jan.kratochvil@redhat.com>
* aarch64-tdep.c (selftests::aarch64_process_record_test): Make it #if
GDB_SELF_TEST.
* arm-tdep.c (selftests::arm_record_test): Likewise.
Yao Qi [Fri, 21 Apr 2017 13:59:27 +0000 (14:59 +0100)]
Simplify regcache_restore
This patches removes the 2nd argument of regcache_restore, because it
is only called by regcache_cpy. In regcache_cpy, if regcache_restore
is called, dst is not readonly, but src is readonly. So this patch
adds an assert that src is readonly in regcache_restore.
regcache_cook_read read everything from a readonly regcache cache
(src)'s register_buffer, and register status is from ->register_status.
gdb:
2017-04-21 Yao Qi <yao.qi@linaro.org>
* regcache.c (regcache_restore): Remove argument 2. Replace
argument 3 with regcache. Get register status from
src->register_status and get register contents from
register_buffer (src, regnum).
(regcache_cpy): Update.
Jose E. Marchesi [Fri, 21 Apr 2017 12:19:06 +0000 (05:19 -0700)]
opcodes: mark SPARC RETT instructions as v6notv9.
This prevents the disassembler to show `return' instructions as
`rett' in V9 and later architectures.
opcodes/ChangeLog:
2017-04-21 Jose E. Marchesi <jose.marchesi@oracle.com>
* sparc-opc.c (sparc_opcodes): Mark RETT instructions as v6notv9.
Nick Clifton [Fri, 21 Apr 2017 11:31:59 +0000 (12:31 +0100)]
Fix shift overflow when parsing an overlarge note value.
PR binutils/21378
* readelf.c (print_gnu_build_attribute_name): Check for an
overlarge name field.
Nick Clifton [Fri, 21 Apr 2017 11:18:06 +0000 (12:18 +0100)]
Fix detection of illegal AArch64 opcodes that resemble LD1R, LD2R, LD3R and LD4R.
PR binutils/21380
opcodes * aarch64-tbl.h (aarch64_opcode_table): Fix masks for LD1R, LD2R,
LD3R and LD4R.
gas * testsuite/gas/aarch64/illegal-3.s: New file.
* testsuite/gas/aarch64/illegal-3.d: New file.
GDB Administrator [Fri, 21 Apr 2017 00:00:18 +0000 (00:00 +0000)]
Automatic date update in version.in
H.J. Lu [Thu, 20 Apr 2017 19:33:55 +0000 (12:33 -0700)]
Skip PIE indirect5 and indirect6 tests on i386
On i386, since GOT reference is needed to access global symbols in PIE,
those symbols are made dynamic. Crash happens when there is a reference
to the same global symbol with a different symbol type in a shared
object. Since mixing different types of the same symbol doesn't work in
general, this patch skips those tests on i386 as well as compiles non-PIE
indirect5 and indirect6 tests with $NOPIE_LDFLAGS and $NOPIE_CFLAGS.
PR ld/21402
* testsuite/ld-elf/indirect.exp: Pass $NOPIE_LDFLAGS and
$NOPIE_CFLAGS to non-PIE indirect5 and indirect6 tests. Skip
PIE indirect5 and indirect6 tests on i386.
Maciej W. Rozycki [Thu, 13 Apr 2017 09:26:05 +0000 (10:26 +0100)]
ELF/LD: Always consider STB_LOCAL symbols local
Do not require forced local (STB_LOCAL) symbols to have a definition in
a regular file to be considered to resolve local to the current module,
matching `elf_link_renumber_local_hash_table_dynsyms'. In the absence
of a regular definition any reference to a STB_LOCAL symbol will have to
be garbage collected along with the undefined symbol itself, or the link
will eventually fail. Either way the symbol concerned is not going to
be external.
bfd/
* elflink.c (_bfd_elf_symbol_refs_local_p): Always return TRUE
if forced local.
Maciej W. Rozycki [Thu, 20 Apr 2017 00:39:30 +0000 (01:39 +0100)]
MIPS/LD/testsuite: Join `__ehdr_start' tests
Complement commit
3807734dbe48 ("PR ld/15428: MIPS/LD/testsuite:
Un-KFAIL `__ehdr_start' test 2") and join tests that do not need to be
split anymore.
ld/
* testsuite/ld-mips-elf/mips-elf.exp: Join `__ehdr_start' tests.
Maciej W. Rozycki [Wed, 19 Apr 2017 15:51:17 +0000 (16:51 +0100)]
MIPS/BFD: Reorder comment about dynamic symbol sorting
Move the comment about dynamic symbol sorting next to where it happens.
bfd/
* elfxx-mips.c (_bfd_mips_elf_final_link): Reorder comment about
dynamic symbol sorting.
H.J. Lu [Thu, 20 Apr 2017 14:48:24 +0000 (07:48 -0700)]
Handle symbol defined in IR and referenced in DSO
We need to make an IR symbol visible if it is defined in an IR object
and referenced in a dynamic object. When --as-needed is used, since
linker removes the IR symbol reference of the dynamic object if the
dynamic object isn't needed in the first pass, the IR definition isn't
visible to the dynamic object even if the dynamic object becomes needed
in the second pass. Add dynamic_ref_after_ir_def to bfd_link_hash_entry
to track IR symbol which is defined in an IR object and later referenced
in a dynamic object. dynamic_ref_after_ir_def is preserved when restoring
the symbol table for unneeded dynamic object.
bfd/
PR ld/21382
* elflink.c (elf_link_add_object_symbols): Preserve
dynamic_ref_after_ir_def when restoring the symbol table for
unneeded dynamic object.
include/
PR ld/21382
* bfdlink.h (bfd_link_hash_entry): Add dynamic_ref_after_ir_def.
ld/
PR ld/21382
* plugin.c (is_visible_from_outside): Symbol may be visible
from outside if dynamic_ref_after_ir_def is set.
(plugin_notice): Set dynamic_ref_after_ir_def if the symbol is
defined in an IR object and referenced in a dynamic object.
* testsuite/ld-plugin/lto.exp: Run PR ld/21382 tests.
* testsuite/ld-plugin/pr21382a.c: New file.
* testsuite/ld-plugin/pr21382b.c: Likewise.
GDB Administrator [Thu, 20 Apr 2017 00:00:41 +0000 (00:00 +0000)]
Automatic date update in version.in
H.J. Lu [Wed, 19 Apr 2017 16:59:14 +0000 (09:59 -0700)]
x86-64: Handle undefined IFUNC symbol with -z now
Since undefined IFUNC symbol is treated as normal FUNC symbol, don't
abort on undefined IFUNC symbol in the second PLT.
bfd/
PR ld/21401
* elf64-x86-64.c (elf_x86_64_finish_dynamic_symbol): Don't abort
on on undefined IFUNC symbol in the second PLT.
ld/
PR ld/21401
* testsuite/ld-ifunc/ifunc.exp: Add a libtest-2-now.so test with
-z now.
Pedro Alves [Wed, 19 Apr 2017 12:16:05 +0000 (13:16 +0100)]
gdbthread.h: Fix comment typo
gdb/ChangeLog:
2017-04-19 Pedro Alves <palves@redhat.com>
* gdbthread.h (thread): Add missing closing parenthesis in
comment.
Pedro Alves [Wed, 19 Apr 2017 12:12:23 +0000 (13:12 +0100)]
Fix removing inferiors from within "thread apply" commands
This patch fixes an internal error exposed by a test that does
something like:
define kill-and-remove
kill inferiors 2
remove-inferiors 2
end
# Start one inferior.
start
# Start another inferior.
add-inferior 2
inferior 2
start
# Kill and remove inferior 1 while inferior 2 is selected.
thread apply 1.1 kill-and-remove
The internal error looks like this:
Thread 1.1 (Thread 0x7ffff7fc2700 (LWP 20677)):
[Switching to inferior 1 [process 20677] (gdb/testsuite/outputs/gdb.threads/threadapply/threadapply)]
[Switching to thread 1.1 (Thread 0x7ffff7fc2700 (LWP 20677))]
#0 main () at src/gdb/testsuite/gdb.threads/threadapply.c:38
38 for (i = 0; i < NUM; i++)
src/gdb/inferior.c:66: internal-error: void set_current_inferior(inferior*): Assertion `inf != NULL' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) FAIL: gdb.threads/threadapply.exp: kill_and_remove_inferior: try kill-and-remove: thread apply 1.1 kill-and-remove (GDB internal error)
There are several problems around this area of the code. One is that
in do_restore_current_thread_cleanup, we do a look up of inferior by
ptid, which can find the wrong inferior if the previously selected
inferior exited and some other inferior was started with a reused pid
(rare, but still...).
The other problem is that the "remove-inferiors" command rejects
attempts to remove the current inferior, but when we get to
"remove-inferiors" in a "thread apply THR remove-inferiors 2" command,
the current inferior is the inferior of thread THR, not the previously
selected inferior, so if the previously selected inferior was inferior
2, that command still manages to wipe it, and then gdb restores the
old selected inferior, which is now a dangling pointer...
So the fix here is:
- Make make_cleanup_restore_current_thread store a pointer to the
previously selected inferior directly, and use it directly instead
of doing ptid look ups.
- Add a refcount to inferiors, very similar to thread_info's refcount,
that is incremented/decremented by
make_cleanup_restore_current_thread, and checked before deleting an
inferior. To avoid duplication, a new refcounted_object type is
added, that both thread_info and inferior inherit from.
gdb/ChangeLog:
2017-04-19 Pedro Alves <palves@redhat.com>
* common/refcounted-object.h: New file.
* gdbthread.h: Include "common/refcounted-object.h".
(thread_info): Inherit from refcounted_object and add comments.
(thread_info::incref, thread_info::decref)
(thread_info::m_refcount): Delete.
(thread_info::deletable): Use the refcounted_object::refcount()
method.
* inferior.c (current_inferior_): Add comment.
(set_current_inferior): Increment/decrement refcounts.
(prune_inferiors, remove_inferior_command): Skip inferiors marked
not-deletable instead of comparing with the current inferior.
(initialize_inferiors): Increment the initial inferior's refcount.
* inferior.h (struct inferior): Forward declare.
Include "common/refcounted-object.h".
(current_inferior, set_current_inferior): Move declaration to
before struct inferior's definition, and fix comment.
(inferior): Inherit from refcounted_object. Add comments.
* thread.c (switch_to_thread_no_regs): Reference the thread's
inferior pointer directly instead of doing a ptid lookup.
(switch_to_no_thread): New function.
(switch_to_thread(thread_info *)): New function, factored out
from ...
(switch_to_thread(ptid_t)): ... this.
(restore_current_thread): Delete.
(current_thread_cleanup): Remove 'inf_id' and 'was_removable'
fields, and add 'inf' field.
(do_restore_current_thread_cleanup): Check whether old->inf is
alive instead of looking up an inferior by ptid. Use
switch_to_thread and switch_to_no_thread.
(restore_current_thread_cleanup_dtor): Use old->inf directly
instead of lookup up an inferior by id. Decref the inferior.
Don't restore 'removable'.
(make_cleanup_restore_current_thread): Same the inferior pointer
in old, instead of the inferior number. Incref the inferior.
Don't save/clear 'removable'.
gdb/testsuite/ChangeLog:
2017-04-19 Pedro Alves <palves@redhat.com>
* gdb.threads/threadapply.exp (kill_and_remove_inferior): New
procedure.
(top level): Call it.
* lib/gdb.exp (gdb_define_cmd): New procedure.
Pedro Alves [Wed, 19 Apr 2017 12:12:23 +0000 (13:12 +0100)]
Make inferior::detaching a bool, and introduce scoped_restore::release()
I left making inferior::detaching a bool to a separate patch, because
doing that makes a make_cleanup_restore_integer call in
infrun.c:prepare_for_detach no longer compile (passing a 'bool *' when
an 'int *' is expected). Since we want to get rid of cleanups anyway,
I looked at converting that to a scoped_restore. However,
prepare_for_detach wants to discard the cleanup on success, and
scoped_restore doesn't have an equivalent for that. So I added one --
I called it "release()" because it seems like a natural fit in the way
standard components call similarly-spirited methods, and, it's also
what the proposal for a generic scope guard calls it too, AFAICS:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4189.pdf
I've added some scoped_guard unit tests, while at it.
gdb/ChangeLog:
2017-04-19 Pedro Alves <palves@redhat.com>
* Makefile.in (SUBDIR_UNITTESTS_SRCS): Add
unittests/scoped_restore-selftests.c.
(SUBDIR_UNITTESTS_OBS): Add scoped_restore-selftests.o.
* common/scoped_restore.h (scoped_restore_base): Make "class".
(scoped_restore_base::release): New public method.
(scoped_restore_base::scoped_restore_base): New protected ctor.
(scoped_restore_base::m_saved_var): New protected field.
(scoped_restore_tmpl::scoped_restore_tmpl(T*)): Initialize the
scoped_restore_base base class instead of m_saved_var directly.
(scoped_restore_tmpl::scoped_restore_tmpl(T*, T2)): Likewise.
(scoped_restore_tmpl::scoped_restore_tmpl(const
scoped_restore_tmpl<T>&)): Likewise.
(scoped_restore_tmpl::~scoped_restore_tmpl): Use the saved_var
method.
(scoped_restore_tmpl::saved_var): New method.
(scoped_restore_tmpl::m_saved_var): Delete.
* inferior.h (inferior::detaching): Now a bool.
* infrun.c (prepare_for_detach): Use a scoped_restore instead of a
cleanup.
* unittests/scoped_restore-selftests.c: New file.
Pedro Alves [Wed, 19 Apr 2017 12:06:20 +0000 (13:06 +0100)]
gdb/Makefile.in: Re-sort SUBDIR_UNITTESTS_SRCS/SUBDIR_UNITTESTS_OBS
Note to self: 'o' before 'p'.
gdb/ChangeLog:
2017-04-19 Pedro Alves <palves@redhat.com>
* Makefile.in (SUBDIR_UNITTESTS_SRCS, SUBDIR_UNITTESTS_OBS):
Re-sort in alphabetic order.
Wedson Almeida Filho [Wed, 19 Apr 2017 08:32:53 +0000 (18:02 +0930)]
Correct PE reloc display
* peXXigen.c (pe_print_reloc): Correct chunk_end.
Alan Modra [Tue, 18 Apr 2017 15:56:57 +0000 (01:26 +0930)]
Implement -z dynamic-undefined-weak
-z nodynamic-undefined-weak is only implemented for x86. (The sparc
backend has some support code but doesn't enable the option by
including ld/emulparams/dynamic_undefined_weak.sh, and since the
support looks like it may be broken I haven't enabled it.) This patch
adds the complementary -z dynamic-undefined-weak, extends both options
to affect building of shared libraries as well as executables, and
adds support for the option on powerpc.
include/
* bfdlink.h (struct bfd_link_info <dynamic_undefined_weak>):
Revise comment.
bfd/
* elflink.c (_bfd_elf_adjust_dynamic_symbol): Hide undefweak
or make dynamic for info->dynamic_undefined_weak 0 and 1.
* elf32-ppc.c:Formatting.
(ensure_undefweak_dynamic): Don't make dynamic when
info->dynamic_undefined_weak is zero.
(allocate_dynrelocs): Discard undefweak dyn_relocs for
info->dynamic_undefined_weak. Discard undef dyn_relocs when
not default visibility. Discard undef and undefweak
dyn_relocs earlier.
(ppc_elf_relocate_section): Adjust to suit.
* elf64-ppc.c: Formatting.
(ensure_undefweak_dynamic): Don't make dynamic when
info->dynamic_undefined_weak is zero.
(allocate_dynrelocs): Discard undefweak dyn_relocs for
info->dynamic_undefined_weak. Discard them earlier.
ld/
* ld.texinfo (dynamic-undefined-weak): Document.
(nodynamic-undefined-weak): Document that this option now can
be used with shared libs.
* emulparams/dynamic_undefined_weak.sh: Support -z
dynamic-undefined-weak.
* emulparams/elf32ppccommon.sh: Include dynamic_undefined_weak.sh.
* testsuite/ld-undefined/weak-undef.exp (undef_weak_so),
(undef_weak_exe): New. Use them. Add -z dynamic-undefined-weak
and -z nodynamic-undefined-weak tests.
* Makefile.am: Update powerpc dependencies.
* Makefile.in: Regenerate.
GDB Administrator [Wed, 19 Apr 2017 00:00:40 +0000 (00:00 +0000)]
Automatic date update in version.in
Pedro Alves [Tue, 18 Apr 2017 20:39:25 +0000 (21:39 +0100)]
Eliminate obstack_printf
Not used anywhere.
gdb/ChangeLog:
2017-04-18 Pedro Alves <palves@redhat.com>
* xml-support.c (obstack_xml_printf): Delete.
* xml-support.h (obstack_xml_printf): Delete.
Pedro Alves [Tue, 18 Apr 2017 20:39:25 +0000 (21:39 +0100)]
gdb_xml_parser: make data fields private and make more functions methods
This patch makes the data fields of gdb_xml_parser private, and makes
more functions be gdb_xml_parser methods. This is mostly for better
encapsulation.
Some free functions have their parsing-related guts converted to
methods, while the free functions remain, as they're used as expat
callbacks. Now their only job is to be small shims that restore back
the gdb_xml_parser type, defer work to the corresponding method, and
make sure C++ exceptions don't cross expat.
More C++-fycation of the XML parsers built on top of gdb_xml_parser
could follow, but this was my stopping point.
gdb/ChangeLog:
2017-04-18 Pedro Alves <palves@redhat.com>
* xml-support.c (gdb_xml_parser) <use_dtd, dtd_name, parse,
vdebug, verror, body_text, start_element, end_element, name,
user_data, set_is_xinclude, set_error, expat_parser>: New methods.
<name, user_data, expat_parser, scopes, error, last_line, dtd_name,
is_xinclude>: Make private and add m_ prefix.
(gdb_xml_parser::body_text): New method, based on ...
(gdb_xml_body_text): ... this. Adjust.
(gdb_xml_parser::vdebug): New method, based on ...
(gdb_xml_debug): ... this. Adjust.
(gdb_xml_parser::verror): New method, based on ...
(gdb_xml_error): ... this. Adjust.
(gdb_xml_parser::start_element): New method, based on ...
(gdb_xml_start_element): ... this. Adjust.
(gdb_xml_start_element_wrapper): Defer to
gdb_xml_parser::start_element and gdb_xml_parser::set_error.
(gdb_xml_parser::end_element): New method, based on ...
(gdb_xml_end_element_wrapper): ... this. Adjust.
(gdb_xml_parser::~gdb_xml_parser): Adjust.
(gdb_xml_parser::gdb_xml_parser): Adjust to field renames.
(gdb_xml_parser::use_dtd): New method, based on ...
(gdb_xml_use_dtd): ... this. Adjust.
(gdb_xml_parser::parse): New method, based on ...
(gdb_xml_parse): ... this. Adjust.
(gdb_xml_parse_quick): Adjust to call the parser's parse method.
(xinclude_start_include): Adjust to call the parser's name method.
(xml_xinclude_default, xml_xinclude_start_doctype)
(xml_xinclude_end_doctype): Adjust to call the parser's user_data
method.
(xml_process_xincludes): Adjust to call parser methods.
* xml-support.h (gdb_xml_use_dtd, gdb_xml_parse): Delete
declarations.
Pedro Alves [Tue, 18 Apr 2017 20:39:25 +0000 (21:39 +0100)]
xml-support.c: Use std::string for growing string buffer
This main idea behind this patch is this change to xml-support.c:scope_level
- /* Body text accumulation. This is an owning pointer. */
- struct obstack *body;
+ /* Body text accumulation. */
+ std::string body;
... which allows simplifying other parts of the code.
In target_fetch_description_xml, we want to distinguish between
returning "success + empty std::string" and "no success", and
gdb::optional is a natural fit for that.
gdb/ChangeLog:
2017-04-18 Pedro Alves <palves@redhat.com>
* tracefile-tfile.c (tfile_write_tdesc): Adjust to use
gdb::optional<std::string>.
* xml-support.c: Include <string>.
(scope_level::scope_level(scope_level &&))
(scope_level::~scope_level): Delete.
(scope_level::body): Now a std::string.
(gdb_xml_body_text, gdb_xml_end_element): Adjust.
(xinclude_parsing_data::xinclude_parsing_data): Add 'output'
parameter.
(xinclude_parsing_data::~xinclude_parsing_data): Delete.
(xinclude_parsing_data::output): Now a std::string reference.
(xinclude_start_include): Adjust.
(xml_xinclude_default): Adjust.
(xml_process_xincludes): Add 'output' parameter, and return bool.
* xml-support.h (xml_process_xincludes): Add 'output' parameter,
and return bool.
* xml-tdesc.c: Include <unordered_map> and <string>.
(tdesc_xml_cache): Delete.
(tdesc_xml_cache_s): Delete.
(xml_cache): Now an std::unordered_map.
(tdesc_parse_xml): Adjust to use std::string and unordered_map.
(target_fetch_description_xml): Change return type to
gdb::optional<std::string>, and adjust.
* xml-tdesc.h: Include "common/gdb_optional.h" and <string>.
(target_fetch_description_xml): Change return type to
gdb::optional<std::string>.
Pedro Alves [Tue, 18 Apr 2017 20:39:24 +0000 (21:39 +0100)]
gdb::optional unit tests
I thought I'd add some unit tests to make sure gdb::optional behaved
correctly, and started writing some, but then thought/realized that
libstdc++ already has extensive testing for C++17 std::optional, which
gdb::optional is a subset of, and thought why bother writing something
from scratch. So I tried copying over a subset of libstdc++'s tests
(that ones that cover the subset supported by gdb::optional), and was
positively surprised that they mostly work OOTB. This did help shake
out a few bugs from what I was implementing in the previous patch to
gdb::optional. Still, it's a good chunk of code being copied over, so
if people dislike this copying/duplication, I can drop this patch.
gdb/ChangeLog:
2017-04-18 Pedro Alves <palves@redhat.com>
* Makefile.in (SUBDIR_UNITTESTS_SRCS): Add
unittests/optional-selftests.c.
(SUBDIR_UNITTESTS_OBS): Add optional-selftests.o.
* unittests/optional-selftests.c: New file.
* unittests/optional/assignment/1.cc: New file.
* unittests/optional/assignment/2.cc: New file.
* unittests/optional/assignment/3.cc: New file.
* unittests/optional/assignment/4.cc: New file.
* unittests/optional/assignment/5.cc: New file.
* unittests/optional/assignment/6.cc: New file.
* unittests/optional/assignment/7.cc: New file.
* unittests/optional/cons/copy.cc: New file.
* unittests/optional/cons/default.cc: New file.
* unittests/optional/cons/move.cc: New file.
* unittests/optional/cons/value.cc: New file.
* unittests/optional/in_place.cc: New file.
* unittests/optional/observers/1.cc: New file.
* unittests/optional/observers/2.cc: New file.
Pedro Alves [Tue, 18 Apr 2017 20:39:24 +0000 (21:39 +0100)]
More gdb::optional features
Currently we can't use gdb::optional<T> as function return type,
because gdb::optional's copy ctor is deleted. For example, with:
gdb::optional<int> function ()
{
gdb::optional<int> opt;
....
return opt;
we get:
src/gdb/foo.c: In function ‘gdb::optional<int> foo()’:
src/gdb/foo.c:75:10: error: use of deleted function ‘gdb::optional<T>::optional(const gdb::optional<T>&) [with T = int]’
return opt;
^
In file included from src/gdb/foo.c:68:0:
src/gdb/common/gdb_optional.h:53:3: note: declared here
optional (const optional &other) = delete;
^
I started by fixing that, and then ran into another missing feature,
also fixed by this patch.
The next feature I'm missing most from gdb::optional<T> compared to
std::optional<T> is construction/move/assignment from a T, instead of
having to default construct an gdb::optional and then use
optional::emplace(....).
For example:
gdb::optional<std::string> function ()
{
gdb::optional<std::string> opt;
std::string str;
...
opt.emplace (std::move (str));
return opt;
vs
gdb::optional<std::string> function ()
{
std::string str;
...
return str;
The copy/move ctor/assign methods weren't initialy implemented because
std::optional supports construction from a type U if U is convertible
to T too, and has rules to decide whether the ctors are
explicit/implicit based on that, and rules for whether the ctor should
be trivial or not, etc., which leads to a much more complicated
implementation.
If we stick to supporting copy/move construction/assignment of/to an
optional<T> from exactly only optional<T> and T, then all that
conversion-related complication disappears, and we still gain
convenience in most use cases.
The patch also makes emplace return a reference to the constructor
object, per C++17 std::optional, and adds a reset method, againt
because std::optional has one and it's trivial to support it. These
two changes are a requirement of the gdb::optional unit testing patch
that will follow.
gdb/ChangeLog:
2017-04-18 Pedro Alves <palves@redhat.com>
* common/gdb_optional.h: Include common/traits.h.
(in_place_t): New type.
(in_place): New constexpr variable.
(optional::optional): Remove member initialization of
m_instantiated.
(optional::optional(in_place_t...)): New constructor.
(optional::~optional): Use reset.
(optional::optional(const optional&)): New.
(optional::optional(const optional&&)): New.
(optional::optional(T &)): New.
(optional::optional(T &&)): New.
(operator::operator=(const optional &)): New.
(operator::operator=(optional &&)): New.
(operator::operator= (const T &))
(operator::operator= (T &&))
(operator::emplace (Args &&... args)): Return a T&. Use reset.
(operator::reset): New.
(operator::m_instantiated):: Add in-class initializer.
* common/traits.h: Include <type_traits>.
(struct And): New types.
Pedro Alves [Tue, 18 Apr 2017 20:39:24 +0000 (21:39 +0100)]
xml-support.c: Use std::vector
scope_level::scope_level needed both a move ctor and a dtor explicitly
coded, but those will be eliminated in a following patch.
gdb/ChangeLog:
2017-04-18 Pedro Alves <palves@redhat.com>
* xml-support.c: Include <vector>.
(scope_level::scope_level(const gdb_xml_element *))
(scope_level::scope_level(scope_level&&)): New.
(scope_level::~scope_level): New.
(scope_level_s): Delete.
(gdb_xml_parser::scopes): Now a std::vector.
(gdb_xml_body_text, gdb_xml_start_element, gdb_xml_end_element):
Use std::vector.
(gdb_xml_parser::~gdb_xml_parser): Remove now unnecessary
scope cleanup code.
(gdb_xml_parser::gdb_xml_parser): Remove explicit initialization
of the scopes member. Use std::vector::emplace_back.
Pedro Alves [Tue, 18 Apr 2017 20:39:24 +0000 (21:39 +0100)]
C++-ify gdb/xml-support.c a bit to eliminate cleanups
Basically convert cleanups to destructors in gdb_xml_parser and
xinclude_parsing_data, and then allocate objects of those types on the
stack.
More C++-ification is possible / will follow, but this removes a few
make_cleanup calls already.
gdb/ChangeLog:
2017-04-18 Pedro Alves <palves@redhat.com>
* xml-support.c (gdb_xml_parser): Add ctor/dtor. Make is_xinclude
a bool.
(gdb_xml_end_element): Change type of first parameter.
(gdb_xml_cleanup): Rename to ...
(gdb_xml_parser::~gdb_xml_parser): ... this.
(gdb_xml_create_parser_and_cleanup): Delete with ...
(gdb_xml_parser::gdb_xml_parser): ... creation parts factored out
to this new ctor.
(gdb_xml_parse_quick): Create a local gdb_xml_parser instead of
using gdb_xml_create_parser_and_cleanup.
(xinclude_parsing_data): Add ctor/dtor.
(xml_xinclude_cleanup): Delete.
(xml_process_xincludes): Create a local xinclude_parsing_data
instead of heap-allocating one. Create a local gdb_xml_parser
instead of heap-allocating one with
gdb_xml_create_parser_and_cleanup.
John Baldwin [Tue, 18 Apr 2017 16:44:32 +0000 (09:44 -0700)]
PR threads/20743: Don't attempt to suspend or resume exited threads.
When resuming a native FreeBSD process, ignore exited threads when
suspending/resuming individual threads prior to continuing the process.
gdb/ChangeLog:
PR threads/20743
* fbsd-nat.c (resume_one_thread_cb): Remove.
(resume_all_threads_cb): Remove.
(fbsd_resume): Use ALL_NON_EXITED_THREADS instead of
iterate_over_threads.
GDB Administrator [Tue, 18 Apr 2017 00:00:36 +0000 (00:00 +0000)]
Automatic date update in version.in
H.J. Lu [Mon, 17 Apr 2017 14:47:17 +0000 (07:47 -0700)]
Put soname in the version definition section
commit
902e9fc76a0ec9f642cefa71ef88cca1c675ad54
Author: Maciej W. Rozycki <macro@imgtec.com>
Date: Tue Feb 21 01:46:42 2017 +0000
PR ld/20828: Move symbol version processing ahead of GC symbol sweep
breaks version definition with --version-script --soname. This patch
fixes it by getting soname index before generating the version definition
section.
bfd/
PR ld/21389
* elflink.c (bfd_elf_size_dynamic_sections): Get soname index
before generating the version definition section.
ld/
PR ld/21389
* testsuite/ld-elf/pr21389.map: New file.
* testsuite/ld-elf/pr21389.s: Likewise.
* testsuite/ld-elf/pr21389a.d: Likewise.
* testsuite/ld-elf/pr21389b.d: Likewise.
* testsuite/ld-elf/pr21389c.d: Likewise.
Joel Brobecker [Mon, 17 Apr 2017 14:30:29 +0000 (07:30 -0700)]
Update NEWS post GDB 8.0 branch creation.
gdb/ChangeLog:
* NEWS: Create a new section for the next release branch.
Rename the section of the current branch, now that it has
been cut.
Joel Brobecker [Mon, 17 Apr 2017 14:20:49 +0000 (07:20 -0700)]
Bump version to 8.0.50.DATE-git
Now that the GDB 8.0 branch has been created, we should bump
the GDB version accordingly.
gdb/ChangeLog:
GDB 8.0 branch created (
725bf5cf125783c2a7ca4ab63d3768e220bab2db):
* version.in: Bump version to 7.99.90.DATE-git.
Alan Modra [Mon, 17 Apr 2017 09:03:52 +0000 (18:33 +0930)]
Undo dynamic symbol state after regular object sym type mismatch
We already handle the case of an object file first defining a symbol
that a later shared library also defines where the symbol types are
incompatible. This patch handles the reverse, when a later object
file defines an incompatible symbol defined by an earlier shared
library.
bfd/
* elflink.c (_bfd_elf_merge_symbol): Undo dynamic linking
state when a regular object file defines a symbol with
incompatible type to that defined by an earlier shared lib.
ld/
* testsuite/ld-elf/indirect5a.c,
* testsuite/ld-elf/indirect5b.c,
* testsuite/ld-elf/indirect5.map,
* testsuite/ld-elf/indirect5.out: New test.
* testsuite/ld-elf/indirect6a.c: Likewise.
* testsuite/ld-elf/indirect.exp (check_dynamic_syms): New proc.
Run new tests and check dynsyms.
GDB Administrator [Mon, 17 Apr 2017 00:00:33 +0000 (00:00 +0000)]
Automatic date update in version.in
GDB Administrator [Sun, 16 Apr 2017 00:00:35 +0000 (00:00 +0000)]
Automatic date update in version.in
GDB Administrator [Sat, 15 Apr 2017 00:00:36 +0000 (00:00 +0000)]
Automatic date update in version.in
Sergio Durigan Junior [Fri, 14 Apr 2017 01:01:53 +0000 (21:01 -0400)]
Fix build breakage on Cygwin (PR gdb/21385)
On gdb/windows-nat.c:windows_create_inferior, ALLARGS needs to be
declared independently of the host that we're building for. This
fixes a build breakage on Cygwin.
2017-04-13 Sergio Durigan Junior <sergiodj@redhat.com>
PR gdb/21385
* windows-nat.c (windows_create_inferior): Declare 'allargs'
independently of the host, and fix build breakage on Cygwin.
GDB Administrator [Fri, 14 Apr 2017 00:00:35 +0000 (00:00 +0000)]
Automatic date update in version.in
Pedro Alves [Thu, 13 Apr 2017 15:15:35 +0000 (16:15 +0100)]
Make inferior a class with cdtors, and use new/delete
struct inferior became a non-POD when enum_flags was made a non-POD,
so we should be allocating/destroying inferiors with new/delete, etc.
That's what this commit does.
Note: this commit makes all boolean fields of inferior be "bool",
except the "detaching" field. That'll require more work, so I split
it to a separate patch.
gdb/ChangeLog:
2017-04-13 Pedro Alves <palves@redhat.com>
* inferior.c (free_inferior): Convert to ...
(inferior::~inferior): ... this dtor.
(inferior::inferior): New ctor, factored out from ...
(add_inferior_silent): ... here. Allocate the inferior with a new
expression.
(delete_inferior): Call delete instead of free_inferior.
* inferior.h (gdb_environ, continuation): Forward declare.
(inferior): Now a class. Add in-class initialization to all
members. Make boolean fields bool, except 'detaching'.
(inferior::inferior): New explicit ctor.
(inferior::~inferior): New.
Pedro Alves [Thu, 13 Apr 2017 15:15:34 +0000 (16:15 +0100)]
GC inferior.c:init_inferior_list
Not used anywhere. This was actually never used. It came in because
I originally created inferior.c by copying thread.c, and doing
s/thread/inferior/g, and missed that nothing needs this. :-)
gdb/ChangeLog:
2017-04-13 Pedro Alves <palves@redhat.com>
* inferior.c (init_inferior_list): Delete.
* inferior.h (init_inferior_list): Delete.
Pedro Alves [Thu, 13 Apr 2017 15:15:34 +0000 (16:15 +0100)]
Improve coverage of the PR threads/13217 regression test
- Make sure we end up with no thread selected after the detach.
- Test both "thread apply all" and "thread apply $some_threads", for
completeness.
gdb/ChangeLog:
2017-04-13 Pedro Alves <palves@redhat.com>
PR threads/13217
* gdb.threads/threadapply.exp (thr_apply_detach): New procedure.
(top level): Call it twice, with different thread sets.
Pedro Alves [Thu, 13 Apr 2017 15:15:34 +0000 (16:15 +0100)]
C++fy thread_apply_all_command
This eliminates a couple cleanups.
gdb/ChangeLog:
2017-04-13 Pedro Alves <palves@redhat.com>
* thread.c: Include <algorithm>.
(thread_array_cleanup): Delete.
(scoped_inc_dec_ref): New class.
(live_threads_count): New function.
(set_thread_refcount): Delete.
(tp_array_compar_ascending): Now a bool.
(tp_array_compar): Convert to a std::sort comparison function.
(thread_apply_all_command): Use std::vector and scoped_inc_dec_ref
and live_threads_count.
Pedro Alves [Thu, 13 Apr 2017 15:15:34 +0000 (16:15 +0100)]
Fix follow-fork latent bug
A later patch in the series adds an assertion to switch_to_thread that
the resulting inferior_ptid always matches the "current_inferior()"
inferior. This exposed a latent bug in the follow-fork code, where
we're building the fork child inferior. We're switching
inferior_ptid, but not the current inferior object...
gdb/ChangeLog:
2017-04-13 Pedro Alves <palves@redhat.com>
* infrun.c (follow_fork_inferior): Also switch the current
inferior.
Pedro Alves [Thu, 13 Apr 2017 15:15:34 +0000 (16:15 +0100)]
watch_command_1: Fix dangling frame access
While working on some changes to switch_to_thread, I inadvertently
make switch_to_thread call reinit_frame_cache more frequently, even
when the thread didn't change. This exposed a latent bug in
watch_command_1, where we're referencing a frame after
creating/inserting breakpoints, which potentially calls
reinit_frame_cache if it needs to install breakpoints with a different
thread selected.
Handle this similarly to how it's already handled in other similar
cases. I.e., save any frame-related information we might need before
creating a breakpoint.
gdb/ChangeLog:
2017-04-13 Pedro Alves <palves@redhat.com>
* breakpoint.c (watch_command_1): Save watchpoint-frame info
before calling create_internal_breakpoint.
Nick Clifton [Thu, 13 Apr 2017 15:06:30 +0000 (16:06 +0100)]
readelf: fix out of range subtraction, seg fault from a NULL pointer and memory exhaustion, all from parsing corrupt binaries.
PR binutils/21379
* readelf.c (process_dynamic_section): Detect over large section
offsets in the DT_SYMTAB entry.
PR binutils/21345
* readelf.c (process_mips_specific): Catch an unfeasible memory
allocation before it happens and print a suitable error message.
Nick Clifton [Thu, 13 Apr 2017 13:50:56 +0000 (14:50 +0100)]
Add note merging to strip and add code to merge stack size notes.
* objcopy.c: Add --no-merge-notes option to disable note merging.
Add --[no-]merge-notes option to strip, and enable it by default.
(num_bytes): New function.
(merge_gnu_build_notes): Add code to merge stack size notes.
* binutils.texi: Update strip and objcopy documentation.
* readelf.c (print_gnu_build_attribute_name): Use defined
constants for note types.
Alan Modra [Thu, 13 Apr 2017 01:03:53 +0000 (10:33 +0930)]
Regen cgen files
* epiphany-desc.c: Regenerate.
* fr30-desc.c: Regenerate.
* frv-desc.c: Regenerate.
* ip2k-desc.c: Regenerate.
* iq2000-desc.c: Regenerate.
* lm32-desc.c: Regenerate.
* m32c-desc.c: Regenerate.
* m32r-desc.c: Regenerate.
* mep-desc.c: Regenerate.
* mt-desc.c: Regenerate.
* or1k-desc.c: Regenerate.
* xc16x-desc.c: Regenerate.
* xstormy16-desc.c: Regenerate.
Pedro Alves [Thu, 13 Apr 2017 10:46:07 +0000 (11:46 +0100)]
fork-child.c: Avoid unnecessary heap-allocation / string copying
The previous change to fork-child.c converted the argv building from
an alloca-allocated array of non-owning arg pointers, to a std::vector
of owning pointers, which results in N string dups, with N being the
number of arguments in the vector, and then requires manually
releasing the pointers owned by the vector.
This patch makes the vector hold non-owning pointers, and avoids the
string dups, by doing one single string copy of the arguments upfront,
and replacing separators with NULL terminators in place, like we used
to. All the logic to do that is encapsulated in a new class.
With this, there's no need to remember to manually release the argv
elements with free_vector_argv either.
gdb/ChangeLog:
2017-04-13 Pedro Alves <palves@redhat.com>
* fork-child.c (execv_argv): New class.
(breakup_args): Refactored as ...
(execv_argv::init_for_no_shell): .. this method of execv_argv.
Copy arguments to storage and replace separators with NULL
terminators in place.
(escape_bang_in_quoted_argument): Adjust to return bool.
(execv_argv::execv_argv): New ctor.
(execv_argv::init_for_shell): New method, factored out from
fork_inferior. Don't strdup strings into the vector.
(fork_inferior): Eliminate "shell" local and use execv_argv. Use
Remove free_vector_argv call.
Andrew Jenner [Thu, 13 Apr 2017 09:34:19 +0000 (02:34 -0700)]
* config.sub: Sync with master version in config project.
Iain Buclaw [Thu, 13 Apr 2017 08:39:13 +0000 (10:39 +0200)]
Add ChangeLog entries
ChangeLog entries were left unstaged in my previous commit on March 30th.
Alan Modra [Thu, 13 Apr 2017 03:54:18 +0000 (13:24 +0930)]
Wrap long lines
Not a comprehensive change, just some split out from fixes made for
the %A and %B changes.
* coffcode.h: Wrap some overly long _bfd_error_handler args.
* elf.c: Likewise.
* elf32-arm.c: Likewise.
* elf32-i386.c: Likewise.
* elf32-mep.c: Likewise.
* elf64-ia64-vms.c: Likewise.
* elf64-x86-64.c: Likewise.
* elflink.c: Likewise.
* elfnn-ia64.c: Likewise.
* elfxx-mips.c: Likewise.
Alan Modra [Thu, 13 Apr 2017 03:50:15 +0000 (13:20 +0930)]
Use %A and %B in more error messages
* aoutx.h: Use %B and %A in error messages throughout file.
* aout-cris.c: Likewise.
* archive.c: Likewise.
* binary.c: Likewise.
* coff-rs6000.c: Likewise.
* coff-tic4x.c: Likewise.
* coffcode.h: Likewise.
* coffgen.c: Likewise.
* cofflink.c: Likewise.
* coffswap.h: Likewise.
* cpu-arm.c: Likewise.
* elf-eh-frame.c: Likewise.
* elf-m10300.c: Likewise.
* elf.c: Likewise.
* elf32-arc.c: Likewise.
* elf32-arm.c: Likewise.
* elf32-bfin.c: Likewise.
* elf32-frv.c: Likewise.
* elf32-iq2000.c: Likewise.
* elf32-m32c.c: Likewise.
* elf32-microblaze.c: Likewise.
* elf32-nds32.c: Likewise.
* elf32-rl78.c: Likewise.
* elf32-rx.c: Likewise.
* elf32-score.c: Likewise.
* elf32-score7.c: Likewise.
* elf32-sh64.c: Likewise.
* elf32-v850.c: Likewise.
* elf32-vax.c: Likewise.
* elf32-visium.c: Likewise.
* elf64-ia64-vms.c: Likewise.
* elf64-mmix.c: Likewise.
* elf64-sh64.c: Likewise.
* elfcode.h: Likewise.
* elfnn-aarch64.c: Likewise.
* elfnn-ia64.c: Likewise.
* elfxx-mips.c: Likewise.
* hpux-core.c: Likewise.
* ieee.c: Likewise.
* ihex.c: Likewise.
* linker.c: Likewise.
* merge.c: Likewise.
* mmo.c: Likewise.
* oasys.c: Likewise.
* pdp11.c: Likewise.
* peXXigen.c: Likewise.
* rs6000-core.c: Likewise.
* vms-alpha.c: Likewise.
* xcofflink.c: Likewise.
Alan Modra [Thu, 13 Apr 2017 01:28:40 +0000 (10:58 +0930)]
Rewrite bfd error handler
This steals _doprnt from libiberty, extended to handle %A and %B.
Which lets us do away with the current horrible %A and %B handling
that requires all %A and %B arguments to be passed first, rather than
in the natural order.
* bfd.c (PRINT_TYPE): Define.
(_doprnt): New function.
(error_handler_internal): Use _doprnt.
* coff-arm.c: Put %A and %B arguments to _bfd_error_handler
calls in their natural order, throughout file.
* coff-mcore.c: Likewise.
* coff-ppc.c: Likewise.
* coff-tic80.c: Likewise.
* cofflink.c: Likewise.
* elf-s390-common.c: Likewise.
* elf.c: Likewise.
* elf32-arm.c: Likewise.
* elf32-i386.c: Likewise.
* elf32-m32r.c: Likewise.
* elf32-msp430.c: Likewise.
* elf32-spu.c: Likewise.
* elf64-ia64-vms.c: Likewise.
* elf64-sparc.c: Likewise.
* elf64-x86-64.c: Likewise.
* elflink.c: Likewise.
* elfnn-aarch64.c: Likewise.
* elfnn-ia64.c: Likewise.
* elfxx-mips.c: Likewise.
Alan Modra [Thu, 13 Apr 2017 01:14:20 +0000 (10:44 +0930)]
Missing _bfd_error_handler args
* elf32-arm.c (arm_type_of_stub): Supply missing args to "long
branch veneers" error. Fix double space and format message.
* elf32-avr.c (avr_add_stub): Do not pass NULL as %B arg.
* elf64-ppc.c (tocsave_find): Supply missing %B arg.
Alan Modra [Thu, 13 Apr 2017 01:03:11 +0000 (10:33 +0930)]
Regen bfd-in2.h
* bfd-in2.h: Regenerate.
Yao Qi [Thu, 13 Apr 2017 07:29:44 +0000 (08:29 +0100)]
Fix a typo in rx_fpsw_type
gdb:
2017-04-13 Yao Qi <yao.qi@linaro.org>
* rx-tdep.c (rx_fpsw_type): Check tdep->rx_fpsw_type instead of
tdep->rx_psw_type.
Yao Qi [Thu, 13 Apr 2017 07:29:43 +0000 (08:29 +0100)]
XCNEW gdbarch_tdep in rl78 and rx
"struct gdbarch_tdep" is XNEW'ed in rl78 and rx, so the memory is not
cleared. As the result, tdep->rl78_psw_type is never initialized
properly.
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
if (tdep->rl78_psw_type == NULL)
{
tdep->rl78_psw_type = arch_flags_type (gdbarch,
"builtin_type_rl78_psw", 1);
The bug is found by my unit test in the following patch.
gdb:
2017-04-13 Yao Qi <yao.qi@linaro.org>
* rl78-tdep.c (rl78_gdbarch_init): Use XCNEW instead of XNEW.
* rx-tdep.c (rx_gdbarch_init): Likewise.
Pedro Alves [Thu, 13 Apr 2017 02:07:21 +0000 (03:07 +0100)]
struct breakpoint: Fix indentation
I'm going to need to touch all these fields to add in-class
initialization anyway, might as well take the opportunity to finally
fix this...
gdb/ChangeLog:
2017-04-13 Pedro Alves <palves@redhat.com>
* breakpoint.h (struct breakpoint): Reindent.
Pedro Alves [Thu, 13 Apr 2017 01:12:53 +0000 (02:12 +0100)]
breakpoint.c: bp_location (the array) shadows bp_location (the type)
The bp_location array has the same name as the "struct bp_location",
type preventing refering to the structure without the "struct" inside
breakpoint.c. I.e., we must write:
"new struct bp_location;"
instead of:
"new bp_location"
Rename the array and the associated variables/functions to avoid the
shadowing.
gdb/ChangeLog:
2017-04-13 Pedro Alves <palves@redhat.com>
* breakpoint.c (bp_location): Rename to ...
(bp_locations): ... this. All references updated.
(bp_location_count): Rename to ...
(bp_locations_count): ... this. All references updated.
(bp_location_placed_address_before_address_max): Rename to ...
(bp_locations_placed_address_before_address_max): ... this. All
references updated.
(bp_location_shadow_len_after_address_max): Rename to ...
(bp_locations_shadow_len_after_address_max): ... this. All
references updated.
(bp_location_compare_addrs): Rename to ...
(bp_locations_compare_addrs): ... this. All references updated.
(bp_location_compare):Rename to ...
(bp_locations_compare): ... this. All references updated.
(bp_location_target_extensions_update): Rename to ...
(bp_locations_target_extensions_update): ... this. All references
updated.
GDB Administrator [Thu, 13 Apr 2017 00:00:38 +0000 (00:00 +0000)]
Automatic date update in version.in
Sergio Durigan Junior [Wed, 12 Apr 2017 01:05:12 +0000 (21:05 -0400)]
Create gdb_termios.h (and cleanup gdb/{,gdbserver/}terminal.h)
As requested, I'm sending this as a separate patch because it is ready
to be included as-is.
The idea here is that both gdb/terminal.h and gdb/gdbserver/terminal.h
share the same code, which is responsible for setting a bunch of
defines on based on the presence of termios.h and a few other headers.
This simple patch just moves this common code to common/gdb_termios.h
and makes the necessary adjustments on both GDB and gdbserver so that
they can use this new header. It also implements the some header
checks on common/common.m4.
As a bonus, gdb/gdbserver/terminal.h can be removed because it's now
empty.
Built on x86_64, no regressions found.
gdb/ChangeLog:
2017-04-12 Sergio Durigan Junior <sergiodj@redhat.com>
* Makefile.in (HFILES_NO_SRCDIR): Add "common/gdb_termios.h".
* common/common.m4: Check headers 'termios.h', 'termio.h' and
'sgtty.h'.
* common/gdb_termios.h: New file, with parts of "terminal.h".
* inflow.c: Include "gdb_termios.h".
* ser-unix.c: Include "gdb_termios.h".
* terminal.h: Move terminal-related defines to
"common/gdb_termios.h".
gdb/gdbserver/ChangeLog:
2017-04-12 Sergio Durigan Junior <sergiodj@redhat.com>
* remote-utils.c: Include "gdb_termios.h" instead of
"terminal.h".
* terminal.h: Delete file.
Tom Tromey [Mon, 10 Apr 2017 21:53:22 +0000 (15:53 -0600)]
Change linespec_result::location to be an event_location_up
This is a follow-up to another patch. It changes
linespec_result::location to be an event_location_up.
gdb/ChangeLog
2017-04-12 Tom Tromey <tom@tromey.com>
* probe.c (parse_probes): Update.
* location.h (delete_event_location): Don't declare.
(event_location_deleter::operator()): Update.
* location.c (event_location_deleter::operator()): Rename from
delete_event_location.
* linespec.h (linespec_result) <location>: Change type to
event_location_up.
* linespec.c (canonicalize_linespec, event_location_to_sals)
(decode_objc): Update.
(linespec_result): Don't call delete_event_location.
* breakpoint.c (create_breakpoints_sal)
(bkpt_probe_create_sals_from_location)
(strace_marker_create_sals_from_location): Update.
Tom Tromey [Mon, 10 Apr 2017 21:47:21 +0000 (15:47 -0600)]
Add a constructor and destructor to linespec_result
linespec_result is only ever allocated on the stack, so it's
relatively easy to convert to having a constructor and a destructor.
This patch makes this change. This removes some cleanups.
gdb/ChangeLog
2017-04-12 Tom Tromey <tom@tromey.com>
* linespec.h (struct linespec_result): Add constructor and
destructor.
(init_linespec_result, destroy_linespec_result)
(make_cleanup_destroy_linespec_result): Don't declare.
* linespec.c (init_linespec_result): Remove.
(linespec_result::~linespec_result): Rename from
destroy_linespec_result. Update.
(cleanup_linespec_result, make_cleanup_destroy_linespec_result):
Remove.
* breakpoint.c (create_breakpoint, break_range_command)
(decode_location_default): Update.
* ax-gdb.c (agent_command_1): Update.
Tom Tromey [Mon, 10 Apr 2017 21:41:25 +0000 (15:41 -0600)]
Change breakpoint event locations to event_location_up
This is a follow-up to an earlier patch. It changes breakpoint's
location and location_range_end members to be of type
event_location_up, then fixes up the users.
gdb/ChangeLog
2017-04-12 Tom Tromey <tom@tromey.com>
* remote.c (remote_download_tracepoint): Update.
* python/py-breakpoint.c (bppy_get_location): Update.
* guile/scm-breakpoint.c (bpscm_print_breakpoint_smob)
(gdbscm_breakpoint_location): Update.
* elfread.c (elf_gnu_ifunc_resolver_return_stop): Update.
* breakpoint.h (struct breakpoint) <location, location_range_end>:
Change type to event_location_up.
* breakpoint.c (create_overlay_event_breakpoint)
(create_longjmp_master_breakpoint)
(create_std_terminate_master_breakpoint)
(create_exception_master_breakpoint)
(breakpoint_event_location_empty_p, print_breakpoint_location)
(print_one_breakpoint_location, create_thread_event_breakpoint)
(init_breakpoint_sal, create_breakpoint)
(print_recreate_ranged_breakpoint, break_range_command)
(init_ada_exception_breakpoint, say_where): Update.
(base_breakpoint_dtor): Don't call delete_event_location.
(bkpt_print_recreate, tracepoint_print_recreate)
(dprintf_print_recreate, update_static_tracepoint)
(breakpoint_re_set_default): Update.
Tom Tromey [Fri, 7 Apr 2017 22:05:42 +0000 (16:05 -0600)]
Use std::vector in compile-loc2c.c
This changes compile-loc2c.c to use std::vector in place of a VEC,
allowing the removal of a cleanup.
gdb/ChangeLog
2017-04-12 Tom Tromey <tom@tromey.com>
* compile/compile-loc2c.c (compute_stack_depth_worker): Change
type of "to_do". Update.
(compute_stack_depth): Use std::vector.
Tom Tromey [Fri, 7 Apr 2017 22:01:10 +0000 (16:01 -0600)]
Use std::vector in find_instruction_backward
This changes find_instruction_backward to use std::vector, removing a
cleanup.
gdb/ChangeLog
2017-04-12 Tom Tromey <tom@tromey.com>
* printcmd.c (find_instruction_backward): Use std::vector.
Tom Tromey [Fri, 7 Apr 2017 21:58:25 +0000 (15:58 -0600)]
Use std::vector in reread_symbols
This changes reread_symbols to use std::vector, removing a cleanup.
gdb/ChangeLog
2017-04-12 Tom Tromey <tom@tromey.com>
* symfile.c (objfilep): Remove typedef.
(reread_symbols): Use a std::vector.
Tom Tromey [Fri, 7 Apr 2017 21:37:25 +0000 (15:37 -0600)]
Use scoped_restore in more places
This changes a few more places to use scoped_restore, allowing some
cleanup removals.
gdb/ChangeLog
2017-04-12 Tom Tromey <tom@tromey.com>
* mi/mi-main.c (exec_direction_forward): Remove.
(exec_reverse_continue, mi_execute_command): Use scoped_restore.
* guile/scm-ports.c (ioscm_with_output_to_port_worker): Use
scoped_restore.
* guile/guile.c (guile_repl_command, guile_command)
(gdbscm_execute_gdb_command): Use scoped_restore.
* go-exp.y (go_parse): Use scoped_restore.
* d-exp.y (d_parse): Use scoped_restore.
* cli/cli-decode.c (cmd_func): Use scoped_restore.
* c-exp.y (c_parse): Use scoped_restore.
Tom Tromey [Fri, 7 Apr 2017 21:34:02 +0000 (15:34 -0600)]
C++ify mi_parse
This changes mi_parse to return a unique_ptr, and to use "new"; then
fixes up the users. This allows removing one cleanup.
gdb/ChangeLog
2017-04-12 Tom Tromey <tom@tromey.com>
* mi/mi-parse.h (struct mi_parse): Add constructor, destructor.
(mi_parse): Update return type.
(mi_parse_free): Remove.
* mi/mi-parse.c (mi_parse::mi_parse): New constructor.
(mi_parse::~mi_parse): Rename from mi_parse_free.
(mi_parse_cleanup): Remove.
(mi_parse): Return a unique_ptr. Use new.
* mi/mi-main.c (mi_execute_command): Update.
Tom Tromey [Fri, 7 Apr 2017 05:26:14 +0000 (23:26 -0600)]
Remove some cleanups from location.c
This removes some more cleanups from location.c by using
unique_xmalloc_ptr.
gdb/ChangeLog
2017-04-12 Tom Tromey <tom@tromey.com>
* location.c (explicit_location_lex_one): Return a
unique_xmalloc_ptr.
(string_to_explicit_location): Update. Remove cleanups.
Tom Tromey [Fri, 7 Apr 2017 04:48:27 +0000 (22:48 -0600)]
Remove some cleanups from gnu-v3-abi.c
This removes some cleanups from gnu-v3-abi.c, by using std::vector
rather than VEC.
gdb/ChangeLog
2017-04-12 Tom Tromey <tom@tromey.com>
* gnu-v3-abi.c (value_and_voffset_p): Remove typedef.
(compare_value_and_voffset): Change type. Update.
(compute_vtable_size): Change type of "offset_vec".
(gnuv3_print_vtable): Use std::vector. Remove cleanups.
(gnuv3_get_typeid): Remove extraneous declaration.
Tom Tromey [Fri, 7 Apr 2017 03:07:00 +0000 (21:07 -0600)]
Fix up wchar_iterator comment
This fixes up a comment in charset.h that has been obsolete for a
while.
gdb/ChangeLog
2017-04-12 Tom Tromey <tom@tromey.com>
* charset.h (wchar_iterator): Fix comment.
Tom Tromey [Fri, 7 Apr 2017 02:50:38 +0000 (20:50 -0600)]
Remove cleanup_iconv
This introduces a new "iconv_wrapper" class, to be used in
convert_between_encodings. This allows the removal of cleanup_iconv.
gdb/ChangeLog
2017-04-12 Tom Tromey <tom@tromey.com>
* charset.c (iconv_wrapper): New class.
(cleanup_iconv): Remove.
(convert_between_encodings): Use it.
Tom Tromey [Fri, 7 Apr 2017 02:27:10 +0000 (20:27 -0600)]
Change increment_reading_symtab to return a scoped_restore
This changes increment_reading_symtab to return a scoped_restore, then
fixes up the users.
gdb/ChangeLog
2017-04-12 Tom Tromey <tom@tromey.com>
* symfile.h (increment_reading_symtab): Update type.
* symfile.c (decrement_reading_symtab): Remove.
(increment_reading_symtab): Return a scoped_restore_tmpl<int>.
* psymtab.c (psymtab_to_symtab): Update.
* dwarf2read.c (dw2_instantiate_symtab): Update.
Tom Tromey [Fri, 7 Apr 2017 02:09:42 +0000 (20:09 -0600)]
Introduce gdb_dlhandle_up
This introduces gdb_dlhandle_up, a unique_ptr that can close a
dlopen'd library. All the functions working with dlopen handles are
updated to use this new type.
I did not try to build this on Windows.
gdb/ChangeLog
2017-04-12 Tom Tromey <tom@tromey.com>
* jit.c (struct jit_reader): Declare separately. Add constructor
and destructor. Change type of "handle".
(loaded_jit_reader): Define separately.
(jit_reader_load): Update. New "new".
(jit_reader_unload_command): Use "delete".
* gdb-dlfcn.h (struct dlclose_deleter): New.
(gdb_dlhandle_up): New typedef.
(gdb_dlopen, gdb_dlsym): Update types.
(gdb_dlclose): Remove.
* gdb-dlfcn.c (gdb_dlopen): Return a gdb_dlhandle_up.
(gdb_dlsym): Change type of "handle".
(make_cleanup_dlclose): Remove.
(dlclose_deleter::operator()): Rename from gdb_dlclose.
* compile/compile-c-support.c (load_libcc): Update.
Tom Tromey [Thu, 6 Apr 2017 22:38:56 +0000 (16:38 -0600)]
Change find_pcs_for_symtab_line to return a std::vector
This changes find_pcs_for_symtab_line to return a std::vector. This
allows the removal of some cleanups.
gdb/ChangeLog
2017-04-12 Tom Tromey <tom@tromey.com>
* symtab.h (find_pcs_for_symtab_line): Change return type.
* symtab.c (find_pcs_for_symtab_line): Change return type.
* python/py-linetable.c (build_line_table_tuple_from_pcs): Change
type of "vec". Update.
(ltpy_get_pcs_for_line): Update.
* linespec.c (decode_digits_ordinary): Update.
Tom Tromey [Thu, 6 Apr 2017 03:14:09 +0000 (21:14 -0600)]
Introduce command_line_up
This introduces command_line_up, a unique_ptr for command_line
objects, and changes many places to use it. This removes a number of
cleanups.
Command lines are funny in that sometimes they are reference counted.
Once there is more C++-ification of some of the users, perhaps all of
these can be changed to use shared_ptr instead.
gdb/ChangeLog
2017-04-12 Tom Tromey <tom@tromey.com>
* tracepoint.c (actions_command): Update.
* python/python.c (python_command, python_interactive_command):
Update.
* mi/mi-cmd-break.c (mi_cmd_break_commands): Update.
* guile/guile.c (guile_command): Update.
* defs.h (read_command_lines, read_command_lines_1): Return
command_line_up.
(command_lines_deleter): New struct.
(command_line_up): New typedef.
* compile/compile.c (compile_code_command)
(compile_print_command): Update.
* cli/cli-script.h (get_command_line, copy_command_lines): Return
command_line_up.
(make_cleanup_free_command_lines): Remove.
* cli/cli-script.c (get_command_line, read_command_lines_1)
(copy_command_lines): Return command_line_up.
(while_command, if_command, read_command_lines, define_command)
(document_command): Update.
(do_free_command_lines_cleanup, make_cleanup_free_command_lines):
Remove.
* breakpoint.h (breakpoint_set_commands): Change type of
"commands".
* breakpoint.c (breakpoint_set_commands): Change type of
"commands". Update.
(do_map_commands_command, update_dprintf_command_list)
(create_tracepoint_from_upload): Update.
Tom Tromey [Thu, 6 Apr 2017 02:44:01 +0000 (20:44 -0600)]
Introduce event_location_up
This removes make_cleanup_delete_event_location and instead changes
the various location functions to return an event_location_up, a new
unique_ptr typedef.
This is largely straightforward, but be sure to examine the
init_breakpoint_sal change. I believe the code I deleted there is
dead, because "location != NULL" can never be true in that branch; but
you should double-check.
gdb/ChangeLog
2017-04-12 Tom Tromey <tom@tromey.com>
* tracepoint.c (scope_info): Update.
* spu-tdep.c (spu_catch_start): Update.
* python/python.c (gdbpy_decode_line): Update.
* python/py-finishbreakpoint.c (bpfinishpy_init): Update.
* python/py-breakpoint.c (bppy_init): Update.
* probe.c (parse_probes): Update.
* mi/mi-cmd-break.c (mi_cmd_break_insert_1): Update.
* location.h (event_location_deleter): New struct.
(event_location_up): New typedef.
(new_linespec_location, new_address_location, new_probe_location)
(new_explicit_location, copy_event_location)
(string_to_event_location, string_to_event_location_basic)
(string_to_explicit_location): Update return type.
(make_cleanup_delete_event_location): Remove.
* location.c (new_linespec_location, new_address_location)
(new_probe_location, new_explicit_location, copy_event_location):
Return event_location_up.
(delete_event_location_cleanup)
(make_cleanup_delete_event_location): Remove.
(string_to_explicit_location, string_to_event_location_basic)
(string_to_event_location): Return event_location_up.
* linespec.c (canonicalize_linespec, event_location_to_sals)
(decode_line_with_current_source)
(decode_line_with_last_displayed, decode_objc): Update.
* guile/scm-breakpoint.c (gdbscm_register_breakpoint_x): Update.
* completer.c (location_completer): Update.
* cli/cli-cmds.c (edit_command, list_command): Update.
* breakpoint.c (create_overlay_event_breakpoint)
(create_longjmp_master_breakpoint)
(create_std_terminate_master_breakpoint)
(create_exception_master_breakpoint)
(create_thread_event_breakpoint): Update.
(init_breakpoint_sal): Update. Remove some dead code.
(create_breakpoint_sal): Change type of "location". Update.
(create_breakpoints_sal, create_breakpoint, break_command_1)
(dprintf_command, break_range_command, until_break_command)
(init_ada_exception_breakpoint)
(strace_marker_create_sals_from_location)
(update_static_tracepoint, trace_command, ftrace_command)
(strace_command, create_tracepoint_from_upload): Update.
* break-catch-throw.c (re_set_exception_catchpoint): Update.
* ax-gdb.c (agent_command_1): Update.
Pedro Alves [Wed, 12 Apr 2017 15:00:04 +0000 (16:00 +0100)]
gdb: Move DJGPP/go32 bits to their own tdep file
I posit that this makes them easier to find.
The other day while working on the wchar_t patch, I had a bit of
trouble finding the DJGPP/go32 tdep bits. My initial reaction was
looking for a go32-specific tdep file, but there's none.
Confirmed that a --host=i586-pc-msdosdjgpp GDB still builds
successfully and includes the i386-go32-tdep.o object.
Confirmed that an --enable-targets=all build of GDB on x86-64
GNU/Linux includes the DJGPP/go32 bits too.
gdb/ChangeLog:
2017-04-12 Pedro Alves <palves@redhat.com>
* Makefile.in (ALL_TARGET_OBS): Add i386-go32-tdep.o.
* configure.tgt: Handle i[34567]86-*-go32* and
i[34567]86-*-msdosdjgpp*.
* i386-tdep.c (i386_svr4_reg_to_regnum):
Make extern.
(i386_go32_init_abi, i386_coff_osabi_sniffer): Moved to
i386-go32-tdep.c.
(_initialize_i386_tdep): DJGPP bits moved to i386-go32-tdep.c.
* i386-go32-tdep.c: New file.
* i386-tdep.h (tdesc_i386_mmx, i386_svr4_reg_to_regnum): New
declarations.
Simon Marchi [Wed, 12 Apr 2017 14:46:13 +0000 (10:46 -0400)]
Fix build error in aix-thread.c
Obvious fix for:
aix-thread.c: In function 'char* pd_status2str(int)':
aix-thread.c:163:33: error: deprecated conversion from string constant to 'char*' [-Werror=write-strings]
case PTHDB_SUCCESS: return "SUCCESS";
^
gdb/ChangeLog:
* aix-thread.c (pd_status2str): Change return type to const char *.
Pedro Alves [Fri, 31 Mar 2017 12:41:45 +0000 (13:41 +0100)]
Remove unnecessary set_gdbarch_gnu_triplet_regexp calls
i386_gdbarch_init already does this unconditionally for all x86 ports.
Tested on x86-64 Fedora 23.
gdb/ChangeLog:
2017-04-12 Pedro Alves <palves@redhat.com>
* i386-tdep.c (i386_elf_init_abi, i386_go32_init_abi): Remove
calls to set_gdbarch_gnu_triplet_regexp.
Pedro Alves [Wed, 12 Apr 2017 13:00:49 +0000 (14:00 +0100)]
Teach GDB that wchar_t is a built-in type in C++ mode
GDB is currently not aware that wchar_t is a built-in type in C++
mode. This is usually not a problem because the debug info describes
the type, so when you have a program loaded, you don't notice this.
However, if you try expressions involving wchar_t before a program is
loaded, gdb errors out:
(gdb) p (wchar_t)-1
No symbol table is loaded. Use the "file" command.
(gdb) p L"hello"
No type named wchar_t.
(gdb) ptype L"hello"
No type named wchar_t.
This commit teaches gdb about the type. After:
(gdb) p (wchar_t)-1
$1 = -1 L'\xffffffff'
(gdb) p L"hello"
$2 = L"hello"
(gdb) ptype L"hello"
type = wchar_t [6]
Unlike char16_t/char32_t, unfortunately, the underlying type of
wchar_t is implementation dependent, both size and signness. So this
requires adding a couple new gdbarch hooks.
I grepped the GCC code base for WCHAR_TYPE and WCHAR_TYPE_SIZE, and it
seems to me that the majority of the ABIs have a 4-byte signed
wchar_t, so that's what I made the default for GDB too. And then I
looked for which ports have a 16-bit and/or unsigned wchar_t, and made
GDB follow suit.
gdb/ChangeLog:
2017-04-12 Pedro Alves <palves@redhat.com>
PR gdb/21323
* c-lang.c (cplus_primitive_types) <cplus_primitive_type_wchar_t>:
New enum value.
(cplus_language_arch_info): Register cplus_primitive_type_wchar_t.
* gdbtypes.h (struct builtin_type) <builtin_wchar>: New field.
* gdbtypes.c (gdbtypes_post_init): Create the "wchar_t" type.
* gdbarch.sh (wchar_bit, wchar_signed): New per-arch values.
* gdbarch.h, gdbarch.c: Regenerate.
* aarch64-tdep.c (aarch64_gdbarch_init): Override
gdbarch_wchar_bit and gdbarch_wchar_signed.
* alpha-tdep.c (alpha_gdbarch_init): Likewise.
* arm-tdep.c (arm_gdbarch_init): Likewise.
* avr-tdep.c (avr_gdbarch_init): Likewise.
* h8300-tdep.c (h8300_gdbarch_init): Likewise.
* i386-nto-tdep.c (i386nto_init_abi): Likewise.
* i386-tdep.c (i386_go32_init_abi): Likewise.
* m32r-tdep.c (m32r_gdbarch_init): Likewise.
* moxie-tdep.c (moxie_gdbarch_init): Likewise.
* nds32-tdep.c (nds32_gdbarch_init): Likewise.
* rs6000-aix-tdep.c (rs6000_aix_init_osabi): Likewise.
* sh-tdep.c (sh_gdbarch_init): Likewise.
* sparc-tdep.c (sparc32_gdbarch_init): Likewise.
* sparc64-tdep.c (sparc64_init_abi): Likewise.
* windows-tdep.c (windows_init_abi): Likewise.
* xstormy16-tdep.c (xstormy16_gdbarch_init): Likewise.
gdb/testsuite/ChangeLog:
2017-04-12 Pedro Alves <palves@redhat.com>
PR gdb/21323
* gdb.cp/wide_char_types.c: Include <wchar.h>.
(wchar): New global.
* gdb.cp/wide_char_types.exp (wide_char_types_program)
(do_test_wide_char, wide_char_types_no_program, top level): Add
wchar_t testing.
Pedro Alves [Wed, 12 Apr 2017 13:00:49 +0000 (14:00 +0100)]
Fix PR c++/21323: GDB thinks char16_t and char32_t are signed in C++
While the C++ standard says that char16_t and char32_t are unsigned types:
Types char16_t and char32_t denote distinct types with the same size,
signedness, and alignment as uint_least16_t and uint_least32_t,
respectively, in <cstdint>, called the underlying types.
... gdb treats them as signed currently:
(gdb) p (char16_t)-1
$1 = -1 u'\xffff'
There are actually two places in gdb that hardcode these types:
- gdbtypes.c:gdbtypes_post_init, when creating the built-in types,
seemingly used by the "x /s" command (judging from commit
9a22f0d0).
- dwarf2read.c, when reading base types with DW_ATE_UTF encoding
(which is what is used for these types, when compiling for C++11 and
up). Despite the comment, the type created does end up used.
Both places need fixing. But since I couldn't tell why dwarf2read.c
needs to create a new type, I've made it use the per-arch built-in
types instead, so that the types are only created once per arch
instead of once per objfile. That seems to work fine.
While writting the test, I noticed that the C++ language parser isn't
actually aware of these built-in types, so if you try to use them
without a program that uses them, you get:
(gdb) set language c++
(gdb) ptype char16_t
No symbol table is loaded. Use the "file" command.
(gdb) ptype u"hello"
No type named char16_t.
(gdb) p u"hello"
No type named char16_t.
That's fixed by simply adding a couple entries to C++'s built-in types
array in c-lang.c. With that, we get the expected:
(gdb) ptype char16_t
type = char16_t
(gdb) ptype u"hello"
type = char16_t [6]
(gdb) p u"hello"
$1 = u"hello"
gdb/ChangeLog:
2017-04-12 Pedro Alves <palves@redhat.com>
PR c++/21323
* c-lang.c (cplus_primitive_types) <cplus_primitive_type_char16_t,
cplus_primitive_type_char32_t>: New enum values.
(cplus_language_arch_info): Register cplus_primitive_type_char16_t
and cplus_primitive_type_char32_t.
* dwarf2read.c (read_base_type) <DW_ATE_UTF>: If bit size is 16 or
32, use the archtecture's built-in type for char16_t and char32_t,
respectively. Otherwise, fallback to init_integer_type as before,
but make the type unsigned, and issue a complaint.
* gdbtypes.c (gdbtypes_post_init): Make char16_t and char32_t unsigned.
gdb/testsuite/ChangeLog:
2017-04-12 Pedro Alves <palves@redhat.com>
PR c++/21323
* gdb.cp/wide_char_types.c: New file.
* gdb.cp/wide_char_types.exp: New file.
Alan Hayward [Wed, 12 Apr 2017 08:51:04 +0000 (09:51 +0100)]
Alan Hayward [Wed, 12 Apr 2017 08:19:55 +0000 (09:19 +0100)]
Add M32R_ARG_REGISTER_SIZE
gdb/
* m32r-tdep.c M32R_ARG_REGISTER_SIZE: Added.
(m32r_push_dummy_call): Use M32R_ARG_REGISTER_SIZE.
Sergio Durigan Junior [Wed, 12 Apr 2017 05:16:50 +0000 (01:16 -0400)]
Fix build breakage from last commit (window-nat.c:windows_create_inferior)
Forgot to declare the variable 'toexec' (from
window-nat.c:windows_create_inferior) as 'const char *', which caused
a build breakage.
gdb/ChangeLog:
2017-04-12 Sergio Durigan Junior <sergiodj@redhat.com>
* windows-nat.c (windows_create_inferior): Declare 'toexec' as
'const char *'.
Sergio Durigan Junior [Thu, 23 Mar 2017 01:54:49 +0000 (21:54 -0400)]
C++-fy and prepare for sharing fork_inferior
As a preparation for the next patch, which will move fork_inferior
from GDB to common/ (and therefore share it with gdbserver), it is
interesting to convert a few functions to C++.
This patch touches functions related to parsing command-line arguments
to the inferior (see gdb/fork-child.c:breakup_args), the way the
arguments are stored on fork_inferior (using std::vector instead of
char **), and the code responsible for dealing with argv also on
gdbserver.
I've taken this opportunity and decided to constify a few arguments to
fork_inferior/create_inferior as well, in order to make the code
cleaner. And now, on gdbserver, we're using xstrdup everywhere and
aren't checking for memory allocation failures anymore, as requested
by Pedro:
<https://sourceware.org/ml/gdb-patches/2017-03/msg00191.html>
Message-Id: <
025ebdb9-90d9-d54a-c055-
57ed2406b812@redhat.com>
Pedro Alves wrote:
> On the "== NULL" check: IIUC, the old NULL check was there to
> handle strdup returning NULL due to out-of-memory.
> See NULL checks and comments further above in this function.
> Now that you're using a std::vector, that doesn't work or make
> sense any longer, since if push_back fails to allocate space for
> its internal buffer (with operator new), our operator new replacement
> (common/new-op.c) calls malloc_failure, which aborts gdbserver.
>
> Not sure it makes sense to handle out-of-memory specially in
> the gdb/rsp-facing functions nowadays (maybe git blame/log/patch
> submission for that code shows some guidelines). Maybe (or, probably)
> it's OK to stop caring about it, but then we should consistently remove
> left over code, by using xstrdup instead and remove the NULL checks.
IMO this refactoring was very good to increase the readability of the
code as well, because some parts of the argument handling were
unnecessarily confusing before.
gdb/ChangeLog:
2017-04-12 Sergio Durigan Junior <sergiodj@redhat.com>
* common/common-utils.c (free_vector_argv): New function.
* common/common-utils.h: Include <vector>.
(free_vector_argv): New prototype.
* darwin-nat.c (darwin_create_inferior): Rewrite function
prototype in order to constify "exec_file" and accept a
"std::string" for "allargs".
* fork-child.c: Include <vector>.
(breakup_args): Rewrite function, using C++.
(fork_inferior): Rewrite function header, constify "exec_file_arg"
and accept "std::string" for "allargs". Update the code to
calculate "argv" based on "allargs". Update calls to "exec_fun"
and "execvp".
* gnu-nat.c (gnu_create_inferior): Rewrite function prototype in
order to constify "exec_file" and accept a "std::string" for
"allargs".
* go32-nat.c (go32_create_inferior): Likewise.
* inf-ptrace.c (inf_ptrace_create_inferior): Likewise.
* infcmd.c (run_command_1): Constify "exec_file". Use
"std::string" for inferior arguments.
* inferior.h (fork_inferior): Update prototype.
* linux-nat.c (linux_nat_create_inferior): Rewrite function
prototype in order to constify "exec_file" and accept a
"std::string" for "allargs".
* nto-procfs.c (procfs_create_inferior): Likewise.
* procfs.c (procfs_create_inferior): Likewise.
* remote-sim.c (gdbsim_create_inferior): Likewise.
* remote.c (extended_remote_run): Update code to accept
"std::string" as argument.
(extended_remote_create_inferior): Rewrite function prototype in
order to constify "exec_file" and accept a "std::string" for
"allargs".
* rs6000-nat.c (super_create_inferior): Likewise.
(rs6000_create_inferior): Likewise.
* target.h (struct target_ops) <to_create_inferior>: Likewise.
* windows-nat.c (windows_create_inferior): Likewise.
gdb/gdbserver/ChangeLog:
2017-04-12 Sergio Durigan Junior <sergiodj@redhat.com>
* server.c: Include <vector>.
<program_argv, wrapper_argv>: Convert to std::vector.
(start_inferior): Rewrite function to use C++.
(handle_v_run): Likewise. Update code that calculates the argv
based on the vRun packet; use C++.
(captured_main): Likewise.
GDB Administrator [Wed, 12 Apr 2017 00:00:43 +0000 (00:00 +0000)]
Automatic date update in version.in
H.J. Lu [Tue, 11 Apr 2017 22:41:00 +0000 (15:41 -0700)]
Remove the extra `\n' in warning/error messages
* elf-properties.c (_bfd_elf_parse_gnu_properties): Remove the
extra `\n' in warning/error messages.
* elf32-i386.c (elf_i386_parse_gnu_properties): Likewise.
* elf64-x86-64.c (elf_x86_64_parse_gnu_properties): Likewise.
H.J. Lu [Tue, 11 Apr 2017 22:07:41 +0000 (15:07 -0700)]
Ignore processor-specific GNU program properties
Skip processor-specific GNU program properties with generic ELF target
vector. They should be handled by the matching ELF target vector.
* elf-properties.c (_bfd_elf_parse_gnu_properties): Ignore
processor-specific properties with generic ELF target vector.
Pedro Alves [Tue, 11 Apr 2017 12:57:52 +0000 (13:57 +0100)]
gdb/thread.c: Fix whitespace throughout
gdb/ChangeLog:
2017-04-11 Pedro Alves <palves@redhat.com>
* thread.c: Fix whitespace throughout.
Philipp Rudo [Tue, 11 Apr 2017 13:28:51 +0000 (14:28 +0100)]
Fix read after xfree in linux-nat.c:linux_nat_detach
At the end of linux_nat_detach the main_lwp is deleted (delete_lwp).
This is problematic as during detach (detach_one_lwp and
linux_fork_detach) main_lwp already gets freed. Thus calling
delete_lwp causes a read after free. Fix it by removing the
unnecessary delete_lwp.
gdb/ChangeLog:
2017-04-11 Philipp Rudo <prudo@linux.vnet.ibm.com>
* linux-nat.c (linux_nat_detach): Remove delete_lwp call.
Alan Hayward [Tue, 11 Apr 2017 12:51:58 +0000 (13:51 +0100)]
Remove MAX_REGISTER_SIZE from arm-tdep.c
gdb/
* arm-tdep.c (arm_store_return_value): Use FP_REGISTER_SIZE
Alan Modra [Tue, 11 Apr 2017 10:07:51 +0000 (19:37 +0930)]
PR 21274, ld segfaults linking PE DLL
Don't use fixed size buffers for symbol names.
PR 21274
PR 18466
* emultempl/pe.em (pe_find_data_imports): Don't use fixed size
symbol buffer. Instead, xmalloc max size needed with space for
prefix. Wrap overlong lines. Formatting. Pass symbol buffer
copy of name to pe_walk_relocs_of_symbol.
(make_inport_fixup): Add "name" param, pass to pe_create_import_fixup.
* emultempl/pe.em (pep_find_data_imports): As for pe_find_data_imports.
(make_import_fixup): Add "name" param, pass to pep_create_import_fixup.
Use bfd_get_signed_* and remove unnecessary casts. Formatting.
* pe-dll.c (pe_walk_relocs_of_symbol): Add "name" param. Pass to
callback.
(make_import_fixup_mark): Add "name" param. Make use of prefix
space rather than xmalloc here.
(pe_create_import_fixup): Likewise.
* pe-dll.h (pe_walk_relocs_of_symbol): Update prototype.
(pe_create_import_fixup): Likewise.
* pep-dll.h (pep_walk_relocs_of_symbol): Likewise.
(pep_create_import_fixup): Likewise.
GDB Administrator [Tue, 11 Apr 2017 00:00:28 +0000 (00:00 +0000)]
Automatic date update in version.in
Alan Modra [Mon, 10 Apr 2017 22:13:21 +0000 (07:43 +0930)]
Reorder PPC_OPCODE_* and set PPC_OPCODE_TMR for e6500
PPC_OPCODE_* renumbered to fill the gaps left by previous patches,
and reordered chronologically just because. I kept PPC_OPCODE_TMR
because presumably it might be used in future APUinfo for e6500.
include/
* opcode/ppc.h (PPC_OPCODE_*): Renumber and order chronologically.
(PPC_OPCODE_SPE): Comment on this and other bits used for APUinfo.
opcodes/
* ppc-dis.c (ppc_opts): Formatting. Set PPC_OPCODE_TMR for e6500.
* ppc-opc.c (powerpc_opcodes <mftmr, mttmr>): Remove now
unnecessary E6500.
Alan Modra [Mon, 10 Apr 2017 22:10:24 +0000 (07:40 +0930)]
Bye bye PPC_OPCODE_HTM and -mhtm
The -mhtm option is fairly useless too.
include/
* opcode/ppc.h (PPC_OPCODE_HTM): Delete.
gas/
* config/tc-ppc.c (md_show_usage): Delete mention of -mhtm.
* testsuite/gas/ppc/htm.d: Pass -mpower8 and -Mpower8.
opcodes/
* ppc-dis.c (ppc_opts): Remove PPC_OPCODE_HTM and "htm".
* ppc-opc.c (PPCHTM): Define as PPC_OPCODE_POWER8.
Alan Modra [Mon, 10 Apr 2017 22:06:43 +0000 (07:36 +0930)]
Bye Bye PPC_OPCODE_VSX3
This bit is also useless as it can be replaced with PPC_OPCODE_POWER9.
Defining the VSX2 and VSX3 selection based on cpu bits also lets the
assembler/disassembler distinguish between the power7 VSX opcodes and
the power8 ones. Note that this change means -mvsx now reverts back
to just adding the power7 VSX insns.
include/
* opcode/ppc.h (PPC_OPCODE_VSX3): Delete.
opcodes/
* ppc-dis.c (ppc_opts): Remove PPC_OPCODE_VSX3.
* ppc-opc.c (PPCVSX2): Define as PPC_OPCODE_POWER8.
(PPCVSX3): Define as PPC_OPCODE_POWER9.