Commit Graph

83672 Commits

Author SHA1 Message Date
Pedro Alves 8d707a12ef gdb/18216: displaced step+deliver signal, a thread needs step-over, crash
The problem is that with hardware step targets and displaced stepping,
"signal FOO" when stopped at a breakpoint steps the breakpoint
instruction at the same time it delivers a signal.  This results in
tp->stepped_breakpoint set, but no step-resume breakpoint set.  When
the next stop event arrives, GDB crashes.  Irrespective of whether we
should do something more/different to step past the breakpoint in this
scenario (e.g., PR 18225), it's just wrong to assume there'll be a
step-resume breakpoint set (and was not the original intention).

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

	PR gdb/18216
	* infrun.c (process_event_stop_test): Don't assume a step-resume
	is set if tp->stepped_breakpoint is true.

gdb/testsuite/ChangeLog:
2015-04-10  Pedro Alves  <palves@redhat.com>

	PR gdb/18216
	* gdb.threads/multiple-step-overs.exp: Remove expected eof.
2015-04-10 10:36:23 +01:00
Yao Qi ef713951c5 [arm] Fix displaced stepping for thumb alu reg instruction
Recent patch series "V2 All-stop on top of non-stop" causes a SIGSEGV
in the test case,

> -PASS: gdb.base/info-shared.exp: continue to breakpoint: library function #4
> +FAIL: gdb.base/info-shared.exp: continue to breakpoint: library function #4
>
> continue^M
> Continuing.^M
> ^M
> Program received signal SIGSEGV, Segmentation fault.^M
> 0x40021564 in ?? () gdb/testsuite/gdb.base/info-shared-solib1.so^M
> (gdb) FAIL: gdb.base/info-shared.exp: continue to breakpoint: library function #4

and an ARM displaced stepping bug is exposed.  It can be reproduced by
the modified gdb.arch/arm-disp-step.exp as below,

continue^M
Continuing.^M
^M
Program received signal SIGSEGV, Segmentation fault.^M
0xa713cfcc in ?? ()^M
(gdb) FAIL: gdb.arch/arm-disp-step.exp: continue to breakpoint: continue to test_add_rn_pc_end

This patch is to fix it.

gdb:

2015-04-10  Yao Qi  <yao.qi@linaro.org>

	* arm-tdep.c (install_alu_reg): Update comment.
	(thumb_copy_alu_reg): Remove local variable rn.  Update
	debugging message.  Use r2 instead of r1 in the modified
	instruction.

gdb/testsuite:

2015-04-10  Yao Qi  <yao.qi@linaro.org>

	* gdb.arch/arm-disp-step.S (main): Call test_add_rn_pc.
	(test_add_rn_pc): New function.
	* gdb.arch/arm-disp-step.exp (test_add_rn_pc): New proc.
	(top level): Invoke test_add_rn_pc.
2015-04-10 10:33:01 +01:00
Pedro Alves 906d60cf46 PR13858 - Can't do displaced stepping with no symbols
Running break-interp.exp with the target always in non-stop mode trips
on PR13858, as enabling non-stop also enables displaced stepping.

The problem is that when GDB doesn't know where the entry point is, it
doesn't know where to put the displaced stepping scratch pad.  The
test added by this commit exercises this.  Without the fix, we get:

 (gdb) PASS: gdb.base/step-over-no-symbols.exp: displaced=on: break *$pc
 set displaced-stepping on
 (gdb) PASS: gdb.base/step-over-no-symbols.exp: displaced=on: set displaced-stepping on
 stepi
 0x00000000004005be in ?? ()
 Entry point address is not known.
 (gdb) PASS: gdb.base/step-over-no-symbols.exp: displaced=on: stepi
 p /x $pc
 $2 = 0x4005be
 (gdb) PASS: gdb.base/step-over-no-symbols.exp: displaced=on: get after PC
 FAIL: gdb.base/step-over-no-symbols.exp: displaced=on: advanced

The fix switches all GNU/Linux ports to get the entry point from
AT_ENTRY in the target auxiliary vector instead of from symbols.  This
is currently only done by PPC when Cell debugging is enabled, but I
think all archs should be able to do the same.  Note that
ppc_linux_displaced_step_location cached the result, I'm guessing to
avoid constantly re-fetching the auxv out of remote targets, but
that's no longer necessary nowadays, as the auxv blob is itself cached
in the inferior object.  The ppc_linux_entry_point_addr global is
obviously bad for multi-process too nowadays.

Tested on x86-64 (-m64/-m32), PPC64 (-m64/-m32) and S/390 GNU/Linux.
Yao tested the new test on ARM as well.

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

	PR gdb/13858
	* amd64-linux-tdep.c (amd64_linux_init_abi_common): Install
	linux_displaced_step_location as gdbarch_displaced_step_location
	hook.
	* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
	* i386-linux-tdep.c (i386_linux_init_abi): Likewise.
	* linux-tdep.c (linux_displaced_step_location): New function,
	based on ppc_linux_displaced_step_location.
	* linux-tdep.h (linux_displaced_step_location): New declaration.
	* ppc-linux-tdep.c (ppc_linux_entry_point_addr): Delete.
	(ppc_linux_inferior_created, ppc_linux_displaced_step_location):
	Delete.
	(ppc_linux_init_abi): Install linux_displaced_step_location as
	gdbarch_displaced_step_location hook, even without Cell/B.E..
	(_initialize_ppc_linux_tdep): Don't install
	ppc_linux_inferior_created as inferior_created observer.
	* s390-linux-tdep.c (s390_gdbarch_init): Install
	linux_displaced_step_location as gdbarch_displaced_step_location
	hook.

gdb/testsuite/
2015-04-10  Pedro Alves  <palves@redhat.com>

	PR gdb/13858
	* gdb.base/step-over-no-symbols.exp: New file.
2015-04-10 10:07:02 +01:00
Alan Modra 8c3fff59dc Correct setting of elf_list_options
* configure.ac: Set elf_list_options etc. in proper case.
	* configure: Regenerate.
2015-04-10 18:22:50 +09:30
Jan Kratochvil e7a8570f75 doc patch: compile: missing bits
gdb/doc/ChangeLog
2015-04-10  Jan Kratochvil  <jan.kratochvil@redhat.com>
	    Eli Zaretskii  <eliz@gnu.org>

	* gdb.texinfo (Compiling and Injecting Code): Describe set debug
	compile, show debug compile.  New subsection Compilation options for
	the compile command.  New subsection Compiler search for the compile
	command.
2015-04-10 10:34:51 +02:00
Nick Clifton 080bb7bbe9 Add documentation about the interation of the ARM assembler's -EB option and the linker's --be8 option.
PR binutils/18198
	* ld.texinfo (--be8): Add a note about the interaction of this
	option with the assembler's -EB option.

	* doc/c-arm.texi (ARM Options): Add a note about the interaction of
	the -EB option with the linker's --be8 option.
2015-04-10 08:26:07 +01:00
Alan Modra 6166ed9330 Mark _init and _fini for --gc-sections
gold marks _init and _fini via symbol, ld marks them via section
(default scripts set .init and .fini section KEEP).  This makes it
possible for people to write their own _init and not bother to put the
function into the right section.

	PR ld/18223
	* ldlang.c (lang_process): Add _init and _fini to gc_sym_list.
2015-04-10 10:27:03 +09:30
GDB Administrator 4f0d8f2d9f Automatic date update in version.in 2015-04-10 00:00:08 +00:00
Cary Coutant a6a177507c Allow gold to resolve defined TLS symbols in a PIE link.
This patch fixes Symbol::final_value_is_known so that a defined TLS symbol
in a PIE link is treated as having a known final value, thus allowing
GD->LE TLS optimization, eliminating an unnecessary GOT entry and dynamic
relocation.

gold/
	* symtab.cc (Symbol::final_value_is_known): Check for TLS symbol
	in a PIE link.
	* testsuite/Makefile.am (tls_pie_test.sh): New test.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/tls_pie_test.sh: New.
2015-04-09 15:47:37 -07:00
H.J. Lu 18ece1defb Update comments in compress.c
* compress.c (bfd_compress_section_contents): Update comments.
	(bfd_init_section_decompress_status): Likewise.
	(bfd_init_section_compress_status): Likewise.
2015-04-09 12:48:49 -07:00
Hans-Peter Nilsson 4b5708f5d9 doc/c-rx.texi: Fix markup typos in last change. 2015-04-09 21:09:02 +02:00
Cary Coutant 437ddf0c4c Improve ODR checking in gold.
gold/
	* debug.h (DEBUG_LOCATION): New.
	(DEBUG_ALL): Include DEBUG_LOCATION.
	(debug_string_to_enum): Add DEBUG_LOCATION.
	* dwarf_reader.cc (Sized_dwarf_line_info::read_lines): Fix debug
	output to print correct context.
	(Sized_dwarf_line_info::do_addr2line): Add debug output. Return
	up to 4 more locations at the beginning of the function.
	* symtab.cc (Symbol_table::detect_odr_violations): Get canonical
	result before sorting list of line numbers.
	* testsuite/debug_msg.sh: Allow range of line numbers for
	canonical results on optimized code.
2015-04-09 11:53:01 -07:00
H.J. Lu cd6faa73f8 Properly check --compress-debug-sections=XXX
We can't check if input is ELF in copy_file since some targets may only
set xvec after bfd_check_format_matches is called.  This patch moves
this check to copy_object.

bfd/

	* elfxx-target.h (TARGET_BIG_SYM): Add BFD_COMPRESS_GABI to
	object_flags.
	(TARGET_LITTLE_SYM): Likewise.

binutils/

	* objcopy.c (do_debug_sections): Use bit patterns.
	(copy_object): Return FALSE for compress_zlib, compress_gnu_zlib
	and compress_gabi_zlib on non-ELF input.
	(copy_file): Don't check non-ELF input here.
2015-04-09 10:56:28 -07:00
Max Filippov 1942484389 xtensa: update bfd/Changelog 2015-04-09 19:27:53 +03:00
Max Filippov 4c2af04fe8 xtensa: replace action list with splay tree
text_action_add uses linear list search to order text actions list by
action VMA. The list is used at the first relaxation pass, when it's not
fixed yet.
Replace the list with splay tree from libiberty.

Original profile:

% time    self  children    called     name
-----------------------------------------
          0.00    0.00      14/158225      compute_text_actions
          3.62    0.00   25211/158225      remove_dead_literal
          8.42    0.00   58645/158225      coalesce_shared_literal
         10.68    0.00   74355/158225      text_action_add_proposed
  38.8   22.73    0.00  158225         text_action_add
          0.00    0.00  144527/293246      bfd_zmalloc
-----------------------------------------

Same data, after optimization:

% time    self  children    called     name
-----------------------------------------
          0.00    0.00      14/158225      compute_text_actions
          0.00    0.00   25211/158225      remove_dead_literal
          0.00    0.01   58645/158225      coalesce_shared_literal
          0.00    0.01   74355/158225      text_action_add_proposed
   0.1    0.00    0.02  158225         text_action_add
          0.01    0.00  144527/144527      splay_tree_insert
          0.00    0.00  144527/195130      splay_tree_lookup
          0.00    0.00  144527/293246      bfd_zmalloc
-----------------------------------------

2015-04-03  Max Filippov  <jcmvbkbc@gmail.com>
bfd/
	* elf32-xtensa.c (splay-tree.h): include header.
	(text_action_struct): drop next pointer.
	(text_action_list_struct): drop head pointer, add count and
	tree fields.
	(find_fill_action): instead of linear search in text_action_list
	search in the tree.
	(text_action_compare, action_first, action_next): new functions.
	(text_action_add, text_action_add_literal): instead of linear
	search and insertion insert new node into the tree.
	(removed_by_actions): pass additional parameter: action_list,
	use it to traverse the tree.
	(offset_with_removed_text): pass additional action_list parameter
	to removed_by_actions.
	(map_action_fn_context): new typedef.
	(map_action_fn_context_struct): new structure.
	(map_action_fn): new function.
	(map_removal_by_action): use splay_tree_foreach to build map.
	(find_insn_action): replace linear search in text_action_list
	with series of splay_tree_lookups.
	(print_action, print_action_list_fn): new functions.
	(print_action_list): use splay_tree_foreach.
	(init_xtensa_relax_info): drop action_list.head initialization.
	Initialize the tree.
	(compute_text_actions): use non-zero action_list_count instead of
	non-NULL action list.
	(xlate_map_context): new typedef.
	(xlate_map_context_struct): new structure.
	(xlate_map_fn): new function.
	(build_xlate_map): use splay_tree_foreach to build map.
	(action_remove_bytes_fn): new function.
	(relax_section): use zero action_list_count instead of NULL
	action list. Use splay_tree_foreach to count final section size.
	Drop unused variable 'removed'.
2015-04-09 19:10:25 +03:00
Max Filippov 3439c46627 xtensa: optimize find_removed_literal
find_removed_literal uses linear search to find removed literal by its
VMA. The list of literals is fixed at that point, build an ordered index
array and use binary search instead.

Original profile:

% time    self  children    called     name
-----------------------------------------
         56.72    0.00  297578/669392      translate_reloc
         70.86    0.00  371814/669392      relax_section
  67.9  127.58    0.00  669392         find_removed_literal
-----------------------------------------

Same data, after optimization:

% time    self  children    called     name
-----------------------------------------
          0.00    0.00  297578/669392      translate_reloc
          0.00    0.00  371814/669392      relax_section
   0.0    0.00    0.00  669392         find_removed_literal
          0.00    0.00   23838/23838       map_removed_literal
-----------------------------------------

2015-04-03  Max Filippov  <jcmvbkbc@gmail.com>
bfd/
	* elf32-xtensa.c (removed_literal_map_entry): new typedef.
	(removed_literal_map_entry_struct): new structure.
	(removed_literal_list_struct): add new fields: n_map and map.
	(map_removed_literal, removed_literal_compare): new functions.
	(find_removed_literal): build index array for literals ordered
	by VMA, use binary search to find removed literal.
2015-04-09 19:10:25 +03:00
Max Filippov 071aa5c98a xtensa: optimize removed_by_actions
The function removed_by_actions iterates through text actions to
calculate an offset applied by text actions to a given VMA. Although it
has a parameter p_start_action that allows for incremental offset
calculation, in many places it's used with p_start_action explicitly set
to the first action. After the first relaxation pass when the list of
text actions is finalized, an array of offsets sorted by VMA may be used
to speed up this function.

Original profile:

% time    self  children    called     name
-----------------------------------------
          0.35    0.00   33872/4808961     relax_section_symbols
          3.32    0.00  326022/4808961     relax_property_section
         12.83    0.00 1259379/4808961     offset_with_removed_text
         32.50    0.00 3189688/4808961     translate_reloc
  71.5   49.00    0.00 4808961         removed_by_actions
-----------------------------------------

Same data, after optimization:

% time    self  children    called     name
-----------------------------------------
          0.00    0.00   33872/4808537     relax_section_symbols
          0.01    0.00  326022/4808537     relax_property_section
          0.05    0.00 1258955/4808537     offset_with_removed_text_map
          0.13    0.00 3189688/4808537     translate_reloc
   1.0    0.20    0.00 4808537         removed_by_actions_map
          0.00    0.00     120/120         map_removal_by_action
-----------------------------------------

2015-04-01  Max Filippov  <jcmvbkbc@gmail.com>
bfd/
	* elf32-xtensa.c (removal_by_action_entry_struct,
	removal_by_action_map_struct): new structures.
	(removal_by_action_entry, removal_by_action_map): new typedefs.
	(text_action_list_struct): add new field: map.
	(map_removal_by_action, removed_by_actions_map,
	offset_with_removed_text_map): new functions.
	(relax_section): replace offset_with_removed_text with
	offset_with_removed_text_map.
	(translate_reloc, relax_property_section, relax_section_symbols):
	replace removed_by_actions with removed_by_actions_map.
2015-04-09 19:10:25 +03:00
Max Filippov b2b326d246 xtensa: optimize check_section_ebb_pcrels_fit
The original check_section_ebb_pcrels_fit algorithm checks that text
actions proposed for current EBB are OK for every relocation in a
section. There's no need to check every relocation, because text actions
for EBB can only change size of that EBB, thus only affecting
relocations that in any way cross that EBB. In addition EBBs are
iterated in ascending order of their VMA, making it easier to track
relevant relocations.

Introduce a structure that can track relocations that cross the range of
VMAs of EBB and use it to only check relocations relevant to current EBB
in check_section_ebb_pcrels_fit.
It takes O(N log N) operations to build it and O(N) operations to move
current EBB VMA window through its entire range, where N is the number
of relocations in a section. The resulting complexity of
compute_text_actions is thus reduced from O(N^2) to O(N log N + N * M),
where M is the average number of relocations crossing each EBB.

Original profile:

% time    self  children    called     name
-----------------------------------------
         44.26   71.53    6429/6429        compute_text_actions
  50.2   44.26   71.53    6429         check_section_ebb_pcrels_fit
          1.16   20.12 347506666/347576152     pcrel_reloc_fits
          2.95   16.52 347506666/348104944     get_relocation_opnd
          2.01    9.74 347575100/361252208     r_reloc_init
          0.55    7.53 347575100/363381467     r_reloc_get_section
          5.76    0.02 695013332/695013332     xlate_offset_with_removed_text
          0.68    3.89 347575100/363483827     bfd_octets_per_byte
          0.32    0.00 347506666/349910253     is_alt_relocation
          0.18    0.11    6391/6391        build_xlate_map
          0.00    0.00    6429/19417168     get_xtensa_relax_info
          0.00    0.00    6391/6391        free_xlate_map
-----------------------------------------

Same data, after optimization:

% time    self  children    called     name
-----------------------------------------
          2.56    3.08    6429/6429        compute_text_actions
   8.2    2.56    3.08    6429         check_section_ebb_pcrels_fit
          0.08    0.91 17721075/17790561     pcrel_reloc_fits
          0.17    0.47 17721075/31685977     r_reloc_init
          0.43    0.00 35442150/35442150     xlate_offset_with_removed_text
          0.02    0.37 17721075/33815236     r_reloc_get_section
          0.22    0.11    6391/6391        build_xlate_map
          0.05    0.22 17721075/33917596     bfd_octets_per_byte
          0.03    0.00 17721075/20405299     is_alt_relocation
          0.01    0.00    6429/6429        reloc_range_list_update_range
          0.00    0.00    6429/19417168     get_xtensa_relax_info
          0.00    0.00    6391/6391        free_xlate_map
-----------------------------------------

2015-04-01  Max Filippov  <jcmvbkbc@gmail.com>
bfd/
	* elf32-xtensa.c (reloc_range_list, reloc_range_list_entry,
	reloc_range): new typedef.
	(reloc_range_list_struct, reloc_range_list_entry_struct,
	reloc_range_struct): new structures.
	(reloc_range_compare, build_reloc_ranges,
	reloc_range_list_append, reloc_range_list_remove,
	reloc_range_list_update_range, free_reloc_range_list): new
	functions.
	(compute_text_actions): precompute relocation opcodes before the
	loop. Add relevant_relocs variable, initialize it before the
	loop, pass it to the check_section_ebb_pcrels_fit.
	(check_section_ebb_pcrels_fit): add new parameter:
	relevant_relocs. Update address range in the relevant_relocs if
	it's non-NULL and iterate only over relevant relocations.
2015-04-09 19:10:24 +03:00
H.J. Lu eba27bd781 Remove BNDPLT and add PARSE_AND_LIST_ARGS_CASE_Z
* emulparams/elf_x86_64.sh (BNDPLT): Removed.
	(PARSE_AND_LIST_OPTIONS): New.
	(PARSE_AND_LIST_ARGS_CASE_Z): Likewise.
	* emultempl/elf32.em (gld${EMULATION_NAME}_handle_option): Remove
	BNDPLT check.  Handle PARSE_AND_LIST_ARGS_CASE_Z.
	(gld${EMULATION_NAME}_list_options): Remove BNDPLT check.
2015-04-09 07:53:00 -07:00
Gary Benson 7823a9415b Rename common-remote-fileio.[ch] as fileio.[ch]
This commit renames common-remote-fileio.[ch] as fileio.[ch]
and renames all functions in these files.

gdb/ChangeLog:

	* common/common-remote-fileio.h: Rename to...
	* common/fileio.h: ...this.  Update all references.
	(remote_fileio_to_fio_error): Rename to...
	(host_to_fileio_error): ...this.
	(remote_fileio_to_be): Rename to...
	(host_to_bigendian): ...this.  Update all callers.
	(remote_fileio_to_fio_uint): Rename to...
	(host_to_fileio_uint): ...this.  Update all callers.
	(remote_fileio_to_fio_time): Rename to...
	(host_to_fileio_time): ...this.  Update all callers.
	(remote_fileio_to_fio_stat): Rename to...
	(host_to_fileio_stat): ...this.
	Update all references.
	* common/common-remote-fileio.c: Rename to...
	* common/fileio.c: ...this.  Update all references.
	(remote_fileio_to_fio_error): Rename to...
	(host_to_fileio_error): ...this.  Update all callers.
	(remote_fileio_mode_to_target): Rename to...
	(fileio_mode_pack): ...this.  Update all callers.
	(remote_fileio_to_fio_mode): Rename to...
	(host_to_fileio_mode): ...this.  Update all callers.
	(remote_fileio_to_fio_ulong): Rename to...
	(host_to_fileio_ulong): ...this.  Update all callers.
	(remote_fileio_to_fio_stat): Rename to...
	(host_to_fileio_stat): ...this.  Update all callers.
2015-04-09 15:44:31 +01:00
Nick Clifton 233723a43c Update French translation of ld strings.
* po/fr.po: Updated French translation.
2015-04-09 14:56:29 +01:00
Andy Wingo f2983cc34e Add Guile frame-read-register command
gdb/ChangeLog:

	* guile/scm-frame.c (gdbscm_frame_read_register): New function.
	(frame_functions): Bind gdbscm_frame_read_register to
	frame-read-register.
	* guile/lib/gdb.scm (frame-read-register): Export.

gdb/doc/ChangeLog:

	* guile.texi (Frames In Guile): Describe frame-read-register.

gdb/testsuite/ChangeLog:

	* gdb.guile/scm-frame.exp: Add frame-read-register tests, modelled
	after the Python tests.
2015-04-09 14:39:00 +02:00
Gary Benson b88bb45061 Introduce new shared function remote_fileio_to_fio_error
This commit introduces a new shared function to replace three
identical functions in various places in the codebase.

gdb/ChangeLog:

	* common/common-remote-fileio.h (remote_fileio_to_fio_error):
	New declaration.
	* common/common-remote-fileio.c (remote_fileio_to_fio_error):
	New function, factored out the named functions below.
	* inf-child.c (gdb/fileio.h): Remove include.
	(common-remote-fileio.h): New include.
	(inf_child_errno_to_fileio_error): Remove function.  Update
	all callers to use remote_fileio_to_fio_error.
	* remote-fileio.c (remote_fileio_errno_to_target): Likewise.

gdb/gdbserver/ChangeLog:

	* hostio-errno.c (errno_to_fileio_error): Remove function.
	Update caller to use remote_fileio_to_fio_error.
2015-04-09 13:26:32 +01:00
Andy Wingo 2f2680f33a Add myself to Write After Approval list.
gdb/ChangeLog:

	* MAINTAINERS (Write After Approval): Add Andy Wingo.
2015-04-09 13:56:32 +02:00
Nick Clifton 3525236c57 Add support to the RX toolchain to restrict the use of string instructions.
bfd	* elf32-rx.c (describe_flags): Report the settings of the string
	insn using bits.
	(rx_elf_merge_private_bfd_data): Handle merging of the string insn
	using bits.

bin	* readelf.c (get_machine_flags): Report the setting of the string
	insn using bits.

gas	* config/tc-rx.c (enum options): Add OPTION_DISALLOW_STRING_INSNS.
	(md_longopts): Add -mno-allow-string-insns.
	(md_parse_option): Handle -mno-allow-string-insns.
	(md_show_usage): Mention -mno-allow-string-insns.
	(rx_note_string_insn_use): New function.  Produces an error
	message if a string insn is used when it is not allowed.
	* config/rx-parse.y (SCMPU): Call rx_note_string_insn_use.
	(SMOVU, SMOVB, SMOVF, SUNTIL, SWHILE, RMPA): Likewise.
	* config/rx-defs.h (rx_note_string_insn_use): Prototype.
	* doc/c-rx.texi: Document -mno-allow-string-insns.

elf	* rx.h (E_FLAG_RX_SINSNS_SET): New bit in e_flags field.
	(E_FLAG_RX_SINSNS_YES): Likewise.
	(E_FLAG_RX_SINSNS_MASK): New define.
2015-04-09 12:48:37 +01:00
H.J. Lu 5a2d4533e2 Replace $zlibdir with $ZLIBDIR in LDFLAGS
* acinclude.m4: (GDB_AC_CHECK_BFD): Set ZLIBDIR with $zlibdir.
	Replace $zlibdir with $ZLIBDIR in LDFLAGS.
	* configure: Regenerated.
2015-04-09 04:43:57 -07:00
Pedro Alves 421693b020 Import strtok_r gnulib module
gdb/linux-tdep.c recently gained a strtok_r use.  That broke
--enable-targets=all with some versions of mingw64, which don't have
strtok_r:

  https://sourceware.org/ml/gdb-patches/2015-04/msg00266.html

Fix that by importing the strtok_r gnulib module.

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

	* gnulib/update-gnulib.sh (IMPORTED_GNULIB_MODULES): Add strtok_r.
	* gnulib/Makefile.in (aclocal_m4_deps): Add import/m4/strtok_r.m4.
	* gnulib/configure, gnulib/config.in, gnulib/aclocal.m4: Regenerate.
	* gnulib/import/Makefile.am: Update.
	* gnulib/import/Makefile.in: Update.
	* gnulib/import/m4/gnulib-cache.m4: Update.
	* gnulib/import/m4/gnulib-comp.m4: Update.
	* gnulib/import/m4/strtok_r.m4: New file.
	* gnulib/import/strtok_r.c: New file.
2015-04-09 10:36:05 +01:00
Pedro Alves f543dc83b8 update-gnulib.sh: work around aclocal warning with Perl >= 5.16
gdb/ChangeLog:
2015-04-09  Pedro Alves  <palves@redhat.com>

	* gnulib/update-gnulib.sh (aclocal version check): Filter out
	"called too early to check prototype".
2015-04-09 10:35:29 +01:00
Yao Qi c8f4bfdd12 gdbserver gnu/linux: stepping over breakpoint
Hi,
I see the following error on arm linux gdbserver,

continue^M
Continuing.^M
../../../binutils-gdb/gdb/gdbserver/linux-arm-low.c:458: A problem internal to GDBserver has been detected.^M
raw_bkpt_type_to_arm_hwbp_type: unhandled raw type^M
Remote connection closed^M
(gdb) FAIL: gdb.base/cond-eval-mode.exp: hbreak: continue

After we make GDBserver handling Zx/zx packet idempotent,

  [PATCH 3/3] [GDBserver] Make Zx/zx packet handling idempotent.
  https://sourceware.org/ml/gdb-patches/2014-04/msg00480.html

> Now removal/insertion of all kinds of breakpoints/watchpoints, either
> internal, or from GDB, always go through the target methods.

GDBserver handles all kinds of breakpoints/watchpoints through target
methods.  However, some target backends, such as arm, don't support Z0
packet but need software breakpoint to do breakpoint stepping over in
linux-low.c:start_step_over,

  if (can_hardware_single_step ())
    {
      step = 1;
    }
  else
    {
      CORE_ADDR raddr = (*the_low_target.breakpoint_reinsert_addr) ();
      set_reinsert_breakpoint (raddr);
      step = 0;
    }

a software breakpoint is requested to the backend, and the error is
triggered.  This problem should affect targets having
breakpoint_reinsert_addr hooked.

Instead of handling memory breakpoint in these affected linux backend,
this patch handles memory breakpoint in linux_{insert,remove}_point,
that, if memory breakpoint is requested, call
{insert,remove}_memory_breakpoint respectively.  Then, it becomes
unnecessary to handle memory breakpoint for linux x86 backend, so
this patch removes the code there.

This patch is tested with GDBserver on x86_64-linux and arm-linux
(-marm, -mthumb).  Note that there are still some fails in
gdb.base/cond-eval-mode.exp with -mthumb, because GDBserver doesn't
know how to select the correct breakpoint instruction according to
the arm-or-thumb-mode of requested address.  This is a separate
issue, anyway.

gdb/gdbserver:

2015-04-09  Yao Qi  <yao.qi@linaro.org>

	* linux-low.c (linux_insert_point): Call
	insert_memory_breakpoint if TYPE is raw_bkpt_type_sw.
	(linux_remove_point): Call remove_memory_breakpoint if type is
	raw_bkpt_type_sw.
	* linux-x86-low.c (x86_insert_point): Don't call
	insert_memory_breakpoint.
	(x86_remove_point): Don't call remove_memory_breakpoint.
2015-04-09 10:20:48 +01:00
H.J. Lu 82d8e420ab Enable ELF ld_list_options for --enable-targets=all
When --enable-targets=all is used with non-ELF target, we should enable
ELF ld_list_options.

	* configure.ac (elf_list_options): Set to TRUE for
	--enable-targets=all.
	(elf_shlib_list_options): Likewise.
	(elf_plt_unwind_list_options): Likewise.
	* configure: Regenerated.
2015-04-08 17:08:45 -07:00
GDB Administrator 11161a6e38 Automatic date update in version.in 2015-04-09 00:00:08 +00:00
Sergio Durigan Junior 6d62641c83 Fix Python completion when using the "complete" command
This patch is related to PR python/16699, and is an improvement over the
patch posted here:

  <https://sourceware.org/ml/gdb-patches/2014-03/msg00301.html>

Keith noticed that, when using the "complete" command on GDB to complete
a Python command, some strange things could happen.  In order to
understand what can go wrong, I need to explain how the Python
completion mechanism works.

When the user requests a completion of a Python command by using TAB,
GDB will first try to determine the right set of "brkchars" that will be
used when doing the completion.  This is done by actually calling the
"complete" method of the Python class.  Then, when we already know the
"brkchars" that will be used, we call the "complete" method again, for
the same values.

If you read the thread mentioned above, you will see that one of the
design decisions was to make the "cmdpy_completer_helper" (which is the
function the does the actual calling of the "complete" method) cache the
first result of the completion, since this result will be used in the
second call, to do the actual completion.

The problem is that the "complete" command does not process the
brkchars, and the current Python completion mechanism (improved by the
patch mentioned above) relies on GDB trying to determine the brkchars,
and then doing the completion itself.  Therefore, when we use the
"complete" command instead of doing a TAB-completion on GDB, there is a
scenario where we can use the invalid cache of a previous Python command
that was completed before.  For example:

  (gdb) A <TAB>
  (gdb) complete B
  B value1
  B value10
  B value2
  B value3
  B value4
  B value5
  B value6
  B value7
  B value8
  B value9
  (gdb) B <TAB>
  comp1   comp2   comp4   comp6   comp8
  comp10  comp3   comp5   comp7   comp9

Here, we see that "complete B " gave a different result than "B <TAB>".
The reason for that is because "A <TAB>" was called before, and its
completion results were "value*", so when GDB tried to "complete B " it
wrongly answered with the results for A.  The problem here is using a
wrong cache (A's cache) for completing B.

We tried to come up with a solution that would preserve the caching
mechanism, but it wasn't really possible.  So I decided to completely
remove the cache, and doing the method calling twice for every
completion.  This is not optimal, but I do not think it will impact
users noticeably.

It is worth mentioning another small issue that I found.  The code was
doing:

  wordobj = PyUnicode_Decode (word, sizeof (word), host_charset (), NULL);

which is totally wrong, because using "sizeof" here will lead to always
the same result.  So I changed this to use "strlen".  The testcase also
catches this problem.

Keith kindly expanded the existing testcase to cover the problem
described above, and everything is passing.

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

	PR python/16699
	* python/py-cmd.c (cmdpy_completer_helper): Adjust function to not
	use a caching mechanism.  Adjust comments and code to reflect
	that.  Replace 'sizeof' by 'strlen' when fetching 'wordobj'.
	(cmdpy_completer_handle_brkchars): Adjust call to
	cmdpy_completer_helper.  Call Py_XDECREF for 'resultobj'.
	(cmdpy_completer): Likewise.

gdb/testsuite/ChangeLog:
2015-04-08  Keith Seitz  <keiths@redhat.com>

	PR python/16699
	* gdb.python/py-completion.exp: New tests for completion.
	* gdb.python/py-completion.py (CompleteLimit1): New class.
	(CompleteLimit2): Likewise.
	(CompleteLimit3): Likewise.
	(CompleteLimit4): Likewise.
	(CompleteLimit5): Likewise.
	(CompleteLimit6): Likewise.
	(CompleteLimit7): Likewise.
2015-04-08 18:27:10 -04:00
Pedro Alves f3770638ca Add test for PR18214 and PR18216 - multiple step-overs with queued signals
Both PRs are triggered by the same use case.

PR18214 is about software single-step targets.  On those, the 'resume'
code that detects that we're stepping over a breakpoint and delivering
a signal at the same time:

  /* Currently, our software single-step implementation leads to different
     results than hardware single-stepping in one situation: when stepping
     into delivering a signal which has an associated signal handler,
     hardware single-step will stop at the first instruction of the handler,
     while software single-step will simply skip execution of the handler.
...
     Fortunately, we can at least fix this particular issue.  We detect
     here the case where we are about to deliver a signal while software
     single-stepping with breakpoints removed.  In this situation, we
     revert the decisions to remove all breakpoints and insert single-
     step breakpoints, and instead we install a step-resume breakpoint
     at the current address, deliver the signal without stepping, and
     once we arrive back at the step-resume breakpoint, actually step
     over the breakpoint we originally wanted to step over.  */

doesn't handle the case of _another_ thread also needing to step over
a breakpoint.  Because the other thread is just resumed at the PC
where it had stopped and a breakpoint is still inserted there, the
thread immediately re-traps the same breakpoint.  This test exercises
that.  On software single-step targets, it fails like this:

 KFAIL: gdb.threads/multiple-step-overs.exp: displaced=off: signal thr3: continue to sigusr1_handler
 KFAIL: gdb.threads/multiple-step-overs.exp: displaced=off: signal thr2: continue to sigusr1_handler

gdb.log (simplified):

 (gdb) continue
 Continuing.

 Breakpoint 4, child_function_2 (arg=0x0) at src/gdb/testsuite/gdb.threads/multiple-step-overs.c:66
 66            callme (); /* set breakpoint thread 2 here */
 (gdb) thread 3
 (gdb) queue-signal SIGUSR1
 (gdb) thread 1
 [Switching to thread 1 (Thread 0x7ffff7fc1740 (LWP 24824))]
 #0  main () at src/gdb/testsuite/gdb.threads/multiple-step-overs.c:106
 106       wait_threads (); /* set wait-threads breakpoint here */
 (gdb) break sigusr1_handler
 Breakpoint 5 at 0x400837: file src/gdb/testsuite/gdb.threads/multiple-step-overs.c, line 31.
 (gdb) continue
 Continuing.
 [Switching to Thread 0x7ffff7fc0700 (LWP 24828)]

 Breakpoint 4, child_function_2 (arg=0x0) at src/gdb/testsuite/gdb.threads/multiple-step-overs.c:66
 66            callme (); /* set breakpoint thread 2 here */
 (gdb) KFAIL: gdb.threads/multiple-step-overs.exp: displaced=off: signal thr3: continue to sigusr1_handler


For good measure, I made the test try displaced stepping too.  And
then I found it crashes GDB on x86-64 (a hardware step target), but
only when displaced stepping... :

 KFAIL: gdb.threads/multiple-step-overs.exp: displaced=on: signal thr1: continue to sigusr1_handler (PRMS: gdb/18216)
 KFAIL: gdb.threads/multiple-step-overs.exp: displaced=on: signal thr2: continue to sigusr1_handler (PRMS: gdb/18216)
 KFAIL: gdb.threads/multiple-step-overs.exp: displaced=on: signal thr3: continue to sigusr1_handler (PRMS: gdb/18216)

 Program terminated with signal SIGSEGV, Segmentation fault.
 #0  0x000000000062a83a in process_event_stop_test (ecs=0x7fff847eeee0) at src/gdb/infrun.c:4964
 4964          if (sr_bp->loc->permanent
 Setting up the environment for debugging gdb.
 Breakpoint 1 at 0x79fcfc: file src/gdb/common/errors.c, line 54.
 Breakpoint 2 at 0x50a26c: file src/gdb/cli/cli-cmds.c, line 217.
 (top-gdb) p sr_bp
 $1 = (struct breakpoint *) 0x0
 (top-gdb) bt
 #0  0x000000000062a83a in process_event_stop_test (ecs=0x7fff847eeee0) at src/gdb/infrun.c:4964
 #1  0x000000000062a1af in handle_signal_stop (ecs=0x7fff847eeee0) at src/gdb/infrun.c:4715
 #2  0x0000000000629097 in handle_inferior_event (ecs=0x7fff847eeee0) at src/gdb/infrun.c:4165
 #3  0x0000000000627482 in fetch_inferior_event (client_data=0x0) at src/gdb/infrun.c:3298
 #4  0x000000000064ad7b in inferior_event_handler (event_type=INF_REG_EVENT, client_data=0x0) at src/gdb/inf-loop.c:56
 #5  0x00000000004c375f in handle_target_event (error=0, client_data=0x0) at src/gdb/linux-nat.c:4658
 #6  0x0000000000648c47 in handle_file_event (file_ptr=0x2e0eaa0, ready_mask=1) at src/gdb/event-loop.c:658

The all-stop-non-stop series fixes this, but meanwhile, this augments
the multiple-step-overs.exp test to cover this, KFAILed.

gdb/testsuite/ChangeLog:
2015-04-08  Pedro Alves  <palves@redhat.com>

	PR gdb/18214
	PR gdb/18216
	* gdb.threads/multiple-step-overs.c (sigusr1_handler): New
	function.
	(main): Install it as SIGUSR1 handler.
	* gdb.threads/multiple-step-overs.exp (setup): Remove 'prefix'
	parameter.  Always use "setup" as prefix.  Toggle "set
	displaced-stepping" off/on depending on global.  Don't switch to
	thread 1 here.
	(top level): Add displaced stepping "off/on" test axis.  Update
	"setup" calls.  Wrap each subtest with with_test_prefix.  Test
	continuing with a queued signal in each thread.
2015-04-08 19:59:03 +01:00
H.J. Lu febdfe65a8 Add chdr_size, Chdr, Chdr_write and Chdr_data
* elfcpp.h (Elf_sizes): Add chdr_size.
	(Chdr): New.
	(Chdr_write): Likewise.
	* elfcpp_internal.h (Chdr_data): Likewise.
2015-04-08 10:29:40 -07:00
H.J. Lu 91fb4b1a83 Add SHF_COMPRESSED and ELFCOMPRESS_XXX to elfcpp.h
* elfcpp.h (SHF): Add SHF_COMPRESSED.
	(ELFCOMPRESS_ZLIB): New.
	(ELFCOMPRESS_LOOS): Likewise.
	(ELFCOMPRESS_HIOS): Likewise.
	(ELFCOMPRESS_LOPROC): Likewise.
	(ELFCOMPRESS_HIPROC): Likewise.
2015-04-08 10:28:35 -07:00
H.J. Lu 31b94bbb7b Skip empty EMULATION_NAME
* emulparams/elf32bmipn32-defs.sh: Skip empty EMULATION_NAME.
2015-04-08 09:46:50 -07:00
H.J. Lu 5150992626 Work around a GCC uninitialized warning bug
* compress.c (bfd_compress_section_contents): Work around a GCC
	uninitialized warning bug fixed in GCC 4.7.
2015-04-08 09:27:27 -07:00
Yao Qi 85558555ec [spu] Don't call set_gdbarch_cannot_step_breakpoint in spu_gdbarch_init
Nowadays, in infrun.c:resume, the setting to 'step' variable is like:

  if (use_displaced_stepping (gdbarch)
      && tp->control.trap_expected
      && sig == GDB_SIGNAL_0
      && !current_inferior ()->waiting_for_vfork_done)
    {
    }
  /* Do we need to do it the hard way, w/temp breakpoints?  */
  else if (step)
    step = maybe_software_singlestep (gdbarch, pc); <-- [1]

  ...

  if (execution_direction != EXEC_REVERSE
      && step && breakpoint_inserted_here_p (aspace, pc))
    {
      ...
      if (gdbarch_cannot_step_breakpoint (gdbarch)) <-- [2]
        step = 0;
    }

spu doesn't have displaced stepping and uses software single step,
so 'step' is set to zero in [1], and [2] becomes unreachable as a
result.  So don't have to call set_gdbarch_cannot_step_breakpoint
in spu_gdbarch_init.

gdb:

2015-04-08  Yao Qi  <yao.qi@linaro.org>

	* spu-tdep.c (spu_gdbarch_init): Don't call
	set_gdbarch_cannot_step_breakpoint.
2015-04-08 16:04:07 +01:00
H.J. Lu 151411f8af Add SHF_COMPRESSED support to gas and objcopy
This patch adds --compress-debug-sections={none|zlib|zlib-gnu|zlib-gabi}
options to gas and objcopy for ELF files. They control how DWARF debug
sections are compressed.  --compress-debug-sections=none is equivalent to
--nocompress-debug-sections.  --compress-debug-sections=zlib and
--compress-debug-sections=zlib-gnu are equivalent to
--compress-debug-sections.  --compress-debug-sections=zlib-gabi compresses
DWARF debug sections with SHF_COMPRESSED from the ELF ABI.  No linker
changes are required to support SHF_COMPRESSED.

bfd/

	* archive.c (_bfd_get_elt_at_filepos): Also copy BFD_COMPRESS_GABI
	bit.
	* bfd.c (bfd::flags): Increase size to 18 bits.
	(BFD_COMPRESS_GABI): New.
	(BFD_FLAGS_SAVED): Add BFD_COMPRESS_GABI.
	(BFD_FLAGS_FOR_BFD_USE_MASK): Likewise.
	(bfd_update_compression_header): New fuction.
	(bfd_check_compression_header): Likewise.
	(bfd_get_compression_header_size): Likewise.
	(bfd_is_section_compressed_with_header): Likewise.
	* compress.c (MAX_COMPRESSION_HEADER_SIZE): New.
	(bfd_compress_section_contents): Return the uncompressed size if
	the full section contents is compressed successfully.  Support
	converting from/to .zdebug* sections.
	(bfd_get_full_section_contents): Call
	bfd_get_compression_header_size to get compression header size.
	(bfd_is_section_compressed): Renamed to ...
	(bfd_is_section_compressed_with_header): This.  Add a pointer
	argument to return compression header size.
	(bfd_is_section_compressed): Use it.
	(bfd_init_section_decompress_status): Call
	bfd_get_compression_header_size to get compression header size.
	Return FALSE if uncompressed section size is 0.
	* elf.c (_bfd_elf_make_section_from_shdr): Support converting
	from/to .zdebug* sections.
	* bfd-in2.h: Regenerated.

binutils/

	* objcopy.c (do_debug_sections): Add compress_zlib,
	compress_gnu_zlib and compress_gabi_zlib.
	(copy_options): Use optional_argument on compress-debug-sections.
	(copy_usage): Update --compress-debug-sections.
	(copy_file): Handle compress_zlib, compress_gnu_zlib and
	compress_gabi_zlib.
	(copy_main): Handle
	--compress-debug-sections={none|zlib|zlib-gnu|zlib-gabi}.
	* doc/binutils.texi: Document
	--compress-debug-sections={none|zlib|zlib-gnu|zlib-gabi}.

binutils/testsuite/

	* compress.exp: Add tests for
	--compress-debug-sections={none|zlib|zlib-gnu|zlib-gabi}.
	* binutils-all/dw2-3.rS: New file.
	* binutils-all/dw2-3.rt: Likewise.
	* binutils-all/libdw2-compressedgabi.out: Likewise.

gas/

	* as.c (show_usage): Update --compress-debug-sections.
	(std_longopts): Use optional_argument on compress-debug-sections.
	(parse_args): Handle
	--compress-debug-sections={none|zlib|zlib-gnu|zlib-gabi}.
	* as.h (compressed_debug_section_type): New.
	(flag_compress_debug): Change type to compressed_debug_section_type.
	--compress-debug-sections={none|zlib|zlib-gnu|zlib-gabi}.
	* write.c (compress_debug): Set BFD_COMPRESS_GABI for
	--compress-debug-sections=zlib-gabi.  Call
	bfd_get_compression_header_size to get compression header size.
	Don't rename section name for --compress-debug-sections=zlib-gabi.
	* config/tc-i386.c (compressed_debug_section_type): Set to
	COMPRESS_DEBUG_ZLIB.
	* doc/as.texinfo: Document
	--compress-debug-sections={none|zlib|zlib-gnu|zlib-gabi}.

gas/testsuite/

	* gas/i386/dw2-compressed-1.d: New file.
	* gas/i386/dw2-compressed-2.d: Likewise.
	* gas/i386/dw2-compressed-3.d: Likewise.
	* gas/i386/x86-64-dw2-compressed-2.d: Likewise.
	* gas/i386/i386.exp: Run dw2-compressed-2, dw2-compressed-1,
	dw2-compressed-3 and x86-64-dw2-compressed-2.

ld/testsuite/

	* ld-elf/compress.exp: Add a test for
	--compress-debug-sections=zlib-gabi.
	(build_tests): Add 2 tests for --compress-debug-sections=zlib-gabi.
	(run_tests): Likewise.
	Verify linker output with zlib-gabi compressed debug input.
	* ld-elf/compressed1a.d: New file.
	* ld-elf/compressed1b.d: Likewise.
	* ld-elf/compressed1c.d: Likewise.
2015-04-08 07:54:09 -07:00
H.J. Lu bfcf0ccd01 Display --interleave[=<number>]
Optional argument of a command line option must start with "=".

	* objcopy.c (copy_usage): Replace "--interleave [<number>]" with
	--interleave[=<number>].
2015-04-08 05:04:13 -07:00
H.J. Lu c58212eaf9 Add ld_list_options
This patch adds ld_list_options for ELF targets to avoid duplicated
outputs from ld --help.

	* Makefile.am (ELF_CLFAGS): New.
	(AM_CFLAGS): Add $(ELF_CLFAGS).
	* configure.ac (elf_list_options): New.  AC_SUBST.
	(elf_shlib_list_options): Likewise.
	(elf_plt_unwind_list_options): Likewise.
	* lexsup.c (elf_shlib_list_options): New.
	(elf_static_list_options): Likewise.
	(elf_plt_unwind_list_options): Likewise.
	(ld_list_options): Likewise.
	(help): Call ld_list_options.
	* Makefile.in: Regenerated.
	* configure: Likewise.
	* emulparams/plt_unwind.sh (PLT_UNWIND): New.
	(PARSE_AND_LIST_OPTIONS): Removed.
	* emultempl/elf32.em (gld_list_options): New.
	(gld${EMULATION_NAME}_list_options): Define only if BNDPLT or
	PARSE_AND_LIST_OPTIONS is defined.
	(ld_${EMULATION_NAME}_emulation): Replace
	gld${EMULATION_NAME}_list_options with ${gld_list_options.
2015-04-08 04:55:23 -07:00
Pedro Alves 4496bed7f3 Fix gdb.trace/{actions,infotrace,while-stepping}.exp with extended-remote
The recent actions.exp change to check gdb_run_cmd succeeded caught
further problems.  The test now fails like this
with --target_board=native-extended-gdbserver:

 FAIL: gdb.trace/actions.exp: Can't run to main

gdb.log shows:

 (gdb) run
 Starting program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.trace/actions
 Running the default executable on the remote target failed; try "set remote exec-file"?
 (gdb) FAIL: gdb.trace/actions.exp: Can't run to main

The problem is that a gdb_load call is missing.

Grepping around for similar problems in other tests, I found that
infotrace.exp and while-stepping.exp should be likewise affected.  And
indeed this is what we get today:

 FAIL: gdb.trace/infotrace.exp: tstart
 FAIL: gdb.trace/infotrace.exp: continue to end (the program is no longer running)
 FAIL: gdb.trace/infotrace.exp: tstop
 FAIL: gdb.trace/infotrace.exp: 2.6: info tracepoints (trace buffer usage)
 FAIL: gdb.trace/while-stepping.exp: tstart
 FAIL: gdb.trace/while-stepping.exp: tstop
 FAIL: gdb.trace/while-stepping.exp: tfile: info tracepoints
 FAIL: gdb.trace/while-stepping.exp: ctf: info tracepoints

while-stepping.exp even has the same race bug actions.exp had.

After this, {actions,infotrace,while-stepping}.exp all pass cleanly
with the native-extended-gdbserver board.

gdb/testsuite/ChangeLog:
2015-04-08  Pedro Alves  <palves@redhat.com>

	* gdb.trace/actions.exp: Use gdb_load before gdb_run_cmd.
	* gdb.trace/infotrace.exp: Use gdb_load before gdb_run_cmd.  Use
	gdb_breakpoint instead of gdb_test that doesn't expect anything.
	Return early if running to main fails.
	* gdb.trace/while-stepping.exp: Likewise.
2015-04-08 10:39:43 +01:00
Han Shen 2449132744 Add AArch32 support for arm gold linker. 2015-04-07 17:21:27 -07:00
GDB Administrator 31ba1f58f8 Automatic date update in version.in 2015-04-08 00:00:08 +00:00
Sergio Durigan Junior d249a14abe Initialize variable on gdb/linux-tdep.c:decode_vmflags
This obvious commit initializes the 'saveptr' variable on
gdb/linux-tdep.c:decode_vmflags.  This was causing a build failure on
Fedora 21 x86_64, caught by the BuildBot here:

  <https://sourceware.org/ml/gdb-testers/2015-q2/msg00450.html>
2015-04-07 15:19:07 -04:00
Pedro Alves b97fde9213 gdb.base/interrupt.exp: Use send_inferior/$inferior_spawn_id
The gdb.base/interrupt.exp test is important for testing system call
restarting, but because it depends on inferior I/O, it ends up skipped
against gdbserver.  This patch adjusts the test to use send_inferior
and $inferior_spawn_id so it works against GDBserver.

gdb/testsuite/ChangeLog:
2015-04-07  Pedro Alves  <palves@redhat.com>

	* gdb.base/interrupt.exp: Don't skip if $inferior_spawn_id !=
	$gdb_spawn_id.  Use send_inferior and $inferior_spawn_id to
	interact with inferior program.
2015-04-07 18:29:12 +01:00
Pedro Alves f71c18e755 testsuite: Introduce $inferior_spawn_id
Some important tests, like gdb.base/interrupt.exp end up skipped
against gdbserver, because they depend on inferior I/O, which
gdbserver doesn't do.

This patch adds a mechanism that makes it possible to make them work.
It adds a new "inferior_spawn_id" global that is the spawn ID used for
I/O interaction with the inferior.  By default, for native targets, or
remote targets that can do I/O through GDB (semi-hosting) this will be
the same as the gdb/host spawn ID.  Otherwise, the board may set this
to some other spawn ID.  When debugging with GDBserver, this will be
set to GDBserver's spawn ID.

Then tests can use send_inferior instead of send_gdb to send input to
the inferior, and use expect's "-i" switch to select which spawn ID to
use for matching input/output.  That is, something like this will now
work:

  send_inferior "echo me\n"
  gdb_test_multiple "continue" "test msg" {
    -i "$inferior_spawn_id" -re "echo me\r\necho\r\n" {
      ...
    }
  }

Or even:

  gdb_test_multiple "continue" "test msg" {
    -i "$inferior_spawn_id" -re "hello world" {
      ...
    }
    -i "$gdb_spawn_id" -re "error.*$gdb_prompt $" {
      ...
    }
  }

Of course, by default, gdb_test_multiple still matches with
$gdb_spawn_id.

gdb/testsuite/ChangeLog:
2015-04-07  Pedro Alves  <palves@redhat.com>

	* lib/gdb.exp (inferior_spawn_id): New global.
	(gdb_test_multiple): Handle "-i".  Reset the spawn id to GDB's
	spawn id after processing the user code.
	(default_gdb_start): Set inferior_spawn_id.
	(send_inferior): New procedure.
	* lib/gdbserver-support.exp (gdbserver_start): Set
	inferior_spawn_id.
	(close_gdbserver, gdb_exit): Unset inferior_spawn_id.
2015-04-07 18:28:38 +01:00
Pedro Alves 6423214fcb testsuite: Don't use expect_background to reap gdbserver
I adjusted a test to do 'expect -i $server_spawn_id -re ...', and saw
really strange behavior.  Whether that expect would work, depended on
whether GDB would also send output and the same expect matched it too
(on $gdb_spawn_id).  I was perplexed until I noticed that
gdbserver_spawn spawns gdbserver and then uses expect_background to
reap gdbserver.  That expect_background conflicts/races with any
"expect -i $server_spawn_id" done anywhere else in parallel...

In order to make it possible for tests to read inferior I/O out of
$server_spawn_id, we to get rid of that expect_background.  This patch
makes us instead reap gdbserver's spawn id when GDB exits.  If GDB is
still around, this gives a chance for gdbserver to exit cleanly.  The
current code in gdb_finish uses "kill", but that doesn't work with
extended-remote (gdbserver doesn't exit).  We now use "monitor exit"
instead which works in both remote and extended-remote modes.

gdb/testsuite/ChangeLog:
2015-04-07  Pedro Alves  <palves@redhat.com>

	* lib/gdb.exp (gdb_finish): Delete persistent gdbserver handling.
	* lib/gdbserver-support.exp (gdbserver_start): Make
	$server_spawn_id global.
	(gdbserver_start): Don't wait for gdbserver's spawn id with
	expect_background.
	(close_gdbserver): New procedure.
	(gdb_exit): Rename the default version and reimplement.
2015-04-07 18:27:55 +01:00
Pedro Alves 71c0ee8cb9 gdb_test_multiple: Fix user code argument processing
While teaching gdb_test_multiple to forward "-i" to gdb_expect, I
found that with:

      gdb_test_multiple (...) {
        -i $some_variable -re "..." {}
      }

$some_variable was not getting expanded in the gdb_test_multiple
caller's scope.  This is a bug inside gdb_test_multiple.  When
processing an argument in passed in user code, it was appending the
original argument literally, instead of appending the uplist'ed
argument.

gdb/testsuite/ChangeLog:
2015-04-07  Pedro Alves  <palves@redhat.com>

        * lib/gdb.exp (gdb_test_multiple): When processing an argument,
	append the substituted item, not the original item.
2015-04-07 18:27:24 +01:00
Pedro Alves 203bc29be2 gdb.base/interrupt.exp: Use gdb_test_multiple instead of gdb_expect
gdb/testsuite/ChangeLog:
2015-04-07  Pedro Alves  <palves@redhat.com>

	* gdb.base/interrupt.exp: Use gdb_test_multiple instead of
	gdb_expect.
2015-04-07 18:27:22 +01:00