binutils-gdb.git
10 years agoPR gdb/13860: make "-exec-foo"'s MI output equal to "foo"'s MI output.
Pedro Alves [Tue, 18 Mar 2014 17:50:28 +0000 (17:50 +0000)]
PR gdb/13860: make "-exec-foo"'s MI output equal to "foo"'s MI output.

Part of PR gdb/13860 is about the mi-solib.exp test's output being
different in sync vs async modes.

sync:

  >./gdb -nx -q ./testsuite/gdb.mi/solib-main -ex "set stop-on-solib-events 1" -ex "set target-async off" -i=mi
  =thread-group-added,id="i1"
  ~"Reading symbols from /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.mi/solib-main..."
  ~"done.\n"
  (gdb)
  &"start\n"
  ~"Temporary breakpoint 1 at 0x400608: file ../../../src/gdb/testsuite/gdb.mi/solib-main.c, line 21.\n"
  =breakpoint-created,bkpt={number="1",type="breakpoint",disp="del",enabled="y",addr="0x0000000000400608",func="main",file="../../../src/gdb/testsuite/gdb.mi/solib-main.c",fullname="/home/pedro/gdb/mygit/src/gdb/testsuite/gdb.mi/solib-main.c",line="21",times="0",original-location="main"}
  ~"Starting program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.mi/solib-main \n"
  =thread-group-started,id="i1",pid="17724"
  =thread-created,id="1",group-id="i1"
  ^running
  *running,thread-id="all"
  (gdb)
  =library-loaded,id="/lib64/ld-linux-x86-64.so.2",target-name="/lib64/ld-linux-x86-64.so.2",host-name="/lib64/ld-linux-x86-64.so.2",symbols-loaded="0",thread-group="i1"
  ~"Stopped due to shared library event (no libraries added or removed)\n"
  *stopped,reason="solib-event",frame={addr="0x000000379180f990",func="_dl_debug_state",args=[],from="/lib64/ld-linux-x86-64.so.2"},thread-id="1",stopped-threads="all",core="3"
  (gdb)

async:

  >./gdb -nx -q ./testsuite/gdb.mi/solib-main -ex "set stop-on-solib-events 1" -ex "set target-async on" -i=mi
  =thread-group-added,id="i1"
  ~"Reading symbols from /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.mi/solib-main..."
  ~"done.\n"
  (gdb)
  start
  &"start\n"
  ~"Temporary breakpoint 1 at 0x400608: file ../../../src/gdb/testsuite/gdb.mi/solib-main.c, line 21.\n"
  =breakpoint-created,bkpt={number="1",type="breakpoint",disp="del",enabled="y",addr="0x0000000000400608",func="main",file="../../../src/gdb/testsuite/gdb.mi/solib-main.c",fullname="/home/pedro/gdb/mygit/src/gdb/testsuite/gdb.mi/solib-main.c",line="21",times="0",original-location="main"}
  ~"Starting program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.mi/solib-main \n"
  =thread-group-started,id="i1",pid="17729"
  =thread-created,id="1",group-id="i1"
  ^running
  *running,thread-id="all"
  =library-loaded,id="/lib64/ld-linux-x86-64.so.2",target-name="/lib64/ld-linux-x86-64.so.2",host-name="/lib64/ld-linux-x86-64.so.2",symbols-loaded="0",thread-group="i1"
  (gdb)
  *stopped,reason="solib-event",thread-id="1",stopped-threads="all",core="1"

For now, let's focus only on the *stopped event.  We see that the
async output is missing frame info.  And this causes a test failure in
async mode, as "mi_expect_stop solib-event" wants to see the frame
info.

However, if we compare the event output when a real MI execution
command is used, compared to a CLI command (e.g., run vs -exec-run,
next vs -exec-next, etc.), we see:

  >./gdb -nx -q ./testsuite/gdb.mi/solib-main -ex "set stop-on-solib-events 1" -ex "set target-async off" -i=mi
  =thread-group-added,id="i1"
  ~"Reading symbols from /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.mi/solib-main..."
  ~"done.\n"
  (gdb)
  r
  &"r\n"
  ~"Starting program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.mi/solib-main \n"
  =thread-group-started,id="i1",pid="17751"
  =thread-created,id="1",group-id="i1"
  ^running
  *running,thread-id="all"
  (gdb)
  =library-loaded,id="/lib64/ld-linux-x86-64.so.2",target-name="/lib64/ld-linux-x86-64.so.2",host-name="/lib64/ld-linux-x86-64.so.2",symbols-loaded="0",thread-group="i1"
  ~"Stopped due to shared library event (no libraries added or removed)\n"
  *stopped,reason="solib-event",frame={addr="0x000000379180f990",func="_dl_debug_state",args=[],from="/lib64/ld-linux-x86-64.so.2"},thread-id="1",stopped-threads="all",core="3"
  (gdb)
  -exec-run
  =thread-exited,id="1",group-id="i1"
  =thread-group-exited,id="i1"
  =library-unloaded,id="/lib64/ld-linux-x86-64.so.2",target-name="/lib64/ld-linux-x86-64.so.2",host-name="/lib64/ld-linux-x86-64.so.2",thread-group="i1"
  =thread-group-started,id="i1",pid="17754"
  =thread-created,id="1",group-id="i1"
  ^running
  *running,thread-id="all"
  (gdb)
  =library-loaded,id="/lib64/ld-linux-x86-64.so.2",target-name="/lib64/ld-linux-x86-64.so.2",host-name="/lib64/ld-linux-x86-64.so.2",symbols-loaded="0",thread-group="i1"
  *stopped,reason="solib-event",thread-id="1",stopped-threads="all",core="1"
  =thread-selected,id="1"
  (gdb)

As seen above, with MI commands, the *stopped event _doesn't_ have
frame info.  This is because normal_stop, as commanded by the result
of bpstat_print, skips printing frame info in this case (it's an
"event", not a "breakpoint"), and when the interpreter is MI,
mi_on_normal_stop skips calling print_stack_frame, as the normal_stop
call was already done with the MI uiout.  This explains why the async
output is different even with a CLI command.  Its because in async
mode, the mi_on_normal_stop path is always taken; it is always reached
with the MI uiout, because the stop is handled from the event loop,
instead of from within `proceed -> wait_for_inferior -> normal_stop'
with the interpreter overridden, as in sync mode.

This patch fixes the issue by making all cases output the same
*stopped event, by factoring out the print code from normal_stop, and
using it from mi_on_normal_stop as well.  I chose the *stopped output
without a frame, mainly because that is what you already get if you
use MI execution commands, the commands frontends are supposed to use
(except when implementing a console).  This patch makes it simpler to
tweak the MI output differently if desired, as we only have to change
the centralized print_stop_event (taking into account whether the
uiout is MI-like), and all different modes will change accordingly.

Tested on x86_64 Fedora 17, no regressions.  The mi-solib.exp test no
longer fails in async mode with this patch, so the patch removes the
kfail.

2014-03-18  Pedro Alves  <palves@redhat.com>

PR gdb/13860
* inferior.h (print_stop_event): Declare.
* infrun.c (print_stop_event): New, factored out from ...
(normal_stop): ... this.
* mi/mi-interp.c (mi_on_normal_stop): Use print_stop_event instead
of bpstat_print/print_stack_frame.

2014-03-18  Pedro Alves  <palves@redhat.com>

PR gdb/13860
* gdb.mi/mi-solib.exp: Remove gdb/13860 kfail.
* lib/mi-support.exp (mi_expect_stop): Add special handling for
solib-event.

10 years agoEnable verbose error messages by default for AArch64 gas.
Yufeng Zhang [Tue, 18 Mar 2014 17:41:43 +0000 (17:41 +0000)]
Enable verbose error messages by default for AArch64 gas.

gas/

* config/tc-aarch64.c (aarch64_opts): Add new option
"mno-verbose-error".
(verbose_error_p): Initialize to 1.
* doc/c-aarch64.texi (AArch64 Options): Document -mverbose-error
and -mno-verbose-error.

gas/testsuite/

* gas/aarch64/illegal.d: Pass -mno-verbose-error.
* gas/aarch64/verbose-error.s: Add more verbose message testcases.
* gas/aarch64/verbose-error.l: Ditto.

10 years agoConvert function declarations to ISO C format. Remove redundant code.
Nick Clifton [Tue, 18 Mar 2014 14:16:54 +0000 (14:16 +0000)]
Convert function declarations to ISO C format.  Remove redundant code.

* wrapper.c: Convert function declarations to ISO C format.
(sim_open): Delete code for handling t,d and z command line
options.

10 years agodaily update
Alan Modra [Mon, 17 Mar 2014 23:00:50 +0000 (09:30 +1030)]
daily update

10 years agofix latent bugs in ui-out.c
Tom Tromey [Mon, 17 Mar 2014 19:02:13 +0000 (19:02 +0000)]
fix latent bugs in ui-out.c

The destructor code in ui-out.c has a latent bug, which is hidden by
the fact that nothing uses this right now.  This patch fixes the
problem.  The bug is that we don't always clear a pointer in the
ui-out object, leading to a bad free.

2014-03-17  Tom Tromey  <tromey@redhat.com>

* ui-out.c (clear_table, ui_out_new): Clear uiout->table.id.

10 years ago2014-03-17 Christopher Faylor <me.cygwin2014@cgf.cx>
Chris Faylor [Mon, 17 Mar 2014 17:09:15 +0000 (13:09 -0400)]
2014-03-17  Christopher Faylor  <me.cygwin2014@cgf.cx>

* Makefile.am: Use host version of windres.
* Makefile.in: Regenerate.

10 years agoAdd support for parsing VFP register names in .cfi_offset directives.
Nick Clifton [Mon, 17 Mar 2014 16:30:30 +0000 (16:30 +0000)]
Add support for parsing VFP register names in .cfi_offset directives.

PR gas/16694
* config/tc-arm.c (tc_arm_regname_to_dw2regnum): Parse VFP
registers as well.

* gas/cfi/cfi-arm-1.s: Add checks of VFP registers.
* gas/cfi/cfi-arm-1.d: Update expected output.

10 years ago[testsuite/Ada] New testcase for packed array renaming.
Joel Brobecker [Mon, 17 Mar 2014 15:41:48 +0000 (08:41 -0700)]
[testsuite/Ada] New testcase for packed array renaming.

gdb/testsuite/ChangeLog:

        * gdb.ada/pckd_arr_ren: New testcase.

10 years ago[Ada] Crash with references to GNAT packed arrays handling
Pierre-Marie de Rodat [Fri, 14 Mar 2014 13:55:42 +0000 (14:55 +0100)]
[Ada] Crash with references to GNAT packed arrays handling

Consider the following declarations:

  type Packed_Array is array (Natural range <>) of Boolean;
  pragma Pack (Packed_Array);

  function Make (H, L : Natural) return Packed_Array is
  begin
     return (H .. L => False);
  end Make;

  A1 : Packed_Array := Make (1, 2);
  A2 : Packed_Array renames A1;

One possible DWARF translation for A2 is:

  <3><1e4>: Abbrev Number: 21 (DW_TAG_variable)
     <1e5>   DW_AT_name                 : a2
     <1ea>   DW_AT_type                 : <0x1d9>

  <3><1d9>: Abbrev Number: 22 (DW_TAG_const_type)
     <1da>   DW_AT_type                 : <0x1de>
  <3><1de>: Abbrev Number: 23 (DW_TAG_reference_type)
     <1e0>   DW_AT_type                 : <0x1a3>
  <3><1a3>: Abbrev Number: 17 (DW_TAG_array_type)
     <1a4>   DW_AT_name                 : foo__Ta1S___XP1
     <1a8>   DW_AT_GNAT_descriptive_type: <0x16b>

  <3><16b>: Abbrev Number: 6 (DW_TAG_typedef)
     <16c>   DW_AT_name                 : foo__Ta1S
     <172>   DW_AT_type                 : <0x176>
  <3><176>: Abbrev Number: 17 (DW_TAG_array_type)
     <177>   DW_AT_name                 : foo__Ta1S
     <17b>   DW_AT_GNAT_descriptive_type: <0x223>

Here, foo__Ta1S___XP1 is the type used for the code generation while
foo__Ta1S is the source-level type. Both form a valid GNAT encoding for
a packed array type.

Trying to print A2 (1) can make GDB crash. This is because A2 is defined
as a reference to a GNAT encoding for a packed array. When decoding
constrained packed arrays, the ada_coerce_ref subprogram follows
references and returns a fixed type from the target type, peeling
the GNAT encoding for packed arrays. The remaining code assumes that
the resulting type is still such an encoding while we only have
a standard GDB array type, hence the crash:

  arr = ada_coerce_ref (arr);
  [...]
  type = decode_constrained_packed_array_type (value_type (arr));

decode_constrained_packed_array_type assumes that its argument is
such an encoding. From its front comment:

  /* The array type encoded by TYPE, where
     ada_is_constrained_packed_array_type (TYPE).  */

This patch simply replaces the call to ada_coerce_ref with a call
to coerce_ref in order to avoid prematurely transforming
the packed array type as a side-effect. This way, the remaining code
will always work with a GNAT encoding.

gdb/ChangeLog:

* ada-lang.c (decode_constrained_packed_array): Perform a
minimal coercion for reference with coerce_ref instead of
ada_coerce_ref.

10 years agodarwin: handle recent version of dyld
Tristan Gingold [Mon, 17 Mar 2014 13:01:02 +0000 (14:01 +0100)]
darwin: handle recent version of dyld

gdb/
* solib-darwin.c (DYLD_VERSION_MAX): Increase value.
(darwin_solib_create_inferior_hook): Emit a warning if version
is unhandled.

10 years agoreadelf -s test: Skip extra symbols produced by MSP430 assembler.
Nick Clifton [Mon, 17 Mar 2014 11:00:32 +0000 (11:00 +0000)]
readelf -s test: Skip extra symbols produced by MSP430 assembler.

* binutils-all/readelf.ss: Add skip of MSP430 defined symbols.

10 years agood-macho: dump compact unwind info.
Tristan Gingold [Mon, 17 Mar 2014 08:46:36 +0000 (09:46 +0100)]
od-macho: dump compact unwind info.

binutils/
* od-macho.c (dump_section_header): Renames of dump_section.
(dump_segment): Adjust after renaming.
(OPT_COMPACT_UNWIND): Define.
(options): Add compact unwind.
(mach_o_help): Document compact_unwind.
(unwind_x86_64_regs, unwind_x86_regs): New arrays.
(dump_unwind_encoding_x86, dump_unwind_encoding)
(dump_obj_compact_unwind, dump_exe_compact_unwind)
(dump_section_content): New functions.
(mach_o_dump): Handle compact unwind.

include/mach-o/
* unwind.h: New file.

10 years agomach-o: handle lasz load dylib command.
Tristan Gingold [Mon, 17 Mar 2014 08:46:07 +0000 (09:46 +0100)]
mach-o: handle lasz load dylib command.

bfd/
* mach-o.c (bfd_mach_o_read_dylib): Handle lazy load dylib.
(bfd_mach_o_read_command): Ditto.

binutils/
* od-macho.c (dump_load_command): Handle lazy load dylib.

10 years agodaily update
Alan Modra [Sun, 16 Mar 2014 23:00:41 +0000 (09:30 +1030)]
daily update

10 years agoFix Python 2.4 build break
Ulrich Weigand [Sun, 16 Mar 2014 14:01:24 +0000 (15:01 +0100)]
Fix Python 2.4 build break

This fixes a build failure against Python 2.4 by casting away "const"
on the second argument to PyObject_GetAttrString.  Similar casts to
support Python 2.4 were already present in a number of other places.

gdb/
2014-03-16  Ulrich Weigand  <uweigand@de.ibm.com>

* python/py-value.c (get_field_flag): Cast flag_name argument to
PyObject_GetAttrString to support Python 2.4.

10 years agodaily update
Alan Modra [Sat, 15 Mar 2014 23:00:42 +0000 (09:30 +1030)]
daily update

10 years agodaily update
Alan Modra [Fri, 14 Mar 2014 23:00:57 +0000 (09:30 +1030)]
daily update

10 years agoStep down from being global maintainer.
Jan Kratochvil [Fri, 14 Mar 2014 18:54:08 +0000 (19:54 +0100)]
Step down from being global maintainer.

gdb/
2014-03-14  Jan Kratochvil  <jan.kratochvil@redhat.com>

* MAINTAINERS (The Official FSF-appointed GDB Maintainers)
(Global Maintainers): Remove Jan Kratochvil.

10 years agoCheck fwrite return code
Anthony Green [Fri, 14 Mar 2014 16:56:12 +0000 (12:56 -0400)]
Check fwrite return code

10 years agoAdd support for instruction level tracing to the ARM simulator.
Nick Clifton [Fri, 14 Mar 2014 15:21:23 +0000 (15:21 +0000)]
Add support for instruction level tracing to the ARM simulator.

* wrapper.c (op_print): New function.
(sim_dis_read): New function.
(print_insn): New function - disassembles the given instruction.
(sim_trace): Note that tracing is now allowed.
(sim_create_inferior): Default to emulating v6.
Initialise the disassembler machinery.
(sim_target_parse_command_line): Add support for -t -d and -z
options.
(sim_target_display_usage): Note existence of -d and -z options.
(sim_open): Parse -t -d and -z options.
* armemu.h: Add exports of trace, disas and trace_funcs.
Add prototype for print_insn.
* armemu.c (ARMul_Emulate26): Add tracing code.
Delete unused variables.
* thumbemu (handle_v6_thumb_insn): Delete unused variable Rd.
Move Rm variable into switch cases.
Add tracing code.

* armcopro.c (XScale_cp15_init): Add a return value.
(XScale_cp13_init): Likewise.
(XScale_cp14_init): Likewise.
(XScale_cp15_LDC): Delete unused function.
(XScale_cp15_STC): Likewise.
* maverick.c: Delete comment inside comment.
(DSPInit): Delete unused function.
(DSPMCR4): Fix compile time warning about missing parenthesis.
(DSPMCR5): Likewise.
(DSPCDP6): Delete unused variable opcode2.

10 years agoPrevent writes to R15 via LDR or LDM from changing the ARM/Thumb state in pre-v5...
David McQuillan [Fri, 14 Mar 2014 14:03:29 +0000 (14:03 +0000)]
Prevent writes to R15 via LDR or LDM from changing the ARM/Thumb state in pre-v5 architectures.

PR sim/8388
* armemu.c (WriteR15Load): New function.  Determines if the state
can be changed upon a write to R15.
(LoadMult): Use WriteR15Load.
* armemu.h (WRITEDESTB): Use WriteR15Load.

10 years agoCorrect ld-powerpc/vle-reloc-2 test
Alan Modra [Fri, 14 Mar 2014 13:40:14 +0000 (00:10 +1030)]
Correct ld-powerpc/vle-reloc-2 test

* ld-powerpc/vle-reloc-3.d: Remove addresses.

10 years agoFix build time problem with MingGW hosts, which do not have a strnlen() function.
Nick Clifton [Fri, 14 Mar 2014 11:21:00 +0000 (11:21 +0000)]
Fix build time problem with MingGW hosts, which do not have a strnlen() function.

2014-03-13  Meador Inge  <meadori@codesourcery.com>

 * configure.in: Add strnlen to AC_CHECK_DECLS.
 * config.in: Regenerate.
         * configure: Regenerate.
 * sysdep.h (strnlen): Add prototype.

         * dwarf.c (strnlen): Move prototype ...
 * sysdep.h (strnlen): ... to here.

10 years agoFix guit.texi CL entry.
Joel Brobecker [Fri, 14 Mar 2014 07:55:26 +0000 (08:55 +0100)]
Fix guit.texi CL entry.

10 years agoFix overflow handling of VLE_SDA21
Alan Modra [Fri, 14 Mar 2014 04:31:53 +0000 (15:01 +1030)]
Fix overflow handling of VLE_SDA21

bfd/
* elf32-ppc.c (ppc_elf_relocate_section): Correct overflow
handling for VLE_SDA21 relocs.
ld/testsuite/
* ld-powerpc/vle.ld: Place .PPC.EMB.sdata0 within 32k of 0.
* ld-powerpc/vle-reloc-3.d: Update.

10 years agoRemove search path from -l:namespec DT_NEEDED
Alan Modra [Fri, 14 Mar 2014 00:55:59 +0000 (11:25 +1030)]
Remove search path from -l:namespec DT_NEEDED

For libraries without a soname, -l:libfoo.so set DT_NEEDED to the search
dir plus filename, while gold and -lfoo just use the filename.  This
patch fixes the inconsistency.

* ldlang.h (full_name_provided): New input flag.
* ldlang.c (new_afile): Don't use lang_input_file_is_search_file_enum
for -l:namespec.  Instead use lang_input_file_is_l_enum with
full_name_provided flag.
* ldlfile.c (ldfile_open_file_search): Don't complete lib name if
full_name_provided flag is set.
* emultempl/elf32.em (gld${EMULATION_NAME}_open_dynamic_archive):
Handle full_name_provided libraries.  Tidy EXTRA_SHLIB_EXTENSION
support.  Set DT_NEEDED for -l:namespec as namespec.
* emultempl/aix.em (ppc_after_open_output): Handle full_name_provided.
* emultempl/linux.em (gld${EMULATION_NAME}_open_dynamic_archive):
Don't handle full_name_provided libraries.
* emultempl/pe.em (gld${EMULATION_NAME}_open_dynamic_archive): Ditto.
* emultempl/pep.em (gld${EMULATION_NAME}_open_dynamic_archive): Ditto.
* emultempl/vms.em (gld${EMULATION_NAME}_open_dynamic_archive): Ditto.

10 years agoRename native-only terminal related functions.
Pedro Alves [Fri, 14 Mar 2014 00:06:45 +0000 (00:06 +0000)]
Rename native-only terminal related functions.

Looking at target_terminal_inferior etc. in async mode, I realized
that the naming of the terminal_inferior, terminal_ours,
etc. functions doesn't really give a clue that they're meant for the
native target only.  This patch renames them.  There's already
child_terminal_info using the child_ prefix, and, they're most
prominently installed by inf-child.c, so I went with the child_
prefix.  I dropped "inferior" from a couple to make the name match the
corresponding target method.

Tested on x86_64 Fedora 17, and cross built for mingw.  I didn't test
gnu-nat.c, but I think the change is as obvious as it gets.  I grepped
the tree looking for other potential spots that would need adjustment
but this is all I found.  If something breaks, it should be trivial to
fix.

gdb/
2014-03-14  Pedro Alves  <palves@redhat.com>

* inferior.h (terminal_ours_for_output): Rename to ...
(child_terminal_ours_for_output): ... this.
(terminal_save_ours): Rename to ...
(child_terminal_save_ours): ... this.
(terminal_ours): Rename to ...
(child_terminal_ours): ... this.
(terminal_inferior): Rename to ...
(child_terminal_inferior): ... this.
(terminal_init_inferior): Rename to ...
(child_terminal_init_inferior): ... this.
(terminal_init_inferior_with_pgrp): Rename to ...
(child_terminal_init_inferior_with_pgrp): ... this.
* inflow.c (terminal_init_inferior_with_pgrp): Rename to ...
(child_terminal_init_with_pgrp): ... this.
(terminal_save_ours): Rename to ...
(child_terminal_save_ours): ... this.
(terminal_init_inferior): Rename to ...
(child_terminal_init): ... this.  Adjust.
(terminal_inferior): Rename to ...
(child_terminal_inferior): ... this.
(terminal_ours_for_output): Rename to ...
(child_terminal_ours_for_output): ... this.  Adjust.
(terminal_ours): Rename to ...
(child_terminal_ours): ... this.
(terminal_ours_1): Rename to ...
(child_terminal_ours_1): ... this.  Adjust.
* linux-nat.c (linux_nat_terminal_inferior): Adjust.
* windows-nat.c (do_initial_windows_stuff): Adjust.
* gnu-nat.c (gnu_terminal_init_inferior): Rename to ...
(gnu_terminal_init): ... this.  Adjust.
(gnu_target): Adjust.
* inf-child.c (inf_child_target): Adjust.

10 years agodaily update
Alan Modra [Thu, 13 Mar 2014 23:01:24 +0000 (09:31 +1030)]
daily update

10 years agoAArch64: Clean up docs and document -mcpu and -march.
Richard Earnshaw [Thu, 13 Mar 2014 17:10:04 +0000 (17:10 +0000)]
AArch64: Clean up docs and document -mcpu and -march.

2014-03-13  Richard Earnshaw  <rearnsha@arm.com>
    Jiong Wang  <Jiong.Wang@arm.com>

* doc/c-aarch64.texi: Clean up some formatting issues.
(AArch64 Options): Document -mcpu and -march.
(AArch64 Extensions): New node.

10 years agoFix pr 16612.
Doug Evans [Thu, 13 Mar 2014 16:55:12 +0000 (09:55 -0700)]
Fix pr 16612.

* guile/scm-type.c (tyscm_copy_type_recursive): Move type to its
new eq?-hashtab.

testsuite/
* gdb.guile/scm-value.ep (test_value_after_death): Do a garbage
collect after discarding symbols.

10 years agoFix segv when referencing a value added to history after a Guile garbage collect.
Doug Evans [Thu, 13 Mar 2014 16:24:19 +0000 (09:24 -0700)]
Fix segv when referencing a value added to history after a Guile garbage collect.

* value.c (record_latest_value): Call release_value_or_incref
instead of release_value.

testsuite/
* gdb.guile/scm-value.exp (test_value_in_inferior): Verify value added
to history survives a gc.

10 years agoMake the new aarch64 bignum test endian agnostic.
Nick Clifton [Thu, 13 Mar 2014 12:47:05 +0000 (12:47 +0000)]
Make the new aarch64 bignum test endian agnostic.

* gas/aarch64/litpool.s: Make the test endian agnostic.
* gas/aarch64/litpool.d: Update expected disassembly.

10 years agoRename Solaris's target to "target child" like most other ports.
Pedro Alves [Wed, 12 Mar 2014 12:40:40 +0000 (12:40 +0000)]
Rename Solaris's target to "target child" like most other ports.

Note that "target procfs" is used by QNX, but the test must be failing
there, as nto-procfs.c overrides to_open with a method that doesn't
throw the error being tested.  So I'm just removing the test
completely.

gdb/
2014-03-13  Pedro Alves  <palves@redhat.com>

* procfs.c (procfs_target): Don't override to_shortname,
to_longname or to_doc.

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

* gdb.base/default.exp: Don't test "target procfs".

10 years agoDon't mention "Unix" in native target name.
Pedro Alves [Thu, 13 Mar 2014 12:02:24 +0000 (12:02 +0000)]
Don't mention "Unix" in native target name.

I find the mention of "Unix" unnecessary (and really slightly a lie)
on GNU/Linux in a couple of places:

 (gdb) maint print target-stack
 The current target stack is:
  - multi-thread (multi-threaded child process.)
  - child (Unix child process)
  - exec (Local exec file)
  - None (None)

 (gdb) help target child
 Unix child process (started by the "run" command).

 (gdb) target child
 Use the "run" command to start a Unix child process.

It's also odd that e.g., the Windows port says "Unix" in reaction to
"target child" (it was already that way before Windows used
inf-child.c):

 (gdb) target child
 Use the "run" command to start a Unix child process.
 (gdb)

So drop "Unix", going in the direction of saying mostly the same on
all native targets:

  (gdb) maint print target-stack
  The current target stack is:
   - multi-thread (multi-threaded child process.)
 - - child (Unix child process)
 + - child (Child process)
   - exec (Local exec file)
   - None (None)

  (gdb) help target child
 - Unix child process (started by the "run" command).
 + Child process (started by the "run" command).

 (gdb) target child
 -Use the "run" command to start a Unix child process.
 +Use the "run" command to start a child process.

gdb/
2014-03-13  Pedro Alves  <palves@redhat.com>

* inf-child.c (inf_child_open, inf_child_target): Don't mention
Unix in user visible strings.

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

* gdb.base/default.exp: Update "target child" and "target procfs"
tests to not expect "Unix".

10 years agoAdd pe/x86_64 bigobj file format.
Tristan Gingold [Mon, 2 Dec 2013 13:30:32 +0000 (14:30 +0100)]
Add pe/x86_64 bigobj file format.

bfd/
* peicode.h (pe_ILF_object_p): Adjust, as the version number
has been read.
(pe_bfd_object_p): Also read version number to detect ILF.
* pe-x86_64.c (COFF_WITH_PE_BIGOBJ): Define.
(x86_64pe_bigobj_vec): Define
* coffcode.h (bfd_coff_backend_data): Add _bfd_coff_max_nscns field.
(bfd_coff_max_nscns): New macro.
(coff_compute_section_file_positions): Use unsigned int for
target_index.  Compare with bfd_coff_max_nscns.
(bfd_coff_std_swap_table, ticoff0_swap_table, ticoff1_swap_table):
Set a value for _bfd_coff_max_nscns.
(header_bigobj_classid): New constant.
(coff_bigobj_swap_filehdr_in, coff_bigobj_swap_filehdr_out)
(coff_bigobj_swap_sym_in, coff_bigobj_swap_sym_out)
(coff_bigobj_swap_aux_in, coff_bigobj_swap_aux_out): New
functions.
(bigobj_swap_table): New table.
* libcoff.h: Regenerate.
* coff-sh.c (bfd_coff_small_swap_table): Likewise.
* coff-alpha.c (alpha_ecoff_backend_data): Add value for
_bfd_coff_max_nscns.
* coff-mips.c (mips_ecoff_backend_data): Likewise.
* coff-rs6000.c (bfd_xcoff_backend_data)
(bfd_pmac_xcoff_backend_data): Likewise.
* coff64-rs6000.c (bfd_xcoff_backend_data)
(bfd_xcoff_aix5_backend_data): Likewise.
* targets.c (x86_64pe_bigobj_vec): Declare.
* configure.in (x86_64pe_bigobj_vec): New vector.
* configure: Regenerate.
* config.bfd: Add bigobj object format for Windows targets.

gas/
* config/tc-i386.c (use_big_obj): Declare.
(OPTION_MBIG_OBJ): Define.
(md_longopts): Add -mbig-obj option.
(md_parse_option): Handle it.
(md_show_usage): Display help for this option.
(i386_target_format): Use bigobj for x86-64 if -mbig-obj.
* doc/c-i386.texi: Document the option.

gas/testsuite/
* gas/pe/big-obj.d, gas/pe/big-obj.s: Add test.
* gas/pe/pe.exp: Add test.

include/coff/
* pe.h (struct external_ANON_OBJECT_HEADER_BIGOBJ): Declare.
(FILHSZ_BIGOBJ): Define.
(struct external_SYMBOL_EX): Declare.
(SYMENT_BIGOBJ, SYMESZ_BIGOBJ): Define.
(union external_AUX_SYMBOL_EX): Declare.
(AUXENT_BIGOBJ, AUXESZ_BIGOBJ): Define.
* internal.h (struct internal_filehdr): Change type
of f_nscns.

10 years agoDoxygenate gdbtypes.h
Stan Shebs [Thu, 13 Mar 2014 02:36:45 +0000 (19:36 -0700)]
Doxygenate gdbtypes.h

10 years agodaily update
Alan Modra [Wed, 12 Mar 2014 23:01:14 +0000 (09:31 +1030)]
daily update

10 years agoFactor out foreground/background execution command preparation.
Pedro Alves [Wed, 12 Mar 2014 20:32:53 +0000 (20:32 +0000)]
Factor out foreground/background execution command preparation.

All execution commands currently have this pattern:

  /* If we must run in the background, but the target can't do it,
     error out.  */
  if (async_exec && !target_can_async_p ())
    error (_("Asynchronous execution not supported on this target."));

  /* If we are not asked to run in the bg, then prepare to run in the
     foreground, synchronously.  */
  if (!async_exec && target_can_async_p ())
    {
      /* Simulate synchronous execution.  */
      async_disable_stdin ();
    }

This patch factors that into a shared function.

attach_command installs a cleanup to re-enable stdin, but that's not
necessary, as per the comment in prepare_execution_command.  In any
case, if someday it turns out necessary, we have a single place to
install it now.

Tested on x86_64 Fedora 17, sync and async modes.

gdb/
2014-03-12  Pedro Alves  <palves@redhat.com>

* infcmd.c (prepare_execution_command): New function, factored out
from several execution commands.
(run_command_1, continue_command, step_1, jump_command)
(signal_command, until_command, advance_command, finish_command)
(attach_command): Use prepare_execution_command.

10 years agoSupport for HWbreak/watchpoint across fork/vfork on arm-native
Omair Javaid [Wed, 12 Mar 2014 20:23:55 +0000 (01:23 +0500)]
Support for HWbreak/watchpoint across fork/vfork on arm-native

This patch updates arm native support for hwbreak-/watchpoints to enable
support for hwbreak-/watchpoints across fork/vfork. This involves changes to
hwbreak-/watchpoint insertion mechanism to the modern way, by marking debug
registers as needing update, but only really updating them on resume, which is
necessary for supporting watchpoints in non-stop mode. This also updates a
previously maintained per thread hwbreak-/watchpoint cache to a per process
cache which allows target specific code to come in sync with gdb-linux calls to
threads create/destroy and process fork/exit hooks.

10 years agoMake 'make check TESTS="..."' work from GDB's build dir.
Pedro Alves [Wed, 12 Mar 2014 19:40:52 +0000 (19:40 +0000)]
Make 'make check TESTS="..."' work from GDB's build dir.

I noticed 'make check TESTS="..."' works when ran from gdb/testsuite/,
but TESTS is ignored when "make check" is ran from gdb/.

The issue is that TESTS isn't being passed to the testsuite subdir
make invocation.

gdb/
2014-03-12  Pedro Alves  <palves@redhat.com>

* Makefile.in (TARGET_FLAGS_TO_PASS): Add TESTS.

10 years agofix regressions with target-async
Tom Tromey [Fri, 28 Feb 2014 16:47:34 +0000 (09:47 -0700)]
fix regressions with target-async

A patch in the target cleanup series caused a regression when using
record with target-async.  Version 4 of the patch is here:

    https://sourceware.org/ml/gdb-patches/2014-03/msg00159.html

The immediate problem is that record supplies to_can_async_p and
to_is_async_p methods, but does not supply a to_async method.  So,
when target-async is set, record claims to support async -- but if the
underlying target does not support async, then the to_async method
call will end up in that method's default implementation, namely
tcomplain.

This worked previously because the record target used to provide a
to_async method; one that (erroneously, only at push time) checked the
other members of the target stack, and then simply dropped to_async
calls in the "does not implement async" case.

My first thought was to simply drop tcomplain as the default for
to_async.  This works, but Pedro pointed out that the only reason
record has to supply to_can_async_p and to_is_async_p is that these
default to using the find_default_run_target machinery -- and these
defaults are only needed by "run" and "attach".

So, a nicer solution presents itself: change run and attach to
explicitly call into the default run target when needed; and change
to_is_async_p and to_can_async_p to default to "return 0".  This makes
the target stack simpler to use and lets us remove the method
implementations from record.  This is also in harmony with other plans
for the target stack; namely trying to reduce the impact of
find_default_run_target.  This approach makes it clear that
find_default_is_async_p is not needed -- it is asking whether a target
that may not even be pushed is actually async, which seems like a
nonsensical question.

While an improvement, this approach proved to introduce the same bug
when using the core target.  Looking a bit deeper, the issue is that
code in "attach" and "run" may need to use either the current target
stack or the default run target -- but different calls into the target
API in those functions could wind up querying different targets.

This new patch makes the target to use more explicit in "run" and
"attach".  Then these commands explicitly make the needed calls
against that target.  This ensures that a single target is used for
all relevant operations.  This lets us remove a couple find_default_*
functions from various targets, including the dummy target.  I think
this is a decent understandability improvement.

One issue I see with this patch is that the new calls in "run" and
"attach" are not very much like the rest of the target API.  I think
fundamentally this is due to bad factoring in the target API, which
may need to be fixed for multi-target.  Tackling that seemed ambitious
for a regression fix.

While working on this I noticed that there don't seem to be any test
cases that involve both target-async and record, so this patch changes
break-precsave.exp to add some.  It also changes corefile.exp to add
some target-async tests; these pass with current trunk and with this
patch applied, but fail with the v1 patch.

This patch differs from v4 in that it moves initialization of
to_can_async_p and to_supports_non_stop into inf-child, adds some
assertions to complete_target_initialization, and adds some comments
to target.h.

Built and regtested on x86-64 Fedora 20.

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

* inf-child.c (return_zero): New function.
(inf_child_target): Set to_can_async_p, to_supports_non_stop.
* aix-thread.c (aix_thread_inferior_created): New function.
(aix_thread_attach): Remove.
(init_aix_thread_ops): Don't set to_attach.
(_initialize_aix_thread): Register inferior_created observer.
* corelow.c (init_core_ops): Don't set to_attach or
to_create_inferior.
* exec.c (init_exec_ops): Don't set to_attach or
to_create_inferior.
* infcmd.c (run_command_1): Use find_run_target.  Make direct
target calls.
(attach_command): Use find_attach_target.  Make direct target
calls.
* record-btrace.c (init_record_btrace_ops): Don't set
to_create_inferior.
* record-full.c (record_full_can_async_p, record_full_is_async_p):
Remove.
(init_record_full_ops, init_record_full_core_ops): Update.  Don't
set to_create_inferior.
* target.c (complete_target_initialization): Add assertion.
(target_create_inferior): Remove.
(find_default_attach, find_default_create_inferior): Remove.
(find_attach_target, find_run_target): New functions.
(find_default_is_async_p, find_default_can_async_p)
(target_supports_non_stop, target_attach): Remove.
(init_dummy_target): Don't set to_create_inferior or
to_supports_non_stop.
* target.h (struct target_ops) <to_attach>: Add comment.  Remove
TARGET_DEFAULT_FUNC.
<to_create_inferior>: Add comment.
<to_can_async_p, to_is_async_p, to_supports_non_stop>: Use
TARGET_DEFAULT_RETURN.
<to_can_async_p, to_supports_non_stop, to_can_run>: Add comments.
(find_attach_target, find_run_target): Declare.
(target_create_inferior): Remove.
(target_has_execution_1): Update comment.
(target_supports_non_stop): Remove.
* target-delegates.c: Rebuild.

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

* gdb.base/corefile.exp (corefile_test_run, corefile_test_attach):
New procs.  Add target-async tests.
* gdb.reverse/break-precsave.exp (precsave_tests): New proc.
Add target-async tests.

10 years agoThe value of a bignum expression is held in a single global array. This means
Nick Clifton [Wed, 12 Mar 2014 15:44:09 +0000 (15:44 +0000)]
The value of a bignum expression is held in a single global array.  This means
that if multiple bignum values are encountered only the most recent is valid.
If such expressions are cached, eg to be emitted into a literal pool later on
in the assembly, then only one expression - the last - will be correct.  This
patch fixes the problem for the AArch64 target by caching each bignum value
locally.

PR gas/16688
* config/tc-aarch64.c (literal_expression): New structure.
(literal_pool): Replace exp array with literal_expression array.
(add_to_lit_pool): When adding a bignum cache the big value.
(s_ltorg): When emitting a bignum initialise the global bignum
array from the cached value.

* gas/aarch64/litpool.s: New test case.
* gas/aarch64/litpool.d: Expected disassembly.

10 years agoFix dw2-ifort-parameter.exp on PPC64
Andreas Arnez [Fri, 7 Mar 2014 12:23:47 +0000 (12:23 +0000)]
Fix dw2-ifort-parameter.exp on PPC64

On PPC64, 'func' and 'main' are function descriptors and don't point
to the actual code.  Thus the usage of these symbols in the DWARF
assembler source was broken.  The patch introduces new labels
func_start and func_end for this purpose.

10 years agoMigrate dw2-ifort-parameter.exp to Dwarf::assemble
Andreas Arnez [Fri, 7 Mar 2014 11:52:54 +0000 (11:52 +0000)]
Migrate dw2-ifort-parameter.exp to Dwarf::assemble

A "side effect" of the migration to Dwarf::assemble is that the DWARF
address size is now automatically adjusted to the target architecture.
The original assembler source hard-coded the DWARF address size to 4,
even on 64-bit architectures.  This address size mismatch caused a
test case failure on s390x due to a wrong result from DW_OP_deref.

10 years agoExploit 'prepare_for_testing' etc. for 'Dwarf::assemble'-generated files
Andreas Arnez [Fri, 7 Mar 2014 11:45:49 +0000 (11:45 +0000)]
Exploit 'prepare_for_testing' etc. for 'Dwarf::assemble'-generated files

Now that prepare_for_testing etc. can cope with absolute path names,
this can be exploited for test cases with generated source files.
This is just to simplify the code and shouldn't cause any functional
change.

10 years agogdb.exp: Support absolute path name args in 'prepare_for_testing' etc.
Andreas Arnez [Fri, 7 Mar 2014 10:23:42 +0000 (10:23 +0000)]
gdb.exp: Support absolute path name args in 'prepare_for_testing' etc.

Test cases that produce source files in the build directory have not
been able to use prepare_for_testing and friends.  This was because
build_executable_from_specs unconditionally prepended the source
directory path name to its arguments.

10 years agoPrevent the linker from generaing a seg-fault when the user attempts to link
Nick Clifton [Wed, 12 Mar 2014 13:12:37 +0000 (13:12 +0000)]
Prevent the linker from generaing a seg-fault when the user attempts to link
an ARM ELF binary into an AARCH64 ELF executable.

PR ld/16671
* elf32-arm.c (elf32_arm_add_symbol_hook): Check for ARM format
before testing for vxworks.

10 years agoUpdate the documentation for the AR command so that it shows the --plugin
Nick Clifton [Wed, 12 Mar 2014 12:00:27 +0000 (12:00 +0000)]
Update the documentation for the AR command so that it shows the --plugin
option coming *after* the command option not before it.

PR binutils/16652
* doc/binutils.texi (ar cmdline): Move --plugin command line
option to after the command option.

10 years agoinf-child.h: Update comment.
Pedro Alves [Wed, 12 Mar 2014 11:55:02 +0000 (11:55 +0000)]
inf-child.h: Update comment.

Like inf-child.c, this file is no longer used exclusively by Unix
targets anymore.

gdb/
2014-03-12  Pedro Alves  <palves@redhat.com>

        * inf-child.h: Update comment to not mention Unix.

10 years agoinf-child.c: Update comments.
Pedro Alves [Wed, 12 Mar 2014 11:33:59 +0000 (11:33 +0000)]
inf-child.c: Update comments.

This file is no longer used exclusively by Unix targets anymore.

gdb/
2014-03-12  Pedro Alves  <palves@redhat.com>

* inf-child.c: Update top comment to not mention Unix.  Add
generic comment describing how this target is meant to be used.
(inf_child_post_attach, inf_child_post_startup_inferior)
(inf_child_follow_fork, inf_child_pid_to_exec_file): Don't mention
Unix in comment.

10 years agoMake the nto-procfs.c target inherit inf-child.c.
Pedro Alves [Wed, 12 Mar 2014 11:21:36 +0000 (11:21 +0000)]
Make the nto-procfs.c target inherit inf-child.c.

So that all native targets inherit a single "superclass".

Target methods that are set to or do the same as inf-child.c's are
removed.

Not tested.

gdb/
2014-03-12  Pedro Alves  <palves@redhat.com>

* nto-procfs.c: Include inf-child.h.
(procfs_ops): Delete global.
(procfs_can_run): Delete method.
(procfs_detach, procfs_mourn_inferior): Unpush the passed in
target pointer instead of referencing procfs_ops.
(procfs_prepare_to_store): Delete.
(init_procfs_ops): Delete function.
(procfs_target): New function, based on init_procfs_ops, but
inherit inf_child_target.
(_initialize_procfs): Use procfs_target.

10 years agoMake the windows-nat.c target inherit inf-child.c.
Pedro Alves [Wed, 12 Mar 2014 11:21:36 +0000 (11:21 +0000)]
Make the windows-nat.c target inherit inf-child.c.

So that all native targets inherit a single "superclass".

Target methods that are set to or do the same as inf-child.c's are
removed.

Tested by cross building on Fedora 17, and then confirming that

./gdb.exe ./gdb.exe -ex "set pagination off" -ex "start"

under Wine still works.

Also, Joel tested this with Adacore's internal testsuite.

gdb/
2014-03-12  Pedro Alves  <palves@redhat.com>

* windows-nat.c: Include inf-child.h.
(windows_ops): Delete global.
(windows_open, windows_prepare_to_store, windows_can_run): Delete
methods.
(init_windows_ops): Delete function.
(windows_target): New function, based on init_windows_ops, but
inherit inf_child_target.
(_initialize_windows_nat): Use windows_target.  Install x86
specific target methods here.

10 years agoMention PR gdb/16696 in corresponding ChangeLog entry.
Pedro Alves [Wed, 12 Mar 2014 11:07:37 +0000 (11:07 +0000)]
Mention PR gdb/16696 in corresponding ChangeLog entry.

10 years agoAdd myself as the maintainer for the MSP430 sim.
Nick Clifton [Wed, 12 Mar 2014 11:02:57 +0000 (11:02 +0000)]
Add myself as the maintainer for the MSP430 sim.

10 years agoFix compile time warnings about unused variables 'yyinput' and 'input'.
Dmitry Gorbachev [Wed, 12 Mar 2014 10:56:17 +0000 (10:56 +0000)]
Fix compile time warnings about unused variables 'yyinput' and 'input'.

PR binutils/16567
* deflex.l: Add noinput and nounput options.

10 years agoautoreconf
Alan Modra [Wed, 12 Mar 2014 04:32:00 +0000 (15:02 +1030)]
autoreconf

Regenerate Makefile.in in bfd, binutils, gas, gold, gprof, ld, opcodes.
Regenerate gas/config.in.

10 years agoobjcopy/strip ELF program header p_vaddr confusion
Alan Modra [Wed, 12 Mar 2014 00:03:26 +0000 (10:33 +1030)]
objcopy/strip ELF program header p_vaddr confusion

copy_elf_program_header has logic to reject non-alloc sections when
calculating p_vaddr offset for padding, but blithely assumed the
first section in a segment was allocated.

PR 16690
* elf.c (copy_elf_program_header): Ignore first section lma if
non-alloc.

10 years agodaily update
Alan Modra [Tue, 11 Mar 2014 23:01:13 +0000 (09:31 +1030)]
daily update

10 years agointptr_t type definition needed
Alan Modra [Tue, 11 Mar 2014 05:12:46 +0000 (15:42 +1030)]
intptr_t type definition needed

coffcode.h uses an intptr_t cast inside an #ifdef RS6000COFF_C, so
ensure that intptr_t is defined.  We don't see this when
cross-compiling from linux due to intptr_t being provided by
unistd.h.

PR 16686
* coff-rs6000.c: Include stdint.h.
* coff64-rs6000.c: Likewise.

10 years ago * guile/guile.c (call_initialize_gdb_module): New function.
Doug Evans [Tue, 11 Mar 2014 04:02:19 +0000 (00:02 -0400)]
* guile/guile.c (call_initialize_gdb_module): New function.
(initialize_guile): Replace call to scm_init_guile with call to
scm_with_guile.

10 years agosim: msp430: start a test framework
Mike Frysinger [Sat, 8 Mar 2014 05:21:13 +0000 (00:21 -0500)]
sim: msp430: start a test framework

The current sim lacks any sort of tests.  Start a basic framework and
add a simple one to test the add insn.

10 years agosim: msp430: set initial PC to ELF entry if available
Mike Frysinger [Sat, 8 Mar 2014 05:20:11 +0000 (00:20 -0500)]
sim: msp430: set initial PC to ELF entry if available

If we want to run a simple ELF, the reset vector isn't set up, so starting
at address 0 doesn't make sense.  Use the ELF's entry point instead.

10 years agosim: msp430: fix build time warnings
Mike Frysinger [Fri, 7 Mar 2014 04:29:37 +0000 (23:29 -0500)]
sim: msp430: fix build time warnings

This fix is simple:

msp430-sim.c: In function 'maybe_perform_syscall':
msp430-sim.c:898:10: warning: format '%d' expects argument of type 'int',
                     but argument 5 has type 'long int' [-Wformat]

This one we change to use casts like everyone else does in the code base:

msp430-sim.c: In function 'msp430_step_once':
msp430-sim.c:985:7: warning: passing argument 3 of 'init_disassemble_info'
                    from incompatible pointer type [enabled by default]
include/dis-asm.h:368:13: note: expected 'fprintf_ftype' but argument is
of type 'int (*)(struct FILE * __restrict__,  const char * __restrict__)'

10 years agosim: constify arg to sim_do_command
Mike Frysinger [Thu, 20 Feb 2014 05:28:17 +0000 (00:28 -0500)]
sim: constify arg to sim_do_command

It is rare for people to want to modify the cmd arg.  In general, they
really shouldn't be, but a few still do.  For those who misbehave, dupe
the string locally so they can bang on it.

10 years agodaily update
Alan Modra [Mon, 10 Mar 2014 23:00:40 +0000 (09:30 +1030)]
daily update

10 years agoAdd function to set non-visibility part of st_other.
Cary Coutant [Mon, 10 Mar 2014 20:38:20 +0000 (13:38 -0700)]
Add function to set non-visibility part of st_other.

2014-03-10  Sasa Stankovic  <Sasa.Stankovic@imgtec.com>

gold/
* symtab.h (Symbol::set_nonvis): New function.

10 years agoAdd explicit instantiations for Sized_symbol::init_output_data.
Cary Coutant [Mon, 10 Mar 2014 20:36:40 +0000 (13:36 -0700)]
Add explicit instantiations for Sized_symbol::init_output_data.

2014-03-10  Sasa Stankovic  <Sasa.Stankovic@imgtec.com>

gold/
* symtab.cc (Sized_symbol<32>::init_output_data):
Instantiate the template.
(Sized_symbol<64>::init_output_data): Likewise.

10 years agoAllow target to adjust dynamic symbol value.
Cary Coutant [Mon, 10 Mar 2014 20:35:53 +0000 (13:35 -0700)]
Allow target to adjust dynamic symbol value.

2014-03-10  Sasa Stankovic  <Sasa.Stankovic@imgtec.com>

gold/
* symtab.cc (Symbol_table::sized_write_globals): Allow a target to
adjust dynamic symbol value.
* target.h (Target::adjust_dyn_symbol): New function.
(Target::do_adjust_dyn_symbol): New function.

10 years agoAllow target to add custom dynamic table entries.
Cary Coutant [Mon, 10 Mar 2014 20:34:53 +0000 (13:34 -0700)]
Allow target to add custom dynamic table entries.

2014-03-10  Sasa Stankovic  <Sasa.Stankovic@imgtec.com>

gold/
* output.cc (Output_data_dynamic::Dynamic_entry::write):
Get the value of DYNAMIC_CUSTOM dynamic entry.
* output.h (Output_data_dynamic::add_custom): New function.
(Dynamic_entry::Dynamic_entry): New constructor for DYNAMIC_CUSTOM
dynamic entry.
(enum Dynamic_entry::Classification): Add DYNAMIC_CUSTOM.
* target.h (Target::dynamic_tag_custom_value): New function.
(Target::do_dynamic_tag_custom_value): New function.

10 years agoAllow target to set dynsym indexes.
Cary Coutant [Mon, 10 Mar 2014 20:33:20 +0000 (13:33 -0700)]
Allow target to set dynsym indexes.

2014-03-10  Sasa Stankovic  <Sasa.Stankovic@imgtec.com>

gold/
* symtab.cc (Symbol_table::set_dynsym_indexes): Allow a target to set
dynsym indexes.
* target.h (Target::has_custom_set_dynsym_indexes): New function.
(Target::do_has_custom_set_dynsym_indexes): New function.
(Target::set_dynsym_indexes): New function.
(Target::do_set_dynsym_indexes): New function.

10 years agoRemove bfd/ticoff.h (unused)
Tristan Gingold [Mon, 10 Mar 2014 14:10:27 +0000 (15:10 +0100)]
Remove bfd/ticoff.h (unused)

2013-12-03  Tristan Gingold  <gingold@adacore.com>

* ticoff.h: Remove.

10 years agoMissing space before '(' in ada-lang.c::ada_evaluate_subexp
Joel Brobecker [Mon, 10 Mar 2014 13:45:26 +0000 (14:45 +0100)]
Missing space before '(' in ada-lang.c::ada_evaluate_subexp

gdb/ChangeLog:

        * ada-lang.c (ada_evaluate_subexp): Add missing space before '('
        in call to TYPE_CODE macro.

10 years agoMinor style change in the previous commits' ChangeLog entry.
Joel Brobecker [Mon, 10 Mar 2014 13:44:30 +0000 (14:44 +0100)]
Minor style change in the previous commits' ChangeLog entry.

10 years ago[Ada] Full view of tagged type with ptype
Jerome Guitton [Wed, 12 Feb 2014 11:08:23 +0000 (12:08 +0100)]
[Ada] Full view of tagged type with ptype

When evaluating an expression, if it is of a tagged type, GDB reads
the tag in memory and deduces the full view. At parsing time, however,
this operation is done only in the case of OP_VAR_VALUE. ptype does
not go through a full evaluation of expressions so it may return some
odd results:

 (gdb) print c.menu_name
 $1 = 0x0
 (gdb) ptype $
 type = system.strings.string_access
 (gdb) ptype c.menu_name
 type = <void>

This change removes this peculiarity by extending the tag resolution
to UNOP_IND and STRUCTOP_STRUCT. As in the case of OP_VAR_VALUE, this
implies switching from EVAL_AVOID_SIDE_EFFECTS to EVAL_NORMAL when a
tagged type is dereferenced.

gdb/
* ada-lang.c (ada_evaluate_subexp): Resolve tagged types to
full view in the case of UNOP_IND and STRUCTOP_STRUCT.

gdb/testsuite/

* gdb.ada/tagged_access: New testcase.

10 years agoRemove "hardware" from comments of "target_insert_breakpoint"
Hui Zhu [Mon, 10 Mar 2014 07:42:26 +0000 (15:42 +0800)]
Remove "hardware" from comments of "target_insert_breakpoint"

This function is for simple breakpoint.  So I post a patch to remove "hardware".

Thanks,
Hui

2014-03-10  Hui Zhu  <hui@codesourcery.com>

* target.h (target_insert_breakpoint): Remove "hardware" from its
comments.

10 years agodaily update
Alan Modra [Sun, 9 Mar 2014 23:00:41 +0000 (09:30 +1030)]
daily update

10 years agodaily update
Alan Modra [Sat, 8 Mar 2014 23:01:12 +0000 (09:31 +1030)]
daily update

10 years agoBetter overflow checking for powerpc32 relocations
Alan Modra [Sat, 8 Mar 2014 02:35:06 +0000 (13:05 +1030)]
Better overflow checking for powerpc32 relocations

Similar to the powerpc64 patch, this improves overflow checking in
elf32-ppc.c.  Many reloc "howto" entries needed fixes, some just
cosmetic.

The patch also fixes the R_PPC_VLE_SDA21 reloc application code, which
was horribly broken.  In fact, it may still be broken since Power ISA
2.07 says e_li behaves as
   RT <- EXTS(li20 1:4 || li20 5:8 || li20 0 || li20 9:19)
where li20 is a field taken from bits 17..20, 11..15, 21..31 of the
instruction.  Freescale VLEPEM says differently, and I assume
correctly, that
   RT <- EXTS(li20 0:3 || li20 4:8 || li20 9:19)
The VLE_SDA21 relocation description matches this too.

Now the VLE_SDA21 relocation specifies in the case where e_addi16 is
converted to e_li for symbols in .PPC.EMB.sdata0 or .PPC.EMB.sbss0
(no base register), that the field is restricted to 16 bits, with the
sign bit being propagated to the top 4 bits.  I don't see the sense in
restricting the value like this, so have allowed the full 20 bit
signed value.  This of course is compatible with the reloc description
in that values in the 16 bit signed range will result in exactly the
same insn field as when the reloc description is followed to the
letter.

* elf32-ppc.c (ppc_elf_howto_raw): Correct overflow check for
many relocations.  Correct bitsize and rightshift too for a number
of VLE relocs.  Describe R_PPC_VLE_SDA21 and R_PPC_VLE_SDA21_LO.
Correct dst_mask on R_PPC_VLE_SDA21_LO.
(ppc_elf_vle_split16): Tidy, delete unnecessary prototype.
(ppc_elf_relocate_section): Modify overflow test for 16-bit
fields in instructions to signed/unsigned according to whether
the field takes a signed or unsigned value.  Tidy vle split16 code.
Correct R_PPC_VLE_SDA21 and R_PPC_VLE_SDA21_LO handling.

10 years agoBetter overflow checking for powerpc64 relocations
Alan Modra [Thu, 6 Mar 2014 23:44:30 +0000 (10:14 +1030)]
Better overflow checking for powerpc64 relocations

R_PPC64_ADDR16 is used in three contexts:
- .short data relocation
- 16-bit signed insn fields, eg. addi
- 16-bit unsigned insn fields, eg. ori
In the first case we want to allow both signed and unsigned 16-bit
values, the latter two ought to error if the field exceeds the range
of values allowed for 16-bit signed and unsigned integers
respectively.  These conflicting requirements meant that ld had to
choose the least restrictive overflow checks, and thus it is possible
to construct testcases where an addi field overflows but is not
reported by ld.  Many relocations dealing with 16-bit insn fields have
this problem.  What's more, some relocations that are only ever used
for signed fields of instructions woodenly copied the lax overflow
checking of R_PPC64_ADDR16.

bfd/
* elf64-ppc.c (ppc64_elf_howto_raw): Use complain_overflow_signed
for R_PPC64_ADDR14, R_PPC64_ADDR14_BRTAKEN, R_PPC64_ADDR14_BRNTAKEN,
R_PPC64_SECTOFF, R_PPC64_ADDR16_DS, R_PPC64_SECTOFF_DS,
R_PPC64_REL16 entries.  Use complain_overflow_dont for R_PPC64_TOC.
(ppc64_elf_relocate_section): Modify overflow test for 16-bit
fields in instructions to signed/unsigned according to whether
the field takes a signed or unsigned value.
gold/
* powerpc.cc (Powerpc_relocate_functions::Overflow_check): Add
CHECK_UNSIGNED, CHECK_LOW_INSN, CHECK_HIGH_INSN.
(Powerpc_relocate_functions::has_overflow_unsigned): New function.
(Powerpc_relocate_functions::has_overflow_bitfield,
overflowed): Use the above.
(Target_powerpc::Relocate::relocate): Correct overflow checking
for a number of relocations.  Modify overflow test for 16-bit
fields in instructions to signed/unsigned according to whether
the field takes a signed or unsigned value.

10 years ago* dwarf2read.c (read_str_index): Rename local dwo_name to objf_name.
Doug Evans [Sat, 8 Mar 2014 01:33:12 +0000 (17:33 -0800)]
* dwarf2read.c (read_str_index): Rename local dwo_name to objf_name.

10 years agoread_cutu_die_from_dwo: Misc minor cleanups.
Doug Evans [Sat, 8 Mar 2014 00:38:26 +0000 (16:38 -0800)]
read_cutu_die_from_dwo: Misc minor cleanups.

* dwarf2read.c (read_cutu_die_from_dwo): Fix function comment.
Remove unused local comp_dir_attr.  Assert exactly one of
stub_comp_unit_die, stub_comp_dir is non-NULL.

10 years agotarget.h: Expands complete_target_initialization and add_target comments.
Joel Brobecker [Fri, 7 Mar 2014 17:00:27 +0000 (09:00 -0800)]
target.h: Expands complete_target_initialization and add_target comments.

Expand a bit the comments to answer some questions I had when looking
at why a target of mine would not have some default methods set.

gdb/ChangeLog:

        * target.h (complete_target_initialization, add_target):
        Add comment.

10 years agodaily update
Alan Modra [Fri, 7 Mar 2014 23:00:39 +0000 (09:30 +1030)]
daily update

10 years agoMake the go32-nat.c target inherit inf-child.c.
Pedro Alves [Fri, 7 Mar 2014 15:36:50 +0000 (15:36 +0000)]
Make the go32-nat.c target inherit inf-child.c.

So that all native targets inherit a single "superclass".

Target methods that are set to or do the same as inf-child.c's are
removed.

Tested by cross building on Fedora 17.

gdb/
2014-03-07  Pedro Alves  <palves@redhat.com>

* go32-nat.c: Include inf-child.h.
(go32_ops): Delete global.
(go32_close, go32_detach, go32_prepare_to_store, go32_can_run):
Delete methods.
(go32_create_inferior): Push the passed in target pointer instead
of referencing go32_ops.
(init_go32_ops): Delete function.  Moved parts to _initialize_go32_nat.
(go32_target): New function, based on init_go32_ops, but inherit
inf_child_target.
(_initialize_go32_nat): Use go32_target.  Move parts of
init_go32_ops here.

10 years agoAIX 32-bit core loading, high section addresses.
Pedro Alves [Fri, 7 Mar 2014 12:11:40 +0000 (12:11 +0000)]
AIX 32-bit core loading, high section addresses.

I noticed GDB was failing to enable threading support for 32-bit AIX
cores.  I traced it to failure to read variables from libpthreads.a.
The issue is that data for that library is loaded at a high address,
and bfd is sign extending the section addresses:

 (gdb) info files
 Symbols from "/home/palves/crash".
 Local core dump file:
 `/home/palves/core', file type aixcoff-rs6000.
 0x2ff22000 - 0x2ff23000 is .stack
 0x20000000 - 0x200316e0 is .data
 0x20000e90 - 0x200016c0 is .data
 0xfffffffff0254000 - 0xfffffffff0297920 is .data
 0xfffffffff07b46a8 - 0xfffffffff07b47c8 is .data
 0xfffffffff0298000 - 0xfffffffff029bfcc is .data
 0xfffffffff06dafe0 - 0xfffffffff07b3838 is .data
 Local exec file:
 `/home/palves/crash', file type aixcoff-rs6000.
 Entry point: 0x20001394
 0x10000150 - 0x10000e90 is .text
 0x20000e90 - 0x2000149c is .data
 0x2000149c - 0x200016c0 is .bss
 0xd053b124 - 0xd053e15f is .text in /usr/lib/libpthreads.a(shr_comm.o)
 0xf0254000 - 0xf0297920 is .data in /usr/lib/libpthreads.a(shr_comm.o)
 0xf0254450 - 0xf0297920 is .bss in /usr/lib/libpthreads.a(shr_comm.o)
 0xd053a280 - 0xd053aabe is .text in /usr/lib/libcrypt.a(shr.o)
 0xf07b46a8 - 0xf07b47c8 is .data in /usr/lib/libcrypt.a(shr.o)
 0xf07b47c8 - 0xf07b47c8 is .bss in /usr/lib/libcrypt.a(shr.o)
 0xd04fb180 - 0xd053917e is .text in /usr/lib/libpthreads.a(shr_xpg5.o)
 0xf0298000 - 0xf029bfcc is .data in /usr/lib/libpthreads.a(shr_xpg5.o)
 0xf029bf64 - 0xf029bfcc is .bss in /usr/lib/libpthreads.a(shr_xpg5.o)
 0xd0100900 - 0xd04fa39c is .text in /usr/lib/libc.a(shr.o)
 0xf06dafe0 - 0xf07b3838 is .data in /usr/lib/libc.a(shr.o)
 0xf0751e94 - 0xf07b3838 is .bss in /usr/lib/libc.a(shr.o)

Notice:
...
0xfffffffff0298000 - 0xfffffffff029bfcc is .data
...

Those are the bfd section start/end addresses.  It't not visible here:

         ...
 0xf0298000 - 0xf029bfcc is .data in /usr/lib/libpthreads.a(shr_xpg5.o)
         ...

... just because GDB trims that number to 32-bit when printing.

GDB then fails to find the memory for libpthreads.a variables in the
core, and falls back to reading it directly from the executable (which
yields the values as originally initialized in the code).

E.g.:

 (gdb) p &__n_pthreads
 $2 = (<data variable, no debug info> *) 0xf074fda8 <__n_pthreads>
 (gdb) p __n_pthreads
 $1 = -1

That should have returned 2 instead of -1.

bfd/
2014-03-07  Pedro Alves  <palves@redhat.com>

* rs6000-core.c (rs6000coff_core_p): Cast pointers to bfd_vma
through ptr_to_uint instead of through long.

10 years agobtrace, test: fix gdb.btrace/data test
Markus Metzger [Wed, 5 Mar 2014 10:17:35 +0000 (11:17 +0100)]
btrace, test: fix gdb.btrace/data test

The format of the output changed.  Fix the test.

testsuite/
* gdb.btrace/data.exp: Update expected output.

10 years agodaily update
Alan Modra [Thu, 6 Mar 2014 23:00:46 +0000 (09:30 +1030)]
daily update

10 years agoApply ld-arm/gc-hidden-1 to all ELF targets, not just *eabi* targets
Roland McGrath [Thu, 6 Mar 2014 17:46:15 +0000 (09:46 -0800)]
Apply ld-arm/gc-hidden-1 to all ELF targets, not just *eabi* targets

ld/testsuite/
* ld-arm/gc-hidden-1.d: Remove target, add not-target to match
other ELF-only tests in this directory.  Loosen regexps so they
don't care what the exact addresses are.

10 years agoDisable --long-plt test for arm-nacl targets.
Roland McGrath [Thu, 6 Mar 2014 17:44:25 +0000 (09:44 -0800)]
Disable --long-plt test for arm-nacl targets.

ld/testsuite/
* ld-arm/arm-elf.exp (armelftests_common): Move long-plt case ...
(armelftests_nonacl): ... here.

10 years agoFix sol-thread.c build failure.
Joel Brobecker [Thu, 6 Mar 2014 15:57:29 +0000 (10:57 -0500)]
Fix sol-thread.c build failure.

Some updates where needed after the minimal symbol handling got changed
a little. This patch makes those changes.

gdb/ChangeLog:

        * sol-thread.c: #include "symtab.h", "minsym.h" and "objfiles.h".
        (ps_pglobal_lookup): Use BMSYMBOL_VALUE_ADDRESS instead of
        SYMBOL_VALUE_ADDRESS.
        (info_cb): MSYMBOL_PRINT_NAME instead of SYMBOL_PRINT_NAME.

10 years ago * gas/tc-avr.c: Add new devices
Denis Chertykov [Thu, 6 Mar 2014 14:59:05 +0000 (18:59 +0400)]
* gas/tc-avr.c: Add new devices
avr25: ata5272, attiny828
avr35: ata5505, attiny1634
avr4: atmega8a, ata6285, ata6286, atmega48pa
avr5: at90pwm161, ata5790, ata5795, atmega164pa, atmega165pa,
atmega168pa, atmega32a, atmega64rfr2, atmega644rfr2, atmega64a,
atmega16hva2
avr51: atmega128a, atmega1284
avrxmega2: atxmega16a4u, atxmega16c4, atxmega32a4u, atxmega32c4,
atxmega32e5, atxmega16e5, atxmega8e5
avrxmega4: atxmega64a3u, atxmega64a4u, atxmega64b1, atxmega64b3,
atxmega64c3, atxmega64d4
avrxmega6: atxmega128a3u, atxmega128b3, atxmega128c3,
atxmega128d4, atxmega192a3u, atxmega192c3, atxmega256a3u,
atxmega256c3, atxmega384c3, atxmega384d3
avrxmega7: atxmega128a4u
* doc/c-avr.texi: Ditto.

10 years agoPatch for PR binutils/16664 which triggers a seg-fault when attempting to
Nick Clifton [Thu, 6 Mar 2014 10:57:13 +0000 (10:57 +0000)]
Patch for PR binutils/16664 which triggers a seg-fault when attempting to
display the contents of a corrupt attribute section.

* readelf.c (process_attributes): Add checks for corrupt
attribute section names.

* elf-attrs.c (_bfd_elf_parse_attributes): Add checks for corrupt
attribute section names.

10 years agoRemove argument optional_p from get_tracepoint_by_number
Yao Qi [Sat, 22 Feb 2014 05:53:37 +0000 (13:53 +0800)]
Remove argument optional_p from get_tracepoint_by_number

This patch is to remove parameter optional_p as it is always true,
in order to simplify get_tracepoint_by_number.

'optional_p' was added by this change,

1999-11-18  Tom Tromey  <tromey@cygnus.com>

* tracepoint.h (get_tracepoint_by_number): Updated
declaration.
* tracepoint.c (trace_pass_command): Better error message.
Fixed logic when `all' not specified.
(get_tracepoint_by_number): Added `optional_p' argument.  Fixed
all callers.

but after this patch,

 FYI: remove `static's from cli-utils.c
 https://sourceware.org/ml/gdb-patches/2011-03/msg00636.html

'optional_p' passed to get_tracepoint_by_number become always true.

gdb:

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

* breakpoint.c (get_tracepoint_by_number): Remove argument
optional_p.  All callers updated.  Adjust comments.  Update
output message.
* breakpoint.h (get_tracepoint_by_number): Update declaration.

10 years agoHandle parse number error in goto_bookmark_command
Yao Qi [Sat, 22 Feb 2014 06:42:12 +0000 (14:42 +0800)]
Handle parse number error in goto_bookmark_command

In GDB mainline, the error message for goto-bookmark
isn't perfect.

 (gdb) goto-bookmark 1.1
 goto-bookmark: no bookmark found for ''.

This patch tweaks the error message by checking the return value of
get_number.  With patch applied, it becomes:

 (gdb) goto-bookmark 1.1
 goto-bookmark: invalid bookmark number '1.1'.

gdb:

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

* reverse.c (goto_bookmark_command): Add local 'p'.  Emit error
early if get_number returns zero.  Use 'p' instead of 'args'.

10 years agoAdd a newline in output messages
Yao Qi [Thu, 20 Feb 2014 09:35:31 +0000 (17:35 +0800)]
Add a newline in output messages

Hi,
GDB prints two warnings in one single line, as below:

 (gdb) p 1.2
 $1 = 1.2
 (gdb) enable $1.2
 History value must have integer type.Bad breakpoint number '$1'

This patch adds '\n' at the end of message.

gdb:

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

* cli/cli-utils.c (get_number_trailer): Add '\n' at the end of
message.

10 years agoFix PR16508
Yao Qi [Sat, 15 Feb 2014 00:48:53 +0000 (08:48 +0800)]
Fix PR16508

This patch fixes PR16508, which is about MI "-trace-find frame-number 0"
behaves differently from CLI "tfind 0".  In CLI, we check both
status->running and status->filename, but in MI, we only check
status->running, which looks wrong to me.  This patch moves the code
of checking to a new function check_trace_running, and use it in
both CLI and MI.

This patch also adds a test case pr16508.exp, which fails without this
fix, and passes with the fix applied.

  FAIL: gdb.trace/pr16508.exp: interpreter-exec mi "-trace-find frame-number 0"

gdb:

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

PR breakpoints/16508
* tracepoint.c (check_trace_running): New function.
(trace_find_command): Move code to check_trace_running and
call check_trace_running.
(trace_find_pc_command): Likewise.
(trace_find_tracepoint_command): Likewise.
(trace_find_line_command): Likewise.
(trace_find_range_command): Likewise.
* tracepoint.h (check_trace_running): Likewise.
* mi/mi-main.c (mi_cmd_trace_find): Call check_trace_running.

gdb/testsuite:

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

* gdb.trace/pr16508.exp: New file.

10 years agoChange the default implementation of to_traceframe_info to tcomplain
Yao Qi [Tue, 4 Mar 2014 09:39:10 +0000 (17:39 +0800)]
Change the default implementation of to_traceframe_info to tcomplain

This patch is to change the default implementation of to_traceframe_info
from 'return NULL' to tcomplain, which is intended.  If new target
supports tracepoint, this method should be implemented, otherwise,
an error is thrown.

gdb:

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

* target.h (struct target_ops) <to_traceframe_info>: Use
TARGET_DEFAULT_NORETURN (tcomplain ()).
* target-delegates.c: Regenerated.

10 years agodaily update
Alan Modra [Wed, 5 Mar 2014 23:01:23 +0000 (09:31 +1030)]
daily update

10 years agoPR gdb/16575: stale breakpoint instructions in the code cache
Pedro Alves [Wed, 5 Mar 2014 14:18:28 +0000 (14:18 +0000)]
PR gdb/16575: stale breakpoint instructions in the code cache

In non-stop mode, or rather, breakpoints always-inserted mode, the
code cache can easily end up with stale breakpoint instructions:

All it takes is filling a cache line when breakpoints already exist in
that memory region, and then delete the breakpoint.

Vis. (from the new test):

 (gdb) set breakpoint always-inserted on
 (gdb) b 23
 Breakpoint 2 at 0x400540: file ../../../src/gdb/testsuite/gdb.base/breakpoint-shadow.c, line 23.
 (gdb) b 24
 Breakpoint 3 at 0x400547: file ../../../src/gdb/testsuite/gdb.base/breakpoint-shadow.c, line 24.
 disass main
 Dump of assembler code for function main:
    0x000000000040053c <+0>:     push   %rbp
    0x000000000040053d <+1>:     mov    %rsp,%rbp
 => 0x0000000000400540 <+4>:     movl   $0x1,-0x4(%rbp)
    0x0000000000400547 <+11>:    movl   $0x2,-0x4(%rbp)
    0x000000000040054e <+18>:    mov    $0x0,%eax
    0x0000000000400553 <+23>:    pop    %rbp
    0x0000000000400554 <+24>:    retq
 End of assembler dump.

So far so good.  Now flush the code cache:

 (gdb) set code-cache off
 (gdb) set code-cache on

Requesting a disassembly works as expected, breakpoint shadowing is
applied:

 (gdb) disass main
 Dump of assembler code for function main:
    0x000000000040053c <+0>:     push   %rbp
    0x000000000040053d <+1>:     mov    %rsp,%rbp
 => 0x0000000000400540 <+4>:     movl   $0x1,-0x4(%rbp)
    0x0000000000400547 <+11>:    movl   $0x2,-0x4(%rbp)
    0x000000000040054e <+18>:    mov    $0x0,%eax
    0x0000000000400553 <+23>:    pop    %rbp
    0x0000000000400554 <+24>:    retq
 End of assembler dump.

However, now delete the breakpoints:

 (gdb) delete
 Delete all breakpoints? (y or n) y

And disassembly shows the old breakpoint instructions:

 (gdb) disass main
 Dump of assembler code for function main:
    0x000000000040053c <+0>:     push   %rbp
    0x000000000040053d <+1>:     mov    %rsp,%rbp
 => 0x0000000000400540 <+4>:     int3
    0x0000000000400541 <+5>:     rex.RB cld
    0x0000000000400543 <+7>:     add    %eax,(%rax)
    0x0000000000400545 <+9>:     add    %al,(%rax)
    0x0000000000400547 <+11>:    int3
    0x0000000000400548 <+12>:    rex.RB cld
    0x000000000040054a <+14>:    add    (%rax),%al
    0x000000000040054c <+16>:    add    %al,(%rax)
    0x000000000040054e <+18>:    mov    $0x0,%eax
    0x0000000000400553 <+23>:    pop    %rbp
    0x0000000000400554 <+24>:    retq
 End of assembler dump.

Those breakpoint instructions are no longer installed in target memory
they're stale in the code cache.  Easily confirmed by just disabling
the code cache:

 (gdb) set code-cache off
 (gdb) disass main
 Dump of assembler code for function main:
    0x000000000040053c <+0>:     push   %rbp
    0x000000000040053d <+1>:     mov    %rsp,%rbp
 => 0x0000000000400540 <+4>:     movl   $0x1,-0x4(%rbp)
    0x0000000000400547 <+11>:    movl   $0x2,-0x4(%rbp)
    0x000000000040054e <+18>:    mov    $0x0,%eax
    0x0000000000400553 <+23>:    pop    %rbp
    0x0000000000400554 <+24>:    retq
 End of assembler dump.

I stumbled upon this when writing a patch to infrun.c, that made
handle_inferior_event & co fill in the cache before breakpoints were
removed from the target.  Recall that wait_for_inferior flushes the
dcache for every event.  So in that case, always-inserted mode was not
necessary to trigger this.  It's just a convenient way to expose the
issue.

The dcache works at the raw memory level.  We need to update it
whenever memory is written, no matter what kind of target memory
object was originally passed down by the caller.  The issue is that
the dcache update code isn't reached when a caller explicitly writes
raw memory.  Breakpoint insertion/removal is one such case --
mem-break.c uses target_write_read_memory/target_write_raw_memory.

The fix is to move the dcache update code from memory_xfer_partial_1
to raw_memory_xfer_partial so that it's always reachable.

When we do that, we can actually simplify a series of things.
memory_xfer_partial_1 no longer needs to handle writes for any kind of
memory object, and therefore dcache_xfer_memory no longer needs to
handle writes either.  So the latter (dcache_xfer_memory) and its
callees can be simplified to only care about reads.  While we're
touching dcache_xfer_memory's prototype, might as well rename it to
reflect that fact that it only handles reads, and make it follow the
new target_xfer_status/xfered_len style.  This made me notice that
dcache_xfer_memory loses the real error status if a memory read fails:
we could have failed to read due to TARGET_XFER_E_UNAVAILABLE, for
instance, but we always return TARGET_XFER_E_IO, hence the FIXME note.
I felt that fixing that fell out of the scope of this patch.

Currently dcache_xfer_memory handles the case of a write failing.  The
whole cache line is invalidated when that happens.  However,
dcache_update, the sole mechanism for handling writes that will remain
after the patch, does not presently handle that scenario.  That's a
bug.  The patch makes it handle that, by passing down the
target_xfer_status status from the caller, so that it can better
decide what to do itself.  While I was changing the function's
prototype, I constified the myaddr parameter, getting rid of the need
for the cast as seen in its existing caller.

Tested on x86_64 Fedora 17, native and gdbserver.

gdb/
2014-03-05  Pedro Alves  <palves@redhat.com>

PR gdb/16575
* dcache.c (dcache_poke_byte): Constify ptr parameter.  Return
void.  Update comment.
(dcache_xfer_memory): Delete.
(dcache_read_memory_partial): New, based on the read bits of
dcache_xfer_memory.
(dcache_update): Add status parameter.  Use ULONGEST for len, and
adjust.  Discard cache lines if the reason for the update was
error.
* dcache.h (dcache_xfer_memory): Delete declaration.
(dcache_read_memory_partial): New declaration.
(dcache_update): Update prototype.
* target.c (raw_memory_xfer_partial): Update the dcache here.
(memory_xfer_partial_1): Don't handle dcache writes here.

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

PR gdb/16575
* gdb.base/breakpoint-shadow.exp (compare_disassembly): New
procedure.
(top level): Adjust to use it.  Add tests that exercise breakpoint
interaction with the code-cache.

10 years agoUpdate copyright years
Alan Modra [Wed, 5 Mar 2014 11:46:15 +0000 (22:16 +1030)]
Update copyright years