]> git.ipfire.org Git - thirdparty/binutils-gdb.git/log
thirdparty/binutils-gdb.git
6 years agobfd/version.h: Add rationale for BFD_VERSION_DATE
Pedro Alves [Fri, 22 Sep 2017 13:57:52 +0000 (14:57 +0100)] 
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.

6 years agoFix sometimes-uninitialized warning in gdbscm_value_address
Simon Marchi [Thu, 21 Sep 2017 14:37:40 +0000 (16:37 +0200)] 
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.

6 years agoFix gdb 8.1 Solaris compilation
Rainer Orth [Fri, 22 Sep 2017 08:42:45 +0000 (10:42 +0200)] 
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.

6 years ago[GOLD] clone assert breakage
Alan Modra [Fri, 22 Sep 2017 05:41:12 +0000 (15:11 +0930)] 
[GOLD] clone assert breakage

* resolve.cc (clone): Fix got_offset_list test.

6 years ago[GOLD] Set non-exec stack for ppc64
Alan Modra [Fri, 22 Sep 2017 01:34:41 +0000 (11:04 +0930)] 
[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.

6 years agoreadelf tests
Alan Modra [Thu, 21 Sep 2017 22:57:01 +0000 (08:27 +0930)] 
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.

6 years agoAutomatic date update in version.in
GDB Administrator [Fri, 22 Sep 2017 00:00:27 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 years agoreadelf: Handle E_MIPS_MACH_5900
Maciej W. Rozycki [Thu, 21 Sep 2017 23:54:19 +0000 (00:54 +0100)] 
readelf: Handle E_MIPS_MACH_5900

Fix commit e407c74b5b60 ("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.

6 years agoPR gas/21762: MIPS: Fix .stabs directive marking labels as MIPS16
James Cowgill [Thu, 21 Sep 2017 23:54:19 +0000 (00:54 +0100)] 
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.

6 years agoTest case for Inferior.thread_from_thread_handle
Kevin Buettner [Thu, 5 May 2016 19:39:36 +0000 (12:39 -0700)] 
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.

6 years agoDocumentation for qXfer:threads:read handle attribute
Kevin Buettner [Thu, 6 Apr 2017 21:55:32 +0000 (14:55 -0700)] 
Documentation for qXfer:threads:read handle attribute

gdb/doc/ChangeLog:

* gdb.texinfo (qXfer:threads:read): Add documentation for handle
attribute.

6 years agoAdd thread_handle_to_thread_info support for remote targets
Kevin Buettner [Tue, 4 Apr 2017 23:17:05 +0000 (16:17 -0700)] 
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.

6 years agoAdd thread_db_notice_clone to gdbserver
Kevin Buettner [Tue, 4 Apr 2017 22:25:43 +0000 (15:25 -0700)] 
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.

6 years agoDocumentation for Inferior.thread_from_thread_handle
Kevin Buettner [Wed, 4 May 2016 23:46:50 +0000 (16:46 -0700)] 
Documentation for Inferior.thread_from_thread_handle

gdb/doc/ChangeLog:

* python.texi (Inferiors In Python): Add description for method
Inferior.thread_from_thread_handle.

6 years agoAdd `thread_from_thread_handle' method to (Python) gdb.Inferior
Kevin Buettner [Wed, 4 May 2016 23:23:08 +0000 (16:23 -0700)] 
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.

6 years agoAdd target method for converting thread handle to thread_info struct pointer
Kevin Buettner [Wed, 4 May 2016 22:21:12 +0000 (15:21 -0700)] 
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.

6 years agogdbserver: Remove traces of ancient Hc handling
Pedro Alves [Thu, 21 Sep 2017 15:52:33 +0000 (16:52 +0100)] 
gdbserver: Remove traces of ancient Hc handling

Back in commit f0db101d9897 ("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.

6 years agoS/390: Fix Elf note swap s390_gs_bc vs. s390_gs_cb
Andreas Arnez [Thu, 21 Sep 2017 15:45:18 +0000 (17:45 +0200)] 
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.

6 years agoReduce excessive .eh_frame alignment for powerpc
Alan Modra [Thu, 21 Sep 2017 00:24:04 +0000 (09:54 +0930)] 
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.

6 years agolinux-waitpid: Get rid of format string warning
Simon Marchi [Thu, 21 Sep 2017 13:19:40 +0000 (15:19 +0200)] 
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.

6 years agomicroblaze-tdep: Add ATTRIBUTE_PRINTF to microblaze_debug
Simon Marchi [Thu, 21 Sep 2017 12:09:33 +0000 (14:09 +0200)] 
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.

6 years agoFix aarch64-freebsd build failure
Yao Qi [Thu, 21 Sep 2017 08:19:23 +0000 (09:19 +0100)] 
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.

6 years agooops - changelog entry omitted from previous delta
Nick Clifton [Thu, 21 Sep 2017 08:04:43 +0000 (09:04 +0100)] 
oops - changelog entry omitted from previous delta

6 years ago[SIM, ARM] Fix build failure
Yao Qi [Thu, 21 Sep 2017 08:02:25 +0000 (09:02 +0100)] 
[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.

6 years agoChange counted_command_line to a shared_ptr
Tom Tromey [Tue, 22 Aug 2017 03:51:11 +0000 (21:51 -0600)] 
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.

6 years agoUse function_view in a couple of places in breakpoint.c
Tom Tromey [Tue, 22 Aug 2017 03:37:45 +0000 (21:37 -0600)] 
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.

6 years agoAllocate bpstats with new
Tom Tromey [Tue, 22 Aug 2017 03:08:59 +0000 (21:08 -0600)] 
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.

6 years agoAutomatic date update in version.in
GDB Administrator [Thu, 21 Sep 2017 00:00:27 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 years agoeval.c:evaluate_subexp_standard: Use RAII to avoid leaks
Pedro Alves [Wed, 20 Sep 2017 23:34:41 +0000 (00:34 +0100)] 
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'.

6 years agoCheck for export dynamic symbol options when doing symbol resolution in plugins.
Teresa Johnson [Wed, 20 Sep 2017 22:43:37 +0000 (15:43 -0700)] 
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.

6 years agoRemove make_cleanup_restore_target_terminal
Tom Tromey [Wed, 20 Sep 2017 03:56:36 +0000 (21:56 -0600)] 
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.

6 years agoOverload catch_command_errors
Tom Tromey [Tue, 12 Sep 2017 20:14:33 +0000 (14:14 -0600)] 
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.

6 years agoMake "list ambiguous" show symbol names too
Pedro Alves [Wed, 20 Sep 2017 15:12:54 +0000 (16:12 +0100)] 
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.

6 years agoFix "list ambiguous_variable"
Pedro Alves [Wed, 20 Sep 2017 15:12:54 +0000 (16:12 +0100)] 
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.

6 years ago[OBV] amd64-features-makefile: add missing backslash.
Walfred Tedeschi [Wed, 20 Sep 2017 13:24:47 +0000 (15:24 +0200)] 
[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.

6 years agoadd ChangeLog from previous commit
Walfred Tedeschi [Wed, 20 Sep 2017 12:47:04 +0000 (14:47 +0200)] 
add ChangeLog from previous commit

6 years agogdb - avx512: tests were failing due to missing memory aligment.
Walfred Tedeschi [Wed, 20 Sep 2017 11:42:21 +0000 (13:42 +0200)] 
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

6 years ago[GOLD] PowerPC function address in non-PIC
Alan Modra [Tue, 19 Sep 2017 23:47:56 +0000 (09:17 +0930)] 
[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.

6 years agoAutomatic date update in version.in
GDB Administrator [Wed, 20 Sep 2017 00:00:30 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 years agoAdd a 'starti' command.
John Baldwin [Mon, 11 Sep 2017 21:57:37 +0000 (14:57 -0700)] 
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.

6 years agoMIPS/LD: Add OpenBSD/mips64 support
Maciej W. Rozycki [Tue, 19 Sep 2017 14:20:41 +0000 (15:20 +0100)] 
MIPS/LD: Add OpenBSD/mips64 support

Complement commit 26eebcf553d7 ("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.

6 years agoRemove one explicit rule for monitor.o
Yao Qi [Tue, 19 Sep 2017 09:18:57 +0000 (10:18 +0100)] 
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.

6 years agoUse DISABLE_COPY_AND_ASSIGN
Yao Qi [Tue, 19 Sep 2017 09:10:03 +0000 (10:10 +0100)] 
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.

6 years agoPowerPC64 stubs don't match calculated size
Alan Modra [Tue, 19 Sep 2017 03:52:49 +0000 (13:22 +0930)] 
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.

6 years agoPR22150, ld keeps a version reference for gc'd symbols
Alan Modra [Tue, 19 Sep 2017 02:29:30 +0000 (11:59 +0930)] 
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.

6 years ago[GOLD, PowerPC] Add --no-stub-group-multi
Alan Modra [Tue, 19 Sep 2017 02:15:51 +0000 (11:45 +0930)] 
[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.

6 years agoAutomatic date update in version.in
GDB Administrator [Tue, 19 Sep 2017 00:00:29 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 years agoCheck error return from bfd_canonicalize_dynamic_reloc
H.J. Lu [Mon, 18 Sep 2017 20:05:25 +0000 (13:05 -0700)] 
Check error return from bfd_canonicalize_dynamic_reloc

Since bfd_canonicalize_dynamic_reloc returns -1 on error, check it in
_bfd_x86_elf_get_synthetic_symtab.

PR ld/22148
* elfxx-x86.c (_bfd_x86_elf_get_synthetic_symtab): Check error
return from bfd_canonicalize_dynamic_reloc.

6 years agodwarf2expr: Remove unused abort_expression label in execute_stack_op
Simon Marchi [Mon, 18 Sep 2017 11:09:20 +0000 (13:09 +0200)] 
dwarf2expr: Remove unused abort_expression label in execute_stack_op

The label abort_expression is unused, so remove it.

gdb/ChangeLog:

* dwarf2expr.c (dwarf_expr_context::execute_stack_op): Remove
label abort_expression.

6 years ago[PATCH] Sync libiberty/ & include/ with GCC - addendum: update elfcpp/dwarf.h with...
Nick Clifton [Mon, 18 Sep 2017 08:21:38 +0000 (09:21 +0100)] 
[PATCH] Sync libiberty/ & include/ with GCC - addendum: update elfcpp/dwarf.h with the new DW_CFA_DUP macro.

From the original email:
  Note this brings in the interface files for libcc1/G++ as well, which
  we will be needing in GDB soon anyway.  That commit renamed a method
  in the C interface and that required a small update to GDB's compile/
  code, which I've included that in this patch to keep the tree
  building.

From the follow up email:
  That breaks gold:

  g++ -DHAVE_CONFIG_H -I. -I../../binutils/gold  -I../../binutils/gold -I../../binutils/gold/../include -I../../binutils/gold/../elfcpp -DLOCALEDIR="\"/usr/share/locale\"" -DBINDIR="\"/usr/bin\"" -DTOOLBINDIR="\"/usr/x86_64-linux/bin\"" -DTOOLLIBDIR="\"/usr/x86_64-linux/lib\""   -W -Wall    -Werror -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -frandom-seed=dwarf_reader.o  -O2 -g -MT dwarf_reader.o -MD -MP -MF .deps/dwarf_reader.Tpo -c -o dwarf_reader.o ../../binutils/gold/dwarf_reader.cc
  In file included from ../../binutils/gold/../elfcpp/dwarf.h:83:0,
                   from ../../binutils/gold/dwarf_reader.cc:30:
  ../../binutils/gold/../include/dwarf2.def:781:1: error: expected ?}? before ?DW_CFA_DUP?
   DW_CFA_DUP (DW_CFA_AARCH64_negate_ra_state, 0x2d)

6 years agoAutomatic date update in version.in
GDB Administrator [Mon, 18 Sep 2017 00:00:30 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 years agoAutomatic date update in version.in
GDB Administrator [Sun, 17 Sep 2017 00:00:32 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 years agoRefactor handle_qxfer_libraries and friends to use std::string
Simon Marchi [Sat, 16 Sep 2017 12:22:11 +0000 (14:22 +0200)] 
Refactor handle_qxfer_libraries and friends to use std::string

Using std::string in handle_qxfer_libraries and friends allow to
simplify the code.  We don't have to manually free the buffer, and we
don't have to pre-compute the required space.

gdb/gdbserver/ChangeLog:

* server.c (accumulate_file_name_length): Remove.
(emit_dll_description): Adjust to std::string change.
(handle_qxfer_libraries): Use std::string to hold document.

6 years agoMake xml_escape_text return an std::string
Simon Marchi [Sat, 16 Sep 2017 12:19:31 +0000 (14:19 +0200)] 
Make xml_escape_text return an std::string

This is a simple replacement, it allows removing some manual free'ing in
the callers.

gdb/ChangeLog:

* common/buffer.c (buffer_xml_printf): Adjust.
* common/xml-utils.c (xml_escape_text): Change return type to
std::string, update code accordingly.
* common/xml-utils.h (xml_escape_text): Change return type to
std::string.
* rs6000-aix-tdep.c (rs6000_aix_shared_library_to_xml): Adjust.
* windows-tdep.c (windows_xfer_shared_library): Adjust.
* unittests/xml-utils-selftests.c (test_xml_escape_text):
Adjust.

gdb/gdbserver/ChangeLog:

* linux-low.c (linux_qxfer_libraries_svr4): Adjust to change of
return type of xml_escape_text.
* server.c (emit_dll_description): Likewise.

6 years agoAdd unit test for xml_escape_text
Simon Marchi [Sat, 16 Sep 2017 12:16:27 +0000 (14:16 +0200)] 
Add unit test for xml_escape_text

The following patch modifies xml_escape_text, so I took the opportunity
to write a unit test for it.

gdb/ChangeLog:

* Makefile.in (SUBDIR_UNITTESTS_SRCS): Add new source file.
(SUBDIR_UNITTESTS_OBS): Add new object file.
* unittests/xml-utils-selftests.c: New file.

6 years agoAdd selftests run filtering
Simon Marchi [Sat, 16 Sep 2017 12:06:03 +0000 (14:06 +0200)] 
Add selftests run filtering

With the growing number of selftests, I think it would be useful to be
able to run only a subset of the tests.  This patch associates a name to
each registered selftest.  It then allows doing something like:

  (gdb) maintenance selftest aarch64
  Running self-tests.
  Running selftest aarch64-analyze-prologue.
  Running selftest aarch64-process-record.
  Ran 2 unit tests, 0 failed

or with gdbserver:

  ./gdbserver --selftest=aarch64

In both cases, only the tests that contain "aarch64" in their name are
ran.  To help validate that the tests you want to run were actually ran,
it also prints a message with the test name before running each test.

Right now, all the arch-dependent tests are registered as a single test
of the selftests.  To be able to filter those too, I made them
"first-class citizen" selftests.  The selftest type is an interface,
with different implementations for "simple selftests" and "arch
selftests".  The run_tests function simply iterates on that an invokes
operator() on each test.

I changed the tests data structure from a vector to a map, because

  - it allows iterating in a stable (alphabetical) order
  - it allows to easily verify if a test with a given name has been
    registered, to avoid duplicates

There's also a new command "maintenance info selftests" that lists the
registered selftests.

gdb/ChangeLog:

* common/selftest.h (selftest): New struct/interface.
(register_test): Add name parameter, add new overload.
(run_tests): Add filter parameter.
(for_each_selftest_ftype): New typedef.
(for_each_selftest): New declaration.
* common/selftest.c (tests): Change type to
map<string, unique_ptr<selftest>>.
(simple_selftest): New struct.
(register_test): New function.
(register_test): Add name parameter and use it.
(run_tests): Add filter parameter and use it.  Add prints.
Adjust to vector -> map change.
* aarch64-tdep.c (_initialize_aarch64_tdep): Add names when
registering selftests.
* arm-tdep.c (_initialize_arm_tdep): Likewise.
* disasm-selftests.c (_initialize_disasm_selftests): Likewise.
* dwarf2-frame.c (_initialize_dwarf2_frame): Likewise.
* dwarf2loc.c (_initialize_dwarf2loc): Likewise.
* findvar.c (_initialize_findvar): Likewise.
* gdbarch-selftests.c (_initialize_gdbarch_selftests): Likewise.
* maint.c (maintenance_selftest): Update call to run_tests.
(maintenance_info_selftests): New function.
(_initialize_maint_cmds): Register "maintenance info selftests"
command.  Update "maintenance selftest" doc.
* regcache.c (_initialize_regcache): Add names when registering
selftests.
* rust-exp.y (_initialize_rust_exp): Likewise.
* selftest-arch.c (gdbarch_selftest): New struct.
(gdbarch_tests): Remove.
(register_test_foreach_arch): Add name parameter.  Call
register_test.
(tests_with_arch): Remove, move most content to
gdbarch_selftest::operator().
(_initialize_selftests_foreach_arch): Remove.
* selftest-arch.h (register_test_foreach_arch): Add name
parameter.
(run_tests_with_arch): New declaration.
* utils-selftests.c (_initialize_utils_selftests): Add names
when registering selftests.
* utils.c (_initialize_utils): Likewise.
* unittests/array-view-selftests.c
(_initialize_array_view_selftests): Likewise.
* unittests/environ-selftests.c (_initialize_environ_selftests):
Likewise.
* unittests/function-view-selftests.c
(_initialize_function_view_selftests): Likewise.
* unittests/offset-type-selftests.c
(_initialize_offset_type_selftests): Likewise.
* unittests/optional-selftests.c
(_initialize_optional_selftests): Likewise.
* unittests/scoped_restore-selftests.c
(_initialize_scoped_restore_selftests): Likewise.
* NEWS: Document "maintenance selftest" and "maint info
selftests".

gdb/gdbserver/ChangeLog:

* server.c (captured_main): Accept argument for --selftest.
Update run_tests call.
* linux-x86-tdesc-selftest.c (initialize_low_tdesc): Add names
when registering selftests.

gdb/doc/ChangeLog:

* gdb.texinfo (Maintenance Commands): Document filter parameter
of "maint selftest".  Document "maint info selftests" command.

6 years agomi_load_progress: Restore current_uiout using a scoped_restore
Simon Marchi [Sat, 16 Sep 2017 11:45:56 +0000 (13:45 +0200)] 
mi_load_progress: Restore current_uiout using a scoped_restore

Simply use a scoped_restore instead of manually saving and restoring
current_uiout.

gdb/ChangeLog:

* mi/mi-main.c (mi_load_progress): Restore current_uiout using a
scoped_restore.

6 years agomi_load_progress: Use unique_ptr to manage ui_out lifetime
Simon Marchi [Sat, 16 Sep 2017 11:45:55 +0000 (13:45 +0200)] 
mi_load_progress: Use unique_ptr to manage ui_out lifetime

In mi_load_progress, we xfree a ui_out object.  Because ui_out is not
trivially destructible, it should be freed with delete.  This patch
makes use of a unique_ptr to do it.

gdb/ChangeLog:

* mi/mi-main.c (mi_load_progress): Make uiout variable
a unique_ptr.

diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index 0ee2605..0359dc1
100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -2325,7 +2325,6
@@ mi_load_progress (const char *section_name, static char
*previous_sect_name = NULL; int new_section; struct ui_out *saved_uiout;
-  struct ui_out *uiout; struct mi_interp *mi = (struct mi_interp *)
   current_interpreter ();

   /* This function is called through deprecated_show_load_progress
@@ -2333,17 +2332,19 @@ mi_load_progress (const char *section_name,
      of this function.  */
   saved_uiout = current_uiout;

+  std::unique_ptr<ui_out> uiout;
+
   if (current_interp_named_p (INTERP_MI)
       || current_interp_named_p (INTERP_MI2))
-    current_uiout = mi_out_new (2);
+    uiout.reset (mi_out_new (2));
   else if (current_interp_named_p (INTERP_MI1))
-    current_uiout = mi_out_new (1);
+    uiout.reset (mi_out_new (1));
   else if (current_interp_named_p (INTERP_MI3))
-    current_uiout = mi_out_new (3);
+    uiout.reset (mi_out_new (3));
   else
     return;

-  uiout = current_uiout;
+  current_uiout = uiout.get ();

   new_section = (previous_sect_name ?
   strcmp (previous_sect_name, section_name) : 1);
@@ -2356,12 +2357,12 @@ mi_load_progress (const char *section_name,
  fputs_unfiltered (current_token, mi->raw_stdout);
       fputs_unfiltered ("+download", mi->raw_stdout);
       {
- ui_out_emit_tuple tuple_emitter (uiout, NULL);
+ ui_out_emit_tuple tuple_emitter (uiout.get (), NULL);
  uiout->field_string ("section", section_name);
  uiout->field_int ("section-size", total_section);
  uiout->field_int ("total-size", grand_total);
       }
-      mi_out_put (uiout, mi->raw_stdout);
+      mi_out_put (uiout.get (), mi->raw_stdout);
       fputs_unfiltered ("\n", mi->raw_stdout);
       gdb_flush (mi->raw_stdout);
     }
@@ -2374,19 +2375,18 @@ mi_load_progress (const char *section_name,
  fputs_unfiltered (current_token, mi->raw_stdout);
       fputs_unfiltered ("+download", mi->raw_stdout);
       {
- ui_out_emit_tuple tuple_emitter (uiout, NULL);
+ ui_out_emit_tuple tuple_emitter (uiout.get (), NULL);
  uiout->field_string ("section", section_name);
  uiout->field_int ("section-sent", sent_so_far);
  uiout->field_int ("section-size", total_section);
  uiout->field_int ("total-sent", total_sent);
  uiout->field_int ("total-size", grand_total);
       }
-      mi_out_put (uiout, mi->raw_stdout);
+      mi_out_put (uiout.get (), mi->raw_stdout);
       fputs_unfiltered ("\n", mi->raw_stdout);
       gdb_flush (mi->raw_stdout);
     }

-  xfree (uiout);
   current_uiout = saved_uiout;
 }

6 years agoUse std::vector on tdesc->reg_defs (gdbserver/tdesc.h)
Sergio Durigan Junior [Sun, 10 Sep 2017 16:17:18 +0000 (12:17 -0400)] 
Use std::vector on tdesc->reg_defs (gdbserver/tdesc.h)

This is a followup patch to the build breakage fix on AArch64.  While
doing the fix, I found it better to convert tdesc->reg_defs (on
gdbserver/tdesc.h) from using VEC to using std::vector.  This makes
the code easier to read and maintain, and also is one more step
towards the C++fication.

Regtested on BuildBot.

2017-09-16  Sergio Durigan Junior  <sergiodj@redhat.com>

* regcache.c (get_thread_regcache): Update code to use "std::vector"
instead of "VEC" for "target_desc.reg_defs".
(regcache_cpy): Likewise.
(registers_to_string): Likewise.
(registers_from_string): Likewise.
(find_regno): Likewise.
(supply_regblock): Likewise.
(regcache_raw_read_unsigned): Likewise.
* tdesc.c (init_target_desc): Likewise.
(tdesc_create_reg): Likewise.
* tdesc.h: Remove declaration of "tdesc_reg_p".  Include <vector>.
(struct target_desc) <reg_defs>: Convert to "std::vector".
(target_desc): Do not initialize "reg_defs".
(~target_desc): Update code to use "std::vector" instead of "VEC"
for "target_desc.reg_defs".
(operator==): Likewise.

6 years agoAutomatic date update in version.in
GDB Administrator [Sat, 16 Sep 2017 00:00:34 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 years agoSync libiberty/ & include/ with GCC
Pedro Alves [Fri, 15 Sep 2017 16:40:33 +0000 (17:40 +0100)] 
Sync libiberty/ & include/ with GCC

Note this brings in the interface files for libcc1/G++ as well, which
we will be needing in GDB soon anyway.  That commit renamed a method
in the C interface and that required a small update to GDB's compile/
code, which I've included that in this patch to keep the tree
building.

include/ChangeLog:
2017-09-15  Pedro Alves  <palves@redhat.com>

* ansidecl.h (DISABLE_COPY_AND_ASSIGN): New macro.

2017-09-12  Jiong Wang  <jiong.wang@arm.com>

* dwarf2.def (DW_CFA_AARCH64_negate_ra_state): New DW_CFA_DUP.
* dwarf2.h (DW_CFA_DUP): New define.

2017-08-21  Richard Biener  <rguenther@suse.de>

* simple-object.h (simple_object_copy_lto_debug_sections): New
function.

2017-05-18  Martin Liska  <mliska@suse.cz>

* ansidecl.h: Define CONSTEXPR macro.

2017-05-24  Nathan Sidwell  <nathan@acm.org>

* libiberty.h (ASTRDUP): Adjust cast to avoid warning.

2017-01-30  Alexandre Oliva <aoliva@redhat.com>

Introduce C++ support in libcc1.
* gcc-c-fe.def (int_type_v0): Rename from...
(int_type): ... this.  Introduce new version.
(float_type_v0): Rename from...
(float_type): ... this.  Introduce new version.
(char_type): New.
* gcc-c-interface.h (gcc_c_api_version): Add GCC_C_FE_VERSION_1.
(gcc_type_array): Move...
* gcc-interface.h: ... here.
* gcc-cp-fe.def: New.
* gcc-cp-interface.h: New.

2016-04-29  Oleg Endo  <olegendo@gcc.gnu.org>

* longlong.h (umul_ppmm): Remove SHMEDIA checks.
(__umulsidi3, count_leading_zeros): Remove SHMEDIA implementations.

2017-09-15  Yao Qi  <yao.qi@linaro.org>
    Pedro Alves  <palves@redhat.com>

* ansidecl.h (DISABLE_COPY_AND_ASSIGN): New macro.

2017-09-12  Jiong Wang  <jiong.wang@arm.com>

* dwarf2.def (DW_CFA_AARCH64_negate_ra_state): New DW_CFA_DUP.
* dwarf2.h (DW_CFA_DUP): New define.

2017-08-21  Richard Biener  <rguenther@suse.de>

* simple-object.h (simple_object_copy_lto_debug_sections): New
function.

2017-05-18  Martin Liska  <mliska@suse.cz>

* ansidecl.h: Define CONSTEXPR macro.

2017-05-24  Nathan Sidwell  <nathan@acm.org>

* libiberty.h (ASTRDUP): Adjust cast to avoid warning.

2017-01-30  Alexandre Oliva <aoliva@redhat.com>

Introduce C++ support in libcc1.
* gcc-c-fe.def (int_type_v0): Rename from...
(int_type): ... this.  Introduce new version.
(float_type_v0): Rename from...
(float_type): ... this.  Introduce new version.
(char_type): New.
* gcc-c-interface.h (gcc_c_api_version): Add GCC_C_FE_VERSION_1.
(gcc_type_array): Move...
* gcc-interface.h: ... here.
* gcc-cp-fe.def: New.
* gcc-cp-interface.h: New.

2016-04-29  Oleg Endo  <olegendo@gcc.gnu.org>

* longlong.h (umul_ppmm): Remove SHMEDIA checks.
(__umulsidi3, count_leading_zeros): Remove SHMEDIA implementations.

libiberty/ChangeLog:
2017-09-15  Nathan Sidwell  <nathan@acm.org>

PR demangler/82195
* cp-demangle.c (d_name): Add 'toplevel' parm.  Pass to ...
(d_local_name): ... here.  Parse trailing function args on nested
local_name.
(d_encoding, d_special_name, d_class_enum_type): Adjust d_name calls.
* testsuite/demangle-expected: Add tests.

2017-09-15  Richard Biener  <rguenther@suse.de>

PR lto/81968
* simple-object-elf.c (simple_object_elf_copy_lto_debug_sections):
Iterate marking dependent sections necessary.

2017-09-15  Nathan Sidwell  <nathan@acm.org>

* cp-demangle.c (is_fnqual_component_type): Reimplement using
FNQUAL_COMPONENT_CASE.
(d_encoding): Hold bare_function_type in local var.
(d_local_name): Build name in both cases and build result once.
Collapse switch-if to single conditional.
(d_local_name):

* testsuite/demangle-expected: Realign blank lines with tests.

2017-09-12  Jiong Wang  <jiong.wang@arm.com>

* dwarfnames.c (DW_CFA_DUP): New define.

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

* compile/compile-c-types.c (convert_enum, convert_int)
(convert_float): Adjust to refer to int_type_v0 and float_type_v0.

6 years agogdbserver: Remove thread_to_gdb_id
Simon Marchi [Fri, 15 Sep 2017 16:02:51 +0000 (18:02 +0200)] 
gdbserver: Remove thread_to_gdb_id

As explained in the previous patch, the gdb_id concept is no longer
relevant.  The function thread_to_gdb_id is trivial, it returns the
thread's ptid.  Remove it and replace its usage with ptid_of.

The changes in nto-low.c and lynx-low.c are fairly straightforward, but
I was not able to build test them.

gdb/gdbserver/ChangeLog:

* inferiors.h (thread_to_gdb_id): Remove.
* inferiors.c (thread_to_gdb_id): Remove.
* server.c (handle_qxfer_threads_worker, handle_query): Adjust.
* lynx-low.c (lynx_resume, lynx_wait_1, lynx_fetch_registers,
lynx_store_registers, lynx_read_memory, lynx_write_memory):
Likewise.
* nto-low.c (nto_fetch_registers, nto_store_registers,
nto_stopped_by_watchpoint, nto_stopped_data_address): Likewise.

6 years agogdbserver: Remove gdb_id_to_thread_id
Simon Marchi [Fri, 15 Sep 2017 16:02:51 +0000 (18:02 +0200)] 
gdbserver: Remove gdb_id_to_thread_id

From what I understand, this function is not doing anything useful as of
today.

Here's the result of my archeological research:

- The field thread_info::gdb_id was added in

  a06660f7  Use LWP IDs for thread IDs in gdbserver

  There was problem when using a 32-bits gdb with a 64-bits gdbserver.
  For some reason that I don't fully understand, the thread ids
  exchanged between gdb and gdbserver could overflow a 32 bits data
  type.  My guess is that they were the thread address (e.g. the
  0x7ffff7f20b40 in "Thread 0x7ffff7f20b40 (LWP 1058)" today).  This
  patch changed that so gdb/gdbserver would talk in terms of the OS
  assigned numerical id (as shown in ps).  It therefore added a way to
  convert between this gdb_id (the numerical id) and the thread id (the
  address).

95954743cb  Implement the multiprocess extensions, and add linux
              multiprocess supportNon-stop mode support.

  This patch made gdbserver deal with threads using their numerical ids
  and not the address-like id.  Starting from there, the gdb_id <->
  thread id conversion was not needed anymore, since the remote protocol
  and gdbserver were using the same kind of ids again.  The gdb_id field
  in the thread_info structure was also unused starting there.

d50171e4  Teach linux gdbserver to step-over-breakpoints.

  This patch moved the thread_info structure around, and got rid of the
  gdb_id field (which was unused).

Looking at the implementation of gdb_id_to_thread_id, it is not doing
anything useful.  It is looking up a thread by ptid using
find_thread_ptid, which basically loops over all threads looking at
their entry.id field.  If a thread with that ptid is found, it returns
its entry.id field.  So it will always return the same thing as it input
(with the exception of if no thread exist with that ptid, then it will
return null_ptid).

gdb/gdbserver/ChangeLog:

* inferiors.h (gdb_id_to_thread_id): Remove.
* inferiors.c (gdb_id_to_thread_id): Remove.
* server.c (process_serial_event): Adjust to gdb_id_to_thread_id
removal.  Move pid declaration closer to where it's used.

6 years agogdbserver: Move detach code to its own function
Simon Marchi [Fri, 15 Sep 2017 15:59:37 +0000 (17:59 +0200)] 
gdbserver: Move detach code to its own function

The code required to handle the 'D' packet is non trivial, so move it
out to its own function.

The moved out code is identical, except for the call to strtol and some
breaks that became returns.

Tested manually, and by running gdb.base/*detach*.exp with
native-gdbserver and native-extended-gdbserver.

gdb/gdbserver/ChangeLog:

* server.c (handle_detach): New function.
(process_serial_event): Move code out, call handle_detach.

6 years agoDeduplicate require_running macros and move them up
Simon Marchi [Fri, 15 Sep 2017 15:59:36 +0000 (17:59 +0200)] 
Deduplicate require_running macros and move them up

I find it very confusing to define the require_running in the middle of
the file, and re-define it to something else later in the middle of the
same file.  I think it would be better if those macros had different
names so that we know exactly what they do.

gdb/gdbserver/ChangeLog:

* server.c (require_running): Rename to ...
(require_running_or_return): ... this ...
(require_running_or_break): ... and this.
(handle_query, process_serial_event): Adjust.

6 years agoAdd -l option to src-release script.
Nick Clifton [Fri, 15 Sep 2017 15:18:20 +0000 (16:18 +0100)] 
Add -l option to src-release script.

Since we are updating src-release.sh I thought I would check in this
small patch.  It adds the option to create lzip compressed tarballs
via the -l command line option.

* src-release.sh (LZIPPROG): New define.  Provides the name of the
lzip program.
(do_lz): New function.  Compresses a tarball using the lzip
program.
(do_compress): Add support for lzip compression.
(usage): Mention -l option.
(build_release): Support -l option to invoke lzip compression.

6 years agolinux-low: Remove unused variables
Simon Marchi [Fri, 15 Sep 2017 14:41:35 +0000 (16:41 +0200)] 
linux-low: Remove unused variables

gdb/gdbserver/ChangeLog:

* linux-low.c (linux_set_resume_request): Remove unused
variables.

6 years agodwarf2read: Replace copy_string usages with savestring
Simon Marchi [Fri, 15 Sep 2017 14:41:34 +0000 (16:41 +0200)] 
dwarf2read: Replace copy_string usages with savestring

copy_string does the exact same thing as savestring, so replace the
usages of the former with the latter.

gdb/ChangeLog:

* dwarf2read.c (copy_string): Remove.
(parse_macro_definition): Replace copy_string with savestring.

6 years agogdbserver: Remove duplicate functions to find any thread of process
Simon Marchi [Fri, 15 Sep 2017 12:53:07 +0000 (14:53 +0200)] 
gdbserver: Remove duplicate functions to find any thread of process

We have about 6 functions/callbacks to find_inferior meant to find a
thread that belongs to a given pid.  Remove all but
find_any_thread_of_pid and replace their uses with
find_any_thread_of_pid.

gdb/gdbserver/ChangeLog:

* server.c (first_thread_of): Remove.
(process_serial_event): Replace usage of first_thread_of with
find_any_thread_of_pid.
* tracepoint.c (same_process_p): Remove.
(gdb_agent_about_to_close): Replace usage of same_process_p with
find_any_thread_of_pid.
* linux-x86-low.c (same_process_callback): Remove.
(x86_arch_setup_process_callback): Replace usage of
same_process_callback with find_any_thread_of_pid.
* thread-db.c (any_thread_of): Remove.
(switch_to_process): Replace usage of any_thread_of with
find_any_thread_of_pid.
* inferiors.c (thread_pid_matches_callback): Remove.
(find_thread_process): Adjust to use find_any_thread_of_pid.

6 years agoFix x86 build failures
Yao Qi [Fri, 15 Sep 2017 12:05:39 +0000 (13:05 +0100)] 
Fix x86 build failures

Christophe Lyon told me that GDB build failed on i386-linux with
--enable-64-bit-bfd=yes, so I audit the gdb/configure.tgt again.  I
find that i386-darwin has the same issue too.  Additionally, GDB
for solaris target fails to build too.  This patch fixes all of them.

gdb:

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

* configure.tgt (i[34567]86-*-darwin*): Append amd64.o to
gdb_target_obs.
(i[34567]86-*-solaris2.1[0-9]* | x86_64-*-solaris2.1[0-9]*):
Likewise.
(i[34567]86-*-linux*): Likewise.

6 years agoPR22118, Incorrectly-capitalized regexp
Alan Modra [Fri, 15 Sep 2017 10:38:02 +0000 (20:08 +0930)] 
PR22118, Incorrectly-capitalized regexp

PR 22118
* testsuite/ld-aarch64/erratum843419.d: Correct regexp.

6 years agoEnable/disable various dirs in src-release.sh
Alan Modra [Fri, 15 Sep 2017 05:03:58 +0000 (14:33 +0930)] 
Enable/disable various dirs in src-release.sh

gold needs to be enabled for a binutils release, but it's rather odd
to do so for gas, gdb or sim.  This patch passes various --enable and
--disable options depending on the directories being released.

* src-release.sh (do_proto_toplev): Revert last patch.  Enable or
disable binutils, gas, gdb, gold, gprof, ld, libdecnumber, readline,
and sim depending on $tool and $support_files.  Echo configure line.

6 years agoError when 32-bit ar tries to handle 4G or larger files
Alan Modra [Fri, 15 Sep 2017 00:52:13 +0000 (10:22 +0930)] 
Error when 32-bit ar tries to handle 4G or larger files

We used to silently truncate the size returned by stat() to 32 bits.
While it is possible to make binutils handle a 64-bit off_t on a
32-bit host, to me the effort needed doesn't seem worth the benefit.
Instead, error if we truncate the size.  I've written the test the way
I have to avoid a signed/unsigned warning.

PR 22116
* archive.c (bfd_ar_hdr_from_filesystem): Detect when status.st_size
overflows bfd_size_type.

6 years agoAutomatic date update in version.in
GDB Administrator [Fri, 15 Sep 2017 00:00:28 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 years agoMake dwarf_expr_context::stack an std::vector
Simon Marchi [Thu, 14 Sep 2017 20:36:57 +0000 (22:36 +0200)] 
Make dwarf_expr_context::stack an std::vector

Replace the manually managed array with a vector.  It is mostly
straightforward, except maybe one thing in execute_stack_op, in the
handling of DW_OP_fbreg.  When the code stumbles on that opcode while
evaluating an expression, it needs to evaluate a subexpression to find
where the fb reg has been saved.  Rather than creating a new context, it
reuses the current context.  It saves the size of the stack before and
restores the stack to that size after.

I think we can do a little bit better by saving the current stack
locally and installing a new empty stack.  This way, if the
subexpression is malformed and underflows, we'll get an exception.
Before, it would have overwritten the top elements of the top-level
expression.  The evaluation of the top-level expression would have then
resumed with the same stack size, but possibly some corrupted elements.

gdb/ChangeLog:

* dwarf2expr.h (dwarf_stack_value): Add constructor.
(dwarf_expr_context) <~dwarf_expr_context>: Define as default.
<stack>: Change type to std::vector.
<stack_len, stack_allocated>: Remove.
<grow_stack>: Remove.
* dwarf2expr.c (dwarf_expr_context::dwarf_expr_context): Adjust.
(dwarf_expr_context::~dwarf_expr_context): Remove.
(dwarf_expr_context::grow_stack): Remove.
(dwarf_expr_context::push): Adjust.
(dwarf_expr_context::pop): Adjust.
(dwarf_expr_context::fetch): Adjust.
(dwarf_expr_context::fetch_in_stack_memory): Adjust.
(dwarf_expr_context::stack_empty_p): Adjust.
(dwarf_expr_context::execute_stack_op): Adjust.

6 years agoglobalaudit.rd: Allow additional bits in DT_FLAGS_1
H.J. Lu [Thu, 14 Sep 2017 19:45:18 +0000 (12:45 -0700)] 
globalaudit.rd: Allow additional bits in DT_FLAGS_1

With -PIE on x86-64, we get

 0x000000006ffffffb (FLAGS_1)            Flags: GLOBAUDIT PIE

We should allow additional bits in DT_FLAGS_1.

PR ld/22139
* testsuite/ld-elf/globalaudit.rd: Allow additional bits in
DT_FLAGS_1.

6 years agox86: Cache section contents and relocations
H.J. Lu [Thu, 14 Sep 2017 18:41:58 +0000 (11:41 -0700)] 
x86: Cache section contents and relocations

bfd/

PR ld/22135
* elf32-i386.c (elf_i386_convert_load_reloc): Add an argument
to indicate if conversion is performed.
(elf_i386_check_relocs): Cache section contents and relocations
if conversion is performed.
* elf64-x86-64.c (elf_x86_64_check_relocs): Cache section
contents and relocations if conversion is performed.

ld/

PR ld/22135
* testsuite/ld-i386/i386.exp: Run pr22135.
* testsuite/ld-x86-64/x86-64.exp: Likewise.
* testsuite/ld-i386/pr22135.d: New file.
* testsuite/ld-i386/pr22135.s: Likewise.
* testsuite/ld-x86-64/pr22135.d: Likewise.
* testsuite/ld-x86-64/pr22135.s: Likewise.

6 years agogdb.base/nodebug.exp: Rename called functions
Pedro Alves [Thu, 14 Sep 2017 17:09:42 +0000 (18:09 +0100)] 
gdb.base/nodebug.exp: Rename called functions

I'm seeing these failures on my system:

  FAIL: gdb.base/nodebug.exp: p (double) mult (2.0, 3.0)
  FAIL: gdb.base/nodebug.exp: p ((double (*) (double, double)) mult)(2.0f, 3.0f)
  FAIL: gdb.base/nodebug.exp: p ((double (*) (double, double)) mult)(2, 3)

The problem is simply that GDB is finding a symbol named "mult" from
glibc's debug info:

  (gdb) ptype mult
  type = enum expression_operator {var, num, lnot, mult, divide, module, plus, minus, less_than, greater_than, less_or_equal, greater_or_equal, equal, not_equal, land, lor,  qmop}

  (gdb) info types expression_operator
  All types matching regular expression "expression_operator":

  File plural-exp.h:
  enum expression_operator;

Fix this by unloading symbols from shared libraries.

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

* gdb.base/nodebug.exp (nodebug_runto): New procedure.
(top level): Use it instead of runto.

6 years agoMake dwarf_expr_context::stack_empty_p return a bool
Simon Marchi [Thu, 14 Sep 2017 14:54:37 +0000 (16:54 +0200)] 
Make dwarf_expr_context::stack_empty_p return a bool

gdb/ChangeLog:

* dwarf2expr.h (dwarf_expr_context) <stack_empty_p>: Change
return type to bool.
* dwarf2expr.c (dwarf_expr_context::stack_empty_p): Likewise.

6 years agoMake dwarf_stack_value::in_stack_memory a bool
Simon Marchi [Thu, 14 Sep 2017 14:13:33 +0000 (16:13 +0200)] 
Make dwarf_stack_value::in_stack_memory a bool

Replace int with bool, because that's what it is.

gdb/ChangeLog:

* dwarf2expr.h (dwarf_expr_piece) <v.mem.in_stack_memory>:
Change type to bool.
(dwarf_stack_value) <in_stack_memory>: Likewise.
(dwarf_expr_context) <push_address>: Change parameter type to
bool.
<fetch_in_stack_memory>: Change return type to bool.
<push>: Change parameter type to bool.
* dwarf2expr.c (dwarf_expr_context::push): Change parameter type
to bool.
(dwarf_expr_context::push_address): Likewise.
(dwarf_expr_context::fetch_in_stack_memory): Change return type
to bool.
(dwarf_expr_context::execute_stack_op): Adjust.
* dwarf2loc.c (dwarf2_evaluate_loc_desc_full): Adjust.

6 years agoMake dwarf_expr_piece::pieces an std::vector
Simon Marchi [Thu, 14 Sep 2017 13:57:01 +0000 (15:57 +0200)] 
Make dwarf_expr_piece::pieces an std::vector

Change the manually managed array dwarf_expr_piece::piece with an
std::vector.  After passing the pieces array to allocate_piece_closure,
dwarf2_evaluate_loc_desc_full doesn't need that data anymore.  We can
therefore move the content of the vector to avoid copying it.

Reg-tested on the buildbot.

gdb/ChangeLog:

* dwarf2expr.h (struct dwarf_expr_piece): Move up.
(struct dwarf_expr_context) <n_pieces>: Remove.
<pieces>: Change type to std::vector.
* dwarf2expr.c (dwarf_expr_context::dwarf_expr_context): Adjust.
(dwarf_expr_context::~dwarf_expr_context): Don't manually free
pieces.
(dwarf_expr_context::add_piece): Adjust.
* dwarf2loc.c (struct piece_closure): Initialize fields.
<n_pieces>: Remove.
<pieces>: Change type to std::vector.
(allocate_piece_closure): Adjust, change parameter to
std::vector rvalue and std::move it to piece_closure.
(rw_pieced_value): Adjust.
(check_pieced_synthetic_pointer): Adjust.
(indirect_synthetic_pointer): Adjust.
(coerce_pieced_ref): Adjust.
(free_pieced_value_closure):  Adjust.  Use delete to free
piece_closure.
(dwarf2_evaluate_loc_desc_full): Adjust.  std::move ctx.pieces
to allocate_piece_closure.
(dwarf2_loc_desc_get_symbol_read_needs): Adjust.

6 years agoFix address violation when parsing a corrupt PE binary.
Nick Clifton [Thu, 14 Sep 2017 10:15:55 +0000 (11:15 +0100)] 
Fix address violation when parsing a corrupt PE binary.

PR binutils/22113
* peXXigen.c (pe_print_idata): Extend check for HintName vector
entries.

6 years agoAdd enable-gold and enable-ld to src-release
matt rice [Wed, 13 Sep 2017 16:46:22 +0000 (09:46 -0700)] 
Add enable-gold and enable-ld to src-release

So that the tarball picks up gold bison output.

* src-release.sh (do_proto_toplev): Enable gold during release process.

6 years agoPR22127, as segfaults assembling invalid .reloc
Alan Modra [Thu, 14 Sep 2017 00:49:31 +0000 (10:19 +0930)] 
PR22127, as segfaults assembling invalid .reloc

"sec" gets set to NULL on errors in the offset expression.  This patch
disables part of the reloc expression processing that needs "sec"
valid.  I didn't disable the entire reloc expression handling so that
errors in the reloc expression are reported even when the offset
expression has an error.

PR 22127
* write.c (resolve_reloc_expr_symbols): Don't segfault when
sec has been set to NULL.

6 years agoAutomatic date update in version.in
GDB Administrator [Thu, 14 Sep 2017 00:00:26 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 years agoelfxx-x86.h: Fix a typo in comments
H.J. Lu [Wed, 13 Sep 2017 11:25:14 +0000 (04:25 -0700)] 
elfxx-x86.h: Fix a typo in comments

* elfxx-x86.h: Fix a typo in comments.

6 years agoAutomatic date update in version.in
GDB Administrator [Wed, 13 Sep 2017 00:00:31 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 years agoprobe: Replace VEC(probe_ops_cp) with std::vector
Simon Marchi [Tue, 12 Sep 2017 12:15:23 +0000 (14:15 +0200)] 
probe: Replace VEC(probe_ops_cp) with std::vector

This patch replaces the usage of VEC to store pointers to probe_ops with
an std::vector.  The sole usage of that vector type is one global
variable that holds the ops for the various kinds of probes, so this is
pretty straightforward (no allocation/deallocation issues).

gdb/ChangeLog:

* probe.h (probe_ops_cp): Remove typedef.
(DEF_VEC_P (probe_ops_cp)): Remove.
(all_probe_ops): Change type to std::vector.
* probe.c (info_probes_for_ops): Adjust to vector change.
(probe_linespec_to_ops): Likewise.
(all_probe_ops): Change type to std::vector.
(_initialize_probe): Adjust to vector change.
* dtrace-probe.c (_initialize_dtrace_probe): Likewise.
* elfread.c (elf_get_probes): Likewise.
* stap-probe.c (_initialize_stap_probe): Likewise.

6 years agoMake collect_probes return an std::vector
Simon Marchi [Tue, 12 Sep 2017 11:55:32 +0000 (13:55 +0200)] 
Make collect_probes return an std::vector

Change collect_probes so it returns an std::vector<bound_probe> instead
of a VEC(bound_probe_s).  This allows removing some cleanups.  It also
seems like enable_probes_command and disable_probes_command were not
freeing that vector.

The comparison function compare_probes needs to be updated to return a
bool indicating whether the first parameter is "less than" the second
parameter.

I defined two constructors to bound_probe.  The default constructor is
needed, for example, so the instance in struct bp_location can be
constructed without parameters.  The constructor with parameters is
useful so we can use emplace_back and pass the values directly.

The s390 builder on the buildbot shows a weird failure that I can't
explain:

../../binutils-gdb/gdb/elfread.c: In function void probe_key_free(bfd*, void*):
../../binutils-gdb/gdb/elfread.c:1346:8: error: types may not be defined in a for-range-declaration [-Werror]
   for (struct probe *probe : *probes)
        ^~~~~~

I guess it's a bug with that specific version< of the compiler, since no
other gcc gives me that error.  It is using:

  g++ (GCC) 6.3.1 20161221 (Red Hat 6.3.1-1)

Any idea about this problem?

gdb/ChangeLog:

* probe.h (struct bound_probe): Define constructors.
* probe.c (bound_probe_s): Remove typedef.
(DEF_VEC_O (bound_probe_s)): Remove VEC.
(collect_probes): Change return type to std::vector, remove
cleanup.
(compare_probes): Return bool, change parameter type.  Change
semantic to "less than".
(gen_ui_out_table_header_info): Change parameter to std::vector
and update.
(exists_probe_with_pops): Likewise.
(info_probes_for_ops): Update to std::vector change.
(enable_probes_command): Likewise.
(disable_probes_command): Likewise.

6 years agoMake probe_ops::get_probes fill an std::vector
Simon Marchi [Tue, 12 Sep 2017 11:37:00 +0000 (13:37 +0200)] 
Make probe_ops::get_probes fill an std::vector

This patch changes one usage of VEC to std::vector.  It is a relatively
straightforward 1:1 change.  The implementations of
sym_probe_fns::sym_get_probes return a borrowed reference to their probe
vectors, meaning that the caller should not free it.  In the new code, I
made them return a const reference to the vector.

This patch and the following one were tested by the buildbot.  I didn't
see any failures that looked related to this one.

gdb/ChangeLog:

* probe.h (struct probe_ops) <get_probes>: Change parameter from
vec to std::vector.
* probe.c (parse_probes_in_pspace): Update.
(find_probes_in_objfile): Update.
(find_probe_by_pc): Update.
(collect_probes): Update.
(probe_any_get_probes): Update.
* symfile.h (struct sym_probe_fns) <sym_get_probes> Change
return type to reference to std::vector.
* dtrace-probe.c (dtrace_process_dof_probe): Change parameter to
std::vector and update.
(dtrace_process_dof): Likewise.
(dtrace_get_probes): Likewise.
* elfread.c (elf_get_probes): Change return type to std::vector,
store an std::vector in bfd_data.
(probe_key_free): Update to std::vector.
* stap-probe.c (handle_stap_probe): Change parameter to
std::vector and update.
(stap_get_probes): Likewise.
* symfile-debug.c (debug_sym_get_probes): Change return type to
std::vector and update.

6 years agoAutomatic date update in version.in
GDB Administrator [Tue, 12 Sep 2017 00:00:28 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 years agoRemove make_show_memory_breakpoints_cleanup
Tom Tromey [Sat, 9 Sep 2017 16:47:10 +0000 (10:47 -0600)] 
Remove make_show_memory_breakpoints_cleanup

This removes make_show_memory_breakpoints_cleanup, replacing it with
make_scoped_restore_show_memory_breakpoints and updating all callers.

ChangeLog
2017-09-11  Tom Tromey  <tom@tromey.com>

* breakpoint.c (program_breakpoint_here_p): Update.
* target.c (make_scoped_restore_show_memory_breakpoints): Rename
from make_show_memory_breakpoints_cleanup.  Return a
scoped_restore_tmpl<int>.
(restore_show_memory_breakpoints): Remove.
* ppc-linux-tdep.c (ppc_linux_memory_remove_breakpoint): Update.
* mem-break.c (memory_validate_breakpoint): Update.
* ia64-tdep.c (ia64_memory_insert_breakpoint): Update.
(ia64_memory_remove_breakpoint): Update.
(ia64_breakpoint_from_pc): Update.
* target.h (make_scoped_restore_show_memory_breakpoints): Rename
from make_show_memory_breakpoints_cleanup.

6 years agoUse std::string in d-namespace.c
Tom Tromey [Sat, 9 Sep 2017 16:46:36 +0000 (10:46 -0600)] 
Use std::string in d-namespace.c

This removes some cleanups from d-namespace.c by replacing manual
string management with std::string.

ChangeLog
2017-09-11  Tom Tromey  <tom@tromey.com>

* d-namespace.c (d_lookup_symbol): Use std::string.
(find_symbol_in_baseclass): Likewise.

6 years agoUse std::string in ctf_start
Tom Tromey [Sat, 9 Sep 2017 16:17:11 +0000 (10:17 -0600)] 
Use std::string in ctf_start

This changes ctf_start to use std::string, allowing for some cleanup
removal.

ChangeLog
2017-09-11  Tom Tromey  <tom@tromey.com>

* ctf.c (ctf_start): Use std::string.

6 years agoRemove cleanups from find_frame_funname
Tom Tromey [Sat, 9 Sep 2017 16:14:52 +0000 (10:14 -0600)] 
Remove cleanups from find_frame_funname

This changes find_frame_funname to return a unique_xmalloc_ptr and
then fixes up the callers.  This removes several cleanups.

ChangeLog
2017-09-11  Tom Tromey  <tom@tromey.com>

* ada-lang.c (is_known_support_routine): Update.
(ada_unhandled_exception_name_addr_from_raise): Update.
* guile/scm-frame.c (gdbscm_frame_name): Update.
* python/py-frame.c (frapy_name): Update.
(frapy_function): Update.
* stack.h (find_frame_funname): Update.
* stack.c (find_frame_funname): Return unique_xmalloc_ptr.
(print_frame): Update.

6 years agoRemove cleanups from findcmd.c
Tom Tromey [Sat, 9 Sep 2017 15:56:27 +0000 (09:56 -0600)] 
Remove cleanups from findcmd.c

This removes cleanups from findcmd.c, replacing manual buffer
management with a gdb::byte_vector.

ChangeLog
2017-09-11  Tom Tromey  <tom@tromey.com>

* findcmd.c (put_bits): Take a gdb::byte_vector.
(parse_find_args): Return gdb::byte_vector.  "args" now const.
Remove "pattern_bufp" and "pattern_lenp" parameters.  Remove
cleanups.
(find_command): Update.

6 years agoReplace clear_hook_in_cleanup with scoped_restore_hook_in
Tom Tromey [Sun, 13 Aug 2017 20:44:08 +0000 (14:44 -0600)] 
Replace clear_hook_in_cleanup with scoped_restore_hook_in

This removes clear_hook_in_cleanup in favor of a scoped_restore-like
class.  scoped_restore itself can't be used because hook_in is a
bitfield.

ChangeLog
2017-09-11  Tom Tromey  <tom@tromey.com>

* cli/cli-script.c (class scoped_restore_hook_in): New.
(clear_hook_in_cleanup): Remove.
(execute_cmd_pre_hook, execute_cmd_post_hook): Use
scoped_restore_hook_in.

6 years agoReplace interp_set_temp with scoped_restore_interp
Tom Tromey [Sun, 13 Aug 2017 20:40:46 +0000 (14:40 -0600)] 
Replace interp_set_temp with scoped_restore_interp

This removes interp_set_temp and an associated cleanup, in favor of a
new RAII class, scoped_restore_interp.

ChangeLog
2017-09-11  Tom Tromey  <tom@tromey.com>

* cli/cli-script.c (restore_interp): Remove.
(read_command_lines): Use scoped_restore_interp.
* interps.c (scoped_restore_interp::set_temp): Rename from
interp_set_temp.
* interps.h (class scoped_restore_interp): New.
(interp_set_temp): Remove.

6 years agoChange setup_breakpoint_reporting to return a scoped_restore
Tom Tromey [Sun, 13 Aug 2017 16:55:28 +0000 (10:55 -0600)] 
Change setup_breakpoint_reporting to return a scoped_restore

This changes setup_breakpoint_reporting to return a scoped_restore,
allowing for some cleanup removal.

ChangeLog
2017-09-11  Tom Tromey  <tom@tromey.com>

* mi/mi-cmd-catch.c (mi_cmd_catch_assert)
(mi_cmd_catch_exception, mi_catch_load_unload): Update.
* mi/mi-cmd-break.c (setup_breakpoint_reporting): Return a
scoped_restore.
(mi_cmd_break_insert_1): Update.
* mi/mi-cmd-break.h (setup_breakpoint_reporting): Return a
scoped_restore.

6 years agoMake extract_arg return a std::string
Tom Tromey [Sun, 10 Sep 2017 20:48:30 +0000 (14:48 -0600)] 
Make extract_arg return a std::string

Change extract_arg to return a std::string and fix up all the users.
I think string is mildly better than unique_xmalloc_ptr<char>, when
possible, because it provides a more robust API.

I changed the error messages emitted from find_location_by_number to
avoid either writing to a string or an extra allocation; this can be
changed but I thought that the new message was not any less clear.
You can see an example in the testsuite patch.

ChangeLog
2017-09-11  Tom Tromey  <tom@tromey.com>

* demangle.c (demangle_command): Update.
* breakpoint.c (disable_command): Update.
(enable_command): Update.
(find_location_by_number): Make "number" const.  Use
get_number_trailer.
* cli/cli-utils.c (extract_arg): Return std::string.
* probe.c (parse_probe_linespec): Update.  Change types.
(collect_probes): Take string arguments.
(parse_probe_linespec): Likewise.
(info_probes_for_ops): Update.
(enable_probes_command): Update.
(disable_probes_command): Update.
* break-catch-sig.c (catch_signal_split_args): Update.
* mi/mi-parse.c (mi_parse): Update.

testsuite/ChangeLog
2017-09-11  Tom Tromey  <tom@tromey.com>

* gdb.base/ena-dis-br.exp (test_ena_dis_br): Update test.