Commit Graph

91661 Commits

Author SHA1 Message Date
Simon Marchi cc4d742f4c gdbserver x86 on win32: call init_target_desc
When trying to run gdbserver compiled for x86 win32 under wine, I get:

  $ wine ./gdbserver/gdbserver.exe --once :1234 ./test
  /home/emaisin/src/binutils-gdb/gdb/gdbserver/regcache.c:177: A problem internal to GDBserver has been detected.
  regcache* new_register_cache(const target_desc*): Assertion `tdesc->registers_size != 0' failed.

It seems like on that platform, init_target_desc is never called, so
registers_size is never computed.

My first thought was to call init_target_desc somewhere in win32-low.c,
but it turns out that when using win32 on arm, the target description is
already initialized by the generated code.  My second thought was to
call it in {i386,amd64}_create_target_description, but those functions
are shared with GDB, and init_target_desc is gdbserver-specific.  So I
ended up with the simplest fix, calling it in i386_arch_setup.

Now I hit some other problem:

  $ wine ./gdbserver/gdbserver.exe --once :1234 ./test
  Killing process(es): 39
  No program to debug
  Exiting

but still, I think fixing the tdesc issue this is a step forward.

gdb/gdbserver/ChangeLog:

	* win32-i386-low.c (i386_arch_setup): Call init_target_desc.
2017-09-22 16:51:55 +02:00
H.J. Lu b69e9267d1 x86: Return -1 if bfd_canonicalize_dynamic_reloc returns 0
Stop if bfd_canonicalize_dynamic_reloc returns 0.

	PR ld/22163
	* elfxx-x86.c (_bfd_x86_elf_get_synthetic_symtab): Also return
	-1 if bfd_canonicalize_dynamic_reloc returns 0.
2017-09-22 07:25:16 -07:00
H.J. Lu be2b629f64 Add a test for PR ld/22150
PR ld/22150
	* testsuite/ld-elf/pr22150.vd: New file.
	* testsuite/ld-elf/pr22150.ver: Likewise.
	* testsuite/ld-elf/pr22150a.s: Likewise.
	* testsuite/ld-elf/pr22150b.s: Likewise.
	* testsuite/ld-elf/shared.exp: Run PR ld/22150 tests.
2017-09-22 07:05:53 -07:00
Pedro Alves b877d21f34 bfd/version.h: Add rationale for BFD_VERSION_DATE
bfd/ChangeLog:
2017-09-22  Pedro Alves  <palves@redhat.com>
	    Alan Modra  <amodra@gmail.com>

	* version.h: Add comment.
2017-09-22 14:57:52 +01:00
Simon Marchi 432ae719d3 Fix sometimes-uninitialized warning in gdbscm_value_address
I am getting this warning with clang:

/home/emaisin/src/binutils-gdb/gdb/guile/scm-value.c:439:11: error: variable 'address' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
      if (res_val != NULL)
          ^~~~~~~~~~~~~~~
/home/emaisin/src/binutils-gdb/gdb/guile/scm-value.c:444:32: note: uninitialized use occurs here
      if (gdbscm_is_exception (address))
                               ^~~~~~~
/home/emaisin/src/binutils-gdb/gdb/guile/scm-value.c:439:7: note: remove the 'if' if its condition is always true
      if (res_val != NULL)
      ^~~~~~~~~~~~~~~~~~~~
/home/emaisin/src/binutils-gdb/gdb/guile/scm-value.c:427:18: note: initialize the variable 'address' to silence this warning
      SCM address;
                 ^
                  = nullptr

We can get rid of it with a small refactoring.  I think it's a bit
cleaner/safer to initialize address with a pessimistic value and assign
it on success.  Then there's no chance of using it uninitialized.  If I
understand correctly, the NULL check on res_val was to check whether
value_addr threw, and that if value_addr returns without throwing, the
result will never be NULL.  If that's true, we can skip the res_val
variable.

Tested by running gdb.guile/*.exp locally.

gdb/ChangeLog:

	* guile/scm-value.c (gdbscm_value_address): Initialize address,
	get rid of res_val.
2017-09-22 10:47:19 +02:00
Rainer Orth 4fa7574eec Fix gdb 8.1 Solaris compilation
I just tried to compile gdb trunk on Solaris 11.4 (formerly 12), and
failed for a couple of reasons:

*

In file included from /usr/include/python2.7/Python.h:128:0,
                 from /vol/src/gnu/gdb/gdb/dist/gdb/python/python-internal.h:94,
                 from /vol/src/gnu/gdb/gdb/dist/gdb/python/py-instruction.h:23,
                 from /vol/src/gnu/gdb/gdb/dist/gdb/python/py-instruction.c:21:
/usr/include/python2.7/ceval.h:67:0: error: ignoring #pragma no_inline  [-Werror=unknown-pragmas]
 #pragma no_inline(PyEval_EvalFrameEx)
 ^

  New in Solaris 11.4: <python2.7/ceval.h> uses a Studio-only #pragma.
  I've disabled the warning in warnings.m4.

*

/vol/src/gnu/gdb/gdb/dist/gdb/ser-pipe.c: In function ‘int pipe_open(serial*, const char*)’:
/vol/src/gnu/gdb/gdb/dist/gdb/ser-pipe.c:77:9: error: ‘pid_t vfork()’ is deprecated (declared at /usr/include/unistd.h:659) [-Werror=deprecated-declarations]
   pid = vfork ();
         ^
/vol/src/gnu/gdb/gdb/dist/gdb/ser-pipe.c:77:16: error: ‘pid_t vfork()’ is deprecated (declared at /usr/include/unistd.h:659) [-Werror=deprecated-declarations]
   pid = vfork ();
                ^

  Since Solaris 11, vfork () is marked deprecated in <unistd.h>.

  cf. vfork(2):

       The  vfork()  and vforkx() functions are deprecated. Their sole legiti-
       mate use as a prelude to an immediate call to a function from the  exec
       family can be achieved safely by posix_spawn(3C) or posix_spawnp(3C).

  Again, I've disabled the warning.

*

/vol/src/gnu/gdb/gdb/dist/gdb/cli/cli-cmds.c: In function ‘void shell_escape(const char*, int)’:
/vol/src/gnu/gdb/gdb/dist/gdb/cli/cli-cmds.c:750:14: error: ‘pid_t vfork()’ is deprecated (declared at /usr/include/unistd.h:659) [-Werror=deprecated-declarations]
   if ((pid = vfork ()) == 0)
              ^
/vol/src/gnu/gdb/gdb/dist/gdb/cli/cli-cmds.c:750:21: error: ‘pid_t vfork()’ is deprecated (declared at /usr/include/unistd.h:659) [-Werror=deprecated-declarations]
   if ((pid = vfork ()) == 0)
                     ^

  Same problem.

*

/vol/src/gnu/gdb/gdb/dist/gdb/procfs.c: In function ‘void procfs_init_inferior(target_ops*, int)’:
/vol/src/gnu/gdb/gdb/dist/gdb/procfs.c:4380:30: error: ‘START_INFERIOR_TRAPS_EXPECTED’ was not declared in this scope
   gdb_startup_inferior (pid, START_INFERIOR_TRAPS_EXPECTED);
                              ^

  defined in nat/fork-inferior.h, need to include that header

/vol/src/gnu/gdb/gdb/dist/gdb/procfs.c: In function ‘void procfs_create_inferior(target_ops*, const char*, const string&, char**, int)’:
/vol/src/gnu/gdb/gdb/dist/gdb/procfs.c:4605:38: error: ‘fork_inferior’ was not declared in this scope
          NULL, NULL, shell_file, NULL);
                                      ^

  likewise

/vol/src/gnu/gdb/gdb/dist/gdb/procfs.c: In function ‘void procfs_info_proc(target_ops*, const char*, info_proc_what)’:
/vol/src/gnu/gdb/gdb/dist/gdb/procfs.c:5124:20: error: ‘argv’ was not declared in this scope
   for (char *arg : argv)
                    ^

  Typo, should be built_argv instead!

*

Undefined                       first referenced
 symbol                             in file
fork_inferior(char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char**, void (*)(), void (*)(int), void (*)(), char const*, void (*)(char const*, char* const*, char* const*)) procfs.o
startup_inferior(int, int, target_waitstatus*, ptid_t*) fork-child.o
ld: fatal: symbol referencing errors
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:2249: gdb] Error 1

  Need to add fork-inferior.o to NATDEPFILES.

With the changes below, I can build gdb on sparcv9-sun-solaris2.11 and
amd64-pc-solaris2.11 and a simple smoke test (gdb/gdb gdb/gdb) works.
2017-09-22 10:42:45 +02:00
Alan Modra 7790bd6c74 [GOLD] clone assert breakage
* resolve.cc (clone): Fix got_offset_list test.
2017-09-22 15:20:12 +09:30
Alan Modra ec76901011 [GOLD] Set non-exec stack for ppc64
gcc doesn't emit stack notes for ELFv1, since ELFv1 never needs an
executable stack.  Note that ELFv1 is usually big-endian and ELFv2
little-endian, but the ABI is really orthogonal to endiannes.

	* powerpc.cc (Target_powerpc<64,*>::powerpc_info): Set
	is_default_stack_executable false.
2017-09-22 11:47:02 +09:30
Alan Modra 11bb0c7abc readelf tests
We have multiple tests that report failure to assemble without saying
exactly what test is failing.

	* testsuite/binutils-all/readelf.exp: Don't perror and exit on
	bintest.s assembly failure.  Report tests unresolved instead.
	Likewise for version note test, pr18374, decompress, and dw5
	tests.
	(readelf_test): Set testname to include both option and binary
	file name.  Use for pass/fail.
2017-09-22 11:45:55 +09:30
GDB Administrator df52f331ed Automatic date update in version.in 2017-09-22 00:00:27 +00:00
Maciej W. Rozycki ef272caa74 readelf: Handle E_MIPS_MACH_5900
Fix commit e407c74b5b ("Support for MIPS R5900 (Sony Playstation 2)"),
<https://sourceware.org/ml/binutils/2012-12/msg00240.html>, and add the
handling of E_MIPS_MACH_5900, correctly showing `5900' among `Flags:' in
the output of `-h' rather than `unknown CPU'.

	binutils/
	* readelf.c (get_machine_flags) <E_MIPS_MACH_5900>: New case.

	gas/
	* testsuite/gas/mips/elf_mach_5900.d: New test.
	* testsuite/gas/mips/mips.exp: Run it.
2017-09-22 00:54:19 +01:00
James Cowgill 42c0794e96 PR gas/21762: MIPS: Fix .stabs directive marking labels as MIPS16
If a .stabs directive was used before another .set directive in a MIPS
source file, s_mips_stab would call mips_mark_labels without having
initialized the mips_opts structure yet.  Fix this by calling
file_mips_check_options which will initialize mips_opts if necessary.

gas/
	PR gas/21762
	* config/tc-mips.c (s_mips_stab): Insert call to
	file_mips_check_options.
	* testsuite/gas/mips/micromips@stabs-symbol-type.d: New test.
	* testsuite/gas/mips/mips.exp: Run the new tests.
	* testsuite/gas/mips/mips16@stabs-symbol-type.d: New test.
	* testsuite/gas/mips/stabs-symbol-type.d: New test.
	* testsuite/gas/mips/stabs-symbol-type.s: New test source.
2017-09-22 00:54:19 +01:00
Kevin Buettner 757bf54bb4 Test case for Inferior.thread_from_thread_handle
As the title says, this is a test case for
Inferior.thread_from_thread_handle, a python method which will,
given a thread library dependent thread handle, find the GDB thread
which corresponds to that thread handle (in the inferior under
consideration).

The C file for this test case causes the thread handles for the
main thread and two child threads to be placed into an array.  The
test case runs to one of the functions (do_something()) at which point,
it retrieves the thread handles from the array and attempts to find the
corresponding thread in GDB's internal thread list.

I use barriers to make sure that both threads have actually started;
execution will stop when one of the threads breaks at do_something.

Thanks to Simon Marchi for suggestions for forcing the thread
numbering to be stable.

gdb/testsuite/ChangeLog:

	* gdb.python/py-thrhandle.c, gdb.python/py-thrhandle.exp: New
	files.
2017-09-21 11:49:48 -07:00
Kevin Buettner f2ff95c583 Documentation for qXfer:threads:read handle attribute
gdb/doc/ChangeLog:

	* gdb.texinfo (qXfer:threads:read): Add documentation for handle
	attribute.
2017-09-21 11:49:48 -07:00
Kevin Buettner f6327dcbf0 Add thread_handle_to_thread_info support for remote targets
This patch adds support to remote targets for converting a thread
handle to a thread_info struct pointer.

A thread handle is fetched via a "handle" attribute which has been
added to the qXfer:threads:read query packet.  An implementation is
provided in gdbserver for targets using the Linux kernel.

gdb/gdbserver/ChangeLog:

	* linux-low.h (struct lwp_info): Add new field, thread_handle.
	(thread_db_thread_handle): Declare.
	* linux-low.c (linux_target_ops): Initialize thread_handle.
	* server.c (handle_qxfer_threads_worker): Add support for
	"handle" attribute.
	* target.h (struct target_ops): Add new function pointer,
	thread_handle.
	(target_thread_handle): Define.
	* thread-db.c (find_one_thread, attach_thread): Set thread_handle
	field in lwp.
	(thread_db_thread_handle): New function.

gdb/ChangeLog:

	* remote.c (vector): Include.
	(struct private_thread_info): Add field, thread_handle.
	(free_private_thread_info): Deallocate storage associated with
	thread handle.
	(get_private_info_thread): Initialize `thread_handle' field.
	(struct thread_item): Add field, thread_handle.
	(clear_threads_listing_context): Deallocate storage associated
	with thread handle.
	(start_thread): Add support for "handle" attribute.
	(thread_attributes): Add "handle".
	(remote_get_threads_with_qthreadinfo): Initialize thread_handle
	field.
	(remote_update_thread_list): Update thread_handle.
	(remote_thread_handle_to_thread_info): New function.
	(init_remote_ops): Initialize to_thread_handle_to_thread_info.
2017-09-21 11:49:47 -07:00
Kevin Buettner 8629910955 Add thread_db_notice_clone to gdbserver
While working on a patch for fetching a thread handle in gdbserver, I
ran into a circumstance in which tests in gdb.mi/mi-nsmoribund.exp
would occasionally fail.  Over a large enough number of runs, it would
fail roughly 2% of the time.

That thread handle patch caused find_one_thread() to be called on
every stop.  find_one_thread() calls td_ta_map_lwp2thr() which, in
turn, can cause ps_get_thread_area() to be called.
ps_get_thread_area() makes a call to ptrace() for getting the thread
area address.  If this should happen when the thread is not stopped,
the call to ptrace will return error which in turn propogates back to
find_one_thread().  find_one_thread() calls error() in this instance
which causes the program to die.

This patch causes find_one_thread() to be called upon reciept of a
clone event.  Since the clone is stopped, the circumstances described
above cannot occur.

gdb/gdbserver/ChangeLog:

	* linux-low.c (handle_extended_wait): Call thread_db_notice_clone().
	* linux-low.h (thread_db_notice_clone): Declare.
	* thread-db.c (thread_db_notice_clone): New function.
2017-09-21 11:49:47 -07:00
Kevin Buettner da2c323bff Documentation for Inferior.thread_from_thread_handle
gdb/doc/ChangeLog:

	* python.texi (Inferiors In Python): Add description for method
	Inferior.thread_from_thread_handle.
2017-09-21 11:49:46 -07:00
Kevin Buettner fbbe5337a6 Add `thread_from_thread_handle' method to (Python) gdb.Inferior
gdb/ChangeLog:
	* python/py-inferior.c (gdbpy_thread_from_thread_handle): New
	function.
	(inferior_object_methods): Add gdbpy_thread_from_thread_handle.
	* python/python-internal.h (thread_object_type): Declare.
2017-09-21 11:20:51 -07:00
Kevin Buettner e04ee09e24 Add target method for converting thread handle to thread_info struct pointer
This patch adds a target method named `to_thread_handle_to_thread_info'.
It is intended to map a thread library specific thread handle (such as
pthread_t for the pthread library) to the corresponding GDB internal
thread_info struct (pointer).

An implementation is provided for Linux pthreads; see linux-thread-db.c.

gdb/ChangeLog:

	* target.h (struct target_ops): Add to_thread_handle_to_thread_info.
	(target_thread_handle_to_thread_info): Declare.
	* target.c (target_thread_handle_to_thread_info): New function.
	* target-delegates.c: Regenerate.
	* gdbthread.h (find_thread_by_handle): Declare.
	* thread.c (find_thread_by_handle): New function.
	* linux-thread-db.c (thread_db_thread_handle_to_thread_info): New
	function.
	(init_thread_db_ops): Register thread_db_thread_handle_to_thread_info.
2017-09-21 11:19:10 -07:00
Pedro Alves f557a88ab1 gdbserver: Remove traces of ancient Hc handling
Back in commit f0db101d98 ("gdbserver: don't pick a random thread if
the current thread dies"), a couple years ago, the last references to
set_desired_thread(0) [select the Hc thread] were removed, and all the
remaining calls to set_desired_thread pass '1', meaning general
thread.  This means we can simplify set_desired_thread.

gdb/gdbserver/ChangeLog:
2017-09-21  Pedro Alves  <palves@redhat.com>

	* server.c (gdb_read_memory, handle_status, process_serial_event)
	(handle_serial_event, handle_target_event): Adjust to
	set_desired_thread prototype change.
	* target.c (set_desired_thread): Remove 'use_general' parameter
	and adjust.
	* target.h (set_desired_thread): Remove 'use_general' parameter.
2017-09-21 16:52:33 +01:00
Andreas Arnez 8fe09d7421 S/390: Fix Elf note swap s390_gs_bc vs. s390_gs_cb
Fix two typos that resulted in swapping the BFD names for the core note
register sections NT_S390_GS_CB and NT_S390_GS_BC.

bfd/ChangeLog:

	* elf.c (elfcore_grok_note): For the cases NT_S390_GS_CB and
	NT_S390_GS_BC, correct the previously swapped invocations of
	elfcore_grok_s390_gs_bc and elfcore_grok_s390_gs_cb.
2017-09-21 17:45:18 +02:00
Alan Modra ba52cbb9d0 Reduce excessive .eh_frame alignment for powerpc
PowerPC64 .cfi directives use DW_EH_PE_sdata4 encoding for .eh_frame,
so there is no real reason why .eh_frame should be 8 byte aligned.

gas/
	* config/tc-ppc.h (EH_FRAME_ALIGNMENT): Define.
ld/
	* testsuite/ld-powerpc/tlsopt5.wf: Update for reduced alignment.
2017-09-21 23:17:44 +09:30
Simon Marchi 1e5b66ed42 linux-waitpid: Get rid of format string warning
Clang gives this warning:

/home/emaisin/src/binutils-gdb/gdb/gdbserver/../nat/linux-waitpid.c:45:25: error: format string is not a string literal [-Werror,-Wformat-nonliteral]
      vfprintf (stderr, format, args);
                        ^~~~~~

Get rid of it by adding ATTRIBUTE_PRINTF.

gdb/ChangeLog:

	* nat/linux-waitpid.c (linux_debug): Add ATTRIBUTE_PRINTF.
2017-09-21 15:19:40 +02:00
Simon Marchi ebe48ba085 microblaze-tdep: Add ATTRIBUTE_PRINTF to microblaze_debug
I am getting this warning with clang:

/home/emaisin/src/binutils-gdb/gdb/microblaze-tdep.c:94:28: error: format string is not a string literal [-Werror,-Wformat-nonliteral]
       vprintf_unfiltered (fmt, args);
                           ^~~

Adding ATTRIBUTE_PRINTF to microblaze_debug gets rid of it.  Strangely,
gcc doesn't warn about non-literal format strings when calling vprintf
(or a vprintf-style function, like vprintf_unfiltered).  I filed this
gcc bug:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82206

gdb/ChangeLog:

	* microblaze-tdep.c (microblaze_debug): Add ATTRIBUTE_PRINTF.
2017-09-21 14:09:33 +02:00
Yao Qi 0a0bf5dc14 Fix aarch64-freebsd build failure
I happen to see that fbsd-tdep.o is missing for target aarch64-freebsd,
and it causes the build failure,

aarch64-fbsd-tdep.o: In function `aarch64_fbsd_init_abi(gdbarch_info, gdbarch*)':
binutils-gdb/gdb/aarch64-fbsd-tdep.c:186: undefined reference to `fbsd_init_abi(gdbarch_info, gdbarch*)'
binutils-gdb/gdb/aarch64-fbsd-tdep.c:189: undefined reference to `svr4_lp64_fetch_link_map_offsets()'
binutils-gdb/gdb/aarch64-fbsd-tdep.c:189: undefined reference to `set_solib_svr4_fetch_link_map_offsets(gdbarch*, link_map_offsets* (*)())'

This patch fixed it.

gdb:

2017-09-21  Yao Qi  <yao.qi@linaro.org>

	* configure.tgt (aarch64*-*-freebsd*): Add fbsd-tdep.o solib-svr4.o
	to gdb_target_obs.
2017-09-21 09:20:05 +01:00
Nick Clifton ea5cf0fe29 oops - changelog entry omitted from previous delta 2017-09-21 09:07:11 +01:00
Yao Qi 88240b186d [SIM, ARM] Fix build failure
This patch fixes the build failure by using disassembler to get
disassemble function pointer, and do the disassembly, because
print_insn_little_arm is no longer visible outside opcodes/

binutils-gdb/sim/arm/wrapper.c:98:10: error: implicit declaration of function 'print_insn_little_arm' [-Werror=implicit-function-declaration]
   size = print_insn_little_arm (0, & info);
          ^

sim/arm:

2017-09-21  Yao Qi  <yao.qi@linaro.org>

	* wrapper.c (print_insn): Use disassembler instead of
	print_insn_little_arm.
2017-09-21 09:02:25 +01:00
Tom Tromey d1b0a7bfd3 Change counted_command_line to a shared_ptr
This changes counted_command_line to be a typedef for std::shared_ptr
and removes the associated cleanups.  In the long run I believe that
cmd_list_element should also be changed to use a shared_ptr.

gdb/ChangeLog
2017-09-20  Tom Tromey  <tom@tromey.com>

	* breakpoint.c (struct counted_command_line): Remove.
	(breakpoint_commands): Update.
	(alloc_counted_command_line, incref_counted_command_line)
	(decref_counted_command_line, do_cleanup_counted_command_line)
	(make_cleanup_decref_counted_command_line): Remove.
	(breakpoint_set_commands, commands_command_1, ~bpstats, bpstats)
	(bpstat_clear_actions, bpstat_do_actions_1, watchpoint_check)
	(bpstat_stop_status, print_one_breakpoint_location, ~breakpoint)
	(save_breakpoints): Update.
	* breakpoint.h (counted_command_line): Now a typedef to
	shared_ptr.
	(struct breakpoint) <commands>: Now a counted_command_line.
	(struct bpstats) <command>: Likewise.
2017-09-20 22:05:16 -06:00
Tom Tromey 48649e1bfe Use function_view in a couple of places in breakpoint.c
This changes iterate_over_related_breakpoints and
map_breakpoint_numbers to take a function_view.  Then, it simplifies
the callers by using lambdas.  This then allows the removal of some
bookkeeping types.

gdb/ChangeLog
2017-09-20  Tom Tromey  <tom@tromey.com>

	* breakpoint.c (struct commands_info, do_map_commands_command):
	Remove.
	(commands_command_1): Update.
	(iterate_over_related_breakpoints): Take a function_view.
	(do_delete_breakpoint, do_map_delete_breakpoint): Remove.
	(delete_command): Update.
	(map_breakpoint_numbers): Take a function_view.
	(do_disable_breakpoint, do_map_delete_breakpoint): Remove.
	(disable_command): Update.
	(do_enable_breakpoint, do_map_enable_breakpoint): Remove.
	(enable_command): Update.
	(struct disp_data, do_enable_breakpoint_disp)
	(do_map_enable_once_breakpoint, do_map_enable_count_breakpoint)
	(do_map_enable_delete_breakpoint): Remove.
	(enable_once_command, enable_count_command, enable_delete_command)
	(delete_trace_variable_command): Update.
2017-09-20 22:05:15 -06:00
Tom Tromey 04afa70c8e Allocate bpstats with new
This changes struct bpstats to be allocated with new and freed with
delete, adding constructors and a destructor in the process.  This
allows the removal of one cleanup and clears the way for more to
follow.

gdb/ChangeLog
2017-09-20  Tom Tromey  <tom@tromey.com>

	* breakpoint.c (~bpstats): Rename from bpstat_free.  Update.
	(bpstat_clear): Use delete.
	(bpstats): New constructors.
	(bpstat_copy, bpstat_stop_status): Use new.
	(dprintf_after_condition_true): Update.
	* breakpoint.h (bpstats::bpstats): Add constructors.
	(bpstats::~bpstats): Add destructor.
2017-09-20 22:05:14 -06:00
GDB Administrator f5b358c8aa Automatic date update in version.in 2017-09-21 00:00:27 +00:00
Pedro Alves c83833f493 eval.c:evaluate_subexp_standard: Use RAII to avoid leaks
While working on the no-debug-info debugging improvements series, I
noticed these bare xfree calls, which lead to leaks if
evaluate_subexp_standard throws.

Fix that by reworking make_params as a RAII class.  Ends up
eliminating a couple heap allocations too.

gdb/ChangeLog:
2017-09-20  Pedro Alves  <palves@redhat.com>

	* eval.c (make_params): Delete, refactored as ...
	(class fake_method): ... this new type's ctor.
	(fake_method::~fake_method): New.
	(evaluate_subexp_standard): Use 'fake_method'.
2017-09-21 00:34:41 +01:00
Teresa Johnson ca464aac1b Check for export dynamic symbol options when doing symbol resolution in plugins.
2017-09-20  Teresa Johnson  <tejohnson@google.com>
	* plugin.cc (is_visible_from_outside): Check for export dynamic symbol
        option and list.
	* testsuite/Makefile.am (plugin_test_12): New test.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/export_dynamic_plugin.cc: New test source.
	* testsuite/plugin_test_12.sh: New test script.
2017-09-20 15:45:04 -07:00
Tom Tromey 223ffa714c Remove make_cleanup_restore_target_terminal
This removes make_cleanup_restore_target_terminal and generally
C++-ifies target terminal handling.  It changes all target_terminal_*
functions to be static members of a new target_terminal class and
changes the cleanup to be a scoped_* class.
make_cleanup_override_quit_handler is also removed in favor of simply
using scoped_restore.

Note that there are some files in this patch that I could not compile.
Considering that some of the rewrites were automated, and that none of
these files involed cleanups, I feel that this is relatively safe.

Regression tested by the buildbot.

gdb/ChangeLog
2017-09-20  Tom Tromey  <tom@tromey.com>

	* windows-nat.c (get_windows_debug_event, windows_wait)
	(do_initial_windows_stuff, windows_attach): Update.
	* utils.c (vwarning, internal_vproblem): Update.
	(ui_unregister_input_event_handler_cleanup)
	(prepare_to_handle_input): Remove.
	(class scoped_input_handler): New.
	(defaulted_query, prompt_for_continue): Update.
	* tui/tui-hooks.c (tui_refresh_frame_and_register_information):
	Update.
	* top.c (undo_terminal_modifications_before_exit): Update.
	* target/target.h (target_terminal_init, target_terminal_inferior)
	(target_terminal_ours): Don't declare.
	(class target_terminal): New.
	* target.h (target_terminal_is_inferior, target_terminal_is_ours)
	(target_terminal_ours_for_output)
	(make_cleanup_restore_target_terminal): Don't declare.
	(target_terminal_info): Remove.
	* target.c (enum terminal_state, terminal_state): Remove.
	(target_terminal::terminal_state): Define.
	(target_terminal::init): Rename from target_terminal_init.
	(target_terminal::inferior): Rename from
	target_terminal_inferior.
	(target_terminal::ours): Rename from target_terminal_ours.
	(target_terminal::ours_for_output): Rename from
	target_terminal_ours_for_output.
	(target_terminal::info): New method.
	(cleanup_restore_target_terminal)
	(make_cleanup_restore_target_terminal): Remove.
	* solib.c (handle_solib_event): Update.
	* remote.c (remote_serial_quit_handler): Update.
	(remote_terminal_inferior, remote_wait_as): Update.
	* record-full.c (record_full_wait_1): Update.
	* nto-procfs.c (procfs_create_inferior): Update.
	* nat/fork-inferior.c (startup_inferior): Update.
	* mi/mi-interp.c (mi_new_thread, mi_thread_exit)
	(mi_record_changed, mi_inferior_added, mi_inferior_appeared)
	(mi_inferior_exit, mi_inferior_removed, mi_traceframe_changed)
	(mi_tsv_created, mi_tsv_deleted, mi_tsv_modified)
	(mi_breakpoint_created, mi_breakpoint_deleted)
	(mi_breakpoint_modified, mi_on_resume, mi_solib_loaded)
	(mi_solib_unloaded, mi_command_param_changed, mi_memory_changed)
	(mi_user_selected_context_changed, report_initial_inferior):
	Update.
	* linux-nat.c (linux_nat_attach, linux_nat_terminal_ours)
	(linux_nat_terminal_inferior): Update.
	* infrun.c (follow_fork_inferior)
	(handle_vfork_child_exec_or_exit, do_target_resume)
	(check_curr_ui_sync_execution_done, handle_inferior_event_1)
	(handle_signal_stop, maybe_remove_breakpoints, normal_stop):
	Update.
	* inflow.c (child_terminal_init, info_terminal_command): Update.
	* infcmd.c (post_create_inferior, continue_1, prepare_one_step)
	(attach_command): Update.
	* infcall.c (call_thread_fsm_should_stop): Update.
	* gnu-nat.c (gnu_attach): Update.
	* extension.c (struct active_ext_lang_state)
	(restore_active_ext_lang): Update.
	* exceptions.c (print_flush): Update.
	* event-top.c (async_enable_stdin, default_quit_handler): Update.
	(struct quit_handler_cleanup_data, restore_quit_handler)
	(restore_quit_handler_dtor, make_cleanup_override_quit_handler):
	Remove.
	* cp-support.c (gdb_demangle): Update.
	* breakpoint.c (update_inserted_breakpoint_locations)
	(insert_breakpoint_locations, handle_jit_event)
	(disable_breakpoints_in_unloaded_shlib): Update.
	* annotate.c (annotate_breakpoints_invalid)
	(annotate_frames_invalid): Update.

gdb/gdbserver/ChangeLog
2017-09-20  Tom Tromey  <tom@tromey.com>

	* target.c (target_terminal::terminal_state): Define.
	(target_terminal::init): Rename from target_terminal_init.
	(target_terminal::inferior): Rename from
	target_terminal_inferior.
	(target_terminal::ours): Rename from target_terminal_ours.
	(target_terminal::ours_for_output, target_terminal::info): New.
2017-09-20 16:09:50 -06:00
Tom Tromey 013af3fc8e Overload catch_command_errors
This changes catch_command_errors_const to be an overload of
catch_command_errors, which may mildly help future constification
efforts.

Tested by rebuilding.

gdb/ChangeLog
2017-09-20  Tom Tromey  <tom@tromey.com>

	* main.c (catch_command_errors): Rename from
	catch_command_errors_const.
	(captured_main_1): Update.
2017-09-20 16:04:11 -06:00
Pedro Alves 06871ae840 Make "list ambiguous" show symbol names too
Currently, with an ambiguous "list first,last", we get:

  (gdb) list bar,main
  Specified first line 'bar' is ambiguous:
  file: "src/gdb/testsuite/gdb.cp/overload.cc", line number: 97
  file: "src/gdb/testsuite/gdb.cp/overload.cc", line number: 98

This commit makes gdb's output above a bit clearer by printing the
symbol name as well:

  (gdb) list bar,main
  Specified first line 'bar' is ambiguous:
  file: "src/gdb/testsuite/gdb.cp/overload.cc", line number: 97, symbol: "bar(A)"
  file: "src/gdb/testsuite/gdb.cp/overload.cc", line number: 98, symbol: "bar(B)"

And while at it, makes gdb print the symbol name when actually listing
multiple locations too.  I.e., before (with "set listsize 2"):

  (gdb) list bar
  file: "src/gdb/testsuite/gdb.cp/overload.cc", line number: 97
  96
  97      int bar (A) { return 11; }
  file: "src/gdb/testsuite/gdb.cp/overload.cc", line number: 98
  97      int bar (A) { return 11; }
  98      int bar (B) { return 22; }

After:

  (gdb) list bar
  file: "src/gdb/testsuite/gdb.cp/overload.cc", line number: 97, symbol: "bar(A)"
  96
  97      int bar (A) { return 11; }
  file: "src/gdb/testsuite/gdb.cp/overload.cc", line number: 98, symbol: "bar(B)"
  97      int bar (A) { return 11; }
  98      int bar (B) { return 22; }

Currently, the result of decoding a linespec loses information about
the original symbol that was found.  All we end up with is an address.
This makes it difficult to find the original symbol again to get at
its print name.  Fix that by storing a pointer to the symbol in the
sal.  We already store the symtab and obj_section, so it feels like a
natural progression to me.  This avoids having to do any extra symbol
lookup too.

gdb/ChangeLog:
2017-09-20  Pedro Alves  <palves@redhat.com>

	* cli/cli-cmds.c (list_command): Use print_sal_location.
	(print_sal_location): New function.
	(ambiguous_line_spec): Use print_sal_location.
	* linespec.c (symbol_to_sal): Record the symbol in the sal.
	* symtab.c (find_function_start_sal): Likewise.
	* symtab.h (symtab_and_line::symbol): New field.

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

	* gdb.base/list-ambiguous.exp (test_list_ambiguous_symbol): Expect
	symbol names in gdb's output.
	* gdb.cp/overload.exp ("list all overloads"): Likewise.
2017-09-20 16:21:26 +01:00
Pedro Alves e5f25bc5d6 Fix "list ambiguous_variable"
The "list" command allows specifying the name of variables as
argument, not just functions, so that users can type "list
a_global_variable".

That support is a broken when it comes to ambiguous locations though.

If there's more than one such global variable in the program, e.g.,
static globals in different compilation units, GDB ends up listing the
source of the first variable it finds, only.

linespec.c does find both symbol and minsym locations for all the
globals.  The problem is that it ends up merging all the resulting
sals into one, because they all have address, zero.  I.e., all sals
end up with sal.pc == 0, so maybe_add_address returns false for all
but the first.

The zero addresses appear because:

- in the minsyms case, linespec.c:minsym_found incorrectly treats all
  minsyms as if they were function/text symbols.  In list mode we can
  end up with data symbols there, and we shouldn't be using
  find_pc_sect_line on data symbols.

- in the debug symbols case, symbol_to_sal misses recording an address
  (sal.pc) for non-block, non-label symbols.

gdb/ChangeLog:
2017-09-20  Pedro Alves  <palves@redhat.com>

	* linespec.c (minsym_found): Handle non-text minsyms.
	(symbol_to_sal): Record a sal.pc for non-block, non-label symbols.

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

	* gdb.base/list-ambiguous.exp (test_list_ambiguous_function):
	Rename to ...
	(test_list_ambiguous_symbol): ... this and add a symbol name
	parameter.  Adjust.
	(test_list_ambiguous_function): Reimplement on top of
	test_list_ambiguous_symbol and also test listing ambiguous
	variables.
	* gdb.base/list-ambiguous0.c (ambiguous): Rename to ...
	(ambiguous_fun): ... this.
	(ambiguous_var): New.
	* gdb.base/list-ambiguous1.c (ambiguous): Rename to ...
	(ambiguous_fun): ... this.
	(ambiguous_var): New.
2017-09-20 16:12:54 +01:00
Walfred Tedeschi 1b7fa39ed9 [OBV] amd64-features-makefile: add missing backslash.
In an old commit the backslash of was missing in the rule for creating the
i386-avx-mpx-avx512-pku.dat file.  No need to regenerate the files, this
was done by another commit from Yao.

2017-09-20  Walfred Tedeschi  <walfred.tedeschi@intel.com>

	* features/Makefile (i386-avx-mpx-avx512-pku.dat): Add backslash.
2017-09-20 15:01:40 +02:00
Walfred Tedeschi 37dd082596 add ChangeLog from previous commit 2017-09-20 14:47:04 +02:00
Walfred Tedeschi 6470a84860 gdb - avx512: tests were failing due to missing memory aligment.
Test was running on a fault during code execution.  Analysis have shown
that the wrong instruction had been used.  An instruction that takes
not alligned memory is more appropriated for the task.

ChangeLog:

2017-09-20  Walfred Tedeschi  <walfred.tedeschi@intel.com>

gdb/testesuite/ChangeLog:
	* gdb.arch/i386-avx512.c (move_zmm_data_to_reg): Use
	vmovups instead vmovaps.
	(move_zmm_data_to_memory): Use vmovups instead vmovaps.

Change-Id: I4a95560861ef1792ed6ce86578fdd726162863f1
2017-09-20 13:42:21 +02:00
Alan Modra 64b5d6d785 [GOLD] PowerPC function address in non-PIC
ppc32, like many targets, defines the address of a function as the PLT
call stub code for functions referenced but not defined in a non-PIC
executable.  ppc32 gold, unlike other targets, inherits the ppc64
multiple stub capability for dealing with very large binaries where
one set of stubs can't be reached from all code locations.  This means
there can be multiple choices of address for a function, which might
cause function pointer comparison failures.  So for ppc32, make
non-branch references always use the first stub group.

(PowerPC64 ELFv1 is always PIC so doesn't need to define the address
of an external function as the PLT stub.  PowerPC64 ELFv2 needs a
special set of global entry stubs to serve as the address of external
functions, so it too is not affected by this bug.)

	* powerpc.cc (Target_powerpc::Branch_info::make_stub): Put
	stubs for ppc32 non-branch relocs in first stub table.
	(Target_powerpc::Relocate::relocate): Resolve similarly.
2017-09-20 09:56:19 +09:30
GDB Administrator dba74cb2b7 Automatic date update in version.in 2017-09-20 00:00:30 +00:00
John Baldwin 4e5a4f5850 Add a 'starti' command.
This works like 'start' but it stops at the first instruction rather
than the first line in main().  This is useful if one wants to single
step through runtime linker startup.

While here, introduce a RUN_ARGS_HELP macro for shared help text
between run, start, and starti.  This includes expanding the help for
start and starti to include details from run's help text.

gdb/ChangeLog:

	* NEWS (Changes since GDB 8.0): Add starti.
	* infcmd.c (enum run_break): New.
	(run_command_1): Queue pending event for RUN_STOP_AT_FIRST_INSN
	case.
	(run_command): Use enum run_how.
	(start_command): Likewise.
	(starti_command): New function.
	(RUN_ARGS_HELP): New macro.
	(_initialize_infcmd): Use RUN_ARGS_HELP for run and start
	commands.  Add starti command.

gdb/doc/ChangeLog:

	* gdb.texinfo (Starting your Program): Add description of
	starti command.  Mention starti command as an alternative for
	debugging the elaboration phase.

gdb/testsuite/ChangeLog:

	* gdb.base/starti.c: New file.
	* gdb.base/starti.exp: New file.
	* lib/gdb.exp (gdb_starti_cmd): New procedure.
2017-09-19 12:15:35 -07:00
Maciej W. Rozycki b7f54058d9 MIPS/LD: Add OpenBSD/mips64 support
Complement commit 26eebcf553 ("Update OpenBSD/mips64 support"),
<https://sourceware.org/ml/binutils/2005-04/msg00382.html>, which added
OpenBSD/mips64 support to GAS, and also add it to LD, avoiding a build
failure at the configuration stage, like:

*** ld does not support target mips64-unknown-openbsd
*** see ld/configure.tgt for supported targets
make[1]: *** [configure-ld] Error 1

As per OS support only include n64 MIPS emulations, and use the
traditional ones, matching the choice already made with the addition of
GAS support.

	ld/
	* configure.tgt <mips64el-*-openbsd*, mips64-*-openbsd*>: New
	targets.
2017-09-19 15:20:41 +01:00
Yao Qi aa70c9f195 Remove one explicit rule for monitor.o
gdb/monitor.c was removed by 40e0b27 (Delete the remaining ROM monitor
targets).

gdb:

2017-09-19  Yao Qi  <yao.qi@linaro.org>

	* Makefile.in (monitor.o): Remove the rule.
2017-09-19 10:18:57 +01:00
Yao Qi d654162044 Use DISABLE_COPY_AND_ASSIGN
We have many classes that copy cotr and assignment operator are deleted,
so this patch replaces these existing mechanical code with macro
DISABLE_COPY_AND_ASSIGN.

gdb:

2017-09-19  Yao Qi  <yao.qi@linaro.org>

	* annotate.h (struct annotate_arg_emitter): Use
	DISABLE_COPY_AND_ASSIGN.
	* common/refcounted-object.h (refcounted_object): Likewise.
	* completer.h (struct completion_result): Likewise.
	* dwarf2read.c (struct dwarf2_per_objfile): Likewise.
	* filename-seen-cache.h (filename_seen_cache): Likewise.
	* gdbcore.h (thread_section_name): Likewise.
	* gdb_regex.h (compiled_regex): Likewise.
	* gdbthread.h (scoped_restore_current_thread): Likewise.
	* inferior.h (scoped_restore_current_inferior): Likewise.
	* jit.c (jit_reader): Likewise.
	* linespec.h (struct linespec_result): Likewise.
	* mi/mi-parse.h (struct mi_parse): Likewise.
	* nat/fork-inferior.c (execv_argv): Likewise.
	* progspace.h (scoped_restore_current_program_space): Likewise.
	* python/python-internal.h (class gdbpy_enter): Likewise.
	* regcache.h (regcache): Likewise.
	* target-descriptions.c (struct tdesc_reg): Likewise.
	(struct tdesc_type): Likewise.
	(struct tdesc_feature): Likewise.
	* ui-out.h (ui_out_emit_type): Likewise.
2017-09-19 10:10:03 +01:00
Alan Modra 25516cc573 PowerPC64 stubs don't match calculated size
After the PR 21411 fix, the linker generated .eh_frame for ppc64 glink
can be edited by the generic code.  The sequence of events goes
something like:
1) Some object file adds .eh_frame aligned to 8, making the output
   .eh_frame aligned to at least 8, so linker generated .eh_frame FDE
   is padded to an 8 byte boundary.
2) All .eh_frame past the glink .eh_frame is garbage collected.
3) Generic code detects that last FDE (the glink .eh_frame) doesn't
   need to be padded to an 8 byte boundary, reducing size from 88 to
   84.
4) elf64-ppc.c check fails.

	PR 21441
	* elf64-ppc.c (ppc64_elf_build_stubs): Don't check glink_eh_frame
	size.
2017-09-19 14:32:18 +09:30
Alan Modra 3d13f3e9bd PR22150, ld keeps a version reference for gc'd symbols
elf_gc_sweep_symbol should run after verdefs are calculated, since
the verdef code creates symbols for the versions.  However,
elf_gc_sweep_symbol needs to run before verrefs so as to not emit
useless verrefs for symbols that are gc'd.

I've also removed a _bfd_elf_link_renumber_dynsyms calls added by
Maciej after I fussed about it when reviewing.  On further examination
the call appears to be unnecessary.  Looking at renumber_dynsyms also
made me realize that the test to exclude .gnu.version has been wrong
since 2016-04-26 (git commit d5486c4372), so fix that too.

	PR 22150
	* elflink.c (bfd_elf_size_dynamic_sections): Garbage collect
	symbols before calculating verrefs.  Don't renumber dynsyms
	after gc.  Exclude .gnu.version when zero or one dynsym.
	Localize some vars and reindent.
2017-09-19 12:18:49 +09:30
Alan Modra ab502e635e [GOLD, PowerPC] Add --no-stub-group-multi
The trouble with stubs per output section is that ppc32 uses a plt
stub as the address of a global function.  This needs to be unique,
otherwise we'll get multiple addresses for a function.

Obviously this is only a partial solution, since ppc32 will get
multiple stubs when code is larger than 33M.  A proper fix will
involve selecting a unique stub to use for non-branch relocs.

	* options.h (stub-group-multi): Default to true.  Add
	--no-stub-group-multi.
2017-09-19 11:45:51 +09:30
GDB Administrator ced154d810 Automatic date update in version.in 2017-09-19 00:00:29 +00:00