deliverable/binutils-gdb.git
9 years agoFix dw-2 test for 16-bit targets.
Nick Clifton [Mon, 18 May 2015 13:36:15 +0000 (14:36 +0100)] 
Fix dw-2 test for 16-bit targets.

* binutils-all/dw2-3.S: Replace .int with .4byte.

9 years agoRemove Disp32 from AMD64 direct call/jmp
H.J. Lu [Mon, 18 May 2015 11:17:12 +0000 (04:17 -0700)] 
Remove Disp32 from AMD64 direct call/jmp

* i386-opc.tbl: Remove Disp32 from AMD64 direct call/jmp.
* i386-init.h: Regenerated.

9 years ago[AArch64] Remove X86-64 comments
Jiong Wang [Mon, 18 May 2015 09:43:43 +0000 (10:43 +0100)] 
[AArch64] Remove X86-64 comments

bfd/
  * elfnn-aarch64.c (elfNN_aarch64_adjust_dynamic_symbol): Rewrite comments.

9 years agoAutomatic date update in version.in
GDB Administrator [Mon, 18 May 2015 00:00:07 +0000 (00:00 +0000)] 
Automatic date update in version.in

9 years agoAdd myself to write-after-approval list
Max Filippov [Sun, 17 May 2015 23:05:57 +0000 (02:05 +0300)] 
Add myself to write-after-approval list

gdb/
* MAINTAINERS (Write After Approval): Add Max Filippov.

9 years agosim: erc32: restore attribution
Mike Frysinger [Sun, 17 May 2015 09:11:17 +0000 (17:11 +0800)] 
sim: erc32: restore attribution

9 years agoELF options may be missing from `ld --help' output
Chung-Lin Tang [Thu, 14 May 2015 10:40:57 +0000 (18:40 +0800)] 
ELF options may be missing from `ld --help' output

nios2-linux has an emulation named "nios2linux", and happens to not include
another extra emulation with a name matching *elf*.  This makes nios2-linux
left out of the ELF options printing targets, which is unintended.

* configure.ac (AC_PROG_GREP): Check for grep program.
(elf_list_options,elf_shlib_list_options,elf_plt_unwind_list_options):
Enable ELF option printing for emulations containing
'TEMPLATE_NAME=elf32'.
* configure: Regenerate.

9 years agoAutomatic date update in version.in
GDB Administrator [Sun, 17 May 2015 00:00:08 +0000 (00:00 +0000)] 
Automatic date update in version.in

9 years agoAdd support for unbuffered and zero sized Guile ports.
Doug Evans [Sat, 16 May 2015 19:14:26 +0000 (12:14 -0700)] 
Add support for unbuffered and zero sized Guile ports.

gdb/ChangeLog

* NEWS: Mention support for unbuffered Guile memory ports.
* scm-ports.c (ioscm_memory_port): Update comments on end, size.
(ioscm_lseek_address): Improve overflow calculation.
(gdbscm_memory_port_fill_input): Add assert.
(gdbscm_memory_port_write): Handle unbuffered ports.
Handle large writes identical to Guile's fport_write.
(gdbscm_memory_port_seek): Fix seeking past end check.
(gdbscm_memory_port_close): Handle closing unbuffered port.
(ioscm_parse_mode_bits): Recognize "0" for unbuffered ports.
(ioscm_init_memory_port): Handle unbuffered ports.
(ioscm_reinit_memory_port): Ditto.
(ioscm_init_memory_port): Update size calculation.
(gdbscm_open_memory): Support zero sized ports.

gdb/testsuite/ChangeLog

* gdb.guile/scm-ports.c: New file.
* gdb.guile/scm-ports.exp: Add memory port tests.

gdb/doc/ChangeLog

* guile.texi (Memory Ports in Guile): Document support for unbuffered
memory ports.

9 years agocompile: Fix uninitialized variable compiler warnings
Jan Kratochvil [Sat, 16 May 2015 14:36:44 +0000 (16:36 +0200)] 
compile: Fix uninitialized variable compiler warnings

gdb/ChangeLog
2015-05-16  Jan Kratochvil  <jan.kratochvil@redhat.com>

* compile/compile-object-load.c (get_out_value_type): Fix uninitialized
variable compiler warnings.

9 years agoDon't generate PLT relocations for now binding
H.J. Lu [Sat, 16 May 2015 14:00:21 +0000 (07:00 -0700)] 
Don't generate PLT relocations for now binding

There is no need for PLT relocations with -z now. We can use GOT
relocations, which take less space, instead and replace 16-byte .plt
entres with 8-byte .plt.got entries.

bfd/

* elf32-i386.c (elf_i386_check_relocs): Create .plt.got section
for now binding.
(elf_i386_allocate_dynrelocs): Use .plt.got section for now
binding.
* elf64-x86-64.c (elf_x86_64_check_relocs): Create .plt.got
section for now binding.
(elf_x86_64_allocate_dynrelocs): Use .plt.got section for now
binding.

ld/testsuite/

* ld-i386/i386.exp: Run PR ld/17689 tests with -z now.
* ld-x86-64/x86-64.exp: Likewise
* ld-i386/pr17689now.rd: New file.
* ld-x86-64/pr17689now.rd: Likewise

9 years agocompile: Fix detected inferior type
Jan Kratochvil [Sat, 16 May 2015 13:36:33 +0000 (15:36 +0200)] 
compile: Fix detected inferior type

gdb/ChangeLog
2015-05-16  Jan Kratochvil  <jan.kratochvil@redhat.com>

* compile/compile-object-load.c (get_out_value_type): Fix returned type.

9 years ago[GOLD] Add PowerPC64 -fsplit-stack support
Alan Modra [Wed, 13 May 2015 04:42:38 +0000 (14:12 +0930)] 
[GOLD] Add PowerPC64 -fsplit-stack support

PowerPC64 ELFv1 requires a tweak to find_functions in order to return
code addresses, rather than OPD entry addresses.

* reloc.cc (Sized_relobj_file::find_functions): Use function_location.
* powerpc.cc (Target_powerpc::do_calls_non_split): New function.
(addi_12_1, addis_2_12, addis_12_1, cmpld_7_12_0): New constants.
(lis_0): Rename from lis_0_0.

9 years agocompile: New 'compile print'
Jan Kratochvil [Sat, 16 May 2015 12:20:46 +0000 (14:20 +0200)] 
compile: New 'compile print'

It is planned the existing GDB command 'print' will be able to evaluate its
expressions using the compiler.  There will be some option to choose between
the existing GDB evaluation and the compiler evaluation.  But as an
intermediate step this patch provides the expression printing feature as a new
command.

I can imagine it could be also called 'maintenance compile print' as in the
future one should be able to use its functionality by the normal 'print'
command.

There was a discussion with Eli about the command name:
https://sourceware.org/ml/gdb-patches/2015-03/msg00880.html
As there were no other comments yet I haven't renamed it yet, before there is
some confirmation about settlement on the final name.

Support for the GDB '@' operator to create arrays has been submitted for GCC:
[gcc patch] libcc1: '@' GDB array operator
https://gcc.gnu.org/ml/gcc-patches/2015-03/msg01451.html

gdb/ChangeLog
2015-05-16  Jan Kratochvil  <jan.kratochvil@redhat.com>
    Phil Muldoon  <pmuldoon@redhat.com>

* NEWS (Changes since GDB 7.9): Add compile print.
* compile/compile-c-support.c (add_code_header, add_code_footer)
(c_compute_program): Add COMPILE_I_PRINT_ADDRESS_SCOPE and
COMPILE_I_PRINT_VALUE_SCOPE.
* compile/compile-internal.h (COMPILE_I_PRINT_OUT_ARG_TYPE)
(COMPILE_I_PRINT_OUT_ARG, COMPILE_I_EXPR_VAL, COMPILE_I_EXPR_PTR_TYPE):
New.
* compile/compile-object-load.c: Include block.h.
(get_out_value_type): New function.
(compile_object_load): Handle COMPILE_I_PRINT_ADDRESS_SCOPE and
COMPILE_I_PRINT_VALUE_SCOPE.  Set compile_module's OUT_VALUE_ADDR and
OUT_VALUE_TYPE.
* compile/compile-object-load.h (struct compile_module): Add fields
out_value_addr and out_value_type.
* compile/compile-object-run.c: Include valprint.h and compile.h.
(struct do_module_cleanup): Add fields out_value_addr and
out_value_type.
(do_module_cleanup): Handle COMPILE_I_PRINT_ADDRESS_SCOPE and
COMPILE_I_PRINT_VALUE_SCOPE.
(compile_object_run): Propagate out_value_addr and out_value_type.
Pass OUT_VALUE_ADDR.
* compile/compile.c: Include valprint.h.
(compile_print_value, compile_print_command): New functions.
(eval_compile_command): Handle failed COMPILE_I_PRINT_ADDRESS_SCOPE.
(_initialize_compile): Update compile code help text.  Install
compile_print_command.
* compile/compile.h (compile_print_value): New prototype.
* defs.h (enum compile_i_scope_types): Add
COMPILE_I_PRINT_ADDRESS_SCOPE and COMPILE_I_PRINT_VALUE_SCOPE.

gdb/doc/ChangeLog
2015-05-16  Jan Kratochvil  <jan.kratochvil@redhat.com>

* gdb.texinfo (Compiling and Injecting Code): Add compile print.

gdb/testsuite/ChangeLog
2015-05-16  Jan Kratochvil  <jan.kratochvil@redhat.com>

* gdb.compile/compile-print.c: New file.
* gdb.compile/compile-print.exp: New file.

9 years agoCode cleanup: compile: func_addr -> func_sym
Jan Kratochvil [Sat, 16 May 2015 12:20:45 +0000 (14:20 +0200)] 
Code cleanup: compile: func_addr -> func_sym

Currently the code fetches _gdb_expr address/types at multiple places, guessing
its parameters at multiple places etc.

Fetch it once, verify it has expected type and then rely on it.

While the patch tries to clean up the code it is still horrible due to the
missing C++ sub-classing.

gdb/ChangeLog
2015-05-16  Jan Kratochvil  <jan.kratochvil@redhat.com>

* compile/compile-object-load.c (get_regs_type): Add parameter func_sym.
Rely on its parameter count.
(compile_object_load): Replace lookup_minimal_symbol_text by
lookup_global_symbol_from_objfile.  Verify FUNC_SYM.  Set it in the
return value.
* compile/compile-object-load.h (struct compile_module): Replace
func_addr by func_sym.
* compile/compile-object-run.c: Include block.h.
(compile_object_run): Reset module variable after it is freed.  Use
FUNC_SYM instead of FUNC_ADDR.  Rely on it.

9 years agocompile: Use -Wall, not -w
Jan Kratochvil [Sat, 16 May 2015 12:20:45 +0000 (14:20 +0200)] 
compile: Use -Wall, not -w

For a reason unknown to me GDB was using -w instead of -Wall for 'compile code'.
The problem is later patch for 'compile printf' really needs some warnings to
be able to catch for example missing format string parameters:
(gdb) compile printf "%d\n"
GCC does not seem to be able to cancel -w (there is nothing like -no-w).

Besides that I think even 'compile code' can benefit from -Wall.

That #ifndef change in print_one_macro() is needed otherwise we get
macro-redefinition warnings for the GCC built-in macros (as -w is no
longer in effect).  For example, without the #ifndef/#endif one gets:

compile -r -- void _gdb_expr(){int i = 5;}^M
/tmp/gdbobj-xpU1yB/out4.c:4:0: warning: "__FILE__" redefined [-Wbuiltin-macro-redefined]^M
/tmp/gdbobj-xpU1yB/out4.c:5:0: warning: "__LINE__" redefined^M
...

It makes more sense to pick the inferior's version of the macros, hence
#ifndef instead of #undef.

That new testsuite XFAIL is there as if one changes the struct definition to be
compliant with cv-qualifiers (to prevent the warnings):
struct struct_type {
-  struct struct_type *selffield;
+  volatile struct struct_type *selffield;
only then GCC/GDB will hit the crash, described in that GDB PR 18202.

gdb/ChangeLog
2015-05-16  Jan Kratochvil  <jan.kratochvil@redhat.com>

* compile/compile-c-support.c (print_one_macro): Use #ifndef.
(generate_register_struct): Use __gdb_uintptr for TYPE_CODE_PTR.
(c_compute_program): Call generate_register_struct after typedefs.
* compile/compile-loc2c.c (push, pushf_register_address)
(pushf_register): Cast to GCC_UINTPTR.
(do_compile_dwarf_expr_to_c): Use unused attribute.  Add space after
type.  Use GCC_UINTPTR instead of void *.  Remove excessive cast.
(compile_dwarf_expr_to_c): Use GCC_UINTPTR instead of void *.
* compile/compile.c (_initialize_compile): Enable warnings for
COMPILE_ARGS.

gdb/testsuite/ChangeLog
2015-05-16  Jan Kratochvil  <jan.kratochvil@redhat.com>

* gdb.compile/compile-ops.exp: Cast param to void.
* gdb.compile/compile.exp: Complete type for _gdb_expr.
(compile code struct_object.selffield = &struct_object): Add xfail.

9 years agocompile: Distribute scope, add scope_data
Jan Kratochvil [Sat, 16 May 2015 12:27:47 +0000 (14:27 +0200)] 
compile: Distribute scope, add scope_data

Provide a way to access current 'scope' during the do_module_cleanup stage and
associate more data with it.

gdb/ChangeLog
2015-05-16  Jan Kratochvil  <jan.kratochvil@redhat.com>

* cli/cli-script.c (execute_control_command): Update
eval_compile_command caller.
* compile/compile-object-load.c (compile_object_load): Add parameters
scope and scope_data.  Set them.
* compile/compile-object-load.h (struct compile_module): Add fields
scope and scope_data.
(compile_object_load): Add parameters scope and scope_data.
* compile/compile-object-run.c (struct do_module_cleanup): Add fields
scope and scope_data.
(compile_object_run): Propagate the fields scope and scope_data.
* compile/compile.c (compile_file_command, compile_code_command):
Update eval_compile_command callers.
(eval_compile_command): Add parameter scope_data.  Pass it plus scope.
* compile/compile.h (eval_compile_command): Add parameter scope_data.
* defs.h (struct command_line): Add field scope_data.

9 years agoCode cleanup: Make parts of print_command_1 public
Jan Kratochvil [Sat, 16 May 2015 12:26:06 +0000 (14:26 +0200)] 
Code cleanup: Make parts of print_command_1 public

The later 'compile print' command should share its behavior with the existing
'print' command.  Make the needed existing parts of print_command_1 public.

gdb/ChangeLog
2015-05-16  Jan Kratochvil  <jan.kratochvil@redhat.com>

* printcmd.c (struct format_data): Move it to valprint.h.
(print_command_parse_format, print_value): New functions from ...
(print_command_1): ... here.  Call them.
* valprint.h (struct format_data): Move it here from printcmd.c.
(print_command_parse_format, print_value): New declarations.

9 years agoAdd forgotten ChangeLog entry for the previous commit.
Jan Kratochvil [Sat, 16 May 2015 12:25:28 +0000 (14:25 +0200)] 
Add forgotten ChangeLog entry for the previous commit.

9 years agocompile: Add one debug message
Jan Kratochvil [Sat, 16 May 2015 12:14:10 +0000 (14:14 +0200)] 
compile: Add one debug message

gdb/ChangeLog
2015-05-16  Jan Kratochvil  <jan.kratochvil@redhat.com>

* compile/compile-object-load.c (compile_object_load): Add
COMPILE_DEBUG message.

9 years agoAutomatic date update in version.in
GDB Administrator [Sat, 16 May 2015 00:00:08 +0000 (00:00 +0000)] 
Automatic date update in version.in

9 years agoArray indexed by non-contiguous enumeration types
Jerome Guitton [Fri, 27 Mar 2015 13:45:08 +0000 (14:45 +0100)] 
Array indexed by non-contiguous enumeration types

In Ada, index types of arrays can be enumeration types, and enumeration
types can be non-contiguous. In which case the address of elements is
not given by the value of the index, but by its position in the enumeration
type.

In other words, in this example:

 type Color is (Blue, Red);
 for Color use (Blue => 8, Red => 12, Green => 16);

 type A is array (Color) of Integer;
 type B is array (1 .. 3) of Integer;

Arrays of type A and B will have the same layout in memory, even if
the enumeration Color has a hole in its set of integer value.

Since recently support for such a feature was in ada-lang.c, where the
array was casted to a regular continuous index range. We were losing
the information of index type. And this was not quite working for
subranges in variable-length fields; their bounds are expressed using
the integer value of the bounds, not its position in the enumeration,
and there was some confusion all over ada-lang.c as to whether we had
the position or the integer value was used for indexes.

The idea behind this patch is to clean this up by keeping the real
representation of these array index types and bounds when representing
the value, and only use the position when accessing the elements or
computing the length. This first patch fixes the printing of such
an array.

To the best of my knowledge, this feature only exists in Ada so it
should only affect this language.

gdb/ChangeLog:

        Jerome Guitton  <guitton@adacore.com>:
        * ada-lang.c (ada_value_ptr_subscript): Use enum position of
        index to get element instead of enum value.
        (ada_value_slice_from_ptr, ada_value_slice): Use enum position
        of index to compute length, but enum values to compute bounds.
        (ada_array_length): Use enum position of index instead of enum value.
        (pos_atr): Move position computation to...
        (ada_evaluate_subexp): Use enum values to compute bounds.
        * gdbtypes.c (discrete_position): ...this new function.
        * gdbtypes.h (discrete_position): New function declaration.
        * valprint.c (val_print_array_elements): Call discrete_position
        to handle array indexed by non-contiguous enumeration types.

gdb/testsuite/ChangeLog:

        * gdb.ada/arr_enum_with_gap: New testcase.

9 years agoNon bit-packed packed arrays as variable-length fields
Jerome Guitton [Thu, 26 Mar 2015 15:19:27 +0000 (16:19 +0100)] 
Non bit-packed packed arrays as variable-length fields

In the case of non bit-packed arrays, GNAT does not generate its
traditional XP encoding; it is not needed. However, it still generates
the so-called "implementation type" with a P suffix. This
implementation type shall be skipped when looking for other
descriptive types such as XA encodings for variable-length
fields.

Note also that there may be an intermediate typedef between the
implementation type and its XA description. It shall be skipped
as well.

gdb/ChangeLog:

        Jerome Guitton  <guitton@adacore.com>
* ada-lang.c (find_parallel_type_by_descriptive_type):
Go through typedefs during lookup.
(to_fixed_array_type): Add support for non-bit packed arrays
as variable-length fields.

gdb/testsuite/ChangeLog:

        * gdb.ada/byte_packed_arr: New testcase.

9 years agoChange pointers from char * to unsigned char *
H.J. Lu [Fri, 15 May 2015 17:29:03 +0000 (10:29 -0700)] 
Change pointers from char * to unsigned char *

GCC 4.2 complaints:

cc1: warnings being treated as errors
binutils/readelf.c:12057: warning: dereferencing type-punned pointer will break strict-aliasing rules

This patch silences this GCC warning.

* readelf.c (dump_section_as_strings): Change pointers from
char * to unsigned char *.

9 years agoSupport AMD64/Intel ISAs in assembler/disassembler
H.J. Lu [Fri, 15 May 2015 16:47:39 +0000 (09:47 -0700)] 
Support AMD64/Intel ISAs in assembler/disassembler

AMD64 spec and Intel64 spec differ in direct unconditional branches in
64-bit mode.  AMD64 supports direct unconditional branches with 16-bit
offset via the data size prefix, which truncates RIP to 16 bits, while
the data size prefix is ignored by Intel64.

This patch adds -mamd64/-mintel64 option to x86-64 assembler and
-Mamd64/-Mintel64 option to x86-64 disassembler.  The most permissive
ISA, which is AMD64, is the default.

GDB can add an option, similar to

(gdb) help set disassembly-flavor
Set the disassembly flavor.
The valid values are "att" and "intel", and the default value is "att".

to select which ISA to disassemble.

binutils/

PR binutis/18386
* doc/binutils.texi: Document -Mamd64 and -Mintel64.

gas/

PR binutis/18386
* config/tc-i386.c (OPTION_MAMD64): New.
(OPTION_MINTEL64): Likewise.
(md_longopts): Add -mamd64 and -mintel64.
(md_parse_option): Handle OPTION_MAMD64 and OPTION_MINTEL64.
(md_show_usage): Add -mamd64 and -mintel64.
* doc/c-i386.texi: Document -mamd64 and -mintel64.

gas/testsuite/

PR binutis/18386
* gas/i386/i386.exp: Run x86-64-branch-2 and x86-64-branch-3.
* gas/i386/x86-64-branch.d: Also pass -Mintel64 to objdump.
* gas/i386/ilp32/x86-64-branch.d: Likewise.
* gas/i386/x86-64-branch-2.d: New file.
* gas/i386/x86-64-branch-2.s: Likewise.
* gas/i386/x86-64-branch-3.l: Likewise.
* gas/i386/x86-64-branch-3.s: Likewise.

ld/testsuite/

PR binutis/18386
* ld-x86-64/tlsgdesc.dd: Also pass -Mintel64 to objdump.
* ld-x86-64/tlspic.dd: Likewise.
* ld-x86-64/x86-64.exp (x86_64tests): Also pass -Mintel64 to
objdump for tlspic.dd and tlsgdesc.dd.

opcodes/

PR binutis/18386
* i386-dis.c: Add comments for '@'.
(x86_64_table): Use '@' on call/jmp for X86_64_E8/X86_64_E9.
(enum x86_64_isa): New.
(isa64): Likewise.
(print_i386_disassembler_options): Add amd64 and intel64.
(print_insn): Handle amd64 and intel64.
(putop): Handle '@'.
(OP_J): Don't ignore the operand size prefix for AMD64 in 64-bit.
* i386-gen.c (cpu_flags): Add CpuAMD64 and CpuIntel64.
* i386-opc.h (AMD64): New.
(CpuIntel64): Likewise.
(i386_cpu_flags): Add cpuamd64 and cpuintel64.
* i386-opc.tbl: Add direct call/jmp with Disp16|Disp32 for AMD64.
Mark direct call/jmp without Disp16|Disp32 as Intel64.
* i386-init.h: Regenerated.
* i386-tbl.h: Likewise.

9 years agoAdd --decompress option to readelf to decompress sections before they are dumped.
Nick Clifton [Fri, 15 May 2015 16:16:31 +0000 (17:16 +0100)] 
Add --decompress option to readelf to decompress sections before they are dumped.

bin * readelf.c (options): Add "decompress".
(usage): Mention -z/--decompress.
(parse_args): Handle -z.
(uncompress_section_contents): Move to earlier in the file.
(dump_section_as_strings): If requested, decompress the section
before dumping.
(dump_section_as_bytes): Likewise.
* doc/binutils.texi: Document the new option.

tests * binutils-all/z.s: New test.  Checks the --decompress option to
readelf.
* binutils-all/readelf.exp: Run the test.
* binutils-all/readelf.z: Expected output from readelf.

9 years agoFix gdb.mi/mi-nsmoribund.exp timeouts
Pedro Alves [Fri, 15 May 2015 15:26:53 +0000 (16:26 +0100)] 
Fix gdb.mi/mi-nsmoribund.exp timeouts

The PPC64 buildbot has been showing timeouts in mi-nsmoribund.exp,
like this:

 (...)
 -thread-info
 FAIL: gdb.mi/mi-nsmoribund.exp: thread state: all running except the breakpoint thread (timeout)

... and I can reproduce this on gcc110 (PPC64) on the gcc compile
farm.

That is, the test sends "-thread-info" to GDB, but GDB never replies
back.

The problem is that these machines are too fast for gdb.  :-)

That test has a few threads running the same tight loop, and
constantly hitting a thread-specific breakpoint that needs to be
stepped over.  If threads trip on breakpoints fast enough that
linux-nat.c's event pipe associated with SIGCHLD is constantly being
written to, even if the stdin file descriptor also has an event to
handle, gdb never gets to it. because linux-nat.c's pipe comes first
in the set of descriptors served by the poll/select code in the event
loop.

Fix this by having the event loop serve file event sources in
round-robin-like fashion, similarly to how its done in
gdb_do_one_event.

Unfortunately, the poll and the select variants each need their own
fixing.

Tested on x86_64 Fedora 20 (poll and select variants), and PPC64
Fedora 18.  Fixes the timeout in the PPC64 machine in the compile farm
that times out without this, and I won't be surprised if it fixes
other random timeouts in other tests.

(gdbserver's copy of the event-loop doesn't need this (yet), as it
still pushes all ready events to an event queue.  That is, it hasn't
had 70b66289 merged yet.  We should really merge both event-loop.c
copies into a single shared file, but that's for another day.)

gdb/ChangeLog:
2015-05-15  Pedro Alves  <palves@redhat.com>
    Simon Marchi  <simon.marchi@ericsson.com>

* event-loop.c (gdb_notifier) <next_file_handler,
next_poll_fds_index>: New fields.
(get_next_file_handler_to_handle_and_advance): New function.
(delete_file_handler): If deleting the next file handler to
handle, advance to the next file handler.
(gdb_wait_for_event): Bail early if no event fired.  Poll file
handlers in round-robin fashion.

9 years agoMore C++ build fixing
Pedro Alves [Fri, 15 May 2015 15:00:42 +0000 (16:00 +0100)] 
More C++ build fixing

Fixes:

In file included from ../../../binutils-gdb/gdb/gdbserver/server.h:61:0,
                 from ../../../binutils-gdb/gdb/gdbserver/server.c:19:
../../../binutils-gdb/gdb/gdbserver/target.h:442:50: error: second operand to the conditional operator is of type 'void', but the third operand is neither a throw-expression nor of type 'void'
    (*the_target->handle_new_gdb_connection) () : 0)
                                                  ^

Reported by Yuanhui Zhang.

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

* target.h (target_handle_new_gdb_connection): Rewrite using if
wrapped in do/while.

9 years agoAvoid using 'private' C++ keyword as symbol
Pedro Alves [Fri, 15 May 2015 15:00:41 +0000 (16:00 +0100)] 
Avoid using 'private' C++ keyword as symbol

gdb/ChangeLog:
2015-05-15  Pedro Alves  <palves@redhat.com>

* linux-tdep.c (linux_find_memory_regions_full): Rename local
'private' to 'priv'.

9 years agoInclude header for enum target_stop_reason
Pedro Alves [Fri, 15 May 2015 15:00:40 +0000 (16:00 +0100)] 
Include header for enum target_stop_reason

Building in C++ mode errors with:

 ~~~
 g++ -fpermissive (...) /home/pedro/gdb/mygit/src/gdb/gdbserver/../nat/x86-linux.c
 In file included from /home/pedro/gdb/mygit/src/gdb/gdbserver/../nat/x86-linux.h:23:0,
  from /home/pedro/gdb/mygit/src/gdb/gdbserver/../nat/x86-linux.c:21:
 /home/pedro/gdb/mygit/src/gdb/gdbserver/../nat/linux-nat.h:74:13: error: use of enum â€˜target_stop_reason’ without previous declaration
  extern enum target_stop_reason lwp_stop_reason (struct lwp_info *lwp);
      ^
 /home/pedro/gdb/mygit/src/gdb/gdbserver/../nat/linux-nat.h:74:70: error: invalid type in declaration before â€˜;’ token
  extern enum target_stop_reason lwp_stop_reason (struct lwp_info *lwp);
       ^
 ~~~

gdb/ChangeLog:
2015-05-15  Pedro Alves  <palves@redhat.com>

* nat/linux-nat.h: Include "target/waitstatus.h".

9 years agoFix a couple C++ build issues
Yuanhui Zhang [Fri, 15 May 2015 15:00:40 +0000 (16:00 +0100)] 
Fix a couple C++ build issues

Building mingw GDB with --enable-build-with-cxx shows:

../../binutils-gdb/gdb/python/py-unwind.c:500:45: error: cannot convert 'cached_frame_info::reg_info*' to 'pyuw_prev_register(frame_info*, void**, int)::reg_info*' in initialization
   struct reg_info *reg_info = cached_frame->reg;
                                             ^
../../binutils-gdb/gdb/python/py-unwind.c:501:60: error: invalid use of incomplete type 'struct pyuw_prev_register(frame_info*, void**, int)::reg_info'
   struct reg_info *reg_info_end = reg_info + cached_frame->reg_count;
                                                            ^
../../binutils-gdb/gdb/python/py-unwind.c:500:10: error: forward declaration of 'struct pyuw_prev_register(frame_info*, void**, int)::reg_info'
   struct reg_info *reg_info = cached_frame->reg;
          ^
../../binutils-gdb/gdb/python/py-unwind.c:505:37: error: cannot increment a pointer to incomplete type 'pyuw_prev_register(frame_info*, void**, int)::reg_info'
   for (; reg_info < reg_info_end; ++reg_info)
                                     ^
../../binutils-gdb/gdb/python/py-unwind.c:507:29: error: invalid use of incomplete type 'struct pyuw_prev_register(frame_info*, void**, int)::reg_info'
       if (regnum == reg_info->number)
                             ^
../../binutils-gdb/gdb/python/py-unwind.c:500:10: error: forward declaration of 'struct pyuw_prev_register(frame_info*, void**, int)::reg_info'
   struct reg_info *reg_info = cached_frame->reg;
          ^
../../binutils-gdb/gdb/python/py-unwind.c:508:68: error: invalid use of incomplete type 'struct pyuw_prev_register(frame_info*, void**, int)::reg_info'
         return frame_unwind_got_bytes (this_frame, regnum, reg_info->data);
                                                                    ^
../../binutils-gdb/gdb/python/py-unwind.c:500:10: error: forward declaration of 'struct pyuw_prev_register(frame_info*, void**, int)::reg_info'
   struct reg_info *reg_info = cached_frame->reg;
          ^
../../binutils-gdb/gdb/python/py-unwind.c: In function 'int pyuw_sniffer(const frame_unwind*, frame_info*, void**)':
../../binutils-gdb/gdb/python/py-unwind.c:574:70: warning: invalid conversion from 'void*' to 'cached_frame_info*' [-fpermissive]
                             reg_count * sizeof (cached_frame->reg[0]));
                                                                      ^
../../binutils-gdb/gdb/python/py-unwind.c: In function 'void pyuw_on_new_gdbarch(gdbarch*)':
../../binutils-gdb/gdb/python/py-unwind.c:636:47: warning: invalid conversion from 'void*' to 'pyuw_gdbarch_data_type*' [-fpermissive]
       gdbarch_data (newarch, pyuw_gdbarch_data);
                                               ^
../../binutils-gdb/gdb/python/py-unwind.c:647:29: warning: invalid conversion from 'void*' to 'const frame_data*' [-fpermissive]
       unwinder->unwind_data = (void *) newarch;
                             ^
../../binutils-gdb/gdb/python/py-unwind.c: At global scope:
../../binutils-gdb/gdb/python/py-unwind.c:699:21: error: redefinition of 'PyTypeObject pending_frame_object_type'
 static PyTypeObject pending_frame_object_type =
                     ^
../../binutils-gdb/gdb/python/py-unwind.c:96:21: error: 'PyTypeObject pending_frame_object_type' previously declared here
 static PyTypeObject pending_frame_object_type
                     ^
../../binutils-gdb/gdb/python/py-unwind.c:749:21: error: redefinition of 'PyTypeObject unwind_info_object_type'
 static PyTypeObject unwind_info_object_type =
                     ^
../../binutils-gdb/gdb/python/py-unwind.c:99:21: error: 'PyTypeObject unwind_info_object_type' previously declared here
 static PyTypeObject unwind_info_object_type
                     ^

The first kind of error is caused by the embedded struct definition,
so move it out of the parent struct.

The second kind of error is caused by forward declaring a static
global variable, which works in C, but not in C++ (or C with
-fno-common).  Make it using extern instead, like done in other
similar cases.

gdb/ChangeLog:
2015-05-15  Yuanhui Zhang  <asmwarrior@gmail.com>

* python/py-unwind.c (struct reg_info): Move out of ...
(struct cached_frame_info): ... this scope.
(pending_frame_object_type, unwind_info_object_type): Make extern.

9 years ago[Ada] problem printing negative integer values in packed arrays.
Joel Brobecker [Sat, 9 May 2015 00:11:35 +0000 (17:11 -0700)] 
[Ada] problem printing negative integer values in packed arrays.

Consider the following declarations:

   type Signed_Small is new Integer range - (2 ** 5) .. (2 ** 5 - 1);
   type Signed_Simple_Array is array (1 .. 4) of Signed_Small;
   pragma Pack (Signed_Simple_Array);
   SSA : Signed_Simple_Array := (-1, 2, -3, 4);

GDB currently print its value incorrectly for the elements that
are negative:

    (gdb) print ssa
    $1 = (65535, 2, 1048573, 4)
    (gdb) print ssa(1)
    $2 = 65535
    (gdb) print ssa(2)
    $3 = 2
    (gdb) print ssa(3)
    $4 = 1048573
    (gdb) print ssa(4)
    $5 = 4

What happens is that the sign-extension is not working because
we're trying to do left shift with a negative count. In
ada_value_primitive_packed_val, we have a loop which populates
the extra bits of the target (unpacked) value, after extraction
of the data from the original (packed) value:

        while (ntarg > 0)
          {
            accum |= sign << accumSize;
            unpacked[targ] = accum & ~(~0L << HOST_CHAR_BIT);
!!! ->      accumSize -= HOST_CHAR_BIT;
            accum >>= HOST_CHAR_BIT;
            ntarg -= 1;
            targ += delta;
          }

At each iteration, accumSize gets decremented by HOST_CHAR_BIT,
which can easily cause it to become negative, particularly on
little endian targets, where accumSize is at most HOST_CHAR_BIT - 1.
This causes us to perform a left-shift operation with a negative
accumSize at the next loop iteration, which is undefined, and
acutally does not produce the effect we wanted (value left untouched)
when the code is compiled with GCC.

This patch fixes the issue by simply setting accumSize to zero
if negative.

gdb/ChangeLog:

        * ada-lang.c (ada_value_primitive_packed_val): Make sure
        accumSize is never negative.

gdb/testsuite/ChangeLog:

        * gdb.ada/pckd_neg: New testcase.

9 years agoAdd -mshared option to x86 ELF assembler
H.J. Lu [Fri, 15 May 2015 10:17:31 +0000 (03:17 -0700)] 
Add -mshared option to x86 ELF assembler

This patch adds -mshared option to x86 ELF assembler.  By default,
assembler will optimize out non-PLT relocations against defined non-weak
global branch targets with default visibility.  The -mshared option tells
the assembler to generate code which may go into a shared library
where all non-weak global branch targets with default visibility can
be preempted.  The resulting code is slightly bigger.  This option
only affects the handling of branch instructions.

This Linux kernel patch is needed to create a working x86 Linux kernel if
it hasn't been applied:

diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
index ae6588b..b91a00c 100644
--- a/arch/x86/kernel/head_64.S
+++ b/arch/x86/kernel/head_64.S
@@ -339,8 +339,8 @@ early_idt_handlers:
  i = i + 1
  .endr

-/* This is global to keep gas from relaxing the jumps */
-ENTRY(early_idt_handler)
+/* This is weak to keep gas from relaxing the jumps */
+WEAK(early_idt_handler)
  cld

  cmpl $2,(%rsp) # X86_TRAP_NMI
--

gas/

* config/tc-i386.c (shared): New.
(OPTION_MSHARED): Likewise.
(elf_symbol_resolved_in_segment_p): Add relocation argument.
Check PLT relocations and shared.
(md_estimate_size_before_relax): Pass fragP->fr_var to
elf_symbol_resolved_in_segment_p.
(md_longopts): Add -mshared.
(md_show_usage): Likewise.
(md_parse_option): Handle OPTION_MSHARED.
* doc/c-i386.texi: Document -mshared.

gas/testsuite/

* gas/i386/i386.exp: Don't run pcrel for ELF targets.  Run
pcrel-elf, relax-4 and x86-64-relax-3 for ELF targets.
* gas/i386/pcrel-elf.d: New file.
* gas/i386/relax-4.d: Likewise.
* gas/i386/x86-64-relax-3.d: Likewise.
* gas/i386/relax-3.d: Pass -mshared to assembler.  Updated.
* gas/i386/x86-64-relax-2.d: Likewise.
* gas/i386/relax-3.s: Add test for PLT relocation.

9 years agoFix PR18374 by making readelf and objdump ignore end-of-list markers in the .debug_lo...
Nick Clifton [Fri, 15 May 2015 10:21:38 +0000 (11:21 +0100)] 
Fix PR18374 by making readelf and objdump ignore end-of-list markers in the .debug_loc section if there are relocations against them.

PR binutils/18374
bin * dwarf.h (struct dwarf_section): Add reloc_info and num_relocs
fields.
(struct dwarf_section_display): Change bitfield to boolean.
(reloc_at): Add prototype.
* dwarf.c (display_loc_list): Ignore list terminators if there are
relocs against them.
(display_debug_loc): Issue a warning if there are relocs against
the .debug_loc section.
(display_displays): Initialise reloc_info and num_relocs fields.
* objdump.c (load_specific_debug_section): Initialise reloc_info
and num_relocs fields.
(reloc_at): New function.
* readelf.c (is_32bit_abs_reloc): Add IA64's R_IA64_DIS32LSB
reloc.
(reloc_at): New function.
(apply_relocations): Add relocs_return and num_relocs_return
parameters.  Fill them in with the loaded relocs if non-NULL.
(dump_section_as_bytes): Update call to apply_relocations.
(load_specific_debug_section): Initialise reloc_info and
num_relocs fields.

tests * binutils-all/pr18374.s: New test file.
* binutils-all/readelf.exp: Assemble and run the new test.
* binutils-all/readelf.pr18374: Expected output from readelf.

9 years agoFix some PPC assembler errors.
Peter Bergner [Fri, 15 May 2015 01:57:50 +0000 (20:57 -0500)] 
Fix some PPC assembler errors.

Remove the wait instructions for server processors, since they were never
implemented.  Also add the extra operands added to the tlbie and slbia
instructions with ISA 2.06 and ISA 2.05 respectively.

binutils/
* MAINTAINERS: Add myself as PPC maintainer.

opcodes/
        * ppc-opc.c (IH) New define.
        (powerpc_opcodes) <wait>: Do not enable for POWER7.
        <tlbie>: Add RS operand for POWER7.
        <slbia>: Add IH operand for POWER6.

gas/testsuite/
        * gas/ppc/power4.d: Add a slbia test.
        * gas/ppc/power4.s: Likewise.
        * gas/ppc/power6.d: Add slbia and tlbie tests.
        * gas/ppc/power6.s: Likewise.
        * gas/ppc/power7.d: Remove wait tests. Add a tlbie test.
        * gas/ppc/power7.s: Likewise.

9 years agoAutomatic date update in version.in
GDB Administrator [Fri, 15 May 2015 00:00:08 +0000 (00:00 +0000)] 
Automatic date update in version.in

9 years agoDon't add the zlib header to SHF_COMPRESSED section
H.J. Lu [Thu, 14 May 2015 22:58:51 +0000 (15:58 -0700)] 
Don't add the zlib header to SHF_COMPRESSED section

In a SHF_COMPRESSED compressed section, the raw compressed data should
begin immediately after the compression header.  This patch removes the
extra zlib header from the SHF_COMPRESSED section.

bfd/

* bfd.c (bfd_update_compression_header): Also write the zlib
header if the SHF_COMPRESSED bit cleared..
(bfd_check_compression_header): Return the uncompressed size.
* compress.c (decompress_contents): Don't skip the zlib header.
(bfd_compress_section_contents): Properly handle ELFCOMPRESS_ZLIB,
which doesn't have the zlib header.
(bfd_init_section_decompress_status): Likewise.
(bfd_get_full_section_contents): Updated.
(bfd_is_section_compressed): Likewise.
(bfd_is_section_compressed_with_header): Return the uncompressed
size.
* elf.c (_bfd_elf_make_section_from_shdr): Updated.
* bfd-in2.h: Regenerated.

binutils/

* readelf.c (uncompress_section_contents): Add a parameter for
uncompressed size.  Don't check the zlib header.
(load_specific_debug_section): Updated.

binutils/testsuite/

* binutils-all/compress.exp: Replace "$OBJDUMP -s -j .debug_info"
with "$OBJDUMP -W".
* binutils-all/libdw2-compressedgabi.out: Updated.

gas/

2015-05-14  H.J. Lu  <hongjiu.lu@intel.com>

* write.c (compress_debug): Don't write the zlib header, which
is handled by bfd_update_compression_header.

9 years agoFix build gdbserver build errors on arm, mips, aarch64.
Don Breazeal [Thu, 14 May 2015 20:11:41 +0000 (13:11 -0700)] 
Fix build gdbserver build errors on arm, mips, aarch64.

Fix build errors introduced by
https://sourceware.org/ml/gdb-patches/2015-05/msg00281.html, which
didn't account for the change of the name of the struct process_info
field 'private' to 'priv' made in
https://sourceware.org/ml/gdb-patches/2015-02/msg00829.html.

gdb/gdbserver/ChangeLog:

* linux-aarch64-low.c (aarch64_linux_new_fork): Change reference
to process_info.private to process_info.priv.
* linux-arm-low.c (arm_new_fork): Likewise.
* linux-mips-low.c (mips_linux_new_fork): Likewise.

9 years agoFix gdbserver build failure on arm-android.
Joel Brobecker [Tue, 24 Mar 2015 17:19:10 +0000 (13:19 -0400)] 
Fix gdbserver build failure on arm-android.

The following patch...

| proc-service, extern "C"
|
| libthread_db.so calls symbols in the client (GDB), through the
| proc-service interface.  These routines must have extern "C" linkage
| so their symbol names are not mangled when GDB is built as a C++
| program.  On the GDBserver side, we were missing fallback declarations for
| all these symbols.
|
| gdb/ChangeLog:
|
|     * gdb_proc_service.h: Wrap with EXTERN_C_PUSH/EXTERN_C_POP.
|
| gdb/gdbserver/ChangeLog:
| 2015-02-27  Pedro Alves  <palves@redhat.com>
|
|     * gdb_proc_service.h: Wrap with EXTERN_C_PUSH/EXTERN_C_POP.
|     [!HAVE_PROC_SERVICE_H] (struct ps_prochandle): Forward declare.
|     [!HAVE_PROC_SERVICE_H] (ps_pdread, ps_pdwrite, ps_ptread)
|     ps_ptwrite, ps_lgetregs, ps_lsetregs, ps_lgetfpregs)
|     (ps_lsetfpregs, ps_getpid)
|     (ps_get_thread_area, ps_pglobal_lookup, ps_pstop, ps_pcontinue)
|     (ps_lstop, ps_lcontinue, ps_lgetxregsize, ps_lgetxregs)
|     (ps_lsetxregs, ps_plog): Declare.

... added a number of declarations which do not compile when cross-
compiling GDBserver on arm-android. The problem comes from type
prfpregset_t not being declared:

    /[...]/gdbserver/gdb_proc_service.h:98:47:
    error: unknown type name 'prfpregset_t'

After searching through the includes of the install we have,
I could not find that type being declared anywhere. So I did
the same as for prgregset_t, and created the typedef if the
type isn't declared.

gdb/gdbserver/ChangeLog:

        * configure.ac: Add prfpregset_t BFD_HAVE_SYS_PROCFS_TYPE check.
        * configure, config.in: Regenerate.
        * gdb_proc_service.h [HAVE_PRFPREGSET_T] (prfpregset_t):
        Declare typedef.

9 years agoRemove buggy xterm workaround in tui_dispatch_ctrl_char()
Patrick Palka [Wed, 13 May 2015 20:26:48 +0000 (16:26 -0400)] 
Remove buggy xterm workaround in tui_dispatch_ctrl_char()

The function tui_dispatch_ctrl_char() has an old workaround (from 1999)
for buggy terminals and/or ncurses library that don't return page
up/down keys as single characters.  Because the workaround is so old, I
think the bug it is targetting is no longer relevant anymore.

But more importantly, the workaround is itself buggy: it 1) performs a
blocking call to wgetch() and 2) if the key returned by wgetch() does
not make up a relevant key sequence it throws away the input instead of
pushing it back via ungetch().  And indeed the workaround breaks Alt-key
sequences under TERM=xterm because of bug #2.

So this patch removes the buggy workaround and tidies up the function
accordingly.

I personally tested this change on a recent xterm (with TERM=xterm) in
Fedora 20 and had no problems with having ncurses properly interpret
page up/down keys.  And Alt-key sequences now work when TERM=xterm too.

gdb/ChangeLog:

* tui/tui-command.c: Remove include of <ctype.h>.
(tui_dispatch_ctrl_char): Remove workaround for xterm terminals.

9 years ago[AArch64] Remove BFD overflow check restrictions
Jiong Wang [Thu, 14 May 2015 11:46:31 +0000 (12:46 +0100)] 
[AArch64] Remove BFD overflow check restrictions

bfd/
  * elfnn-aarch64.c (elfNN_aarch64_relocate_section): Remove overflow
  check restriction.

9 years agoUpdate description of the ASSERT linker script command to note its interation with...
Nick Clifton [Thu, 14 May 2015 11:32:12 +0000 (12:32 +0100)] 
Update description of the ASSERT linker script command to note its interation with PROVIDEd symbols.

* ld.texinfo (ASSERT): Describe the interaction with PROVIDEd
symbols.

9 years agoxtensa: fix localized symbol refcounting with --gc-sections
Max Filippov [Thu, 14 May 2015 02:22:55 +0000 (05:22 +0300)] 
xtensa: fix localized symbol refcounting with --gc-sections

elf_xtensa_gc_sweep_hook doesn't correctly unreference symbols that were
made local, that results in link failure with the following message:

  BFD (GNU Binutils) 2.24 internal error, aborting at elf32-xtensa.c line
  3372 in elf_xtensa_finish_dynamic_sections

elf_xtensa_gc_sweep_hook determines symbol reference type (PLT or GOT) by
relocation type. Relocation types are not changed when symbol becomes
local, but its PLT references are added to GOT references and
plt.refcount is set to 0. Such symbol cannot be unreferences in the
elf_xtensa_gc_sweep_hook and its extra references make calculated GOT
relocations section size not match number of GOT relocations.

Fix it by treating PLT reference as GOT reference when plt.refcount is
not positive.

2015-05-14  Max Filippov  <jcmvbkbc@gmail.com>
bfd/
* elf32-xtensa.c (elf_xtensa_gc_sweep_hook): Treat PLT reference
as GOT reference when plt.refcount is not positive.

9 years agoAutomatic date update in version.in
GDB Administrator [Thu, 14 May 2015 00:00:07 +0000 (00:00 +0000)] 
Automatic date update in version.in

9 years agodwarf2read.c (die_needs_namespace): Return 1 for DW_TAG_inlined_subroutine.
Martin Galvan [Wed, 13 May 2015 21:09:19 +0000 (14:09 -0700)] 
dwarf2read.c (die_needs_namespace): Return 1 for DW_TAG_inlined_subroutine.

gdb/ChangeLog:

* dwarf2read.c (die_needs_namespace): Return 1 for
DW_TAG_inlined_subroutine.

9 years agorevert previous patch, author not set
Doug Evans [Wed, 13 May 2015 21:07:03 +0000 (14:07 -0700)] 
revert previous patch, author not set

9 years agodwarf2read.c (die_needs_namespace): Return 1 for DW_TAG_inlined_subroutine.
Doug Evans [Wed, 13 May 2015 20:55:09 +0000 (13:55 -0700)] 
dwarf2read.c (die_needs_namespace): Return 1 for DW_TAG_inlined_subroutine.

gdb/ChangeLog:

* dwarf2read.c (die_needs_namespace): Return 1 for
DW_TAG_inlined_subroutine.

9 years agoMake regcache_cpy_no_passthrough static
Jan Kratochvil [Wed, 13 May 2015 18:47:33 +0000 (20:47 +0200)] 
Make regcache_cpy_no_passthrough static

regcache_cpy_no_passthrough is no longer used for a standalone call.

gdb/ChangeLog
2015-05-13  Jan Kratochvil  <jan.kratochvil@redhat.com>

* regcache.c (regcache_cpy_no_passthrough): New declaration.
(regcache_cpy_no_passthrough): Make it static, add function comment.
* regcache.h (regcache_dup, regcache_cpy): Reduce/update their comment.
(regcache_cpy_no_passthrough): Remove declaration.

9 years agoRemove stop_registers
Jan Kratochvil [Wed, 13 May 2015 18:47:33 +0000 (20:47 +0200)] 
Remove stop_registers

Now stop_registers are no longer used and it can be removed.

I am not much sure what 'proceed_to_finish' really means now so I make a wild
guess while updating comments about it.

gdb/ChangeLog
2015-05-13  Jan Kratochvil  <jan.kratochvil@redhat.com>

* gdbthread.h (struct thread_control_state): Update comment for
proceed_to_finish.
* infcall.c (run_inferior_call): Update comment about
proceed_to_finish.
* infcmd.c (get_return_value): Update comment about stop_registers.
(finish_forward): Update comment about proceed_to_finish.
* infrun.c (stop_registers): Remove.
(clear_proceed_status, normal_stop): Remove stop_registers handling.
* infrun.h (stop_registers): Remove.

9 years agoinfcall: stop_registers -> register_dummy_frame_dtor
Jan Kratochvil [Wed, 13 May 2015 18:47:32 +0000 (20:47 +0200)] 
infcall: stop_registers -> register_dummy_frame_dtor

With dummy_frame destructors GDB no longer has to use global stop_registers.
dummy_frame's registers can be now stored associated with their specific
dummy_frame.

gdb/ChangeLog
2015-05-13  Jan Kratochvil  <jan.kratochvil@redhat.com>

* infcall.c (struct dummy_frame_context_saver)
(dummy_frame_context_saver_data_free, dummy_frame_context_saver_dtor)
(dummy_frame_context_saver_drop, dummy_frame_context_saver_cleanup)
(dummy_frame_context_saver_get_regs, dummy_frame_context_saver_setup):
New.
(call_function_by_hand_dummy): Move discard_cleanups of
inf_status_cleanup before dummy_frame_push.  Call
dummy_frame_context_saver_setup and prepare context_saver_cleanup.
Use dummy_frame_context_saver_get_regs instead of stop_registers.
* infcall.h (struct dummy_frame_context_saver)
(dummy_frame_context_saver_drop, dummy_frame_context_saver_cleanup)
(dummy_frame_context_saver_get_regs, dummy_frame_context_saver_setup):
New declarations.
* infcmd.c: Include infcall.h.
(get_return_value): Add parameter ctx_saver, use it instead of
stop_registers.
(print_return_value): Add parameter ctx_saver, pass it.
(struct finish_command_continuation_args): Add field ctx_saver.
(finish_command_continuation): Update print_return_value caller.
(finish_command_continuation_free_arg): Free also ctx_saver.
(finish_forward): Call dummy_frame_context_saver_setup.
* inferior.h (struct dummy_frame_context_saver): New declaration.
(get_return_value): Add parameter ctx_saver.
* python/py-finishbreakpoint.c (bpfinishpy_pre_stop_hook): Update
get_return_value caller.

9 years agoregister_dummy_frame_dtor: Permit multiple dtors
Jan Kratochvil [Wed, 13 May 2015 18:47:32 +0000 (20:47 +0200)] 
register_dummy_frame_dtor: Permit multiple dtors

Later patch needs two independent destructors for the same dummy_frame.
Therefore the registrar has been extended to an arbitrary number of
destructors.

gdb/ChangeLog
2015-05-13  Jan Kratochvil  <jan.kratochvil@redhat.com>

* dummy-frame.c (struct dummy_frame_dtor_list): New.
(struct dummy_frame): Replace dtor and dtor_data by dtor_list.
(remove_dummy_frame): Process dtor_list.
(pop_dummy_frame): Process dtor_list.
(register_dummy_frame_dtor): Maintain dtor_list.
(find_dummy_frame_dtor): Handle dtor_list.
* dummy-frame.h (register_dummy_frame_dtor, find_dummy_frame_dtor):
Update comments.

9 years agoCall dummy_frame_dtor_ftype also from remove_dummy_frame
Jan Kratochvil [Wed, 13 May 2015 18:47:32 +0000 (20:47 +0200)] 
Call dummy_frame_dtor_ftype also from remove_dummy_frame

There was now a leak-like bug that if dummy_frame "disappeared" by
remove_dummy_frame then its destructor was not called.  For example in the case
of 'compile code' dummy frames the injected objfile would never get freed after
some inferior longjmp out of the injected code.

gdb/ChangeLog
2015-05-13  Jan Kratochvil  <jan.kratochvil@redhat.com>

* compile/compile-object-run.c (do_module_cleanup): Add parameter
registers_valid.
(compile_object_run): Update do_module_cleanup caller.
* dummy-frame.c: Include infcall.h.
(struct dummy_frame): Update dtor comment.
(remove_dummy_frame): Call dtor.
(pop_dummy_frame): Update dtor caller.
* dummy-frame.h (dummy_frame_dtor_ftype): Add parameter
registers_valid.

9 years agoDocument the GDB 7.9.1 release in gdb/ChangeLog
Joel Brobecker [Wed, 13 May 2015 17:48:31 +0000 (10:48 -0700)] 
Document the GDB 7.9.1 release in gdb/ChangeLog

gdb/ChangeLog:

GDB 7.9.1 released.

9 years agogdb/NEWS: Move "Xmethods can now specify a result type" to GDB 7.9.1 section.
Joel Brobecker [Wed, 13 May 2015 17:31:00 +0000 (10:31 -0700)] 
gdb/NEWS: Move "Xmethods can now specify a result type" to GDB 7.9.1 section.

As this change was ported to GDB 7.9.1, the NEWS entry is moved to
a newly-created "Changes in GDB 7.9.1" section, matching the NEWS
file which is going to be distributed with the GDB 7.9.1 release.

gdb/ChangeLog:

        * NEWS: Create "Changes in GDB 7.9.1" section.  Move news about
        Xmethods now being able to specify a result type to that new
        section.

9 years agoDisable the configuration of GDB for HPUX targets.
John David Anglin [Wed, 13 May 2015 16:32:01 +0000 (17:32 +0100)] 
Disable the configuration of GDB for HPUX targets.

* configure.ac: Disable configuration of GDB for HPUX targets.
* configure: Regenerate.

9 years agoxtensa: fix gas trampolines regression
Max Filippov [Sat, 9 May 2015 22:02:31 +0000 (01:02 +0300)] 
xtensa: fix gas trampolines regression

Extra condition 'abs (addr - trampaddr) < J_RANGE / 2' for trampoline
selection results in regressions: when relaxable jump is little longer
than J_RANGE so that single trampoline makes two new jumps, one longer
than J_RANGE / 2 and one shorter, correct trampoline cannot be found.

Drop that condition.

2015-05-13  Max Filippov  <jcmvbkbc@gmail.com>
gas/
* config/tc-xtensa.c (xtensa_relax_frag): Allow trampoline to be
closer than J_RANGE / 2 to jump frag.

gas/testsuite/
* gas/xtensa/trampoline.s: Add regression testcase.

9 years agoAdd missing ChangeLog entry for previous commit
Patrick Palka [Wed, 13 May 2015 15:57:06 +0000 (11:57 -0400)] 
Add missing ChangeLog entry for previous commit

9 years agoAvoid race condition when handling a SIGWINCH signal
Patrick Palka [Tue, 28 Apr 2015 01:37:48 +0000 (21:37 -0400)] 
Avoid race condition when handling a SIGWINCH signal

The control variable win_resized must be cleared before responding to
it.

Otherwise there is a small window where another SIGWINCH might occur in
between the handling of an earlier SIGWINCH and the clearing of
win_resized, at which point win_resized would be set (again) by the
signal handler.  Shortly thereafter we would clear win_resized even
though we only handled the earlier SIGWINCH but not the latest one.
This chain of events is all avoided if we clear win_resized first.

gdb/ChangeLog:

* tui/tui-win.c (tui_async_resize_screen): Clear win_resized
first before resizing the window.
* tui.c (tui_enable): Likewise.

9 years agodummy_frame_dtor_ftype vs. call_function_by_hand_dummy_dtor_ftype cleanup
Jan Kratochvil [Wed, 13 May 2015 13:55:09 +0000 (15:55 +0200)] 
dummy_frame_dtor_ftype vs. call_function_by_hand_dummy_dtor_ftype cleanup

Both dummy_frame_dtor_ftype and call_function_by_hand_dummy_dtor_ftype
represent the same type, there was some mistake/duplication during check-in.

gdb/ChangeLog
2015-05-08  Jan Kratochvil  <jan.kratochvil@redhat.com>

* dummy-frame.c (struct dummy_frame): Use proper typedef for dtor.
* dummy-frame.h (dummy_frame_dtor_ftype): Add its comment.
* infcall.c (call_function_by_hand_dummy): Use proper typedef for
dummy_dtor parameter.
* infcall.h: Include dummy-frame.h.
(call_function_by_hand_dummy_dtor_ftype): Remove.
(call_function_by_hand_dummy): Use proper typedef for dummy_dtor
parameter.

9 years agoFix PR gdb/17820
Patrick Palka [Sun, 26 Apr 2015 18:13:59 +0000 (14:13 -0400)] 
Fix PR gdb/17820

This patch is a comprehensive fix for PR 17820 which reports that
using "set history size unlimited" inside one's gdbinit file doesn't
really work.

There are three small changes in this patch.  The most important change
this patch makes is to decode the argument of the "size" subcommand
using add_setshow_zuinteger_unlimited_cmd() instead of using
add_setshow_uinteger_cmd().  The new decoder takes an int * and maps
unlimited to -1 whereas the old decoder takes an unsigned int * and maps
unlimited to UINT_MAX.  Using the new decoder simplifies our handling of
unlimited and makes it easier to interface with readline which itself
expects a signed-int history size.

The second change is the factoring of the [stifle|unstifle]_history logic
into a common function which is now used by both init_history() and
set_history_size_command().  This is technically the change that fixes
the PR itself.

Thirdly, this patch initializes history_size_setshow_var to -2 to mean
that the variable has not been set yet.  Now init_history() tests for -2
instead of 0 to determine whether to give the variable a default value.
This means that having "set history size 0" in one's gdbinit file will
actually keep the history size at 0 and not reset it to 256.

gdb/ChangeLog:

PR gdb/17820
* top.c (history_size_setshow_var): Change type to signed.
Initialize to -2.  Update documentation.
(set_readline_history_size): Define.
(set_history_size_command): Use it.  Remove logic for handling
out-of-range sizes.
(init_history): Use set_readline_history_size().  Test for a
value of -2 instead of 0 when determining whether to set a
default history size.
(init_main): Decode the argument of the "size" command as a
zuinteger_unlimited.

gdb/testsuite/ChangeLog:

PR gdb/17820
* gdb.base/gdbinit-history.exp: New test.
* gdb.base/gdbinit-history/unlimited/.gdbinit: New file.
* gdb.base/gdbinit-history/zero/.gdbinit: New file.

9 years agoRevert "Add -mno-shared to x86 assembler"
H.J. Lu [Wed, 13 May 2015 11:47:59 +0000 (04:47 -0700)] 
Revert "Add -mno-shared to x86 assembler"

This reverts commit 573cc2e57db66165b390044338d3a4ad51f36bf8.

9 years agoAdd missing ChangeLog entries for PR binutis/18386
H.J. Lu [Wed, 13 May 2015 11:33:45 +0000 (04:33 -0700)] 
Add missing ChangeLog entries for PR binutis/18386

9 years agoReturn ELF_CLASS_BOTH by default
H.J. Lu [Wed, 13 May 2015 10:57:46 +0000 (03:57 -0700)] 
Return ELF_CLASS_BOTH by default

* elfedit.c (elf_class): Return ELF_CLASS_BOTH by default.

9 years agoMAINTAINERS: Add myself as s390 and s390x maintainer.
Andreas Krebbel [Wed, 13 May 2015 06:19:45 +0000 (08:19 +0200)] 
MAINTAINERS: Add myself as s390 and s390x maintainer.

binutils/
* MAINTAINERS: Add myself as s390 and s390x maintainer.

9 years agoAutomatic date update in version.in
GDB Administrator [Wed, 13 May 2015 00:00:07 +0000 (00:00 +0000)] 
Automatic date update in version.in

9 years agoAllocate the first .plt entry space only if needed
H.J. Lu [Tue, 12 May 2015 20:11:48 +0000 (13:11 -0700)] 
Allocate the first .plt entry space only if needed

Commit dd7e64d45b317128f5fe813a8da0b13b4ad046ae may optimize out
i386/x86-64 JUMP_SLOT relocation.  If there is no JUMP_SLOT relocation
left, we don't need to the first .plt entry.  This patch allocates
space for the first .plt entry only if we also reserve space for a PLT
slot for JUMP_SLOT relocation.

bfd/

* elf32-i386.c (elf_i386_allocate_dynrelocs): Allocate space
for the first .plt entry only if needed.
* elf64-x86-64.c (elf_x86_64_allocate_dynrelocs): Likewise.

ld/testsuite/

* ld-i386/i386.exp: Run pltgot-1 for Linux targets.
* ld-x86-64/x86-64.exp: Likewise.
* ld-i386/pltgot-1.d: New file.
* ld-i386/pltgot-1.s: Likewise.
* ld-x86-64/pltgot-1.d: Likewise.
* ld-x86-64/pltgot-1.s: Likewise.

9 years agoAlso skip x86_64-*-nacl*
H.J. Lu [Tue, 12 May 2015 19:47:27 +0000 (12:47 -0700)] 
Also skip x86_64-*-nacl*

* binutils-all/elfedit-1.d: Also skip x86_64-*-nacl*.

9 years agotweak some comments
Doug Evans [Tue, 12 May 2015 17:42:49 +0000 (10:42 -0700)] 
tweak some comments

gdb/ChangeLog:

* dwarf2read.c (struct file_entry): Tweak comments.
(get_debug_line_section): Tweak comments.

9 years agoExtended-remote fork event docs
Don Breazeal [Tue, 12 May 2015 16:52:47 +0000 (09:52 -0700)] 
Extended-remote fork event docs

This patch contains the accumulated documentation changes for the
rest of the extended-remote follow fork patchset.

gdb/ChangeLog:

        * NEWS: Announce fork support in the RSP and support
          for fork debugging in extended mode.

gdb/doc/ChangeLog:

        * gdb.texinfo (Forks): Note that fork debugging is
          supported in extended mode.
          (Remote Configuration): Add fork event features to table
          of packet settings.
          (Stop Reply Packets): Add fork events to list of stop reasons.
          (General Query Packets): Add fork events to tables of
          'gdbfeatures' and 'stub features' supported in the qSupported
          packet, as well as to the list containing stub feature
          details.

9 years agoExtended-remote fork catch
Don Breazeal [Tue, 12 May 2015 16:52:46 +0000 (09:52 -0700)] 
Extended-remote fork catch

This patch implements catchpoints for fork events on extended-remote
Linux targets.

Implementation appeared to be straightforward, requiring four new functions
in remote.c to implement insert/remove of fork/vfork catchpoints.  These
functions are essentially stubs that just return 0 ('success') if the
required features are enabled.  If the fork events are being reported, then
catchpoints are set and hit.

However, there are some extra issues that arise with catchpoints.

1) Thread creation reporting -- fork catchpoints are hit before the
   follow_fork has been completed.  When stopped at a fork catchpoint
   in the native implementation, the new process is not 'reported'
   until after the follow is done.  It doesn't show up in the inferiors
   list or the threads list.  However, in the gdbserver case, an
   'info threads' while stopped at a fork catchpoint will retrieve the
   new thread info from the target and add it to GDB's data structures,
   prior to the follow operations.  Because of this premature report,
   things on the GDB side eventually get very confused.

   So in remote.c:remote_update_thread_list, we check to see if there
   are any pending fork parent threads.  If there are we remove the
   related fork child thread from the thread list sent by the target.

2) Kill process before fork is followed -- on the native side in
   linux-nat.c:linux_nat_kill, there is some code to handle the case where
   a fork has occurred but follow_fork hasn't been called yet.  It does
   this by using the last status to determine if a follow is pending, and
   if it is, to kill the child task.  The use of last_status is fragile
   in situations like non-stop mode where other events may have occurred
   after the fork event.  This patch identifies a fork parent
   in remote.c:extended_remote_kill in a way similar to that used in
   thread creation reporting above.  If one is found, it kills the new
   child as well.

Tested on x64 Ubuntu Lucid, native, remote, extended-remote.  Tested the
case of killing the forking process before the fork has been followed
manually.

gdb/ChangeLog:
        * remote.c (remote_insert_fork_catchpoint): New function.
        (remote_remove_fork_catchpoint): New function.
        (remote_insert_vfork_catchpoint): New function.
        (remote_remove_vfork_catchpoint): New function.
        (pending_fork_parent_callback): New function.
        (remove_new_fork_child): New function.
        (remote_update_thread_list): Call remote_notif_get_pending_events
        and remove_new_fork_child.
        (extended_remote_kill): Kill fork child when killing the
        parent before follow_fork completes.
        (init_extended_remote_ops): Initialize target vector with
        new fork catchpoint functions.

9 years agoExtended-remote follow vfork
Don Breazeal [Tue, 12 May 2015 16:52:45 +0000 (09:52 -0700)] 
Extended-remote follow vfork

This patch implements follow-fork for vfork on extended-remote Linux targets.

The implementation follows the native implementation as much as possible.
Most of the work is done on the GDB side in the existing code now in
infrun.c.  GDBserver just has to report the events and do a little
bookkeeping.

Implementation includes:

 * enabling VFORK events by adding ptrace options for VFORK and VFORK_DONE
   to linux-low.c:linux_low_ptrace_options.

 * handling VFORK and VFORK_DONE events in linux-low.c:handle_extended_wait
   and reporting them to GDB.

 * including VFORK and VFORK_DONE events in the predicate
   linux-low.c:extended_event_reported.

 * adding support for VFORK and VFORK_DONE events in RSP by adding stop
   reasons "vfork" and "vforkdone" to the 'T' Stop Reply Packet in both
   gdbserver/remote-utils.c and gdb/remote.c.

Tested on x64 Ubuntu Lucid, native, remote, extended-remote.

gdb/gdbserver/ChangeLog:

        * linux-low.c (handle_extended_wait): Handle PTRACE_EVENT_FORK and
        PTRACE_EVENT_VFORK_DONE.
        (linux_low_ptrace_options, extended_event_reported): Add vfork
        events.
        * remote-utils.c (prepare_resume_reply): New stop reasons "vfork"
        and "vforkdone" for RSP 'T' Stop Reply Packet.
        * server.h (report_vfork_events): Declare
        global variable.

gdb/ChangeLog:

        * remote.c (remove_vfork_event_p): New function.
        (remote_follow_fork): Add vfork event type to event checking.
        (remote_parse_stop_reply): New stop reasons "vfork" and
        "vforkdone" for RSP 'T' Stop Reply Packet.

9 years agoArch-specific remote follow fork
Don Breazeal [Tue, 12 May 2015 16:52:44 +0000 (09:52 -0700)] 
Arch-specific remote follow fork

This patch implements the architecture-specific pieces of follow-fork
for remote and extended-remote Linux targets, which in the current
implementation copyies the parent's debug register state into the new
child's data structures.  This is required for x86, arm, aarch64, and
mips.

This follows the native implementation as closely as possible by
implementing a new linux_target_ops function 'new_fork', which is
analogous to 'linux_nat_new_fork' in linux-nat.c.  In gdbserver, the debug
registers are stored in the process list, instead of an
architecture-specific list, so the function arguments are process_info
pointers instead of an lwp_info and a pid as in the native implementation.

In the MIPS implementation the debug register mirror is stored differently
from x86, ARM, and aarch64, so instead of doing a simple structure assignment
I had to clone the list of watchpoint structures.

Tested using gdb.threads/watchpoint-fork.exp on x86, and ran manual tests
on a MIPS board and an ARM board.  Aarch64 hasn't been tested.

gdb/gdbserver/ChangeLog:

        * linux-aarch64-low.c (aarch64_linux_new_fork): New function.
        (the_low_target) <new_fork>: Initialize new member.
        * linux-arm-low.c (arm_new_fork): New function.
        (the_low_target) <new_fork>: Initialize new member.
        * linux-low.c (handle_extended_wait): Call new target function
        new_fork.
        * linux-low.h (struct linux_target_ops) <new_fork>: New member.
        * linux-mips-low.c (mips_add_watchpoint): New function
        extracted from mips_insert_point.
        (the_low_target) <new_fork>: Initialize new member.
        (mips_linux_new_fork): New function.
        (mips_insert_point): Call mips_add_watchpoint.
        * linux-x86-low.c (x86_linux_new_fork): New function.
        (the_low_target) <new_fork>: Initialize new member.

9 years agoExtended-remote Linux follow fork
Don Breazeal [Tue, 12 May 2015 16:52:43 +0000 (09:52 -0700)] 
Extended-remote Linux follow fork

This patch implements basic support for follow-fork and detach-on-fork on
extended-remote Linux targets.  Only 'fork' is supported in this patch;
'vfork' support is added n a subsequent patch.  This patch depends on
the previous patches in the patch series.

Sufficient extended-remote functionality has been implemented here to pass
gdb.base/multi-forks.exp, as well as gdb.base/foll-fork.exp with the
catchpoint tests commented out.  Some other fork tests fail with this
patch because it doesn't provide the architecture support needed for
watchpoint inheritance or fork catchpoints.

The implementation follows the same general structure as for the native
implementation as much as possible.

This implementation includes:
 * enabling fork events in linux-low.c in initialize_low and
   linux_enable_extended_features

 * handling fork events in gdbserver/linux-low.c:handle_extended_wait

   - when a fork event occurs in gdbserver, we must do the full creation
     of the new process, thread, lwp, and breakpoint lists.  This is
     required whether or not the new child is destined to be
     detached-on-fork, because GDB will make target calls that require all
     the structures.  In particular we need the breakpoint lists in order
     to remove the breakpoints from a detaching child.  If we are not
     detaching the child we will need all these structures anyway.

   - as part of this event handling we store the target_waitstatus in a new
     member of the parent lwp_info structure, 'waitstatus'.  This
     is used to store extended event information for reporting to GDB.

   - handle_extended_wait is given a return value, denoting whether the
     handled event should be reported to GDB.  Previously it had only
     handled clone events, which were never reported.

 * using a new predicate in gdbserver to control handling of the fork event
   (and eventually all extended events) in linux_wait_1.  The predicate,
   extended_event_reported, checks a target_waitstatus.kind for an
   extended ptrace event.

 * implementing a new RSP 'T' Stop Reply Packet stop reason: "fork", in
   gdbserver/remote-utils.c and remote.c.

 * implementing new target and RSP support for target_follow_fork with
   target extended-remote.  (The RSP components were actually defined in
   patch 1, but they see their first use here).

   - remote target routine remote_follow_fork, which just sends the 'D;pid'
     detach packet to detach the new fork child cleanly.  We can't just
     call target_detach because the data structures for the forked child
     have not been allocated on the host side.

Tested on x64 Ubuntu Lucid, native, remote, extended-remote.

gdb/gdbserver/ChangeLog:

        * linux-low.c (handle_extended_wait): Implement return value,
        rename argument 'event_child' to 'event_lwp', handle
        PTRACE_EVENT_FORK, call internal_error for unrecognized event.
        (linux_low_ptrace_options): New function.
        (linux_low_filter_event): Call linux_low_ptrace_options,
        use different argument fo linux_enable_event_reporting,
        use return value from handle_extended_wait.
        (extended_event_reported): New function.
        (linux_wait_1): Call extended_event_reported and set
        status to report fork events.
        (linux_write_memory): Add pid to debug message.
        (reset_lwp_ptrace_options_callback): New function.
        (linux_handle_new_gdb_connection): New function.
        (linux_target_ops): Initialize new structure member.
        * linux-low.h (struct lwp_info) <waitstatus>: New member.
        * lynx-low.c: Initialize new structure member.
        * remote-utils.c (prepare_resume_reply): Implement stop reason
        "fork" for "T" stop message.
        * server.c (handle_query): Call handle_new_gdb_connection.
        * server.h (report_fork_events): Declare global flag.
        * target.h (struct target_ops) <handle_new_gdb_connection>:
        New member.
        (target_handle_new_gdb_connection): New macro.
        * win32-low.c: Initialize new structure member.

gdb/ChangeLog:

        * linux-nat.c (linux_nat_ptrace_options): New function.
        (linux_init_ptrace, wait_lwp, linux_nat_filter_event):
        Call linux_nat_ptrace_options and use different argument to
        linux_enable_event_reporting.
        (_initialize_linux_nat): Delete call to
        linux_ptrace_set_additional_flags.
        * nat/linux-ptrace.c (current_ptrace_options): Rename to
        supported_ptrace_options.
        (additional_flags): Delete variable.
        (linux_check_ptrace_features): Use supported_ptrace_options.
        (linux_test_for_tracesysgood, linux_test_for_tracefork):
        Likewise, and remove additional_flags check.
        (linux_enable_event_reporting): Change 'attached' argument to
        'options'.  Use supported_ptrace_options.
        (ptrace_supports_feature): Change comment.  Use
        supported_ptrace_options.
        (linux_ptrace_set_additional_flags): Delete function.
        * nat/linux-ptrace.h (linux_ptrace_set_additional_flags):
        Delete function prototype.
        * remote.c (remote_fork_event_p): New function.
        (remote_detach_pid): New function.
        (remote_detach_1): Call remote_detach_pid, don't mourn inferior
        if doing detach-on-fork.
        (remote_follow_fork): New function.
        (remote_parse_stop_reply): Handle new "T" stop reason "fork".
        (remote_pid_to_str): Print "process" strings for pid/0/0 ptids.
        (init_extended_remote_ops): Initialize to_follow_fork.

9 years agoClone remote breakpoints
Don Breazeal [Tue, 12 May 2015 16:52:42 +0000 (09:52 -0700)] 
Clone remote breakpoints

This patch implements gdbserver routines to clone the breakpoint lists of a
process, duplicating them for another process.  In gdbserver, each process
maintains its own independent breakpoint list.  When a fork call creates a
child, all of the breakpoints currently inserted in the parent process are
also inserted in the child process, but there is nothing to describe them
in the data structures related to the child.  The child must have a
breakpoint list describing them so that they can be removed (if detaching)
or recognized (if following).  Implementation is a mechanical process of
just cloning the lists in several new functions in gdbserver/mem-break.c.

Tested by building, since none of the new functions are called yet.  This
was tested with another patch in the series that implements follow-fork.

gdb/gdbserver/ChangeLog:

        * mem-break.c (APPEND_TO_LIST): Define macro.
        (clone_agent_expr): New function.
        (clone_one_breakpoint): New function.
        (clone_all_breakpoints): New function.
        * mem-break.h: Declare new functions.

9 years agoIdentify remote fork event support
Don Breazeal [Tue, 12 May 2015 16:52:41 +0000 (09:52 -0700)] 
Identify remote fork event support

This patch implements a mechanism for GDB to determine whether fork
events are supported in gdbserver.  This is a preparatory patch for
remote fork and exec event support.

Two new RSP packets are defined to represent fork and vfork event
support.  These packets are used just like PACKET_multiprocess_feature
to denote whether the corresponding event is supported.  GDB sends
fork-events+ and vfork-events+ to gdbserver to inquire about fork
event support.  If the response enables these packets, then GDB
knows that gdbserver supports the corresponding events and will
enable them.

Target functions used to query for support are included along with
each new packet.

In order for gdbserver to know whether the events are supported at the
point where the qSupported packet arrives, the code in nat/linux-ptrace.c
had to be reorganized.  Previously it would test for fork/exec event
support, then enable the events using the pid of the inferior.  When the
qSupported packet arrives there may not be an inferior.  So the mechanism
was split into two parts: a function that checks whether the events are
supported, called when gdbserver starts up, and another that enables the
events when the inferior stops for the first time.

Another gdbserver change was to add some global variables similar to
multi_process, one per new packet.  These are used to control whether
the corresponding fork events are enabled.  If GDB does not inquire
about the event support in the qSupported packet, then gdbserver will
not set these "report the event" flags.  If the flags are not set, the
events are ignored like they were in the past.  Thus, gdbserver will
never send fork event notification to an older GDB that doesn't
recognize fork events.

Tested on Ubuntu x64, native/remote/extended-remote, and as part of
subsequent patches in the series.

gdb/gdbserver/ChangeLog:

        * linux-low.c (linux_supports_fork_events): New function.
        (linux_supports_vfork_events): New function.
        (linux_target_ops): Initialize new structure members.
        (initialize_low): Call linux_check_ptrace_features.
        * lynx-low.c (lynx_target_ops): Initialize new structure
        members.
        * server.c (report_fork_events, report_vfork_events):
        New global flags.
        (handle_query): Add new features to qSupported packet and
        response.
        (captured_main): Initialize new global variables.
        * target.h (struct target_ops) <supports_fork_events>:
        New member.
        <supports_vfork_events>: New member.
        (target_supports_fork_events): New macro.
        (target_supports_vfork_events): New macro.
        * win32-low.c (win32_target_ops): Initialize new structure
        members.

gdb/ChangeLog:

        * nat/linux-ptrace.c (linux_check_ptrace_features): Change
        from static to extern.
        * nat/linux-ptrace.h (linux_check_ptrace_features): Declare.
        * remote.c (anonymous enum): <PACKET_fork_event_feature,
        * PACKET_vfork_event_feature>: New enumeration constants.
        (remote_protocol_features): Add table entries for new packets.
        (remote_query_supported): Add new feature queries to qSupported
        packet.
        (_initialize_remote): Exempt new packets from the requirement
        to have 'set remote' commands.

9 years ago[AArch64] Add R_AARCH64_P32_LD32_GOTPAGE_LO14 to elf header
Jiong Wang [Tue, 12 May 2015 12:47:15 +0000 (13:47 +0100)] 
[AArch64] Add R_AARCH64_P32_LD32_GOTPAGE_LO14 to elf header

2015-05-12  Jiong. Wang  <jiong.wang@arm.com>

include/
  * elf/aarch64.h (R_AARCH64_P32_LD32_GOTPAGE_LO14): New enumeration.

9 years agoLocate executables on remote stubs without multiprocess extensions
Gary Benson [Tue, 12 May 2015 10:57:52 +0000 (11:57 +0100)] 
Locate executables on remote stubs without multiprocess extensions

This commit allows GDB to determine filenames of main executables
when debugging using remote stubs without multiprocess extensions.
The qXfer:exec-file:read packet is extended to allow an empty
annex, with the meaning that the remote stub should supply the
filename of whatever it thinks is the current process.

gdb/ChangeLog:

* remote.c (remote_add_inferior): Call exec_file_locate_attach
for fake PIDs as well as real ones.
(remote_pid_to_exec_file): Send empty annex if PID is fake.

gdb/doc/ChangeLog:

* gdb.texinfo (General Query Packets): Document
qXfer:exec-file:read with empty annex.

gdb/gdbserver/ChangeLog:

* server.c (handle_qxfer_exec_file): Use current process
if annex is empty.

9 years agoEnables the -t abbreviated form of the --temp-prefix command line option for dlltool.
Stephen Kitt [Tue, 12 May 2015 10:16:03 +0000 (11:16 +0100)] 
Enables the -t abbreviated form of the --temp-prefix command line option for dlltool.

* dlltool.c (main): Accept -t as an abbreviation for
--temp-prefix.

9 years agoAutomatic date update in version.in
GDB Administrator [Tue, 12 May 2015 00:00:07 +0000 (00:00 +0000)] 
Automatic date update in version.in

9 years agoRemove Disp16|Disp32 from 64-bit direct branches
H.J. Lu [Mon, 11 May 2015 21:20:37 +0000 (14:20 -0700)] 
Remove Disp16|Disp32 from 64-bit direct branches

Disp16 and Disp32 aren't supported by direct branches in 64-bit mode.
This patch removes them from 64-bit direct branches.

* opcodes/i386-opc.tbl (call): Remove Disp16|Disp32 from 64-bit
direct branch.
(jmp): Likewise.
* i386-tbl.h: Regenerated.

9 years agoAllow mixing target and not-target directives
H.J. Lu [Mon, 11 May 2015 19:29:27 +0000 (12:29 -0700)] 
Allow mixing target and not-target directives

Mixing target and not-target directives can be used to run for x86_64-*-*
target while skipping x86_64-*-gnux32 target.  This patch allows mixing
target and not-target directives. It is used to skip elfedit-1 for
x86_64-*-gnux32.

* binutils-all/elfedit-1.d: Skip x86_64-*-gnux32.
* lib/utils-lib.exp (run_dump_test): Allow mixing target and
not-target directives.

9 years agoDefault e_machine to EM_IAMCU for i?86-*-elfiamcu
H.J. Lu [Mon, 11 May 2015 19:01:57 +0000 (12:01 -0700)] 
Default e_machine to EM_IAMCU for i?86-*-elfiamcu

This patch sets the default ELF output format of assembler and linker to
EM_IAMCU when binutils is configured to i?86-*-elfiamcu target.

gas/

* configure.tgt (arch): Set to iamcu for i386-*-elfiamcu target.
* config/tc-i386.c (i386_mach): Support iamcu.
(i386_target_format): Likewise.

ld/

* configure.tgt: Support i[3-7]86-*-elfiamcu target.

ld/testsuite/

* ld-i386/i386.exp (iamcu_tests): Run iamcu-4.
* ld-i386/iamcu-4.d: New file.

9 years agoAdd Intel MCU support to ld
H.J. Lu [Mon, 11 May 2015 18:27:34 +0000 (11:27 -0700)] 
Add Intel MCU support to ld

-m elf_iamcu must be passed to i386 linker to generate Intel MCU binary.

ld/

* Makefile.am (ALL_EMULATION_SOURCES): Add eelf_iamcu.c.
(eelf_iamcu.c): New.
* configure.tgt (targ_extra_emuls): Add elf_iamcu if elf_i386 is
enabled in BFD.
* Makefile.in: Regenerated.
* emulparams/elf_iamcu.sh: New file.

ld/testsuite/

* ld-i386/abs-iamcu.d: New file.
* ld-i386/dummy.s: Likewise.
* ld-i386/foo.s: Likewise.
* ld-i386/iamcu-1.d: Likewise.
* ld-i386/iamcu-2.d: Likewise.
* ld-i386/iamcu-3.d: Likewise.
* ld-i386/start.s: Likewise.
* ld-i386/i386.exp (iamcu_tests): New.
Run iamcu_tests.

9 years agoAdd Intel MCU support to gas
H.J. Lu [Mon, 11 May 2015 18:11:19 +0000 (11:11 -0700)] 
Add Intel MCU support to gas

-march=iamcu must be passed to i386 assembler to generate Intel MCU object
file.

gas/

* config/tc-i386.c (cpu_arch): Add iamcu.
(i386_align_code): Handle PROCESSOR_IAMCU.
(i386_arch): Likewise.
(i386_mach): Likewise.
(i386_target_format): Likewise.
(valid_iamcu_cpu_flags): New function.
(check_cpu_arch_compatible): Only allow Intel MCU instructions
when targeting Intel MCU.
(set_cpu_arch): Call valid_iamcu_cpu_flags to check if CPU flags
are valid for Intel MCU.
(md_parse_option): Likewise.
* tc-i386.h (ELF_TARGET_IAMCU_FORMAT): New.
(processor_type): Add PROCESSOR_IAMCU.
* doc/c-i386.texi: Document iamcu.

gas/testsuite/

* gas/i386/i386.exp: Run iamcu-1, iamcu-2, iamcu-3, iamcu-inval-1,
iamcu-inval-2 and iamcu-inval-3.
* gas/i386/iamcu-1.d: New file.
* gas/i386/iamcu-1.s: Likewise.
* gas/i386/iamcu-2.d: Likewise.
* gas/i386/iamcu-2.s: Likewise.
* gas/i386/iamcu-3.d: Likewise.
* gas/i386/iamcu-3.s: Likewise.
* gas/i386/iamcu-inval-1.l: Likewise.
* gas/i386/iamcu-inval-1.s: Likewise.
* gas/i386/iamcu-inval-2.l: Likewise.
* gas/i386/iamcu-inval-2.s: Likewise.
* gas/i386/iamcu-inval-3.l: Likewise.
* gas/i386/iamcu-inval-3.s: Likewise.

9 years agoAdd Intel MCU support to opcodes
H.J. Lu [Mon, 11 May 2015 17:47:55 +0000 (10:47 -0700)] 
Add Intel MCU support to opcodes

* configure.ac: Support bfd_iamcu_arch.
* disassemble.c (disassembler): Support bfd_iamcu_arch.
* i386-gen.c (cpu_flag_init): Add CPU_IAMCU_FLAGS and
CPU_IAMCU_COMPAT_FLAGS.
(cpu_flags): Add CpuIAMCU.
* i386-opc.h (CpuIAMCU): New.
(i386_cpu_flags): Add cpuiamcu.
* configure: Regenerated.
* i386-init.h: Likewise.
* i386-tbl.h: Likewise.

9 years agoAdd init_dwarf_regnames_iamcu
H.J. Lu [Mon, 11 May 2015 17:41:00 +0000 (10:41 -0700)] 
Add init_dwarf_regnames_iamcu

* dwarf.c (dwarf_regnames_iamcu): New.
(init_dwarf_regnames_iamcu): Likewise.
(init_dwarf_regnames): Call init_dwarf_regnames_iamcu for EM_IAMCU.
* dwarf.h (init_dwarf_regnames_iamcu): New.
* objdump.c (dump_dwarf): Call init_dwarf_regnames_iamcu for
bfd_arch_iamcu.

9 years agoAdd Intel MCU support to bfd
H.J. Lu [Mon, 11 May 2015 17:30:32 +0000 (10:30 -0700)] 
Add Intel MCU support to bfd

bfd/

* Makefile.am (ALL_MACHINES): Add cpu-iamcu.lo.
(ALL_MACHINES_CFILES): Likewise.
* archures.c (bfd_mach_iamcu): New.
(bfd_mach_i386_iamcu): Likewise.
(bfd_mach_i386_iamcu_intel_syntax): Likewise.
(bfd_iamcu_arch): Likewise.
(bfd_archures_list): Add &bfd_iamcu_arch.
* config.bfd (targ_selvecs): Add iamcu_elf32_vec to
i386_elf32_vec.
(targ_archs): Add bfd_iamcu_arch if needed.
* configure.ac: Support iamcu_elf32_vec.
* cpu-iamcu.c: New file.
* elf32-i386.c (elf32_iamcu_elf_object_p): New function.
Add support for iamcu_elf32_vec and elf32_iamcu_bed.
* targets.c (iamcu_elf32_vec): New.
(_bfd_target_vector): Add iamcu_elf32_vec.
* Makefile.in: Regenerated.
* bfd-in2.h: Likewise.
* configure: Likewise.

binutils/testsuite/

* binutils-all/objdump.exp (cpus_expected): Append iamcu.

9 years agoAdd EM_386/EM_IAMCU support to elfedit.c
H.J. Lu [Mon, 11 May 2015 16:57:20 +0000 (09:57 -0700)] 
Add EM_386/EM_IAMCU support to elfedit.c

binutils/

* elfedit.c (enum elfclass): New.
(input_elf_class): Change type to enum elfclass.
(output_elf_class): New.
(elf_class): Change return type to enum elfclass.  Support EM_386
and EM_IAMCU.
(update_elf_header): Check if input and output ELF classes match.
(elf_machine): Support EM_386 and EM_IAMCU.
(main): Update input_elf_class.  Set output_elf_class.
* doc/binutils.texi: Update elfedit.

binutils/testsuite/

* binutils-all/elfedit-5.d: New file.
* binutils-all/elfedit.exp: Run elfedit-5.

9 years agoRename EM_486 to EM_IAMCU
H.J. Lu [Mon, 11 May 2015 15:52:43 +0000 (08:52 -0700)] 
Rename EM_486 to EM_IAMCU

bfd/

* elfcode.h (elf_object_p): Replace EM_486 with EM_IAMCU.

binutils/

* dwarf.c (init_dwarf_regnames): Replace EM_486 with EM_IAMCU.
* readelf.c (guess_is_rela): Likewise.
(dump_relocations): Likewise.
(get_machine_name): Likewise.
(get_elf_section_flags): Likewise.
(process_section_headers): Likewise.
(is_32bit_abs_reloc): Likewise.
(is_32bit_pcrel_reloc): Likewise.

include/elf/

* common.h (EM_486): Renamed to ...
(EM_IAMCU): This.

9 years agoAutomatic date update in version.in
GDB Administrator [Mon, 11 May 2015 00:00:08 +0000 (00:00 +0000)] 
Automatic date update in version.in

9 years agoReplace input_bfd and output_bfd with abfd
H.J. Lu [Sun, 10 May 2015 13:44:12 +0000 (06:44 -0700)] 
Replace input_bfd and output_bfd with abfd

The first argument to bfd_get_8/bfd_put_8 isn't used.  But we should
use something real.  Replace input_bfd and output_bfd with abfd.

* elf32-i386.c (elf_i386_convert_mov_to_lea): Replace input_bfd
and output_bfd with abfd.
* elf64-x86-64.c (elf_x86_64_convert_mov_to_lea): Likewise.

9 years ago[Python] Add methods reference_value and const_value to gdb.Value.
Siva Chandra [Sat, 25 Apr 2015 14:04:40 +0000 (07:04 -0700)] 
[Python] Add methods reference_value and const_value to gdb.Value.

gdb/ChangeLog:

* NEWS (Python Scripting): Mention the new gdb.Value methods.
* python/py-value.c (valpy_reference_value): New function.
(valpy_const_value): Likewise.
(value_object_methods): Add new methods.
* value.c (make_cv_value): New function.
* value.h (make_cv_value): Declare.

gdb/doc/ChangeLog:

* python.texi (Values From Inferior): Add descriptions of new
methods gdb.Value.reference_value and gdb.Value.const_value.

gdb/testsuite/ChangeLog:

* gdb.python/py-xmethods.cc: Enhance test case.
* gdb.python/py-xmethods.exp: New tests.
* gdb.python/py-xmethods.py (A_indexoper): New xmethod worker
function.
(B_indexoper): Likewise.
(global_dm_list) : Add new xmethod worker functions.

9 years agoAutomatic date update in version.in
GDB Administrator [Sun, 10 May 2015 00:00:08 +0000 (00:00 +0000)] 
Automatic date update in version.in

9 years agoIgnore 0x66 prefix for call/jmp/jcc in 64-bit mode
H.J. Lu [Sat, 9 May 2015 00:13:30 +0000 (17:13 -0700)] 
Ignore 0x66 prefix for call/jmp/jcc in 64-bit mode

The operand size prefix (0x66) is ignored for 32-bit PC-relative call,
jmp and jcc in 64-bit mode.

gas/testsuite/

PR binutis/18386
* gas/i386/i386.exp: Run x86-64-jump.
* gas/i386/x86-64-branch.d: Updated.
* gas/i386/ilp32/x86-64-branch.d: Likewise.
* gas/i386/x86-64-branch.s: Add tests for the operand size prefix
with call, jmp and jb.
* gas/i386/x86-64-jump.d: New file.
* gas/i386/x86-64-jump.s: Likewise.

ld/testsuite/

PR binutis/18386
* ld-x86-64/tlsgdesc.dd: Updated.
* ld-x86-64/tlspic.dd: Likewise.

opcodes/

PR binutis/18386
* i386-dis.c (X86_64_E8): New.
(X86_64_E9): Likewise.
Update comments on 'T', 'U', 'V'.  Add comments for '^'.
(dis386): Replace callT/jmpT with X86_64_E8/X86_64_E9.
(x86_64_table): Add X86_64_E8 and X86_64_E9.
(mod_table): Replace {T|} with ^ on Jcall/Jmp.
(putop): Handle '^'.
(OP_J): Ignore the operand size prefix in 64-bit.  Don't check
REX_W.

9 years agoAutomatic date update in version.in
GDB Administrator [Sat, 9 May 2015 00:00:08 +0000 (00:00 +0000)] 
Automatic date update in version.in

9 years agoAvoid segfault on missing directory table.
Sandra Loosemore [Fri, 8 May 2015 19:43:39 +0000 (12:43 -0700)] 
Avoid segfault on missing directory table.

2015-05-08  Yao Qi  <yao@codesourcery.com>
    Sandra Loosemore  <sandra@codesourcery.com>

gdb/
* dwarf2read.c (setup_type_unit_groups): Do NULL pointer check
to 'lh->include_dirs' before accessing to it.
(psymtab_include_file_name): Likewise.
(dwarf_decode_lines_1): Likewise.
(dwarf_decode_lines): Likewise.
(file_file_name): Likewise.

9 years agoFix register save offset for nios2 signal handler trampolines.
Sandra Loosemore [Fri, 8 May 2015 19:34:52 +0000 (12:34 -0700)] 
Fix register save offset for nios2 signal handler trampolines.

2015-05-08  Sandra Loosemore  <sandra@codesourcery.com>

gdb/
* nios2-linux-tdep.c (NIOS2_SIGRETURN_TRAMP_ADDR): Define.
(NIOS2_SIGRETURN_REGSAVE_OFFSET): Define.
(nios2_linux_rt_sigreturn_init): Adjust base address of
register save area.

9 years agoUse PTRACE_GETREGSET/SETREGSET in nios2 gdbserver.
Sandra Loosemore [Fri, 8 May 2015 19:32:43 +0000 (12:32 -0700)] 
Use PTRACE_GETREGSET/SETREGSET in nios2 gdbserver.

2015-05-08  Sandra Loosemore  <sandra@codesourcery.com>

gdb/gdbserver/
* linux-nios2-low.c: Include elf/common.h.  Adjust comments.
Remove HAVE_PTRACE_GETREGS conditionals.
(nios2_regsets): Use PTRACE_GETREGSET and PTRACE_SETREGSET
instead of PTRACE_GETREGS and PTRACE_SETREGS.

9 years agoRevert to using "trap 31" for breakpoints on nios2.
Sandra Loosemore [Fri, 8 May 2015 19:24:41 +0000 (12:24 -0700)] 
Revert to using "trap 31" for breakpoints on nios2.

2015-05-08  Sandra Loosemore  <sandra@codesourcery.com>

gdb/
* nios2-tdep.c (nios2_breakpoint_from_pc): Revert to using
"trap 31" as the breakpoint instruction on all targets.

9 years agoFix coredump-filter.exp by correctly unsetting array
Sergio Durigan Junior [Fri, 8 May 2015 17:19:19 +0000 (13:19 -0400)] 
Fix coredump-filter.exp by correctly unsetting array

In my last commit to make gdb.base/coredump-filter.exp be more robust
regarding using arrays in the global namespace, I cleared the
"coredump_var_addr" array like this:

  set coredump_var_addr ""
  # use coredump_var_addr as an array...

This causes DejaGNU to complain because the variable is first set as
non-array, and the used as an array.  The correct way to do this is to
unset the variable using:

  unset -nocomplain coredump_var_addr
  # use coredump_var_addr as an array...

The "-nocomplain" part is necessary because if the variable doesn't
exist "unset" will not error.

Tested on Fedora 20 x86_64.

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

* gdb.base/coredump-filter.exp: Correctly unset
"coredump_var_addr" array.

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