binutils-gdb.git
7 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

7 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.

7 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.

7 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.

7 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.

7 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.

7 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;
 }

7 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.

7 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

7 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.

7 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.

7 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.

7 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.

7 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.

7 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.

7 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.

7 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.

7 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.

7 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.

7 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.

7 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.

7 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.

7 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

7 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.

7 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.

7 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.

7 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.

7 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.

7 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.

7 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.

7 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.

7 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.

7 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.

7 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

7 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.

7 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

7 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.

7 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.

7 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.

7 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

7 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.

7 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.

7 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.

7 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.

7 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.

7 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.

7 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.

7 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.

7 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.

7 years agoConstify language_enum
Tom Tromey [Sun, 10 Sep 2017 20:29:22 +0000 (14:29 -0600)]
Constify language_enum

Change language_enum to take a const argument.

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

* language.h (language_enum): Make argument const.
* language.c (language_enum): Make argument const.

7 years agoRename _const functions to use overloading instead
Tom Tromey [Sun, 10 Sep 2017 20:19:19 +0000 (14:19 -0600)]
Rename _const functions to use overloading instead

This renames a few functions -- skip_spaces_const,
skip_to_space_const, get_number_const, extract_arg_const -- to drop
the "_const" suffix and instead rely on overloading.

This makes future const fixes simpler by reducing the number of lines
that must be changed.  I think it is also not any less clear, as all
these functions have the same interface as their non-const versions by
design.  Furthermore there's an example of using an overload in-tree
already, namely check_for_argument.

This patch was largely created using some perl one-liners; then a few
fixes were applied by hand.

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

* common/common-utils.h (skip_to_space): Remove macro, redeclare
as function.
(skip_to_space): Rename from skip_to_space_const.
* common/common-utils.c (skip_to_space): New function.
(skip_to_space): Rename from skip_to_space_const.
* cli/cli-utils.h (get_number): Rename from get_number_const.
(extract_arg): Rename from extract_arg_const.
* cli/cli-utils.c (get_number): Rename from get_number_const.
(extract_arg): Rename from extract_arg_const.
(number_or_range_parser::get_number): Use ::get_number.
* aarch64-linux-tdep.c, ada-lang.c, arm-linux-tdep.c, ax-gdb.c,
break-catch-throw.c, breakpoint.c, cli/cli-cmds.c, cli/cli-dump.c,
cli/cli-script.c, cli/cli-setshow.c, compile/compile.c,
completer.c, demangle.c, disasm.c, findcmd.c, linespec.c,
linux-tdep.c, linux-thread-db.c, location.c, mi/mi-parse.c,
minsyms.c, nat/linux-procfs.c, printcmd.c, probe.c,
python/py-breakpoint.c, record.c, rust-exp.y, serial.c, stack.c,
stap-probe.c, tid-parse.c, tracepoint.c: Update all callers.

7 years agoMake it simpler to add events to Python
Tom Tromey [Fri, 8 Sep 2017 21:38:12 +0000 (15:38 -0600)]
Make it simpler to add events to Python

The first patch in this series went through several iterations as I'd
forgotten how many places had to be touched to add a new event and a
new event type.

This patch simplifies the process using two new ".def" files.  Now, a
new event type can be added by adding a line to "py-event-types.def",
and a new event registry can be added by adding a line to
"py-all-events.def".

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

* python/python.c (do_start_initialization): Use
py-event-types.def to initialize types.
Define all object type structures.
* python/python-internal.h: Don't declare event initialization
functions.
* python/py-threadevent.c (thread_event_object_type): Don't
define.
* python/py-stopevent.c (stop_event_object_type): Don't define.
* python/py-signalevent.c (signal_event_object_type): Don't
declare or define.
* python/py-newobjfileevent.c (new_objfile_event_object_type)
(clear_objfiles_event_object_type): Don't declare or define.
* python/py-infevents.c (inferior_call_pre_event_object_type)
(inferior_call_post_event_object_type)
(register_changed_event_object_type)
(memory_changed_event_object_type): Don't declare or define.
* python/py-inferior.c (new_thread_event_object_type)
(new_inferior_event_object_type)
(inferior_deleted_event_object_type): Don't declare or define.
* python/py-exitedevent.c (exited_event_object_type): Don't
declare or define.
* python/py-evts.c (gdbpy_initialize_py_events): Use
py-all-events.def.
* python/py-events.h (thread_event_object_type): Don't declare.
(events_object): Use py-all-events.def.
* python/py-event.h (GDBPY_NEW_EVENT_TYPE): Remove.  Use
py-event-types.def.
* python/py-event-types.def: New file.
* python/py-continueevent.c (create_continue_event_object): Don't
declare or define.
* python/py-bpevent.c (breakpoint_event_object_type): Don't
declare or define.
* python/py-all-events.def: New file.

7 years agoSmall event ownership clean up in Python layer
Tom Tromey [Fri, 8 Sep 2017 20:26:43 +0000 (14:26 -0600)]
Small event ownership clean up in Python layer

It seems cleaner to me for functions like create_thread_event_object,
which pass object ownership to their callers, to directly return a
gdb_ref<>.  This way the ownership transfer is part of the API.  This
patch makes this change.

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

* python/py-threadevent.c (create_thread_event_object): Return
gdbpy_ref.
* python/py-stopevent.h (create_stop_event_object)
(create_breakpoint_event_object, create_signal_event_object):
Update.
* python/py-stopevent.c (create_stop_event_object): Return
gdbpy_ref.
(emit_stop_event): Update.
* python/py-signalevent.c (create_signal_event_object): Return
gdbpy_ref.
* python/py-infevents.c (create_inferior_call_event_object):
Update.
* python/py-event.h (create_event_object)
(create_thread_event_object): Update.
* python/py-event.c (create_event_object): Return gdbpy_ref.
* python/py-continueevent.c: Return gdbpy_ref.
* python/py-bpevent.c (create_breakpoint_event_object): Return
gdbpy_ref.

7 years agoAdd new_inferior, inferior_deleted, and new_thread events
Tom Tromey [Tue, 5 Sep 2017 18:07:00 +0000 (12:07 -0600)]
Add new_inferior, inferior_deleted, and new_thread events

This adds a few new events to gdb's Python layer: new_inferior,
inferior_deleted, and new_thread.  I wanted to be able to add a
combined inferior/thread display window to my GUI, and I needed a few
events to make this work.  This is PR python/15622.

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

PR python/15622:
* NEWS: Add entry.
* python/python.c (do_start_initialization): Initialize new event
types.
* python/python-internal.h (gdbpy_initialize_new_inferior_event)
(gdbpy_initialize_inferior_deleted_event)
(gdbpy_initialize_new_thread_event): Declare.
* python/py-threadevent.c (create_thread_event_object): Add option
"thread" parameter.
* python/py-inferior.c (new_thread_event_object_type)
(new_inferior_event_object_type)
(inferior_deleted_event_object_type): Declare.
(python_new_inferior, python_inferior_deleted): New functions.
(add_thread_object): Emit new_thread event.
(gdbpy_initialize_inferior): Attach new functions to corresponding
observers.
(new_thread, new_inferior, inferior_deleted): Define new event
types.
* python/py-evts.c (gdbpy_initialize_py_events): Add new
registries.
* python/py-events.h (events_object) <new_inferior,
inferior_deleted, new_thread>: New fields.
* python/py-event.h (create_thread_event_breakpoint): Add optional
"thread" parameter.

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

* python.texi (Events In Python): Document new events.

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

* gdb.python/py-infthread.exp: Add tests for new_thread event.
* gdb.python/py-inferior.exp: Add tests for new inferior events.

7 years agonds32: Rename __BIT() to N32_BIT().
Kuan-Lin Chen [Mon, 11 Sep 2017 05:46:27 +0000 (13:46 +0800)]
nds32: Rename __BIT() to N32_BIT().

7 years agoAutomatic date update in version.in
GDB Administrator [Mon, 11 Sep 2017 00:00:31 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoFix build breakage on GNU/Linux AArch64, take 2
Sergio Durigan Junior [Sun, 10 Sep 2017 21:50:29 +0000 (17:50 -0400)]
Fix build breakage on GNU/Linux AArch64, take 2

The last commit unfortunately was not enough to fix the build breakage
on AArch64.  I made a mistake and did not test it alone on BuildBot,
but along with another patch that was responsible for fixing the
breakage.

The failure is:

  In file included from /usr/include/string.h:640:0,
   from build-gnulib-gdbserver/import/string.h:41,
   from ../../../binutils-gdb/gdb/gdbserver/../common/common-defs.h:56,
   from ../../../binutils-gdb/gdb/gdbserver/server.h:22,
   from ../../../binutils-gdb/gdb/gdbserver/regcache.c:19:
  In function â€˜void* memset(void*, int, size_t)’,
      inlined from â€˜regcache* init_register_cache(regcache*, const target_desc*, unsigned char*)’ at ../../../binutils-gdb/gdb/gdbserver/regcache.c:150:50:
  /usr/include/aarch64-linux-gnu/bits/string3.h:81:32: error: call to â€˜__warn_memset_zero_len’ declared with attribute warning: memset used with constant zero length parameter; this could be due to transposed parameters [-Werror]
 __warn_memset_zero_len ();
  ^
  In function â€˜void* memset(void*, int, size_t)’,
      inlined from â€˜regcache* get_thread_regcache(thread_info*, int)’ at ../../../binutils-gdb/gdb/gdbserver/regcache.c:57:60:
  /usr/include/aarch64-linux-gnu/bits/string3.h:81:32: error: call to â€˜__warn_memset_zero_len’ declared with attribute warning: memset used with constant zero length parameter; this could be due to transposed parameters [-Werror]
 __warn_memset_zero_len ();

This is likely due to a GCC bug, because for some reason the compiler
assumes that the third argument to the memset:

  memset (regcache->register_status, REG_UNAVAILABLE,
  VEC_length (tdesc_reg_p, regcache->tdesc->reg_defs));

is always zero, which is not always true.

Anyway, the simple fix for this is to guard the memset calls with:

  if (!VEC_empty (tdesc_reg_p, regcache->tdesc->reg_defs))

This time, I made sure to regtest only this patch on BuildBot, and it
finally solved the breakage.

gdb/gdbserver/ChangeLog:
2017-09-10  Sergio Durigan Junior  <sergiodj@redhat.com>

* regcache.c (get_thread_regcache): Guard calls to "memset"
          with "!VEC_empty".

7 years agoFix build breakage on GNU/Linux AArch64
Sergio Durigan Junior [Sun, 10 Sep 2017 16:16:54 +0000 (12:16 -0400)]
Fix build breakage on GNU/Linux AArch64

This patch fixes the build breakage that has been happening on AArch64
since September 5th.  The breakage was introduced by the following
commit:

  author        Yao Qi <yao.qi@linaro.org>
          Tue, 5 Sep 2017 04:54:52 -0400 (09:54 +0100)
  committer     Yao Qi <yao.qi@linaro.org>
          Tue, 5 Sep 2017 04:54:52 -0400 (09:54 +0100)
  commit        f7000548a2b79d7e5cb924468117ca4245e6b820

  Use VEC for target_desc.reg_defs

The build log for this commit can be seen here:

  <https://gdb-build.sergiodj.net/builders/Ubuntu-AArch64-native-gdbserver-m64/builds/2696/steps/compile%20gdb/logs/stdio>

And the underlying problem is that the code is not calling the new
function "allocate_target_description" to allocate the "struct
target_desc" using "new" instead of XNEW, which end up not properly
initializing the fields of the structure.

Regtested on BuildBot.

gdb/gdbserver/ChangeLog:
2017-09-10  Sergio Durigan Junior  <sergiodj@redhat.com>

* linux-low.c (handle_extended_wait): Use
"allocate_target_description" instead of "XNEW".
* linux-x86-low.c (initialize_low_arch): Likewise.

7 years agogdb: Remove check for gdb_stderr == NULL
Andrew Burgess [Sun, 6 Aug 2017 20:45:08 +0000 (21:45 +0100)]
gdb: Remove check for gdb_stderr == NULL

Recent changes made gdb_stderr a macro:

  #define gdb_stderr (*current_ui_gdb_stderr_ptr ())

and current_ui_gdb_stderr_ptr return this:

   &current_ui->m_gdb_stderr

The problem is that this is undefined if current_ui is NULL, which can
happen early on during gdb start up.

If we run into an error during early gdb start up then we write the
error message to gdb_stderr.  However, if we are too early during the
start up then current_ui is NULL, and using the gdb_stderr macro
triggers undefined behaviour.

We try to avoid this using a check 'gdb_stderr == NULL' which was fine
before the recent changes, but now, still triggers undefined behaviour.

A better check is instead 'current_ui == NULL' which is what I use in
this patch.

Triggering this failure is pretty hard, most of the really early errors
are only triggered if pretty basic things are not as expected, for
example, if the default signal handlers are not as expected.  Seeing one
of these errors trigger usually means that someone working on gdb has
made an incorrect change.  Still, the errors are present in gdb, and
should we ever trigger one it would be nice if gdb didn't crash.

For testing this change I've been applying this patch which adds an
unconditional error into a function called early during gdb start up.
Later in the same function is a real error call which, in some
circumstances could be triggered:

  ## START ##
  diff --git a/gdb/common/signals-state-save-restore.c b/gdb/common/signals-state-save-restore.c
  index d11a9ae006c..d75ba70f894 100644
  --- a/gdb/common/signals-state-save-restore.c
  +++ b/gdb/common/signals-state-save-restore.c
  @@ -37,6 +37,9 @@ static sigset_t original_signal_mask;
   void
   save_original_signals_state (void)
   {
  +
  +  internal_error (__FILE__, __LINE__, "example error");
  +
   #ifdef HAVE_SIGACTION
     int i;
     int res;
  ## END ##

gdb/ChangeLog:

* utils.c (abort_with_message): Don't compare gdb_stderr to NULL,
check current_ui instead.
(internal_vproblem): Likewise.

7 years agoAutomatic date update in version.in
GDB Administrator [Sun, 10 Sep 2017 00:00:33 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoRemove unnecessary calls to is_mi_like_p in print_thread_info_1
Simon Marchi [Sat, 9 Sep 2017 20:51:58 +0000 (22:51 +0200)]
Remove unnecessary calls to is_mi_like_p in print_thread_info_1

There are two calls to uiout->is_mi_like_p in the else branch of a
if (uiout->is_mi_like_p ()), we already know they will return false.

A bit lower, there are two if (!uiout->is_mi_like_p ()) that we can
merge.

gdb/ChangeLog:

* thread.c (print_thread_info_1): Remove unnecessary calls to
uiout->is_mi_like_p.

7 years agoUse std::vector in add_using_directive
Tom Tromey [Wed, 6 Sep 2017 23:18:23 +0000 (17:18 -0600)]
Use std::vector in add_using_directive

This changes add_using_directive to accept a std::vector and then
changes the callers.  This allows removing a cleanup.

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

* namespace.h (add_using_directive): Update.
* namespace.c (add_using_directive): Change type of excludes to
std::vector.
* dwarf2read.c (read_import_statement): Use std::vector.
(read_namespace): Update.
* cp-namespace.c (cp_scan_for_anonymous_namespaces): Update.

7 years agoUse gdb::def_vector in create_sals_line_offset
Tom Tromey [Wed, 6 Sep 2017 22:16:38 +0000 (16:16 -0600)]
Use gdb::def_vector in create_sals_line_offset

This changes create_sals_line_offset to use gdb::def_vector, removing
some cleanups.

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

* linespec.c (create_sals_line_offset): Use gdb::def_vector.

7 years agoUse gdb::byte_vector in pascal_object_print_value
Tom Tromey [Mon, 14 Aug 2017 06:15:33 +0000 (00:15 -0600)]
Use gdb::byte_vector in pascal_object_print_value

This changes pascal_object_print_value to use a gdb::byte_vector.
This removes a cleanup.  This change also points out how the previous
code had a possible use-after-free bug.

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

* p-valprint.c (pascal_object_print_value): Use gdb::byte_vector.

7 years agoUse gdb::def_vector in func_command
Tom Tromey [Wed, 6 Sep 2017 22:03:28 +0000 (16:03 -0600)]
Use gdb::def_vector in func_command

This changes func_command to use gdb::def_vector, removing a cleanup.

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

* stack.c (func_command): Use gdb::def_vector.

7 years agoUse ui_out_emit_list and ui_out_emit_tuple with gdb::optional
Tom Tromey [Thu, 7 Sep 2017 03:41:40 +0000 (21:41 -0600)]
Use ui_out_emit_list and ui_out_emit_tuple with gdb::optional

This changes a few spots to use ui_out_emit_list and/or
ui_out_emit_tuple with gdb::optional, to preserve existing behavior.
This allows for the removal of a few more cleanups.

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

* mi/mi-cmd-var.c (mi_cmd_var_list_children): Use gdb::optional,
ui_out_emit_list, ui_out_emit_tuple.
(mi_cmd_var_update): Likewise.

7 years agoRemove make_cleanup_ui_out_redirect_pop
Tom Tromey [Sun, 13 Aug 2017 16:47:32 +0000 (10:47 -0600)]
Remove make_cleanup_ui_out_redirect_pop

This patch introduces ui_out_redirect_pop.  All uses of
make_cleanup_ui_out_redirect_pop are replaced with this new class.

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

* mi/mi-interp.c (mi_user_selected_context_changed): Use
ui_out_redirect_pop.
* guile/scm-ports.c (ioscm_with_output_to_port_worker): Use
ui_out_redirect_pop.
* utils.c (do_ui_out_redirect_pop)
(make_cleanup_ui_out_redirect_pop): Remove.
* top.c (execute_command_to_string): Use ui_out_redirect_pop.
* utils.h (make_cleanup_ui_out_redirect_pop): Remove.
* ui-out.h (ui_out_redirect_pop): New class.

7 years agoUse ui_out_emit_list in more places
Tom Tromey [Fri, 11 Aug 2017 21:17:59 +0000 (15:17 -0600)]
Use ui_out_emit_list in more places

This changes various spots to use ui_out_emit_list, removing some
cleanups.

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

* mi/mi-main.c (output_cores): Use ui_out_emit_list.
(list_available_thread_groups, mi_cmd_list_thread_groups)
(mi_cmd_data_list_changed_registers, mi_cmd_data_read_memory)
(mi_cmd_data_read_memory_bytes, mi_cmd_trace_frame_collected):
Likewise.

7 years agoUse ui_out_emit_tuple in disasm.c
Tom Tromey [Fri, 11 Aug 2017 21:17:26 +0000 (15:17 -0600)]
Use ui_out_emit_tuple in disasm.c

This changes one spot in disasm.c to use ui_out_emit_tuple.  This
patch required a large reindentation, so I've separated it out.

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

* disasm.c (gdb_pretty_print_disassembler::pretty_print_insn): Use
ui_out_emit_tuple.

7 years agoUse ui_out_emit_tuple in more places
Tom Tromey [Fri, 11 Aug 2017 21:02:04 +0000 (15:02 -0600)]
Use ui_out_emit_tuple in more places

This changes more places to use ui_out_emit_tuple, removing cleanups.

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

* target.c (flash_erase_command): Use ui_out_emit_tuple.
* stack.c (print_frame): Use ui_out_emit_tuple.
* spu-tdep.c (info_spu_event_command): Use ui_out_emit_tuple.
(info_spu_mailbox_command, info_spu_dma_command)
(info_spu_proxydma_command): Likewise.
* mi/mi-main.c (mi_cmd_trace_frame_collected): Use
ui_out_emit_tuple, gdb::byte_vector, bin2hex.
* mi/mi-cmd-file.c (mi_cmd_file_list_shared_libraries): Use
ui_out_emit_tuple.
* breakpoint.c (print_it_watchpoint): Use ui_out_emit_tuple.

7 years agoRemove make_cleanup_ui_out_table_begin_end
Tom Tromey [Sat, 9 Sep 2017 15:16:49 +0000 (09:16 -0600)]
Remove make_cleanup_ui_out_table_begin_end

This changes the few remaining uses of
make_cleanup_ui_out_table_begin_end to use ui_out_emit_table instead,
and then removes the cleanup.

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

* ui-out.h (make_cleanup_ui_out_table_begin_end): Remove.
(class ui_out_emit_table): Update comment.
* ui-out.c (do_cleanup_table_end)
(make_cleanup_ui_out_table_begin_end): Remove.
* spu-tdep.c (info_spu_mailbox_list): Use ui_out_emit_table.
(info_spu_dma_cmdlist): Likewise.
* probe.c (info_probes_for_ops): Use ui_out_emit_table.
* darwin-nat-info.c (darwin_debug_regions_recurse): Use
ui_out_emit_table.

7 years agoUse ui_out_emit_table and ui_out_emit_list in print_thread_info_1
Tom Tromey [Sat, 9 Sep 2017 15:15:23 +0000 (09:15 -0600)]
Use ui_out_emit_table and ui_out_emit_list in print_thread_info_1

This changes print_thread_info_1 to use ui_out_emit_table and
ui_out_emit_list.  Which one is used depends on whether the ui-out is
mi-like; so the emitters are wrapped in gdb::optional.

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

* thread.c (print_thread_info_1): Use ui_out_emit_table,
ui_out_emit_list, gdb::optional.

7 years agoRemove unnecessary function prototypes.
John Baldwin [Sat, 9 Sep 2017 18:02:37 +0000 (11:02 -0700)]
Remove unnecessary function prototypes.

These prototypes were required when compiling GDB as C but are not
required for C++.

gdb/ChangeLog:

* aarch64-linux-nat.c: Remove _initialize_aarch64_linux_nat
prototype.
* aarch64-linux-tdep.c: Remove _initialize_aarch64_linux_tdep
prototype.
* aarch64-newlib-tdep.c: Remove _initialize_aarch64_newlib_tdep
prototype.
* aarch64-tdep.c: Remove _initialize_aarch64_tdep prototype.
* ada-exp.y: Remove _initialize_ada_exp prototype.
* ada-lang.c: Remove _initialize_ada_language prototype.
* ada-tasks.c: Remove _initialize_tasks prototype.
* addrmap.c: Remove _initialize_addrmap prototype.
* agent.c: Remove _initialize_agent prototype.
* aix-thread.c: Remove _initialize_aix_thread prototype.
* alpha-bsd-nat.c: Remove _initialize_alphabsd_nat prototype.
* alpha-linux-nat.c: Remove _initialize_alpha_linux_nat prototype.
* alpha-linux-tdep.c: Remove _initialize_alpha_linux_tdep
prototype.
* alpha-nbsd-tdep.c: Remove _initialize_alphanbsd_tdep prototype.
* alpha-obsd-tdep.c: Remove _initialize_alphaobsd_tdep prototype.
* alpha-tdep.c: Remove _initialize_alpha_tdep prototype.
* amd64-darwin-tdep.c: Remove _initialize_amd64_darwin_tdep
prototype.
* amd64-dicos-tdep.c: Remove _initialize_amd64_dicos_tdep
prototype.
* amd64-fbsd-nat.c: Remove _initialize_amd64fbsd_nat prototype.
* amd64-fbsd-tdep.c: Remove _initialize_amd64fbsd_tdep prototype.
* amd64-linux-nat.c: Remove _initialize_amd64_linux_nat prototype.
* amd64-linux-tdep.c: Remove _initialize_amd64_linux_tdep
prototype.
* amd64-nbsd-nat.c: Remove _initialize_amd64nbsd_nat prototype.
* amd64-nbsd-tdep.c: Remove _initialize_amd64nbsd_tdep prototype.
* amd64-obsd-nat.c: Remove _initialize_amd64obsd_nat prototype.
* amd64-obsd-tdep.c: Remove _initialize_amd64obsd_tdep prototype.
* amd64-sol2-tdep.c: Remove _initialize_amd64_sol2_tdep prototype.
* amd64-tdep.c: Remove _initialize_amd64_tdep prototype.
* amd64-windows-nat.c: Remove _initialize_amd64_windows_nat
prototype.
* amd64-windows-tdep.c: Remove _initialize_amd64_windows_tdep
prototype.
* annotate.c: Remove _initialize_annotate prototype.
* arc-newlib-tdep.c: Remove _initialize_arc_newlib_tdep prototype.
* arc-tdep.c: Remove _initialize_arc_tdep prototype.
* arch-utils.c: Remove _initialize_gdbarch_utils prototype.
* arm-linux-nat.c: Remove _initialize_arm_linux_nat prototype.
* arm-linux-tdep.c: Remove _initialize_arm_linux_tdep prototype.
* arm-nbsd-tdep.c: Remove _initialize_arm_netbsd_tdep prototype.
* arm-obsd-tdep.c: Remove _initialize_armobsd_tdep prototype.
* arm-symbian-tdep.c: Remove _initialize_arm_symbian_tdep
prototype.
* arm-tdep.c: Remove _initialize_arm_tdep prototype.
* arm-wince-tdep.c: Remove _initialize_arm_wince_tdep prototype.
* auto-load.c: Remove _initialize_auto_load prototype.
* auxv.c: Remove _initialize_auxv prototype.
* avr-tdep.c: Remove _initialize_avr_tdep prototype.
* ax-gdb.c: Remove _initialize_ax_gdb prototype.
* bfin-linux-tdep.c: Remove _initialize_bfin_linux_tdep prototype.
* bfin-tdep.c: Remove _initialize_bfin_tdep prototype.
* break-catch-sig.c: Remove _initialize_break_catch_sig prototype.
* break-catch-syscall.c: Remove _initialize_break_catch_syscall
prototype.
* break-catch-throw.c: Remove _initialize_break_catch_throw
prototype.
* breakpoint.c: Remove _initialize_breakpoint prototype.
* bsd-uthread.c: Remove _initialize_bsd_uthread prototype.
* btrace.c: Remove _initialize_btrace prototype.
* charset.c: Remove _initialize_charset prototype.
* cli/cli-cmds.c: Remove _initialize_cli_cmds prototype.
* cli/cli-dump.c: Remove _initialize_cli_dump prototype.
* cli/cli-interp.c: Remove _initialize_cli_interp prototype.
* cli/cli-logging.c: Remove _initialize_cli_logging prototype.
* cli/cli-script.c: Remove _initialize_cli_script prototype.
* coff-pe-read.c: Remove _initialize_coff_pe_read prototype.
* coffread.c: Remove _initialize_coffread prototype.
* compile/compile.c: Remove _initialize_compile prototype.
* complaints.c: Remove _initialize_complaints prototype.
* completer.c: Remove _initialize_completer prototype.
* copying.awk: Remove _initialize_copying prototype.
* copying.c: Regenerate.
* core-regset.c: Remove _initialize_core_regset prototype.
* corefile.c: Remove _initialize_core prototype.
* corelow.c: Remove _initialize_corelow prototype.
* cp-abi.c: Remove _initialize_cp_abi prototype.
* cp-namespace.c: Remove _initialize_cp_namespace prototype.
* cp-support.c: Remove _initialize_cp_support prototype.
* cp-valprint.c: Remove _initialize_cp_valprint prototype.
* cris-linux-tdep.c: Remove _initialize_cris_linux_tdep prototype.
* cris-tdep.c: Remove _initialize_cris_tdep prototype.
* ctf.c: Remove _initialize_ctf prototype.
* d-lang.c: Remove _initialize_d_language prototype.
* darwin-nat-info.c: Remove _initialize_darwin_info_commands
prototype.
* darwin-nat.c: Remove _initialize_darwin_inferior prototype.
* dbxread.c: Remove _initialize_dbxread prototype.
* dcache.c: Remove _initialize_dcache prototype.
* demangle.c: Remove _initialize_demangler prototype.
* disasm-selftests.c: Remove _initialize_disasm_selftests
prototype.
* disasm.c: Remove _initialize_disasm prototype.
* dtrace-probe.c: Remove _initialize_dtrace_probe prototype.
* dummy-frame.c: Remove _initialize_dummy_frame prototype.
* dwarf2-frame-tailcall.c: Remove _initialize_tailcall_frame
prototype.
* dwarf2-frame.c: Remove _initialize_dwarf2_frame prototype.
* dwarf2expr.c: Remove _initialize_dwarf2expr prototype.
* dwarf2loc.c: Remove _initialize_dwarf2loc prototype.
* dwarf2read.c: Remove _initialize_dwarf2_read prototype.
* elfread.c: Remove _initialize_elfread prototype.
* exec.c: Remove _initialize_exec prototype.
* extension.c: Remove _initialize_extension prototype.
* f-lang.c: Remove _initialize_f_language prototype.
* f-valprint.c: Remove _initialize_f_valprint prototype.
* fbsd-nat.c: Remove _initialize_fbsd_nat prototype.
* fbsd-tdep.c: Remove _initialize_fbsd_tdep prototype.
* filesystem.c: Remove _initialize_filesystem prototype.
* findcmd.c: Remove _initialize_mem_search prototype.
* fork-child.c: Remove _initialize_fork_child prototype.
* frame-base.c: Remove _initialize_frame_base prototype.
* frame-unwind.c: Remove _initialize_frame_unwind prototype.
* frame.c: Remove _initialize_frame prototype.
* frv-linux-tdep.c: Remove _initialize_frv_linux_tdep prototype.
* frv-tdep.c: Remove _initialize_frv_tdep prototype.
* ft32-tdep.c: Remove _initialize_ft32_tdep prototype.
* gcore.c: Remove _initialize_gcore prototype.
* gdb_bfd.c: Remove _initialize_gdb_bfd prototype.
* gdbarch.c: Regenerate.
* gdbarch.sh: Remove _initialize_gdbarch prototype.
* gdbtypes.c: Remove _initialize_gdbtypes prototype.
* gnu-nat.c: Remove _initialize_gnu_nat prototype.
* gnu-v2-abi.c: Remove _initialize_gnu_v2_abi prototype.
* gnu-v3-abi.c: Remove _initialize_gnu_v3_abi prototype.
* go-lang.c: Remove _initialize_go_language prototype.
* go32-nat.c: Remove _initialize_go32_nat prototype.
* guile/guile.c: Remove _initialize_guile prototype.
* h8300-tdep.c: Remove _initialize_h8300_tdep prototype.
* hppa-linux-nat.c: Remove _initialize_hppa_linux_nat prototype.
* hppa-linux-tdep.c: Remove _initialize_hppa_linux_tdep prototype.
* hppa-nbsd-nat.c: Remove _initialize_hppanbsd_nat prototype.
* hppa-nbsd-tdep.c: Remove _initialize_hppanbsd_tdep prototype.
* hppa-obsd-nat.c: Remove _initialize_hppaobsd_nat prototype.
* hppa-obsd-tdep.c: Remove _initialize_hppaobsd_tdep prototype.
* hppa-tdep.c: Remove _initialize_hppa_tdep prototype.
* i386-bsd-nat.c: Remove _initialize_i386bsd_nat prototype.
* i386-cygwin-tdep.c: Remove _initialize_i386_cygwin_tdep
prototype.
* i386-darwin-tdep.c: Remove _initialize_i386_darwin_tdep
prototype.
* i386-dicos-tdep.c: Remove _initialize_i386_dicos_tdep prototype.
* i386-fbsd-nat.c: Remove _initialize_i386fbsd_nat prototype.
* i386-fbsd-tdep.c: Remove _initialize_i386fbsd_tdep prototype.
* i386-gnu-nat.c: Remove _initialize_i386gnu_nat prototype.
* i386-gnu-tdep.c: Remove _initialize_i386gnu_tdep prototype.
* i386-linux-nat.c: Remove _initialize_i386_linux_nat prototype.
* i386-linux-tdep.c: Remove _initialize_i386_linux_tdep prototype.
* i386-nbsd-nat.c: Remove _initialize_i386nbsd_nat prototype.
* i386-nbsd-tdep.c: Remove _initialize_i386nbsd_tdep prototype.
* i386-nto-tdep.c: Remove _initialize_i386nto_tdep prototype.
* i386-obsd-nat.c: Remove _initialize_i386obsd_nat prototype.
* i386-obsd-tdep.c: Remove _initialize_i386obsd_tdep prototype.
* i386-sol2-nat.c: Remove _initialize_amd64_sol2_nat prototype.
* i386-sol2-tdep.c: Remove _initialize_amd64_sol2_tdep prototype.
* i386-tdep.c: Remove _initialize_i386_tdep prototype.
* i386-windows-nat.c: Remove _initialize_i386_windows_nat
prototype.
* ia64-libunwind-tdep.c: Remove _initialize_libunwind_frame
prototype.
* ia64-linux-nat.c: Remove _initialize_ia64_linux_nat prototype.
* ia64-linux-tdep.c: Remove _initialize_ia64_linux_tdep prototype.
* ia64-tdep.c: Remove _initialize_ia64_tdep prototype.
* ia64-vms-tdep.c: Remove _initialize_ia64_vms_tdep prototype.
* infcall.c: Remove _initialize_infcall prototype.
* infcmd.c: Remove _initialize_infcmd prototype.
* inferior.c: Remove _initialize_inferiors prototype.
* inflow.c: Remove _initialize_inflow prototype.
* infrun.c: Remove _initialize_infrun prototype.
* interps.c: Remove _initialize_interpreter prototype.
* iq2000-tdep.c: Remove _initialize_iq2000_tdep prototype.
* jit.c: Remove _initialize_jit prototype.
* language.c: Remove _initialize_language prototype.
* linux-fork.c: Remove _initialize_linux_fork prototype.
* linux-nat.c: Remove _initialize_linux_nat prototype.
* linux-tdep.c: Remove _initialize_linux_tdep prototype.
* linux-thread-db.c: Remove _initialize_thread_db prototype.
* lm32-tdep.c: Remove _initialize_lm32_tdep prototype.
* m2-lang.c: Remove _initialize_m2_language prototype.
* m32c-tdep.c: Remove _initialize_m32c_tdep prototype.
* m32r-linux-nat.c: Remove _initialize_m32r_linux_nat prototype.
* m32r-linux-tdep.c: Remove _initialize_m32r_linux_tdep prototype.
* m32r-tdep.c: Remove _initialize_m32r_tdep prototype.
* m68hc11-tdep.c: Remove _initialize_m68hc11_tdep prototype.
* m68k-bsd-nat.c: Remove _initialize_m68kbsd_nat prototype.
* m68k-bsd-tdep.c: Remove _initialize_m68kbsd_tdep prototype.
* m68k-linux-nat.c: Remove _initialize_m68k_linux_tdep prototype.
* m68k-linux-tdep.c: Remove _initialize_m68k_linux_tdep prototype.
* m68k-tdep.c: Remove _initialize_m68k_tdep prototype.
* m88k-bsd-nat.c: Remove _initialize_m68kbsd_nat prototype.
* m88k-tdep.c: Remove _initialize_m68kbsd_tdep prototype.
* machoread.c: Remove _initialize_machoread prototype.
* macrocmd.c: Remove _initialize_macrocmd prototype.
* macroscope.c: Remove _initialize_macroscope prototype.
* maint.c: Remove _initialize_maint_cmds prototype.
* mdebugread.c: Remove _initialize_mdebugread prototype.
* memattr.c: Remove _initialize_mem prototype.
* mep-tdep.c: Remove _initialize_mep_tdep prototype.
* mi/mi-cmd-env.c: Remove _initialize_mi_cmd_env prototype.
* mi/mi-cmds.c: Remove _initialize_mi_cmds prototype.
* mi/mi-interp.c: Remove _initialize_mi_interp prototype.
* mi/mi-main.c: Remove _initialize_mi_main prototype.
* microblaze-linux-tdep.c: Remove
_initialize_microblaze_linux_tdep prototype.
* microblaze-tdep.c: Remove _initialize_microblaze_tdep prototype.
* mips-fbsd-nat.c: Remove _initialize_mips_fbsd_nat prototype.
* mips-fbsd-tdep.c: Remove _initialize_mips_fbsd_tdep prototype.
* mips-linux-nat.c: Remove _initialize_mips_linux_nat prototype.
* mips-linux-tdep.c: Remove _initialize_mips_linux_tdep prototype.
* mips-nbsd-nat.c: Remove _initialize_mipsnbsd_nat prototype.
* mips-nbsd-tdep.c: Remove _initialize_mipsnbsd_tdep prototype.
* mips-sde-tdep.c: Remove _initialize_mips_sde_tdep prototype.
* mips-tdep.c: Remove _initialize_mips_tdep prototype.
* mips64-obsd-nat.c: Remove _initialize_mips64obsd_nat prototype.
* mips64-obsd-tdep.c: Remove _initialize_mips64obsd_tdep
prototype.
* mipsread.c: Remove _initialize_mipsread prototype.
* mn10300-linux-tdep.c: Remove _initialize_mn10300_linux_tdep
prototype.
* mn10300-tdep.c: Remove _initialize_mn10300_tdep prototype.
* moxie-tdep.c: Remove _initialize_moxie_tdep prototype.
* msp430-tdep.c: Remove _initialize_msp430_tdep prototype.
* mt-tdep.c: Remove _initialize_mt_tdep prototype.
* nds32-tdep.c: Remove _initialize_nds32_tdep prototype.
* nios2-linux-tdep.c: Remove _initialize_nios2_linux_tdep
prototype.
* nios2-tdep.c: Remove _initialize_nios2_tdep prototype.
* nto-procfs.c: Remove _initialize_procfs prototype.
* nto-tdep.c: Remove _initialize_nto_tdep prototype.
* objc-lang.c: Remove _initialize_objc_language prototype.
* objfiles.c: Remove _initialize_objfiles prototype.
* observer.c: Remove observer_test_first_notification_function,
observer_test_second_notification_function,
observer_test_third_notification_function, and
_initialize_observer prototypes.
* opencl-lang.c: Remove _initialize_opencl_language prototypes.
* osabi.c: Remove _initialize_gdb_osabi prototype.
* osdata.c: Remove _initialize_osdata prototype.
* p-valprint.c: Remove _initialize_pascal_valprint prototype.
* parse.c: Remove _initialize_parse prototype.
* ppc-fbsd-nat.c: Remove _initialize_ppcfbsd_nat prototype.
* ppc-fbsd-tdep.c: Remove _initialize_ppcfbsd_tdep prototype.
* ppc-linux-nat.c: Remove _initialize_ppc_linux_nat prototype.
* ppc-linux-tdep.c: Remove _initialize_ppc_linux_tdep prototype.
* ppc-nbsd-nat.c: Remove _initialize_ppcnbsd_nat prototype.
* ppc-nbsd-tdep.c: Remove _initialize_ppcnbsd_tdep prototype.
* ppc-obsd-nat.c: Remove _initialize_ppcobsd_nat prototype.
* ppc-obsd-tdep.c: Remove _initialize_ppcobsd_tdep prototype.
* printcmd.c: Remove _initialize_printcmd prototype.
* probe.c: Remove _initialize_probe prototype.
* proc-api.c: Remove _initialize_proc_api prototype.
* proc-events.c: Remove _initialize_proc_events prototype.
* proc-service.c: Remove _initialize_proc_service prototype.
* procfs.c: Remove _initialize_procfs prototype.
* psymtab.c: Remove _initialize_psymtab prototype.
* python/python.c: Remove _initialize_python prototype.
* ravenscar-thread.c: Remove _initialize_ravenscar prototype.
* record-btrace.c: Remove _initialize_record_btrace prototype.
* record-full.c: Remove _initialize_record_full prototype.
* record.c: Remove _initialize_record prototype.
* regcache.c: Remove _initialize_regcache prototype.
* reggroups.c: Remove _initialize_reggroup prototype.
* remote-notif.c: Remove _initialize_notif prototype.
* remote-sim.c: Remove _initialize_remote_sim prototype.
* remote.c: Remove _initialize_remote prototype.
* reverse.c: Remove _initialize_reverse prototype.
* rl78-tdep.c: Remove _initialize_rl78_tdep prototype.
* rs6000-aix-tdep.c: Remove _initialize_rs6000_aix_tdep prototype.
* rs6000-lynx178-tdep.c: Remove _initialize_rs6000_lynx178_tdep
prototype.
* rs6000-nat.c: Remove _initialize_rs6000_nat prototype.
* rs6000-tdep.c: Remove _initialize_rs6000_tdep prototype.
* rust-exp.y: Remove _initialize_rust_exp prototype.
* rx-tdep.c: Remove _initialize_rx_tdep prototype.
* s390-linux-nat.c: Remove _initialize_s390_nat prototype.
* s390-linux-tdep.c: Remove _initialize_s390_tdep prototype.
* score-tdep.c: Remove _initialize_score_tdep prototype.
* selftest-arch.c: Remove _initialize_selftests_foreach_arch
prototype.
* ser-go32.c: Remove _initialize_ser_dos prototype.
* ser-mingw.c: Remove _initialize_ser_windows prototype.
* ser-pipe.c: Remove _initialize_ser_pipe prototype.
* ser-tcp.c: Remove _initialize_ser_tcp prototype.
* ser-unix.c: Remove _initialize_ser_hardwire prototype.
* serial.c: Remove _initialize_serial prototype.
* sh-linux-tdep.c: Remove _initialize_sh_linux_tdep prototype.
* sh-nbsd-nat.c: Remove _initialize_shnbsd_nat prototype.
* sh-nbsd-tdep.c: Remove _initialize_shnbsd_tdep prototype.
* sh-tdep.c: Remove _initialize_sh_tdep prototype.
* skip.c: Remove _initialize_step_skip prototype.
* sol-thread.c: Remove _initialize_sol_thread prototype.
* solib-aix.c: Remove _initialize_solib_aix prototype.
* solib-darwin.c: Remove _initialize_darwin_solib prototype.
* solib-dsbt.c: Remove _initialize_dsbt_solib prototype.
* solib-frv.c: Remove _initialize_frv_solib prototype.
* solib-spu.c: Remove _initialize_spu_solib prototype.
* solib-svr4.c: Remove _initialize_svr4_solib prototype.
* solib-target.c: Remove _initialize_solib_target prototype.
* solib.c: Remove _initialize_solib prototype.
* source.c: Remove _initialize_source prototype.
* sparc-linux-nat.c: Remove _initialize_sparc_linux_nat prototype.
* sparc-linux-tdep.c: Remove _initialize_sparc_linux_tdep
prototype.
* sparc-nat.c: Remove _initialize_sparc_nat prototype.
* sparc-nbsd-nat.c: Remove _initialize_sparcnbsd_nat prototype.
* sparc-nbsd-tdep.c: Remove _initialize_sparcnbsd_tdep prototype.
* sparc-obsd-tdep.c: Remove _initialize_sparc32obsd_tdep
prototype.
* sparc-sol2-nat.c: Remove _initialize_sparc_sol2_nat prototype.
* sparc-sol2-tdep.c: Remove _initialize_sparc_sol2_tdep prototype.
* sparc-tdep.c: Remove _initialize_sparc_tdep prototype.
* sparc64-fbsd-nat.c: Remove _initialize_sparc64fbsd_nat
prototype.
* sparc64-fbsd-tdep.c: Remove _initialize_sparc64fbsd_tdep
prototype.
* sparc64-linux-nat.c: Remove _initialize_sparc64_linux_nat
prototype.
* sparc64-linux-tdep.c: Remove _initialize_sparc64_linux_tdep
prototype.
* sparc64-nat.c: Remove _initialize_sparc64_nat prototype.
* sparc64-nbsd-nat.c: Remove _initialize_sparc64nbsd_nat
prototype.
* sparc64-nbsd-tdep.c: Remove _initialize_sparc64nbsd_tdep
prototype.
* sparc64-obsd-nat.c: Remove _initialize_sparc64obsd_nat
prototype.
* sparc64-obsd-tdep.c: Remove _initialize_sparc64obsd_tdep
prototype.
* sparc64-sol2-tdep.c: Remove _initialize_sparc64_sol2_tdep
prototype.
* spu-linux-nat.c: Remove _initialize_spu_nat prototype.
* spu-multiarch.c: Remove _initialize_spu_multiarch prototype.
* spu-tdep.c: Remove _initialize_spu_tdep prototype.
* stabsread.c: Remove _initialize_stabsread prototype.
* stack.c: Remove _initialize_stack prototype.
* stap-probe.c: Remove _initialize_stap_probe prototype.
* std-regs.c: Remove _initialize_frame_reg prototype.
* symfile-debug.c: Remove _initialize_symfile_debug prototype.
* symfile-mem.c: Remove _initialize_symfile_mem prototype.
* symfile.c: Remove _initialize_symfile prototype.
* symmisc.c: Remove _initialize_symmisc prototype.
* symtab.c: Remove _initialize_symtab prototype.
* target-dcache.c: Remove _initialize_target_dcache prototype.
* target-descriptions.c: Remove _initialize_target_descriptions
prototype.
* thread.c: Remove _initialize_thread prototype.
* tic6x-linux-tdep.c: Remove _initialize_tic6x_linux_tdep
prototype.
* tic6x-tdep.c: Remove _initialize_tic6x_tdep prototype.
* tilegx-linux-nat.c: Remove _initialize_tile_linux_nat prototype.
* tilegx-linux-tdep.c: Remove _initialize_tilegx_linux_tdep
prototype.
* tilegx-tdep.c: Remove _initialize_tilegx_tdep prototype.
* tracefile-tfile.c: Remove _initialize_tracefile_tfile prototype.
* tracefile.c: Remove _initialize_tracefile prototype.
* tracepoint.c: Remove _initialize_tracepoint prototype.
* tui/tui-hooks.c: Remove _initialize_tui_hooks prototype.
* tui/tui-interp.c: Remove _initialize_tui_interp prototype.
* tui/tui-layout.c: Remove _initialize_tui_layout prototype.
* tui/tui-regs.c: Remove _initialize_tui_regs prototype.
* tui/tui-stack.c: Remove _initialize_tui_stack prototype.
* tui/tui-win.c: Remove _initialize_tui_win prototype.
* tui/tui.c: Remove _initialize_tui prototype.
* typeprint.c: Remove _initialize_typeprint prototype.
* user-regs.c: Remove _initialize_user_regs prototype.
* utils.c: Remove _initialize_utils prototype.
* v850-tdep.c: Remove _initialize_v850_tdep prototype.
* valarith.c: Remove _initialize_valarith prototype.
* valops.c: Remove _initialize_valops prototype.
* valprint.c: Remove _initialize_valprint prototype.
* value.c: Remove _initialize_values prototype.
* varobj.c: Remove _initialize_varobj prototype.
* vax-bsd-nat.c: Remove _initialize_vaxbsd_nat prototype.
* vax-nbsd-tdep.c: Remove _initialize_vaxnbsd_tdep prototype.
* vax-tdep.c: Remove _initialize_vax_tdep prototype.
* windows-nat.c: Remove _initialize_windows_nat,
_initialize_check_for_gdb_ini, and _initialize_loadable
prototypes.
* windows-tdep.c: Remove _initialize_windows_tdep prototype.
* xcoffread.c: Remove _initialize_xcoffread prototype.
* xml-support.c: Remove _initialize_xml_support prototype.
* xstormy16-tdep.c: Remove _initialize_xstormy16_tdep prototype.
* xtensa-linux-nat.c: Remove _initialize_xtensa_linux_nat
prototype.
* xtensa-linux-tdep.c: Remove _initialize_xtensa_linux_tdep
prototype.
* xtensa-tdep.c: Remove _initialize_xtensa_tdep prototype.

7 years agoPowerPC64 --plt-align
Alan Modra [Sat, 9 Sep 2017 12:25:22 +0000 (21:55 +0930)]
PowerPC64 --plt-align

This changes the PowerPC64 --plt-align option to perform the usual
alignment of code as suggested by its name, as well as the previous
behaviour of padding so as to reduce boundary crossing.  The old
behaviour is had by using a negative parameter.

The default is also changed to align plt stub code by default to 32
byte boundaries, the point being to get better bctr branch prediction
on power8 and power9 hardware.

bfd/
* elf64-ppp.c (plt_stub_pad): Handle positive and negative
plt_stub_align.
ld/
* ld.texinfo (--plt-align): Describe new behaviour of option.
* emultempl/ppc64elf.em (params): Default plt_stub_align to 5.
* testsuite/ld-powerpc/powerpc.exp: Pass --no-plt-align for
selected tests.
* testsuite/ld-powerpc/relbrlt.d: Pass --no-plt-align.
* testsuite/ld-powerpc/elfv2so.d: Adjust expected output.

7 years agox86: Update UNDEFINED_WEAK_RESOLVED_TO_ZERO
H.J. Lu [Sat, 9 Sep 2017 14:29:15 +0000 (07:29 -0700)]
x86: Update UNDEFINED_WEAK_RESOLVED_TO_ZERO

Since the only information which SYMBOL_REFERENCES_LOCAL_P doesn't check
is relocations, UNDEFINED_WEAK_RESOLVED_TO_ZERO only needs to check for
relocations with SYMBOL_REFERENCES_LOCAL_P.

* elf32-i386.c (elf_i386_relocate_section): Update usage of
UNDEFINED_WEAK_RESOLVED_TO_ZERO.
(elf_i386_finish_dynamic_symbol): Likewise.
* elf64-x86-64.c (elf_x86_64_relocate_section): Likewise.
(elf_x86_64_finish_dynamic_symbol): Likewise.
* elfxx-x86.c (elf_x86_allocate_dynrelocs): Likewise.
(_bfd_x86_elf_fixup_symbol): Likewise.

7 years agox86: Don't check has_non_got_reloc
H.J. Lu [Sat, 9 Sep 2017 14:19:36 +0000 (07:19 -0700)]
x86: Don't check has_non_got_reloc

_bfd_x86_elf_link_symbol_references_local should depend only on symbol
references, not relocations, to work in check_relocs.

* elfxx-x86.c (_bfd_x86_elf_link_symbol_references_local): Don't
check has_non_got_reloc.

7 years agox86: Remove restriction on NOTRACK prefix position
H.J. Lu [Sat, 9 Sep 2017 12:31:30 +0000 (05:31 -0700)]
x86: Remove restriction on NOTRACK prefix position

Since the NOTRACK prefix is no longer required to be the last prefix
before the REX prefix, restriction on the NOTRACK prefix position is
removed from assembler as well as disassembler.  Assembler encodes the
NOTRACK prefix the same way as the DS segment register, which places
it before other prefixes.  Disassembler displays prefixes in the order
they appear.

gas/

* config/tc-i386.c (NOTRACK_PREFIX): Removed.
(REX_PREFIX): Updated.
(MAX_PREFIXES): Likewise.
(parse_insn): Remove restriction on NOTRACK prefix position.
* testsuite/gas/i386/notrack.s: Add tests with NOTRACK prefix
before other prefixes.
* testsuite/gas/i386/x86-64-notrack.s: Likewise.
* testsuite/gas/i386/notrackbad.s: Remove tests with NOTRACK
prefix before other prefixes.
* testsuite/gas/i386/x86-64-notrackbad.s: Likewise.
* testsuite/gas/i386/notrack-intel.d: Updated.
* testsuite/gas/i386/notrack.d: Likewise.
* testsuite/gas/i386/notrackbad.l: Likewise.
* testsuite/gas/i386/x86-64-notrack-intel.d: Likewise.
* testsuite/gas/i386/x86-64-notrack.d: Likewise.
* testsuite/gas/i386/x86-64-notrackbad.l: Likewise.

opcodes/

* i386-dis.c (last_active_prefix): Removed.
(ckprefix): Don't set last_active_prefix.
(NOTRACK_Fixup): Don't check last_active_prefix.

7 years agox86: Properly handle __ehdr_start
H.J. Lu [Sat, 9 Sep 2017 12:05:16 +0000 (05:05 -0700)]
x86: Properly handle __ehdr_start

After _bfd_i386_elf_convert_load and _bfd_x86_64_elf_convert_load are
removed, elf_i386_convert_load_reloc and elf_x86_64_convert_load_reloc
see __ehdr_start as an undefined symbol when they are called from
check_relocs to convert GOT relocations against local symbols.  But
__ehdr_start will be defined as a hidden symbol by linker at the later
stage if it is referenced.  This patch marks __ehdr_start as a defined
local symbol at the start of check_relocs if it is referenced and not
defined.

bfd/

PR ld/22115
* elf32-i386.c (elf_i386_convert_load_reloc): Check linker_def.
Don't use UNDEFINED_WEAK_RESOLVED_TO_ZERO.
* elf64-x86-64.c (elf_x86_64_convert_load_reloc): Check
linker_def.  Don't use UNDEFINED_WEAK_RESOLVED_TO_ZERO.
* elfxx-x86.c (_bfd_x86_elf_link_check_relocs): Set local_ref
and linker_def on __ehdr_start if it is referenced and not
defined.
(_bfd_x86_elf_link_symbol_references_local): Also set local_ref
and return TRUE when building executable, if a symbol has
non-GOT/non-PLT relocations in text section or there is no
dynamic linker.
* elfxx-x86.h (elf_x86_link_hash_entry): Add linker_def.

ld/

PR ld/22115
* ld-i386/i386.exp: Run PR ld/22115 tests,
* ld/testsuite/ld-x86-64/x86-64.exp: Likewise.
* testsuite/ld-i386/pr22115-1.s: New file.
* testsuite/ld-i386/pr22115-1a.d: Likewise.
* testsuite/ld-i386/pr22115-1b.d: Likewise.
* testsuite/ld-i386/pr22115-1c.d: Likewise.
* testsuite/ld-i386/pr22115-1d.d: Likewise.
* testsuite/ld-x86-64/pr22115-1.s: Likewise.
* testsuite/ld-x86-64/pr22115-1a-x32.d: Likewise.
* testsuite/ld-x86-64/pr22115-1a.d: Likewise.
* testsuite/ld-x86-64/pr22115-1b-x32.d: Likewise.
* testsuite/ld-x86-64/pr22115-1b.d: Likewise.
* testsuite/ld-x86-64/pr22115-1c-x32.d: Likewise.
* testsuite/ld-x86-64/pr22115-1c.d: Likewise.
* testsuite/ld-x86-64/pr22115-1d-x32.d: Likewise.
* testsuite/ld-x86-64/pr22115-1d.d: Likewise.

7 years agoAutomatic date update in version.in
GDB Administrator [Sat, 9 Sep 2017 00:00:19 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoRemove unused field field_info.fnfields
Keith Seitz [Fri, 8 Sep 2017 23:44:30 +0000 (16:44 -0700)]
Remove unused field field_info.fnfields

Since at least 7.3 the "fnfields" field in struct field_info has been
unused.  This patch simply removes it.

gdb/ChangeLog:

* dwarf2read.c (struct field_info) <fnfields>: Remove unused
field.

7 years agox86: Update comments in elfxx-x86.h
H.J. Lu [Fri, 8 Sep 2017 16:15:25 +0000 (09:15 -0700)]
x86: Update comments in elfxx-x86.h

* elfxx-x86.h: Update comments.

7 years agoRemove C/C++ relevant code in Fortran specific file.
Christoph Weinmann [Fri, 8 Sep 2017 13:11:47 +0000 (15:11 +0200)]
Remove C/C++ relevant code in Fortran specific file.

Remove code relevant for printing C/C++ Integer values in a
Fortran specific file to unify printing of Fortran values.
This does not change the output.

7 years agofortran: Testsuite, fix typos in vla-value.
Bernhard Heckel [Fri, 8 Sep 2017 13:11:47 +0000 (15:11 +0200)]
fortran: Testsuite, fix typos in vla-value.

7 years agoFortran: Testsuite, fix differences in type naming.
Bernhard Heckel [Fri, 8 Sep 2017 13:11:47 +0000 (15:11 +0200)]
Fortran: Testsuite, fix differences in type naming.

7 years agoFix indentation for printing Fortran types with pointers
Frank Penczek [Fri, 8 Sep 2017 13:11:47 +0000 (15:11 +0200)]
Fix indentation for printing Fortran types with pointers

Printing the prefix "PTR TO -> (" resp. "REF TO ->(" ignored the active
indentation level.  This caused inconsistent appearance of user-defined
Fortran types containing pointers.  Fix by using "fprintfi_filtered" with the
current indentation level for outputting the prefix string.  Add test case
ptr-indentation.

Example using 'ptype' on object of type:
  type TypeWithPointer
    integer i
    integer, pointer:: p
  end type TypeWithPointer

Before:
  type = Type typewithpointer
      integer(kind=4) :: i
  PTR TO -> ( integer(kind=4) :: p)
  End Type typewithpointer

After:
  type = Type typewithpointer
      integer(kind=4) :: i
      PTR TO -> ( integer(kind=4) :: p)
  End Type typewithpointer

7 years agox86: Replace elf_x86_plt_layout_table with elf_x86_init_table
H.J. Lu [Fri, 8 Sep 2017 11:10:34 +0000 (04:10 -0700)]
x86: Replace elf_x86_plt_layout_table with elf_x86_init_table

* elf32-i386.c (elf_i386_link_setup_gnu_properties): Replace
elf_x86_plt_layout_table with elf_x86_init_table.
* elf64-x86-64.c (elf_x86_64_link_setup_gnu_properties):
Likewise.
* elfxx-x86.c (_bfd_x86_elf_link_setup_gnu_properties):
Likewise.
* elfxx-x86.h (elf_x86_plt_layout_table): Renamed to ...
(elf_x86_init_table): This.
(_bfd_x86_elf_link_setup_gnu_properties): Replace
elf_x86_plt_layout_table with elf_x86_init_table.

7 years agox86; Don't add elf64-x86-64.lo nor elf64.lo together with elfxx-x86.lo
H.J. Lu [Fri, 8 Sep 2017 00:19:10 +0000 (17:19 -0700)]
x86; Don't add elf64-x86-64.lo nor elf64.lo together with elfxx-x86.lo

Don't set r_info and r_sym fields in _bfd_x86_elf_link_hash_table_create.
Instead, set them in _bfd_x86_elf_link_setup_gnu_properties.  We can
avoid adding elf64-x86-64.lo and elf64.lo together with elfxx-x86.lo to
bfd_backends.

* configure.ac (bfd_backends): Don't add elf64-x86-64.lo nor
elf64.lo together with elfxx-x86.lo for 64-bit BFD.
* configure: Regenerated.
* elf32-i386.c (elf_i386_link_setup_gnu_properties): Set r_info
and r_sym fields of plt_layout.
* elf64-x86-64.c (elf_x86_64_link_setup_gnu_properties):
Likewise.
* elfxx-x86.c (elf_x86_64_is_reloc_section): Remove BFD64 check.
(_bfd_x86_elf_link_hash_table_create): Likewise.  Don't set
r_info nor r_sym fields.
(_bfd_x86_elf_link_setup_gnu_properties): Set r_info and r_sym
fields of htab.
* elfxx-x86.h (elf_x86_plt_layout_table): Add r_info and r_sym.

7 years agoAutomatic date update in version.in
GDB Administrator [Fri, 8 Sep 2017 00:00:20 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoRISC-V: Avoid emitting invalid instructions in mixed RVC/no-RVC code
Palmer Dabbelt [Fri, 16 Jun 2017 21:33:16 +0000 (14:33 -0700)]
RISC-V: Avoid emitting invalid instructions in mixed RVC/no-RVC code

When linking the following code

    .global _prog_start
    _prog_start:
            mv x1, x1
            mv x2, x2
    .align 2
    rvc_boundry:
    .option norvc
    .align 3
            mv x3, x3

we currently emit an invalid two-byte 0 instruction.  The actual output
code looks like

    0000000080000000 <_prog_start>:
        80000000:   8086                    mv      ra,ra
        80000002:   810a                    mv      sp,sp

    0000000080000004 <rvc_boundry>:
        80000004:   0000                    unimp
        80000006:   0001                    nop
        80000008:   00018193                mv      gp,gp

This ends up manifesting due to the two-byte compressed NOP that's
pessimisticly emitted by the ".align 2", which results in "rvc_boundry"
being 2-byte aligned.  frag_align_code() then goes and outputs a 2-byte
NOP (which is invalid in no-RVC mode) to align the code back to a 4-byte
boundry, which can't be relaxed away by the linker as it's not part of
the R_RISCV_RELAX relocation.

The fix is to just always emit the worst case possible alignment into
the output as a single R_RISCV_RELAX, which the linker will then fix up.

With this patch I get the expected code generation

    0000000080000000 <_prog_start>:
        80000000:   8086                    mv      ra,ra
        80000002:   810a                    mv      sp,sp

    0000000080000004 <rvc_boundry>:
        80000004:   00000013                nop
        80000008:   00018193                mv      gp,gp

gas/ChangeLog

2017-09-07  Palmer Dabbelt  <palmer@dabbelt.com>

        * config/tc-riscv.c (riscv_frag_align_code): Emit the entire
        alignment sequence inside R_RISCV_ALIGN.

7 years agoRISC-V: Print an error when unable to align a section
Palmer Dabbelt [Fri, 16 Jun 2017 21:19:55 +0000 (14:19 -0700)]
RISC-V: Print an error when unable to align a section

This used to just print "can't relax section: Success", which is a silly
error message.

bfd/ChangeLog

2017-09-07  Palmer Dabbelt  <palmer@dabbelt.com>

        * elfnn-riscv.c (_bfd_riscv_relax_align): Call bfd_set_error and
        print an error message when unable to relax a .align directive.

7 years agoRISC-V: Support PCREL_* relocations agaist weak undefined symbols
Palmer Dabbelt [Wed, 16 Aug 2017 17:41:56 +0000 (10:41 -0700)]
RISC-V: Support PCREL_* relocations agaist weak undefined symbols

I recently modified our Linux port's base address such the absolute
address 0 is no longer addressable as a 32-bit PC-relative offset.
Since Linux links a weak undefined symbol in an intermediate binary, it
needs to be able to reference absolute address 0.

This patch changes R_RISCV_PCREL_* relocations to absolute relocations
while resolving them in order to allow these symbols to be referenced in
PC-relative programs linked at high addresses.  Note that this doesn't
apply to PIC, which also uses PC-relative relocations, just to
position-dependent objects, which we use to allow programs to be linked
at high addresses.

In case some of our embedded users are using R_RISCV_PCREL_* as a hacked
up method of getting position-independent binaries (which can work if
you have very simple programs), we only convert the relocations when the
PC-relative version would overflow.

bfd/ChangeLog:

2017-09-07  Palmer Dabbelt  <palmer@dabbelt.com>

        * elfnn-riscv.c (riscv_zero_pcrel_hi_reloc): New function.
        (riscv_record_pcrel_hi_reloc): Add absolute argument.
        (riscv_elf_relocate_section): Call riscv_zero_pcrel_hi_reloc for
        R_RISCV_PCREL_HI20 relocs, and pass the result to
        riscv_record_pcrel_hi_reloc.

7 years agoDocument the GDB 8.0.1 release in gdb/ChangeLog
Joel Brobecker [Thu, 7 Sep 2017 14:40:10 +0000 (07:40 -0700)]
Document the GDB 8.0.1 release in gdb/ChangeLog

gdb/ChangeLog:

GDB 8.0.1 released.

7 years agoremove QStartupWithShell entry from NEWS::Changes in GDB 7.11
Joel Brobecker [Thu, 7 Sep 2017 14:24:33 +0000 (07:24 -0700)]
remove QStartupWithShell entry from NEWS::Changes in GDB 7.11

This entry was added twice within the same commit, back in Dec 2017
by the following change:

    commit aefd8b33d97bded58e51d75271f99e1eaec9fb28
    Date:   Thu Dec 22 22:14:02 2016 -0500
    Subject: Implement proper "startup-with-shell" support on gdbserver

I think the second entry is just a rebase/merge oversight, and it wasn't
meant to be added there, particularly since the 7.11 branch was no longer
active at that time anymore.

This patch just removes the entry.

gdb/ChangeLog:

* NEWS (Changes in GDB 7.11): Remove entry for QStartupWithShell.

7 years agox86: Remove _bfd_{i386,x86_64}_elf_convert_load
H.J. Lu [Thu, 7 Sep 2017 11:03:15 +0000 (04:03 -0700)]
x86: Remove _bfd_{i386,x86_64}_elf_convert_load

Instead of converting GOT relocations when sizing dynamic sections, we
convert GOT relocations during relocation check.  Add a field, local_ref,
to elf_x86_link_hash_entry to indicate if symbol references are always
local with a new function to check if symbol references are always local,
which works in check_relocs.

* elf32-i386.c (elf_i386_convert_load_reloc): Add an argument,
r_type_p.  Remove the converted argument.  Replace
SYMBOL_REFERENCES_LOCAL with SYMBOL_REFERENCES_LOCAL_P.  Return
the new relocation type via r_type_p.
(elf_i386_relocate_section): Likewise.
(elf_i386_finish_dynamic_symbol): Likewise.
(need_convert_load): Removed.
(check_relocs_failed): Updated.
(elf_i386_check_relocs): Call elf_i386_convert_load_reloc,
instead of setting need_convert_load.
(_bfd_i386_elf_convert_load): Removed.
* elf64-x86-64.c (need_convert_load): Removed.
(check_relocs_failed): Updated.
(elf_x86_64_convert_load_reloc): Add an argument, r_type_p.
Replace SYMBOL_REFERENCES_LOCAL with SYMBOL_REFERENCES_LOCAL_P.
Return the new relocation type via r_type_p.
(elf_x86_64_check_relocs): Call elf_x86_64_convert_load_reloc,
instead of setting need_convert_load.
(elf_x86_64_check_relocs): Don't check PIC if relocation has
been converted.
(_bfd_x86_64_elf_convert_load): Removed.
(elf_x86_64_relocate_section): Replace SYMBOL_REFERENCES_LOCAL
with SYMBOL_REFERENCES_LOCAL_P.
(elf_x86_64_finish_dynamic_symbol): Likewise.
* elfxx-x86.c (_bfd_x86_elf_link_hash_table_create): Don't
set convert_load.
(_bfd_x86_elf_size_dynamic_sections): Don't call convert_load.
(_bfd_x86_elf_link_symbol_references_local): New function.
* elfxx-x86.h (SYMBOL_REFERENCES_LOCAL_P): New.
(UNDEFINED_WEAK_RESOLVED_TO_ZERO): Replace elf.forced_local with
SYMBOL_REFERENCES_LOCAL_P.
(elf_x86_link_hash_entry): Add local_ref.
(elf_x86_link_hash_table): Remove convert_load.
(_bfd_i386_elf_convert_load): Removed.
(_bfd_x86_64_elf_convert_load): Likewise.
(_bfd_x86_elf_link_symbol_references_local): New.

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

7 years agoChange funcall_chain to be a std::vector
Tom Tromey [Mon, 4 Sep 2017 03:50:47 +0000 (21:50 -0600)]
Change funcall_chain to be a std::vector

This simplifies the handling of funcall_chain, by changing it to be a
std::vector<int> and then fixing the users.  This allows the removal
of a cleanup.

It would be even cleaner to replace this with better logic in the
parsers; but a baby step seemed ok.

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

* parse.c (funcall_chain): Now a std::vector.
(start_arglist, end_arglist): Simplify.
(free_funcalls): Remove.
(parse_exp_in_context_1): Remove cleanup.

7 years agoRemove last cleanups from go-exp.y
Tom Tromey [Sun, 13 Aug 2017 16:40:35 +0000 (10:40 -0600)]
Remove last cleanups from go-exp.y

This removes the last remaining cleanups from go-exp.y.

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

* go-exp.y (go_parse): Don't create a cleanup.

7 years agoRemove last cleanups from d-exp.y
Tom Tromey [Sun, 13 Aug 2017 16:38:53 +0000 (10:38 -0600)]
Remove last cleanups from d-exp.y

This removes the last remaining cleanups from d-exp.y.

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

* d-exp.y (PrimaryExpression): Use std::string.
(d_parse): Don't create a cleanup.

7 years agoRemove make_cleanup_clear_parser_state
Tom Tromey [Sun, 13 Aug 2017 16:37:13 +0000 (10:37 -0600)]
Remove make_cleanup_clear_parser_state

This removes make_cleanup_clear_parser_state in favor of
scoped_restore.

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

* utils.c (do_clear_parser_state): Remove.
(make_cleanup_clear_parser_state): Remove.
* p-exp.y (pascal_parse): Use scoped_restore.
* m2-exp.y (m2_parse): Use scoped_restore.
* f-exp.y (f_parse): Use scoped_restore.
* d-exp.y (d_parse): Use scoped_restore.
* c-exp.y (c_parse): Use scoped_restore.
* ada-exp.y (ada_parse): Use scoped_restore.
* utils.h (make_cleanup_clear_parser_state): Remove.

7 years agoIntroduce dw2_linkage_name and dw2_linkage_name_attr.
Keith Seitz [Wed, 6 Sep 2017 19:50:52 +0000 (12:50 -0700)]
Introduce dw2_linkage_name and dw2_linkage_name_attr.

The DWARF reader is littered with the following idiom to read a linkage name
from the debug info:

  mangled = dwarf2_string_attr (die, DW_AT_linkage_name, cu);
  if (mangled == NULL)
    mangled = dwarf2_string_attr (die, DW_AT_MIPS_linkage_name, cu);

This patch introduces functions to simplify this to:

  mangled = dw2_linkage_name (die, cu);

or

  attr = dw2_linkage_name_attr (die, cu);

gdb/ChangeLog:

* dwarf2read.c (dw2_linkage_name_attr): New function.
(dw2_linkage_name): New function.
(dwarf2_compute_name, dwarf2_physname, read_call_site_scope)
(guess_full_die_structure_name, dwarf2_name): Use dw2_linkage_name.
(anonymous_struct_prefix, dwarf2_name): Use dw2_linkage_name_attr.