deliverable/binutils-gdb.git
9 years agoIn a couple functions (type_update_when_use_rtti_test and
Luis Machado [Tue, 17 Jun 2014 09:42:23 +0000 (10:42 +0100)] 
In a couple functions (type_update_when_use_rtti_test and
skip_type_update_when_not_use_rtti_test) the testcase assumes an
uninitialized object has a specific type. In particular, 'ptr' and
's'.

In reality the compiler is free to do what it wants with that
uninitialized variable, even initialize it beforehand with the future
assignment's value.  This is exactly what happens on some targets.

ptr should have type 'Base *', but it really has type 'Derived *'
because it is already initialized (earlier) by the compiler. The same
thing happens to 's'.

The following patch addresses this by explicitly initializing those
variables so the compiler doesn't optimize their assignments and GDB
can print their correct values.

2014-06-17  Luis Machado  <lgustavo@codesourcery.com>

* gdb.mi/mi-var-rtti.cc (type_update_when_use_rtti_test):
Initialize ptr and S explicitly.
(skip_type_update_when_not_use_rtti_test): Likewise.

9 years agogas/ARM: Misses deprecated IT instruction warning for ARMv8
Jiong Wang [Tue, 17 Jun 2014 09:06:00 +0000 (10:06 +0100)] 
gas/ARM: Misses deprecated IT instruction warning for ARMv8

  Add sp increment and decrement to ARMv8 IT block deprecate
  pattern.

  gas/
    * config/tc-arm.c (depr_it_insns): New check for inc/dec sp.

  gas/testsuite/
    * gas/arm/armv8-a-it-bad.s: New check for inc/dec sp.
    * gas/arm/armv8-a-it-bad.l: Likewise.

9 years agodaily update
Alan Modra [Tue, 17 Jun 2014 00:01:07 +0000 (09:31 +0930)] 
daily update

9 years agoGAS: Fix CRIS double-error reports caused by recent generic GAS changes.
Hans-Peter Nilsson [Mon, 16 Jun 2014 22:56:01 +0000 (00:56 +0200)] 
GAS: Fix CRIS double-error reports caused by recent generic GAS changes.

9 years agoFix for PR mi/15863
Keith Seitz [Wed, 11 Jun 2014 20:26:50 +0000 (13:26 -0700)] 
Fix for PR mi/15863

If an MI client creates a varobj and attempts to update the root
/before/ the inferior is started, gdb will throw an internal error:

(gdb)
-var-create * - batch_flag
^done,name="var1",numchild="0",value="0",type="int",has_more="0"
(gdb)
-var-update var1
^done,changelist=[]
(gdb)
-var-update *
~"../../src/gdb/thread.c:628: internal-error: is_thread_state: Assertion `tp' failed.\nA problem internal to GDB has been detected,\nfurther debugging may prove unreliable.\nQuit this debugging session? "
~"(y or n) "

The function that handles the varobj update in the failing case,
mi_cmd_var_udpate_iter, checks if the thread/inferior is stopped before
attempting to update the varobj. It calls is_stopped (inferior_ptid)
which calls is_thread_state:

    tp = find_thread_ptid (ptid);
    gdb_assert (tp);

When there is no inferior, ptid is null_ptid, and find_thread_ptid (null_ptid)
returns NULL and the assertion is triggered.

This patch changes mi_cmd_var_update_iter to behave the same way
"-var-update var1" does: by calling the thread "stopped" if
there is no inferior (and thereby calling varobj_update_one).

ChangeLog
2014-06-16  Keith Seitz  <keiths@redhat.com>

PR mi/15863
* mi/mi-cmd-var.c (mi_cmd_var_update_iter): Do not attempt
to update the varobj if inferior_ptid is null_ptid.

testsuite/ChangeLog
2014-06-16  Keith Seitz  <keiths@redhat.com>

PR mi/15863
* gdb.mi/mi-var-cmd.exp: Add test for -var-update before
the inferior is started.

9 years agoFixes a problem exposed by the aarcg64/illegal.s test case - where the assembler was
Nick Clifton [Mon, 16 Jun 2014 16:37:46 +0000 (17:37 +0100)] 
Fixes a problem exposed by the aarcg64/illegal.s test case - where the assembler was
generating too many error messages.

* config/tc-aarch64.c (md_apply_fix): Ignore unused relocs.

9 years agoconstify to_info_proc and friends
Tom Tromey [Fri, 6 Jun 2014 19:38:16 +0000 (13:38 -0600)] 
constify to_info_proc and friends

This makes a parameter of to_info_proc const and then fixes up some
fallout, including parameters in a couple of gdbarch methods.

I could not test the procfs.c change.  I verified it by inspection.
If this causes an error here, it will be trivial to fix.

2014-06-16  Tom Tromey  <tromey@redhat.com>

* target.h (struct target_ops) <to_info_proc>: Make parameter
const.
(target_info_proc): Update.
* target.c (target_info_proc): Make "args" const.
* procfs.c (procfs_info_proc): Update.
* linux-tdep.c (linux_info_proc): Update.
(linux_core_info_proc_mappings): Make "args" const.
(linux_core_info_proc): Update.
* gdbarch.sh (info_proc, core_info_proc): Make "args" const.
* gdbarch.c: Rebuild.
* gdbarch.h: Rebuild.
* corelow.c (core_info_proc): Update.

9 years agoconstify to_disconnect
Tom Tromey [Fri, 6 Jun 2014 19:26:53 +0000 (13:26 -0600)] 
constify to_disconnect

This constifies an parameter of to_disconnect and updates
target_disconnect as well.

2014-06-16  Tom Tromey  <tromey@redhat.com>

* target.h (struct target_ops) <to_disconnect>: Make parameter
const.
(target_disconnect): Update.
* target.c (target_disconnect): Make "args" const.
* target-delegates.c: Rebuild.
* remote.c (remote_disconnect): Update.
* record.h (record_disconnect): Update.
* record.c (record_disconnect): Update.
* inf-child.c (inf_child_disconnect): Update.

9 years agoconstify to_rcmd
Tom Tromey [Fri, 6 Jun 2014 19:19:53 +0000 (13:19 -0600)] 
constify to_rcmd

This makes the "command" parameter of the to_rcmd target method const.

2014-06-16  Tom Tromey  <tromey@redhat.com>

* target.h (struct target_ops) <to_rcmd>: Make "command" const.
* target.c (debug_to_rcmd, default_rcmd): Update.
* target-delegates.c: Rebuild.
* remote.c (remote_rcmd): Update.
* monitor.c (monitor_rcmd): Update.

9 years agoThis fixes the aarch64 assembler so that it will generate error messages when
Jiong Wang [Mon, 16 Jun 2014 16:22:19 +0000 (17:22 +0100)] 
This fixes the aarch64 assembler so that it will generate error messages when
a syntax error is detected in an optional operand.

  * config/tc-aarch64.c (END_OF_INSN): New macro.
  (parse_operands): Handle operand given and be in wrong
  format when operand is optional.

  * gas/aarch64/diagnostic.s: New test patterns.
  * gas/aarch64/diagnostic.l: Likewise.

9 years agold/ARM: Fix IFUNC and TLS descriptors in the same shared object
Will Newton [Mon, 16 Jun 2014 14:49:07 +0000 (15:49 +0100)] 
ld/ARM: Fix IFUNC and TLS descriptors in the same shared object

Combining TLS descriptors and GNU indirect functions in the same
object could lead to assertions or multiple dynamic relocations
for the same GOT slot. Fix the bookkeeping so this doesn't happen.

This allows building and make checking glibc with -mtls-dialect=gnu2.

bfd/ChangeLog:

2014-06-16  Will Newton  <will.newton@linaro.org>

* elf32-arm.c (elf32_arm_allocate_plt_entry): Increment
htab->next_tls_desc_index in the non-IPLT case.
Calculate GOT offset correctly for the non-IPLT case.
(allocate_dynrelocs_for_symbol): Don't increment
htab->next_tls_desc_index here.

ld/testsuite/ChangeLog:

2014-06-16  Will Newton  <will.newton@linaro.org>

* ld-arm/arm-elf.exp: Add ifunc-gdesc test.
* ld-arm/ifunc-gdesc.r: New file.
* ld-arm/ifunc-gdesc.s: Likewise.
* ld-arm/ifunc-gdesc.ver: Likewise.

9 years ago"$ gdb PROGRAM" vs "(gdb) file PROGRAM" difference; warn on failure to remove breakpoint.
Pedro Alves [Mon, 16 Jun 2014 14:38:13 +0000 (15:38 +0100)] 
"$ gdb PROGRAM" vs "(gdb) file PROGRAM" difference; warn on failure to remove breakpoint.

Turns out there's a difference between loading the program with "gdb
PROGRAM", vs loading it with "(gdb) file PROGRAM".  The latter results
in the objfile ending up with OBJF_USERLOADED set, while not with the
former.  (That difference seems bogus, but still that's not the point
of this patch.  We can revisit that afterwards.)

The new code that suppresses breakpoint removal errors for
add-symbol-file objects ends up being too greedy:

      /* In some cases, we might not be able to remove a breakpoint in
         a shared library that has already been removed, but we have
         not yet processed the shlib unload event.  Similarly for an
         unloaded add-symbol-file object - the user might not yet have
         had the chance to remove-symbol-file it.  shlib_disabled will
         be set if the library/object has already been removed, but
         the breakpoint hasn't been uninserted yet, e.g., after
         "nosharedlibrary" or "remove-symbol-file" with breakpoints
         always-inserted mode.  */
      if (val
          && (bl->loc_type == bp_loc_software_breakpoint
              && (bl->shlib_disabled
                  || solib_name_from_address (bl->pspace, bl->address)
                  || userloaded_objfile_contains_address_p (bl->pspace,
                                                            bl->address))))
        val = 0;

as it turns out that OBJF_USERLOADED can be set for objfiles loaded by
some other means not add-symbol-file.  In this case, symbol-file (or
"file", which is really just "exec-file"+"symbol-file").

Recall that add-symbol-file is documented as:

 (gdb) help add-symbol-file
 Load symbols from FILE, assuming FILE has been dynamically loaded.
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

And it's the "dynamically loaded" aspect that the breakpoint.c code
cares about.  So make add-symbol-file set OBJF_SHARED on its objfiles
too, and tweak the breakpoint.c code to look for OBJF_SHARED instead
of OBJF_USERLOADED.

This restores back the missing breakpoint removal warning when we let
sss-bp-on-user-bp-2.exp run on native GNU/Linux
(https://sourceware.org/ml/gdb-patches/2014-06/msg00335.html):

 (gdb) PASS: gdb.base/sss-bp-on-user-bp-2.exp: define stepi_del_break
 stepi_del_break
 warning: Error removing breakpoint 3
 (gdb) FAIL: gdb.base/sss-bp-on-user-bp-2.exp: stepi_del_break

I say "restores" because this was GDB's behavior in 7.7 and earlier.

And, likewise, "file" with no arguments only started turning
breakpoints set in the main executable to "<pending>" with the
remote-symbol-file patch (63644780).  The old behavior is now
restored, and we break-unload-file.exp test now exercizes both "gdb;
file PROGRAM" and "gdb PROGRAM".

gdb/
2014-06-16  Pedro Alves  <palves@redhat.com>

* breakpoint.c (insert_bp_location, remove_breakpoint_1): Adjust.
(disable_breakpoints_in_freed_objfile): Skip objfiles that don't
have OBJF_SHARED set.
* objfiles.c (userloaded_objfile_contains_address_p): Rename to...
(shared_objfile_contains_address_p): ... this.  Check OBJF_SHARED
instead of OBJF_USERLOADED.
* objfiles.h (OBJF_SHARED): Update comment.
(userloaded_objfile_contains_address_p): Rename to ...
(shared_objfile_contains_address_p): ... this, and update
comments.
* symfile.c (add_symbol_file_command): Also set OBJF_SHARED in the
new objfile.
(remove_symbol_file_command): Skip objfiles that don't have
OBJF_SHARED set.

gdb/testsuite/
2014-06-16  Pedro Alves  <palves@redhat.com>

* gdb.base/break-main-file-remove-fail.c: New file.
* gdb.base/break-main-file-remove-fail.exp: New file.
* gdb.base/break-unload-file.exp: Use build_executable instead of
prepare_for_testing.
(test_break): New parameter "initial_load".  Handle it.
(top level): Add initial_load cmdline/file axis.

9 years agofix incorrect comments in minsyms.h
Tom Tromey [Mon, 16 Jun 2014 08:07:50 +0000 (02:07 -0600)] 
fix incorrect comments in minsyms.h

minsyms.h incorrectly claims that a couple of functions call
prim_record_minimal_symbol_full with COPY_NAME=0 -- but actually they
pass 1.  Passing 1 is the correct behavior, so this patch fixes the
documentation.

I'm checking this in as obvious.

2014-06-16  Tom Tromey  <tromey@redhat.com>

* minsyms.h (prim_record_minimal_symbol)
(prim_record_minimal_symbol_and_info): Update comments.

9 years agoFix duplicated assignments to __rel_iplt and __rela_iplt symbols
Alan Modra [Mon, 16 Jun 2014 12:51:16 +0000 (22:21 +0930)] 
Fix duplicated assignments to __rel_iplt and __rela_iplt symbols

and fix more nds32 dependencies.

* scripttempl/elf.sc: Edit out __rela_iplt symbol assignments from
.rel sections, and __rel_iplt from .rela sections.
* scripttempl/nds32elf.sc: Likewise.
* Makefile.am (ends32*.c): Depend on nds32elf.sc.
* Makefile.in: Regenerate.

9 years agoRun write_object_file after errors
Alan Modra [Mon, 16 Jun 2014 01:34:04 +0000 (11:04 +0930)] 
Run write_object_file after errors

This is to fix unitialised memory access when printing listings.
Many targets don't initialise parts of insn frags or data frags that
have fixups, relying on md_apply_fix to finalise the frag.  Which is
fine normally, but means we need to run write_object_file after
errors, for listings.  Otherwise MALLOC_PERTURB_=1 causes errors like:
x86_64-linux  +FAIL: i386 mpx-inval-1
x86_64-linux  +FAIL: i386 inval-equ-1
x86_64-linux  +FAIL: i386 x86-64-mpx-inval-1

Running write_object_file after errors requires some tweaking to the
testsuite, since we then get extra errors reported from md_apply_fix.

gas/
* write.h (subsegs_finish): Delete declaration.
* write.c (subsegs_finish): Make static.
(write_object_file): Call subsegs_finish from here.  Don't print
warning and error count here..
* as.c (main): ..do so here instead.  Remove dead code for "no
object file generated".  Split out count strings to better support
internationalisation.  Don't call subsegs_finish. Tidy setting of
"keep_it".  Run write_object_file even after errors.
(keep_it): Make static.
* config/obj-elf.c (elf_frob_symbol): Remove assert.
(elf_frob_file_before_adjust): Likewise.
gas/testsuite/
* gas/elf/bad-group.s: Use %function.
* gas/elf/bad-group.err: Expect correct line number.  Allow
other errors.
* gas/elf/bad-size.err: Allow other errors.  Match expected
error somewhat more rigorously.
* gas/i386/reloc32.l: Allow other errors.
* gas/i386/mpx-inval-1.l: Match applied relocs.
* gas/i386/x86-64-mpx-inval-1.l: Likewise, and nop padding.
* gas/i386/x86-64-mpx-inval-2.l: Match nop padding, and allow
other errors.
* gas/macros/dot.s: Use .balign.
* gas/macros/dot.l: Update alignment output.
* gas/symver/symver6.l: Allow other errors.

9 years agoDon't leave DLX the_insn uninitialised
Alan Modra [Mon, 16 Jun 2014 00:32:59 +0000 (10:02 +0930)] 
Don't leave DLX the_insn uninitialised

In particular the_insn.reloc must be initialised, otherwise the early
exit cases for bad opcodes will result in cascading errors if
write_object_file is called after an error.

* config/tc-dlx.c (machine_ip): Move initialisation of the_insn
earlier.

9 years agoReport an error on x86 pcrel BFD_RELOC_SIZE64
Alan Modra [Mon, 16 Jun 2014 01:58:26 +0000 (11:28 +0930)] 
Report an error on x86 pcrel BFD_RELOC_SIZE64

* config/tc-i386.c (reloc): Don't avoid pcrel check for
BFD_RELOC_SIZE64.  Return NO_RELOC on failing pcrel check.

9 years agoFix unintitialised TIC6X data
Alan Modra [Mon, 16 Jun 2014 01:26:56 +0000 (10:56 +0930)] 
Fix unintitialised TIC6X data

MALLOC_PERTURB_=1 results in the following fails due to uninitialised
exindx data:

FAIL: C6X unwinding directives 1 (little endian)
FAIL: C6X unwinding directives 2 (big endian)
FAIL: C6X unwinding directives 3 (segment change)
FAIL: ld-tic6x/unwind-1
FAIL: ld-tic6x/unwind-2
FAIL: ld-tic6x/unwind-3
FAIL: ld-tic6x/unwind-4
FAIL: ld-tic6x/unwind-6

* config/tc-tic6x.c (s_tic6x_ehtype): Clear after frag_more.
(tic6x_output_exidx_entry): Likewise.
(md_apply_fix): Simplify 1 byte md_number_to_chars.

9 years agoFix TIC54X buffer overruns
Alan Modra [Mon, 16 Jun 2014 01:03:26 +0000 (10:33 +0930)] 
Fix TIC54X buffer overruns

MALLOC_PERTURB_=1 results in "FAIL: c54x macros".

* config/tc-tic54x.c (tic54x_mlib): Don't write garbage past
end of archive to temp file.
(tic54x_start_line_hook): Start scan for parallel on next line,
not one char into next line (which may overrun the buffer).

9 years agoFix uninitialised VAX insn
Alan Modra [Mon, 16 Jun 2014 00:47:50 +0000 (10:17 +0930)] 
Fix uninitialised VAX insn

MALLOC_PERTURB_=1 results in "FAIL: VAX ELF relocations", due to object
file being emitted with uninitialised fields.  Since these fields had
RELA relocs the field value won't be used at final link time, so the
problem is only seen in relocatable object files.

This rewrite of md_apply_fix clears all fields with relocs, whereas
before some fields had non-zero values.

gas/
* config/tc-vax.c (md_apply_fix): Rewrite.
(tc_gen_reloc, vax_cons, vax_cons_fix_new): Style: Use NO_RELOC
define rather than the equivalent BFD_RELOC_NONE.
gas/testsuite/
* gas/vax/elf-rel.d: Update.

9 years agoFix uninitialised VAX .got and .got.plt section
Alan Modra [Mon, 16 Jun 2014 00:42:12 +0000 (10:12 +0930)] 
Fix uninitialised VAX .got and .got.plt section

Cures these failures with MALLOC_PERTURB_=1
FAIL: GOT test (executable)
FAIL: GOT test (shared library)
FAIL: VAX export class call relocation test
FAIL: VAX export class data relocation test

* elf32-vax.c (elf_vax_size_dynamic_sections): Clear linker
created sections.

9 years agoFix uninitialised ARM data
Alan Modra [Mon, 16 Jun 2014 00:26:29 +0000 (09:56 +0930)] 
Fix uninitialised ARM data

MALLOC_PERTURB_=1 results in "FAIL: PIC" on arm-vxworks, due to garbage
in words with got relocs.

* config/tc-arm.c (s_arm_elf_cons): Initialise after frag_more.
(md_apply_fix): Delete now unnecessary zeroing for BFD_RELOC_ARM_GOT*
and BFD_RELOC_ARM_TLS* relocs.  Simplify BFD_RELOC_8 case.

9 years agoFix uninitialised CRIS insn
Alan Modra [Mon, 16 Jun 2014 00:20:15 +0000 (09:50 +0930)] 
Fix uninitialised CRIS insn

gas/
* config/tc-cris.c (md_create_long_jump): Follow "short" jump
with a nop rather than leaving uninitialised.
gas/testsuite/
* gas/cris/rd-bkw4v32.d: Update.

9 years agodaily update
Alan Modra [Mon, 16 Jun 2014 00:00:38 +0000 (09:30 +0930)] 
daily update

9 years agodaily update
Alan Modra [Sun, 15 Jun 2014 00:01:08 +0000 (09:31 +0930)] 
daily update

9 years agoInclude --with-guile in 'show configuration's output.
Eli Zaretskii [Sat, 14 Jun 2014 17:54:16 +0000 (20:54 +0300)] 
Include --with-guile in 'show configuration's output.

* top.c (print_gdb_configuration) [HAVE_GUILE]: Print --with-guile
or --without-guile, according to how GDB was built.

9 years agodaily update
Alan Modra [Sat, 14 Jun 2014 00:01:18 +0000 (09:31 +0930)] 
daily update

9 years agoAdd support for reading Aarch64 core dumps.
Omair Javaid [Fri, 13 Jun 2014 16:07:21 +0000 (17:07 +0100)] 
Add support for reading Aarch64 core dumps.

* elfxx-aarch64.c (stdarg.h): Include.
(string.h): Include.
(_bfd_aarch64_elf_grok_prstatus): Updated.
(_bfd_aarch64_elf_grok_psinfo): New function.
(_bfd_aarch64_elf_write_core_note): New function.
* elfxx-aarch64.h (elf_backend_grok_psinfo): Define.
(elf_backend_write_core_note): Define.

9 years agomake calls to help_list use enumerator
Tom Tromey [Thu, 5 Jun 2014 14:25:00 +0000 (08:25 -0600)] 
make calls to help_list use enumerator

Currently there are many calls to help_list that pass the constant -1
as the "class" value.  However, the parameter is declared as being of
type enum command_class, and uses of the constant violate this
abstraction.

This patch fixes the error everywhere it occurs in the gdb sources.

Tested by rebuilding.

2014-06-13  Tom Tromey  <tromey@redhat.com>

* cp-support.c (maint_cplus_command): Pass all_commands, not -1,
to help_list.
* guile/guile.c (info_guile_command): Pass all_commands, not -1,
to help_list.
* tui/tui-win.c (tui_command): Pass all_commands, not -1, to
help_list.
* tui/tui-regs.c (tui_reg_command): Pass all_commands, not -1, to
help_list.Pass all_commands, not -1, to help_list.
* cli/cli-dump.c (dump_command, append_command)
(srec_dump_command, ihex_dump_command, tekhex_dump_command)
(binary_dump_command, binary_append_command): Pass all_commands,
not -1, to help_list.
* cli/cli-cmds.c (info_command, set_debug): Pass all_commands, not
-1, to help_list.
* valprint.c (set_print, set_print_raw): Pass all_commands, not
-1, to help_list.
* typeprint.c (set_print_type): Pass all_commands, not -1, to
help_list.
* top.c (set_history): Pass all_commands, not -1, to help_list.
* target-descriptions.c (set_tdesc_cmd, unset_tdesc_cmd): Pass
all_commands, not -1, to help_list.
* symfile.c (overlay_command): Pass all_commands, not -1, to
help_list.
* spu-tdep.c (info_spu_command): Pass all_commands, not -1, to
help_list.
* serial.c (serial_set_cmd): Pass all_commands, not -1, to
help_list.
* ser-tcp.c (set_tcp_cmd, show_tcp_cmd): Pass all_commands, not
-1, to help_list.
* remote.c (remote_command, set_remote_cmd): Pass all_commands,
not -1, to help_list.
* ravenscar-thread.c (set_ravenscar_command): Pass all_commands,
not -1, to help_list.
* maint.c (maintenance_command, maintenance_info_command)
(maintenance_print_command, maintenance_set_cmd): Pass
all_commands, not -1, to help_list.
* macrocmd.c (macro_command): Pass all_commands, not -1, to
help_list.
* language.c (set_check): Pass all_commands, not -1, to help_list.
* infcmd.c (unset_command): Pass all_commands, not -1, to
help_list.
* frame.c (set_backtrace_cmd): Pass all_commands, not -1, to
help_list.
* dwarf2read.c (set_dwarf2_cmd): Pass all_commands, not -1, to
help_list.
* dcache.c (set_dcache_command): Pass all_commands, not -1, to
help_list.
* breakpoint.c (save_command): Pass all_commands, not -1, to
help_list.
* ada-lang.c (maint_set_ada_cmd, set_ada_command): Pass
all_commands, not -1, to help_list.

9 years agoFix seg-faults when fetching the frags of local symbols.
Chen Gang [Fri, 13 Jun 2014 15:07:21 +0000 (16:07 +0100)] 
Fix seg-faults when fetching the frags of local symbols.

* config/tc-score7.c: (s7_b32_relax_to_b16): Use symbol_get_frag() to access a symbol's frag.
* config/tc-score.c (s3_relax_branch_inst16): Likewise.
(s3_relax_cmpbranch_inst32): Likewise.

9 years agoA simple replacement of sprintf (xxx, "%s", xxx) with strcpy.
Chen Gang [Fri, 13 Jun 2014 14:52:55 +0000 (15:52 +0100)] 
A simple replacement of sprintf (xxx, "%s", xxx) with strcpy.

* config/tc-score7.c: Replace sprintf with strcpy where
appropriate.

9 years agoInvalidate a register in cache when a remote target failed to write it.
Pierre Langlois [Tue, 20 May 2014 14:13:20 +0000 (15:13 +0100)] 
Invalidate a register in cache when a remote target failed to write it.

As shown by the bug report, GDB crashes when the remote target was unable to
write to a register (the program counter) with the 'P' packet. This was reported
for AVR but can be reproduced on any architecture with a gdbserver that fails to
handle a 'P' packet.

Issue
=====

This GDB session was done with a custom gdbserver patched to send an error
packet when trying to set the program counter with a 'P' packet:

~~~
(gdb) file Debug/ATMega2560-simple-program.elf
Reading symbols from Debug/ATMega2560-simple-program.elf...done.
(gdb) target remote :51000
Remote debugging using :51000
0x00000000 in __vectors ()
(gdb) load
Loading section .text, size 0x1fc lma 0x0
Start address 0x0, load size 508
Transfer rate: 248 KB/sec, 169 bytes/write.
(gdb) b main
Breakpoint 1 at 0x164: file .././ATMega2560-simple-program.c, line 39.
(gdb) c
Continuing.

Program received signal SIGTRAP, Trace/breakpoint trap.
main () at .././ATMega2560-simple-program.c:42
42 DDRD |= LED0_MASK;// | LED1_MASK;
(gdb) info line 43
Line 43 of ".././ATMega2560-simple-program.c" is at address 0x178 <main+40> but contains no code.
(gdb) set $pc=0x178
Could not write register "PC2"; remote failure reply 'E00'
(gdb) info registers pc
pc             0x178 0x178 <main+40>
(gdb) s
../../unisrc-mainline/gdb/infrun.c:1978: internal-error: resume: Assertion `pc_in_thread_step_range (pc, tp)' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n)
../../unisrc-mainline/gdb/infrun.c:1978: internal-error: resume: Assertion `pc_in_thread_step_range (pc, tp)' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Create a core file of GDB? (y or n)
~~~

We can see that even though GDB reports that writing to the register failed, the
register cache was updated:

~~~
(gdb) set $pc=0x178
Could not write register "PC2"; remote failure reply 'E00'
(gdb) info registers pc
pc             0x178 0x178 <main+40>
~~~

The root of the problem is of course in the gdbserver but I thought GDB should
keep a register cache consistent with the hardware even in case of a failure.

Changes
=======

This patch adds routines to add a regcache_invalidate cleanup to the current
chain.

We can then register one before calling target_store_registers. This way if the
target throws an error, the register we wanted to write to will be invalidated
in cache. If target_store_registers succeeds, we can discard the new cleanup.

2014-06-12  Pierre Langlois  <pierre.langlois@embecosm.com>

* regcache.c (struct register_to_invalidate): New structure.
(do_register_invalidate, make_cleanup_regcache_invalidate): New
functions.
(regcache_raw_write): Call make_cleanup_regcache_invalidate.

9 years agoFree linker hash table from bfd_close.
Alan Modra [Fri, 13 Jun 2014 09:41:39 +0000 (19:11 +0930)] 
Free linker hash table from bfd_close.

Also tidies numerous error exit paths in various link_hash_table_create
functions that failed to free memory.

include/
* bfdlink.h (struct bfd_link_hash_table): Add hash_table_free field.
bfd/
* archive.c: Include bfdlink.h.
(_bfd_archive_close_and_cleanup): Call linker hash_table_free.
* bfd.c (struct bfd): Add is_linker_output field.
* elf-bfd.h (_bfd_elf_link_hash_table_free): Update prototype.
* linker.c (_bfd_link_hash_table_init): Set up hash_table_free,
link.hash and is_linker_output.
(_bfd_generic_link_hash_table_free): Replace bfd_link_hash_table*
param with bfd*.  Assert is_linker_output and link.hash, and
clear them before exit.
* elf-m10300.c (elf32_mn10300_link_hash_table_free): Replace
bfd_link_hash_table* param with bfd*.  Hack is_linker_output
and link.hash so we can free two linker hash tables.
(elf32_mn10300_link_hash_table_create): Create static_hash_table
first.  Clean up on errors.  Set hash_table_free pointer.
* elf32-arm.c (elf32_arm_link_hash_table_free): Replace
bfd_link_hash_table* param with bfd*.
(elf32_arm_link_hash_table_create): Clean up on errors.  Set
hash_table_free pointer.
* elf32-avr.c, * elf32-hppa.c, * elf32-i386.c, * elf32-m68hc1x.c,
* elf32-m68k.c, * elf32-metag.c, * elf32-nios2.c, * elf32-xgate.c,
* elf64-ia64-vms.c, * elf64-ppc.c, * elf64-x86-64.c, * elflink.c,
* elfnn-aarch64.c, * elfnn-ia64.c, * elfxx-sparc.c,
* xcofflink.c: Similarly.
* simple.c (bfd_simple_get_relocated_section_contents): Save and
clear link.next before creating linker hash table.  Clean up on
errors, and restore link.next on exit.
* elf32-m68hc1x.h (m68hc11_elf_bfd_link_hash_table_free): Delete.
* elf32-xgate.h (xgate_elf_bfd_link_hash_table_free): Delete.
* elfxx-sparc.h (_bfd_sparc_elf_link_hash_table_free): Delete.
* libcoff-in.h (_bfd_xcoff_bfd_link_hash_table_free): Delete.
* hash.c (bfd_hash_table_init_n): Free table on error.
* libbfd-in.h (_bfd_generic_link_hash_table_free): Update proto.
* bfd-in2.h: Regenerate.
* libbfd.h: Regenerate.
* libcoff.h: Regenerate.

9 years agoDon't call bfd_link_hash_table_free
Alan Modra [Fri, 13 Jun 2014 09:41:29 +0000 (19:11 +0930)] 
Don't call bfd_link_hash_table_free

Freeing the linker hash table is a royal pain.  It can't be freed
before the _bfd_write_contents call in bfd_close, because some target
bfd_write_contents functions access the hash table.  It can't be freed
after bfd_close either, since bfd_alloc memory holding side data
structures disappears (PR17047).  Clearly the only place it can be freed
is actually in bfd_close.  This patch doesn't do that, but kills off
the existing means of freeing the hash table via a bfd target xvec call.

bfd/
PR 17047
* targets.c (BFD_JUMP_TABLE): Delete NAME##_bfd_link_hash_table_free.
(struct bfd_target <_bfd_link_hash_table_free>): Delete.
* bfd.c (bfd_link_hash_table_free): Don't define.
* aout-adobe.c, * aout-target.h, * aout-tic30.c, * binary.c, * bout.c,
* coff64-rs6000.c, * coffcode.h, * elf-m10300.c, * elf32-arm.c,
* elf32-avr.c, * elf32-hppa.c, * elf32-i386.c, * elf32-m68hc11.c,
* elf32-m68hc12.c, * elf32-m68k.c, * elf32-metag.c, * elf32-nios2.c,
* elf32-sparc.c, * elf32-xgate.c, * elf64-ia64-vms.c, * elf64-ppc.c,
* elf64-sparc.c, * elf64-x86-64.c, * elfnn-aarch64.c, * elfnn-ia64.c,
* elfxx-target.h, * i386msdos.c, * i386os9k.c, * ieee.c, * ihex.c,
* libbfd-in.h, * libecoff.h, * mach-o-target.c, * mmo.c,
* nlm-target.h, * oasys.c, * pef.c, * plugin.c, * ppcboot.c, * som.c,
* srec.c, * tekhex.c, * verilog.c, * versados.c, * vms-alpha.c,
* xsym.c: Don't define various link_hash_table_free defines, and
remove from bfd_target vars.  Temporarily reference some of the
target link_hash_table_free functions to avoid warnings.
* bfd-in2.h: Regenerate.
* libbfd.h: Regenerate.
ld/
PR 17047
* ldlang.c (output_bfd_hash_table_free_fn): Delete.
(open_output): Don't set it..
* ldmain.c (ld_cleanup): ..or call it.

9 years agoMove link_hash_table_free functions earlier
Alan Modra [Fri, 13 Jun 2014 09:41:19 +0000 (19:11 +0930)] 
Move link_hash_table_free functions earlier

Move some code around, in preparation for a followup patch.

* elf-m10300.c, * elf32-arm.c, * elf32-avr.c, * elf32-hppa.c,
* elf32-i386.c, * elf32-m68hc1x.c, * elf32-m68k.c, * elf32-metag.c,
* elf32-nios2.c, * elf64-ia64-vms.c, * elf64-ppc.c, * elf64-x86-64.c,
* elfnn-aarch64.c, * elfnn-ia64.c, * elfxx-sparc.c, * xcofflink.c:
Move link_hash_table_free functions before their corresponding
link_hash_table_create functions.

9 years agoMake bfd.link_next field a union
Alan Modra [Fri, 13 Jun 2014 09:40:57 +0000 (19:10 +0930)] 
Make bfd.link_next field a union

This field of struct bfd is currently only used to chain together
linker input files.  This patch prepares to use the field to stash
the linker hash table, which is always created on the linker output
file.

bfd/
* bfd.c (struct bfd): Replace link_next with a union.
* aoutx.h, * bfd.c, * coff-ppc.c, * coff-rs6000.c, * cofflink.c,
* ecoff.c, * elf-m10300.c, * elf32-arm.c, * elf32-avr.c,
* elf32-hppa.c, * elf32-i386.c, * elf32-lm32.c, * elf32-m32c.c,
* elf32-m32r.c, * elf32-m68hc1x.c, * elf32-metag.c,
* elf32-microblaze.c, * elf32-nds32.c, * elf32-nios2.c,
* elf32-or1k.c, * elf32-ppc.c, * elf32-rl78.c, * elf32-s390.c,
* elf32-score.c, * elf32-score7.c, * elf32-sh.c, * elf32-spu.c,
* elf32-tic6x.c, * elf32-tilepro.c, * elf32-xstormy16.c,
* elf32-xtensa.c, * elf64-alpha.c, * elf64-hppa.c, * elf64-ia64-vms.c,
* elf64-mmix.c, * elf64-ppc.c, * elf64-s390.c, * elf64-x86-64.c,
* elflink.c, * elfnn-aarch64.c, * elfxx-mips.c, * elfxx-sparc.c,
* elfxx-tilegx.c, * linker.c, * pdp11.c, * peXXigen.c, * simple.c,
* sunos.c, * vms-alpha.c, * xcofflink.c: Update for above.
* bfd-in2.h: Regenerate.
include/
* bfdlink.h: Update for bfd.link_next change.
ld/
* emultempl/cr16elf.em, * emultempl/elf32.em, * emultempl/genelf.em,
* emultempl/m68kcoff.em, * emultempl/m68kelf.em,
* emultempl/nds32elf.em, * emultempl/pe.em, * emultempl/pep.em,
* ldlang.c, * ldmain.c, * pe-dll.c: Update for bfd.link_next change.

9 years agoAdd missing ld makefile dependency for nios.
Alan Modra [Fri, 13 Jun 2014 02:58:18 +0000 (12:28 +0930)] 
Add missing ld makefile dependency for nios.

* Makefile.am (ALL_EMULATION_SOURCES): Add enios2elf.c, enios2linux.c.
* Makefile.in: Regenerate.

9 years agodaily update
Alan Modra [Fri, 13 Jun 2014 00:01:18 +0000 (09:31 +0930)] 
daily update

9 years agodelete gdbserver's freeargv
Tom Tromey [Mon, 20 Jan 2014 02:34:23 +0000 (19:34 -0700)] 
delete gdbserver's freeargv

gdbserver defines freeargv, but it is now trivial to just use the one
in libiberty.

2014-06-12  Tom Tromey  <tromey@redhat.com>

* utils.c (freeargv): Remove.

9 years agolink gdbserver against libiberty
Tom Tromey [Sun, 19 Jan 2014 21:33:37 +0000 (14:33 -0700)] 
link gdbserver against libiberty

This builds a libiberty just for gdbserver and arranges for gdbserver
to use it.  I've tripped across the lack of libiberty in gdbserver at
least once, and I have seen other threads where it would have been
useful.

2014-06-12  Tom Tromey  <tromey@redhat.com>

* debug.c (debug_printf): Remove HAVE_GETTIMEOFDAY checks.
* server.c (monitor_show_help): Remove HAVE_GETTIMEOFDAY check.
(parse_debug_format_options): Likewise.
(gdbserver_usage): Likewise.
* Makefile.in (LIBIBERTY_BUILDDIR, LIBIBERTY): New variables.
(SUBDIRS, REQUIRED_SUBDIRS): Add libiberty.
(gdbserver$(EXEEXT), gdbreplay$(EXEEXT)): Depend on and link
against libiberty.
($(LIBGNU)): Depend on libiberty.
(all-lib): Recurse into all subdirs.
(install-only): Invoke "install" target in subdirs.
(vasprintf.o, vsnprintf.o, safe-ctype.o, lbasename.o): Remove
targets.
* configure: Rebuild.
* configure.ac: Add ACX_CONFIGURE_DIR for libiberty.  Don't check
for vasprintf, vsnprintf, or gettimeofday.
* configure.srv: Don't add safe-ctype.o or lbasename.o to
srv_tgtobj.

9 years agodon't use directory in test name
Tom Tromey [Thu, 12 Jun 2014 18:04:54 +0000 (12:04 -0600)] 
don't use directory in test name

I noticed that a few tests in completion.exp put the directory name
into the name of the resulting test.  While the directory name is
relative, this still makes for spurious differences depending on
whether the test was run in serial or parallel mode.

This patch fixes the problem.  I'm checking it in.

2014-06-12  Tom Tromey  <tromey@redhat.com>

* gdb.base/completion.exp: Don't use directory name in test.

9 years agoMove ChangeLog entry to proper place.
Pedro Alves [Thu, 12 Jun 2014 17:47:54 +0000 (18:47 +0100)] 
Move ChangeLog entry to proper place.

gdb/
2014-06-09  Pedro Alves  <palves@redhat.com>

* linux-nat.c (linux_child_follow_fork): Initialize status with
W_STOPCODE (0) instead of 0.  Remove shodowing 'status' local from
inner block.  Only pass the signal to PTRACE_DETACH if in pass
state.

9 years agoUse varobj_is_dynamic_p more widely
Yao Qi [Sat, 23 Nov 2013 08:05:58 +0000 (16:05 +0800)] 
Use varobj_is_dynamic_p more widely

Use varobj_is_dynamic_p more widely so that the callers of
varobj_is_dynamic_p are unchanged when we add available-children-only
stuff in varobj_is_dynamic_p.

gdb:

2014-06-12  Yao Qi  <yao@codesourcery.com>

* varobj.c (varobj_get_num_children): Call
varobj_is_dynamic_p.
(varobj_list_children): Likewise.
(varobj_update): Likewise.  Update comments.

9 years agoRename varobj_pretty_printed_p to varobj_is_dynamic_p
Yao Qi [Sat, 23 Nov 2013 07:58:04 +0000 (15:58 +0800)] 
Rename varobj_pretty_printed_p to varobj_is_dynamic_p

We think varobj with --available-children-only behaves like a dynamic
varobj, so dyanmic varobj is not pretty-printer specific.  We rename
varobj_pretty_printed_p to varobj_is_dynamic_p, so that we can handle
available-children-only checking in varobj_is_dynamic_p in the next
patch.

gdb:

2014-06-12  Yao Qi  <yao@codesourcery.com>

* varobj.c (varobj_pretty_printed_p): Rename to ...
(varobj_is_dynamic_p): ... this.  New function.
* varobj.h (varobj_pretty_printed_p): Remove declaration.
(varobj_is_dynamic_p): Declare.
* mi/mi-cmd-var.c (print_varobj): All callers updated.
(mi_print_value_p, varobj_update_one): Likewise.

9 years agoRemove #if HAVE_PYTHON
Yao Qi [Fri, 30 Aug 2013 08:30:32 +0000 (16:30 +0800)] 
Remove #if HAVE_PYTHON

This patch removes some unnecessary "#if HAVE_PYTHON" so that more
code is generalized.

gdb:

2014-06-12  Pedro Alves  <pedro@codesourcery.com>
    Yao Qi  <yao@codesourcery.com>

* varobj.c: Remove "#if HAVE_PYTHON" and "#endif".
(varobj_get_iterator): Wrap up code for pretty-printer by
"#if HAVE_PYTHON" and "#endif".
(update_dynamic_varobj_children): Likewise.

9 years agoIterate over 'struct varobj_item' instead of PyObject
Yao Qi [Tue, 12 Nov 2013 12:49:52 +0000 (20:49 +0800)] 
Iterate over 'struct varobj_item' instead of PyObject

In previous patch, "saved_item" is still a PyOjbect and iteration is
still performed over PyObject.  This patch continues to decouple
iteration from python code, so it changes its type to "struct
varobj_item *", so that the iterator itself is independent of python.

 V2:
 - Call varobj_delete_iter in free_variable.
 - Fix changelog entries.
 - Use XNEW.

 V3:
 - Return NULL early in py_varobj_iter_next if gdb_python_initialized
   is false.

gdb:

2014-06-12  Pedro Alves  <pedro@codesourcery.com>
    Yao Qi  <yao@codesourcery.com>

* python/py-varobj.c (py_varobj_iter_next): Return NULL if
gdb_python_initialized is false.  Move some code from varobj.c.
* varobj-iter.h (struct varobj_item): Moved from varobj.c.
* varobj.c: Move "varobj-iter.h" inclusion earlier.
(struct varobj_item): Moved to varobj-iter.h".
(varobj_clear_saved_item): New function.
(update_dynamic_varobj_children): Move python-related code to
py-varobj.c.
(free_variable): Call varobj_clear_saved_item and
varobj_iter_delete.

9 years agoGeneralize varobj iterator
Yao Qi [Fri, 30 Aug 2013 01:44:46 +0000 (09:44 +0800)] 
Generalize varobj iterator

This patch generalizes varobj iterator, in a python-independent way.
Note varobj_item is still a typedef of PyObject, we can only focus on
API changes, and leave the data type changes to the next patch.  As a
result, we include "varobj-iter.h" after the typedef of PyObject in
varobj.c, but it is an intermediate state.  Finally, varobj-iter.h is
independent of PyObject.

This change is helpful to move some python-related code out of
varobj.c.

 V2:
  - Fix a missing cleanup.
  - Fix typos.
  - Use XNEW.
  - Check against NULL explicitly.
  - Update copyright year for new added files.

 V3:
  - Call PyGILState_Ensure before Py_XDECREF.
  - Use CPYCHECKER_STEALS_REFERENCE_TO_ARG.
  - Code indentation.

 V4:
  - use varobj_ensure_python_env instead of PyGILState_Ensure.

gdb:

2014-06-12  Pedro Alves  <pedro@codesourcery.com>
    Yao Qi  <yao@codesourcery.com>

* Makefile.in (SUBDIR_PYTHON_OBS): Add "py-varobj.o".
(SUBDIR_PYTHON_SRCS): Add "python/py-varobj.c".
(HFILES_NO_SRCDIR): Add "varobj-iter.h".
(py-varobj.o): New rule.
* python/py-varobj.c: New file.
* python/python-internal.h (py_varobj_get_iterator): Declare.
* varobj-iter.h: New file.
* varobj.c: Include "varobj-iter.h"
(struct varobj) <child_iter>: Change its type from "PyObject *"
to "struct varobj_iter *".
<saved_item>: Likewise.
[HAVE_PYTHON] (varobj_ensure_python_env): Make it extern.
[HAVE_PYTHON] (varobj_get_iterator): New function.
(update_dynamic_varobj_children) [HAVE_PYTHON]: Move
python-specific code to python/py-varobj.c.
(install_visualizer): Call varobj_iter_delete instead of
Py_XDECREF.
* varobj.h (varobj_ensure_python_env): Declare.

9 years agoUse 'struct varobj_item' to represent name and value pair
Yao Qi [Tue, 10 Sep 2013 00:58:23 +0000 (08:58 +0800)] 
Use 'struct varobj_item' to represent name and value pair

Hi,
name and value pair is widely used in varobj.c.  This patch is to add
a new struct varobj_item to represent them, so that the number of
function arguments can be reduced.  Finally, the iteration is done on
'struct varobj_item' instead of PyObject after this patch series.

 V2:
 - Fix changelog entry.
 - Fix one grammatical mistake.

gdb:

2014-06-12  Yao Qi  <yao@codesourcery.com>

* varobj.c (struct varobj_item): New structure.
(create_child_with_value): Update declaration.
(varobj_add_child): Replace arguments 'name' and 'value' with
'item'.  All callers updated.
(install_dynamic_child): Likewise.
(update_dynamic_varobj_children): Likewise.
(varobj_add_child): Likewise.
(create_child_with_value): Likewise.

9 years agoWhitespace fixes for cpu/or1k.opc
Alan Modra [Thu, 12 Jun 2014 02:34:06 +0000 (12:04 +0930)] 
Whitespace fixes for cpu/or1k.opc

* or1k.opc: Whitespace fixes.

9 years agodaily update
Alan Modra [Thu, 12 Jun 2014 00:00:43 +0000 (09:30 +0930)] 
daily update

9 years agoUpdate NEWS post GDB 7.8 branch creation.
Joel Brobecker [Wed, 11 Jun 2014 16:52:29 +0000 (18:52 +0200)] 
Update NEWS post GDB 7.8 branch creation.

gdb/ChangeLog:

* NEWS: Create a new section for the next release branch.
Rename the section of the current branch, now that it has
been cut.

9 years agoBump version to 7.8.50.DATE-cvs.
Joel Brobecker [Wed, 11 Jun 2014 16:37:55 +0000 (18:37 +0200)] 
Bump version to 7.8.50.DATE-cvs.

Now that the GDB 7.8 branch has been created, we can
bump the version number.

gdb/ChangeLog:

GDB 7.8 branch created (173373c6f6388171d1d62a217fae90a052395be2):
* version.in: Bump version to 7.8.50.DATE-cvs.

9 years agoDelete temporary string within demangler even in failure cases.
Andrew Burgess [Tue, 27 May 2014 10:57:33 +0000 (11:57 +0100)] 
Delete temporary string within demangler even in failure cases.

A call to demangle_template might allocate storage within a temporary
string even if the call to demangle_template eventually returns
failure.

This will never cause the demangler to crash, but does leak memory, as
a result I've not added any tests for this.

Calling string_delete is safe, even if nothing is allocated into the
string, the string is initialised with string_init, so we know the
internal pointers are NULL.

libiberty/ChangeLog

* cplus-dem.c (do_type): Call string_delete even if the call to
demangle_template fails.

9 years agoPR remote/17028: GDB+GDBserver hangs on Windows
Pedro Alves [Wed, 11 Jun 2014 10:04:31 +0000 (11:04 +0100)] 
PR remote/17028: GDB+GDBserver hangs on Windows

Since target-async was turned on by default, debugging on Windows
using GDB+GDBserver sometimes hangs while waiting for a RSP reply.

The problem is a race in the gdb_select machinery.

This is what we see for a faulty next on the GDB side:

    (gdb) n
    infrun: clear_proceed_status_thread (Thread 4424)
    infrun: proceed (addr=0xffffffff, signal=GDB_SIGNAL_DEFAULT, step=1)
    (...)
    infrun: resume (step=1, signal=GDB_SIGNAL_0), ...
    Sending packet: $vCont;s:1148;c#5e...
    *hang*

At this point, attaching a debugger to the hanging GDB confirms that
it is blocked, waiting for a socket event:

    #6  0x757841d8 in WaitForMultipleObjects ()
       from C:\Windows\syswow64\kernel32.dll
    #7  0x004708e7 in gdb_select (n=469, readfds=0x88ca50 <gdb_notifier+784>,
        writefds=0x88cb54 <gdb_notifier+1044>,
        exceptfds=0x88cc58 <gdb_notifier+1304>, timeout=0x0)
        at /[...]/gdb/mingw-hdep.c:172
    #8  0x00527926 in gdb_wait_for_event (block=1)
        at /[...]/gdb/event-loop.c:831
    #9  0x00526ff1 in gdb_do_one_event ()
        at /[...]/gdb/event-loop.c:403

However, on the GDBserver side, we see that GDBserver already sent a
T05 packet reply:

    gdbserver: kernel event EXCEPTION_DEBUG_EVENT for pid=4968 tid=1148
    EXCEPTION_SINGLE_STEP
    Child Stopped with signal = 5
    Writing resume reply for LWP 4968.4424:1
    DEBUG: write_prim ($T0505:c8fe2800;04:a0fe2800;08:38164000;thread:1148;#f0)
           -> 55

To recap, on Windows, 'select' only works with sockets, so we have a
wrapper, gdb_select, that uses the GDB serial abstraction to handle
sockets, consoles, pipes, and serial ports.  Each serial descriptor
has a thread associated (we call those the select threads), and those
threads communicate with the main thread by means of standard Windows
events.

It basically goes like this: gdb_select first loops through all fds of
interest, calling their wait_handle hooks, which returns an event that
WaitForMultipleObjects can wait on.  gdb_select then blocks in
WaitForMultipleObjects with all those event handles.  The wait_handle
hook is responsible for arranging for the returned event to become set
once data is available.  This is done by setting the descriptor's
helper thread running, which itself knows how to wait for data from
the type of handle it manages (sockets, pipes, consoles, files, etc.).
Once data arrives, the select thread sets the corresponding event
which unblocks WaitForMultipleObjects within gdb_select.  However, the
wait_handle hook can also apply an optimization: if data is already
pending, then there's no need to set the thread running, and the
descriptors event can be set immediately.  It's around this latter
aspect that lies the bug/race.

Adding some ad hoc debug logs to ser-mingw.c and mingw-hdep.c, we see
the following sequence of events, right after sending
"$vCont;s:1148;c#5e".  Thread 1 is the main thread, and thread 2 is
the socket's helper/select thread.  gdb_select was only passed one
descriptor to wait on, the remote target's socket.
net_windows_select_thread is the entry point of the select threads for
sockets.

 #1 - thread 1: gdb_select: enter
 #2 - thread 2: net_windows_select_thread: WaitForMultipleObjects blocking

gdb_select walked over the wait_handle hooks, and woke up the socket's
helper thread.  The helper thread is now blocked waiting for socket
events.

 #3 - thread 1: gdb_select: WaitForMultipleObjects polling (timeout=0ms)
 #4 - thread 1: gdb_select: WaitForMultipleObjects returned 102 (WAIT_TIMEOUT)

There was no pending data available yet, and gdb_select was passed
timeout==0ms, and so WaitForMultipleObjects times out immediately.

 #5 - thread 2: net_windows_select_thread: WaitForMultipleObjects returned 1

Just afterwards, socket data arrives, and thread 2 wakes up.  Thread 2
calls WSAEnumNetworkEvents, which clears state->sock_event, and marks
the serial's read_event event, telling the main thread that data is
available.

 #6 - thread 1: gdb_select: call serial_done_wait_handle on each serial

gdb_select stops all the helper/select threads.

 #7 - thread 1: gdb_select: return 0 (WAIT_TIMEOUT)

gdb_select in the main thread returns to the caller.

Note that at this point, data is pending on the socket, the serial's
read_event is set, but the socket's sock_event event is not set, until
_further_ data arrives.

Now GDB does its thing and goes back to the event loop.  That calls
gdb_select, but with timeout==INFINITE.

Again, gdb_select calls the socket serial's wait_handle hook.  It
first clears its events, starting from a clean slate:

  ResetEvent (state->base.read_event);
  ResetEvent (state->base.except_event);
  ResetEvent (state->base.stop_select);

That cleared read_event, which was previously set in #5 above.  And
then it checks for pending events, in the sock_event event:

  /* Check any pending events.  This both avoids starting the thread
     unnecessarily, and handles stray FD_READ events (see below).  */
  if (WaitForSingleObject (state->sock_event, 0) == WAIT_OBJECT_0)
    {

That also fails because state->sock_event was cleared in #5 too...

So the wait_handle hook erroneously decides that it needs to start the
helper thread to wait for input:

 #8 - thread 2: net_windows_select_thread: WaitForMultipleObjects blocking
 #9 - thread 1: gdb_select: WaitForMultipleObjects blocking (INFINITE)

But, GDBserver already sent all it had to send, so both threads waits
forever...

At first I thought that net_windows_wait_handle shouldn't be resetting
state->base.read_event or state->base.except_event, but looking
deeper, the pipe and console wait_handle hooks reset all events too.
It actually makes sense that way -- consuming an event from different
threads is bad practice, and, we should always be able to query
pending state without looking at the state->sock_event from within
net_windows_wait_handle.  The end result is much simpler, and makes
net_windows_select_thread look a lot like console_select_thread,
actually.

gdb/
2014-06-11  Pedro Alves  <palves@redhat.com>

PR remote/17028
* ser-mingw.c (net_windows_socket_check_pending): New function.
(net_windows_select_thread): Ignore spurious wakeups.  Use
net_windows_socket_check_pending.
(net_windows_wait_handle): Check for pending events with
ioctlsocket, through net_windows_socket_check_pending, instead of
checking the socket's event.

9 years agoFix silly thinko
Alan Modra [Wed, 11 Jun 2014 09:41:12 +0000 (19:11 +0930)] 
Fix silly thinko

* linker.c (unwrap_hash_lookup): Add missing parens.

9 years ago * libcoff-in.h (coff_tdata): Make relocbase member unsigned.
Kai Tietz [Wed, 11 Jun 2014 07:15:54 +0000 (09:15 +0200)] 
* libcoff-in.h (coff_tdata): Make relocbase member unsigned.
* libcoff.h: Regenerated.

9 years ago * libcoff-in.h (coff_tdata): Make relocbase member unsigned.
Kai Tietz [Thu, 5 Jun 2014 08:59:08 +0000 (10:59 +0200)] 
* libcoff-in.h (coff_tdata): Make relocbase member unsigned.
* libcoff.h: Regenerated.

9 years agodaily update
Alan Modra [Wed, 11 Jun 2014 00:01:20 +0000 (09:31 +0930)] 
daily update

9 years agoWrap PyObject_Get/HasAttrString in a function with second arg having const qualifier.
Siva Chandra [Wed, 4 Jun 2014 17:50:11 +0000 (10:50 -0700)] 
Wrap PyObject_Get/HasAttrString in a function with second arg having const qualifier.

This is done to avoid errors when compiled with -Werror against Python-2.4
which did not have the const qualifier for the second argument of these
functions.

gdb/
* python/python-internal.h (gdb_PyObject_GetAttrString)
(gdb_PyObject_HasAttrString): New inline function definitions.
* py-value.c (get_field_flag): Remove the now unnecessary cast to
char * of the second argument to PyObject_GetAttrString.

9 years agoOnly print prefixes before fwait
H.J. Lu [Tue, 10 Jun 2014 18:16:41 +0000 (11:16 -0700)] 
Only print prefixes before fwait

gas/testsuite/

* gas/i386/prefix.s: Add another fwait test.
* gas/i386/prefix.d: Updated.

opcodes/

* i386-dis.c (fwait_prefix): New.
(ckprefix): Set fwait_prefix.
(print_insn): Properly print prefixes before fwait.

9 years agoadd pr number to changelog
Alan Modra [Tue, 10 Jun 2014 13:37:52 +0000 (23:07 +0930)] 
add pr number to changelog

9 years agomissing changelog entries for 8a5da09b9
Alan Modra [Tue, 10 Jun 2014 13:32:55 +0000 (23:02 +0930)] 
missing changelog entries for 8a5da09b9

9 years agoUnwrap symbols for debug information
Alan Modra [Tue, 10 Jun 2014 12:20:21 +0000 (21:50 +0930)] 
Unwrap symbols for debug information

Fixes issues with dwz multi-file (-m) and ld's -wrap option.
Symbols referenced from DWARF debug info in a separate file, eg. to
specify low and high pc, must use the real symbol.  The DWARF info
is specifying attributes of the real function, not one interposed
with --wrap.

include/
* bfdlink.h (unwrap_hash_lookup): Declare.
bfd/
* linker.c (unwrap_hash_lookup): New function.
* elf-bfd (RELOC_FOR_GLOBAL_SYMBOL): Call unwrap_hash_lookup.
* elf32-i370.c (i370_elf_relocate_section): Likewise.
* elf32-m32c.c (m32c_elf_relocate_section): Likewise.
* elf32-m32r.c (m32r_elf_relocate_section): Likewise.
* elf32-score.c (s3_bfd_score_elf_relocate_section): Likewise.
* elf32-score7.c (s7_bfd_score_elf_relocate_section): Likewise.
* elf32-spu.c (spu_elf_relocate_section): Likewise.
* elf64-hppa.c (elf64_hppa_relocate_section): Likewise.

9 years agothinko in serial.c::serial_write debug trace
Joel Brobecker [Fri, 6 Jun 2014 15:28:27 +0000 (11:28 -0400)] 
thinko in serial.c::serial_write debug trace

I noticed that, when using 'set debug serial 1', the "write" traces
would always be NUL characters:

    [
    w \x00][\x00][\x00][\x00][\x00][etc]

This is due to a small thinko in the loop that output each character,
where we accidently used the loop boundary instead of the loop index
to index the character to be printed.

After this patch is applied, the output now becomes:

    [
    w $][v][C][o][n][t][?][#][4][9]

gdb/ChangeLog:

* serial.c (serial_write): Fix index of character to be printed
in call to serial_logchar when serial debug traces are enabled.

9 years agogdbtypes.resolve_dynamic_range: Add function description.
Joel Brobecker [Tue, 10 Jun 2014 08:48:16 +0000 (10:48 +0200)] 
gdbtypes.resolve_dynamic_range: Add function description.

gdb/ChangeLog:

        * gdbtypes (resolve_dynamic_range): Add function description.

9 years agodaily update
Alan Modra [Tue, 10 Jun 2014 00:00:40 +0000 (09:30 +0930)] 
daily update

9 years agoAdd check to keep from segfaulting on a corrupt .debug_pubnames section.
Cary Coutant [Mon, 9 Jun 2014 21:55:02 +0000 (14:55 -0700)] 
Add check to keep from segfaulting on a corrupt .debug_pubnames section.

gold/
* dwarf_reader.cc (Dwarf_pubnames_table::read_header): Check that
unit_length is within section bounds.

9 years agoPrint unattached sections in the link map.
Cary Coutant [Mon, 9 Jun 2014 19:57:31 +0000 (12:57 -0700)] 
Print unattached sections in the link map.

gold/
PR gold/16980
* layout.cc (Layout::print_to_mapfile): Print unattached sections in
map.

9 years agoAdd space before the opening parenthesis in function descriptions.
Siva Chandra [Mon, 9 Jun 2014 13:47:22 +0000 (06:47 -0700)] 
Add space before the opening parenthesis in function descriptions.

gdb/doc
* python.texi (Xmethod API): Add space before the opening
parenthesis in function descriptions.

9 years agoCorrectly save and recall the CFA saved register state.
Romain Chastenet [Mon, 9 Jun 2014 14:06:58 +0000 (15:06 +0100)] 
Correctly save and recall the CFA saved register state.

PR binutils/16252
* dwarf.c (display_debug_frames): Remember the state of the
cfa_offset, cfa_reg, ra and cfa_exp field

9 years agoRemove reference to GASp from linker testsuite configuration.
Ryan Mansfield [Mon, 9 Jun 2014 14:04:01 +0000 (15:04 +0100)] 
Remove reference to GASp from linker testsuite configuration.

      * config/default.exp (GASP): Remove.

9 years agoUpdate expected disassembly of MSP430X instructions now that the disassembler
Nick Clifton [Mon, 9 Jun 2014 10:04:41 +0000 (11:04 +0100)] 
Update expected disassembly of MSP430X instructions now that the disassembler
correcctly interprets an extension word with zero index offsets.

* gas/msp430/msp430x.d: Update to match revised assembler output.

9 years agoFix a bunch of fork related regressions.
Pedro Alves [Mon, 9 Jun 2014 13:53:51 +0000 (14:53 +0100)] 
Fix a bunch of fork related regressions.

I'm seeing a ton of new FAILs in fork-related tests.  Like, these and
many more:

 +FAIL: gdb.base/disp-step-syscall.exp: vfork: continue to vfork (2nd time) (timeout)
 +FAIL: gdb.base/disp-step-syscall.exp: vfork: display/i $pc (timeout)
 ...
 -PASS: gdb.base/foll-vfork.exp: exec: vfork parent follow, through step: step
 +FAIL: gdb.base/foll-vfork.exp: exec: vfork parent follow, through step: step (timeout)
 -PASS: gdb.base/foll-vfork.exp: exec: vfork parent follow, to bp: continue to bp
 +FAIL: gdb.base/foll-vfork.exp: exec: vfork parent follow, to bp: continue to bp (timeout)
  ...
  FAIL: gdb.threads/watchpoint-fork.exp: parent: multithreaded: breakpoint (A) after the first fork (timeout)
  FAIL: gdb.threads/watchpoint-fork.exp: parent: multithreaded: watchpoint A after the first fork (timeout)
  FAIL: gdb.base/fileio.exp: System(3) call (timeout)
  FAIL: gdb.threads/watchpoint-fork.exp: parent: multithreaded: watchpoint B after the first fork (timeout)
 -PASS: gdb.base/multi-forks.exp: run to exit 2
 +FAIL: gdb.base/multi-forks.exp: run to exit 2 (timeout)
  ...
  PASS: gdb.base/watch-vfork.exp: Watchpoint on global variable (hw)
 -PASS: gdb.base/watch-vfork.exp: Watchpoint triggers after vfork (hw)
 +FAIL: gdb.base/watch-vfork.exp: Watchpoint triggers after vfork (hw) (timeout)
  PASS: gdb.base/watch-vfork.exp: Watchpoint on global variable (sw)
 -PASS: gdb.base/watch-vfork.exp: Watchpoint triggers after vfork (sw)
 +FAIL: gdb.base/watch-vfork.exp: Watchpoint triggers after vfork (sw) (timeout)

Three issues with
https://sourceware.org/ml/gdb-patches/2014-06/msg00348.html
(c077881a).

 - The inner 'status' local is shadowing the outer 'status' local,
   thus PTRACE_DETACH is never seeing the status it intends to pass on
   the inferior.

 - With that fixed, we then try to pass down the SIGTRAP that results
   from the step to the inferior.  Need to filter out signals that are
   in nopass state.

 - For software single-step archs, the current code is equivalent to:

      int status = 0;
      if (WIFSTOPPED (status))
        ptrace (PTRACE_DETACH, child_pid, 0, WSTOPSIG (status));

   ... and status == 0 is WIFEXITED, not WIFSTOPPED, so we're never
   detaching.

gdb/
2014-06-09  Pedro Alves  <palves@redhat.com>

* linux-nat.c (linux_child_follow_fork): Initialize status with
W_STOPCODE (0) instead of 0.  Remove shodowing 'status' local from
inner block.  Only pass the signal to PTRACE_DETACH if in pass
state.

9 years agoSeparate out ANSI-standard signals
Gary Benson [Mon, 9 Jun 2014 09:34:33 +0000 (10:34 +0100)] 
Separate out ANSI-standard signals

This commit reorders various pieces of code to separate ANSI-standard
signals from other signals that need checking.  Comments are added to
document this, and to document the ordering of the signals.

gdb/
2014-06-09  Gary Benson  <gbenson@redhat.com>

* common/signals.c (gdb_signal_from_host): Reorder to separate
the always-available ANSI-standard signals from the signals that
require checking.
(do_gdb_signal_to_host): Likewise.
* proc-events.c (signal_table): Likewise.

gdb/testsuite/
2014-06-09  Gary Benson  <gbenson@redhat.com>

* gdb.base/sigall.c [Functions to send signals]: Reorder to
separate the always-available ANSI-standard signals from the
signals that require checking.
(main): Likewise.
* gdb.reverse/sigall-reverse.c [Functions to send signals]:
Likewise.
(main): Likewise.

9 years agodaily update
Alan Modra [Mon, 9 Jun 2014 00:00:37 +0000 (09:30 +0930)] 
daily update

9 years agoFix gdb.base/watch-vfork.exp: Watchpoint triggers after vfork (sw) (timeout) with...
Hui Zhu [Sun, 8 Jun 2014 11:11:09 +0000 (19:11 +0800)] 
Fix gdb.base/watch-vfork.exp: Watchpoint triggers after vfork (sw) (timeout) with Linux 2.6.32 and older version
https://sourceware.org/ml/gdb-patches/2014-04/msg00047.html

Got gdb.base/watch-vfork.exp: Watchpoint triggers after vfork (sw)
(timeout) with Linux 2.6.32 and older version.

The rootcause is after the test use "set can-use-hw-watchpoints 0" let GDB
doesn't use hardware breakpoint and set a watchpoint on "global", GDB
continue will keep single step inside function "vfork".
The Linux 2.6.32 and older version doesn't have commit
6580807da14c423f0d0a708108e6df6ebc8bc83d (get more info please goto
http://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/commit/?id=6580807da14c423f0d0a708108e6df6ebc8bc83d).
When the function "vfork" do syscall, the single step flag TIF_SINGLESTEP
will copy to child process.
Then GDB detach it, child process and parent process will be hanged.

So I make a patch that do a single step before detach.  Then TIF_SINGLESTEP
of child process in old Linux kernel will be cleared before detach.
Child process in new Linux kernel will not be affected by this single step.

2014-06-08  Hui Zhu  <hui@codesourcery.com>

* common/linux-ptrace.c (linux_disable_event_reporting): New
function.
* common/linux-ptrace.h (linux_disable_event_reporting): New
declaration.
* linux-nat.c (linux_child_follow_fork): Do a single step before
detach.

9 years agodaily update
Alan Modra [Sun, 8 Jun 2014 00:00:45 +0000 (09:30 +0930)] 
daily update

9 years agoRevert patchset for c++/16253: it causes a large performance regression.
Keith Seitz [Sat, 7 Jun 2014 17:40:39 +0000 (10:40 -0700)] 
Revert patchset for c++/16253: it causes a large performance regression.
See the bug for further information.

9 years agoPROVIDE in linker script vs. built-in symbols
Alan Modra [Sat, 7 Jun 2014 04:28:53 +0000 (13:58 +0930)] 
PROVIDE in linker script vs. built-in symbols

* ldexp.c (exp_fold_tree_1 <etree_provide>): Make PROVIDEd
linker script symbol value override a built-in linker symbol.

9 years agoAllow both signed and unsigned fields in PowerPC cmpli insn
Alan Modra [Sat, 7 Jun 2014 02:39:04 +0000 (12:09 +0930)] 
Allow both signed and unsigned fields in PowerPC cmpli insn

There are legitimate reasons to allow a signed value in a cmpli insn
field, for example to test for a "stw r1,lock@sdarel(r13)" instruction
in user code, a kernel might use
subis r3,r3,STW_R1_0R13@ha # subtract off high part
cmplwi r3,lock@sdarel # is low part accessing lock?
Since the lock@sdarel may take a range of -32768 to 32767,
the allowed range of cmpli immediate must be at least [-32768,65535].

bfd/
* elf32-ppc.c (ppc_elf_relocate_section): Treat field of cmpli
insn as a bitfield; Use complain_overflow_bitfield.
* elf64-ppc.c (ppc64_elf_relocate_section): Likewise.
opcodes/
* ppc-opc.c (UISIGNOPT): Define and use with cmpli.
gas/
* config/tc-ppc.c (ppc_insert_operand): Handle PPC_OPERAND_SIGNOPT
on unsigned fields.  Comment on PPC_OPERAND_SIGNOPT signed fields
in 64-bit mode.
gold/
* powerpc.cc (relocate): Treat field of cmpli insn as a bitfield.

9 years agodaily update
Alan Modra [Sat, 7 Jun 2014 00:00:54 +0000 (09:30 +0930)] 
daily update

9 years agoStrip .debug_gnu_pubnames and .debug_gnu_pubtypes when building .gdb_index.
Cary Coutant [Fri, 6 Jun 2014 23:23:21 +0000 (16:23 -0700)] 
Strip .debug_gnu_pubnames and .debug_gnu_pubtypes when building .gdb_index.

When not stripping those sections, there was a bug where gold was incorrectly
adjusting section-relative offsets by the offset of the input section within
the output section. That adjustment was both unnecessary and wrong, causing
gold to miss a number of debug entries that should have been added to
.gdb_index.  (With stripping, the adjustment was always 0, so the bug in
dwarf_reader.cc would have been hidden by the change to layout.cc.)

gold/
* dwarf_reader.h (Dwarf_pubnames_table): Remove output_section_offset_.
* dwarf_reader.cc (Dwarf_pubnames_table::read_section): Likewise.
(Dwarf_pubnames_table::read_header): Likewise.
* layout.cc (gdb_fast_lookup_sections): Add .debug_gnu_pubnames and
.debug_gnu_pubtypes.

9 years agofix email address of previous checkins
Doug Evans [Fri, 6 Jun 2014 23:08:54 +0000 (16:08 -0700)] 
fix email address of previous checkins

9 years agoAdd support for guile 2.0.5.
Doug Evans [Fri, 6 Jun 2014 22:57:03 +0000 (15:57 -0700)] 
Add support for guile 2.0.5.

* guile/guile-internal.h (gdbscm_guile_major_version): Declare.
(gdbscm_guile_minor_version, gdbscm_guile_micro_version): Declare.
(gdbscm_guile_version_is_at_least): Declare.
(gdbscm_scm_string_to_int): Declare.
* guile/guile.c (gdbscm_guile_major_version): New global.
(gdbscm_guile_minor_version, gdbscm_guile_micro_version): New globals.
(guile_datadir): New static global.
(gdbscm_guile_data_directory): New function.
(initialize_scheme_side): Update.
(misc_guile_functions): Add guile-data-directory.
(initialize_gdb_module): Fetch guile version number.
* guile/lib/gdb.scm: Remove call to add-to-load-path.
* guile/lib/gdb/init.scm (%initialize!): Ditto.
* guile/lib/gdb/boot.scm: Use guile-data-directory.
* guile/scm-exception.c (gdbscm_print_exception_with_stack): Fix
comments.
* guile/scm-string.c (gdbscm_scm_string_to_int): New function.
* guile/scm-utils.c (gdbscm_guile_version_is_at_least): New function.
* guile/scm-value.c (gdbscm_value_to_string): Only call
scm_port_conversion_strategy if Guile version >= 2.0.6.

doc/
* guile.texi (Guile Configuration): Document guile-data-directory.

9 years ago* gdb.guile/scm-frame-args.c (foo): Tweak to work with gcc 4.6.3.
Doug Evans [Fri, 6 Jun 2014 22:41:09 +0000 (15:41 -0700)] 
* gdb.guile/scm-frame-args.c (foo): Tweak to work with gcc 4.6.3.

9 years agosss-bp-on-user-bp-2.exp sometimes fails on native GNU/Linux.
Pedro Alves [Fri, 6 Jun 2014 18:59:21 +0000 (19:59 +0100)] 
sss-bp-on-user-bp-2.exp sometimes fails on native GNU/Linux.

I noticed that sss-bp-on-user-bp-2.exp is racy on native GNU/Linux.  I
sometimes still see an int3 in the disassembly:

 (gdb) PASS: gdb.base/sss-bp-on-user-bp-2.exp: set debug target 0
 disassemble test
 Dump of assembler code for function test:
    0x0000000000400590 <+0>:     push   %rbp
    0x0000000000400591 <+1>:     mov    %rsp,%rbp
    0x0000000000400594 <+4>:     nop
 => 0x0000000000400595 <+5>:     int3
    0x0000000000400596 <+6>:     pop    %rbp
    0x0000000000400597 <+7>:     retq
 End of assembler dump.
 (gdb) FAIL: gdb.base/sss-bp-on-user-bp-2.exp: before/after disassembly matches

Enabling infrun/target debug logs, we can see the problem.
Simplified, that's:

 (gdb) PASS: gdb.base/sss-bp-on-user-bp-2.exp: define stepi_del_break
 stepi_del_break
 infrun: clear_proceed_status_thread (process 25311)
 infrun: resume (step=1, signal=GDB_SIGNAL_0), trap_expected=0, current thread [process 25311] at 0x400594
 LLR: PTRACE_SINGLESTEP process 25311, 0 (resume event thread)
 target_resume (25311, step, 0)
 native:target_xfer_partial (3, (null), 0x0, 0x32dce4c, 0x400595, 1) = 0, 0
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 (gdb) linux_nat_wait: [process -1], [TARGET_WNOHANG]

0x400595 is the address of the breakpoint, and "= 0" is
TARGET_XFER_EOF.  That's default_memory_remove_breakpoint trying to
remove the breakpoint, but failing.

The problem is that we had just resumed the target and the native
GNU/Linux target can't read memory off of a running thread.  Most of
the time, we get "lucky", because we manage to read memory before the
kernel actually schedules the target to run.

So just give up and skip the test on any target that uses hardware
stepping, not just remote targets.

gdb/testsuite/
2014-06-06  Pedro Alves  <palves@redhat.com>

* gdb.base/sss-bp-on-user-bp-2.exp: Look for target_resume(step)
in target debug output instead of looking at RSP packets,
disabling the test on any target that uses hardware stepping.
Update comments.

9 years agobreak-unload-file.exp: Fix typo.
Pedro Alves [Fri, 6 Jun 2014 14:52:24 +0000 (15:52 +0100)] 
break-unload-file.exp: Fix typo.

s/is not pending/is pending/

gdb/testsuite/
2014-06-06  Pedro Alves  <palves@redhat.com>

* gdb.base/break-unload-file.exp: Fix typo.

9 years agoRestrict the pattern in gdb.base/jit.exp
Yao Qi [Fri, 6 Jun 2014 11:16:47 +0000 (19:16 +0800)] 
Restrict the pattern in gdb.base/jit.exp

I see the following fail in some thumb multi-lib in arm-none-linux-gnueabi,

info function jit_function^M
All functions matching regular expression "jit_function":^M
^M
Non-debugging symbols:^M
0x00000790  __real_jit_function_XXXX^M
0x0000079c  __jit_function_XXXX_from_arm^M
0x0000079c  jit_function_0000^M
0x00000790  __real_jit_function_XXXX^M
0x0000079c  __jit_function_XXXX_from_arm^M
0x0000079c  jit_function_0001^M
(gdb) FAIL: gdb.base/jit.exp: one_jit_test-2: info function jit_function

the test expects to see only jit_function_0000 and jit_function_0001

one_jit_test 2 "${hex}  jit_function_0000\[\r\n\]+${hex}  jit_function_0001"

Symbols with the prefix "__real_" or suffix "_from_arm" is generated
by gcc/ld for arm/thumb interworking.

This patch is to restrict the pattern from "jit_function" to
"^jit_function", the output becomes expected.

gdb/testsuite:

2014-06-06  Yao Qi  <yao@codesourcery.com>

* gdb.base/jit.exp (one_jit_test): Restrict the pattern
from "jit_function" to "^jit_function".

9 years agoTweak gdb.base/async.exp
Yao Qi [Fri, 6 Jun 2014 06:32:42 +0000 (14:32 +0800)] 
Tweak gdb.base/async.exp

I see two fails in async.exp on arm-none-eabi target:

nexti&^M
(gdb) 0x000001ba        14       x = 5; x = 5;^M
completed.^M
FAIL: gdb.base/async.exp: nexti&
finish&^M
Run till exit from #0  0x000001ba in foo () at /scratch/yqi/arm-none-eabi-lite/src/gdb-trunk/gdb/testsuite/gdb.base/async.c:14^M
(gdb) 0x000001e6 in main () at /scratch/yqi/arm-none-eabi-lite/src/gdb-trunk/gdb/testsuite/gdb.base/async.c:32^M
32       y = foo ();^M
Value returned is $1 = 8^M
completed.^M
FAIL: gdb.base/async.exp: finish&

The corresponding test is "test_background "nexti&" "" ".*y = 3.*"",
and it assumes that GDB "nexti" into the next source line.  It is wrong
on arm.  After "nexti", it still stops at the same source line, and it
fails.

When gdb does "finish", if the PC is in the middle of a source line,
the PC address is printed too.  See stack.c:print_frame,

  if (opts.addressprint)
    if (!sal.symtab
|| frame_show_address (frame, sal)
|| print_what == LOC_AND_ADDRESS)
      {
annotate_frame_address ();
if (pc_p)
  ui_out_field_core_addr (uiout, "addr", gdbarch, pc);
else
  ui_out_field_string (uiout, "addr", "<unavailable>");
annotate_frame_address_end ();
ui_out_text (uiout, " in ");
      }

frame_show_address checks whether PC is the middle of a source line.
Since after "nexti", the inferior stops at the middle of a source line,
when we do "finish" the PC address is displayed.

In sum, GDB works well, but test case needs update.  This patch is to
add a statement at the same line to make sure "nexti" doesn't go to
the new line, match the next instruction address in the output and
match the hex address the output of "finish".

gdb/testsuite:

2014-06-06  Yao Qi  <yao@codesourcery.com>

* gdb.base/async.c (foo): Add one statement.
* gdb.base/async.exp: Get the next instruction address and
match the output of "nexti" by instruction address.  Match
the hex address in the output of "finish".

9 years agoupdate ChangeLog
xmj [Fri, 6 Jun 2014 09:51:30 +0000 (17:51 +0800)] 
update ChangeLog

9 years agoRemove preprocessor conditionals for ANSI-standard signals
Gary Benson [Fri, 6 Jun 2014 09:32:12 +0000 (10:32 +0100)] 
Remove preprocessor conditionals for ANSI-standard signals

The six signals SIGINT, SIGILL, SIGABRT, SIGFPE, SIGSEGV and SIGTERM
are ANSI-standard and thus guaranteed to be available.  This patch
removes all preprocessor conditionals relating to these symbols.

gdb/
2014-06-06  Gary Benson  <gbenson@redhat.com>

* common/signals.c: Remove preprocessor conditionals for
always-defined signals SIGINT, SIGILL, SIGABRT, SIGFPE,
SIGSEGV and SIGTERM.
* proc-events.c: Likewise.

gdb/testsuite/
2014-06-06  Gary Benson  <gbenson@redhat.com>

* gdb.base/call-signals.c: Remove preprocessor conditionals
for always-defined signals SIGINT, SIGILL, SIGABRT, SIGFPE,
SIGSEGV and SIGTERM.
* gdb.base/sigall.c: Likewise.
* gdb.base/unwindonsignal.c: Likewise.
* gdb.reverse/sigall-reverse.c: Likewise.

9 years agoadd -q in help info and doc
xmj [Fri, 6 Jun 2014 09:28:19 +0000 (17:28 +0800)] 
add -q in help info and doc

9 years agoSkip hbreak-unmapped.exp if memory at address 0 is readable
Yao Qi [Fri, 6 Jun 2014 03:05:05 +0000 (11:05 +0800)] 
Skip hbreak-unmapped.exp if memory at address 0 is readable

hbreak-unmapped.exp assumes that memory at address 0 is unmapped or
unreadable, but on bare metal or uclinux targets, memory at address
0 is readable.  For example, on arm-none-eabi, the vector table base
address is 0x0.

hbreak *0^M
Hardware assisted breakpoint 3 at 0x0: file
/scratch/yqi/arm-none-eabi-lite/obj/cs3-2014.11-999999-arm-none-eabi-i686-pc-linux-gnu/generated/arm-vector.S,
line 25.^M
(gdb) FAIL: gdb.base/hbreak-unmapped.exp: hbreak *0
info break^M
Num     Type           Disp Enb Address    What^M
3       hw breakpoint  keep y   0x00000000
/scratch/yqi/arm-none-eabi-lite/obj/cs3-2014.11-999999-arm-none-eabi-i686-pc-linux-gnu/generated/arm-vector.S:25^M
(gdb) FAIL: gdb.base/hbreak-unmapped.exp: info break shows hw breakpoint
delete $bpnum

This patch is to check whether address 0 is readable via command 'x 0'.
If it is, skip the test.

gdb/testsuite:

2014-06-06  Yao Qi  <yao@codesourcery.com>

* gdb.base/hbreak-unmapped.exp: Read memory at address 0.  If
readable, skip the test.

9 years agosymfile, vdso: remove target sections
Markus Metzger [Mon, 2 Jun 2014 09:35:22 +0000 (11:35 +0200)] 
symfile, vdso: remove target sections

Target sections added by the add-symbol-file-from-memory command are not
removed when the process exits.  In fact, they are not removed, at all.

This causes GDB to crash in gdb.base/break-interp.exp.

Change the owner of those target sections to the object file generated in
symbol_file_add_from_memory and generalize the free_objfile observer in
symfile.c to remove target sections of any freed object file.

9 years ago[AArch64] Fix the documentation on :pg_hi21:
Martin Storsjo [Fri, 6 Jun 2014 06:29:19 +0000 (07:29 +0100)] 
[AArch64] Fix the documentation on :pg_hi21:

9 years agoFix the race in gdb.threads/staticthreads.exp
Yao Qi [Thu, 5 Jun 2014 07:07:47 +0000 (15:07 +0800)] 
Fix the race in gdb.threads/staticthreads.exp

The code in gdb.threads/staticthreads.exp about checking the value of
tlsvar in main thread is racy, because when child thread hits
breakpoint, the main thread may not go into pthread_join yet, and
may not be unwind to main.

This patch is to move the line setting breakpoint on after sem_wait,
so that the child thread will hit breakpoint after main thread calls
sem_post.  IOW, when child thread hits breakpoint, the main thread is
in either sem_post or pthread_join.  "up 10" can unwind main thread to
main.

gdb/testsuite:

2014-06-06  Yao Qi  <yao@codesourcery.com>

* gdb.threads/staticthreads.c (thread_function): Move the line
setting breakpoint on forward.
* gdb.threads/staticthreads.exp: Update comments.

9 years agodaily update
Alan Modra [Fri, 6 Jun 2014 00:00:43 +0000 (09:30 +0930)] 
daily update

9 years agoguile: Type-check the argument to 'history-append!'.
Ludovic Courtès [Thu, 5 Jun 2014 22:02:33 +0000 (00:02 +0200)] 
guile: Type-check the argument to 'history-append!'.

gdb/
2014-06-05  Ludovic Courtès  <ludo@gnu.org>

* guile/scm-value.c (gdbscm_history_append_x): Use
'vlscm_get_value_smob_arg_unsafe' instead of
'vlscm_scm_to_value'.

gdb/testsuite/
2014-06-05  Ludovic Courtès  <ludo@gnu.org>

* gdb.guile/scm-value.exp (test_value_in_inferior): Add test
"history-append! type error".

9 years agoPR mi/15806: Fix quoting of async events
Simon Marchi [Mon, 2 Jun 2014 21:10:36 +0000 (17:10 -0400)] 
PR mi/15806: Fix quoting of async events

Original patch:
https://sourceware.org/ml/gdb-patches/2014-04/msg00552.html

New in v2:
* In remote.c:escape_buffer, pass '\\' to fputstrn_unfiltered/printchar to
make sure backslashes are escaped in remote debug output.
* Updated function documentation for printchar.

See updated ChangeLog below.

--------------------

The quoting in whatever goes in the event_channel of MI is little bit broken.

Link for the lazy:
  https://sourceware.org/bugzilla/show_bug.cgi?id=15806

Here is an example of a =library-loaded event with an ill-named directory,
/tmp/how"are\you (the problem is present with every directory on Windows since
it uses backslashes as a path separator). The result will be the following:

=library-loaded,id="/tmp/how"are\\you/libexpat.so.1",...

The " between 'how' and 'are' should be escaped.

Another bad behavior is double escaping in =breakpoint-created, for example:

=breakpoint-created,bkpt={...,fullname="/tmp/how\\"are\\\\you/test.c",...}

The two backslashes before 'how' should be one and the four before 'you' should
be two.

The reason for this is that when sending something to an MI console, escaping
can take place at two different moments (the actual escaping work is always
done in the printchar function):

1. When generating the content, if ui_out_field_* functions are used. Here,
fields are automatically quoted with " and properly escaped. At least
mi_field_string does it, not sure about mi_field_fmt, I need to investigate
further.

2. When gdb_flush is called, to send the data in the buffer of the console to
the actual output (stdout). At this point, mi_console_raw_packet takes the
whole string in the buffer, quotes it, and escapes all occurences of the
quoting character and backslashes. The event_channel does not specify a quoting
character, so quotes are not escaped here, only backslashes.

The problem with =library-loaded is that it does use fprintf_unfiltered, which
doesn't do escaping (so, no #1). When gdb_flush is called, backslashes are
escaped (#2).

The problem with =breakpoint-created is that it first uses ui_out_field_*
functions to generate its output, so backslashes and quotes are escaped there
(#1). backslashes are escaped again in #2, leading to an overdose of
backslashes.

In retrospect, there is no way escaping can be done reliably in
mi_console_raw_packet for data that is already formatted, such as
event_channel. At this point, there is no way to differentiate quotes that
delimit field values from those that should be escaped. In the case of other MI
consoles, it is ok since mi_console_raw_packet receives one big string that
should be quoted and escaped as a whole.

So, first part of the fix: for the MI channels that specify no quoting
character, no escaping at all should be done in mi_console_raw_packet (that's
the change in printchar, thanks to Yuanhui Zhang for this). For those channels,
whoever generates the content is responsible for proper quoting and escaping.
This will fix the =breakpoint-created kind of problem.

Second part of the fix is to make =library-loaded generate content that is
properly escaped. For this, we use ui_out_field_* functions, instead of one big
fprintf_unfiltered. =library-unloaded suffered from the same problem so it is
modified as well. There might be other events that need fixing too, but that's
all I found with a quick scan. Those that use fprintf_unfiltered but whose sole
variable data is a %d are not critical, since it won't generate a " or a \.

Finally, a test has been fixed, as it was expecting an erroneous output.
Otherwise, all other tests that were previously passing still pass (x86-64
linux).

gdb/ChangeLog:

2014-06-02  Simon Marchi  <simon.marchi@ericsson.com>

PR mi/15806
* utils.c (printchar): Don't escape at all if quoter is NUL.
Update function documentation to clarify effect of parameter
QUOTER.
* remote.c (escape_buffer): Pass '\\' as the quoter to
fputstrn_unfiltered.
* mi/mi-interp.c (mi_solib_loaded): Use ui_out_field_* functions to
generate the output.
(mi_solib_unloaded): Same.

gdb/testsuite/ChangeLog:

2014-06-02  Simon Marchi  <simon.marchi@ericsson.com>

* gdb.mi/mi-breakpoint-changed.exp (test_insert_delete_modify): Fix
erroneous dprintf expected input.

9 years agoMake it easy to make --disable-werror the default for both binutils and gdb
Joel Brobecker [Mon, 19 May 2014 21:46:01 +0000 (14:46 -0700)] 
Make it easy to make --disable-werror the default for both binutils and gdb

The goal of this patch is to provide an easy way to make
--disable-werror the default when building binutils, or the parts
of binutils that need to get built when building GDB. In development
mode, we want to continue making -Werror the default with GCC.
But, when making releases, I think we want to make it as easy as
possible for regular users to successfully build from sources.

GDB already has this kind of feature to turn -Werror as well as
the use of the libmcheck library. As GDB Release Manager, I take
advantage of it to turn those off after having cut the branch.
I'd like to be able to do the same for the binutils bits. And
perhaps Tristan will want to do the same for his releases too
(not sure, binutils builders might be a little savvier than GDB
builders).

This patch introduces a new file, called development.sh, which
just sets a variable called $development. In our development branches
(Eg. "master"), it's set to true. But setting it to false would allow
us to change the default behavior of various development-related
features to be turned off; in this case, it turns off the use of
-Werror by default (use --enable-werror to turn it back on).

bfd/ChangeLog:

        * development.sh: New file.
        * warning.m4 (AM_BINUTILS_WARNINGS): Source bfd/development.sh.
        Make -Werror the default with GCC only if DEVELOPMENT is true.
        * Makefile.am (CONFIG_STATUS_DEPENDENCIES): Add
        $(srcdir)/development.sh.
        * Makefile.in, configure: Regenerate.

binutils/ChangeLog:

        * Makefile.am (CONFIG_STATUS_DEPENDENCIES): Add dependency on
        bfd's development.sh.
        * Makefile.in, configure: Regenerate.

gas/ChangeLog:

        * Makefile.am (CONFIG_STATUS_DEPENDENCIES): Add dependency on
        bfd's development.sh.
        * Makefile.in, configure: Regenerate.

gold/ChangeLog:

        * Makefile.am (CONFIG_STATUS_DEPENDENCIES): New.
        * Makefile.in, configure: Regenerate.

gprof/ChangeLog:

        * Makefile.am (CONFIG_STATUS_DEPENDENCIES): Add dependency on
        bfd's development.sh.
        * Makefile.in, configure: Regenerate.

ld/ChangeLog:

        * Makefile.am (CONFIG_STATUS_DEPENDENCIES): Add dependency on
        bfd's development.sh.
        * Makefile.in, configure: Regenerate.

opcodes/ChangeLog:

        * Makefile.am (CONFIG_STATUS_DEPENDENCIES): Add dependency on
        bfd's development.sh.
        * Makefile.in, configure: Regenerate.

gdb/ChangeLog:

        * development.sh: Delete.
        * Makefile.in (config.status): Adjust dependency on development.sh.
        * configure.ac: Adjust development.sh source call.
        * configure: Regenerate.

gdb/gdbserver/ChangeLog:

        * configure.ac: Adjust development.sh source call.
        * Makefile.in (config.status): Adjust dependency on development.sh.
        * configure: Regenerate.

Tested on x86_64-linux by building two ways: One with DEVELOPMENT
set to true, and one with DEVELOPMENT set to false. In the first
case, I could see the use of -Werror, while it disappeared in
the second case.

This page took 0.065972 seconds and 4 git commands to generate.