1. Feb 10, 2017
  2. Feb 09, 2017
    • Gary Benson's avatar
      Fix NULL pointer dereference · ff6fa247
      Gary Benson authored
      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.
      ff6fa247
    • GDB Administrator's avatar
      Automatic date update in version.in · 9d5c5dd7
      GDB Administrator authored
      9d5c5dd7
    • Andrew Burgess's avatar
      ld/arc: Change default linker emulation for nps400 · d7488716
      Andrew Burgess authored
      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.
      d7488716
    • Pedro Alves's avatar
      Eliminate interp::quiet_p · a474bd8e
      Pedro Alves authored
      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
      a474bd8e
    • Jerome Guitton's avatar
      Command abbreviation in define · 604c4576
      Jerome Guitton authored
      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.
      604c4576
    • Jerome Guitton's avatar
      Command names: make them case sensitive · 3d7b173c
      Jerome Guitton authored
      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.
      3d7b173c
  3. Feb 08, 2017
  4. Feb 07, 2017
    • Sheldon Lobo's avatar
      bfd: Fix objdump --dynamic-reloc for SPARC 64-bit to show symbol names. · 3d044c0c
      Sheldon Lobo authored
      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.
      3d044c0c
    • GDB Administrator's avatar
      Automatic date update in version.in · 8a78ba5c
      GDB Administrator authored
      8a78ba5c
  5. Feb 06, 2017
    • Jiong Wang's avatar
      [ld, testsuite] Don't print to stdout for "readelf -w" to avoid buffer overflow · 65f90e82
      Jiong Wang authored
      ld/
      	* testsuite/ld-elf/compress.exp: Don't print to stdout for all
      	"readelf -w".
      65f90e82
    • Claudiu Zissulescu's avatar
      [ARC] Provide an interface to decode ARC instructions. · 6ec7c1ae
      Claudiu Zissulescu authored
      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
      6ec7c1ae
    • Luis Machado's avatar
      [BZ 21005] Add support for Intel 64 rdrand and rdseed record/replay · 20b477a7
      Luis Machado authored
      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.
      20b477a7
    • Ivo Raisr's avatar
      gdb: provide and use sparc{32,64} target description XML files. · 3f7b46f2
      Ivo Raisr authored
      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.
      3f7b46f2
    • GDB Administrator's avatar
      Automatic date update in version.in · de32a80f
      GDB Administrator authored
      de32a80f
  6. Feb 05, 2017
  7. Feb 04, 2017
    • Tom Tromey's avatar
      Fix ptype of single-member Rust enums · f0fd41c1
      Tom Tromey authored
      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.
      f0fd41c1
    • GDB Administrator's avatar
      Automatic date update in version.in · e25dae2c
      GDB Administrator authored
      e25dae2c
    • Pedro Alves's avatar
      C++-fy struct interp/cli_interp/tui_interp/mi_interp · d6f9b0fb
      Pedro Alves authored
      - 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".
      d6f9b0fb
  8. Feb 03, 2017
    • Alan Modra's avatar
      [GOLD] PowerPC64 TOC indirect to TOC relative segfault · e666304e
      Alan Modra authored
      	* powerpc.cc (Powerpc_relobj::make_toc_relative): Don't crash
      	when no .toc section exists.
      e666304e
    • Nick Clifton's avatar
      Fix compile time warning messages when compiling binutils with gcc 7.0.1. · 1b7e3d2f
      Nick Clifton authored
      	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.
      1b7e3d2f
    • Tom Tromey's avatar
      Use bool in Rust code · 65c40c95
      Tom Tromey authored
      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.
      65c40c95
    • Tom Tromey's avatar
      Reindent rust-lang.c · b50f188d
      Tom Tromey authored
      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.
      b50f188d
    • Tom Tromey's avatar
      Use std::string in Rust code · 03c85b11
      Tom Tromey authored
      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.
      03c85b11
    • GDB Administrator's avatar
      Automatic date update in version.in · 73dceb99
      GDB Administrator authored
      73dceb99
    • Pedro Alves's avatar
      Fix "maintenance selftest" printing stray instructions · 9b6da501
      Pedro Alves authored
      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.
      9b6da501
    • Pedro Alves's avatar
      Fix "maintenance selftest" printing stray instructions · b1ace6bd
      Pedro Alves authored
      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.
      b1ace6bd
    • Pedro Alves's avatar
      struct mi_interp: Remove unused fields · ec4cb20b
      Pedro Alves authored
      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.
      ec4cb20b
    • Maciej W. Rozycki's avatar
      MIPS/BFD: Respect the ELF gABI dynamic symbol table sort requirement · e17b0c35
      Maciej W. Rozycki authored
      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'.
      e17b0c35
    • Maciej W. Rozycki's avatar
      MIPS/BFD: Use `bfd_size_type' for dynamic symbol table indices · 55f8b9d2
      Maciej W. Rozycki authored
      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.
      55f8b9d2
    • Maciej W. Rozycki's avatar
      MIPS/BFD: Streamline hash table references in `mips_elf_sort_hash_table' · 0f8c4b60
      Maciej W. Rozycki authored
      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.
      0f8c4b60
    • Maciej W. Rozycki's avatar
      MIPS/BFD: Fix assertion in `mips_elf_sort_hash_table' · 17a80fa8
      Maciej W. Rozycki authored
      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.
      17a80fa8
    • Maciej W. Rozycki's avatar
      CRIS/LD/testsuite: tls-err-20x.d: Fix a typo, s/n/\n/ · fa93e3d3
      Maciej W. Rozycki authored
      	ld/
      	* testsuite/ld-cris/tls-err-20x.d: Fix a typo, s/n/\n/.
      fa93e3d3
    • Maciej W. Rozycki's avatar
      LD/testsuite: ld-lib.exp: Fix a typo, s/regexp/regex/ · 2e9af2d0
      Maciej W. Rozycki authored
      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/.
      2e9af2d0
    • Maciej W. Rozycki's avatar
      BFD: Wrap overlong error handler call line in `elf_gc_sweep' · 8f56d4fd
      Maciej W. Rozycki authored
      	bfd/
      	* elflink.c (elf_gc_sweep): Wrap overlong line.
      8f56d4fd
    • Maciej W. Rozycki's avatar
      MIPS/GAS/doc: Include MIPS options in the man page · 73201331
      Maciej W. Rozycki authored
      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.
      73201331
    • Pedro Alves's avatar
      Move "tee" building down to interpreter::set_logging_proc · 616268b6
      Pedro Alves authored
      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.
      616268b6