Commit Graph

92937 Commits

Author SHA1 Message Date
GDB Administrator c88f7cba81 Automatic date update in version.in 2017-12-04 00:00:26 +00:00
Alan Modra 48f7f3036a Run powerpc vle gas tests for all powerpc ELF targets
* testsuite/gas/ppc/ppc.exp: Don't exclude VLE tests when little-endian.
	* testsuite/gas/ppc/efs.d: Add -mbig to assembler options.
	* testsuite/gas/ppc/efs2.d: Likewise.
	* testsuite/gas/ppc/lsp-checks.d: Likewise.
	* testsuite/gas/ppc/lsp.d: Likewise.
	* testsuite/gas/ppc/spe.d: Likewise.
	* testsuite/gas/ppc/spe2-checks.d: Likewise.
	* testsuite/gas/ppc/spe2.d: Likewise.
	* testsuite/gas/ppc/spe_ambiguous.d: Likewise.
	* testsuite/gas/ppc/vle-mult-ld-st-insns.d: Likewise.
	* testsuite/gas/ppc/vle-reloc.d: Likewise.
	* testsuite/gas/ppc/vle-simple-1.d: Likewise.
	* testsuite/gas/ppc/vle-simple-2.d: Likewise.
	* testsuite/gas/ppc/vle-simple-3.d: Likewise.
	* testsuite/gas/ppc/vle-simple-4.d: Likewise.
	* testsuite/gas/ppc/vle-simple-5.d: Likewise.
	* testsuite/gas/ppc/vle-simple-6.d: Likewise.
	* testsuite/gas/ppc/vle.d: Likewise.
2017-12-04 10:23:57 +10:30
Alan Modra 97d4213f68 Modify ppceabi ld tests to run on all powerpc ELF targets
* testsuite/ld-powerpc/powerpc.exp (ppceabitests): Add -a32 -mbig
	to assembler options, and -melf32ppc to linker options.  Always
	run these tests.
2017-12-04 10:23:57 +10:30
Jim Wilson fed44c60b3 Fix for texinfo 4.8.
gas/
	* doc/c-riscv.texi (RISC-V-Directives): Move @section immediately after
	@node.
2017-12-03 15:14:11 -08:00
Simon Marchi 1e97a22796 Remove mem_region_vector typedef
Now that make-target-delegates understands namespaces and templates,
this typedef is no longer useful.

gdb/ChangeLog:

	* target.h (mem_region_vector): Remove.
	(struct target_ops) <to_memory_map>: Change return type to
	std::vector<mem_region>.
	* target-debug.h (target_debug_print_mem_region_vector): Rename
	to ...
	(target_debug_print_std_vector_mem_region): ... this.
	* target-delegates.c: Re-generate.
2017-12-03 13:06:14 -05:00
Pedro Alves 10f6417841 Make make-target-delegates grok namespace scope op and template params
The next patch will want to use gdb::array_view<int> as parameter type
of a target_ops method.  However, that runs into a
make-target-delegates limitation: target_debug_foo calls in
target-delegates.c for parameters/return types with namespace scope
operators ("::") or template parameters, end up looking like:

 @@ -1313,9 +1313,7 @@ debug_set_syscall_catchpoint (struct target_ops *self, int arg1, int arg2, int a
    fputs_unfiltered (", ", gdb_stdlog);
    target_debug_print_int (arg3);
    fputs_unfiltered (", ", gdb_stdlog);
 -  target_debug_print_int (arg4);
 -  fputs_unfiltered (", ", gdb_stdlog);
 -  target_debug_print_int_p (arg5);
 +  target_debug_print_gdb::array_view<const_int> (arg4);

which obviously isn't something that compiles.  The problem is that
make-target-delegates wasn't ever taught that '::', '<', and '>' can
appear in parameter/return types.  You could work around it by hidding
the unsupported characters behind a typedef in the target method
declaration, or by using an explicit TARGET_DEBUG_PRINTER, but it's
better to just remove the limitation.

While at it, also fix an "abuse" of reserved identifiers.

gdb/ChangeLog:

	* make-target-delegates (munge_type): Also munge '<', '>', and
	':'.  Avoid double underscores in identifiers, and trailing
	underscores.
	* target-debug.h
	(target_debug_print_VEC_static_tracepoint_marker_p__p): Rename to
	...
	(target_debug_print_VEC_static_tracepoint_marker_p_p): ... this.
	* target-delegates.c: Regenerate.
2017-12-03 12:50:43 -05:00
Pedro Alves f0fb2488c9 Fix gdb.threads/process-dies-while-detaching.exp
I noticed [1] a test bug in gdb.threads/process-dies-while-detaching.exp.
Simplified, the test code in question looks somewhat like this:

~~~
  # Detach from a process, and ensure that it exits after detaching.
  # This relies on inferior I/O.

  proc detach_and_expect_exit {test} {

      gdb_test_multiple "detach" $test ....

      set saw_prompt 0
      set saw_inf_exit 0
      while { !$saw_prompt && !$saw_inf_exit } {
          gdb_test_multiple "" $test {
              -re "exited, status=0" {
                  set saw_inf_exit 1
              }
              -re "$gdb_prompt " {
                  set saw_prompt 1
              }
          }
      }

      pass $test
  }
~~~

The bug is in the while loop's condition.  We want to make sure we see
both the inferior output and the prompt, so the loop's test should be:

   -    while { !$saw_prompt && !$saw_inf_exit } {
   +    while { !$saw_prompt || !$saw_inf_exit } {

If we just fix that, the test starts failing though, because it
exposes a couple latent problems:

- When called from test_detach_killed_outside, the parent doesn't
  print "exited, status=0", because in that case the child dies with a
  signal, and so detach_and_expect_exit times out.

  Fix it by making the parent print "signaled, sig=9" in that case,
  and have the .exp expect it.

- When testing against --target_board=native-gdbserver, sometimes we'd
  get this:

    ERROR: Process no longer exists
    ERROR: : spawn id exp9 not open
	while executing
    "expect {
    -i exp8 -timeout 220
	    -i $server_spawn_id
	    eof {
		pass $test
		wait -i $server_spawn_id
		unset server_spawn_id
	    }
	    timeout {
	       ..."
	("uplevel" body line 1)
	invoked from within
    "uplevel $body" NONE : spawn id exp9 not open

  The problem is that:

   - inferior_spawn_id and server_spawn_id are the same when testing
     with gdbserver.
   - gdbserver exits after "detach", so we get an eof for
     $inferior_spawn_id in the loop in detach_and_expect_exit.
     That's the first "ERROR: Process no longer exists".
   - and then when we reach test_server_exit, server_spawn_id
     is already closed (because server_spawn_id==inferior_spawn_id).

  To handle this, make the loop in detach_and_expect_exit use an
  indirect spawn id list and remove $inferior_spawn_id from the list
  as soon as we got the inferior output we're expecting, so that the
  "eof" is left unprocessed until we reach test_server_exit.

[1] I changed GDB in a way that should have made the test fail, but it
    didn't.

gdb/testsuite/ChangeLog:
2017-12-03  Pedro Alves  <palves@redhat.com>

	* gdb.threads/process-dies-while-detaching.c: Include <errno.h>
	and <string.h>.
	(parent_function): Print distinct messages when waitpid fails, or
	the child exits with a signal, or the child exits for an unhandled
	reason.
	* gdb.threads/process-dies-while-detaching.exp
	(detach_and_expect_exit): New 'inf_output_re' parameter and use
	it.  Wait for both inferior output and GDB's prompt.  Use an
	indirect spawn id list.
	(do_detach): New parameter 'child_exit'.  Use it to compute
	expected inferior output.
	(test_detach, test_detach_watch, test_detach_killed_outside):
	Adjust to pass down the expected child exit kind.
2017-12-03 15:32:08 +00:00
Alan Modra f143cb5fc6 Fix "FAIL: VLE relocations 3"
Correct sign extension.

	* ppc-opc.c (extract_li20): Rewrite.
2017-12-03 21:54:47 +10:30
Simon Marchi c0e15c9bfd Remove for_each_inferior_with_data
Remove for_each_inferior_with_data, replacing its sole usage with
for_each_thread.

gdb/gdbserver/ChangeLog:

	* inferiors.c (for_each_inferior_with_data): Remove.
	* inferiors.h (for_each_inferior_with_data): Remove.
	* server.c (handle_qxfer_threads_worker): Change parameter type.
	(handle_qxfer_threads_proper): Use for_each_thread.
2017-12-02 20:38:37 -05:00
Simon Marchi f004534791 Remove for_each_inferior
This patch removes for_each_inferior, replacing all its usages with
for_each_thread.

gdb/gdbserver/ChangeLog:

	* inferiors.c (for_each_inferior): Remove.
	(clear_inferiors): Use for_each_thread.
	* inferiors.h (for_each_inferior): Remove.
	* linux-low.c (linux_wait_for_event_filtered): Use
	for_each_thread.
	(linux_stabilize_threads): Likewise.
	* regcache.c (regcache_release): Likewise.
	* server.c (gdb_wants_all_threads_stopped): Likewise.
	(clear_pending_status_callback): Remove.
	(handle_status): Use for_each_thread.
	(captured_main): Likewise.
	* win32-low.c (child_init_thread_list): Likewise.
	(win32_clear_inferiors): Likewise.
	(fake_breakpoint_event): Likewise.
2017-12-02 20:37:53 -05:00
Simon Marchi 9521758bf9 Remove find_inferior
All the usages of find_inferior were removed, so the function itself can
be removed.

gdb/gdbserver/ChangeLog:

	* inferiors.h (find_inferior): Remove.
	* inferiors.c (find_inferior): Remove.
2017-12-02 20:36:45 -05:00
Simon Marchi 8f86d7aa85 Update comments
These functions were modified in the previous patch series, but I forgot
to update some comments.

gdb/gdbserver/ChangeLog:

	* linux-low.c (resume_status_pending_p): Update comment.
	(need_step_over_p): Update comment.
2017-12-02 20:36:44 -05:00
Simon Marchi e2b4407579 Remove usages of find_inferior that call proceed_one_lwp
Replace with for_each_thread.

gdb/gdbserver/ChangeLog:

	* linux-low.c (proceed_one_lwp): Return void, change parameter
	type.
	(unsuspend_and_proceed_one_lwp): Likewise.
	(proceed_all_lwps): Use for_each_thread.
	(unstop_all_lwps): Likewise.
2017-12-02 20:36:43 -05:00
Simon Marchi c80825ff32 Remove usage of find_inferior in linux_resume
Replace with for_each_thread.

gdb/gdbserver/ChangeLog:

	* linux-low.c (linux_resume_one_thread): Return void, take
	parameter directly.
	(linux_resume): Use for_each_thread.
2017-12-02 20:36:42 -05:00
Simon Marchi df3e4dbe66 Remove usages of find_inferior in stop_all_lwps
Replace with for_each_thread.

gdb/gdbserver/ChangeLog:

	* linux-low.c (send_sigstop_callback): Return void, change
	parameter type.  Rename to...
	(send_sigstop): ... this.
	(suspend_and_send_sigstop_callback): Return void, change parameter
	type.  Rename to...
	(suspend_and_send_sigstop): ... this.
	(stop_all_lwps): Use for_each_thread.
2017-12-02 20:36:42 -05:00
Simon Marchi 5a6b0a41df Remove usage of find_inferior in linux_stabilize_threads
Replace with find_thread.

gdb/gdbserver/ChangeLog:

	* linux-low.c (lwp_running): Return bool, remove unused
	argument.
	(linux_stabilize_threads): Use find_thread.
2017-12-02 20:36:41 -05:00
Simon Marchi 39a64da5fc Remove usages of find_inferior in select_event_lwp
Replace with find_thread/for_each_thread.  I inlined the callbacks,
because they are relatively simple.

gdb/gdbserver/ChangeLog:

	* linux-low.c (select_singlestep_lwp_callback): Remove.
	(count_events_callback): Remove.
	(select_event_lwp_callback): Remove.
	(select_event_lwp): Use find_thread/for_each_thread.
2017-12-02 20:36:40 -05:00
Simon Marchi a1385b7b88 Remove usages of find_inferior calling not_stopped_callback
Replace with find_thread.  Writing a lambda inline in directly in the if
conditions would be a bit messy, so I chose to assign them to variables
instead.

gdb/gdbserver/ChangeLog:

	* linux-low.c (not_stopped_callback): Return bool, take filter
	argument directly.
	(linux_wait_for_event_filtered): Use find_thread.
	(linux_wait_1): Likewise.
2017-12-02 20:36:39 -05:00
Simon Marchi 454296a2c1 Remove usage of find_inferior in find_lwp_pid
Replace with find_thread.  We could almost use find_thread_ptid, except
that find_lwp_pid uses the pid of the input ptid of the lwp is 0, so the
behavior is not quite the same.

gdb/gdbserver/ChangeLog:

	* linux-low.c (same_lwp): Remove.
	(find_lwp_pid): Use find_thread.
2017-12-02 20:36:38 -05:00
Simon Marchi 6b2a85daf5 Remove usage of find_inferior in linux_mourn
Replace with for_each_thread with pid filtering.  The callback becomes
trivial enough that it's better to inline it.

gdb/gdbserver/ChangeLog:

	* linux-low.c (delete_lwp_callback): Remove.
	(linux_mourn): Use for_each_thread.
2017-12-02 20:36:37 -05:00
Simon Marchi 798a38e8de Remove usage of find_inferior in linux_detach
Replace with for_each_thread with pid filtering.

gdb/gdbserver/ChangeLog:

	* linux-low.c (linux_detach_lwp_callback): Return void, remove
	args parameter, don't check for pid.
	(linux_detach): Use for_each_thread.
2017-12-02 20:36:36 -05:00
Simon Marchi e4eb0dec0b Remove usage of find_inferior in last_thread_of_process_p
Replace it with find_thread.  I also modified the code a bit to use a
lambda and a boolean.

gdb/gdbserver/ChangeLog:

	* linux-low.c (struct counter): Remove.
	(second_thread_of_pid_p): Remove.
	(last_thread_of_process_p): Use find_thread.
2017-12-02 20:36:36 -05:00
Simon Marchi 83e1b6c13a Remove find_inferior_in_random
Replace with find_thread_in_random.

gdb/gdbserver/ChangeLog:

	* inferiors.c (find_inferior_in_random): Remove.
	* inferiors.h (find_inferior_in_random): Remove.
	* linux-low.c (status_pending_p_callback): Return bool, accept
	parameter ptid directly.
	(linux_wait_for_event_filtered): Use find_thread_in_random.
	(linux_wait_1): Likewise.
2017-12-02 20:36:35 -05:00
Simon Marchi 8dc7b443a6 Remove find_inferior_id
Remove find_inferior_id, replacing its usages with find_thread_ptid.
find_thread_ptid was implemented using find_inferior_id, so move the
implementation there instead.

gdb/gdbserver/ChangeLog:

	* inferiors.c (find_inferior_id): Remove.
	(find_thread_ptid): Move implemention from find_inferior_id to
	here.
	* inferiors.h (find_inferior_id): Remove.
	* server.c (handle_status): Use find_thread_ptid.
	(process_serial_event): Likewise.
	* thread-db.c (find_one_thread): Likewise.
	(thread_db_thread_handle): Likewise.
	* win32-low.c (thread_rec): Likewise.
	(child_delete_thread): Likewise.
	(win32_thread_alive): Likewise.
	(get_child_debug_event): Likewise.
2017-12-02 20:36:34 -05:00
Simon Marchi da25033cd9 Remove usages of find_inferior in linux-mips-low.c
Replace with for_each_thread with pid filtering.  This allows
simplifying the callback a little bit.

gdb/gdbserver/ChangeLog:

	* linux-mips-low.c (update_watch_registers_callback): Return
	void, remove pid_p parameter, don't check for pid.
	(mips_insert_point, mips_remove_point): Use for_each_thread.
2017-12-02 20:36:33 -05:00
Simon Marchi c91bb56b06 Remove usage of find_inferior in lynx_mourn
Replace it with for_each_thread with pid filtering.  We can remove
lynx_delete_thread_callback and pass remove_thread directly.

I can't build/test this change, but it should be obvious enough.

gdb/gdbserver/ChangeLog:

	* lynx.low (lynx_delete_thread_callback): Remove.
	(lynx_mourn): Use for_each_thread.
2017-12-02 20:36:32 -05:00
Simon Marchi 634a3254c8 Remove usage of find_inferior in regcache_invalidate_pid
Replace with for_each_thread with pid filtering.
regcache_invalidate_one is not longer needed, as it was only used to
filter the pid.  We can call regcache_invalidate_thread directly.

gdb/gdbserver/ChangeLog:

	* regcache.c (regcache_invalidate_one): Remove.
	(regcache_invalidate_pid): use for_each_thread.
2017-12-02 20:36:32 -05:00
Simon Marchi 6d83e819df Fix typo in poison.h
gdb/ChangeLog:

	* common/poison.h (XDELETE): Fix typo.
2017-12-02 20:28:41 -05:00
GDB Administrator 035d856f2c Automatic date update in version.in 2017-12-03 00:00:36 +00:00
Cary Coutant 222b39c283 Handle case where posix_fallocate is not supported for a filesystem.
2017-12-02  Vladimir Kondratyev  <vladimir@kondratyev.su>
	    Cary Coutant  <ccoutant@gmail.com>

gold/
	PR gold/22540
	* output.cc (gold_fallocate): Trivial return for len == 0.
	Add fallback options when posix_fallocate and fallocate return
	not-supported errors.
2017-12-02 09:56:40 -08:00
Cary Coutant 158600eb98 Disallow --incremental with -pie and force -no-pie for incremental tests.
This is a partial fix for the gold testsuite failures documented in
PR 21090. The use of -fpie triggers some mov-to-lea optimizations that
are not compatible with incremental linking, so those optimizations need
to be disabled. We also diagnose the attempt to use -pie with incremental
linking, and force -no-pie for the incremental tests in case the build has
been configured to have GCC pass -pie all the time.

We still have a problem where compiling with -fpie results in some GOT
entries even when linking with -no-pie. This combination still causes test
failures because we are not updating the GOT entries in an incremental update
link.

gold/
	PR gold/21090
	* incremental.cc (Sized_relobj_incr::do_relocate): Fix comment.
	* options.cc (General_options::finalize): Disallow -pie with
	incremental linking.
	* x86_64.cc (Target_x86_64::Scan::local): Don't do mov-to-lea
	or callq-to-direct optimizations for incremental links.
	(Target_x86_64::Scan::global): Likewise.
	(Target_x86_64::Relocate::relocate): Likewise.
	* testsuite/Makefile.am (incremental_test): Force -no-pie.
	(incremental_test_2): Likewise.
	(incremental_test_3): Likewise.
	(incremental_test_4): Likewise.
	(incremental_test_5): Likewise.
	(incremental_test_6): Likewise.
	(incremental_copy_test): Likewise.
	(incremental_common_test_1): Likewise.
	(incremental_comdat_test_1):  Likewise.
	* testsuite/Makefile.in: Regenerate.
2017-12-01 23:46:03 -08:00
Cary Coutant 0af4ccfc5b Workaround GCC 7 bug with debug line numbers causing debug_msg.sh failure.
gold/
	PR gold/21841
	* testsuite/debug_msg.sh: Adjust expected line numbers.
	* testsuite/odr_violation2.cc (DummyFunction): New function.
2017-12-01 22:53:08 -08:00
Cary Coutant 059256c746 Fix incremental linking failure with GCC 7+.
With the new compiler, we're running out of patch space for the .eh_frame
section. To workaround that issue, we compile the before and after versions
both with no unwind tables.

gold/
	PR gold/22309
	* testsuite/Makefile.am (two_file_test_1_v1_ndebug.o): Compile with
	no EH information.
	(two_file_test_1_ndebug.o): Likewise.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/two_file_test_1.cc: Touch to force recompilation with new
	flags.
	* testsuite/two_file_test_1_v1.cc: Likewise.
2017-12-01 22:03:09 -08:00
Sergio Durigan Junior 97cbe998d0 Add support for the readnever concept
The purpose of this concept is to turn the load of debugging
information off, either globally (via the '--readnever' option), or
objfile-specific.  The implementation proposed here is an extension of
the patch distributed with Fedora GDB; looking at the Fedora patch
itself and the history, one can see some reasons why it was never
resubmitted:

  - The patch appears to have been introduced as a workaround, at
    least initially;
  - The patch is far from perfect, as it simply shunts the load of
    DWARF debugging information, without really worrying about the
    other debug format.
  - Who really does non-symbolic debugging anyways?

One use of this feature is when a user simply wants to do the
following sequence: attach, dump core, detach.  Loading the debugging
information in this case is an unnecessary cause of delay.

This patch expands the version shipped with Fedora GDB in order to
make the feature available for all the debuginfo backends, not only
for DWARF.  It also implements a per-objfile flag which can be
activated by using the "-readnever" command when using the
'add-symbol-file' or 'symbol-file' commands.

It's also worth mentioning that this patch tests whether GDB correctly
fails to initialize if both '--readnow' and '--readnever' options are
passed.

Tested on the BuildBot.

gdb/ChangeLog:

2017-12-01  Andrew Cagney  <cagney@redhat.com>
	    Joel Brobecker  <brobecker@adacore.com>
	    Sergio Durigan Junior  <sergiodj@redhat.com>

	* NEWS (Changes since GDB 8.0: Mention new '--readnever'
	feature.
	* coffread.c (coff_symfile_read): Do not map over sections with
	'coff_locate_sections' if readnever is on.
	* dwarf2read.c (dwarf2_has_info): Return 0 if
	readnever is on.
	* elfread.c (elf_symfile_read): Do not map over sections with
	'elf_locate_sections' if readnever is on.
	* main.c (validate_readnow_readnever): New function.
	(captured_main_1): Add support for --readnever.
	(print_gdb_help): Document --readnever.
	* objfile-flags.h (enum objfile_flag) <OBJF_READNEVER>: New
	flag.
	* symfile.c (readnever_symbol_files): New global.
	(symbol_file_add_with_addrs): Set 'OBJF_READNEVER' when
	'READNEVER_SYMBOL_FILES' is set.
	(validate_readnow_readnever): New function.
	(symbol_file_command): Handle '-readnever' option.
	Call 'validate_readnow_readnever'.
	(add_symbol_file_command): Handle '-readnever' option.
	Call 'validate_readnow_readnever'.
	(_initialize_symfile): Document new '-readnever' option for
	both 'symbol-file' and 'add-symbol-file' commands.
	* top.h (readnever_symbol_files): New extern global.
	* xcoffread.c (xcoff_initial_scan): Do not read debug
	information if readnever is on.

gdb/doc/ChangeLog:

2017-12-01  Andrew Cagney  <cagney@redhat.com>
	    Joel Brobecker  <brobecker@adacore.com>
	    Sergio Durigan Junior  <sergiodj@redhat.com>

	* gdb.texinfo (File Options): Document --readnever.
	(Commands to Specify Files): Likewise, for 'symbol-file' and
	'add-symbol-file'.

gdb/testsuite/ChangeLog:

2017-12-01  Joel Brobecker  <brobecker@adacore.com>
	    Sergio Durigan Junior  <sergiodj@redhat.com>
	    Pedro Alves  <palves@redhat.com>

	* gdb.base/readnever.c, gdb.base/readnever.exp: New files.
2017-12-01 21:28:31 -05:00
GDB Administrator 754fa8997d Automatic date update in version.in 2017-12-02 00:00:25 +00:00
Jim Wilson b57e49f726 Update and clean up RISC-V gas documentation.
gas/
	* doc/as.texinfo (RISC-V): Alphabetize RISC-V entries.  Change
	RISC-V-Opts to RISC-V-Options.  Delete redundant space.  Add -fpic
	and related options to option list.
	* doc/c-riscv.texi: (RISC-V-Options): Renamed from RISC-V-Opts.
	(RISC-V Options): Renamed from Options.  Add missing period.
	(-fpic): Also mention -fPIC.
	(RISC-V Directives): New node.
2017-12-01 15:34:42 -08:00
Sergio Durigan Junior 40fc416f4e Make '{add-,}symbol-file' not care about the position of command line arguments
This is a bug that's been detected while doing the readnever work.

If you use 'symbol-file' or 'add-symbol-file', the position of each
argument passed to the command matters.  This means that if you do:

  (gdb) symbol-file -readnow /foo/bar

The symbol file specified will (correctly) have all of its symbols
read by GDB (because of the -readnow flag).  However, if you do:

  (gdb) symbol-file /foo/bar -readnow

GDB will silently ignore the -readnow flag, because it was specified
after the filename.  This is not a good thing to do and may confuse
the user.

To address that, I've modified the argument parsing mechanisms of
symbol_file_command and add_symbol_file_command to be
"position-independent".  I have also added one error call at the end
of add_symbol_file_command's argument parsing logic, which now clearly
complains if no filename has been specified.  Both commands now
support the "--" option to stop argument processing.

This patch provides a testcase for both commands, in order to make
sure that the argument order does not matter.  It has been
regression-tested on BuildBot.

gdb/ChangeLog:

2017-12-01  Sergio Durigan Junior  <sergiodj@redhat.com>

	* symfile.c (symbol_file_command): Call
	'symbol_file_add_main_1' only after processing all command
	line options.
	(add_symbol_file_command): Modify logic to make arguments
	position-independent.

gdb/testsuite/ChangeLog:

2017-12-01  Sergio Durigan Junior  <sergiodj@redhat.com>

	* gdb.base/relocate.exp: Add tests to guarantee that arguments
	to 'symbol-file' and 'add-symbol-file' can be
	position-independent.
2017-12-01 17:01:24 -05:00
Sergio Durigan Junior 7f0f8ac8b1 Revert "Add support for the readnever concept"
This reverts commit e2e321740c.

It was mistakenly pushed.
2017-12-01 16:58:47 -05:00
Cary Coutant 7ef67ba533 Fix localized help string output for -fuse-ld.
gold/
	PR gold/22042
	* options.h (-fuse-ld): Use NULL instead of empty string.
2017-12-01 13:45:27 -08:00
Joel Brobecker ec6a20c268 (Ada) GDB crash printing expression with type casting
One of our users reported that trying to print the following expression,
caused GDB to SEGV:

    (gdb) print some_package.some_type (val)

In this particular instance, the crash occurred inside ada_args_match
because it is given a NULL "func", leading to the SEGV because of:

    struct type *func_type = SYMBOL_TYPE (func);

This NULL symbol comes from a list of symbols which was given to
ada_resolve_function (parameter called "syms") which then iterates
over each of them to discard the ones that don't match the actuals:

     for (k = 0; k < nsyms; k += 1)
       {
         struct type *type = ada_check_typedef (SYMBOL_TYPE (syms[k].symbol));

         if (ada_args_match (syms[k].symbol, args, nargs)
             && (fallback || return_match (type, context_type)))
         [...]
       }

What's really interesting is that, when entering the block above for
the first time, all entries in SYMS have a valid (non-NULL) symbol.
However, once we return from the call to ada_check_typedef, the first
entry of our SYMS table gets set to all zeros:

    (gdb) p syms[0]
    $2 = {symbol = 0x0, block = 0x0}

Hence the call to ada_args_match with a NULL symbol, and the ensuing
SEGV.

To find out why this happen, we need to step back a little and look
at how syms was allocated. This list of symbols comes from a symbol
lookup, which means ada_lookup_symbol_list_worker. We have our first
hint when we look at the function's documentation and see:

    This vector is transient---good only to the next call of
    ada_lookup_symbol_list.

Implementation-wise, this is done by using a static global obstack,
which we just re-initialize each time ada_lookup_symbol_list_worker
gets called:

    obstack_free (&symbol_list_obstack, NULL);
    obstack_init (&symbol_list_obstack);

This property was probably established in order to facilitate the use
of the returned vector, since the users of that function would not have
to worry about releasing that memory when no longer needed. However,
I found during this investigation that it is all to easy to indirectly
trigger another symbol lookup while still using the results of a previous
lookup.

In our particular case, there is the call to ada_check_typedef, which
leads to check_typedef. As it happens, my first symbol had a type which
was a typedef to a stub type, so check_typedef calls lookup_symbol to
find the non-stub version. This in turn eventually leads us back to
ada_lookup_symbol_list_worker, where the first thing it does is free
the memory area when our list of symbols have been residing and then
recreates a new one. in other words, SYMS then becomes a dangling
pointer!

This patch fixes the issue by having ada_lookup_symbol_list_worker
return a copy of the list of symbols, with the responsibility of
deallocating that list now transfered to the users of that list.

More generally speaking, it is absolutely amazing that we haven't seen
consequences of this issue before. This can happen fairly frequently.
For instance, I found that ada-exp.y::write_var_or_type calls
ada_lookup_symbol_list, and then, while processing that list, calls
select_possible_type_sym, which leads to ada_prefer_type, eventually
leading to ada_check_typedef again (via eg. ada_is_array_descriptor_type).

Even more amazing is the fact that, while I was able to produce multiple
scenarios where the corruption occurs, none of them leads to incorrect
behavior at the user level. In other words, it requires a very precise
set of conditions for the corruption to become user-visible, and
despite having a megalarge program where the crash occured, using that
as a template for creating a reproducer did not work (pb goes away).
This is why this patch does not come with a reproducer. On the other hand,
this should not be a problem in terms of testing coverage, as the changes
are made in common areas which, at least for the most part, are routinely
exercised during testing.

gdb/ChangeLog:

        * ada-lang.c (symbol_list_obstack): Delete.
        (resolve_subexp): Make sure "candidates" gets xfree'ed.
        (ada_lookup_symbol_list_worker): Remove the limitation that
        the result is only good until the next call, now making it
        the responsibility of the caller to free the result when no
        longer needed.  Adjust the function's intro comment accordingly.
        (ada_lookup_symbol_list): Adjust the function's intro comment.
        (ada_iterate_over_symbols): Make sure "results" gets xfree'ed.
        (ada_lookup_encoded_symbol, get_var_value): Likewise.
        (_initialize_ada_language): Remove symbol_list_obstack
        initialization.
        * ada-exp.y (block_lookup): Make sure "syms" gets xfree'ed.
        (write_var_or_type, write_name_assoc): Likewise.

Tested on x86_64-linux.
2017-12-01 16:18:30 -05:00
Benjamin Peterson bd2e3511f7 Fix internal error from command line with unbalanced --start-lib/--end-lib.
The problem is that while the command line isn't trivially empty,
it contains no input files. As gold tries to configure the number
of threads to use based on the number of input files, this causes
the assertion failure above. Fix this problem by making the logic
in gold.cc more robust and also adding a better error message
about --start-lib to options.cc.

gold/
	PR gold/22406
	* gold.cc (queue_initial_tasks) Check for number of real input files.
	* options.cc (Command_line::process) Check for unterminated --start-lib
	options.
	* testsuite/Makefile.am: Add new test script.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/check_empty_command_lines.sh: New test script.
2017-12-01 12:59:36 -08:00
Stephen Crane 71739b698d Fix problem where undef can fail to trigger archive rescan.
If a shared library contains an undefined symbol and LTO adds
a new reference to that same undefined symbol, the reference in the new
object added by the plugin would not trigger a rescan of the archive
containing the symbol.

2017-11-17  Stephen Crane  <sjc@immunant.com>

gold/
	PR gold/22448
	* symtab.cc (Symbol_table::add_from_object): Only rescan for
	undefined symbols in regular, not dynamic, objects.
2017-12-01 12:10:02 -08:00
Sergio Durigan Junior e2e321740c Add support for the readnever concept
The purpose of this concept is to turn the load of debugging
information off, either globally (via the '--readnever' option), or
objfile-specific.  The implementation proposed here is an extension of
the patch distributed with Fedora GDB; looking at the Fedora patch
itself and the history, one can see some reasons why it was never
resubmitted:

  - The patch appears to have been introduced as a workaround, at
    least initially;
  - The patch is far from perfect, as it simply shunts the load of
    DWARF debugging information, without really worrying about the
    other debug format.
  - Who really does non-symbolic debugging anyways?

One use of this feature is when a user simply wants to do the
following sequence: attach, dump core, detach.  Loading the debugging
information in this case is an unnecessary cause of delay.

This patch expands the version shipped with Fedora GDB in order to
make the feature available for all the debuginfo backends, not only
for DWARF.  It also implements a per-objfile flag which can be
activated by using the "-readnever" command when using the
'add-symbol-file' or 'symbol-file' commands.

It's also worth mentioning that this patch tests whether GDB correctly
fails to initialize if both '--readnow' and '--readnever' options are
passed.

Tested on the BuildBot.

gdb/ChangeLog:

2017-12-01  Andrew Cagney  <cagney@redhat.com>
	    Joel Brobecker  <brobecker@adacore.com>
	    Sergio Durigan Junior  <sergiodj@redhat.com>

	* NEWS (Changes since GDB 8.0: Mention new '--readnever'
	feature.
	* coffread.c (coff_symfile_read): Do not map over sections with
	'coff_locate_sections' if readnever is on.
	* dwarf2read.c (dwarf2_has_info): Return 0 if
	readnever is on.
	* elfread.c (elf_symfile_read): Do not map over sections with
	'elf_locate_sections' if readnever is on.
	* main.c (validate_readnow_readnever): New function.
	(captured_main_1): Add support for --readnever.
	(print_gdb_help): Document --readnever.
	* objfile-flags.h (enum objfile_flag) <OBJF_READNEVER>: New
	flag.
	* symfile.c (readnever_symbol_files): New global.
	(symbol_file_add_with_addrs): Set 'OBJF_READNEVER' when
	'READNEVER_SYMBOL_FILES' is set.
	(validate_readnow_readnever): New function.
	(symbol_file_command): Handle '-readnever' option.
	Call 'validate_readnow_readnever'.
	(add_symbol_file_command): Handle '-readnever' option.
	Call 'validate_readnow_readnever'.
	(_initialize_symfile): Document new '-readnever' option for
	both 'symbol-file' and 'add-symbol-file' commands.
	* top.h (readnever_symbol_files): New extern global.
	* xcoffread.c (xcoff_initial_scan): Do not read debug
	information if readnever is on.

gdb/doc/ChangeLog:

2017-12-01  Andrew Cagney  <cagney@redhat.com>
	    Joel Brobecker  <brobecker@adacore.com>
	    Sergio Durigan Junior  <sergiodj@redhat.com>

	* gdb.texinfo (File Options): Document --readnever.
	(Commands to Specify Files): Likewise, for 'symbol-file' and
	'add-symbol-file'.

gdb/testsuite/ChangeLog:

2017-12-01  Joel Brobecker  <brobecker@adacore.com>
	    Sergio Durigan Junior  <sergiodj@redhat.com>
	    Pedro Alves  <palves@redhat.com>

	* gdb.base/readnever.c, gdb.base/readnever.exp: New files.
2017-12-01 12:23:30 -05:00
Peter Bergner 0f873fd58b Use consistent types for holding instructions, instruction masks, etc.
include/
	* opcode/ppc.h (PPC_INT_FMT): Define.
	(struct powerpc_opcode) <opcode>: Update type.
	(struct powerpc_opcode) <mask>: Likewise.
	(struct powerpc_opcode) <bitm>: Likewise.
	(struct powerpc_opcode) <insert>: Likewise.
	(struct powerpc_opcode) <extract>: Likewise.
	(ppc_optional_operand_value): Likewise.

gas/
	* config/tc-ppc.c (last_insn): Update type.
	(insn_validate) <omask, mask>: Likewise.
	(ppc_setup_opcodes) <mask, right_bit>: Likewise.
	<PRINT_OPCODE_TABLE>: Update types and printf format specifiers.
	(ppc_insert_operand): Update return and argument types and remove
	unneeded type casts.
	<min, max, right, tmp>: Update type.
	(md_assemble): Remove unneeded type casts.
	<insn, val, tmp_insn>: Update type.

opcodes/
	* opcodes/ppc-dis.c (disassemble_init_powerpc): Fix white space.
	(operand_value_powerpc): Update return and argument type.
	<value, top>: Update type.
	(skip_optional_operands): Update argument type.
	(lookup_powerpc): Likewise.
	(lookup_vle): Likewise.
	<table_opcd, table_mask, insn2>: Update type.
	(lookup_spe2): Update argument type.
	<table_opcd, table_mask, insn2>: Update type.
	(print_insn_powerpc) <insn, value>: Update type.
	Use PPC_INT_FMT for printing instructions and operands.
	* opcodes/ppc-opc.c (insert_arx, extract_arx, insert_ary, extract_ary,
	insert_rx, extract_rx, insert_ry, extract_ry, insert_bat, extract_bat,
	insert_bba, extract_bba, insert_bdm, extract_bdm, insert_bdp,
	extract_bdp, valid_bo_pre_v2, valid_bo_post_v2, valid_bo, insert_bo,
	extract_bo, insert_boe, extract_boe, insert_dcmxs, extract_dcmxs,
	insert_dxd, extract_dxd, insert_dxdn, extract_dxdn, insert_fxm,
	extract_fxm, insert_li20, extract_li20, insert_ls, extract_ls,
	insert_esync, extract_esync, insert_mbe, extract_mbe, insert_mb6,
	extract_mb6, extract_nb, insert_nbi, insert_nsi, extract_nsi,
	insert_ral, extract_ral, insert_ram, extract_ram, insert_raq,
	extract_raq, insert_ras, extract_ras, insert_rbs, extract_rbs,
	insert_rbx, extract_rbx, insert_sci8, extract_sci8, insert_sci8n,
	extract_sci8n, insert_sd4h, extract_sd4h, insert_sd4w, extract_sd4w,
	insert_oimm, extract_oimm, insert_sh6, extract_sh6, insert_spr,
	extract_spr, insert_sprg, extract_sprg, insert_tbr, extract_tbr,
	insert_xt6, extract_xt6, insert_xtq6, extract_xtq6, insert_xa6,
	extract_xa6, insert_xb6, extract_xb6, insert_xb6s, extract_xb6s,
	insert_xc6, extract_xc6, insert_dm, extract_dm, insert_vlesi,
	extract_vlesi, insert_vlensi, extract_vlensi, insert_vleui,
	extract_vleui, insert_vleil, extract_vleil, insert_evuimm1_ex0,
	extract_evuimm1_ex0, insert_evuimm2_ex0, extract_evuimm2_ex0,
	insert_evuimm4_ex0, extract_evuimm4_ex0, insert_evuimm8_ex0,
	extract_evuimm8_ex0, insert_evuimm_lt8, extract_evuimm_lt8,
	insert_evuimm_lt16, extract_evuimm_lt16, insert_rD_rS_even,
	extract_rD_rS_even, insert_off_lsp, extract_off_lsp, insert_off_spe2,
	extract_off_spe2, insert_Ddd, extract_Ddd): Update types.
	(OP, OPTO, OPL, OPVUP, OPVUPRT, A, AFRALFRC_MASK, B, BD8, BD8IO, BD15,
	BD24, BBO, Y_MASK  , AT1_MASK, AT2_MASK, BBOCB, C_LK, C, CTX, UCTX,
	DX, EVSEL, IA16, I16A, I16L, IM7, LI20, MME, MD, MDS, SC, SC_MASK,
	SCI8, SCI8BF, SD4, SE_IM5, SE_R, SE_RR, VX, VX_LSP, VX_RA_CONST,
	VX_RB_CONST, VX_SPE_CRFD, VX_SPE2_CLR, VX_SPE2_SPLATB, VX_SPE2_OCTET,
	VX_SPE2_DDHH, VX_SPE2_HH, VX_SPE2_EVMAR, VX_SPE2_EVMAR_MASK, VXA,
	VXR, VXASH, X, EX, XX2, XX3, XX3RC, XX4, Z, XWRA_MASK, XLRT_MASK,
	XRLARB_MASK, XLRAND_MASK, XRTLRA_MASK, XRTLRARB_MASK, XRTARARB_MASK,
	XRTBFRARB_MASK, XOPL, XOPL2, XRCL, XRT, XRTRA, XCMP_MASK, XCMPL_MASK,
	XTO, XTLB, XSYNC, XEH_MASK, XDSS, XFL, XISEL, XL, XLO, XLYLK, XLOCB,
	XMBAR, XO, XOPS, XS, XFXM, XSPR, XUC, XW, APU): Update types in casts.
2017-12-01 11:20:15 -06:00
Tom Tromey d0df06af9b Fix dependency tracking for objects in subdirectories
On irc, Pedro pointed out that dependencies for objects in
subdirectories didn't seem to be working.

The bug was that the "-include" for .deps files was using the wrong file
name for subdirectory objects; e.g., for cli/cli-decode.o it was trying
to open .deps/cli/cli-decode.o, whereas the correct file is
cli/.deps/cli-decode.o.

This patch changes how the dep files are found.  Tested by touching a
source file and rebuilding cli/cli-decode.o.

2017-12-01  Tom Tromey  <tom@tromey.com>

	* Makefile.in (all_deps_files): New variable.
	Include .Po files using all_deps_files.
2017-12-01 07:56:11 -07:00
Joel Brobecker 2ee0c9b3ee Update GDB's list of maintainers to reflect today's reality
gdb/ChangeLog:

       * MAINTAINERS: Update list of maintainers, moving those who
       stepped down or became inactive to the "Past Maintainers"
       section.
2017-12-01 08:35:56 -05:00
H.J. Lu 92f402a7e0 x86: Print dynreloc in readonly section for map file output
This fixed:

FAIL: DT_TEXTREL map file warning

on Linux/x86.

	* elfxx-x86.c (_bfd_x86_elf_readonly_dynrelocs): Print dynamic
	relocation in readonly section for map file output.
2017-12-01 04:07:01 -08:00
Yao Qi 1cc75e929f Replace mail address with the URL in copyright header
The copyright header in most of GDB files were changed from mail address
to the URL in the conversion to GPLv3 in Aug 2007.  However, some files
still use mail address instead of the URL.  This patch fixes them.

gdb/testsuite:

2017-12-01  Yao Qi  <yao.qi@linaro.org>

	* gdb.arch/aarch64-atomic-inst.exp: Replace mail address with
	the URL in copyright header.
	* gdb.arch/aarch64-fp.exp: Likewise.
	* gdb.arch/ppc64-atomic-inst.exp: Likewise.
	* gdb.arch/ppc64-isa207-atomic-inst.exp: Likewise.
	* gdb.base/expand-psymtabs.exp: Likewise.
	* gdb.cp/expand-psymtabs-cxx.exp: Likewise.
	* gdb.fortran/common-block.exp: Likewise.
	* gdb.fortran/common-block.f90: Likewise.
	* gdb.fortran/logical.exp: Likewise.
	* gdb.fortran/vla-datatypes.f90: Likewise.
	* gdb.fortran/vla-sub.f90: Likewise.
2017-12-01 11:34:14 +00:00
Tobias Ulmer 7b2d209485 Check return value of bfd_new_link_order
* ldwrite.c (build_link_order): Check return value of all
	bfd_new_link_order calls.
2017-12-01 19:26:45 +10:30
Oleksandr Pikozh 0fbdde9429 Add --strip-unneeded to objcopy synopsis
* doc/binutils.texi: Add --strip-unneeded to objcopy synopsis.
2017-12-01 19:08:42 +10:30