]> git.ipfire.org Git - thirdparty/binutils-gdb.git/log
thirdparty/binutils-gdb.git
7 years ago-Wwrite-strings: gdbserver's 'port' parsing
Pedro Alves [Wed, 5 Apr 2017 18:21:35 +0000 (19:21 +0100)] 
-Wwrite-strings: gdbserver's 'port' parsing

-Wwrite-strings flags this assignment as requiring a cast:

  port = STDIO_CONNECTION_NAME;

because 'port' is a "char *", and STDIO_CONNECTION_NAME is a string
literal.

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

        * remote-utils.c (remote_prepare, remote_open): Constify.
        * remote-utils.h (remote_prepare, remote_open): Constify.
        * server.c (captured_main): Constify 'port' handling.

7 years ago-Wwrite-strings: MI -info-os
Pedro Alves [Wed, 5 Apr 2017 18:21:35 +0000 (19:21 +0100)] 
-Wwrite-strings: MI -info-os

-Wwrite-strings flags this attempt to convert a string literal to
 "char *":

      info_osdata_command ("", 0);

info_osdata_command is a command function.  We could address this by
simply passing NULL instead of "".  However, I went a little bit
further and added a new function that is called by both the CLI and
MI.

gdb/ChangeLog:
2017-04-05  Pedro Alves  <palves@redhat.com>

* mi/mi-cmd-info.c (mi_cmd_info_os): Call info_osdata instead of
info_osdata_command.
* osdata.c (info_osdata_command): Rename to ...
(info_osdata): ... this.  Constify 'type' parameter, and remove
the 'from_tty' parameter.  Accept NULL TYPE.
(info_osdata_command): New function.
* osdata.h (info_osdata_command): Remove declaration.
(info_osdata): New declaration.

7 years ago-Wwrite-strings: Constify mi_cmd_argv_ftype's 'command' parameter
Pedro Alves [Wed, 5 Apr 2017 18:21:34 +0000 (19:21 +0100)] 
-Wwrite-strings: Constify mi_cmd_argv_ftype's 'command' parameter

-Wwrite-strings flags this attempt to pass a literal to a "char *":

mi_cmd_interpreter_exec ("-interpreter-exec", argv, 2);

Fix that by constifying mi_cmd_argv_ftype's 'command' parameter and
adjusting all MI commands.

gdb/ChangeLog:
2017-04-05  Pedro Alves  <palves@redhat.com>

* mi/mi-cmd-break.c (mi_cmd_break_insert_1, mi_cmd_break_insert)
(mi_cmd_dprintf_insert, mi_cmd_break_passcount)
(mi_cmd_break_watch, mi_cmd_break_commands): Constify 'command'
parameter.
* mi/mi-cmd-catch.c (mi_cmd_catch_assert, mi_cmd_catch_exception)
(mi_cmd_catch_load, mi_cmd_catch_unload): Constify cmd' parameter.
* mi/mi-cmd-disas.c (mi_cmd_disassemble): Constify 'command'
parameter.
* mi/mi-cmd-env.c (mi_cmd_env_pwd, mi_cmd_env_cd, mi_cmd_env_path)
(mi_cmd_env_dir, mi_cmd_inferior_tty_set, _cmd_inferior_tty_show)
* mi/mi-cmd-file.c (mi_cmd_file_list_exec_source_file)
(mi_cmd_file_list_exec_source_files)
(mi_cmd_file_list_shared_libraries): Constify 'command' parameter.
* mi/mi-cmd-info.c (mi_cmd_info_ada_exceptions)
(mi_cmd_info_gdb_mi_command, mi_cmd_info_os): Constify 'command'
parameter.
* mi/mi-cmd-stack.c (mi_cmd_enable_frame_filters)
(mi_cmd_stack_list_frames, mi_cmd_stack_info_depth)
(mi_cmd_stack_list_locals, mi_cmd_stack_list_args)
(mi_cmd_stack_list_variables, mi_cmd_stack_select_frame)
(mi_cmd_stack_info_frame): Constify 'command' parameter.
* mi/mi-cmd-target.c (mi_cmd_target_file_get)
(mi_cmd_target_file_put, mi_cmd_target_file_delete): Constify
'command' parameter.
* mi/mi-cmd-var.c (mi_cmd_var_create, mi_cmd_var_delete)
(mi_cmd_var_set_format, mi_cmd_var_set_visualizer)
(mi_cmd_var_set_frozen, mi_cmd_var_show_format)
(mi_cmd_var_info_num_children, mi_cmd_var_list_children)
(mi_cmd_var_info_type, mi_cmd_var_info_path_expression)
(mi_cmd_var_info_expression, mi_cmd_var_show_attributes)
(mi_cmd_var_evaluate_expression, mi_cmd_var_assign)
(mi_cmd_var_update, mi_cmd_enable_pretty_printing)
(mi_cmd_var_set_update_range): Constify 'command' parameter.
* mi/mi-cmds.h (mi_cmd_argv_ftype): Constify 'command' parameter.
* mi/mi-interp.c (mi_cmd_interpreter_exec): Constify 'command'
parameter.
* mi/mi-main.c (mi_cmd_gdb_exit, mi_cmd_exec_next)
(mi_cmd_exec_next_instruction, mi_cmd_exec_step)
(mi_cmd_exec_step_instruction, mi_cmd_exec_finish)
(mi_cmd_exec_return ,mi_cmd_exec_jump, mi_cmd_exec_continue)
(mi_cmd_exec_interrupt, mi_cmd_exec_run, mi_cmd_target_detach)
(mi_cmd_target_flash_erase, mi_cmd_thread_select)
(mi_cmd_thread_list_ids, mi_cmd_thread_info)
(mi_cmd_list_thread_groups, mi_cmd_data_list_register_names)
(mi_cmd_data_list_changed_registers)
(mi_cmd_data_write_register_values)
(mi_cmd_data_evaluate_expression, mi_cmd_data_read_memory)
(mi_cmd_data_read_memory_bytes, mi_cmd_data_write_memory)
(mi_cmd_data_write_memory_bytes, mi_cmd_enable_timings)
(mi_cmd_list_features, mi_cmd_list_target_features)
(mi_cmd_add_inferior, mi_cmd_remove_inferior)
(mi_cmd_trace_define_variable, mi_cmd_trace_list_variables)
(mi_cmd_trace_find, mi_cmd_trace_save, mi_cmd_trace_start)
(mi_cmd_trace_status, mi_cmd_trace_stop, mi_cmd_ada_task_info)
(mi_cmd_trace_frame_collected): Constify 'command'
parameter.
* mi/mi-symbol-cmds.c (mi_cmd_symbol_list_lines): Constify
'command' parameter.

7 years ago-Wwrite-strings: Constify word break character arrays
Pedro Alves [Wed, 5 Apr 2017 18:21:34 +0000 (19:21 +0100)] 
-Wwrite-strings: Constify word break character arrays

-Wwrite-strings flags several cases of missing casts around
initializations like:

   static char *gdb_completer_command_word_break_characters =
    " \t\n!@#$%^&*()+=|~`}{[]\"';:?/>.<,";

Obviously these could/should be const.  However, while at it, there's
no need for these variables to be pointers instead of arrays.  They
are never changed to point to anything else.

Unfortunately, readline's rl_completer_word_break_characters is
"char *", not "const char *".  So we always need a cast somewhere.  The
approach taken here is to add a new
set_rl_completer_word_break_characters function that becomes the only
place that writes to rl_completer_word_break_characters, and thus the
single place that needs the cast.

gdb/ChangeLog:
2017-04-05  Pedro Alves  <palves@redhat.com>

* ada-lang.c (ada_completer_word_break_characters): Now a const
array.
(ada_get_gdb_completer_word_break_characters): Constify.
* completer.c (gdb_completer_command_word_break_characters)
(gdb_completer_file_name_break_characters)
(gdb_completer_quote_characters): Now const arrays.
(get_gdb_completer_quote_characters): Constify.
(set_rl_completer_word_break_characters): New function.
(set_gdb_completion_word_break_characters)
(complete_line_internal): Use it.
* completer.h (get_gdb_completer_quote_characters): Constify.
(set_rl_completer_word_break_characters): Declare.
* f-lang.c (f_word_break_characters): Constify.
* language.c (default_word_break_characters): Constify.
* language.h (language_defn::la_word_break_characters): Constify.
(default_word_break_characters): Constify.
* top.c (init_main): Use set_rl_completer_word_break_characters.

7 years ago-Wwrite-strings: Constify target_pid_to_str and target_thread_extra_thread_info
Pedro Alves [Wed, 5 Apr 2017 18:21:34 +0000 (19:21 +0100)] 
-Wwrite-strings: Constify target_pid_to_str and target_thread_extra_thread_info

-Wwrite-strings flagged a missing cast for example here:

   static char *
   ravenscar_extra_thread_info (struct target_ops *self, struct thread_info *tp)
   {
     return "Ravenscar task";

Since callers are not supposed to free the string returned by these
methods, change the methods' signature to return const strings.

gdb/ChangeLog:
2017-04-05  Pedro Alves  <palves@redhat.com>

* aix-thread.c (aix_thread_pid_to_str)
(aix_thread_extra_thread_info): Constify.
* bsd-kvm.c (bsd_kvm_pid_to_str): Constify.
* bsd-uthread.c (bsd_uthread_extra_thread_info)
(bsd_uthread_pid_to_str): Constify.
* corelow.c (core_pid_to_str): Constify.
* darwin-nat.c (darwin_pid_to_str): Constify.
* fbsd-nat.c (fbsd_pid_to_str): Constify.
* fbsd-tdep.c (fbsd_core_pid_to_str, gdbarch_core_pid_to_str):
Constify.
* gnu-nat.c (gnu_pid_to_str): Constify.
* go32-nat.c (go32_pid_to_str): Constify.
* i386-cygwin-tdep.c (i386_windows_core_pid_to_str): Constify.
* inf-ptrace.c (inf_ptrace_pid_to_str): Constify.
* inferior.c (inferior_pid_to_str): Constify.
* linux-nat.c (linux_nat_pid_to_str): Constify.
* linux-tdep.c (linux_core_pid_to_str): Constify.
* linux-thread-db.c (thread_db_pid_to_str)
(thread_db_extra_thread_info): Constify.
* nto-tdep.c (nto_extra_thread_info): Constify.
* nto-tdep.h (nto_extra_thread_info): Constify.
* obsd-nat.c (obsd_pid_to_str): Constify.
* procfs.c (procfs_pid_to_str): Constify.
* ravenscar-thread.c (ravenscar_extra_thread_info)
(ravenscar_pid_to_str): Constify.
* remote-sim.c (gdbsim_pid_to_str): Constify.
* remote.c (remote_threads_extra_info, remote_pid_to_str):
Constify.
* sol-thread.c (solaris_pid_to_str): Constify.
* sol2-tdep.c (sol2_core_pid_to_str): Constify.
* sol2-tdep.h (sol2_core_pid_to_str): Constify.
* target.c (default_pid_to_str, target_pid_to_str)
(normal_pid_to_str, default_pid_to_str): Constify.
* target.h (target_ops::to_pid_to_str)
(target_ops::to_extra_thread_info): Constify.
(target_pid_to_str, normal_pid_to_str): Constify.
* windows-nat.c (windows_pid_to_str): Constify.
* gdbarch.sh (core_pid_to_str): Constify.
* target-delegates.c: Regenerate.
* gdbarch.h, gdbarch.c: Regenerate.

7 years ago-Wwrite-strings: Constify warning_pre_print
Pedro Alves [Wed, 5 Apr 2017 18:21:34 +0000 (19:21 +0100)] 
-Wwrite-strings: Constify warning_pre_print

-Wwrite-strings flags a warning here:

  char *warning_pre_print = "\nwarning: ";

gdb/ChangeLog:
2017-04-05  Pedro Alves  <palves@redhat.com>

* main.c (captured_main_1): Use gdb::unique_xmalloc_ptr to manage
the memory of the temporary warning_pre_print override.
* utils.c (warning_pre_print): Constify.
* utils.h (warning_pre_print): Constify.

7 years ago-Wwrite-strings: Constify shell_escape and plug make_command leak
Pedro Alves [Wed, 5 Apr 2017 18:21:34 +0000 (19:21 +0100)] 
-Wwrite-strings: Constify shell_escape and plug make_command leak

gdb/ChangeLog:
2017-04-05  Pedro Alves  <palves@redhat.com>

* cli/cli-cmds.c (shell_escape): Constify 'arg' parameter.
(shell_command): New function.
(make_command): Use std::string.
(init_cli_cmds): Register shell_command instead of shell_escape.

7 years ago-Wwrite-strings: Don't initialize string command variables to empty string
Pedro Alves [Wed, 5 Apr 2017 18:21:33 +0000 (19:21 +0100)] 
-Wwrite-strings: Don't initialize string command variables to empty string

-Wwrite-strings flags these initializations as requiring a cast.
However, these variables are command variables, and as such point to
heap-allocated memory.  The initial allocation is always done when the
corresponding command is registered.  E.g.,:

    dprintf_function = xstrdup ("printf");
    add_setshow_string_cmd ("dprintf-function", class_support,
    &dprintf_function, _("\
  Set the function to use for dynamic printf"), _("\
  Show the function to use for dynamic printf"), NULL,
    update_dprintf_commands, NULL,
    &setlist, &showlist);

That's why we never reach a bogus attempt to free these string
literals.

So, just drop the incorrect initializations.

gdb/ChangeLog:
2017-04-05  Pedro Alves  <palves@redhat.com>

* breakpoint.c (dprintf_function, dprintf_channel): Don't initialize.
* tracepoint.c (default_collect): Don't initialize.

7 years ago-Wwrite-strings: Constify macroexp.c:init_shared_buffer
Pedro Alves [Wed, 5 Apr 2017 18:21:33 +0000 (19:21 +0100)] 
-Wwrite-strings: Constify macroexp.c:init_shared_buffer

There's one call in the file that passes a string literal, like:

init_shared_buffer (&va_arg_name, "__VA_ARGS__",
  strlen ("__VA_ARGS__"));

Instead of adding a cast here, make init_shared_buffer take a 'const
char *', and remove the several casts in the file that are made
obsolete.

gdb/ChangeLog:
2017-04-05  Pedro Alves  <palves@redhat.com>

* macroexp.c (macro_buffer::shared): Now a bool.
(init_buffer): Update.
(init_shared_buffer): Constify 'addr' parameter.
(substitute_args, expand, macro_expand, macro_expand_next): Remove
casts.

7 years ago-Wwrite-strings: Constify struct disassemble_info's disassembler_options field
Pedro Alves [Wed, 5 Apr 2017 18:21:33 +0000 (19:21 +0100)] 
-Wwrite-strings: Constify struct disassemble_info's disassembler_options field

The memory disassemble_info::disassembler_options points to is always
owned by the client.  I.e., that field is an non-owning, observing
pointer.  Thus const makes sense.

Are the include/ and opcodes/ bits OK?

Tested on x86_64 Fedora 23, built with --enable-targets=all.

include/ChangeLog:
2017-04-05  Pedro Alves  <palves@redhat.com>

* dis-asm.h (disassemble_info) <disassembler_options>: Now a
"const char *".
(next_disassembler_option): Constify.

opcodes/ChangeLog:
2017-04-05  Pedro Alves  <palves@redhat.com>

* arc-dis.c (parse_option, parse_disassembler_options): Constify.
* arm-dis.c (parse_arm_disassembler_options): Constify.
* ppc-dis.c (powerpc_init_dialect): Constify local.
* vax-dis.c (parse_disassembler_options): Constify.

gdb/ChangeLog:
2017-04-05  Pedro Alves  <palves@redhat.com>

* arm-tdep.c (show_disassembly_style_sfunc): Constify local.
* disasm.c (set_disassembler_options): Constify local.
* i386-tdep.c (i386_print_insn): Remove cast and FIXME comment.

7 years agoPR 21352: Add testsuite for "tsave -r" command
Sergio Durigan Junior [Wed, 5 Apr 2017 16:43:52 +0000 (12:43 -0400)] 
PR 21352: Add testsuite for "tsave -r" command

This commit adds a test for the fix of PR 21352.

gdb/testsuite/ChangeLog:
2017-04-05  Sergio Durigan Junior  <sergiodj@redhat.com>

PR gdb/21352
* gdb.trace/tsv.exp: Add test for "tsave -r".

7 years agoFix PR 21352: Command tsave does not support -r argument
Sergio Durigan Junior [Wed, 5 Apr 2017 16:28:30 +0000 (12:28 -0400)] 
Fix PR 21352: Command tsave does not support -r argument

This is an obvious fix for PR 21352.  The problem is that the argument
parsing loop is not using an "else if" where it should, and therefore
the '-r' option ends up unrecognized by GDB.

gdb/ChangeLog:
2017-04-05  Sergio Durigan Junior  <sergiodj@redhat.com>

PR gdb/21352
* tracefile.c (tsave_command): Fix argument parsing for '-r'
option.

7 years agoUse frame_unwind_register_value in frame_unwind_register_unsigned
Yao Qi [Wed, 5 Apr 2017 13:55:43 +0000 (14:55 +0100)] 
Use frame_unwind_register_value in frame_unwind_register_unsigned

gdb:

2017-04-05  Yao Qi  <yao.qi@linaro.org>

* frame.c (frame_unwind_register_unsigned): Call
frame_unwind_register_value.

7 years agoFix racy test in gdb.threads/thread-specific-bp.exp
Yao Qi [Wed, 5 Apr 2017 13:46:13 +0000 (14:46 +0100)] 
Fix racy test in gdb.threads/thread-specific-bp.exp

I see the following test fail from time to time, due to the racy test
in gdb.threads/thread-specific-bp.exp.

continue -a^M
Continuing.^M
^M
Thread 1 "thread-specific" hit Breakpoint 4, end () at binutils-gdb/gdb/testsuite/gdb.threads/thread-specific-bp.c:29^M
29      }^M
(gdb) [Thread 0x40322460 (LWP 12950) exited]^M
Thread-specific breakpoint 3 deleted - thread 2 no longer in the thread list.^M
FAIL: gdb.threads/thread-specific-bp.exp: non-stop: continue to end (timeout)

This patch changes gdb_test to gdb_test_multiple to match prompt only
instead of both prompt and anchor.

gdb/testsuite:

2017-04-05  Yao Qi  <yao.qi@linaro.org>

* gdb.threads/thread-specific-bp.exp (check_thread_specific_breakpoint):
Use gdb_test_multiple, and don't match anchor.

7 years agoPowerPC64le PLT reference counting
Alan Modra [Wed, 5 Apr 2017 03:17:41 +0000 (12:47 +0930)] 
PowerPC64le PLT reference counting

A fix for ELFv2 ABI garbage-collection.

* elf64-ppc.c (ppc64_elf_gc_sweep_hook): Support ELFv2 PLT
reference counting.

7 years agoNew global maintainer - Simon Marchi
Pedro Alves [Wed, 5 Apr 2017 08:39:49 +0000 (09:39 +0100)] 
New global maintainer - Simon Marchi

gdb/ChangeLog:
2017-04-05  Pedro Alves  <palves@redhat.com>

* MAINTAINERS (Global Maintainers): Add Simon Marchi.
(Write After Approval): Remove Simon Marchi.

7 years agoPR ld/21233: xfail failing test-parts for cris*-*-*
Hans-Peter Nilsson [Wed, 5 Apr 2017 01:00:40 +0000 (03:00 +0200)] 
PR ld/21233: xfail failing test-parts for cris*-*-*

7 years agoInitialize gdb::optional empty payload to quiet false -Wmaybe-uninitialized warnings
Pedro Alves [Tue, 4 Apr 2017 22:49:27 +0000 (23:49 +0100)] 
Initialize gdb::optional empty payload to quiet false -Wmaybe-uninitialized warnings

Commit ecfb656c37b982 ("dwarf2read.c: Make dir_index and
file_name_index strong typedefs") added a use of gdb::optional that
triggers bogus -Wmaybe-uninitialized warnings:

GCC trunk is complaining like this:

  ../../binutils-gdb/gdb/dwarf2read.c: In function void read_formatted_entries(bfd*, const gdb_byte**, line_header*, const comp_unit_head*, void (*)(line_header*, const char*, dir_index, unsigned int, unsigned int)):
  ../../binutils-gdb/gdb/dwarf2read.c:17779:65: error: fe.file_entry::length may be used uninitialized in this function [-Werror=maybe-uninitialized]
 callback (lh, fe.name, fe.d_index, fe.mod_time, fe.length);
   ^
  ../../binutils-gdb/gdb/dwarf2read.c:17779:65: error: *((void*)& fe +8) may be used uninitialized in this function [-Werror=maybe-uninitialized]
  ../../binutils-gdb/gdb/dwarf2read.c:17779:65: error: fe.file_entry::mod_time may be used uninitialized in this function [-Werror=maybe-uninitialized]
  ../../binutils-gdb/gdb/dwarf2read.c:17779:65: error: fe.file_entry::name may be used uninitialized in this function [-Werror=maybe-uninitialized]

While some older GCCs are complaining like this:

  ../../binutils-gdb/gdb/dwarf2read.c: In function void read_formatted_entries(bfd*, const gdb_byte**, line_header*, const comp_unit_head*, void (*)(line_header*, const char*, dir_index, unsigned int, unsigned int)):
  ../../binutils-gdb/gdb/dwarf2read.c:17779:65: error: uint may be used uninitialized in this function [-Werror=maybe-uninitialized]
 callback (lh, fe.name, fe.d_index, fe.mod_time, fe.length);

Looking around the web, I see that boost's optional implementation
triggers this kind of issue often too.  See:

  http://www.boost.org/doc/libs/1_63_0/libs/optional/doc/html/boost_optional/tutorial/gotchas/false_positive_with__wmaybe_uninitialized.html

I noticed that replacing the gdb::optional uses with real C++17
std::optional uses against GCC 7/trunk makes the warnings go away.
Looking at the implementation, AFAICS, libstdc++ always initializes
its "empty" union payload member (_M_empty, which is defined as an
empty class, like ours).  I.e., all payload types have this ctor:

    struct _Optional_payload.....
    {
      constexpr _Optional_payload()
: _M_empty() {}

The constexpr makes a diference too.  Without it, GCC7 still warns.

So I'm applying the same treatment to our gdb::optional.

gdb/ChangeLog:
2017-04-05  Pedro Alves  <palves@redhat.com>

* common/gdb_optional.h (optional::optional): Make constexpr and
initialize m_dummy.

7 years agoAutomatic date update in version.in
GDB Administrator [Wed, 5 Apr 2017 00:00:36 +0000 (00:00 +0000)] 
Automatic date update in version.in

7 years agoPR ld/21233: Avoid sweeping forced-undefined symbols in section GC
Maciej W. Rozycki [Mon, 27 Mar 2017 11:39:07 +0000 (12:39 +0100)] 
PR ld/21233: Avoid sweeping forced-undefined symbols in section GC

Complement commit 902e9fc76a0e ("PR ld/20828: Move symbol version
processing ahead of GC symbol sweep"), commit b531344c34b0 ("PR
ld/20828: Reorder the symbol sweep stage of section GC") and commit
81ff47b3a546 ("PR ld/20828: Fix linker script symbols wrongly forced
local with section GC"), and prevent symbols forcibly entered in the
output file with the use of the `--undefined=' or `--require-defined='
linker command line options or the EXTERN linker script command from
being swept in section garbage collection and consequently recorded in
the dynamic symbol table as local entries.  This happens in certain
circumstances, where a symbol reference also exists in one of the static
input files, however only in a section which is garbage-collected and
does not make it to the output file, and the symbol is defined in a
dynamic object present in the link.

For example with the `i386-linux' target and the `pr21233.s' and
`pr21233-l.s' sources, and the `pr21233.ld' linker script included with
this change we get:

$ as -o pr21233-l.o pr21233-l.s
$ ld -shared -T pr21233.ld -o libpr21233.so pr21233-l.o
$ as -o pr21233.o pr21233.s
$ ld --gc-sections -e foo --require-defined=bar -T pr21233.ld -o pr21233 pr21233.o libpr21233.so
$ readelf --dyn-syms pr21233

Symbol table '.dynsym' contains 2 entries:
   Num:    Value  Size Type    Bind   Vis      Ndx Name
     0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND
     1: 00000000     0 OBJECT  LOCAL  DEFAULT  UND bar
$

which makes the run-time `bar' dependency of the `pr21233' executable
different from its corresponding link-time dependency, i.e. the presence
of `libpr21233.so' and its `bar' symbol is required at the link time,
however at the run time a copy of `libpr21233.so' without `bar' will do.
Similarly with `--undefined=' and EXTERN which do not actually require
the reference to the symbol requested to be satisfied with a definition
at the link time, however once the definition has been pulled at the
link time, so it should at the dynamic load time.

Additionally with the `mips-linux' target we get:

$ ld --gc-sections -e foo --require-defined=bar -T pr21233.ld -o pr21233 pr21233.o libpr21233.so
ld: BFD (GNU Binutils) 2.28.51.20170324 assertion fail .../bfd/elfxx-mips.c:3861
$

as the target is not prepared to handle such a local dynamic symbol.

With this change in effect we get:

$ readelf --dyn-syms pr21233

Symbol table '.dynsym' contains 2 entries:
   Num:    Value  Size Type    Bind   Vis      Ndx Name
     0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND
     1: 00000000     0 OBJECT  GLOBAL DEFAULT  UND bar
$

instead, for both targets.

ld/
PR ld/21233
* ldlang.c (insert_undefined): Set `mark' for ELF symbols.
* testsuite/ld-elf/pr21233.sd: New test.
* testsuite/ld-elf/pr21233-l.sd: New test.
* testsuite/ld-elf/pr21233.ld: New test linker script.
* testsuite/ld-elf/pr21233-e.ld: New test linker script.
* testsuite/ld-elf/pr21233.s: New test source.
* testsuite/ld-elf/pr21233-l.s: New test source.
* testsuite/ld-elf/shared.exp: Run the new tests.

7 years agoRemove support for using the bsd-uthread target on FreeBSD.
John Baldwin [Tue, 4 Apr 2017 21:28:07 +0000 (14:28 -0700)] 
Remove support for using the bsd-uthread target on FreeBSD.

The bsd-uthread target supports an old thread library ("libc_r") that
was last included in FreeBSD release 6.4 released in 2008.  However,
this library has not been used as the default library since FreeBSD
5.0 (2003) and 4.11 (2005).  Thread support for modern FreeBSD binaries
is provided via "normal" LWP support in core files and the native
FreeBSD target.

gdb/ChangeLog:

* amd64-fbsd-tdep.c: Remove "bsd-uthread.h" include.
(amd64fbsd_jmp_buf_reg_offset): Remove.
(amd64fbsd_supply_uthread): Remove function.
(amd64fbsd_collect_uthread): Remove function.
(amd64fbsd_init_abi): Don't set bsd-uthread callbacks.
* configure.tgt (i[34567]86-*-freebsd*): Remove bsd-uthread.o.
(x86_64-*-freebsd*): Remove bsd-uthread.o.
(fbsd-nat.c): Update comment.
* i386-fbsd-tdep.c: Remove "bsd-uthread.h" include.
(i386fbsd_jmp_buf_reg_offset): Remove.
(i386fbsd_supply_uthread): Remove function.
(i386fbsd_collect_uthread): Remove function.
(i386fbsd_init_abi): Don't set bsd-uthread callbacks.

7 years agoRemove support for FreeBSD/alpha.
John Baldwin [Tue, 4 Apr 2017 21:20:37 +0000 (14:20 -0700)] 
Remove support for FreeBSD/alpha.

FreeBSD last shipped a release for Alpha (6.3) in 2008.
This also removes support for GNU/kFreeBSD on Alpha.

gdb/ChangeLog:

* Makefile.in (ALL_64_TARGET_OBS): Remove alpha-fbsd-tdep.o.
(ALLDEPFILES): Remove alpha-fbsd-tdep.c
* NEWS: Mention that support for FreeBSD/alpha was removed.
* alpha-fbsd-tdep.c: Delete file.
* config/alpha/fbsd.mh: Delete file.
* configure.host: Delete alpha*-*-freebsd* and
alpha*-*-kfreebsd*-gnu.
* configure.tgt: Delete alpha*-*-freebsd* and
alpha*-*-kfreebsd*-gnu.

7 years agoUse ptid from regcache instead of inferior_ptid.
John Baldwin [Tue, 4 Apr 2017 20:57:47 +0000 (13:57 -0700)] 
Use ptid from regcache instead of inferior_ptid.

gdb/ChangeLog:

* amd64-bsd-nat.c (amd64bsd_fetch_inferior_registers,
amd64bsd_store_inferior_registers): Use ptid from regcache.

7 years agodwarf2read.c: C++fy lnp_state_machine
Pedro Alves [Tue, 4 Apr 2017 19:03:26 +0000 (20:03 +0100)] 
dwarf2read.c: C++fy lnp_state_machine

While I was looking at the file, I noticed that this struct could be
nicely converted to a class.  As I was progressing, I ended up moving
all state machine actual internal state manipulation to methods of
lnp_state_machine, essentially decoupling DWARF parsing from state
tracking.  I also noticed that the lnp_reader_state doesn't really
serve any good use, so that's eliminated in the process.

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

* dwarf2read.c (lnp_state_machine): Now a class.  Initialize all
data fields, make them private and add "m_" prefixes.
(lnp_state_machine::lnp_state_machine): New ctor.
(record_line, check_line_address, handle_set_discriminator)
(handle_set_address, handle_advance_pc, handle_special_opcode)
(handle_advance_line, handle_set_file, handle_negate_stmt)
(handle_const_add_pc, handle_fixed_advance_pc, handle_copy)
(end_sequence, advance_line): New methods.
(m_gdbarch, m_record_lines_p): New fields.
(lnp_reader_state): Delete.
(dwarf_record_line): Rename to ...
(lnp_state_machine::record_line): ... adjust.
(init_lnp_state_machine): Delete.
(lnp_state_machine::lnp_state_machine): New.
(check_line_address): Rename to ...
(lnp_state_machine::check_line_address): This.
(dwarf_decode_lines_1): Remove reference to "reader_state".
Adjust lnp_state_machine having a non-default ctor.  Use bool.
State machine internal state manipulation moved to
lnp_state_machine methods.

7 years agoMake sect_offset and cu_offset strong typedefs instead of structs
Pedro Alves [Tue, 4 Apr 2017 19:03:26 +0000 (20:03 +0100)] 
Make sect_offset and cu_offset strong typedefs instead of structs

A while ago, back when GDB was a C program, the sect_offset and
cu_offset types were made structs in order to prevent incorrect mixing
of those offsets.  Now that we require C++11, we can make them
integers again, while keeping the safety, by exploiting "enum class".
We can add a bit more safety, even, by defining operators that the
types _should_ support, helping making the suspicious uses stand out
more.

Getting at the underlying type is done with the new to_underlying
function added by the previous patch, which also helps better spot
where do we need to step out of the safety net.  Mostly, that's around
parsing the DWARF, and when we print the offset for complaint/debug
purposes.  But there are other occasional uses.

Since we have to define the sect_offset/cu_offset types in a header
anyway, I went ahead and generalized/library-fied the idea of "offset"
types, making it trivial to add more such types if we find a use.  See
common/offset-type.h and the DEFINE_OFFSET_TYPE macro.

I needed a couple generaly-useful preprocessor bits (e.g., yet another
CONCAT implementation), so I started a new common/preprocessor.h file.

I included units tests covering the "offset" types API.  These are
mostly compile-time tests, using SFINAE to check that expressions that
shouldn't compile (e.g., comparing unrelated offset types) really are
invalid and would fail to compile.  This same idea appeared in my
pending enum-flags revamp from a few months ago (though this version
is a bit further modernized compared to what I had posted), and I plan
on reusing the "check valid expression" bits added here in that
series, so I went ahead and defined the CHECK_VALID_EXPR macro in its
own header -- common/valid-expr.h.  I think that's nicer regardless.

I was borderline between calling the new types "offset" types, or
"index" types, BTW.  I stuck with "offset" simply because that's what
we're already calling them, mostly.

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

* Makefile.in (SUBDIR_UNITTESTS_SRCS): Add
unittests/offset-type-selftests.c.
(SUBDIR_UNITTESTS_OBS): Add offset-type-selftests.o.
* common/offset-type.h: New file.
* common/preprocessor.h: New file.
* common/traits.h: New file.
* common/valid-expr.h: New file.
* dwarf2expr.c: Include "common/underlying.h".  Adjust to use
sect_offset and cu_offset strong typedefs throughout.
* dwarf2expr.h: Adjust to use sect_offset and cu_offset strong
typedefs throughout.
* dwarf2loc.c: Include "common/underlying.h".  Adjust to use
sect_offset and cu_offset strong typedefs throughout.
* dwarf2read.c: Adjust to use sect_offset and cu_offset strong
typedefs throughout.
* gdbtypes.h: Include "common/offset-type.h".
(cu_offset): Now an offset type (strong typedef) instead of a
struct.
(sect_offset): Likewise.
(union call_site_parameter_u): Rename "param_offset" field to
"param_cu_off".
* unittests/offset-type-selftests.c: New file.

7 years agodwarf2read.c: Make dir_index and file_name_index strong typedefs
Pedro Alves [Tue, 4 Apr 2017 19:03:25 +0000 (20:03 +0100)] 
dwarf2read.c: Make dir_index and file_name_index strong typedefs

This should help catch mistakes related to mixing the 1-based DWARF
indexes with 0-based std::vector indexes, since the new types do not
implicitly convert to anything.

The change in read_formatted_entries relates to the fact that doing
the seemingly simpler:

 -       uintp = &fe.dir_index;
 +       uintp = (unsigned int *) &fe.dir_index;

would be undefined C/C++.  So to address that, I made the function
extract the form before assigning to the file_entry.  It felt natural
to use gdb::optional for "do I have this value", and this is what
motivated the previous patch that added the missing observer methods
to gdb::optional.

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

* common/underlying.h: New file.
* dwarf2read.c: Include "common/gdb_optional.h" and
"common/underlying.h".
(dir_index, file_name_index): New types.
(file_entry): Use them.
(file_entry::include): Use to_underlying.
(line_header::add_file_name): Use dir_index.
(read_formatted_entries): Use gdb::optional.  Read form before
writting to file_entry.
(dwarf_decode_line_header): Use dir_index.
(lnp_state_machine::current_file): Use to_underlying.
(lnp_state_machine::file): Change type to file_name_index.
(dwarf_record_line): Use to_underlying.
(init_lnp_state_machine): Use file_name_index.
(dwarf_decode_lines_1): Use dir_index and file_name_index.

7 years agogdb::optional: Add observers
Pedro Alves [Tue, 4 Apr 2017 19:03:25 +0000 (20:03 +0100)] 
gdb::optional: Add observers

Currently, gdb::optional is really minimal and can only be used for
lazy initialization.  There's no way to get at the value contained
inside the optinal.  This commit corrects that, by adding observer
methods, mostly copied from libstdc++'s implementation of C++17
std::optional.

This will be used in the following patch.

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

* common/gdb_optional.h (gdb::optiona): Add operator->, operator*,
operator bool, has_value and get methods.

7 years agodwarf2read.c: Some C++fycation, use std::vector, std::unique_ptr
Pedro Alves [Tue, 4 Apr 2017 19:03:25 +0000 (20:03 +0100)] 
dwarf2read.c: Some C++fycation, use std::vector, std::unique_ptr

This starts off as replacing a couple custom open coded vector
implementations in the file with std::vector, and then the rest falls
off of that.  I.e., use new/delete instead of XCNEW/xfree, add
ctors/dtors/initializers where appropriate.  And then use
std::unique_ptr instead of cleanups.  Some functions became methods,
and in a couple spots, some single-use callback functions that would
have to be tweaked anyway are converted to lambdas instead.

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

* dwarf2read.c (struct file_entry): Add ctors, and initialize all
fields.
(line_header): Initialize all data fields.  Change type of
standard_opcode_lengths to std::unique_ptr<unsigned char[]>.
Change type of include_dirs to std::vector<const char *>.  Remove
num_include_dirs, include_dirs_size.  Change type of file_names to
std::vector<file_entry>.  Remove num_file_names, file_names_size.
(line_header::line_header): New.
(line_header::add_include_dir, line_header::add_file_name): New
methods.
(line_header::include_dir_at): Remove NULL check.
(line_header::file_name_at): Add const overload.
(line_header_up): New unique_ptr typedef.
(dw2_get_file_names_reader): Use line_header_up.  Adjust to use
std::vector.  Remove free_line_header call.
(dwarf2_build_include_psymtabs): Use line_header_up.  Remove
free_line_header call.
(free_cu_line_header): Delete.
(handle_DW_AT_stmt_list, handle_DW_AT_stmt_list)
(setup_type_unit_groups): Use line_header_up instead of cleanups.
Adjust to use std::vector.
(free_line_header): Delete.
(free_line_header_voidp): Use delete.
(add_include_dir): Replace with ...
(line_header::add_include_dir): ... this method.  Use std::vector.
(add_file_name): Replace with ...
(line_header::add_file_name): ... this method.  Use std::vector.
(add_include_dir_stub): Delete.
(read_formatted_entries): Remove memset.
(dwarf_decode_line_header): Return a line_header_up instead of a
raw pointer.  Remove cleanup handling.  Pass lambdas to
read_formatted_entries.  Adjust to use line_header methods.
(dwarf_decode_lines_1): Adjust to use line_header methods.
(dwarf_decode_lines, file_file_name, file_full_name): Adjust to
use std::vector.

7 years agoUse symbolic constants instead of magic numbers with add_data_entry()
Jon Turney [Thu, 2 Jun 2016 13:46:58 +0000 (13:46 +0000)] 
Use symbolic constants instead of magic numbers with add_data_entry()

Use symbolic constants from include/coff/internal.h instead of magic numbers
with add_data_entry()

bfd/ChangeLog:

2017-04-02  Jon Turney  <jon.turney@dronecode.org.uk>

(_bfd_XXi_swap_aouthdr_out): For clarity, use defines rather than
numbers for DataDirectory entry indicies passed to
add_data_entry().

7 years agoSupport ELF SHF_GNU_MBIND and PT_GNU_MBIND_XXX
H.J. Lu [Tue, 4 Apr 2017 16:05:48 +0000 (09:05 -0700)] 
Support ELF SHF_GNU_MBIND and PT_GNU_MBIND_XXX

Mark an ALLOC section, which should be placed in special memory area,
with SHF_GNU_MBIND.  Its sh_info field indicates the special memory
type.  GNU_MBIND section names start with ".mbind" so that they are
placed as orphan sections by linker.  All input GNU_MBIND sections
with the same sh_type, sh_flags and sh_info are placed in one output
GNU_MBIND section.  In executable and shared object, create a
GNU_MBIND segment for each GNU_MBIND section and its segment type is
PT_GNU_MBIND_LO plus the sh_info value.  Each GNU_MBIND segment is
aligned at page boundary.

The assembler syntax:

    .section .mbind.foo,"adx",%progbits
                          ^             0: Special memory type.
                          |
                         'd' for SHF_GNU_MBIND.

    .section .mbind.foo,"adx",%progbits,0x1
                          ^             1: Special memory type.
                          |
                         'd' for SHF_GNU_MBIND.

    .section .mbind.bar,"adG",%progbits,.foo_group,comdat,0x2
                          ^                               2: Special memory type.
                          |
                         'd' for SHF_GNU_MBIND.

bfd/

* elf.c (get_program_header_size): Add a GNU_MBIND segment for
each GNU_MBIND section and align GNU_MBIND section to page size.
(_bfd_elf_map_sections_to_segments): Create a GNU_MBIND
segment for each GNU_MBIND section.
(_bfd_elf_init_private_section_data): Copy sh_info from input
for GNU_MBIND section.

binutils/

* NEWS: Mention support for ELF SHF_GNU_MBIND and
PT_GNU_MBIND_XXX.
* readelf.c (get_segment_type): Handle PT_GNU_MBIND_XXX.
(get_elf_section_flags): Handle SHF_GNU_MBIND.
(process_section_headers): Likewise.
* testsuite/binutils-all/mbind1.s: New file.
* testsuite/binutils-all/objcopy.exp: Run readelf test on
mbind1.s.

gas/

* NEWS: Mention support for ELF SHF_GNU_MBIND.
* config/obj-elf.c (section_match): New.
(get_section): Match both sh_info and group name.
(obj_elf_change_section): Add argument for sh_info.  Pass both
sh_info and group name to get_section. Issue an error for
SHF_GNU_MBIND section without SHF_ALLOC.  Set sh_info.
(obj_elf_parse_section_letters): Set SHF_GNU_MBIND for 'd'.
(obj_elf_section): Support SHF_GNU_MBIND section info.
* config/obj-elf.h (obj_elf_change_section): Add argument for
sh_info.
* config/tc-arm.c (start_unwind_section): Pass 0 as sh_info to
obj_elf_change_section.
* config/tc-ia64.c (obj_elf_vms_common): Likewise.
* config/tc-microblaze.c (microblaze_s_data): Likewise.
(microblaze_s_sdata): Likewise.
(microblaze_s_rdata): Likewise.
(microblaze_s_bss): Likewise.
* config/tc-mips.c (s_change_section): Likewise.
* config/tc-msp430.c (msp430_profiler): Likewise.
* config/tc-rx.c (parse_rx_section): Likewise.
* config/tc-tic6x.c (tic6x_start_unwind_section): Likewise.
* doc/as.texinfo: Document 'd' for SHF_GNU_MBIND.
* testsuite/gas/elf/elf.exp: Run section12a, section12b and
section13.
* testsuite/gas/elf/section10.d: Updated.
* testsuite/gas/elf/section10.s: Likewise.
* testsuite/gas/elf/section12.s: New file.
* testsuite/gas/elf/section12a.d: Likewise.
* testsuite/gas/elf/section12b.d: Likewise.
* testsuite/gas/elf/section13.l: Likewise.
* testsuite/gas/elf/section13.d: Likewise.
* testsuite/gas/elf/section13.s: Likewise.

include/

* elf/common.h (PT_GNU_MBIND_NUM): New.
(PT_GNU_MBIND_LO): Likewise.
(PT_GNU_MBIND_HI): Likewise.
(SHF_GNU_MBIND): Likewise.

ld/

* NEWS: Mention support for ELF SHF_GNU_MBIND and
PT_GNU_MBIND_XXX.
* emultempl/elf32.em (gld${EMULATION_NAME}_place_orphan): Place
input GNU_MBIND sections with the same type, attributes and
sh_info field into a single output GNU_MBIND section.
* testsuite/ld-elf/elf.exp: Run mbind2a and mbind2b.
* testsuite/ld-elf/mbind1.s: New file.
* testsuite/ld-elf/mbind1a.d: Likewise.
* testsuite/ld-elf/mbind1b.d: Likewise.
* testsuite/ld-elf/mbind1c.d: Likewise.
* testsuite/ld-elf/mbind2a.s: Likewise.
* testsuite/ld-elf/mbind2b.c: Likewise.

7 years agoRISC-V: Resurrect GP-relative disassembly hints
Palmer Dabbelt [Mon, 3 Apr 2017 17:08:29 +0000 (10:08 -0700)] 
RISC-V: Resurrect GP-relative disassembly hints

We missed a "_gp" when changing the GP symbol.  To make sure that
doesn't happen again, we now use the same definition everywhere (thanks,
Nick).

include/ChangeLog:

2017-04-03  Palmer Dabbelt  <palmer@dabbelt.com>

        * elf/riscv.h (RISCV_GP_SYMBOL): New define.

bfd/ChangeLog:

2017-04-03  Palmer Dabbelt  <palmer@dabbelt.com>

        * elfnn-riscv.c (GP_NAME): Delete.
        (riscv_global_pointer_value): Change GP_NAME to RISCV_GP_SYMBOL.
        (_bfd_riscv_relax_lui): Likewise.

opcodes/ChangeLog:

2017-04-03  Palmer Dabbelt  <palmer@dabbelt.com>

        * riscv-dis.c (riscv_disassemble_insn): Change "_gp" to
        RISCV_GP_SYMBOL.

7 years agogdbserver: Clear .deps on clean
Simon Marchi [Tue, 4 Apr 2017 14:48:24 +0000 (10:48 -0400)] 
gdbserver: Clear .deps on clean

In some situations, the dependency tracking files in .deps can refer to
source files that were removed or renamed, leading to errors like:

  make: *** No rule to make target `version.c', needed by `version.o'. Stop.

This patch makes the clean target clear the .deps directory, which gives
the user a chance to recover from the error wihtout knowing about the
internals of the build system.

It is already done for GDB.  See here for more details:

  https://sourceware.org/ml/gdb-patches/2009-03/msg00000.html

gdb/gdbserver/ChangeLog:

* Makefile.in (clean): Clear .deps.

7 years agoremote.c: Use ptid_t instead of struct ptid
Simon Marchi [Tue, 4 Apr 2017 14:31:50 +0000 (10:31 -0400)] 
remote.c: Use ptid_t instead of struct ptid

It's the only place in the codebase that uses "struct ptid", so change
it to ptid_t for consistency.

gdb/ChangeLog:

* remote.c (set_general_thread, set_continue_thread): Use ptid_t
instead of struct ptid.

7 years agoFix null pointer dereferences when using a link built with clang.
Nick Clifton [Tue, 4 Apr 2017 10:23:36 +0000 (11:23 +0100)] 
Fix null pointer dereferences when using a link built with clang.

PR binutils/21342
* elflink.c (_bfd_elf_define_linkage_sym): Prevent null pointer
dereference.
(bfd_elf_final_link): Only initialize the extended symbol index
section if there are extended symbol tables to list.

7 years agoRemove MAX_REGISTER_SIZE from frame.c
Alan Hayward [Tue, 4 Apr 2017 07:42:30 +0000 (08:42 +0100)] 
Remove MAX_REGISTER_SIZE from frame.c

gdb/
* frame.c (get_frame_register_bytes): Unwind using value.
(put_frame_register_bytes): Likewise.

7 years agoAutomatic date update in version.in
GDB Administrator [Tue, 4 Apr 2017 00:00:42 +0000 (00:00 +0000)] 
Automatic date update in version.in

7 years agoRISC-V: Avoid a const warning
Palmer Dabbelt [Mon, 3 Apr 2017 16:03:57 +0000 (09:03 -0700)] 
RISC-V: Avoid a const warning

2017-04-03  Palmer Dabbelt  <palmer@dabbelt.com>

       * config/tc-riscv.c (riscv_clear_subsets): Cast argument to free to
       avoid const warnings.

7 years ago IA16 support
Andrew Jenner [Mon, 3 Apr 2017 16:13:19 +0000 (09:13 -0700)] 
IA16 support

       * config.sub: Handle ia16 in $basic_machine.

       bfd/
       * config.bfd: Handle ia16.

       gas/
       * configure.tgt: Handle ia16.

       ld/
       * configure.tgt: Handle ia16.

7 years agoCorrect the ChangeLog entry
H.J. Lu [Mon, 3 Apr 2017 15:25:36 +0000 (08:25 -0700)] 
Correct the ChangeLog entry

7 years agold: Support ELF GNU program properties
H.J. Lu [Mon, 3 Apr 2017 15:03:14 +0000 (08:03 -0700)] 
ld: Support ELF GNU program properties

From .note.gnu.property section in each ELF input, we build a list of
GNU properties if .note.gnu.property section isn't corrupt.  The unknown
properties are ignored.  All property lists in relocatable inputs are
merged into an output property list.  When -z stack-size=N is used and
N isn't 0, the GNU_PROPERTY_STACK_SIZE property will be merged with or
added to the output property list.  .note.gnu.property section is
generated in output from the output property list.

bfd/

* Makefile.am (BFD32_BACKENDS): Add elf-properties.lo.
(BFD32_BACKENDS_CFILES): Add elf-properties.c.
* configure.ac (elf): Add elf-properties.lo.
* Makefile.in: Regenerated.
* configure: Likewise.
* elf-bfd.h (elf_property_kind): New.
(elf_property): Likewise.
(elf_property_list): Likewise.
(elf_properties): Likewise.
(_bfd_elf_parse_gnu_properties): Likewise.
(_bfd_elf_get_property): Likewise.
(_bfd_elf_link_setup_gnu_properties): Likewise.
(elf_backend_data): Add parse_gnu_properties, merge_gnu_properties
and setup_gnu_properties.
(elf_obj_tdata): Add properties.
* elf-properties.c: New file.
* elf32-i386.c (elf_i386_parse_gnu_properties): New.
(elf_i386_merge_gnu_properties): Likewise.
(elf_backend_parse_gnu_properties): Likewise.
(elf_backend_merge_gnu_properties): Likewise.
* elf64-x86-64.c (elf_x86_64_parse_gnu_properties): Likewise.
(elf_x86_64_merge_gnu_properties): Likewise.
(elf_backend_parse_gnu_properties): Likewise.
(elf_backend_merge_gnu_properties): Likewise.
* elfxx-target.h (elf_backend_merge_gnu_properties): Likewise.
(elf_backend_parse_gnu_properties): Likewise.
(elf_backend_setup_gnu_properties): Likewise.
(elfNN_bed): Add elf_backend_parse_gnu_properties,
elf_backend_merge_gnu_properties and
elf_backend_setup_gnu_properties.

ld/

* ld/NEWS: Mention support for ELF GNU program properties.
* emultempl/elf32.em (gld${EMULATION_NAME}_after_open): Call
ELF setup_gnu_properties.
* testsuite/ld-i386/i386.exp: Run property tests for Linux/i386.
* testsuite/ld-i386/pass.c: New file.
* testsuite/ld-i386/property-1.r: Likewise.
* testsuite/ld-i386/property-2.r: Likewise.
* testsuite/ld-i386/property-3.r: Likewise.
* testsuite/ld-i386/property-4.r: Likewise.
* testsuite/ld-i386/property-5.r: Likewise.
* testsuite/ld-i386/property-6.r: Likewise.
* testsuite/ld-i386/property-6a.c: Likewise.
* testsuite/ld-i386/property-6b.c: Likewise.
* testsuite/ld-i386/property-6c.S: Likewise.
* testsuite/ld-i386/property-7.r: Likewise.
* testsuite/ld-i386/property-no-copy.S: Likewise.
* testsuite/ld-i386/property-stack.S: Likewise.
* testsuite/ld-i386/property-unsorted-1.S: Likewise.
* testsuite/ld-i386/property-unsorted-2.S: Likewise.
* testsuite/ld-i386/property-x86-1.S: Likewise.
* testsuite/ld-i386/property-x86-2.S: Likewise.
* testsuite/ld-x86-64/pass.c: Likewise.
* testsuite/ld-x86-64/property-1.r: Likewise.
* testsuite/ld-x86-64/property-2.r: Likewise.
* testsuite/ld-x86-64/property-3.r: Likewise.
* testsuite/ld-x86-64/property-4.r: Likewise.
* testsuite/ld-x86-64/property-5.r: Likewise.
* testsuite/ld-x86-64/property-6.r: Likewise.
* testsuite/ld-x86-64/property-6a.c: Likewise.
* testsuite/ld-x86-64/property-6b.c: Likewise.
* testsuite/ld-x86-64/property-6c.S: Likewise.
* testsuite/ld-x86-64/property-7.r: Likewise.
* testsuite/ld-x86-64/property-no-copy.S: Likewise.
* testsuite/ld-x86-64/property-stack.S: Likewise.
* testsuite/ld-x86-64/property-unsorted-1.S: Likewise.
* testsuite/ld-x86-64/property-unsorted-2.S: Likewise.
* testsuite/ld-x86-64/property-x86-1.S: Likewise.
* testsuite/ld-x86-64/property-x86-2.S: Likewise.
* testsuite/ld-x86-64/x86-64.exp: Run property tests for
Linux/x86-64.

7 years agoreadelf: Fix overlarge memory allocation when reading a binary with an excessive...
Nick Clifton [Mon, 3 Apr 2017 11:14:06 +0000 (12:14 +0100)] 
readelf: Fix overlarge memory allocation when reading a binary with an excessive number of program headers.

PR binutils/21345
* readelf.c (get_program_headers): Check for there being too many
program headers before attempting to allocate space for them.

7 years agoFix runtime seg-fault in readelf when parsing a corrupt MIPS binary.
Nick Clifton [Mon, 3 Apr 2017 10:13:21 +0000 (11:13 +0100)] 
Fix runtime seg-fault in readelf when parsing a corrupt MIPS binary.

PR binutils/21344
* readelf.c (process_mips_specific): Check for an out of range GOT
entry before reading the module pointer.

7 years agoreadelf: Update check for invalid word offsets in ARM unwind information.
Nick Clifton [Mon, 3 Apr 2017 10:01:45 +0000 (11:01 +0100)] 
readelf: Update check for invalid word offsets in ARM unwind information.

PR binutils/21343
* readelf.c (get_unwind_section_word): Fix snafu checking for
invalid word offsets in ARM unwind information.

7 years agoAutomatic date update in version.in
GDB Administrator [Mon, 3 Apr 2017 00:00:37 +0000 (00:00 +0000)] 
Automatic date update in version.in

7 years agoAutomatic date update in version.in
GDB Administrator [Sun, 2 Apr 2017 00:00:36 +0000 (00:00 +0000)] 
Automatic date update in version.in

7 years agoAutomatic date update in version.in
GDB Administrator [Sat, 1 Apr 2017 00:00:39 +0000 (00:00 +0000)] 
Automatic date update in version.in

7 years agoRISC-V: Allow ISA subsets to be disabled
Palmer Dabbelt [Wed, 29 Mar 2017 23:05:40 +0000 (16:05 -0700)] 
RISC-V: Allow ISA subsets to be disabled

Without this patch, passing "-march=rv64ic -march=rv64i" results in
you getting a "RV64IC" toolchain, which isn't expected.

gas/ChangeLog:

2017-03-30  Palmer Dabbelt  <palmer@dabbelt.com>

       * config/tc-riscv.c (riscv_clear_subsets): New function.
       (riscv_add_subset): Call riscv_clear_subsets and riscv_set_rvc to
       clear RVC when it's been previously set.

7 years agoRISC-V: Add physical memory protection CSRs
Andrew Waterman [Wed, 22 Mar 2017 09:09:56 +0000 (02:09 -0700)] 
RISC-V: Add physical memory protection CSRs

2017-03-27  Andrew Waterman  <andrew@sifive.com>

       * opcode/riscv-opc.h (CSR_PMPCFG0): New define.
       (CSR_PMPCFG1): Likewise.
       (CSR_PMPCFG2): Likewise.
       (CSR_PMPCFG3): Likewise.
       (CSR_PMPADDR0): Likewise.
       (CSR_PMPADDR1): Likewise.
       (CSR_PMPADDR2): Likewise.
       (CSR_PMPADDR3): Likewise.
       (CSR_PMPADDR4): Likewise.
       (CSR_PMPADDR5): Likewise.
       (CSR_PMPADDR6): Likewise.
       (CSR_PMPADDR7): Likewise.
       (CSR_PMPADDR8): Likewise.
       (CSR_PMPADDR9): Likewise.
       (CSR_PMPADDR10): Likewise.
       (CSR_PMPADDR11): Likewise.
       (CSR_PMPADDR12): Likewise.
       (CSR_PMPADDR13): Likewise.
       (CSR_PMPADDR14): Likewise.
       (CSR_PMPADDR15): Likewise.
       (pmpcfg0): Declare register.
       (pmpcfg1): Likewise.
       (pmpcfg2): Likewise.
       (pmpcfg3): Likewise.
       (pmpaddr0): Likewise.
       (pmpaddr1): Likewise.
       (pmpaddr2): Likewise.
       (pmpaddr3): Likewise.
       (pmpaddr4): Likewise.
       (pmpaddr5): Likewise.
       (pmpaddr6): Likewise.
       (pmpaddr7): Likewise.
       (pmpaddr8): Likewise.
       (pmpaddr9): Likewise.
       (pmpaddr10): Likewise.
       (pmpaddr11): Likewise.
       (pmpaddr12): Likewise.
       (pmpaddr13): Likewise.
       (pmpaddr14): Likewise.
       (pmpaddr15): Likewise.

7 years agogdbserver: Suffix generated C files with -generated
Simon Marchi [Fri, 31 Mar 2017 15:19:44 +0000 (11:19 -0400)] 
gdbserver: Suffix generated C files with -generated

I noticed that there were some missing files in gdbserver's gitignore
(some generated register format .c files).  Of course the easy fix would
be to add those files to .gitignore, but I think we can do a better job,
so that we don't have to worry about adding generated files to
.gitignore or the clean Makefile target.

I suggest naming all generated source files -generated.c.  This way, we
can use a single rule in .gitignore and do a "rm -f *-generated.c" to
clean them up.

New in v2:

  - Don't rename version.o and xml-builtin.o

gdb/gdbserver/ChangeLog:

* .gitignore: Remove generated files, replace with wildcard.
* (clean): Replace removal of generated files with wildcard.
(version.c): Replace with...
(version-generated.c): ...this.
(xml-builtin.c): Replace with...
(xml-builtin-generated.c): ...this.
(%-ipa.o: %-generated.c, %.o: %-generated.c): New rules.
(%.c: *regformats*): Replace with...
(%-generated.c: *regformats*): ...this.

7 years agoFix minor problems with previous wasm32 binutils commit.
Pip Cet [Fri, 31 Mar 2017 12:07:01 +0000 (13:07 +0100)] 
Fix minor problems with previous wasm32 binutils commit.

binutils * NEWS: Use "WebAssembly" consistently.
* testsuite/binutils-all/wasm32/wasm32.exp: Fix copyright notice.

7 years agoReduce the size of s390 symbol tables by allowing relocations in mergeable string...
Nick Clifton [Fri, 31 Mar 2017 11:54:38 +0000 (12:54 +0100)] 
Reduce the size of s390 symbol tables by allowing relocations in mergeable string sections (eg .debug_str) to be made section relative rather than symbol relative.

PR gas/21333
* config/tc-s390.c (tc_s390_fix_adjustable): Allow non pc-relative
fixups in mergeable sections to be adjusted.

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

7 years agoAdd support for the WebAssembly file format and the wasm32 ELF conversion to gas...
Pip Cet [Thu, 30 Mar 2017 09:57:21 +0000 (10:57 +0100)] 
Add support for the WebAssembly file format and the wasm32 ELF conversion to gas and the binutils.

binutils * readelf.c: Add support for wasm32 ELF format WebAssembly files.
(guess_is_rela): Likewise.
(dump_relocations): Likewise.
(is_32bit_abs_reloc): Likewise.
(is_none_reloc_): Likewise.
* NEWS: Mention the new support.
* testsuite/lib/binutils-common.exp (is_elf_format): Mark wasm32
as ELF target.
(supports_gnu_unique): Mark wasm32 as supporting STB_GNU_UNIQUE.
* testsuite/binutils-all/nm.exp: Mark wasm32 as requiring .size annotations.
* testsuite/binutils-all/wasm32: New directory.
* testsuite/binutils-all/wasm32/create-wasm.d: New file.
* testsuite/binutils-all/wasm32/create-wasm.s: Likewise.
* testsuite/binutils-all/wasm32/custom-section.d: Likewise.
* testsuite/binutils-all/wasm32/custom-section.s: Likewise.
* testsuite/binutils-all/wasm32/invalid-wasm-1.d: Likewise.
* testsuite/binutils-all/wasm32/invalid-wasm-1.s: Likewise.
* testsuite/binutils-all/wasm32/long-sections.d: Likewise.
* testsuite/binutils-all/wasm32/long-sections.s: Likewise.
* testsuite/binutils-all/wasm32/parse-wasm.d: Likewise.
* testsuite/binutils-all/wasm32/parse-wasm.s: Likewise.
* testsuite/binutils-all/wasm32/parse-wasm-2.d: Likewise.
* testsuite/binutils-all/wasm32/parse-wasm-2.s: Likewise.
* testsuite/binutils-all/wasm32/prepared-section.d: Likewise.
* testsuite/binutils-all/wasm32/prepared-section.s: Likewise.
* testsuite/binutils-all/wasm32/wasm32.exp: New file, run tests.

gas * config/tc-wasm32.h: New file: Add WebAssembly assembler target.
* config/tc-wasm32.c: New file: Add WebAssembly assembler target.
* Makefile.am: Add WebAssembly assembler target.
* configure.tgt: Add WebAssembly assembler target.
* doc/c-wasm32.texi: New file: Start documenting WebAssembly
assembler.
* doc/all.texi: Define WASM32.
* doc/as.texinfo: Add WebAssembly entries.
* NEWS: Mention the new support.
* Makefile.in: Regenerate.
* po/gas.pot: Regenerate.
* po/POTFILES.in: Regenerate.
* testsuite/gas/wasm32: New directory.
* testsuite/gas/wasm32/allinsn.d: New file.
* testsuite/gas/wasm32/allinsn.s: New file.
* testsuite/gas/wasm32/illegal.l: New file.
* testsuite/gas/wasm32/illegal.s: New file.
* testsuite/gas/wasm32/illegal-2.l: New file.
* testsuite/gas/wasm32/illegal-2.s: New file.
* testsuite/gas/wasm32/illegal-3.l: New file.
* testsuite/gas/wasm32/illegal-3.s: New file.
* testsuite/gas/wasm32/illegal-4.l: New file.
* testsuite/gas/wasm32/illegal-4.s: New file.
* testsuite/gas/wasm32/illegal-5.l: New file.
* testsuite/gas/wasm32/illegal-5.s: New file.
* testsuite/gas/wasm32/illegal-6.l: New file.
* testsuite/gas/wasm32/illegal-6.s: New file.
* testsuite/gas/wasm32/illegal-7.l: New file.
* testsuite/gas/wasm32/illegal-7.s: New file.
* testsuite/gas/wasm32/illegal-8.l: New file.
* testsuite/gas/wasm32/illegal-8.s: New file.
* testsuite/gas/wasm32/illegal-9.l: New file.
* testsuite/gas/wasm32/illegal-9.s: New file.
* testsuite/gas/wasm32/illegal-10.l: New file.
* testsuite/gas/wasm32/illegal-10.s: New file.
* testsuite/gas/wasm32/illegal-11.l: New file.
* testsuite/gas/wasm32/illegal-11.s: New file.
* testsuite/gas/wasm32/illegal-12.l: New file.
* testsuite/gas/wasm32/illegal-12.s: New file.
* testsuite/gas/wasm32/illegal-13.l: New file.
* testsuite/gas/wasm32/illegal-13.s: New file.
* testsuite/gas/wasm32/illegal-14.l: New file.
* testsuite/gas/wasm32/illegal-14.s: New file.
* testsuite/gas/wasm32/illegal-15.l: New file.
* testsuite/gas/wasm32/illegal-15.s: New file.
* testsuite/gas/wasm32/illegal-16.l: New file.
* testsuite/gas/wasm32/illegal-16.s: New file.
* testsuite/gas/wasm32/illegal-17.l: New file.
* testsuite/gas/wasm32/illegal-17.s: New file.
* testsuite/gas/wasm32/illegal-18.l: New file.
* testsuite/gas/wasm32/illegal-18.s: New file.
* testsuite/gas/wasm32/illegal-19.l: New file.
* testsuite/gas/wasm32/illegal-19.s: New file.
* testsuite/gas/wasm32/illegal-20.l: New file.
* testsuite/gas/wasm32/illegal-20.s: New file.
* testsuite/gas/wasm32/illegal-21.l: New file.
* testsuite/gas/wasm32/illegal-21.s: New file.
* testsuite/gas/wasm32/illegal-22.l: New file.
* testsuite/gas/wasm32/illegal-22.s: New file.
* testsuite/gas/wasm32/illegal-24.l: New file.
* testsuite/gas/wasm32/illegal-24.s: New file.
* testsuite/gas/wasm32/illegal-25.l: New file.
* testsuite/gas/wasm32/illegal-25.s: New file.
* testsuite/gas/wasm32/reloc.d: New file.
* testsuite/gas/wasm32/reloc.s: New file.
* testsuite/gas/wasm32/wasm32.exp: New tests for WebAssembly
architecture.

opcodes * configure.ac: Add (empty) bfd_wasm32_arch target.
* configure: Regenerate
* po/opcodes.pot: Regenerate.

include * opcode/wasm.h: New file to support wasm32 architecture.
* elf/wasm32.h: Add R_WASM32_32 relocation.

bfd * elf32-wasm32.c: Add relocation code, two relocs.
* reloc.c: Add wasm32 relocations.
* libbfd.h: Regenerate.
* bfd-in2.h: Regenerate.
* bfd/po/bfd.pot: Regenerate.

7 years agoFix classification of `module.type' in D lexer.
Iain Buclaw [Thu, 30 Mar 2017 08:43:03 +0000 (10:43 +0200)] 
Fix classification of `module.type' in D lexer.

The two-tier lexer in gdb/d-exp.y, which resolves fully qualified names
missed a case where `module.type' was not being classified as one token.
And so when the grammar takes over, it matched the remaining tokens
against the rule `TypeExp . IdentifierExp', where we were expecting to
instead match cast expression `( TypeExp ) UnaryExpression'.

Adding a case for TYPE_CODE_MODULE in type_aggregate_p means that
classify_inner_name will get a chance to lookup the symbol.

This was noticed when using `watch -l', and got the rather confusing
response:

    A syntax error in expression, near `) 0x0add4e55'.

So it's been included in the testsuite, along with another test that
does effectively the same expression, but explicitly.

gdb/ChangeLog:

* d-exp.y (type_aggregate_p): Treat TYPE_CODE_MODULE as being
aggregate-like.

gdb/testsuite/ChangeLog:

* gdb.dlang/watch-loc.c: New file.
* gdb.dlang/watch-loc.exp: New file.

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

7 years agoFix warning: Invalid entry in .debug_gdb_scripts section
Jan Kratochvil [Wed, 29 Mar 2017 19:53:43 +0000 (21:53 +0200)] 
Fix warning: Invalid entry in .debug_gdb_scripts section

$ gdb rustc
Reading symbols from rustc...Reading symbols from /usr/lib/debug/usr/bin/rustc.debug...done.
done.
warning: Invalid entry in .debug_gdb_scripts section

/usr/bin/rustc
Section Headers:
  [Nr] Name              Type            Address          Off    Size   ES Flg Lk Inf Al
  [15] .debug_gdb_scripts PROGBITS        00000000000008ed 0008ed 000022 00 AMS  0   0  1

/usr/lib/debug/usr/bin/rustc.debug
Section Headers:
  [Nr] Name              Type            Address          Off    Size   ES Flg Lk Inf Al
  [15] .debug_gdb_scripts NOBITS          00000000000008ed 000280 000022 00 AMS  0   0  1

There remains questionable whether bfd_get_section_by_name() should not return
an error for !SEC_LOAD but I haven't investigated that.

gdb/ChangeLog
2017-03-29  Jan Kratochvil  <jan.kratochvil@redhat.com>

* auto-load.c (auto_load_section_scripts): Check SEC_HAS_CONTENTS.

gdb/testsuite/ChangeLog
2017-03-29  Jan Kratochvil  <jan.kratochvil@redhat.com>

* gdb.python/py-section-script.exp (sepdebug): New testcases.

7 years agoopcodes: sparc: support missing SPARC ASIs from UA2005, UA2007, OSA2011, & OSA2015
Jose E. Marchesi [Wed, 29 Mar 2017 19:20:23 +0000 (21:20 +0200)] 
opcodes: sparc: support missing SPARC ASIs from UA2005, UA2007, OSA2011, & OSA2015

7 years agoAdd constructor and destructor to thread_info
Yao Qi [Wed, 29 Mar 2017 15:56:31 +0000 (16:56 +0100)] 
Add constructor and destructor to thread_info

This patch adds constructor and destructor to thread_info.

gdb:

2017-03-29  Yao Qi  <yao.qi@linaro.org>

* gdbthread.h (struct thread_info): Declare constructor and
destructor.  Add some in-class member initializers.
* thread.c (free_thread): Remove.
(init_thread_list): Call delete instead of free_thread.
(new_thread): Call thread_info constructor.
(thread_info::thread_info): New function.
(thread_info::~thread_info): New function.
(delete_thread_1): Call delete instead of free_thread.
(make_cleanup_restore_current_thread): Move tp and frame to
inner block.

7 years agoPowerPC -Mraw disassembly
Alan Modra [Wed, 29 Mar 2017 03:13:06 +0000 (13:43 +1030)] 
PowerPC -Mraw disassembly

This adds -Mraw for PowerPC objdump, a disassembler option to display
the underlying machine instruction rather than aliases.  For example,
"rlwinm" always rather than "rotlwi" when the instruction is
performing a simple rotate.

binutils/
* doc/binutils.texi (objdump): Document PowerPC -M options.
gas/
* config/tc-ppc.c (md_parse_option): Reject -mraw.
include/
* opcode/ppc.h (PPC_OPCODE_RAW): Define.
(PPC_OPCODE_*): Make them all unsigned long long constants.
opcodes/
* ppc-dis.c (ppc_opts): Set PPC_OPCODE_PPC for "any" flags.  Add
"raw" option.
(lookup_powerpc): Don't special case -1 dialect.  Handle
PPC_OPCODE_RAW.
(print_insn_powerpc): Mask out PPC_OPCODE_ANY on first
lookup_powerpc call, pass it on second.

7 years agoImprove the speed of scanning PE binaries for line number information.
Nick Clifton [Wed, 29 Mar 2017 11:27:44 +0000 (12:27 +0100)] 
Improve the speed of scanning PE binaries for line number information.

PR binutils/18025
* coff-bfd.h (struct coff_section_data): Add new fields:
saved_bias and bias.
* coffgen.c (coff_find_nearest_line_with_names): Cache the bias
computed for PE binaries.
* dwarf2.c (scan_unit_for_symbols): Only warn once about each
missing abbrev.

7 years agoAutomatic date update in version.in
GDB Administrator [Wed, 29 Mar 2017 00:00:28 +0000 (00:00 +0000)] 
Automatic date update in version.in

7 years agoFix for PR ld/16044: elf32-cris.c h->plt.refcount inconsistency
Hans-Peter Nilsson [Tue, 28 Mar 2017 21:43:09 +0000 (23:43 +0200)] 
Fix for PR ld/16044: elf32-cris.c h->plt.refcount inconsistency

7 years agoarc: Add prologue analysis
Anton Kolesov [Fri, 10 Feb 2017 11:12:09 +0000 (14:12 +0300)] 
arc: Add prologue analysis

Add a prologue analysis that recognizes all instructions that may happen in
compiler-generated prologue, including various stores, core register moves,
subtraction and ENTER_S instruction that does a lot of prologue actions through
microcode.

Testcases cover various prologue scenarios, including instructions that are
spread across multiple 16-bit encodings (for example there are 7 encodings of
store instruction).

gdb/ChangeLog:

yyyy-mm-dd  Anton Kolesov  <anton.kolesov@synopsys.com>

* arc-tdep.c (arc_frame_cache): Add support for prologue analysis.
(arc_skip_prologue): Likewise.
(arc_make_frame_cache): Likewise.
(arc_pv_get_operand): New function.
(arc_is_in_prologue): Likewise.
(arc_analyze_prologue): Likewise.
(arc_print_frame_cache): Likewise.
(MAX_PROLOGUE_LENGTH): New constant.

gdb/doc/ChangeLog:

yyyy-mm-dd  Anton Kolesov  <anton.kolesov@synopsys.com>

* gdb.texinfo (Synopsys ARC): Document "set debug arc 2".

gdb/testsuite/ChangeLog:

yyyy-mm-dd  Anton Kolesov  <anton.kolesov@synopsys.com>

* gdb.arch/arc-analyze-prologue.S: New file.
* gdb.arch/arc-analyze-prologue.exp: Likewise.

7 years agoarc: Add disassembler helper
Anton Kolesov [Fri, 10 Feb 2017 11:12:06 +0000 (14:12 +0300)] 
arc: Add disassembler helper

Add disassembler helper for GDB, that uses opcodes structure arc_instruction
and adds convenience functions to handle instruction operands.  This interface
solves at least those problems with arc_instruction:

  * Some instructions, like "push_s", have implicit operands which are not
    directly present in arc_instruction.
  * Operands of particular meaning, like branch/jump targets, have various
    locations and meaning depending on type of branch/target.
  * Access to operand value is abstracted into a separate function, so callee
    code shouldn't bother if operand value is an immediate value or in a
    register.

Testcases included in this commit are fairly limited - they test exclusively
branch instructions, something that will be used in software single stepping.
Most of the other parts of this disassembler helper are tested during prologue
analysis testing.

gdb/ChangeLog:

yyyy-mm-dd  Anton Kolesov  <anton.kolesov@synopsys.com>

* configure.tgt: Add arc-insn.o.
* arc-tdep.c (arc_delayed_print_insn): Make non-static.
(dump_arc_instruction_command): New function.
(arc_fprintf_disasm): Likewise.
(arc_disassemble_info): Likewise.
(arc_insn_get_operand_value): Likewise.
(arc_insn_get_operand_value_signed): Likewise.
(arc_insn_get_memory_base_reg): Likewise.
(arc_insn_get_memory_offset): Likewise.
(arc_insn_get_branch_target): Likewise.
(arc_insn_dump): Likewise.
(arc_insn_get_linear_next_pc): Likewise.
* arc-tdep.h (arc_delayed_print_insn): Add function declaration.
(arc_disassemble_info): Likewise.
(arc_insn_get_branch_target): Likewise.
(arc_insn_get_linear_next_pc): Likewise.
* NEWS: Mention new "maint print arc arc-instruction".

gdb/doc/ChangeLog:

yyyy-mm-dd  Anton Kolesov  <anton.kolesov@synopsys.com>

* gdb.texinfo (Synopsys ARC): Add "maint print arc arc-instruction".

gdb/testsuite/ChangeLog:

yyyy-mm-dd  Anton Kolesov  <anton.kolesov@synopsys.com>

* gdb.arch/arc-decode-insn.S: New file.
* gdb.arch/arc-decode-insn.exp: Likewise.

7 years agoarc: Add "maintenance print arc" command prefix
Anton Kolesov [Fri, 10 Feb 2017 11:12:01 +0000 (14:12 +0300)] 
arc: Add "maintenance print arc" command prefix

Add an "arc" sublist to "maintenance print" command list.  The list is empty
for now, its purpose is to contain commands that print internal state of some
ARC-specific structures.

gdb/ChangeLog:

yyyy-mm-dd  Anton Kolesov  <anton.kolesov@synopsys.com>

* arc-tdep (maintenance_print_arc_list): New variable.
(maintenance_print_arc_command): New function.

7 years agoarc: Align internal regnums with architectural regnums
Anton Kolesov [Fri, 10 Feb 2017 11:11:46 +0000 (14:11 +0300)] 
arc: Align internal regnums with architectural regnums

Add ARC_LIMM_REGNUM to arc_regnum enumeration and assign a number 62 to it.
This ensures that for core registers internal register numbers in this enum are
the same as architectural numbers.  This allows to use internal register
numbers in the contexts where architectural number is implied, for example when
disassembling instruction during prologue analysis.

gdb/ChangeLog:

yyyy-mm-dd  Anton Kolesov  <anton.kolesov@synopsys.com>

* arc-tdep.c (core_v2_register_names, core_arcompact_register_names)
Add "limm" and "reserved".
(arc_cannot_fetch_register, arc_cannot_store_register): Add
ARC_RESERVED_REGNUM and ARC_LIMM_REGNUM.
* arc-tdep.h (arc_regnum): Likewise.

7 years agoAutomatic date update in version.in
GDB Administrator [Tue, 28 Mar 2017 00:00:37 +0000 (00:00 +0000)] 
Automatic date update in version.in

7 years agogdbserver: xtensa: support THREADPTR register
Max Filippov [Sat, 19 Nov 2016 00:08:48 +0000 (16:08 -0800)] 
gdbserver: xtensa: support THREADPTR register

Provide aceess to the THREADPTR register to remote gdb.

gdb/gdbserver/
2017-03-27  Max Filippov  <jcmvbkbc@gmail.com>

* linux-xtensa-low.c (regnum::R_THREADPTR): New enum member.
(xtensa_fill_gregset): Call collect_register_by_name for
threadptr register.
(xtensa_store_gregset): Call supply_register_by_name for
threadptr register.

7 years agogdb: xtensa-linux: support THREADPTR register
Max Filippov [Fri, 18 Nov 2016 19:39:47 +0000 (11:39 -0800)] 
gdb: xtensa-linux: support THREADPTR register

Make THREADPTR user register accessible.

gdb/
2017-03-27  Max Filippov  <jcmvbkbc@gmail.com>

* xtensa-linux-nat.c (fill_gregset): Call regcache_raw_collect
for THREADPTR register.
(supply_gregset_reg): Call regcache_raw_supply for THREADPTR
register.
* xtensa-tdep.c (XTENSA_DBREGN_UREG): New definition.
(xtensa_derive_tdep): Initialize tdep->threadptr_regnum.
* xtensa-tdep.h (gdbarch_tdep::threadptr_regnum): New field.

7 years agogdb: xtensa: fix test for privileged register number
Max Filippov [Tue, 21 Feb 2017 23:41:31 +0000 (15:41 -0800)] 
gdb: xtensa: fix test for privileged register number

There are no a0-a15 pseudoregisters at the top of the register set in
call0 registers layout. All registers above gdbarch_num_regs (gdbarch)
are privileged. Treat them as such. This fixes the following gdb
assertion seen when 'finish' command is invoked:

  regcache.c:649: internal-error: register_status
  regcache_raw_read(regcache*, int, gdb_byte*):
  Assertion `regnum >= 0 && regnum < regcache->descr->nr_raw_registers'
  failed.

gdb/
2017-03-27  Max Filippov  <jcmvbkbc@gmail.com>

* xtensa-tdep.c (xtensa_pseudo_register_read): Treat all
registers above gdbarch_num_regs (gdbarch) as privileged in
call0 ABI.

7 years agogdbserver: xtensa: add call0 support
Max Filippov [Fri, 18 Nov 2016 16:58:21 +0000 (08:58 -0800)] 
gdbserver: xtensa: add call0 support

Correctly handle a0- registers on requests from remote gdb. This fixes

  'Register 1 is not available'

and subsequent assertion in the remote gdb connecting to the gdbserver:

  'findvar.c:291: internal-error: value_of_register_lazy:
    Assertion `frame_id_p(get_frame_id (frame))' failed.'

The register structure is the same for windowed and call0 ABIs because
currently linux kernel internally requires windowed registers, so they
are always present.

gdb/gdbserver/
2017-03-27  Max Filippov  <jcmvbkbc@gmail.com>

* linux-xtensa-low.c (xtensa_fill_gregset): Call collect_register
for all registers in a0_regnum..a0_regnum + C0_NREGS range.
(xtensa_store_gregset): Call supply_register for all registers in
a0_regnum..a0_regnum + C0_NREGS range.

7 years agogdb: xtensa-linux: add call0 support
Max Filippov [Fri, 18 Nov 2016 17:48:01 +0000 (09:48 -0800)] 
gdb: xtensa-linux: add call0 support

Correctly handle a0- registers. This allows debugging call0 code in
linux natively.
The register structure is the same for windowed and call0 ABIs because
currently linux kernel internally requires windowed registers, so they are
always present.

gdb/
2017-03-27  Max Filippov  <jcmvbkbc@gmail.com>

* xtensa-linux-nat.c (fill_gregset): Call regcache_raw_collect
for a single specified register or for all registers in
a0_base..a0_base + C0_NREGS range.
(supply_gregset_reg): Call regcache_raw_supply for a single
specified register or for all registers in a0_base..a0_base +
C0_NREGS range.

7 years agogdb: gdbserver: xtensa: make C0_NREGS available
Max Filippov [Wed, 22 Feb 2017 01:14:37 +0000 (17:14 -0800)] 
gdb: gdbserver: xtensa: make C0_NREGS available

Both gdb and gdbserver need this definition to properly work with call0
ABI. Make it available to both.

gdb/
2017-03-27  Max Filippov  <jcmvbkbc@gmail.com>

* arch/xtensa.h (C0_NREGS): Add definition.
* xtensa-tdep.c (C0_NREGS): Remove definition.

7 years agogdb: xtensa: clean up xtensa_default_isa initialization
Max Filippov [Fri, 18 Nov 2016 17:39:41 +0000 (09:39 -0800)] 
gdb: xtensa: clean up xtensa_default_isa initialization

This fixes segfault in native gdb because isa is not initialized at the
point of call to xtensa_isa_maxlength.

gdb/
2017-03-27  Max Filippov  <jcmvbkbc@gmail.com>

* xtensa-tdep.c (xtensa_scan_prologue, call0_analyze_prologue):
Drop xtensa_default_isa initialization.
(xtensa_gdbarch_init): Initialize xtensa_default_isa.

7 years agodwarf2read.c: Clean up out of bounds handling
Pedro Alves [Mon, 27 Mar 2017 14:57:19 +0000 (15:57 +0100)] 
dwarf2read.c: Clean up out of bounds handling

Multiple places in dwarf2read.c open code 1-based to 0-based index
conversion and check for out of bounds accesses to lh->include_dirs
and lh->file_names.  This commit factors those out to a couple methods
and uses them throughout.

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

* dwarf2read.c (file_entry) <dir_index>: Add comment.
(file_entry::include_dir): New method.
(line_header::include_dir_at, line_header::file_name_at): New
methods.
(setup_type_unit_groups, setup_type_unit_groups)
(psymtab_include_file_name): Simplify using the new methods.
(lnp_state_machine) <the_line_header>: New field.
<file>: Add comment.
(lnp_state_machine::current_file): New method.
(dwarf_record_line): Simplify using the new methods.
(init_lnp_state_machine): Initialize the "the_line_header" field.
(dwarf_decode_lines_1, dwarf_decode_lines, file_file_name):
Simplify using the new methods.

7 years agogdb/cp-name-parser.y: Eliminate make_empty, use cplus_demangle_fill_component
Pedro Alves [Mon, 27 Mar 2017 12:56:49 +0000 (13:56 +0100)] 
gdb/cp-name-parser.y: Eliminate make_empty, use cplus_demangle_fill_component

The demangler exports the cplus_demangle_fill_component function that
clients should use to initialize demangle_component components that
use the "s_binary" union member.  cp-name-parser.y uses it in some
places, via the fill_comp wrapper, but not all.  Several places
instead use a GDB-specific "make_empty" function.  Because this
function does not call any of the demangler "fill" functions, we had
to patch it recently to clear the allocated demangle_component's
"d_printing" field, which is supposedly a "private" demangler field.
To avoid such problems in the future, this commit switches those
places to use "fill_comp" instead, and eliminates the "make_empty"
function.

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

* cp-name-parser.y (make_empty): Delete.
(demangler_special, nested_name, ptr_operator, array_indicator)
(direct_declarator, declarator_1): Use fill_comp instead of
make_empty.

7 years agocplus_demangle_fill_component: Handle DEMANGLE_COMPONENT_RVALUE_REFERENCE
Pedro Alves [Mon, 27 Mar 2017 12:56:49 +0000 (13:56 +0100)] 
cplus_demangle_fill_component: Handle DEMANGLE_COMPONENT_RVALUE_REFERENCE

This patch almost a decade ago:

...
    2007-08-31  Douglas Gregor  <doug.gregor@gmail.com>

        * cp-demangle.c (d_dump): Handle
        DEMANGLE_COMPONENT_RVALUE_REFERENCE.
        (d_make_comp): Ditto.
...

... missed doing the same change to cplus_demangle_fill_component that
was done to d_make_comp.  I.e., teach it to only validate that we're
not passing in a "right" subtree.  GDB has recently (finally) learned
about rvalue references, and a change to make it use
cplus_demangle_fill_component more ran into an assertion because of
this.

(GDB is the only user of cplus_demangle_fill_component in both the gcc
and binutils-gdb trees.)

libiberty/ChangeLog:
2017-03-27  Pedro Alves  <palves@redhat.com>

* cp-demint.c (cplus_demangle_fill_component): Handle
DEMANGLE_COMPONENT_RVALUE_REFERENCE.

7 years agoAdd support for the WebAssembly backend to the BFD library.
Pip Cet [Mon, 27 Mar 2017 12:41:39 +0000 (13:41 +0100)] 
Add support for the WebAssembly backend to the BFD library.

* wasm-module.c: New file to support WebAssembly modules.
* wasm-module.h: New file to support WebAssembly modules.
* doc/webassembly.texi: Start documenting wasm-module.c.
* config.bfd: Add wasm_vec.
* targets.c: Likewise.
* configure.ac: Likewise.
* Makefile.am: Add entries for wasm-module.c.
* Makefile.in: Regenerate.
* configure: Regenerate.
* po/SRC-POTFILES.in: Regenerate.

7 years agoFix gdb_xml_debug/gdb_xml_error ATTRIBUTE_PRINTF use
Pedro Alves [Mon, 27 Mar 2017 11:28:03 +0000 (12:28 +0100)] 
Fix gdb_xml_debug/gdb_xml_error ATTRIBUTE_PRINTF use

The declarations of gdb_xml_debug and gdb_xml_error are passing "0" as
"first-to-check" argument to ATTRIBUTE_PRINTF, as if they were va_args
functions.  Consequently, the arguments to gdb_xml_debug /
gdb_xml_error aren't being checked against the format strings.

With that fixed, a couple obvious bugs are exposed, both fixed by this
commit.

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

* xml-support.h (gdb_xml_debug): Pass a "first-to-check" argument
to ATTRIBUTE_PRINTF.
* solib-target.c (library_list_start_list): Print "string" not
"version".
* xml-tdesc.c (tdesc_start_field): Pass "field_name" to
gdb_xml_error call.

7 years agoPR21303, objdump doesn't show e200z4 insns
Alan Modra [Sun, 26 Mar 2017 21:49:48 +0000 (08:19 +1030)] 
PR21303, objdump doesn't show e200z4 insns

PR 21303
opcodes/
* ppc-dis.c (struct ppc_mopt): Comment.
(ppc_opts <e200z4>): Move PPC_OPCODE_VLE from .sticky to .cpu.
gas/
* testsuite/gas/ppc/pr21303.d,
* testsuite/gas/ppc/pr21303.s: New test
* testsuite/gas/ppc/ppc.exp: Run it.

7 years agogdb: Make ldirname return a std::string
Pedro Alves [Mon, 27 Mar 2017 10:56:28 +0000 (11:56 +0100)] 
gdb: Make ldirname return a std::string

Eliminates several uses of cleanups.

Tested on x86_64 Fedora 23 with Python 2 and 3.

gdb/ChangeLog
2017-03-27  Pedro Alves  <palves@redhat.com>

* dwarf2read.c (struct file_and_directory): New.
(dwarf2_get_dwz_file): Adjust to use std::string.
(dw2_get_file_names_reader): Adjust to use file_and_directory.
(find_file_and_directory): Adjust to return a file_and_directory
object.
(read_file_scope): Adjust to use file_and_directory.  Remove
make_cleanup/do_cleanups calls.
(open_and_init_dwp_file): Adjust to use std::string.  Remove
make_cleanup/do_cleanups calls.
* python/python.c (do_start_initialization): Adjust to ldirname
returning a std::string.
* utils.c (ldirname): Now returns a std::string.
* utils.h (ldirname): Change return type to std::string.
* xml-syscall.c (xml_init_syscalls_info): Adjust to ldirname
returning a std::string.
* xml-tdesc.c (file_read_description_xml): Likewise.

7 years agooops - forgot to add the bfd/ChangeLog entry...
Pip Cet [Mon, 27 Mar 2017 10:45:24 +0000 (11:45 +0100)] 
oops - forgot to add the bfd/ChangeLog entry...

7 years agoAdd minimal support for WebAssembly backend to the BFD library.
Pip Cet [Mon, 27 Mar 2017 10:39:50 +0000 (11:39 +0100)] 
Add minimal support for WebAssembly backend to the BFD library.

include * elf/wasm32.h: New file to support wasm32 architecture.

bfd * cpu-wasm32.c: New file to support wasm32 architecture.
    * elf32-wasm32.c: New file to support wasm32 architecture.
    * Makefile.am: Add wasm32 architecture.
    * archures.c: Likewise.
    * config.bfd: Likewise.
    * configure.ac: Likewise.
    * targets.c: Likewise.

7 years agoImplement ARC NPS-400 Ultra Ip and Miscellaneous instructions.
Rinat Zelig [Mon, 27 Mar 2017 10:14:30 +0000 (11:14 +0100)] 
Implement ARC NPS-400 Ultra Ip and Miscellaneous instructions.

opcodes * arc-nps400-tbl.h: Add Ultra Ip and Miscellaneous instructions format.
* arc-opc.c: Add defines. e.g. F_NJ, F_NM , F_NO_T, F_NPS_SR, F_NPS_M, F_NPS_CORE, F_NPS_ALL.
(insert_nps_misc_imm_offset): New function.
(extract_nps_misc imm_offset): New function.
(arc_num_flag_operands): Add F_NJ, F_NM, F_NO_T.
(arc_flag_special_cases): Add F_NJ, F_NM, F_NO_T.

include * opcode/arc.h (insn_class_t): Add ULTRAIP and MISC class.

gas     * testsuite/gas/arc/nps400-12.s: New file.
        * testsuite/gas/arc/nps400-12.d: New file.

7 years agoAutomatic date update in version.in
GDB Administrator [Mon, 27 Mar 2017 00:00:35 +0000 (00:00 +0000)] 
Automatic date update in version.in

7 years agoFix bug with cmn/adds where C flag was incorrectly set.
Jim Wilson [Sun, 26 Mar 2017 03:32:02 +0000 (20:32 -0700)] 
Fix bug with cmn/adds where C flag was incorrectly set.

sim/aarch64/
* simulator.c (set_flags_for_add32): Cast result to uint32_t in carry
flag check.

sim/testsuite/sim/aarch64/
* adds.s: Add checks for values -2 and 1, where C is not set.

7 years agoAutomatic date update in version.in
GDB Administrator [Sun, 26 Mar 2017 00:00:20 +0000 (00:00 +0000)] 
Automatic date update in version.in

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

7 years agoRemove MAX_REGISTER_SIZE from target.c
Alan Hayward [Fri, 24 Mar 2017 16:53:05 +0000 (16:53 +0000)] 
Remove MAX_REGISTER_SIZE from target.c

gdb/
* regcache.c (regcache_debug_print_register): New function.
* regcache.h (regcache_debug_print_register): New declaration.
* target.c (debug_print_register): Remove.
(target_fetch_registers): Call regcache_debug_print_register.
(target_store_registers): Likewise.

7 years agoAvoid segfault on invalid directory table
Pádraig Brady [Fri, 24 Mar 2017 15:12:53 +0000 (15:12 +0000)] 
Avoid segfault on invalid directory table

gdb was segfaulting during backtrace on a binary here, where
fe->dir_index parsed from the DWARF info was seen to access beyond the
provided include_dirs array.

This commit bounds the access to entries actually written to the
array, and was verified to output the backtrace correctly.

gdb/ChangeLog:

* dwarf2read.c (setup_type_unit_groups): Ensure dir_index doesn't
reference beyond the 'lh->include_dirs' array before accessing to
it.
(psymtab_include_file_name): Likewise.
(dwarf_decode_lines_1): Likewise.
(dwarf_decode_lines): Likewise.
(file_file_name): Likewise.

7 years ago[GAS/ARM] Fix selected_cpu with default CPU and -mcpu
Thomas Preud'homme [Fri, 24 Mar 2017 13:22:16 +0000 (13:22 +0000)] 
[GAS/ARM] Fix selected_cpu with default CPU and -mcpu

When GAS is compiled with DEFAULT_CPU set and then run with a -mcpu or
-march option, selected_cpu will be set to the default CPU. This means
the -mcpu is ignored which is surprising behavior. This commit instead
sets selected_cpu from the value passed to -mcpu/-march.

2017-03-24  Thomas preud'homme  <thomas.preudhomme@arm.com>

gas/
* config/tc-arm.: (md_begin): Set selected_cpu from *mcpu_cpu_opt when
CPU_DEFAULT is defined.

7 years agoreadelf: Fix incorrect "Version definition past end of section" message (ChangeLog)
Maciej W. Rozycki [Fri, 24 Mar 2017 12:25:49 +0000 (12:25 +0000)] 
readelf: Fix incorrect "Version definition past end of section" message (ChangeLog)

Correct ChangeLog entry for commit c9f02c3e2949 ("readelf: Fix incorrect
"Version definition past end of section" message").

7 years agoAutomatic date update in version.in
GDB Administrator [Fri, 24 Mar 2017 00:00:33 +0000 (00:00 +0000)] 
Automatic date update in version.in

7 years agoRemove some unnecessary inferior_ptid setting/restoring when fetching/storing registers
Simon Marchi [Thu, 23 Mar 2017 17:37:06 +0000 (13:37 -0400)] 
Remove some unnecessary inferior_ptid setting/restoring when fetching/storing registers

Now that the to_fetch_registers, to_store_registers and
to_prepare_to_store target methods don't rely on the value of
inferior_ptid anymore, we can remove a bunch of now unnecessary setting
and restoring of inferior_ptid.

The asserts added recently in target_fetch_registers and
target_store_registers, which validate that inferior_ptid matches the
regcache's ptid, must go away.  It's the whole point of this effort, to
not require inferior_ptid to have a particular value when calling these
functions.

One thing that I noticed is how sol-thread.c's ps_lgetregs and friends
use the current value of inferior_ptid instead of what's passed as
argument (ph->ptid), unlike proc-service.c's versions of the same
functions.  Is it expected?  I left it like this in the current patch,
but unless there's a good reason for it to be that way, I guess we
should make it use the parameter.

gdb/ChangeLog:

* fbsd-tdep.c (fbsd_corefile_thread): Don't set/restore
inferior_ptid.
* proc-service.c (ps_lgetregs, ps_lsetregs, ps_lgetfpregs,
ps_lsetfpregs): Likewise.
* regcache.c (regcache_raw_update, regcache_raw_write): Likewise.
* sol-thread.c (ps_lgetregs, ps_lsetregs, ps_lgetfpregs,
ps_lsetfpregs): Likewise.
* target.c (target_fetch_registers, target_store_registers):
Remove asserts.

7 years agoRemove MAX_REGISTER_SIZE from sol-thread.c
Alan Hayward [Thu, 23 Mar 2017 14:40:58 +0000 (14:40 +0000)] 
Remove MAX_REGISTER_SIZE from sol-thread.c

gdb/
* sol-thread.c (sol_thread_store_registers): Remove regcache calls.

7 years agoHandle PRFM in AArch64 process record
Yao Qi [Thu, 23 Mar 2017 14:11:04 +0000 (14:11 +0000)] 
Handle PRFM in AArch64 process record

This patch fixes the bug of handling PRFM instruction.  PRFM is documented
in a table with other load and store instructions, but it doesn't do any
load or store.  This patch also adds a unit test to PRFM instruction.

gdb:

2017-03-23  Yao Qi  <yao.qi@linaro.org>

* aarch64-tdep.c (aarch64_process_record_test): Declare.
(_initialize_aarch64_tdep): Register it.
(aarch64_record_load_store): Handle PRFM instruction.
(aarch64_process_record_test): New function.

7 years agoFix code indentation
Yao Qi [Thu, 23 Mar 2017 14:11:04 +0000 (14:11 +0000)] 
Fix code indentation

gdb:

2017-03-23  Yao Qi  <yao.qi@linaro.org>

* aarch64-tdep.c (aarch64_record_load_store): Fix code
indentation.

7 years agoRemove AARCH64_RECORD_FAILURE
Yao Qi [Thu, 23 Mar 2017 14:11:04 +0000 (14:11 +0000)] 
Remove AARCH64_RECORD_FAILURE

It is not used at all.

gdb:

2017-03-23  Yao Qi  <yao.qi@linaro.org>

* aarch64-tdep.c: Remove AARCH64_RECORD_FAILURE.

7 years agoRemove constness of libdir in do_start_initialization
Andreas Arnez [Thu, 23 Mar 2017 11:51:14 +0000 (12:51 +0100)] 
Remove constness of libdir in do_start_initialization

The patch "Fix memory leak in python.c:do_start_initialization"
(https://sourceware.org/ml/gdb-patches/2017-03/msg00407.html) introduced a
compilation error on some platforms:

  ../../binutils-gdb/gdb/python/python.c: In function bool do_start_initialization():
  ../../binutils-gdb/gdb/python/python.c:1556:16: error: invalid conversion from const void* to void* [-fpermissive]
   xfree (libdir);
                ^

This is fixed by removing the constness of libdir's data type.

gdb/ChangeLog:

* python/python.c (do_start_initialization): Remove 'const' from
data type of libdir.

7 years agoFix memory leak in python.c:do_start_initialization
Philipp Rudo [Thu, 23 Mar 2017 11:22:11 +0000 (12:22 +0100)] 
Fix memory leak in python.c:do_start_initialization

When intializing Python the path to the python binary is build the
following way

progname = concat (ldirname (python_libdir), SLASH_STRING, "bin",
   SLASH_STRING, "python", (char *) NULL);

This is problematic as both concat and ldirname allocate memory for the
string they return.  Thus the memory allocated by ldirname cannot be
accessed afterwards causing a memory leak.  Fix it by temporarily storing
libdir in a variable and xfree it after concat.

gdb/ChangeLog:
python/python.c (do_start_initialization): Fix memory leak.