binutils-gdb.git
7 years agoRemove unused variable in rust-lang.c
Tom Tromey [Fri, 10 Feb 2017 20:09:23 +0000 (13:09 -0700)]
Remove unused variable in rust-lang.c

I found another unused "cleanup" local variable, this time in
rust-lang.c.  This patch removes it.  Committing as obvious.

gdb/ChangeLog
2017-02-10  Tom Tromey  <tom@tromey.com>

* rust-lang.c (rust_get_disr_info): Remove unused variable.

7 years agoFix Python test to use lowercase command
Tom Tromey [Thu, 9 Feb 2017 20:39:32 +0000 (13:39 -0700)]
Fix Python test to use lowercase command

While testing this series I saw some errors from the Python test
suite.  There were a couple of tests using "P" as a command; this
changes them to "p".

gdb/testsuite/ChangeLog
2017-02-10  Tom Tromey  <tom@tromey.com>

* gdb.python/py-xmethods.exp: Use "p" command, not "P".

7 years agoRemove unnecessary local variables
Tom Tromey [Thu, 9 Feb 2017 20:32:48 +0000 (13:32 -0700)]
Remove unnecessary local variables

I found an unused local variables in a couple of places in the Python
code; this removes them.

gdb/ChangeLog
2017-02-10  Tom Tromey  <tom@tromey.com>

* python/py-value.c (valpy_richcompare_throw): Remove unnecessary
"cleanup" local.
* python/py-type.c (typy_legacy_template_argument): Remove
unnecessary "cleanup" local.

7 years agoRemove some gotos from Python
Tom Tromey [Thu, 12 Jan 2017 15:59:26 +0000 (08:59 -0700)]
Remove some gotos from Python

This patch slightly refactors a couple of spots in the Python code to
avoid some gotos.

gdb/ChangeLog
2017-02-10  Tom Tromey  <tom@tromey.com>

* python/python.c (do_start_initialization): New function, from
_initialize_python.
(_initialize_python): Call do_start_initialization.
* python/py-linetable.c (ltpy_iternext): Use explicit returns, not
goto.

7 years agoChange one more spot to use gdbpy_ref
Tom Tromey [Thu, 12 Jan 2017 14:46:07 +0000 (07:46 -0700)]
Change one more spot to use gdbpy_ref

This patch changes one more spot in the Python layer to use gdbpy_ref.

gdb/ChangeLog
2017-02-10  Tom Tromey  <tom@tromey.com>

* python/py-prettyprint.c (pretty_print_one_value): Use
gdbpy_ref.

7 years agoUse gdbpy_ref to simplify some logic
Tom Tromey [Wed, 11 Jan 2017 23:28:43 +0000 (16:28 -0700)]
Use gdbpy_ref to simplify some logic

This uses the new gdbpy_ref template to simplify logic in various
parts of the Python layer; for example removing repeated error code or
removing gotos.

gdb/ChangeLog
2017-02-10  Tom Tromey  <tom@tromey.com>

* python/py-cmd.c (cmdpy_destroyer): Use gdbpy_ref.
* python/py-breakpoint.c (gdbpy_breakpoint_deleted): Use
gdbpy_ref.
* python/py-type.c (field_new): Use gdbpy_ref.
* python/py-symtab.c (symtab_and_line_to_sal_object): Use
gdbpy_ref.
* python/py-progspace.c (pspy_new): Use gdbpy_ref.
(py_free_pspace): Likewise.
(pspace_to_pspace_object): Likewise.
* python/py-objfile.c (objfpy_new): Use gdbpy_ref.
(py_free_objfile): Likewise.
(objfile_to_objfile_object): Likewise.
* python/py-inferior.c (delete_thread_object): Use
gdbpy_ref.
(infpy_read_memory): Likewise.
(py_free_inferior): Likewise.
* python/py-evtregistry.c (create_eventregistry_object): Use
gdbpy_ref.
* python/py-event.c (create_event_object): Use gdbpy_ref.

7 years agoTurn gdbpy_ref into a template
Tom Tromey [Thu, 9 Feb 2017 20:16:36 +0000 (13:16 -0700)]
Turn gdbpy_ref into a template

This turns gdbpy_ref into a template class, so that it can be used to
wrap subclasses of PyObject.  The default argument remains PyObject;
and this necessitated renaming uses of "gdbpy_ref" to "gdbpy_ref<>".

gdb/ChangeLog
2017-02-10  Tom Tromey  <tom@tromey.com>

* python/py-ref.h (gdbpy_ref_policy): Now a template.
(gdbpy_ref): Now a template; allow subclasses of PyObject to be
used.
* python/py-arch.c, python/py-bpevent.c, python/py-breakpoint.c,
python/py-cmd.c, python/py-continueevent.c, python/py-event.c,
python/py-exitedevent.c, python/py-finishbreakpoint.c,
python/py-framefilter.c, python/py-function.c,
python/py-inferior.c, python/py-infevents.c,
python/py-linetable.c, python/py-newobjfileevent.c,
python/py-param.c, python/py-prettyprint.c, python/py-ref.h,
python/py-signalevent.c, python/py-stopevent.c,
python/py-symbol.c, python/py-threadevent.c, python/py-type.c,
python/py-unwind.c, python/py-utils.c, python/py-value.c,
python/py-varobj.c, python/py-xmethods.c, python/python.c,
varobj.c: Change gdbpy_ref to gdbpy_ref<>.

7 years agoRemove some ui_out-related cleanups from Python
Tom Tromey [Wed, 11 Jan 2017 06:34:22 +0000 (23:34 -0700)]
Remove some ui_out-related cleanups from Python

This patch introduces a bit of infrastructure -- namely, a minimal
std::optional analogue called gdb::optional, and an RAII template
class that works like make_cleanup_ui_out_tuple_begin_end or
make_cleanup_ui_out_list_begin_end -- and then uses these in the
Python code.  This removes a number of cleanups and generally
simplifies this code.

std::optional is only available in C++17.  Normally I would have had
this code check __cplusplus, but my gcc apparently isn't new enough to
find <optional>, even with -std=c++1z; so, because I could not test
it, the patch does not do this.

gdb/ChangeLog
2017-02-10  Tom Tromey  <tom@tromey.com>

* ui-out.h (ui_out_emit_type): New class.
(ui_out_emit_tuple, ui_out_emit_list): New typedefs.
* python/py-framefilter.c (py_print_single_arg): Use gdb::optional
and ui_out_emit_tuple.
(enumerate_locals): Likewise.
(py_mi_print_variables, py_print_locals, py_print_args): Use
ui_out_emit_list.
(py_print_frame): Use gdb::optional, ui_out_emit_tuple,
ui_out_emit_list.
* common/gdb_optional.h: New file.

7 years agogdb/MAINTAINERS: Update my e-mail address
Martin Galvan [Fri, 10 Feb 2017 16:46:56 +0000 (13:46 -0300)]
gdb/MAINTAINERS: Update my e-mail address

gdb/ChangeLog:

2017-02-10  Martin Galvan  <martingalvan@sourceware.org>

        * MAINTAINERS (Write After Approval): Update my e-mail address.

7 years agoPR gdb/21122: Fix documentation mistakes for breakpoint commands
Martin Galvan [Fri, 10 Feb 2017 16:37:31 +0000 (13:37 -0300)]
PR gdb/21122: Fix documentation mistakes for breakpoint commands

Currently, the breakpoint documentation refers to some commands taking breakpoint
"ranges" as arguments. We discussed this with Pedro and concluded that it would
be more accurate to speak in terms of breakpoint "lists", whose elements can optionally
be ranges. I also fixed a couple of minor mistakes in the docs.

gdb/ChangeLog:

* breakpoint.c (_initialize_breakpoint): Update the help description
of the 'commands' command to indicate that it takes a list argument.

gdb/doc/ChangeLog:

* gdb.texinfo (Breakpoints): Reword documentation to speak in terms of
space-separated breakpoint lists.  Also add a missing @table command
and @cindex for breakpoint lists.

gdb/testsuite/ChangeLog:

* gdb.base/help.exp: Update match pattern for testing 'help commands'.

7 years agoPOWER9 add scv/rfscv instruction support
Nicholas Piggin [Fri, 10 Feb 2017 04:18:23 +0000 (14:18 +1000)]
POWER9 add scv/rfscv instruction support

opcodes/
* ppc-opc.c (powerpc_opcodes) <scv, rfscv>: New mnemonics.

gas/
* testsuite/gas/ppc/power9.d <scv, rfscv>: New tests.

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

7 years agoRemove return in function returning void
Simon Marchi [Thu, 9 Feb 2017 21:24:40 +0000 (16:24 -0500)]
Remove return in function returning void

gdb/ChangeLog:

* interps.c (current_interp_set_logging): Remove "return".

7 years agoFix NULL pointer dereference
Gary Benson [Thu, 9 Feb 2017 15:35:33 +0000 (15:35 +0000)]
Fix NULL pointer dereference

This commit fixes a segmentation fault on tab completion when
certain debuginfo is installed:

  https://bugzilla.redhat.com/show_bug.cgi?id=1398387

gdb/ChangeLog:

* symtab.c (add_symtab_completions): Prevent NULL pointer
dereference.

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

7 years agold/arc: Change default linker emulation for nps400
Andrew Burgess [Thu, 26 Jan 2017 10:33:23 +0000 (10:33 +0000)]
ld/arc: Change default linker emulation for nps400

If we are configuring for an arc/linux target, and --with-cpu=nps400 is
used at configure time then change the default linker emulation to the
nps specific version.  All of the alternative linker emulations are
still available using the -mNAME option for ld.

ld/ChangeLog:

* configure.tgt (arc*-*-linux*): Change the default linker
emulation based on --with-cpu selection.
* NEWS: Mention new configuration option.

7 years agoEliminate interp::quiet_p
Pedro Alves [Wed, 8 Feb 2017 18:08:18 +0000 (18:08 +0000)]
Eliminate interp::quiet_p

This commit removes interp::quiet_p / interp_quiet_p /
interp_set_quiet, because AFAICS, it doesn't really do anything.

interp_quiet is only ever checked inside interp_set nowadays:

  if (!first_time && !interp_quiet_p (interp))
    {
      xsnprintf (buffer, sizeof (buffer),
 "Switching to interpreter \"%.24s\".\n", interp->name);
      current_uiout->text (buffer);
    }

I did a bit of archaelogy, and found that back in 4a8f6654 (2003), it
was also called in another place, to decide whether to print the CLI
prompt.

AFAICS, that condition is always false today, making that if/then
block always dead code.  If we remove that code, then there are no
interp_quiet_p uses left in the tree, so we can remove it all.

There are two paths that lead to interp_set calls:

#1 - When installing the top level interpreter.  In this case,
FIRST_TIME is true.

#2 - In interpreter_exec_cmd.  In this case, the interpreter is always
set quiet before interp_set is called.

Grepping a gdb.log of an x86_64 GNU/Linux run for "Switching to
interpreter" (before this patch) doesn't find any hits.

I suspect the intention of this message was to support something like
a "set interpreter ..." command that would change the interpreter
permanently.  But there's no such command.

Tested on x86_64 Fedora 23.

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

* interps.c (interp::interp): Remove reference to quiet_p.
(interp_set): Make static.  Remove dead "Switching to" output
code.
(interp_quiet_p, interp_set_quiet): Delete.
(interpreter_exec_cmd): Don't set the interpreter quiet.
* interps.h (interp_quiet_p): Make static.
(class interp) <quiet_p>: Remove field

7 years agoCommand abbreviation in define
Jerome Guitton [Tue, 10 Jan 2017 14:15:53 +0000 (15:15 +0100)]
Command abbreviation in define

When defining a new macro, "command" is not recognized as an alias for
"commands":

 (gdb) define breakmain
 Type commands for definition of "breakmain".
 End with a line saying just "end".
 >break main
 >command
 >echo "IN MAIN\n"
 >end
 (gdb)

There is a special case for while-stepping, where 'ws' and 'stepping' are
recognized explicitely. Instead of adding more special cases, this change
uses cli-decode.

gdb/ChangeLog:
* cli/cli-decode.c (find_command_name_length): Make it extern.
* cli/cli-decode.h (find_command_name_length): Declare.
* cli/cli-script.c (command_name_equals, line_first_arg):
New functions.
(process_next_line): Use cli-decode to parse command names.
(build_command_line): Make args a constant pointer.

gdb/testsuite/ChangeLog:

* gdb.base/define.exp: Add test for command abbreviations
in define.

7 years agoCommand names: make them case sensitive
Jerome Guitton [Fri, 27 Jan 2017 16:06:32 +0000 (17:06 +0100)]
Command names: make them case sensitive

Case-insensitive search for command names is an obscure undocumented
feature, which seems to be unused, is not tested and not quite
consistent. Remove it.

gdb/ChangeLog:

* cli-decode.c (lookup_cmd_1, lookup_cmd_composition):
Remove case-insensitive search.

7 years agoFix segfault when .plt section does not exist
Andrew Waterman [Mon, 23 Jan 2017 20:58:30 +0000 (12:58 -0800)]
Fix segfault when .plt section does not exist

bfd/ChangeLog

2017-02-07  Andrew Waterman  <andrew@sifive.com>

* elfnn-riscv.c (riscv_elf_finish_dynamic_sections): Only write PLT
entry size if PLT header is written.

7 years agoAutomatic date update in version.in
GDB Administrator [Wed, 8 Feb 2017 00:00:23 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agogdb: fix ARI warning in sparc-tdep.c
Jose E. Marchesi [Tue, 7 Feb 2017 21:21:54 +0000 (13:21 -0800)]
gdb: fix ARI warning in sparc-tdep.c

gdb/ChangeLog:

2017-02-07  Jose E. Marchesi  <jose.marchesi@oracle.com>

* sparc-tdep.c (sparc32_gdbarch_init): Do not place a + operator
at the end of the line.

7 years agobfd: Fix objdump --dynamic-reloc for SPARC 64-bit to show symbol names.
Sheldon Lobo [Tue, 7 Feb 2017 14:05:59 +0000 (06:05 -0800)]
bfd: Fix objdump --dynamic-reloc for SPARC 64-bit to show symbol names.

Fixes ld/testsuite/ld-elf/shared.exp "Build libpr16496b.so".

The root cause is in bfd/elf64-sparc.c, elf64_sparc_slurp_one_reloc_table(),
bfd_get_symcount() was used for dynamic mode as well. The fix is to use
bfd_get_dynamic_symcount().

This has been tested with sparc64-linux-gnu, and it does not introduce any
regressions.

bfd/ChangeLog:

2017-02-06  Sheldon Lobo  <sheldon.lobo@oracle.com>

Fix sparc64 dynamic relocation processing to use the dynamic
        symbol count.
* elf64-sparc.c (elf64_sparc_slurp_one_reloc_table): Use 'dynamic'
to determine if bfd_get_symcount() or bfd_get_dynamic_symcount()
should be used.

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

7 years ago[ld, testsuite] Don't print to stdout for "readelf -w" to avoid buffer overflow
Jiong Wang [Thu, 2 Feb 2017 17:15:26 +0000 (17:15 +0000)]
[ld, testsuite] Don't print to stdout for "readelf -w" to avoid buffer overflow

ld/
* testsuite/ld-elf/compress.exp: Don't print to stdout for all
"readelf -w".

7 years ago[ARC] Provide an interface to decode ARC instructions.
Claudiu Zissulescu [Mon, 6 Feb 2017 10:26:13 +0000 (11:26 +0100)]
[ARC] Provide an interface to decode ARC instructions.

gas/
2017-02-06  Claudiu Zissulescu  <claziss@synopsys.com>

* config/tc-arc.c (parse_opcode_flags): Ignore implicit flags.

include/
2017-02-06  Claudiu Zissulescu  <claziss@synopsys.com>
    Anton Kolesov  <anton.kolesov@synopsys.com>

* opcode/arc.h (insn_class_t): Add ENTER, LEAVE, POP, PUSH, BBIT0,
BBIT1, BI, BIH, BRCC, EI, JLI, and SUB instruction classes.
(flag_class_t): Add F_CLASS_WB, F_CLASS_ZZ, and F_CLASS_IMPLICIT
flag classes.

opcode/
2017-02-06  Claudiu Zissulescu  <claziss@synopsys.com>
    Anton Kolesov  <anton.kolesov@synopsys.com>

* arc-dis.c (arc_disassemble_info): New structure.
(init_arc_disasm_info): New function.
(find_format_from_table): Ignore implicit flags.
(find_format): Update dissassembler private data.
(print_flags): Likewise.
(print_insn_arc): Likewise.
(arc_opcode_to_insn_type): Consider the new added instruction
classes.
(arcAnalyzeInstr): Remove.
(arc_insn_decode): New function.
* arc-dis.h (arc_ldst_writeback_mode): New enum.
(arc_ldst_data_size): Likewise.
(arc_condition_code): Likewise.
(arc_operand_kind): Likewise.
(arc_insn_kind): New struct.
(arc_instruction): Likewise.
(arc_insn_decode): Declare function.
(ARC_Debugger_OperandType): Deleted.
(Flow): Likewise.
(NullifyMode): Likewise.
(allOperandsSize): Likewise.
(arcDisState): Likewise.
(arcAnalyzeInstr): Likewise.
* arc-dis.c (arc_opcode_to_insn_type): Handle newly introduced
insn_class_t enums.
* arc-opc.c (F_SIZED): New define.
(C_CC_EQ, C_CC_GE, C_CC_GT, C_CC_HI, C_CC_HS): Likewise.
(C_CC_LE, C_CC_LO, C_CC_LS, C_CC_LT, C_CC_NE): Likewise.
(C_CC_NE, C_AA_AB, C_AA_AW, C_ZZ_D, C_ZZ_H, C_ZZ_B): Likewise.
(arc_flag_classes): Add F_CLASS_COND/F_CLASS_IMPLICIT flags.
* opcodes/arc-tbl.h: Update instructions to include new
F_CLASS_IMPLICIT flags.
(bbit0, lp): Change class.
(bbit1, bi, bih, br*, ei_s, jli_s): Likewsie

7 years ago[BZ 21005] Add support for Intel 64 rdrand and rdseed record/replay
Luis Machado [Mon, 6 Feb 2017 09:12:00 +0000 (03:12 -0600)]
[BZ 21005] Add support for Intel 64 rdrand and rdseed record/replay

This patch addresses BZ 21005, which is gdb failing to recognize an rdrand
instruction.

It enables support for both rdrand and rdseed and handles extended register
addressing (R8~R15) for 16-bit, 32-bit and 64-bit.

gdb/ChangeLog
2017-02-06  Luis Machado  <lgustavo@codesourcery.com>

* NEWS: Mention support for record/replay of Intel 64 rdrand and
rdseed instructions.
i386-tdep.c (i386_process_record): Handle Intel 64 rdrand and rseed.

gdb/testsuite/ChangeLog:
2017-02-06  Luis Machado  <lgustavo@codesourcery.com>

* gdb.reverse/insn-reverse.c: Include insn-reverse-x86.c.
* gdb.reverse/insn-reverse-x86.c: New file.

7 years agogdb: provide and use sparc{32,64} target description XML files.
Ivo Raisr [Mon, 6 Feb 2017 07:44:03 +0000 (23:44 -0800)]
gdb: provide and use sparc{32,64} target description XML files.

gdb/ChangeLog:

2017-02-06  Ivo Raisr  <ivo.raisr@oracle.com>

PR tdep/20936
Provide and use sparc32 and sparc64 target description XML files.
* features/sparc/sparc32-cp0.xml, features/sparc/sparc32-cpu.xml,
features/sparc/sparc32-fpu.xml: New files for sparc 32-bit.
* features/sparc/sparc64-cp0.xml, features/sparc/sparc64-cpu.xml,
features/sparc/sparc64-fpu.xml: New files for sparc 64-bit.
* features/sparc/sparc32-solaris.xml: New file.
* features/sparc/sparc64-solaris.xml: New file.
* features/sparc/sparc32-solaris.c: Generated.
* features/sparc/sparc64-solaris.c: Generated.
* sparc-tdep.h: Account for differences in target descriptions.
* sparc-tdep.c (sparc32_register_name): Use target provided registers.
(sparc32_register_type): Use target provided registers.
(validate_tdesc_registers): New function.
(sparc32_gdbarch_init): Use tdesc_has_registers.
Set pseudoregister functions.
* sparc64-tdep.c (sparc64_register_name): Use target provided registers.
(sparc64_register_type): Use target provided registers.
(sparc64_init_abi): Set pseudoregister functions.

gdb/doc/ChangeLog:

2017-02-06  Ivo Raisr  <ivo.raisr@oracle.com>

PR tdep/20936
* gdb.texinfo: (Standard Target Features): Document SPARC features.
(Sparc Features): New node.

gdb/testsuite/ChangeLog:

2017-02-06  Ivo Raisr  <ivo.raisr@oracle.com>

PR tdep/20936
* gdb.xml/tdesc-regs.exp: Provide sparc core registers for the tests.

7 years agoAutomatic date update in version.in
GDB Administrator [Mon, 6 Feb 2017 00:00:21 +0000 (00:00 +0000)]
Automatic date update in version.in

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

7 years agoFix ptype of single-member Rust enums
Tom Tromey [Sat, 4 Feb 2017 05:11:46 +0000 (22:11 -0700)]
Fix ptype of single-member Rust enums

While looking into PR rust/21097, I found that ptype of a
single-element enum in Rust did not always format the result properly.
In particular, it would leave out the members of a tuple struct.
Further testing showed that it also did the wrong thing for ordinary
struct members as well.

This patch fixes these problems.  I'm marking it as being associated
with the PR, since that is where the discovery was made; but this
doesn't actually fix that PR (which I think ultimately is due to a
Rust compiler bug).

Built and regtested on x86-64 Fedora 25, using the system Rust
compiler.  I'm checking this in.

2017-02-03  Tom Tromey  <tom@tromey.com>

PR rust/21097:
* rust-lang.c (rust_print_type) <TYPE_CODE_UNION>: Handle enums
with a single member.

2017-02-03  Tom Tromey  <tom@tromey.com>

PR rust/21097:
* gdb.rust/simple.exp: Add new tests.

7 years agoAutomatic date update in version.in
GDB Administrator [Sat, 4 Feb 2017 00:00:20 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoC++-fy struct interp/cli_interp/tui_interp/mi_interp
Pedro Alves [Fri, 3 Feb 2017 16:30:04 +0000 (16:30 +0000)]
C++-fy struct interp/cli_interp/tui_interp/mi_interp

- The interp->data field disappears, since we can put data in the
  interpreter directly now.  The "init" method remains in place, but
  it now returns void.

- A few places check if the interpreter method is NULL before calling
  it, and also check whether the method returns true/false.  For some
  of those methods, all current implementations always return true.
  In those cases, this commit makes the C++-fied method return void
  instead and cleans up the callers.

Tested on x86_64 Fedora 23.

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

* cli/cli-interp.c (cli_interp_base::cli_interp_base)
(cli_interp_base::~cli_interp_base): New.
(cli_interp): New struct.
(as_cli_interp): Cast the interp itself to cli_interp.
(cli_interpreter_pre_command_loop): Rename to ...
(cli_interp_base::pre_command_loop): ... this.  Remove 'self'
parameter.
(cli_interpreter_init): Rename to ...
(cli_interp::init): ... this.  Remove 'self' parameter.  Use
boolean.  Make extern.
(cli_interpreter_resume): Rename to ...
(cli_interp::resume): ... this.  Remove 'data' parameter.  Make
extern.
(cli_interpreter_suspend): Rename to ...
(cli_interp::suspend): ... this.  Remove 'data' parameter.  Make
extern.
(cli_interpreter_exec): Rename to ...
(cli_interp::exec): ... this.  Remove 'data' parameter.  Make
extern.
(cli_interpreter_supports_command_editing): Rename to ...
(cli_interp_base::supports_command_editing): ... this.  Remove
'interp' parameter.  Make extern.
(cli_ui_out): Rename to ...
(cli_interp::interp_ui_out): ... this.  Remove 'interp' parameter.
Make extern.
(cli_set_logging): Rename to ...
(cli_interp_base::set_logging): ... this.  Remove 'interp'
parameter.  Make extern.
(cli_interp_procs): Delete.
(cli_interp_factory): Adjust to use "new".
* cli/cli-interp.h: Include "interps.h".
(struct cli_interp_base): New struct.
* interps.c (struct interp): Delete.  Fields moved to interps.h.
(interp_new): Delete.
(interp::interp, interp::~interp): New.
(interp_set): Use bool, and return void.  Assume the interpreter
has suspend, init and resume methods, and that the all return
void.
(set_top_level_interpreter): interp_set returns void.
(interp_ui_out): Adapt.
(current_interp_set_logging): Adapt.
(interp_data): Delete.
(interp_pre_command_loop, interp_supports_command_editing): Adapt.
(interp_exec): Adapt.
(top_level_interpreter_data): Delete.
* interps.h (interp_init_ftype, interp_resume_ftype)
(interp_suspend_ftype, interp_exec_ftype)
(interp_pre_command_loop_ftype, interp_ui_out_ftype): Delete.
(class interp): New.
(interp_new): Delete.
(interp_set): Now returns void.  Use bool.
(interp_data, top_level_interpreter_data): Delete.
* mi/mi-common.h: Include interps.h.
(class mi_interp): Inherit from interp.  Define a ctor.  Declare
init, resume, suspect, exec, interp_ui_out, set_logging and
pre_command_loop methods.
* mi/mi-interp.c (as_mi_interp): Cast the interp itself.
(mi_interpreter_init): Rename to ...
(mi_interp::init): ... this.  Remove the 'interp' parameter, use
bool, return void and make extern.  Adjust.
(mi_interpreter_resume): ... Rename to ...
(mi_interp::resume): ... this.  Remove the 'data' parameter,
return void and make extern.  Adjust.
(mi_interpreter_suspend): ... Rename to ...
(mi_interp::suspend): ... this.  Remove the 'data' parameter,
return void and make extern.  Adjust.
(mi_interpreter_exec): ... Rename to ...
(mi_interp::exec): ... this.  Remove the 'data' parameter and make
extern.  Adjust.
(mi_interpreter_pre_command_loop): ... Rename to ...
(mi_interp::pre_command_loop): ... this.  Remove the 'self'
parameter and make extern.
(mi_on_normal_stop_1): Adjust.
(mi_ui_out): Rename to ...
(mi_interp::interp_ui_out): ... this.  Remove the 'interp'
parameter and make extern.  Adjust.
(mi_set_logging): Rename to ...
(mi_interp::set_logging): ... this.  Remove the 'interp'
parameter and make extern.  Adjust.
(mi_interp_procs): Delete.
(mi_interp_factory): Adjust to use 'new'.
* mi/mi-main.c (mi_cmd_gdb_exit, captured_mi_execute_command)
(mi_print_exception, mi_execute_command, mi_load_progress):
Adjust.
* tui/tui-interp.c (tui_interp): New class.
(as_tui_interp): Return a tui_interp pointer.
(tui_on_normal_stop, tui_on_signal_received)
(tui_on_end_stepping_range, tui_on_signal_exited, tui_on_exited)
(tui_on_no_history, tui_on_user_selected_context_changed): Adjust
to use interp::interp_ui_out.
(tui_init): Rename to ...
(tui_interp::init): ... this.  Remove the 'self' parameter, use
bool, return void and make extern.  Adjust.
(tui_resume): Rename to ...
(tui_interp::resume): ... this.  Remove the 'data' parameter,
return void and make extern.  Adjust.
(tui_suspend): Rename to ...
(tui_interp::suspend): ... this.  Remove the 'data' parameter,
return void and make extern.  Adjust.
(tui_ui_out): Rename to ...
(tui_interp::interp_ui_out): ... this.  Remove the 'self'
parameter, and make extern.  Adjust.
(tui_exec): Rename to ...
(tui_interp::exec): ... this.  Remove the 'data' parameter and
make extern.
(tui_interp_procs): Delete.
(tui_interp_factory): Use "new".

7 years ago[GOLD] PowerPC64 TOC indirect to TOC relative segfault
Alan Modra [Fri, 3 Feb 2017 08:48:37 +0000 (19:18 +1030)]
[GOLD] PowerPC64 TOC indirect to TOC relative segfault

* powerpc.cc (Powerpc_relobj::make_toc_relative): Don't crash
when no .toc section exists.

7 years agoFix compile time warning messages when compiling binutils with gcc 7.0.1.
Nick Clifton [Fri, 3 Feb 2017 09:04:21 +0000 (09:04 +0000)]
Fix compile time warning messages when compiling binutils with gcc 7.0.1.

PR 21096
bfd * coffcode.h (coff_write_object_contents): Enlarge size of
s_name_buf in order to avoid compile time warning about possible
integer truncation.
* elf32-nds32.c (nds32_elf_ex9_import_table): Mask off lower
32-bits of insn value before printing into buffer.

opcodes * aarch64-opc.c (print_register_list): Ensure that the register
list index will fir into the tb buffer.
(print_register_offset_address): Likewise.
* tic6x-dis.c (print_insn_tic6x): Increase size of func_unit_buf.

7 years agoUse bool in Rust code
Tom Tromey [Fri, 3 Feb 2017 04:21:19 +0000 (21:21 -0700)]
Use bool in Rust code

This changes various functions in the Rust code to use a bool rather
than an int when a boolean is intended.

2017-02-02  Tom Tromey  <tom@tromey.com>

* rust-exp.y (ends_raw_string, space_then_number)
(rust_identifier_start_p): Return bool.
* rust-lang.c (rust_tuple_type_p, rust_underscore_fields)
(rust_tuple_struct_type_p, rust_tuple_variant_type_p)
(rust_slice_type_p, rust_range_type_p, rust_u8_type_p)
(rust_chartype_p): Return bool.
(val_print_struct, rust_print_struct_def, rust_print_type):
Update.
* rust-lang.h (rust_tuple_type_p, rust_tuple_struct_type_p):
Return bool.

7 years agoReindent rust-lang.c
Tom Tromey [Fri, 3 Feb 2017 04:01:11 +0000 (21:01 -0700)]
Reindent rust-lang.c

I noticed a few spots in rust-lang.c had incorrect indentation.  This
patch fixes this.

2017-02-02  Tom Tromey  <tom@tromey.com>

* rust-lang.c: Reindent.

7 years agoUse std::string in Rust code
Tom Tromey [Fri, 3 Feb 2017 03:58:12 +0000 (20:58 -0700)]
Use std::string in Rust code

This changes a couple of spots in the Rust support to use std::string.
In one spot this removes some manual memory management; in the other
spot this allows the removal of a call to xstrdup.

2017-02-02  Tom Tromey  <tom@tromey.com>

* rust-lang.h (rust_crate_for_block): Update.
* rust-lang.c (rust_crate_for_block): Return std::string.
(rust_get_disr_info): Use std:;string, not
gdb::unique_xmalloc_ptr.
* rust-exp.y (crate_name): Update.

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

7 years agoFix "maintenance selftest" printing stray instructions
Pedro Alves [Thu, 2 Feb 2017 23:36:29 +0000 (23:36 +0000)]
Fix "maintenance selftest" printing stray instructions

The "maintenance selftest" command is printing odd bits of stray
instructions like:

~~~
brkwarning: A handler for the OS ABI "GNU/Linux" is not built into this configuration
of GDB.  Attempting to continue with the default HS settings.

brkmov  r0, #0mov       r0, #0mov       r0, #0mov       r0, #0mov       r0, #0mov       r0, #0mov       r0, #0mov       r0, #0mov       r0, #0mov       r0, #0mov       r0, #0mov   r0, #0mov       r0, #0mov       r0, #0mov       r0, #0breakbreakbreakbreakbreakbreakbreakbreakbreakbreakbreakbreakbreakbreakbreakbreakbreakbreakbreakM3.L = 0xffff;/* ( -1) M3=0x0xffff(65535) */break 8break 8warning: A handler for the OS ABI "GNU/Linux" is not built into this configuration
of GDB.  Attempting to continue with the default cris:common_v10_v32 settings.
~~~

etc.  Those appear because here:

  class gdb_disassembler_test : public gdb_disassembler
  {
  public:

    const bool verbose = false;

    explicit gdb_disassembler_test (struct gdbarch *gdbarch,
    const gdb_byte *insn,
    size_t len)
      : gdb_disassembler (gdbarch,
  (verbose ? gdb_stdout : &null_stream),
  gdb_disassembler_test::read_memory),

specifically in this line:

  (verbose ? gdb_stdout : &null_stream),

"verbose" has not been initialized yet, because the order of
initialization is base classes first, then members.  I.e. "verbose" is
only initialized after the base constructor is called.  Since the
gdb_disassembler_test object is created on the stack, "verbose" has
garbage at that point.  If the gargage is non-zero, then we end up
with the gdb_disassembler_test's stream incorrectly pointing to
gdb_stdout.

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

* disasm-selftests.c (print_one_insn_test): Move the "verbose"
field out of gdb_disassembler_test and make it static.

7 years agoFix "maintenance selftest" printing stray instructions
Pedro Alves [Thu, 2 Feb 2017 23:27:57 +0000 (23:27 +0000)]
Fix "maintenance selftest" printing stray instructions

The "maintenance selftest" command is printing odd bits of stray
instructions like:

~~~
brkwarning: A handler for the OS ABI "GNU/Linux" is not built into this configuration
of GDB.  Attempting to continue with the default HS settings.

brkmov  r0, #0mov       r0, #0mov       r0, #0mov       r0, #0mov       r0, #0mov       r0, #0mov       r0, #0mov       r0, #0mov       r0, #0mov       r0, #0mov       r0, #0mov   r0, #0mov       r0, #0mov       r0, #0mov       r0, #0breakbreakbreakbreakbreakbreakbreakbreakbreakbreakbreakbreakbreakbreakbreakbreakbreakbreakbreakM3.L = 0xffff;/* ( -1) M3=0x0xffff(65535) */break 8break 8warning: A handler for the OS ABI "GNU/Linux" is not built into this configuration
of GDB.  Attempting to continue with the default cris:common_v10_v32 settings.
~~~

etc.  Those appear because here:

  class gdb_disassembler_test : public gdb_disassembler
  {
  public:

    const bool verbose = false;

    explicit gdb_disassembler_test (struct gdbarch *gdbarch,
    const gdb_byte *insn,
    size_t len)
      : gdb_disassembler (gdbarch,
  (verbose ? gdb_stdout : &null_stream),
  gdb_disassembler_test::read_memory),

specifically in this line:

  (verbose ? gdb_stdout : &null_stream),

"verbose" has not been initialized yet, because the order of
initialization is base classes first, then members.  I.e. "verbose" is
only initialized after the base constructor is called.  Since the
gdb_disassembler_test object is created on the stack, "verbose" has
garbage at that point.  If the gargage is non-zero, then we end up
with the gdb_disassembler_test's stream incorrectly pointing to
gdb_stdout.

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

* disasm-selftests.c (print_one_insn_test): Move the "verbose"
field out of gdb_disassembler_test and make it static.

7 years agostruct mi_interp: Remove unused fields
Pedro Alves [Thu, 2 Feb 2017 23:08:12 +0000 (23:08 +0000)]
struct mi_interp: Remove unused fields

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

* mi/mi-common.h (struct mi_interp): Delete the mi2_interp,
mi1_interp and mi_interp fields.

7 years agoMIPS/BFD: Respect the ELF gABI dynamic symbol table sort requirement
Maciej W. Rozycki [Thu, 2 Feb 2017 22:05:46 +0000 (22:05 +0000)]
MIPS/BFD: Respect the ELF gABI dynamic symbol table sort requirement

Ensure all local symbols precede external symbols in the dynamic symbol
table.

No local symbols are expected to make it to the dynamic symbol table
except for section symbols already taken care of, so this is really a
safeguard only against a potential BFD bug otherwise not so harmful,
which may become a grave one due to a symbol table sorting requirement
violation (see PR ld/20828 for an example).  This means however that no
test suite coverage is possible for this change as code introduced here
is not normally expected to trigger.

Logically split then the part of the dynamic symbol table which is not
global offset table mapped, into a local area at the beginning and an
external area following.  By the time `mips_elf_sort_hash_table' is
called we have the number of local dynamic symbol table entries (section
and non-section) already counted in `local_dynsymcount', so use it to
offset the external area from the beginning.

bfd/
* elfxx-mips.c (mips_elf_hash_sort_data): Add
`max_local_dynindx'.
(mips_elf_sort_hash_table): Handle it.
(mips_elf_sort_hash_table_f) <GGA_NONE>: For forced local
symbols bump up `max_local_dynindx' rather than
`max_non_got_dynindx'.

7 years agoMIPS/BFD: Use `bfd_size_type' for dynamic symbol table indices
Maciej W. Rozycki [Thu, 2 Feb 2017 21:43:26 +0000 (21:43 +0000)]
MIPS/BFD: Use `bfd_size_type' for dynamic symbol table indices

Use the `bfd_size_type' data type for dynamic symbol table indices in
the MIPS backend, in line with generic code and removing the need to use
a cast.

bfd/
* elfxx-mips.c (mips_elf_hash_sort_data): Convert the
`min_got_dynindx', `max_unref_got_dynindx' and
`max_non_got_dynindx' members to the `bfd_size_type' data type.
(mips_elf_sort_hash_table): Adjust accordingly.

7 years agoMIPS/BFD: Streamline hash table references in `mips_elf_sort_hash_table'
Maciej W. Rozycki [Thu, 2 Feb 2017 21:30:27 +0000 (21:30 +0000)]
MIPS/BFD: Streamline hash table references in `mips_elf_sort_hash_table'

Make all hash table references throughout `mips_elf_sort_hash_table' use
`htab', simplifying code and improving readability.

bfd/
* elfxx-mips.c (mips_elf_sort_hash_table): Use `htab' throughout
to access the hash table.

7 years agoMIPS/BFD: Fix assertion in `mips_elf_sort_hash_table'
Maciej W. Rozycki [Thu, 2 Feb 2017 20:53:16 +0000 (20:53 +0000)]
MIPS/BFD: Fix assertion in `mips_elf_sort_hash_table'

Move the assertion on non-NULL `htab' in `mips_elf_sort_hash_table' to
the beginning, before the pointer is dereferenced (`mips_elf_hash_table
(info)' and `elf_hash_table (info)' both point to the same memory
location, differently typed).

bfd/
* elfxx-mips.c (mips_elf_sort_hash_table): Move assertion on
non-NULL `htab' to the beginning.

7 years agoCRIS/LD/testsuite: tls-err-20x.d: Fix a typo, s/n/\n/
Maciej W. Rozycki [Thu, 2 Feb 2017 20:44:41 +0000 (20:44 +0000)]
CRIS/LD/testsuite: tls-err-20x.d: Fix a typo, s/n/\n/

ld/
* testsuite/ld-cris/tls-err-20x.d: Fix a typo, s/n/\n/.

7 years agoLD/testsuite: ld-lib.exp: Fix a typo, s/regexp/regex/
Maciej W. Rozycki [Thu, 2 Feb 2017 19:09:57 +0000 (19:09 +0000)]
LD/testsuite: ld-lib.exp: Fix a typo, s/regexp/regex/

Match `$check_ld(source)' against "regex" rather than "regexp" in
reporting, correcting test framework diagnostics, e.g.:

tmpdir/undefined.o: In function `foo':
(.text+0x0): undefined reference to `bar'
failed with: <tmpdir/undefined.o: In function `foo':
(.text+0x0): undefined reference to `bar'>, no expected output
tmpdir/undefined.o: In function `foo':
(.text+0x0): undefined reference to `bar'
PASS: MIPS undefined reference

(current) vs:

tmpdir/undefined.o: In function `foo':
(.text+0x0): undefined reference to `bar'
failed with: <tmpdir/undefined.o: In function `foo':
(.text+0x0): undefined reference to `bar'>, expected: <\A[^\n]*\.o: In function `foo':\n\(\.text\+0x0\): undefined reference to `bar'\Z>
tmpdir/undefined.o: In function `foo':
(.text+0x0): undefined reference to `bar'
PASS: MIPS undefined reference

(corrected).  No functional change.

ld/
* ld/testsuite/lib/ld-lib.exp (run_dump_test): Fix a typo,
s/regexp/regex/.

7 years agoBFD: Wrap overlong error handler call line in `elf_gc_sweep'
Maciej W. Rozycki [Thu, 2 Feb 2017 16:44:09 +0000 (16:44 +0000)]
BFD: Wrap overlong error handler call line in `elf_gc_sweep'

bfd/
* elflink.c (elf_gc_sweep): Wrap overlong line.

7 years agoMIPS/GAS/doc: Include MIPS options in the man page
Maciej W. Rozycki [Thu, 2 Feb 2017 16:23:21 +0000 (16:23 +0000)]
MIPS/GAS/doc: Include MIPS options in the man page

Include the detailed MIPS option description in the man page along with
other target descriptions and complementing the terse list earlier on.

gas/
* doc/as.texinfo (Overview): Select MIPS options for man page
inclusion.

7 years agoMove "tee" building down to interpreter::set_logging_proc
Pedro Alves [Thu, 2 Feb 2017 22:00:43 +0000 (22:00 +0000)]
Move "tee" building down to interpreter::set_logging_proc

This patch gets rid of this hack in mi_set_logging:

      /* The tee created already is based on gdb_stdout, which for MI
 is a console and so we end up in an infinite loop of console
 writing to ui_file writing to console etc.  So discard the
 existing tee (it hasn't been used yet, and MI won't ever use
 it), and create one based on raw_stdout instead.  */

By pushing down responsibility for the tee creation to the
interpreter.  I.e., pushing the CLI bits out of handle_redirections
down to the CLI interpreter's set_logging_proc method.

This fixes a few leaks that I spotted, and then confirmed with
"valgrind --leak-check=full":

[...]
  ==21429== 56 (32 direct, 24 indirect) bytes in 1 blocks are definitely lost in loss record 30,243 of 34,980
  ==21429==    at 0x4C29216: operator new(unsigned long) (vg_replace_malloc.c:334)
  ==21429==    by 0x62D9A9: mi_set_logging(interp*, int, ui_file*, ui_file*) (mi-interp.c:1395)
  ==21429==    by 0x810B8A: current_interp_set_logging(int, ui_file*, ui_file*) (interps.c:360)
  ==21429==    by 0x61C537: handle_redirections(int) (cli-logging.c:162)
  ==21429==    by 0x61C6EC: set_logging_on(char*, int) (cli-logging.c:190)
  ==21429==    by 0x6163BE: do_cfunc(cmd_list_element*, char*, int) (cli-decode.c:105)
  ==21429==    by 0x6193C1: cmd_func(cmd_list_element*, char*, int) (cli-decode.c:1913)
  ==21429==    by 0x8DB790: execute_command(char*, int) (top.c:674)
  ==21429==    by 0x632AE6: mi_execute_cli_command(char const*, int, char const*) (mi-main.c:2343)
  ==21429==    by 0x6329BA: mi_cmd_execute(mi_parse*) (mi-main.c:2306)
  ==21429==    by 0x631E19: captured_mi_execute_command(ui_out*, mi_parse*) (mi-main.c:1998)
  ==21429==    by 0x632389: mi_execute_command(char const*, int) (mi-main.c:2163)
  ==21429==
[...]
  ==26635== 24 bytes in 1 blocks are definitely lost in loss record 20,740 of 34,995
  ==26635==    at 0x4C29216: operator new(unsigned long) (vg_replace_malloc.c:334)
  ==26635==    by 0x61C355: handle_redirections(int) (cli-logging.c:131)
  ==26635==    by 0x61C6EC: set_logging_on(char*, int) (cli-logging.c:190)
  ==26635==    by 0x6163BE: do_cfunc(cmd_list_element*, char*, int) (cli-decode.c:105)
  ==26635==    by 0x6193C1: cmd_func(cmd_list_element*, char*, int) (cli-decode.c:1913)
  ==26635==    by 0x8DB7BC: execute_command(char*, int) (top.c:674)
  ==26635==    by 0x7B9132: command_handler(char*) (event-top.c:590)
  ==26635==    by 0x7B94F7: command_line_handler(char*) (event-top.c:780)
  ==26635==    by 0x7B8ABB: gdb_rl_callback_handler(char*) (event-top.c:213)
  ==26635==    by 0x933CE9: rl_callback_read_char (callback.c:220)
  ==26635==    by 0x7B89ED: gdb_rl_callback_read_char_wrapper_noexcept() (event-top.c:175)
  ==26635==    by 0x7B8A49: gdb_rl_callback_read_char_wrapper(void*) (event-top.c:192)

One is fixed by transfering ownership of the log file to the tee.  In
pseudo-patch, since the code was moved at the same time:

 -     out = new tee_file (curr_output, false, logfile.get (), false);
 +     out = new tee_file (curr_output, false, logfile.get (), true);

The other is this bit in mi_set_logging:

    else
      {
 +      delete mi->raw_stdout;

I tried to split the leak fixes to a smaller preparatory patch, but
that was difficult exactly because of the tee hack in
handle_redirections -> mi_set_logging.

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

* cli/cli-interp.c (struct saved_output_files, saved_output):
Moved from cli/cli-logging.c.
(cli_set_logging): New function.
(cli_interp_procs): Install cli_set_logging.
* cli/cli-interp.h (make_logging_output, cli_set_logging):
Declare.
* cli/cli-logging.c (struct saved_output_files, saved_output):
Moved to cli/cli-interp.c.
(pop_output_files): Don't save outputs here.
(make_logging_output): New function.
(handle_redirections): Don't build tee nor save previous outputs
here.
* interps.c (current_interp_set_logging): Change prototype.
Assume there's always a set_logging_proc method installed.
* interps.h (interp_set_logging_ftype): Change prototype.
(current_interp_set_logging): Change prototype and adjust comment.
* mi/mi-interp.c (mi_set_logging): Change protototype.  Adjust to
use make_logging_output.
* tui/tui-interp.c (tui_interp_procs): Install cli_set_logging.

7 years agoFix "-gdb-set logging redirect on" crash
Pedro Alves [Thu, 2 Feb 2017 19:07:08 +0000 (19:07 +0000)]
Fix "-gdb-set logging redirect on" crash

This commit fixes a "-gdb-set logging redirect on" crash by not
handling "logging redirect on" on the fly.

Previous discussion here:
 https://sourceware.org/ml/gdb-patches/2017-01/msg00467.html

Code for handling "logging redirect on" on the fly was added here:
 https://sourceware.org/ml/gdb-patches/2010-08/msg00202.html

Meanwhile, MI gained support for logging, but flipping redirect "on"
on the fly was not considered.  The result is that this sequence of
commands crashes GDB:

 -gdb-set logging on
 -gdb-set logging redirect on

 Program received signal SIGSEGV, Segmentation fault.
 0x00000000008dd7bc in gdb_flush (file=0x2a097f0) at /home/pedro/gdb/mygit/cxx-convertion/src/gdb/ui-file.c:95
 194       file->to_flush (file);
 (top-gdb) bt
 #0  0x00000000008dd7bc in gdb_flush(ui_file*) (file=0x2a097f0) at /home/pedro/gdb/mygit/cxx-convertion/src/gdb/ui-file.c:95
 #1  0x00000000007b5f34 in gdb_wait_for_event(int) (block=0) at /home/pedro/gdb/mygit/cxx-convertion/src/gdb/event-loop.c:752
 #2  0x00000000007b52b6 in gdb_do_one_event() () at /home/pedro/gdb/mygit/cxx-convertion/src/gdb/event-loop.c:322
 #3  0x00000000007b5362 in start_event_loop() () at /home/pedro/gdb/mygit/cxx-convertion/src/gdb/event-loop.c:371
 #4  0x000000000082704a in captured_command_loop(void*) (data=0x0) at /home/pedro/gdb/mygit/cxx-convertion/src/gdb/main.c:325
 #5  0x00000000007b8d7c in catch_errors(int (*)(void*), void*, char*, return_mask) (func=0x827008 <captured_command_loop(void*)>, func_args=0x0, errstring=0x11dee51 "", mask=RETURN_MASK_ALL) at /home/pedro/gdb/mygit/cxx-convertion/src/gdb/exceptions.c:236
 #6  0x000000000082839b in captured_main(void*) (data=0x7fffffffd820) at /home/pedro/gdb/mygit/cxx-convertion/src/gdb/main.c:1148
 During symbol reading, cannot get low and high bounds for subprogram DIE at 24065.
 #7  0x00000000008283c4 in gdb_main(captured_main_args*) (args=0x7fffffffd820) at /home/pedro/gdb/mygit/cxx-convertion/src/gdb/main.c:1158
 #8  0x0000000000412d4d in main(int, char**) (argc=4, argv=0x7fffffffd928) at /home/pedro/gdb/mygit/cxx-convertion/src/gdb/gdb.c:32

The handling of redirect on the fly is not really a use case we need
to handle, IMO.  Its inconsistent (other "set logging foo" commands
aren't handled on the fly), and complicates the code significantly.
Instead of complicating it further for MI, go back to the original
idea of warning, only:

  https://sourceware.org/ml/gdb-patches/2010-08/msg00083.html

New test included.

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

* cli/cli-logging.c (maybe_warn_already_logging): New factored out
from ...
(set_logging_overwrite): ... here.
(logging_no_redirect_file): Delete.
(set_logging_redirect): Don't handle redirection on the fly.
Instead warn that "logging off" / "logging on" is necessary.
(pop_output_files): Delete references to logging_no_redirect_file.
(show_logging_command): Always speak in terms of what will happen
once logging is reenabled.

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

* gdb.mi/mi-logging.exp: Add "redirect while already logging"
tests.

7 years agoTweak pretty_print_disassembler's intro comment
Pedro Alves [Thu, 2 Feb 2017 11:28:40 +0000 (11:28 +0000)]
Tweak pretty_print_disassembler's intro comment

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

* disasm.h (gdb_pretty_print_disassembler): Tweak intro comment.

7 years agoReuse buffers across gdb_pretty_print_insn calls
Pedro Alves [Thu, 2 Feb 2017 11:11:47 +0000 (11:11 +0000)]
Reuse buffers across gdb_pretty_print_insn calls

gdb_pretty_print_insn allocates and destroys a couple local buffers
each time it is called, which can be many times when disassembling a
region of memory.  Avoid that overhead by adding a new class that
holds the buffers and making gdb_pretty_print_insn a method of that
class, so that the buffers can be reused across calls.

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

* disasm.c (gdb_pretty_print_insn): Rename to ...
(gdb_pretty_print_disassembler::pretty_print_insn): ... this.
Remove gdbarch parameter.  Adapt to clear the object's buffers
instead of allocating new buffers, and to print using the object's
gdb_disassembler instead of calling gdb_print_insn.
(dump_insns): Use gdb_pretty_print_disassembler.
* disasm.h (gdb_pretty_print_insn): Delete declaration.
(gdb_pretty_print_disassembler): New class.
* record-btrace.c (btrace_insn_history): Use
gdb_pretty_print_disassembler.

7 years agoEliminate make_cleanup_ui_file_delete / make ui_file a class hierarchy
Pedro Alves [Thu, 2 Feb 2017 11:11:47 +0000 (11:11 +0000)]
Eliminate make_cleanup_ui_file_delete / make ui_file a class hierarchy

This patch starts from the desire to eliminate
make_cleanup_ui_file_delete, but then goes beyond.  It makes ui_file &
friends a real C++ class hierarchy, and switches temporary
ui_file-like objects to stack-based allocation.

- mem_fileopen -> string_file

mem_fileopen is replaced with a new string_file class that is treated
as a value class created on the stack.  This alone eliminates most
make_cleanup_ui_file_delete calls, and, simplifies code a whole lot
(diffstat shows around 1k loc dropped.)

string_file's internal buffer is a std::string, thus the "string" in
the name.  This simplifies the implementation much, compared to
mem_fileopen, which managed growing its internal buffer manually.

- ui_file_as_string, ui_file_strdup, ui_file_obsavestring all gone

The new string_file class has a string() method that provides direct
writable access to the internal std::string buffer.  This replaced
ui_file_as_string, which forced a copy of the same data the stream had
inside.  With direct access via a writable reference, we can instead
move the string out of the string_stream, avoiding deep string
copying.

Related, ui_file_xstrdup calls are replaced with xstrdup'ping the
stream's string, and ui_file_obsavestring is replaced by
obstack_copy0.

With all those out of the way, getting rid of the weird ui_file_put
mechanism was possible.

- New ui_file::printf, ui_file::puts, etc. methods

These simplify / clarify client code.  I considered splitting
client-code changes, like these, e.g.:

  -  stb = mem_fileopen ();
  -  fprintf_unfiltered (stb, "%s%s%s",
  -       _("The valid values are:\n"),
  -       regdesc,
  -       _("The default is \"std\"."));
  +  string_file stb;
  +  stb.printf ("%s%s%s",
  +       _("The valid values are:\n"),
  +       regdesc,
  +       _("The default is \"std\"."));

In two steps, with the first step leaving fprintf_unfiltered (etc.)
calls in place, and only afterwards do a pass to change all those to
call stb.printf etc..  I didn't do that split, because (when I tried),
it turned out to be pointless make-work: the first pass would have to
touch the fprintf_unfiltered line anyway, to replace "stb" with
"&stb".

- gdb_fopen replaced with stack-based objects

This avoids the need for cleanups or unique_ptr's.  I.e., this:

      struct ui_file *file = gdb_fopen (filename, "w");
      if (filename == NULL)
  perror_with_name (filename);
      cleanups = make_cleanup_ui_file_delete (file);
      // use file.
      do_cleanups (cleanups);

is replaced with this:

      stdio_file file;
      if (!file.open (filename, "w"))
  perror_with_name (filename);
      // use file.

- odd contorsions in null_file_write / null_file_fputs around when to
  call to_fputs / to_write eliminated.

- Global null_stream object

A few places that were allocating a ui_file in order to print to
"nowhere" are adjusted to instead refer to a new 'null_stream' global
stream.

- TUI's tui_sfileopen eliminated.  TUI's ui_file much simplified

The TUI's ui_file was serving a dual purpose.  It supported being used
as string buffer, and supported being backed by a stdio FILE.  The
string buffer part is gone, replaced by using of string_file.  The
'FILE *' support is now much simplified, by making the TUI's ui_file
inherit from stdio_file.

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

* ada-lang.c (type_as_string): Use string_file.
* ada-valprint.c (ada_print_floating): Use string_file.
* ada-varobj.c (ada_varobj_scalar_image)
(ada_varobj_get_value_image): Use string_file.
* aix-thread.c (aix_thread_extra_thread_info): Use string_file.
* arm-tdep.c (_initialize_arm_tdep): Use string_printf.
* breakpoint.c (update_inserted_breakpoint_locations)
(insert_breakpoint_locations, reattach_breakpoints)
(print_breakpoint_location, print_one_detail_ranged_breakpoint)
(print_it_watchpoint): Use string_file.
(save_breakpoints): Use stdio_file.
* c-exp.y (oper): Use string_file.
* cli/cli-logging.c (set_logging_redirect): Use ui_file_up and
tee_file.
(pop_output_files): Use delete.
(handle_redirections): Use stdio_file and tee_file.
* cli/cli-setshow.c (do_show_command): Use string_file.
* compile/compile-c-support.c (c_compute_program): Use
string_file.
* compile/compile-c-symbols.c (generate_vla_size): Take a
'string_file &' instead of a 'ui_file *'.
(generate_c_for_for_one_variable): Take a 'string_file &' instead
of a 'ui_file *'.  Use string_file.
(generate_c_for_variable_locations): Take a 'string_file &'
instead of a 'ui_file *'.
* compile/compile-internal.h (generate_c_for_for_one_variable):
Take a 'string_file &' instead of a 'ui_file *'.
* compile/compile-loc2c.c (push, pushf, unary, binary)
(print_label, pushf_register_address, pushf_register)
(do_compile_dwarf_expr_to_c): Take a 'string_file &' instead of a
'ui_file *'.  Adjust.
* compile/compile.c (compile_to_object): Use string_file.
* compile/compile.h (compile_dwarf_expr_to_c)
(compile_dwarf_bounds_to_c): Take a 'string_file &' instead of a
'ui_file *'.
* cp-support.c (inspect_type): Use string_file and obstack_copy0.
(replace_typedefs_qualified_name): Use string_file and
obstack_copy0.
* disasm.c (gdb_pretty_print_insn): Use string_file.
(gdb_disassembly): Adjust reference the null_stream global.
(do_ui_file_delete): Delete.
(gdb_insn_length): Use null_stream.
* dummy-frame.c (maintenance_print_dummy_frames): Use stdio_file.
* dwarf2loc.c (dwarf2_compile_property_to_c)
(locexpr_generate_c_location, loclist_generate_c_location): Take a
'string_file &' instead of a 'ui_file *'.
* dwarf2loc.h (dwarf2_compile_property_to_c): Likewise.
* dwarf2read.c (do_ui_file_peek_last): Delete.
(dwarf2_compute_name): Use string_file.
* event-top.c (gdb_setup_readline): Use stdio_file.
* gdbarch.sh (verify_gdbarch): Use string_file.
* gdbtypes.c (safe_parse_type): Use null_stream.
* guile/scm-breakpoint.c (gdbscm_breakpoint_commands): Use
string_file.
* guile/scm-disasm.c (gdbscm_print_insn_from_port): Take a
'string_file *' instead of a 'ui_file *'.
(gdbscm_arch_disassemble): Use string_file.
* guile/scm-frame.c (frscm_print_frame_smob): Use string_file.
* guile/scm-ports.c (class ioscm_file_port): Now a class that
inherits from ui_file.
(ioscm_file_port_delete, ioscm_file_port_rewind)
(ioscm_file_port_put): Delete.
(ioscm_file_port_write): Rename to ...
(ioscm_file_port::write): ... this.  Remove file_port_magic
checks.
(ioscm_file_port_new): Delete.
(ioscm_with_output_to_port_worker): Use ioscm_file_port and
ui_file_up.
* guile/scm-type.c (tyscm_type_name): Use string_file.
* guile/scm-value.c (vlscm_print_value_smob, gdbscm_value_print):
Use string_file.
* infcmd.c (print_return_value_1): Use string_file.
* infrun.c (print_target_wait_results): Use string_file.
* language.c (add_language): Use string_file.
* location.c (explicit_to_string_internal): Use string_file.
* main.c (captured_main_1): Use null_file.
* maint.c (maintenance_print_architecture): Use stdio_file.
* mi/mi-cmd-stack.c (list_arg_or_local): Use string_file.
* mi/mi-common.h (struct mi_interp) <out, err, log, targ,
event_channel>: Change type to mi_console_file pointer.
* mi/mi-console.c (mi_console_file_fputs, mi_console_file_flush)
(mi_console_file_delete): Delete.
(struct mi_console_file): Delete.
(mi_console_file_magic): Delete.
(mi_console_file_new): Delete.
(mi_console_file::mi_console_file): New.
(mi_console_file_delete): Delete.
(mi_console_file_fputs): Delete.
(mi_console_file::write): New.
(mi_console_raw_packet): Delete.
(mi_console_file::flush): New.
(mi_console_file_flush): Delete.
(mi_console_set_raw): Rename to ...
(mi_console_file::set_raw): ... this.
* mi/mi-console.h (class mi_console_file): New class.
(mi_console_file_new, mi_console_set_raw): Delete.
* mi/mi-interp.c (mi_interpreter_init): Use mi_console_file.
(mi_set_logging): Use delete and tee_file.  Adjust.
* mi/mi-main.c (output_register): Use string_file.
(mi_cmd_data_evaluate_expression): Use string_file.
(mi_cmd_data_read_memory): Use string_file.
(mi_cmd_execute, print_variable_or_computed): Use string_file.
* mi/mi-out.c (mi_ui_out::main_stream): New.
(mi_ui_out::rewind): Use main_stream and
string_file.
(mi_ui_out::put): Use main_stream and string_file.
(mi_ui_out::mi_ui_out): Remove 'stream' parameter.
Allocate a 'string_file' instead.
(mi_out_new): Don't allocate a mem_fileopen stream here.
* mi/mi-out.h (mi_ui_out::mi_ui_out): Remove 'stream' parameter.
(mi_ui_out::main_stream): Declare method.
* printcmd.c (eval_command): Use string_file.
* psymtab.c (maintenance_print_psymbols): Use stdio_file.
* python/py-arch.c (archpy_disassemble): Use string_file.
* python/py-breakpoint.c (bppy_get_commands): Use string_file.
* python/py-frame.c (frapy_str): Use string_file.
* python/py-framefilter.c (py_print_type, py_print_single_arg):
Use string_file.
* python/py-type.c (typy_str): Use string_file.
* python/py-unwind.c (unwind_infopy_str): Use string_file.
* python/py-value.c (valpy_str): Use string_file.
* record-btrace.c (btrace_insn_history): Use string_file.
* regcache.c (regcache_print): Use stdio_file.
* reggroups.c (maintenance_print_reggroups): Use stdio_file.
* remote.c (escape_buffer): Use string_file.
* rust-lang.c (rust_get_disr_info): Use string_file.
* serial.c (serial_open_ops_1): Use stdio_file.
(do_serial_close): Use delete.
* stack.c (print_frame_arg): Use string_file.
(print_frame_args): Remove local mem_fileopen stream, not used.
(print_frame): Use string_file.
* symmisc.c (maintenance_print_symbols): Use stdio_file.
* symtab.h (struct symbol_computed_ops) <generate_c_location>:
Take a 'string_file *' instead of a 'ui_file *'.
* top.c (new_ui): Use stdio_file and stderr_file.
(free_ui): Use delete.
(execute_command_to_string): Use string_file.
(quit_confirm): Use string_file.
* tracepoint.c (collection_list::append_exp): Use string_file.
* tui/tui-disasm.c (tui_disassemble): Use string_file.
* tui/tui-file.c: Don't include "ui-file.h".
(enum streamtype, struct tui_stream): Delete.
(tui_file_new, tui_file_delete, tui_fileopen, tui_sfileopen)
(tui_file_isatty, tui_file_rewind, tui_file_put): Delete.
(tui_file::tui_file): New method.
(tui_file_fputs): Delete.
(tui_file_get_strbuf): Delete.
(tui_file::puts): New method.
(tui_file_adjust_strbuf): Delete.
(tui_file_flush): Delete.
(tui_file::flush): New method.
* tui/tui-file.h: Tweak intro comment.
Include ui-file.h.
(tui_fileopen, tui_sfileopen, tui_file_get_strbuf)
(tui_file_adjust_strbuf): Delete declarations.
(class tui_file): New class.
* tui/tui-io.c (tui_initialize_io): Use tui_file.
* tui/tui-regs.c (tui_restore_gdbout): Use delete.
(tui_register_format): Use string_stream.
* tui/tui-stack.c (tui_make_status_line): Use string_file.
(tui_get_function_from_frame): Use string_file.
* typeprint.c (type_to_string): Use string_file.
* ui-file.c (struct ui_file, ui_file_magic, ui_file_new): Delete.
(null_stream): New global.
(ui_file_delete): Delete.
(ui_file::ui_file): New.
(null_file_isatty): Delete.
(ui_file::~ui_file): New.
(null_file_rewind): Delete.
(ui_file::printf): New.
(null_file_put): Delete.
(null_file_flush): Delete.
(ui_file::putstr): New.
(null_file_write): Delete.
(ui_file::putstrn): New.
(null_file_read): Delete.
(ui_file::putc): New.
(null_file_fputs): Delete.
(null_file_write_async_safe): Delete.
(ui_file::vprintf): New.
(null_file_delete): Delete.
(null_file::write): New.
(null_file_fseek): Delete.
(null_file::puts): New.
(ui_file_data): Delete.
(null_file::write_async_safe): New.
(gdb_flush, ui_file_isatty): Adjust.
(ui_file_put, ui_file_rewind): Delete.
(ui_file_write): Adjust.
(ui_file_write_for_put): Delete.
(ui_file_write_async_safe, ui_file_read): Adjust.
(ui_file_fseek): Delete.
(fputs_unfiltered): Adjust.
(set_ui_file_flush, set_ui_file_isatty, set_ui_file_rewind)
(set_ui_file_put, set_ui_file_write, set_ui_file_write_async_safe)
(set_ui_file_read, set_ui_file_fputs, set_ui_file_fseek)
(set_ui_file_data): Delete.
(string_file::~string_file, string_file::write)
(struct accumulated_ui_file, do_ui_file_xstrdup, ui_file_xstrdup)
(do_ui_file_as_string, ui_file_as_string): Delete.
(do_ui_file_obsavestring, ui_file_obsavestring): Delete.
(struct mem_file): Delete.
(mem_file_new): Delete.
(stdio_file::stdio_file): New.
(mem_file_delete): Delete.
(stdio_file::stdio_file): New.
(mem_fileopen): Delete.
(stdio_file::~stdio_file): New.
(mem_file_rewind): Delete.
(stdio_file::set_stream): New.
(mem_file_put): Delete.
(stdio_file::open): New.
(mem_file_write): Delete.
(stdio_file_magic, struct stdio_file): Delete.
(stdio_file_new, stdio_file_delete, stdio_file_flush): Delete.
(stdio_file::flush): New.
(stdio_file_read): Rename to ...
(stdio_file::read): ... this.  Adjust.
(stdio_file_write): Rename to ...
(stdio_file::write): ... this.  Adjust.
(stdio_file_write_async_safe): Rename to ...
(stdio_file::write_async_safe) ... this.  Adjust.
(stdio_file_fputs): Rename to ...
(stdio_file::puts) ... this.  Adjust.
(stdio_file_isatty): Delete.
(stdio_file_fseek): Delete.
(stdio_file::isatty): New.
(stderr_file_write): Rename to ...
(stderr_file::write) ... this.  Adjust.
(stderr_file_fputs): Rename to ...
(stderr_file::puts) ... this.  Adjust.
(stderr_fileopen, stdio_fileopen, gdb_fopen): Delete.
(stderr_file::stderr_file): New.
(tee_file_magic): Delete.
(struct tee_file): Delete.
(tee_file::tee_file): New.
(tee_file_new): Delete.
(tee_file::~tee_file): New.
(tee_file_delete): Delete.
(tee_file_flush): Rename to ...
(tee_file::flush): ... this.  Adjust.
(tee_file_write): Rename to ...
(tee_file::write): ... this.  Adjust.
(tee_file::write_async_safe): New.
(tee_file_fputs): Rename to ...
(tee_file::puts): ... this.  Adjust.
(tee_file_isatty): Rename to ...
(tee_file::isatty): ... this.  Adjust.
* ui-file.h (struct obstack, struct ui_file): Don't
forward-declare.
(ui_file_new, ui_file_flush_ftype, set_ui_file_flush)
(ui_file_write_ftype)
(set_ui_file_write, ui_file_fputs_ftype, set_ui_file_fputs)
(ui_file_write_async_safe_ftype, set_ui_file_write_async_safe)
(ui_file_read_ftype, set_ui_file_read, ui_file_isatty_ftype)
(set_ui_file_isatty, ui_file_rewind_ftype, set_ui_file_rewind)
(ui_file_put_method_ftype, ui_file_put_ftype, set_ui_file_put)
(ui_file_delete_ftype, set_ui_file_data, ui_file_fseek_ftype)
(set_ui_file_fseek): Delete.
(ui_file_data, ui_file_delete, ui_file_rewind)
(struct ui_file): New.
(ui_file_up): New.
(class null_file): New.
(null_stream): Declare.
(ui_file_write_for_put, ui_file_put): Delete.
(ui_file_xstrdup, ui_file_as_string, ui_file_obsavestring):
Delete.
(ui_file_fseek, mem_fileopen, stdio_fileopen, stderr_fileopen)
(gdb_fopen, tee_file_new): Delete.
(struct string_file): New.
(struct stdio_file): New.
(stdio_file_up): New.
(struct stderr_file): New.
(class tee_file): New.
* ui-out.c (ui_out::field_stream): Take a 'string_file &' instead
of a 'ui_file *'.  Adjust.
* ui-out.h (class ui_out) <field_stream>: Likewise.
* utils.c (do_ui_file_delete, make_cleanup_ui_file_delete)
(null_stream): Delete.
(error_stream): Take a 'string_file &' instead of a 'ui_file *'.
Adjust.
* utils.h (struct ui_file): Delete forward declaration..
(make_cleanup_ui_file_delete, null_stream): Delete declarations.
(error_stream): Take a 'string_file &' instead of a
'ui_file *'.
* varobj.c (varobj_value_get_print_value): Use string_file.
* xtensa-tdep.c (xtensa_verify_config): Use string_file.
* gdbarch.c: Regenerate.

7 years agoAdd back gdb_pretty_print_insn
Pedro Alves [Thu, 2 Feb 2017 11:11:47 +0000 (11:11 +0000)]
Add back gdb_pretty_print_insn

ui_file_rewind is a ui_file method that only really works with mem
buffer files, and is a nop on other ui_file types.  It'd be desirable
to eliminate it from the base ui_file interface, and move it to the
"mem_fileopen" subclass of ui_file instead.  A following patch does
just that.

Unfortunately, there are a couple references to ui_file_rewind inside
gdb_disassembler::pretty_print_insn that were made harder to eliminate
with the recent addition of the gdb_disassembler wrapper.

Before the gdb_disassembler wrapper was added, in commit
e47ad6c0bd7aa3 ("Refactor disassembly code"), gdb_pretty_print_insn
used to be passed a ui_file pointer as argument, and it was simple to
adjust that pointer be a "mem_fileopen" ui_file pointer instead, since
there's only one gdb_pretty_print_insn caller.

That commit made gdb_pretty_print_insn be a method of
gdb_disassembler, and removed the method's ui_file parameter at the
same time, replaced by referencing the gdb_disassembler's stream
instead.  The trouble is that a gdb_disassembler can be instantiated
with a pointer any kind of ui_file.  Casting the gdb_disassembler's
stream to a mem_fileopen ui_file inside
gdb_disassembler::pretty_print_insn in order to call the reset method
would be gross hack.

The fix here is to:

 - make gdb_disassembler::pretty_print_insn a be free function again
   instead of a method of gdb_disassembler.  I.e., bring back
   gdb_pretty_print_insn.

 - but, don't add back the ui_file * parameter.  Instead, move the
   mem_fileopen allocation inside.  That is a better interface, given
   that the ui_file is only ever used as temporary scratch buffer as
   an implementation detail of gdb_pretty_print_insn.  The function's
   real "where to send output" parameter is the ui_out pointer.  (A
   following patch will add back buffer reuse across invocations
   differently).

 - don't add back a disassemble_info pointer either.  That used to be
   necessary for this bit:

  err = m_di.read_memory_func (pc, &data, 1, &m_di);
  if (err != 0)
    m_di.memory_error_func (err, pc, &m_di);

   ... but AFAIK, it's not really necessary.  We can replace those
   three lines with a call to read_code.  This seems to fix a
   regression even, because before commit d8b49cf0c891d0 ("Don't throw
   exception in dis_asm_memory_error"), that memory_error_func call
   would throw an error/exception, but now it only records the error
   in the gdb_disassembler's m_err_memaddr field.  (read_code throws
   on error.)

With all these, gdb_pretty_print_insn is completely layered on top of
gdb_disassembler only using the latter's public API.

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

* disasm.c (gdb_disassembler::pretty_print_insn): Rename to...
(gdb_pretty_print_insn): ... this.  Now a free function.  Add back
a 'gdbarch' parameter.  Allocate a mem_fileopen stream here.
Adjust to call gdb_print_insn instead of
gdb_disassembler::print_insn.
(dump_insns, do_mixed_source_and_assembly_deprecated)
(do_mixed_source_and_assembly, do_assembly_only): Add back a
'gdbarch' parameter.  Remove gdb_disassembler parameter.
(gdb_disassembly): Don't allocate a gdb_disassembler here.
* disasm.h (gdb_disassembler::pretty_print_insn): Delete
declaration.
(gdb_pretty_print_insn): Re-add declaration.
* record-btrace.c (btrace_insn_history): Don't allocate a
gdb_disassembler here.  Adjust to call gdb_pretty_print_insn.

7 years ago[ld, testsuite] Restrict dl1*main and dl6*main tests on platforms which have libdl...
Jiong Wang [Wed, 1 Feb 2017 16:44:40 +0000 (16:44 +0000)]
[ld, testsuite] Restrict dl1*main and dl6*main tests on platforms which have libdl support

ld/
* testsuite/lib/ld-lib.exp (check_libdl_available): New function.
* testsuite/ld-elf/shared.exp (run_tests): Split tests which require
dlopen support into "dlopen_run_tests".  These tests include dl1*main
and dl6*main.
(dlopen_run_tests): New and only run it when check_libdl_available
returns true.  XFAIL on *-*-netbsdelf*.

7 years agoRemove unused file_string parameter in gdb_disassembly
Simon Marchi [Thu, 2 Feb 2017 03:54:35 +0000 (22:54 -0500)]
Remove unused file_string parameter in gdb_disassembly

The file_string parameter was added in 8f0eea0 (sorry, no title back
then) and has never actually been used.

gdb/ChangeLog:

* disasm.h (gdb_disassembly): Remove file_string parameter.
* disasm.c (gdb_disassembly): Likewise.
* cli/cli-cmds.c (print_disassembly): Adapt.
* mi/mi-cmd-disas.c (mi_cmd_disassemble): Likewise.
* stack.c (do_gdb_disassembly): Likewise.

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

7 years agoMIPS/LD/testsuite: Correct relocation addends in VxWorks tests
Maciej W. Rozycki [Wed, 1 Feb 2017 22:09:33 +0000 (22:09 +0000)]
MIPS/LD/testsuite: Correct relocation addends in VxWorks tests

Fix commit 171191bac50e ("Add support for STT_IFUNC"),
<https://sourceware.org/ml/binutils/2008-12/msg00052.html>, commit
e04d7088afe0 ("PR ld/14088: Always display addend as signed hex
number"), <https://sourceware.org/ml/binutils/2012-05/msg00123.html> and
commit 343dbc36ffae ("Print addend as signed in objdump"),
<https://sourceware.org/ml/binutils/2012-05/msg00163.html> regressions:

FAIL: VxWorks executable test 1 (dynamic)
FAIL: ld-mips-elf/vxworks-forced-local-1

seen with `mips-vxworks' and `mipsel-vxworks' targets and adjust dump
patterns according to changes made to the presentation of relocation
addends in `readelf -r' and `objdump -r' output.

ld/
* testsuite/ld-mips-elf/vxworks-forced-local-1.d: Correct the
presentation of relocation addends.
* testsuite/ld-mips-elf/vxworks1-lib.rd: Likewise.
* testsuite/ld-mips-elf/vxworks1.dd: Likewise.
* testsuite/ld-mips-elf/vxworks1.rd: Likewise.

7 years agoMIPS/LD/testsuite: Fix a `tls-multi-got-1-1.s' build failure
Maciej W. Rozycki [Wed, 1 Feb 2017 22:08:02 +0000 (22:08 +0000)]
MIPS/LD/testsuite: Fix a `tls-multi-got-1-1.s' build failure

Correct a commit ec9ab52c3217 ("gas: consistently emit diagnostics for
non-zero data emission to .bss/.struct"),
<https://sourceware.org/ml/binutils/2015-12/msg00073.html> regression:

.../ld/testsuite/ld-mips-elf/tls-multi-got-1-1.s: Assembler messages:
.../ld/testsuite/ld-mips-elf/tls-multi-got-1-1.s:39: Error: attempt to store non-zero value in section `.tbss'
ERROR: -EB -march=mips1 -32 -KPIC .../ld/testsuite/ld-mips-elf/tls-multi-got-1-1.s: assembly failed
UNRESOLVED: Shared library with multiple GOTs and TLS

in MIPS target testing and move `tlsvar_ld' to `.tdata' section, in line
with the remaining local dynamic definitions introduced with the set of
tests added with commit f4e584bd00f1 ("TLS support for MIPS"),
<https://sourceware.org/ml/binutils/2005-02/msg00607.html>.

ld/
* testsuite/ld-mips-elf/tls-multi-got-1-1.s: Place `tlsvar_ld'
in `.tdata' section.
* testsuite/ld-mips-elf/tls-multi-got-1.got: Adjust accordingly.
* testsuite/ld-mips-elf/tls-multi-got-1.r: Likewise.

7 years agoBig-endian targets: Don't ignore offset into DW_OP_implicit_value
Andreas Arnez [Wed, 1 Feb 2017 15:59:00 +0000 (16:59 +0100)]
Big-endian targets: Don't ignore offset into DW_OP_implicit_value

When a variable's location is expressed as DW_OP_implicit_value, but the
given value is longer than needed, which bytes should be used?  GDB's
current logic was introduced with a patch from 2011 and uses the "least
significant" bytes:

  https://sourceware.org/ml/gdb-patches/2011-08/msg00123.html

Now consider a sub-value from such a location at a given offset, accessed
through DW_OP_implicit_pointer.  Which bytes should be used for that?  The
patch above *always* uses the last bytes on big-endian targets, ignoring
the offset.

E.g., given the code snippet

  const char foo[] = "Hello, world!";
  const char *a = &foo[0];
  const char *b = &foo[7];

assume that `foo' is described as DW_OP_implicit_value and `a' and `b'
each as DW_OP_implicit_pointer into that value.  Then with current GDB
`*a' and `*b' yield the same result -- the string's zero terminator.

This patch basically reverts the portion of the patch above that deals
with DW_OP_implicit_value.  This fixes the offset handling and also goes
back to dropping the last instead of the first bytes on big-endian targets
if the implicit value is longer than needed.  The latter aspect of the
change probably doesn't matter for actual programs, but simplifies the
logic.

The patch also cleans up the original code a bit and adds appropriate test
cases.

gdb/testsuite/ChangeLog:

* gdb.dwarf2/dw2-op-stack-value.exp: Adjust expected result of
taking a 2-byte value out of a 4-byte DWARF implicit value on
big-endian targets.
* gdb.dwarf2/nonvar-access.exp: Add more comments to existing
logic.  Add test cases for DW_OP_implicit.

gdb/ChangeLog:

* dwarf2loc.c (dwarf2_evaluate_loc_desc_full): For
DWARF_VALUE_LITERAL, no longer ignore the offset on big-endian
targets.  And if the implicit value is longer than needed, extract
the first bytes instead of the "least significant" ones.

7 years agotestsuite: diagnose a running GDB in gdb_skip_xml_tests
Markus Metzger [Tue, 31 Jan 2017 16:13:46 +0000 (17:13 +0100)]
testsuite: diagnose a running GDB in gdb_skip_xml_tests

If GDB is running when gdb_skip_xml_tests is called with
--target_board=native-extended-gdbserer.exp, it fails with:

    (gdb) FAIL: ....exp: set tdesc filename .../trivial.xml (got interactive prompt)
    monitor exit

Diagnose this in gdb_skip_xml_tests to generate a more meaningful error message:

    ERROR: tcl error sourcing ....exp.
    ERROR: GDB must not be running in gdb_skip_xml_tests.
        while executing
    [...]

testsuite/
* lib/gdb.exp (gdb_skip_xml_tests): Error if GDB is running.

7 years agobtrace, testsuite: fix extended-remote fail
Markus Metzger [Thu, 26 Jan 2017 14:07:44 +0000 (15:07 +0100)]
btrace, testsuite: fix extended-remote fail

Parts of gdb.btrace/enable.exp are only valid for native debug.  The check for
skip_gdbserver_tests is done while GDB is running, though, which causes it to
fail with --target_board=native-extended-gdbserver.  Exit GDB before that check.

testsuite/
* gdb.btrace/enable.exp: Call gdb_exit before skip_gdbserver_tests.

7 years agobtrace, testsuite: fix extended-remote non-stop test
Markus Metzger [Thu, 26 Jan 2017 08:27:45 +0000 (09:27 +0100)]
btrace, testsuite: fix extended-remote non-stop test

With --target_board=native-extended-gdbserver non-stop tests are failing with

    UNTESTED: gdb.btrace/non-stop.exp: failed to run to main

Fix that by adding '-ex "set non-stop on"' to GDBFLAGS before restarting.

testsuite/
* gdb.btrace/non-stop.exp: Add '-ex "set non-stop on"' to GDBFLAGS.

7 years agobtrace: add unsupported/untested messages when skipping tests
Markus Metzger [Fri, 9 Dec 2016 12:16:22 +0000 (13:16 +0100)]
btrace: add unsupported/untested messages when skipping tests

We may silently skip gdb.btrace tests if

  - the target does not support record-btrace
  - the target does not support TSX
  - the target does not support gdbserver
  - we fail to compile the test
  - we fail to run to main

Add unsupported/untested messages for each of those.

testsuite/
* gdb.btrace/buffer-size.exp: Add unsupported/untested message if
the test is skipped.
* gdb.btrace/data.exp: Likewise.
* gdb.btrace/delta.exp: Likewise.
* gdb.btrace/dlopen.exp: Likewise.
* gdb.btrace/enable-running.exp: Likewise.
* gdb.btrace/enable.exp: Likewise.
* gdb.btrace/exception.exp: Likewise.
* gdb.btrace/function_call_history.exp: Likewise.
* gdb.btrace/gcore.exp: Likewise.
* gdb.btrace/instruction_history.exp: Likewise.
* gdb.btrace/multi-thread-step.exp: Likewise.
* gdb.btrace/nohist.exp: Likewise.
* gdb.btrace/non-stop.exp: Likewise.
* gdb.btrace/reconnect.exp: Likewise.
* gdb.btrace/record_goto-step.exp: Likewise.
* gdb.btrace/record_goto.exp: Likewise.
* gdb.btrace/rn-dl-bind.exp: Likewise.
* gdb.btrace/segv.exp: Likewise.
* gdb.btrace/step.exp: Likewise.
* gdb.btrace/stepi.exp: Likewise.
* gdb.btrace/tailcall-only.exp: Likewise.
* gdb.btrace/tailcall.exp: Likewise.
* gdb.btrace/tsx.exp: Likewise.
* gdb.btrace/unknown_functions.exp: Likewise.
* gdb.btrace/vdso.exp: Likewise.

7 years agobtrace: allow recording to be started (and stopped) for running threads
Markus Metzger [Wed, 30 Nov 2016 10:05:38 +0000 (11:05 +0100)]
btrace: allow recording to be started (and stopped) for running threads

When recording is started for a running thread, GDB was able to start tracing
but then failed to read registers to insert the initial entry for the current
PC.  We don't really need that initial entry if we don't know where exactly we
started recording.  Skip that step to allow recording to be started while
threads are running.

If we do run into errors, we need to undo the tracing enable to not leak this
thread.  The operation did not complete so our caller won't clean up this
thread.

For the BTRACE_FORMAT_PT btrace format, we don't need that initial entry since
it will be recorded in the trace.  We can omit the call to btrace_add_pc.

gdb/
* btrace.c (btrace_enable): Do not call btrace_add_pc for
BTRACE_FORMAT_PT or if can_access_registers_ptid returns false.
(btrace_fetch): Assert can_access_registers_ptid.
* record-btrace.c (require_btrace_thread, record_btrace_info): Call
validate_registers_access.

testsuite/
* gdb.btrace/enable-running.c: New.
* gdb.btrace/enable-running.exp: New.

7 years agothread: add can_access_registers_ptid
Markus Metzger [Fri, 20 Jan 2017 08:05:03 +0000 (09:05 +0100)]
thread: add can_access_registers_ptid

Add a function can_access_registers_ptid that behaves like
validate_registers_access but returns a boolean value instead of throwing an
exception.

gdb/
* gdbthread.h (can_access_registers_ptid): New.
* thread.c (can_access_registers_ptid): New.

7 years ago[ld, testsuite] Append $board_cflags in one more place in ld-unique/unique.exp
Jiong Wang [Tue, 31 Jan 2017 12:20:48 +0000 (12:20 +0000)]
[ld, testsuite] Append $board_cflags in one more place in ld-unique/unique.exp

ld/
* testsuite/ld-unique/unique.exp (Could not link a dynamic executable):
Append $board_cflags to link commands.

7 years agoFix failing print-memory-usage-1 on Windows
Senthil Kumar Selvaraj [Wed, 1 Feb 2017 06:08:39 +0000 (11:38 +0530)]
Fix failing print-memory-usage-1 on Windows

ld/

2017-01-31  Senthil Kumar Selvaraj <senthilkumar.selvaraj@microchip.com>

* testsuite/ld-scripts/print-memory-usage-1.l: Relax
check for digit in second decimal place.

7 years agoDon't allow mov-to-lea optimization for __ehdr_start.
Cary Coutant [Wed, 1 Feb 2017 00:32:59 +0000 (16:32 -0800)]
Don't allow mov-to-lea optimization for __ehdr_start.

gold/
PR gold/21090
* x86_64.cc (Target_x86_64::can_convert_mov_to_lea): Add check
for predefined symbol.
(Target_x86_64::Relocate::relocate): Fix formatting.

7 years agoPR ld/20828: LD/testsuite: Correct indentation
Maciej W. Rozycki [Tue, 31 Jan 2017 17:59:44 +0000 (17:59 +0000)]
PR ld/20828: LD/testsuite: Correct indentation

ld/
PR ld/20828
* testsuite/ld-elf/shared.exp: Correct PR ld/20828 test
indentation.

7 years ago[ob/pushed] Use gdb_insn_length instead of creating dummy stream
Pedro Alves [Wed, 1 Feb 2017 00:07:50 +0000 (00:07 +0000)]
[ob/pushed] Use gdb_insn_length instead of creating dummy stream

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

* i386-tdep.c (i386_fast_tracepoint_valid_at): Use gdb_insn_length.

7 years agoAutomatic date update in version.in
GDB Administrator [Wed, 1 Feb 2017 00:00:22 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agogdb/mi/mi-interp.c: Fix typos
Pedro Alves [Tue, 31 Jan 2017 17:56:36 +0000 (17:56 +0000)]
gdb/mi/mi-interp.c: Fix typos

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

* mi/mi-interp.c (mi_breakpoint_created, mi_breakpoint_modified):
Fix typos.

7 years agogdb/stack.c: Remove unused mem_fileopen
Pedro Alves [Tue, 31 Jan 2017 17:56:36 +0000 (17:56 +0000)]
gdb/stack.c: Remove unused mem_fileopen

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

* stack.c (print_frame_args): Remove local mem_fileopen stream,
not used.

7 years agogdb/varobj.c: Fix leak
Pedro Alves [Tue, 31 Jan 2017 17:56:36 +0000 (17:56 +0000)]
gdb/varobj.c: Fix leak

Whoops, this function returns a std::string.

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

* varobj.c (varobj_value_get_print_value): Remove xstrdup call.

7 years agogdb: make_scoped_restore and types convertible to T
Pedro Alves [Tue, 31 Jan 2017 17:56:35 +0000 (17:56 +0000)]
gdb: make_scoped_restore and types convertible to T

A following patch will want to do

   string_file str_file;

   scoped_restore save_stdout
    = make_scoped_restore (&gdb_stdout, &str_file);

where gdb_stdout is a ui_file *, and string_file is a type that
inherits from ui_file, but that doesn't compile today:

  src/gdb/top.c: In function ‘std::__cxx11::string execute_command_to_string(char*, int)’:
  src/gdb/top.c:710:50: error: no matching function for call to ‘make_scoped_restore(ui_file**, string_file*)’
       = make_scoped_restore (&gdb_stdout, &str_file);
    ^
  [...]
  In file included from src/gdb/utils.h:25:0,
   from src/gdb/defs.h:732,
   from src/gdb/top.c:20:
  src/gdb/common/scoped_restore.h:94:24: note: candidate: template<class T> scoped_restore_tmpl<T> make_scoped_restore(T*, T)
   scoped_restore_tmpl<T> make_scoped_restore (T *var, T value)
  ^
  src/gdb/common/scoped_restore.h:94:24: note:   template argument deduction/substitution failed:
  src/gdb/top.c:710:50: note:   deduced conflicting types for parameter ‘T’ (‘ui_file*’ and ‘string_file*’)
       = make_scoped_restore (&gdb_stdout, &str_file);
    ^

This commit makes code such as the above possible.

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

* common/scoped_restore.h
(scoped_restore_tmpl::scoped_restore_tmpl): Template on T2, and
change the value's parameter type to T2.
(make_scoped_restore): Likewise.

7 years agoFix buffer overflows in ld when printing translated strings.
Nick Clifton [Tue, 31 Jan 2017 12:07:04 +0000 (12:07 +0000)]
Fix buffer overflows in ld when printing translated strings.

ld * ldmain.c (add_archive_element): Eliminate string buffer.
* ldlang.c (lang_print_asneeded): Likewise.

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

7 years agoMIPS: Add options to control branch ISA checks
Maciej W. Rozycki [Mon, 30 Jan 2017 17:11:22 +0000 (17:11 +0000)]
MIPS: Add options to control branch ISA checks

Complement commit 9d862524f6ae ("MIPS: Verify the ISA mode and alignment
of branch and jump targets") and add GAS and LD options to control the
checks for invalid branches between ISA modes introduced there, to help
with some handwritten code lacking `.insn' annotation for labels used as
branch targets and code produced by older versions of GCC which suffers
from the issue with branches to code that has been optimized away,
addressed with GCC commit 242424 ("MIPS/GCC: Mark trailing labels with
`.insn'"), <https://gcc.gnu.org/ml/gcc-patches/2016-11/msg01061.html>.

bfd/
* elfxx-mips.h (_bfd_mips_elf_insn32): Rename prototype to...
(_bfd_mips_elf_linker_flags): ... this.  Add another parameter.
* elfxx-mips.c (mips_elf_link_hash_table): Add
`ignore_branch_isa' member.
(mips_elf_perform_relocation): Do not treat an ISA mode mismatch
in branch relocation calculation as an error if
`ignore_branch_isa' has been set.
(_bfd_mips_elf_insn32): Rename to...
(_bfd_mips_elf_linker_flags): ... this.  Rename the `on'
parameter to `insn32' and add an `ignore_branch_isa' parameter.
Handle the new parameter.

gas/
* config/tc-mips.c (mips_ignore_branch_isa): New variable.
(options): Add OPTION_IGNORE_BRANCH_ISA and
OPTION_NO_IGNORE_BRANCH_ISA enum values.
(md_longopts): Add "mignore-branch-isa" and
"mno-ignore-branch-isa" options.
(md_parse_option): Handle OPTION_IGNORE_BRANCH_ISA and
OPTION_NO_IGNORE_BRANCH_ISA.
(fix_bad_cross_mode_branch_p): Return FALSE if
`mips_ignore_branch_isa' has been set.
(md_show_usage): Add `-mignore-branch-isa' and
`-mno-ignore-branch-isa'.

* doc/as.texinfo (Target MIPS options): Add
`-mignore-branch-isa' and `-mno-ignore-branch-isa' options.
(-mignore-branch-isa, -mno-ignore-branch-isa): New options.
* doc/c-mips.texi (MIPS Options): Add `-mignore-branch-isa' and
`-mno-ignore-branch-isa' options.

* testsuite/gas/mips/branch-local-ignore-2.d: New test.
* testsuite/gas/mips/branch-local-ignore-3.d: New test.
* testsuite/gas/mips/branch-local-ignore-n32-2.d: New test.
* testsuite/gas/mips/branch-local-ignore-n32-3.d: New test.
* testsuite/gas/mips/branch-local-ignore-n64-2.d: New test.
* testsuite/gas/mips/branch-local-ignore-n64-3.d: New test.
* testsuite/gas/mips/mips.exp: Run the new tests.

ld/
* emultempl/mipself.em (ignore_branch_isa): New variable.
(mips_create_output_section_statements): Rename
`_bfd_mips_elf_insn32' called to `_bfd_mips_elf_linker_flags',
add `ignore_branch_isa' argument.
(PARSE_AND_LIST_PROLOGUE): Add OPTION_IGNORE_BRANCH_ISA and
OPTION_NO_IGNORE_BRANCH_ISA enum values.
(PARSE_AND_LIST_LONGOPTS): Add "ignore-branch-isa" and
"no-ignore-branch-isa" options.
(PARSE_AND_LIST_OPTIONS): Add `--ignore-branch-isa' and
`--no-ignore-branch-isa'.
(PARSE_AND_LIST_ARGS_CASES): Handle OPTION_IGNORE_BRANCH_ISA and
OPTION_NO_IGNORE_BRANCH_ISA.

* ld.texinfo (Options specific to MIPS targets): Add
`--ignore-branch-isa' and `--no-ignore-branch-isa' options.
(ld and the MIPS family): Likewise.

* testsuite/ld-mips-elf/bal-jalx-pic-ignore.d: New test.
* testsuite/ld-mips-elf/bal-jalx-pic-ignore-n32.d: New test.
* testsuite/ld-mips-elf/bal-jalx-pic-ignore-n64.d: New test.
* testsuite/ld-mips-elf/unaligned-branch-ignore-2.d: New test.
* testsuite/ld-mips-elf/unaligned-branch-ignore-r6-1: New test.
* testsuite/ld-mips-elf/unaligned-branch-ignore-mips16: New
test.
* testsuite/ld-mips-elf/unaligned-branch-ignore-micromips: New
test.
* testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.

7 years agoMIPS/GAS/testsuite: Convert branch local list tests to dump tests
Maciej W. Rozycki [Mon, 30 Jan 2017 17:10:31 +0000 (17:10 +0000)]
MIPS/GAS/testsuite: Convert branch local list tests to dump tests

gas/
* testsuite/gas/mips/branch-local-2.d: New test.
* testsuite/gas/mips/branch-local-3.d: New test.
* testsuite/gas/mips/branch-local-n32-2.d: New test.
* testsuite/gas/mips/branch-local-n32-3.d: New test.
* testsuite/gas/mips/branch-local-n64-2.d: New test.
* testsuite/gas/mips/branch-local-n64-3.d: New test.
* testsuite/gas/mips/mips.exp: Fold corresponding list tests
into the new tests.

7 years agoAutomatic date update in version.in
GDB Administrator [Mon, 30 Jan 2017 00:00:21 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoFix another typo in the last ChangeLog entry.
Hans-Peter Nilsson [Sun, 29 Jan 2017 15:15:16 +0000 (16:15 +0100)]
Fix another typo in the last ChangeLog entry.

Gah!  Though this time I blame autocompletion.

7 years agoFix typo in ChangeLog
Hans-Peter Nilsson [Sun, 29 Jan 2017 13:18:13 +0000 (14:18 +0100)]
Fix typo in ChangeLog

7 years agoPR binutils/19935
Hans-Peter Nilsson [Sun, 29 Jan 2017 13:13:38 +0000 (14:13 +0100)]
PR binutils/19935

Fix long-standing buglet and fallout from now-default initfini-array.
* emulparams/criself.sh (USER_LABEL_PREFIX): Define.
(OTHER_READONLY_SECTIONS, ENTRY): Delete now-redunant defines.

7 years agoFix long-standing buglet and fallout from now-default initfini-array.
Hans-Peter Nilsson [Sun, 29 Jan 2017 12:53:58 +0000 (13:53 +0100)]
Fix long-standing buglet and fallout from now-default initfini-array.

* emulparams/criself.sh (USER_LABEL_PREFIX): Define.
(OTHER_READONLY_SECTIONS, ENTRY): Delete now-redunant defines.

7 years agoAutomatic date update in version.in
GDB Administrator [Sun, 29 Jan 2017 00:00:21 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoAutomatic date update in version.in
GDB Administrator [Sat, 28 Jan 2017 00:00:27 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years ago[ld, testsuite] XFAIL "pr20995-2", "Build pr20995-2.so" on arm*-*-eabi*
Jiong Wang [Fri, 27 Jan 2017 23:06:28 +0000 (23:06 +0000)]
[ld, testsuite] XFAIL "pr20995-2", "Build pr20995-2.so" on arm*-*-eabi*

ld/
* testsuite/ld-elf/elf.exp ("pr20995-2", "Build pr20995-2.so"): XFAIL on
arm*-*-eabi*.

Some technical discussions about the reason of this XFAIL are available at

  https://sourceware.org/ml/binutils/2017-01/msg00441.html

7 years agoamd64-linux: expose system register FS_BASE and GS_BASE for Linux.
Walfred Tedeschi [Fri, 27 Jan 2017 14:19:14 +0000 (15:19 +0100)]
amd64-linux: expose system register FS_BASE and GS_BASE for Linux.

This patch allows examination of the registers FS_BASE and GS_BASE
for Linux Systems running on 64bit. Tests for simple read and write
of the new registers is also added with this patch.

2017-01-27  Walfred Tedeschi  <walfred.tedeschi@intel.com>
    Richard Henderson  <rth@redhat.com>

gdb/ChangeLog:

* amd64-linux-nat.c (PTRACE_ARCH_PRCTL): New define.
(amd64_linux_fetch_inferior_registers): Add case to fetch FS_BASE
GS_BASE for older kernels.
(amd64_linux_store_inferior_registers): Add case to store FS_BASE
GS_BASE for older kernels.
* amd64-linux-tdep.c (amd64_linux_gregset_reg_offset): Add FS_BASE
and GS_BASE to the offset table.
(amd64_linux_register_reggroup_p): Add FS_BASE and GS_BASE to the
system register group.
* amd64-nat.c (amd64_native_gregset_reg_offset): Implements case
for older kernels.
* amd64-tdep.c (amd64_init_abi): Add segment registers for the
amd64 ABI.
* amd64-tdep.h (amd64_regnum): Add AMD64_FSBASE_REGNUM and
AMD64_GSBASE_REGNUM.
(AMD64_NUM_REGS): Set to AMD64_GSBASE_REGNUM + 1.
* features/Makefile (amd64-linux.dat, amd64-avx-linux.dat)
(amd64-mpx-linux.dat, amd64-avx512-linux.dat, x32-linux.dat)
(x32-avx-linux.dat, x32-avx512-linux.dat): Add
i386/64bit-segments.xml in those rules.
* features/i386/64bit-segments.xml: New file.
* features/i386/amd64-avx-mpx-linux.xml: Add 64bit-segments.xml.
* features/i386/amd64-avx-linux.xml: Add 64bit-segments.xml.
* features/i386/amd64-avx512-linux.xml: Add 64bit-segments.xml.
* features/i386/amd64-mpx-linux.xml: Add 64bit-segments.xml.
* features/i386/x32-avx512-linux.xml: Add 64bit-segments.xml.
* features/i386/x32-avx-linux.xml: Add 64bit-segments.xml.
* features/i386/amd64-linux.xml: Add 64bit-segments.xml.
* features/i386/amd64-avx-linux.c: Regenerated.
* features/i386/amd64-avx-mpx-linux.c: Regenerated.
* features/i386/amd64-avx-mpx.c: Regenerated.
* features/i386/amd64-avx512-linux.c: Regenerated.
* features/i386/amd64-linux.c: Regenerated.
* features/i386/amd64-mpx-linux.c: Regenerated.
* features/i386/i386-avx-mpx-linux.c: Regenerated.
* features/i386/i386-avx-mpx.c: Regenerated.
* features/i386/x32-avx-linux.c: Regenerated.
* features/i386/x32-avx512-linux.c: Regenerated.
* regformats/i386/amd64-avx-linux.dat: Regenerated.
* regformats/i386/amd64-avx-mpx-linux.dat: Regenerated.
* regformats/i386/amd64-avx512-linux.dat: Regenerated.
* regformats/i386/amd64-linux.dat: Regenerated.
* regformats/i386/amd64-mpx-linux.dat: Regenerated.
* regformats/i386/x32-avx-linux.dat: Regenerated.
* regformats/i386/x32-avx512-linux.dat: Regenerated.
* regformats/i386/x32-linux.dat: Regenerated.

gdb/doc/ChangeLog:

* gdb.texinfo (i386 Features): Add system segment registers
as feature.

gdb/gdbserver/ChangeLog:

* linux-x86-low.c (x86_64_regmap): Add fs_base and gs_base
to the register table.
(x86_fill_gregset): Add support for old kernels for the
fs_base and gs_base system registers.
(x86_store_gregset): Likewise.
* configure.srv (srv_i386_64bit_xmlfiles): Add 64bit-segments.xml.

gdb/testsuite/ChangeLog:

* gdb.arch/amd64-gs_base.c: New file.
* gdb.arch/amd64-gs_base.exp: New file.

Change-Id: I2e0eeb93058a2320d4d3b045082643cfe4aff963
Signed-off-by: Walfred Tedeschi <walfred.tedeschi@intel.com>
7 years agoamd64: simplify addition of new general registers.
Walfred Tedeschi [Fri, 27 Jan 2017 14:19:13 +0000 (15:19 +0100)]
amd64: simplify addition of new general registers.

The purpose of this patch is only simplify the addition of new registers.
ORIG_RAX is kept as last register and any addition is done right before it.

2017-01-27  Walfred Tedeschi  <walfred.tedeschi@intel.com>

* amd64-linux-tdep.h (AMD64_LINUX_ORIG_RAX_REGNUM):
Set to AMD64_NUM_REGS.

7 years agoamd64: remove additional comparison for validity of a register number.
Walfred Tedeschi [Fri, 27 Jan 2017 14:19:12 +0000 (15:19 +0100)]
amd64: remove additional comparison for validity of a register number.

Second part of the && is already guaranteed in the "regnum < num_regs"
due to comparison above.

2017-01-27  Walfred Tedeschi  <walfred.tedeschi@intel.com>

* amd64-nat.c (amd64_native_gregset_reg_offset): Simplify logic
that checks validity of a register number.

7 years agogdbserver-amd64: add HAVE_STRUCT_USER_REGS_STRUCT_(GS|FS)_BASE for gdbserver.
Walfred Tedeschi [Fri, 27 Jan 2017 14:19:12 +0000 (15:19 +0100)]
gdbserver-amd64: add HAVE_STRUCT_USER_REGS_STRUCT_(GS|FS)_BASE for gdbserver.

The macros mentioned in the title were set only for GDB. In gdbserver they
were not set until now.  To align the code in GDB and gdbserver these macros
are also added into gdbserver, enabling read and write of gs_base and fs_base
registers from the system in new and old kernels.

2017-01-27  Walfred Tedeschi  <walfred.tedeschi@intel.com>

gdb/gdbserver/ChangeLog:

     * configure.ac: Check if the fs_base and gs_base members of
     `struct user_regs_struct' exist.
     * config.in: Regenerated.
     * configure: Likewise.

7 years agoUpdate description of the -plugin option used by the linker, ar and nm.
Dilyan Palauzov [Fri, 27 Jan 2017 13:20:24 +0000 (13:20 +0000)]
Update description of the -plugin option used by the linker, ar and nm.

PR 20343
ld * ld.texinfo (Options): Extend documentation of the --plugin
option.  Include a description of where the plugins should be
located.

binutils* doc/binutils.texi (ar): Extend documentation of the --plugin
option.  Include a description of where the plugins should be
located.
(nm): Likewise.

7 years agoFix disassembling of TIC6X parallel instructions where the previous fetch packet...
Alexis Deruell [Fri, 27 Jan 2017 12:00:55 +0000 (12:00 +0000)]
Fix disassembling of TIC6X parallel instructions where the previous fetch packet ended with a 32-bit insn.

PR 21056
opcodes * tic6x-dis.c (print_insn_tic6x): Correct displaying of parallel
instructions when the previous fetch packet ends with a 32-bit
instruction.

gas * testsuite/gas/tic6x/insns16-parallel.s: New test case.
* testsuite/gas/tic6x/insns16-parallel.d: New test driver.

7 years agoAdd Serbian translation for the LD directory.
Nick Clifton [Fri, 27 Jan 2017 11:27:50 +0000 (11:27 +0000)]
Add Serbian translation for the LD directory.

ld * po/sr.po: New Serbian translation.
* configure.ac (ALL_LINGUAS): Add sr.
* configure: Regenerate.

7 years agoFix PTRACE_GETREGSET failure for compat inferiors on arm64
Kees Cook [Fri, 27 Jan 2017 11:14:47 +0000 (11:14 +0000)]
Fix PTRACE_GETREGSET failure for compat inferiors on arm64

When running a 32-bit ARM inferior with a 32-bit ARM GDB on a 64-bit
AArch64 host, only VFP registers (NT_ARM_VFP) are available. The FPA
registers (NT_PRFPREG) are not available so GDB must not request them, as
this will fail with -EINVAL.  This is most noticeably exposed when running
"generate-core-file":

(gdb) generate-core-file myprog.core
Unable to fetch the floating point registers.: Invalid argument.

ptrace(PTRACE_GETREGSET, 27642, NT_FPREGSET, 0xffcc67f0) = -1 EINVAL (Invalid argument)

gdb/ChangeLog:

2017-01-27  Kees Cook  <keescook@google.com>

* gdb/arm-linux-nat.c (arm_linux_fetch_inferior_registers): Call
fetch_fpregs if target has fpa registers.
(arm_linux_store_inferior_registers): Call store_fpregs if target
has fpa registers.

7 years agoFix unused-but-set warning in elf32-cris.c:elf_cris_finish_dynamic_symbol
Hans-Peter Nilsson [Fri, 27 Jan 2017 08:12:14 +0000 (09:12 +0100)]
Fix unused-but-set warning in elf32-cris.c:elf_cris_finish_dynamic_symbol

* elf32-cris.c (elf_cris_finish_dynamic_symbol): Remove now unused
local variable dynobj.

7 years agoFix PR ld/20995 for cris-linux
Hans-Peter Nilsson [Fri, 27 Jan 2017 00:50:06 +0000 (01:50 +0100)]
Fix PR ld/20995 for cris-linux

PR ld/20995
* elf32-cris.c (elf_cris_size_dynamic_sections): Handle sdynrelro.
(elf_cris_adjust_dynamic_symbol): Place variables copied into the
executable from read-only sections into sdynrelro.
(elf_cris_finish_dynamic_symbol): Select sreldynrelro for
dynamic relocs in sdynrelro.
(elf_backend_want_dynrelro): Define.