deliverable/binutils-gdb.git
10 years agoDon't suppress errors inserting/removing hardware breakpoints in shared
Pedro Alves [Wed, 23 Apr 2014 14:06:47 +0000 (15:06 +0100)] 
Don't suppress errors inserting/removing hardware breakpoints in shared
libraries.

As explained in
https://sourceware.org/ml/gdb-patches/2008-08/msg00361.html, after a
shared library was unloaded, we can no longer insert or remove
breakpoints into/from its (no longer present) code segment.  That'll
fail with memory errors.  However, that concern does not apply to
hardware breakpoints.  By definition, hardware breakpoints are
implemented using a mechanism that is not dependent on being able to
modify the target's memory.  Usually, by setting up CPU debug
registers.  IOW, we should be able to set hw breakpoints in an
unmapped address.  We don't seem to have a test that exercises that,
so this patch adds one.

I noticed the error supression because of a related issue -- the
target_insert_hw_breakpoint/target_remove_hw_breakpoint interfaces
don't really distinguish "not supported" from "error" return, and so
remote.c returns -1 in both cases.  This results in hardware
breakpoints set in shared libraries silently ending up pending forever
even though the target doesn't actually support hw breakpoints.

 (gdb) set breakpoint always-inserted on
 (gdb) set remote Z-packet off
 (gdb) info breakpoints
 No breakpoints or watchpoints.
 (gdb) hbreak shrfunc
 Hardware assisted breakpoint 3 at 0x7ffff7dfb657: file ../../../src/gdb/testsuite/gdb.base/hbreak-in-shr-unsupported-shr.c, line 21.
 (gdb) info break
 Num     Type           Disp Enb Address            What
 3       hw breakpoint  keep y   <PENDING>          shrfunc

After the patch we get the expected:

 (gdb) hbreak shrfunc
 Hardware assisted breakpoint 3 at 0x7ffff7dfb657: file ../../../src/gdb/testsuite/gdb.base/hbreak-in-shr-unsupported-shr.c, line 21.
 Warning:
 Cannot insert hardware breakpoint 3.
 Could not insert hardware breakpoints:
 You may have requested too many hardware breakpoints/watchpoints.

 (gdb) info break
 Num     Type           Disp Enb Address            What
 3       hw breakpoint  keep y   0x00007ffff7dfb657 in shrfunc at ../../../src/gdb/testsuite/gdb.base/hbreak-in-shr-unsupported-shr.c:21

(HW breakpoints set in the main executable, when the target doesn't
support HW breakpoints always resulted in the latter output.)

We probably should improve the insert/remove interface to return a
different error code for unsupported.  But I chose to fix the error
supression first, as it's a deeper and wider issue.

Tested on x86_64 Fedora 17, native and gdbserver.

gdb/
2014-04-23  Pedro Alves  <palves@redhat.com>

* breakpoint.c (insert_bp_location, remove_breakpoint_1): If
the breakpoint is set in a shared library, only suppress
errors for software breakpoints, not hardware breakpoints.

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

* gdb.base/hbreak-in-shr-unsupported-shr.c: New file.
* gdb.base/hbreak-in-shr-unsupported.c: New file.
* gdb.base/hbreak-in-shr-unsupported.exp: New file.
* gdb.base/hbreak-unmapped.c: New file.
* gdb.base/hbreak-unmapped.exp: New file.
* gdb.trace/qtro.exp (gdb_is_target_remote): Move ...
* lib/gdb.exp (gdb_is_target_remote): ... here.

10 years agold/arm: Fix testsuite failures for armeb-linux-eabi
Will Newton [Fri, 4 Apr 2014 14:08:50 +0000 (15:08 +0100)] 
ld/arm: Fix testsuite failures for armeb-linux-eabi

Fix all the cases where endianness needs to be taken into account
in the ARM ld dump tests.

ld/testsuite/ChangeLog:

2014-04-23  Will Newton  <will.newton@linaro.org>

* ld-arm/arm-no-rel-plt.ld: Remove OUTPUT_FORMAT and
SEARCH_DIR commands.
* ld-arm/arm-rel32.d: Update regexps to allow test to
pass on armeb-linux-eabi configuration.
* ld-arm/data-only-map.d: Likewise.
* ld-arm/fix-arm1176-off.d: Likewise.
* ld-arm/fix-arm1176-on.d: Likewise.
* ld-arm/ifunc-1.gd: Likewise.
* ld-arm/ifunc-10.gd: Likewise.
* ld-arm/ifunc-11.gd: Likewise.
* ld-arm/ifunc-12.gd: Likewise.
* ld-arm/ifunc-13.gd: Likewise.
* ld-arm/ifunc-14.gd: Likewise.
* ld-arm/ifunc-15.gd: Likewise.
* ld-arm/ifunc-16.gd: Likewise.
* ld-arm/ifunc-17.gd: Likewise.
* ld-arm/ifunc-2.gd: Likewise.
* ld-arm/ifunc-3.gd: Likewise.
* ld-arm/ifunc-4.gd: Likewise.
* ld-arm/ifunc-5.gd: Likewise.
* ld-arm/ifunc-6.gd: Likewise.
* ld-arm/ifunc-7.gd: Likewise.
* ld-arm/ifunc-8.gd: Likewise.
* ld-arm/ifunc-9.gd: Likewise.
* ld-arm/jump-reloc-veneers-long.d: Likewise.
* ld-arm/reloc-boundaries.d: Likewise.

10 years agogas/arm: Fix gas tests to run on armeb-linux-eabi
Will Newton [Fri, 4 Apr 2014 10:52:59 +0000 (11:52 +0100)] 
gas/arm: Fix gas tests to run on armeb-linux-eabi

Fix various places where endianness needed to be taken into account
in the gas testsuite for ARM.

gas/testsuite/ChangeLog:

2014-04-23  Will Newton  <will.newton@linaro.org>

* gas/arm/backslash-at.d: Fix dump output regexps for
armeb-linux-eabi configuration.
* gas/arm/got_prel.d: Likewise.
* gas/arm/inst-po.d: Likewise.
* gas/arm/unwind.d: Likewise.

10 years agogas/arm: Force output of a data mapping symbol for literal pools
Will Newton [Fri, 4 Apr 2014 09:07:06 +0000 (10:07 +0100)] 
gas/arm: Force output of a data mapping symbol for literal pools

If there is a a trailing align statement in a code section we may
output data padding with a data mapping followed by a code alignment
with a code mapping. The literal pool may then be output with a code
mapping symbol which will cause it to be endian swapped in a big-endian
configuration. When outputting a literal pool make sure that a data
mapping symbol is output in all cases.

gas/ChangeLog:

2014-04-23  Will Newton  <will.newton@linaro.org>

* config/tc-arm.c (s_ltorg): Call make_mapping_symbol
directly instead of mapping_state.

gas/testsuite/ChangeLog:

2014-04-23  Will Newton  <will.newton@linaro.org>

* gas/arm/mapmisc.d: Check literal pool mapping with
a trailing .align statement.
* gas/arm/mapmisc.s: Likewise.

10 years agoAdd support for the MIPS eXtended Physical Address (XPA) ASE.
Andrew Bennett [Wed, 23 Apr 2014 10:24:30 +0000 (11:24 +0100)] 
Add support for the MIPS eXtended Physical Address (XPA) ASE.

ChangeLog:

binutils/
* doc/binutils.texi: Document the disassemble MIPS XPA instructions
command line option.

gas/
* config/tc-mips.c (options): Add OPTION_XPA and OPTION_NO_XPA.
  (md_longopts): Add xpa and no-xpa command line options.
  (mips_ases): Add MIPS XPA ASE.
  (mips_cpu_info_table): Update p5600 entry to allow the XPA ASE.
  * doc/as.texinfo: Document the MIPS XPA command line options.
  * doc/c-mips.texi: Document the MIPS XPA command line options,
  and assembler directives.

gas/testsuite/
  * gas/mips/mips.exp: Add xpa tests.
  * gas/mips/xpa.s: New test.
  * gas/mips/xpa.d: Likewise.

include/
  * opcode/mips.h (ASE_XPA): New define.

opcodes/
  * mips-dis.c (mips_arch_choices): Update mips32r2 and mips64r2
  to allow the MIPS XPA ASE.
  (parse_mips_dis_option): Process the -Mxpa option.
  * mips-opc.c (XPA): New define.
  (mips_builtin_opcodes): Add MIPS XPA instructions and move the
  locations of the ctc0 and cfc0 instructions.

10 years agoPR ld/16787, stale dwarf2 stash
Alan Modra [Wed, 23 Apr 2014 04:56:19 +0000 (14:26 +0930)] 
PR ld/16787, stale dwarf2 stash

Throw away the dwarf2 stash if it becomes invalid due to section
VMAs changing.  It would be nice to reclaim all the bfd_alloc
memory here when we throw away the stash, perhaps by putting
everything we alloc on a private dwarf2 objalloc, but I haven't done
that with this patch.

I've also fixed a problem with bfd_perform_relocation losing reloc
addends, which meant a second or subsequent look at debug info
sections did not properly relocate the sections.  I can't see why
bfd_perform_relocation should need to change addends except for ld -r,
and the history (985fca12e98e6ec1) doesn't help much.

Finally, the patch tweaks place_sections to avoid unnecessary work.
If we've mapped input to output sections, then input section VMA
isn't used so there's not much point in adjusting it.  Incidentally,
this also means place_sections isn't effective in all cases.

PR ld/16787
* dwarf2.c (struct dwarf2_debug): Add sec_vma field.
(place_sections): Do not modify VMA of sections when called from
linker after sections have been placed in output sections.  Short
circuit single section case.
(save_section_vma, section_vma_same): New functions.
(_bfd_dwarf2_slurp_debug_info): Throw away stash if section VMAs
change.
* reloc.c (bfd_perform_relocation): Do not modify reloc addend
when non-relocatable.

10 years agoAdd missing ChangeLog entries for nios2 gas selftest patch.
Sandra Loosemore [Wed, 23 Apr 2014 02:41:14 +0000 (19:41 -0700)] 
Add missing ChangeLog entries for nios2 gas selftest patch.

10 years agodaily update
Alan Modra [Wed, 23 Apr 2014 00:00:59 +0000 (09:30 +0930)] 
daily update

10 years agoFix alignment for the first section frag on xtensa
Max Filippov [Tue, 15 Apr 2014 15:12:46 +0000 (19:12 +0400)] 
Fix alignment for the first section frag on xtensa

Linking object files produced by partial linking with link-time
relaxation enabled sometimes fails with the following error message:

dangerous relocation: call8: misaligned call target: (.text.unlikely+0x63)

This happens because no basic block with an XTENSA_PROP_ALIGN flag in the
property table is generated for the first basic block, even if the
.align directive is present.
It was believed that the first frag alignment could be derived from the
section alignment, but this was not implemented for the partial linking
case: after partial linking first frag of a section may become not
first, but no additional alignment frag is inserted before it.
Basic block for such frag may be merged with previous basic block into
extended basic block during relaxation pass losing its alignment
restrictions.

Fix this by always recording alignment for the first section frag.

2014-04-22  Max Filippov  <jcmvbkbc@gmail.com>

gas/
    * config/tc-xtensa.c (xtensa_handle_align): record alignment for the
    first section frag.

gas/testsuite/
    * gas/xtensa/all.exp: Add test for the first section frag alignment.
    * gas/xtensa/first_frag_align.d: First section frag alignment expected
    dump.
    * gas/xtensa/first_frag_align.s: First section frag alignment test
    source.

10 years agoConsecutive step-overs trigger internal error.
Pedro Alves [Tue, 22 Apr 2014 14:00:56 +0000 (15:00 +0100)] 
Consecutive step-overs trigger internal error.

If a thread trips on a breakpoint that needs stepping over just after
finishing a step over, GDB currently fails an assertion.  This is a
regression caused by the "Handle multiple step-overs." patch
(99619beac6252113fed212fdb9e1ab97bface423) at
https://sourceware.org/ml/gdb-patches/2014-02/msg00765.html.

 (gdb) x /4i $pc
 => 0x400540 <main+4>:   movl   $0x0,0x2003da(%rip)        # 0x600924 <i>
    0x40054a <main+14>:  movl   $0x1,0x2003d0(%rip)        # 0x600924 <i>
    0x400554 <main+24>:  movl   $0x2,0x2003c6(%rip)        # 0x600924 <i>
    0x40055e <main+34>:  movl   $0x3,0x2003bc(%rip)        # 0x600924 <i>
 (gdb) PASS: gdb.base/consecutive-step-over.exp: get breakpoint addresses
 break *0x40054a
 Breakpoint 2 at 0x40054a: file ../../../src/gdb/testsuite/gdb.base/consecutive-step-over.c, line 23.
 (gdb) PASS: gdb.base/consecutive-step-over.exp: insn 1: set breakpoint
 condition $bpnum condition
 (gdb) PASS: gdb.base/consecutive-step-over.exp: insn 1: set condition
 break *0x400554
 Breakpoint 3 at 0x400554: file ../../../src/gdb/testsuite/gdb.base/consecutive-step-over.c, line 24.
 (gdb) PASS: gdb.base/consecutive-step-over.exp: insn 2: set breakpoint
 condition $bpnum condition
 (gdb) PASS: gdb.base/consecutive-step-over.exp: insn 2: set condition
 break *0x40055e
 Breakpoint 4 at 0x40055e: file ../../../src/gdb/testsuite/gdb.base/consecutive-step-over.c, line 25.
 (gdb) PASS: gdb.base/consecutive-step-over.exp: insn 3: set breakpoint
 condition $bpnum condition
 (gdb) PASS: gdb.base/consecutive-step-over.exp: insn 3: set condition
 break 27
 Breakpoint 5 at 0x400568: file ../../../src/gdb/testsuite/gdb.base/consecutive-step-over.c, line 27.
 (gdb) continue
 Continuing.
 ../../src/gdb/infrun.c:5200: internal-error: switch_back_to_stepped_thread: Assertion `!tp->control.trap_expected' failed.
 A problem internal to GDB has been detected,
 further debugging may prove unreliable.
 FAIL: gdb.base/consecutive-step-over.exp: continue to breakpoint: break here (GDB internal error)

The assertion fails, because the code is not expecting that the event
thread itself might need another step over.  IOW, not expecting that
TP in:

     tp = find_thread_needs_step_over (stepping_thread != NULL,
                                      stepping_thread);

could be the event thread.

A small fix for this would be to clear the event thread's
trap_expected earlier, before asserting.  But looking deeper, although
currently_stepping_or_nexting_callback's intention is finding the
thread that is doing a step/next, it also returns the thread that is
doing a step-over dance, with trap_expected set.  If there ever was a
reason for that (it was I who added
currently_stepping_or_nexting_callback , but I can't recall why I put
trap_expected there in the first place), the only remaining reason
nowadays is to aid in implementing switch_back_to_stepped_thread's
assertion that is now triggering, by piggybacking on the walk over all
threads, thus avoiding a separate walk.  This is quite obscure, and I
think we can do even better, by merging the walks that look for the
stepping thread, and the walk that looks for some thread that might
need a step over.

Tested on x86_64 Fedora 17, native and gdbserver, and also native on
top of my "software single-step on x86_64" series.

gdb/
2014-04-22  Pedro Alves  <palves@redhat.com>

* infrun.c (schedlock_applies): New function, factored out from
find_thread_needs_step_over.
(find_thread_needs_step_over): Use it.
(switch_back_to_stepped_thread): Always clear trap_expected if the
step over is finished.  Return early if scheduler locking applies.
Look for the stepping thread and a potential step-over thread with
a single loop.
(currently_stepping_or_nexting_callback): Delete.

2014-04-22  Pedro Alves  <palves@redhat.com>

* gdb.base/consecutive-step-over.c: New file.
* gdb.base/consecutive-step-over.exp: New file.

10 years agoMake gdb_continue_to_breakpoint fail quickly on internal errors.
Pedro Alves [Tue, 22 Apr 2014 18:15:48 +0000 (19:15 +0100)] 
Make gdb_continue_to_breakpoint fail quickly on internal errors.

This switches the gdb_continue_to_breakpoint routine to use
gdb_test_multiple instead of send_gdb/gdb_expect, so that an internal
error is detected immediately, instead of failing on timeout.

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

* lib/gdb.exp (gdb_continue_to_breakpoint): Use gdb_test_multiple
instead of send_gdb/gdb_expect.

10 years agoFix Nios II assembler self-test mode.
Sandra Loosemore [Tue, 22 Apr 2014 17:56:02 +0000 (10:56 -0700)] 
Fix Nios II assembler self-test mode.

2014-04-22  Sandra Loosemore  <sandra@codesourcery.com>

gas/
* config/tc-nios2.c (nios2_consume_arg): Add case for 'E' to
unbreak self-test mode.

gas/testsuite/
* gas/nios2/selftest.s: New.
* gas/nios2/selftest.d: New.

10 years agoAdd tests for PR ld/16846
H.J. Lu [Tue, 22 Apr 2014 17:22:39 +0000 (10:22 -0700)] 
Add tests for PR ld/16846

PR ld/16846
* ld-plugin/lto.exp (lto_link_tests): Add tests for PR ld/16846.
* ld-plugin/pr16846a.c: New file.
* ld-plugin/pr16846b.c: Likewise.
* ld-plugin/pr16846c.c: Likewise.

10 years agoAnother fix for building on a 32-bit host.
Nick Clifton [Tue, 22 Apr 2014 15:57:34 +0000 (16:57 +0100)] 
Another fix for building on a 32-bit host.

PR ld/16821
* peXXigen.c (_bfd_XXi_swap_sym_out): Fix for 32-bit hosts.

10 years agoRemove support for the (deprecated) openrisc and or32 configurations and replace
Christian Svensson [Tue, 22 Apr 2014 14:57:47 +0000 (15:57 +0100)] 
Remove support for the (deprecated) openrisc and or32 configurations and replace
with support for the new or1k configuration.

10 years agoAdd a note to the GDB/NEWS file mentioning that the ARM simulator now
Nick Clifton [Tue, 22 Apr 2014 10:23:05 +0000 (11:23 +0100)] 
Add a note to the GDB/NEWS file mentioning that the ARM simulator now
supports instruction tracing with or without disassembly alongside.

* NEWS: Mention that ARM sim now supports tracing.

10 years agoFix build problem on 32-bit hosts with the recent patch for PR 16821.
Yuanhui Zhang [Tue, 22 Apr 2014 10:00:39 +0000 (11:00 +0100)] 
Fix build problem on 32-bit hosts with the recent patch for PR 16821.

PR ld/16821
* peXXigen.c (abs_finder): Fix for 32-bit host builds.

10 years agobfd/elfnn-aarch64.c: Remove elfNN_aarch64_section_flags
Will Newton [Mon, 14 Apr 2014 12:37:51 +0000 (13:37 +0100)] 
bfd/elfnn-aarch64.c: Remove elfNN_aarch64_section_flags

This function seems to be a left over from some previous
functionality that no longer exists - the comment above seems to
make no sense with the current code. Remove the function as it
breaks handling of SystemTap static probe note sections.

bfd/ChangeLog:

2014-04-22  Will Newton  <will.newton@linaro.org>

* elfnn-aarch64.c (elfNN_aarch64_section_flags): Remove
function.  (elf_backend_section_flags): Remove define.

10 years agoCheck tracefile is generated by binary execution
Yao Qi [Fri, 21 Mar 2014 04:52:24 +0000 (12:52 +0800)] 
Check tracefile is generated by binary execution

In gdb.trace/tfile.exp, we execute binary to generate tracefile,

  remote_exec target "$binfile"

however, this fails on bare metal target.  This patch is to
handle binary execution failure by running binary in GDB.
The binary will do some io operation to generate tracefile, so
we need a check 'target_info exists gdb,nofileio'.

This patch is to check whether tracefile is generated.  tfile.exp can
be skipped if generation is failed, while test_tfind_tfile in
mi-traceframe-changed.exp is skipped if generated failed.  The rest of
the mi-traceframe-changed.exp can still be executed, because on some
bare metal targets, the remote stub supports tracepoint but doesn't
support fileio.

gdb/testsuite:

2014-04-22  Yao Qi  <yao@codesourcery.com>

* lib/trace-support.exp (generate_tracefile): New procedure.
* gdb.trace/tfile.exp: Skip the test if generate_tracefile
return 0.
* gdb.trace/mi-traceframe-changed.exp: Invoke test_tfind_tfile
if generate_tracefile returns 1.

10 years agoUnify ctf_fetch_registers and tfile_fetch_registers
Yao Qi [Fri, 18 Apr 2014 11:32:01 +0000 (19:32 +0800)] 
Unify ctf_fetch_registers and tfile_fetch_registers

Functions ctf_fetch_registers and tfile_fetch_registers have some
duplicated code about guessing the PC in regcache.  Sometimes, we
may change one function and forget to update the other one, like this
https://www.sourceware.org/ml/gdb-patches/2014-01/msg00292.html

This patch is to move the duplicated code into a new function
tracefile_fetch_registers, and let both ctf_fetch_registers and
tfile_fetch_registers call it.

gdb:

2014-04-22  Yao Qi  <yao@codesourcery.com>

* tracefile-tfile.c (tfile_fetch_registers): Move the bottom to ...
* tracefile.c (tracefile_fetch_registers): ... it.  New function.
* tracefile.h (tracefile_fetch_registers): Declare.
* ctf.c (ctf_fetch_registers): Remove the bottom.  Call
tracefile_fetch_registers.

10 years agodaily update
Alan Modra [Tue, 22 Apr 2014 00:00:39 +0000 (09:30 +0930)] 
daily update

10 years agoFix alpha-elf relaxation
Richard Henderson [Mon, 21 Apr 2014 15:14:18 +0000 (08:14 -0700)] 
Fix alpha-elf relaxation

ld/
* emultempl/alphaelf.em (alpha_after_parse): Enable 2 relax passes.
bfd/
* elf64-alpha.c (elf64_alpha_size_got_sections): New may_merge
parameter; honor it and disable got merging when false.
(elf64_alpha_relax_got_load): Do not relax to GPREL relocs during
the first pass of relaxation.
(elf64_alpha_relax_with_lituse): Likewise.  Move relaxed relocs to
the end of the LITERAL+LITUSE chain.
(elf64_alpha_relax_section): Only process LITERAL relocs during the
second pass of relaxation.

10 years agoEnable secureplt by default for alpha-linux
Richard Henderson [Mon, 21 Apr 2014 15:05:49 +0000 (08:05 -0700)] 
Enable secureplt by default for alpha-linux

* configure.ac (use_secureplt): Enable by default.
* configure: Rebuild.

10 years agodaily update
Alan Modra [Mon, 21 Apr 2014 00:00:38 +0000 (09:30 +0930)] 
daily update

10 years agodaily update
Alan Modra [Sun, 20 Apr 2014 00:00:38 +0000 (09:30 +0930)] 
daily update

10 years agoPR gdb/14018 -- avoid "PC register not available" errors.
Eli Zaretskii [Sat, 19 Apr 2014 08:12:19 +0000 (11:12 +0300)] 
PR gdb/14018 -- avoid "PC register not available" errors.

gdb/windows-nat.c (thread_rec): Don't display a warning when
SuspendThread fails with ERROR_ACCESS_DENIED.  If SuspendThread
fails for any reason, set th->suspended to -1, so that we don't
try to resume such a thread.  Also, don't return NULL in these
cases, to avoid completely ruin the session due to "PC register is
not available" error.
(do_windows_fetch_inferior_registers): Check errors in
GetThreadContext call.
(windows_continue): Accept an additional argument KILLED; if not
zero, ignore errors in the SetThreadContext call, since the
inferior was killed and is shutting down.
(windows_resume, get_windows_debug_event)
(windows_create_inferior, windows_mourn_inferior)
(windows_kill_inferior): All callers of windows_continue changed
to adjust to its new calling sequence.

10 years agoCall post_create_inferior in ctf_open.
Yao Qi [Fri, 18 Apr 2014 11:19:22 +0000 (19:19 +0800)] 
Call post_create_inferior in ctf_open.

We don't call post_create_inferior at the end of ctf_open.  It is an
oversight in patch

  [PATCH 2/2] Create inferior for ctf target.
  https://sourceware.org/ml/gdb-patches/2014-01/msg01056.html

This patch is to call post_create_inferior at the end of ctf_open,
like the end of tfile_open.

gdb:

2014-04-19  Yao Qi  <yao@codesourcery.com>

* ctf.c (ctf_open): Call post_create_inferior.

10 years agoGet trace_regblock_size from metadata instead of event
Yao Qi [Sat, 19 Apr 2014 02:14:58 +0000 (10:14 +0800)] 
Get trace_regblock_size from metadata instead of event

In ctf trace, for each 'R' block, we save it as a "register" event,
as defined below in metadata.

event {
        name = "register";
        id = 0;
        fields := struct {
                ascii contents[440];
        };
}

Nowadays, we initialize trace_regblock_size by getting the length of
"contents" from a "register" event.  However, 'R' block may not exist
in traceframe, as a result, "register" event doesn't exist in trace file
and trace_regblock_size isn't set.

This patch changes to get trace_regblock_size from metadata (or declaration)
which always exists.

gdb:

2014-04-19  Yao Qi  <yao@codesourcery.com>

* ctf.c (handle_id): New static variable.
(ctf_open_dir): Get handle_id from bt_context_add_trace return
value.  Get the declaration of event "register" and get length
of field "contents".

10 years agoAdd null pointer check in ctf_xfer_partial
Yao Qi [Fri, 18 Apr 2014 11:22:23 +0000 (19:22 +0800)] 
Add null pointer check in ctf_xfer_partial

I find a gdb crash when gdb reads ctf trace.  The crash is caused by passing
NULL to strcmp.  This patch is to add null pointer check, as what we did
somewhere else in ctf.c.

gdb:

2014-04-19  Yao Qi  <yao@codesourcery.com>

* ctf.c (ctf_xfer_partial): Check 'name' is NULL before strcmp.

10 years agoRemove unnecessary argument METHOD to valops.c:oload_method_static.
Siva Chandra [Mon, 3 Mar 2014 13:08:47 +0000 (05:08 -0800)] 
Remove unnecessary argument METHOD to valops.c:oload_method_static.

* valops.c (oload_method_static): Remove unnecessary argument
METHOD.  Update all callers.

10 years agodaily update
Alan Modra [Sat, 19 Apr 2014 00:00:59 +0000 (09:30 +0930)] 
daily update

10 years agomach-o: layout executables
Tristan Gingold [Thu, 3 Apr 2014 12:45:31 +0000 (14:45 +0200)] 
mach-o: layout executables

bfd/
* mach-o.h (bfd_mach_o_dyld_info_command): Add rebase_content,
bind_content, weak_bind_content, lazy_bind_content,
export_content.
(bfd_mach_o_load_command): Add comments, add next field.
(mach_o_data_struct): Replace commands field by first_command
and last_command.
* mach-o.c (bfd_mach_o_append_command): New function.
(bfd_mach_o_bfd_copy_private_symbol_data): Add blank lines.
(bfd_mach_o_bfd_copy_private_section_data): Check flavour,
copy fields.
(bfd_mach_o_bfd_copy_private_header_data): Copy load commands.
(bfd_mach_o_pad4, bfd_mach_o_pad_command): New functions.
(bfd_mach_o_write_thread): Use macro instead of literal.
(bfd_mach_o_write_dylinker, bfd_mach_o_write_dylib)
(bfd_mach_o_write_main, bfd_mach_o_write_dyld_info): New
functions.
(bfd_mach_o_write_symtab_content): New function (extracted
from bfd_mach_o_write_symtab).
(bfd_mach_o_write_symtab): Split.
(bfd_mach_o_count_indirect_symbols): Move
(bfd_mach_o_build_dysymtab): Remove layout code.
(bfd_mach_o_write_contents): Rewritten to build commands in order.
(bfd_mach_o_count_sections_for_seg): Remove.
(bfd_mach_o_build_obj_seg_command): New function (extracted from
bfd_mach_o_build_seg_command).
(bfd_mach_o_build_exec_seg_command): New function.
(bfd_mach_o_build_dysymtab_command): Remove.
(bfd_mach_o_layout_commands): New function.
(bfd_mach_o_init_segment): New function.
(bfd_mach_o_build_commands): Major rework to handle non-object
files.
(bfd_mach_o_alloc_and_read, bfd_mach_o_read_dyld_content): New
function.
(bfd_mach_o_read_dyld_info): Clear content fields.
(bfd_mach_o_read_segment): Adjust call.
(bfd_mach_o_flatten_sections): Adjust as now load commands are
chained.
(bfd_mach_o_scan_start_address, bfd_mach_o_scan)
(bfd_mach_o_mkobject_init, bfd_mach_o_get_base_address)
(bfd_mach_o_lookup_command, bfd_mach_o_core_fetch_environment):
Likewise.

binutils/
* od-macho.c (dump_section_map): Adjust as load commands
are now chained.
(dump_load_command, dump_section_content): Likewise.

10 years agomach-o: Define copy_private_header instead of copy_private_bfd.
Tristan Gingold [Wed, 9 Apr 2014 08:16:39 +0000 (10:16 +0200)] 
mach-o: Define copy_private_header instead of copy_private_bfd.

bfd/
* mach-o-target.c (bfd_mach_o_bfd_copy_private_header_data):
Define instead of bfd_mach_o_bfd_copy_private_bfd_data.
* mach-o.c (bfd_mach_o_bfd_copy_private_bfd_data): Rename.
* mach-o.h (bfd_mach_o_bfd_copy_private_bfd_data): Likewise.

10 years agomach-o: remove name_len field.
Tristan Gingold [Wed, 9 Apr 2014 08:15:50 +0000 (10:15 +0200)] 
mach-o: remove name_len field.

bfd/
* mach-o.h (bfd_mach_o_dylinker_command)
(bfd_mach_o_dylib_command, bfd_mach_o_fvmlib_command): Remove
name_len field.
* mach-o.c (bfd_mach_o_read_dylinker, bfd_mach_o_read_dylib)
(bfd_mach_o_read_fvmlib): Adjust after name_len removal.

10 years agoFix PR backtrace/15558
Pedro Alves [Fri, 18 Apr 2014 09:15:21 +0000 (10:15 +0100)] 
Fix PR backtrace/15558

This PR is about an assertion failure in GDB that can be triggered by
setting "backtrace limit" to a value that causes GDB to stop unwinding
after an inline frame.  In this case, an assertion in
inline_frame_this_id will trigger:

  /* We need a valid frame ID, so we need to be based on a valid
     frame.  (...).  */
  gdb_assert (frame_id_p (*this_id));

Looking at the function:

 static void
 inline_frame_this_id (struct frame_info *this_frame,
       void **this_cache,
       struct frame_id *this_id)
 {
   struct symbol *func;

   /* In order to have a stable frame ID for a given inline function,
      we must get the stack / special addresses from the underlying
      real frame's this_id method.  So we must call get_prev_frame.
      Because we are inlined into some function, there must be previous
      frames, so this is safe - as long as we're careful not to
      create any cycles.  */
   *this_id = get_frame_id (get_prev_frame (this_frame));

we see we're computing the frame id for the inline frame.  If this is
an inline frame, which is a virtual frame constructed based on debug
info, on top of a real stack frame, we should _always_ be able to find
where the frame was inlined into, as that ultimately just means
peeling off the virtual frames on top of the real stack frame.  If
there ultimately was no prev (real) stack frame, then we wouldn't have
been able to construct the inline frame either, by design.  That's
what the assertion catches.

So we have an inline frame, we should _always_ be able to compute its
ID, even if that means bypassing the user backtrace limits to get at
the real stack frame's info.  The problem is that inline_frame_id
calls get_prev_frame, and that takes user backtrace limits into
account.  Code that wants to bypass the limits calls get_prev_frame_1
instead.

Note how get_prev_frame_1 already skips all checks for inline frames:

   /* If we are unwinding from an inline frame, all of the below tests
      were already performed when we unwound from the next non-inline
      frame.  We must skip them, since we can not get THIS_FRAME's ID
      until we have unwound all the way down to the previous non-inline
      frame.  */
   if (get_frame_type (this_frame) == INLINE_FRAME)
     return get_prev_frame_if_no_cycle (this_frame);

And note how the related frame_unwind_caller_id function also uses
get_prev_frame_1:

 struct frame_id
 frame_unwind_caller_id (struct frame_info *next_frame)
 {
   struct frame_info *this_frame;

   /* Use get_prev_frame_1, and not get_prev_frame.  The latter will truncate
      the frame chain, leading to this function unintentionally
      returning a null_frame_id (e.g., when a caller requests the frame
      ID of "main()"s caller.  */

   next_frame = skip_artificial_frames (next_frame);
   this_frame = get_prev_frame_1 (next_frame);
   if (this_frame)
     return get_frame_id (skip_artificial_frames (this_frame));
   else
     return null_frame_id;
 }

get_prev_frame_1 is currently static in frame.c.  As a _1 suffix is
not a good name for an extern function, I've renamed it.

Tested on x86-64 Fedora 17.

gdb/
2014-04-18  Pedro alves  <palves@redhat.com>
    Tom Tromey  <tromey@redhat.com>

PR backtrace/15558
* frame.c (get_prev_frame_1): Rename to ...
(get_prev_frame_always): ... this, and make extern.  Adjust.
(skip_artificial_frames): Use get_prev_frame_always.
(frame_unwind_caller_id, frame_pop, get_prev_frame)
(get_frame_unwind_stop_reason): Adjust to rename.
* frame.h (get_prev_frame_always): Declare.
* inline-frame.c: Include frame.h.
(inline_frame_this_id): Use get_prev_frame_always.

gdb/testsuite/
2014-04-18  Tom Tromey  <palves@redhat.com>
    Pedro alves  <tromey@redhat.com>

PR backtrace/15558
* gdb.opt/inline-bt.exp: Test backtracing from an inline function
with a backtrace limit.
* gdb.python/py-frame-inline.exp: Test running to an inline
function with a backtrace limit, and printing the newest frame.
* gdb.python/py-frame-inline.c (main): Call f.

10 years agosolib-darwin: simplify code.
Tristan Gingold [Fri, 18 Apr 2014 09:03:46 +0000 (11:03 +0200)] 
solib-darwin: simplify code.

Use bfd_mach_o_get_base_address to extract load address.

gdb/
* solib-darwin.c (darwin_solib_create_inferior_hook): Simplify
code by using bfd_mach_o_get_base_address.

10 years agomach-o: add page_size to backend data.
Tristan Gingold [Wed, 9 Apr 2014 08:10:44 +0000 (10:10 +0200)] 
mach-o: add page_size to backend data.

This is preliminary work to layout executables.

bfd/
* mach-o.h (bfd_mach_o_backend_data): Add page_size field.
* mach-o-target.c: Check TARGET_PAGESIZE is defined.
(TARGET_NAME_BACKEND): Add TARGET_PAGESIZE.
* mach-o.c (TARGET_PAGESIZE): Define and undefined for
each targets declared.
* mach-o-x86-64.c (TARGET_PAGESIZE): Define.
* mach-o-i386.c (TARGET_PAGESIZE): Define.

10 years agomach-o.c: use boolean instead of int to return status.
Tristan Gingold [Wed, 16 Apr 2014 14:01:47 +0000 (16:01 +0200)] 
mach-o.c: use boolean instead of int to return status.

bfd/
* mach-o.c (bfd_mach_o_write_thread)
(bfd_mach_o_write_section_32, bfd_mach_o_write_section_64)
(bfd_mach_o_write_segment_32, bfd_mach_o_write_segment_64)
(bfd_mach_o_read_dylinker, bfd_mach_o_read_dylib)
(bfd_mach_o_read_prebound_dylib, bfd_mach_o_read_prebind_cksum)
(bfd_mach_o_read_twolevel_hints, bfd_mach_o_read_fvmlib)
(bfd_mach_o_read_thread, bfd_mach_o_read_dysymtab)
(bfd_mach_o_read_symtab, bfd_mach_o_read_uuid)
(bfd_mach_o_read_linkedit, bfd_mach_o_read_str)
(bfd_mach_o_read_dyld_info, bfd_mach_o_read_segment)
(bfd_mach_o_read_segment_32, bfd_mach_o_read_segment_64)
(bfd_mach_o_read_command): Now return a boolean status.
Adjust return statements.
(bfd_mach_o_write_contents, bfd_mach_o_scan): Adjust tests.
(bfd_mach_o_core_file_failing_command): Remove useless initialization.

10 years agodaily update
Alan Modra [Fri, 18 Apr 2014 00:00:42 +0000 (09:30 +0930)] 
daily update

10 years agoDrop srcdir from untested source path.
Marcus Shawcroft [Thu, 17 Apr 2014 14:26:37 +0000 (15:26 +0100)] 
Drop srcdir from untested source path.

10 years agoThis patch causes local GOT entries addressed via a 16-bit index to
Kwok Cheung Yeung [Thu, 17 Apr 2014 13:13:44 +0000 (14:13 +0100)] 
This patch causes local GOT entries addressed via a 16-bit index to
be placed towards the front of local GOT space, while entries addressed
via a 32-bit index are placed towards the rear.

Provided that there are fewer than ~16K local GOT entries addressed via
a 16-bit index in total, this should eliminate any relocation overflows
caused by such GOT entries being allocated beyond the addressable range.

bfd/
* elfxx-mips.c (struct mips_got_info): Delete assigned_gotno
field.  Add assigned_low_gotno and assigned_high_gotno fields.
(mips_elf_create_local_got_entry): Update out-of-space condition.
Set index of new GOT entry to assigned_low_gotno if required by
the current relocation, else set it to assigned_high_gotno.
(mips_elf_set_global_gotidx): Replace uses of assigned_gotno
with assigned_low_gotno.
(mips_elf_multi_got): Initialize assigned_low_gotno and
assigned_high_gotno in secondary GOTs.  Use assigned_low_gotno
in place of assigned_gotno when handling global GOT entries.
(mips_elf_lay_out_got): Initialize assigned_low_gotno and
assigned_high_gotno.
(_bfd_mips_elf_finish_dynamic_sections): Account for a possible
gap in the middle of local GOT space.

ld/testsuite/
* ld-mips-elf/elf-rel-xgot-n32.d: Update for new GOT layout.
* ld-mips-elf/elf-rel-xgot-n32-embed.d: Likewise.
* ld-mips-elf/elf-rel-xgot-n64.d: Likewise.
* ld-mips-elf/elf-rel-xgot-n64-embed.d: Likewise.
* ld-mips-elf/elf-rel-xgot-n64-linux.d: Likewise.

10 years agoEnable DWARF unwinders for SPU
Ulrich Weigand [Thu, 17 Apr 2014 12:09:49 +0000 (14:09 +0200)] 
Enable DWARF unwinders for SPU

This patch enables use of DWARF unwinders for the SPU target.

In addition to appending the DWARF unwinders, we also need to install
a spu_dwarf_reg_to_regnum that maps the raw stack pointer register to
the cooked version (to avoid mismatches with gdbarch_sp_regnum).

This also causes confusion with the AX collect handling, so we also
install ax_pseudo_register routines to handle the cooked SP.

gdb/
2014-04-17  Ulrich Weigand  <uweigand@de.ibm.com>

* spu-tdep.c: Include "dwarf2-frame.h" and "ax.h".
(spu_ax_pseudo_register_collect): New function.
(spu_ax_pseudo_register_push_stack): Likewise.
(spu_dwarf_reg_to_regnum): Likewise.
(spu_gdbarch_init): Install them.  Append DWARF unwinders.

10 years agoUse address_from_register in dwarf2-frame.c:read_addr_from_reg
Ulrich Weigand [Thu, 17 Apr 2014 12:01:39 +0000 (14:01 +0200)] 
Use address_from_register in dwarf2-frame.c:read_addr_from_reg

This patch fixes a problem that prevented use of the Dwarf unwinders on SPU,
because dwarf2-frame.c common code did not support the situation where the
stack and/or frame pointer is maintained in a *vector* register.  This is
because read_addr_from_reg is hard-coded to assume that such pointers can
be read from registers via a simple get_frame_register / unpack_pointer
operation.

Now, there *is* a routine address_from_register that calls into the
appropriate tdep routines to handle pointer values in "weird" registers
like on SPU, but it turns out I cannot simply change dwarf2-frame.c to
use address_from_register.  This is because address_from_register uses
value_from_register to create a (temporary) value, and that routine
at some point calls get_frame_id in order to set up that value's
VALUE_FRAME_ID entry.

However, the dwarf2-frame.c read_addr_from_reg routine will be called
during early unwinding (to unwind the frame's CFA), at which point the
frame's ID is not actually known yet!  This would cause an assert.

On the other hand, we may notice that VALUE_FRAME_ID is only needed in the
value returned by value_from_register if that value is later used as an
lvalue.  But this is obviously never done to the temporary value used in
address_from_register.  So, if we could change address_from_register to
not call value_from_register but instead accept constructing a value
that doesn't have VALUE_FRAME_ID set, things should be fine.

To do that, we can change the value_from_register callback to accept
a FRAME_ID instead of a FRAME; the only existing uses of the FRAME
argument were either to extract its frame ID, or its gdbarch.  (To
keep a way of getting at the latter, we also change the callback's
type from "f" to "m".)  Together with the required follow-on changes
in the existing value_from_register implementations (including the
default one), this seems to fix the problem.

As another minor interface cleanup, I've removed the explicit TYPE
argument from address_from_register.  This routine really always
uses a default pointer type, and in the new implementation it -to
some extent- relies on that fact, in that it will now no longer
handle types that require gdbarch_convert_register_p handling.

gdb:
2014-04-17  Ulrich Weigand  <uweigand@de.ibm.com>

* gdbarch.sh (value_from_register): Make class "m" instead of "f".
Replace FRAME argument with FRAME_ID.
* gdbarch.c, gdbarch.h: Regenerate.
* findvar.c (default_value_from_register): Add GDBARCH argument;
replace FRAME by FRAME_ID.  No longer call get_frame_id.
(value_from_register): Update call to gdbarch_value_from_register.
* value.h (default_value_from_register): Update prototype.
* s390-linux-tdep.c (s390_value_from_register): Update interface
and call to default_value_from_register.
* spu-tdep.c (spu_value_from_register): Likewise.

* findvar.c (address_from_register): Remove TYPE argument.
Do not call value_from_register; use gdbarch_value_from_register
with null_frame_id instead.
* value.h (address_from_register): Update prototype.
* dwarf2-frame.c (read_addr_from_reg): Use address_from_register.
* dwarf2loc.c (dwarf_expr_read_addr_from_reg): Update for
address_from_register interface change.

10 years agoDrop prefix from unsupported source path.
Marcus Shawcroft [Thu, 17 Apr 2014 09:52:43 +0000 (10:52 +0100)] 
Drop prefix from unsupported source path.

10 years agoFix LTO mismatched TLS reference
Alan Modra [Thu, 17 Apr 2014 03:38:32 +0000 (13:08 +0930)] 
Fix LTO mismatched TLS reference

PR 16846
* elflink.c (_bfd_elf_merge_symbol): Ignore TLS mismatch when
current bfd is a plugin.  Don't always set type_change_ok
when old bfd is a plugin.

10 years ago[testsuite] Set target-charset to ascii
Yao Qi [Mon, 24 Mar 2014 03:26:06 +0000 (11:26 +0800)] 
[testsuite] Set target-charset to ascii

Hi,
We find gdb.base/printcmds.exp fails a lot on windows host, like this,

 p ctable1[163]
 $204 = 163 '£'
 (gdb) FAIL: gdb.base/printcmds.exp: p ctable1[163]

however, on linux host,

 p ctable1[163]
 $205 = 163 '\243'
 (gdb) PASS: gdb.base/printcmds.exp: p ctable1[163]

The printing related code is in valprint.c:print_wchar,

  if (gdb_iswprint (w) && (!need_escape || (!gdb_iswdigit (w)
    && w != LCST ('8')
    && w != LCST ('9'))))
    {
      gdb_wchar_t wchar = w;

      if (w == gdb_btowc (quoter) || w == LCST ('\\'))
obstack_grow_wstr (output, LCST ("\\"));
      obstack_grow (output, &wchar, sizeof (gdb_wchar_t));
    }
  else
   {
      // print W in hex or octal digits
   }

When I debug gdb on different hosts, I find
on windows host, gdb_iswprint (iswprint) returns true if 'w' is 163.
However, on linux host, iswprint returns false if 'w' is 163.  Looks
this difference is caused by the charset.  On Linux host,
the target-charset is ANSI_X3.4-1968, while on windows host, the
target-charset is CP1252.

We can see how target-charset affects the output.  On linux host,

 (gdb) set target-charset ASCII
 (gdb) p ctable1[163]
 $1 = 163 '\243'
 (gdb) set target-charset CP1252
 (gdb) p ctable1[163]
 $2 = 163 '£'

we can print the pound sign too, and it shows target-charset does
affect the output.

This patch is to set target-charset temporarily to ASCII for some
charset-sensitive tests.  Tested on arm-none-eabi and
powerpc-linux-gnu on mingw32 host.  More than one hundred fails are
fixed.

gdb/testsuite:

2014-04-17  Yao Qi  <yao@codesourcery.com>

* lib/gdb.exp (with_target_charset): New proc.
* gdb.base/printcmds.exp (test_print_all_chars): Wrap tests with
with_target_charset.
(test_print_strings): Likewise.
(test_repeat_bytes): Likewise.
* gdb.base/setvar.exp: Set target-charset to ASCII temporarily
for some tests.

10 years agoAutomatic link generation by doxygen
Yao Qi [Thu, 13 Mar 2014 06:07:26 +0000 (14:07 +0800)] 
Automatic link generation by doxygen

Nowadays, we have one page on "GDB Types" generated by doxygen, but types
and macros referenced in doc are not linked to their definitions.  This
patch tweaks the comments a little to use doxygen syntax so that these
types and macros are linked their definitions.

Is it OK?

gdb:

2014-04-17  Yao Qi  <yao@codesourcery.com>

* gdbtypes.h: Update comments to link to types and macros'
definitions.

10 years agodaily update
Alan Modra [Thu, 17 Apr 2014 00:01:10 +0000 (09:31 +0930)] 
daily update

10 years agoAdd the ChangeLog entry missed in 8000c58e455259951daa4370631aa616b367d1a7.
Siva Chandra [Wed, 16 Apr 2014 22:41:35 +0000 (15:41 -0700)] 
Add the ChangeLog entry missed in 8000c58e455259951daa4370631aa616b367d1a7.

10 years agoRemove unused and incorrect macro TYPE_FN_FIELDS.
Siva Chandra [Mon, 14 Apr 2014 13:50:24 +0000 (06:50 -0700)] 
Remove unused and incorrect macro TYPE_FN_FIELDS.

* gdbtypes.h: Remove definition of the macro TYPE_FN_FIELDS.

10 years agoPR gdb/15827
Keith Seitz [Wed, 16 Apr 2014 21:39:10 +0000 (14:39 -0700)] 
PR gdb/15827

Install some sanity checks that sibling DIE offsets are not beyond the
defined limits of the DWARF input buffer in read_partial_die and skip_one_die.

2014-03-20  Keith Seitz  <keiths@redhat.com>

PR gdb/15827
* dwarf2read.c (skip_one_die): Check that all relative-offset
sibling DIEs fall within range of the current reader's buffer.
(read_partial_die): Likewise.

2014-03-20  Keith Seitz  <keiths@redhat.com>

PR gdb/15827
* gdb.dwarf2/corrupt.c: New file.
* gdb.dwarf2/corrupt.exp: New file.

10 years agoPR c++/16597
Keith Seitz [Wed, 16 Apr 2014 21:20:19 +0000 (14:20 -0700)] 
PR c++/16597

[forgot to commit/push these with previous push]

If lookup_symbol_file tries to locate a member variable with NULL name:

      /* A simple lookup failed.  Check if the symbol was defined in
         a base class.  */

      cleanup = make_cleanup (null_cleanup, NULL);

      /* Find the name of the class and the name of the method,
         variable, etc.  */
      prefix_len = cp_entire_prefix_len (name);

      /* If no prefix was found, search "this".  */
      if (prefix_len == 0)
        {
          struct type *type;
          struct symbol *this;

         this = lookup_language_this (language_def (language_cplus), block);
          if (this == NULL)
            {
              do_cleanups (cleanup);
              return NULL;
            }

          type = check_typedef (TYPE_TARGET_TYPE (SYMBOL_TYPE (this)));
          klass = xstrdup (TYPE_NAME (type));
          nested = xstrdup (name);
        }

TYPE_NAME (type) is NULL, so xstrdup (NULL) and boom!

This can happen, e.g., with clang++.  See testsuite/gdb.cp/namelessclass.exp
or the bugzilla report.

This patch simply adds a fencepost against this case, allowing the caller
of lookup_symbol_file to search other blocks for the right symbol.

10 years agoPR c++/16597
Keith Seitz [Wed, 16 Apr 2014 21:12:22 +0000 (14:12 -0700)] 
PR c++/16597

If lookup_symbol_file tries to locate a member variable with NULL name:

      /* A simple lookup failed.  Check if the symbol was defined in
         a base class.  */

      cleanup = make_cleanup (null_cleanup, NULL);

      /* Find the name of the class and the name of the method,
         variable, etc.  */
      prefix_len = cp_entire_prefix_len (name);

      /* If no prefix was found, search "this".  */
      if (prefix_len == 0)
        {
          struct type *type;
          struct symbol *this;

         this = lookup_language_this (language_def (language_cplus), block);
          if (this == NULL)
            {
              do_cleanups (cleanup);
              return NULL;
            }

          type = check_typedef (TYPE_TARGET_TYPE (SYMBOL_TYPE (this)));
          klass = xstrdup (TYPE_NAME (type));
          nested = xstrdup (name);
        }

TYPE_NAME (type) is NULL, so xstrdup (NULL) and boom!

This can happen, e.g., with clang++.  See testsuite/gdb.cp/namelessclass.exp
or the bugzilla report.

This patch simply adds a fencepost against this case, allowing the caller
of lookup_symbol_file to search other blocks for the right symbol.

10 years ago2014-04-16 Steve Ellcey <sellcey@mips.com>
Steve Ellcey [Wed, 16 Apr 2014 17:47:13 +0000 (10:47 -0700)] 
2014-04-16  Steve Ellcey  <sellcey@mips.com>

* emultempl/elf32.em: Include safe-ctype.h.

10 years ago2014-04-16 Steve Ellcey <sellcey@mips.com>
Steve Ellcey [Wed, 16 Apr 2014 17:45:08 +0000 (10:45 -0700)] 
2014-04-16  Steve Ellcey  <sellcey@mips.com>

* ldbuildid.c (generate_build_id): Add ATTRIBUTE_UNUSED to size arg.

10 years agoFix wrapper.exp testcase with stdio gdbserver.
Doug Evans [Wed, 16 Apr 2014 17:40:41 +0000 (10:40 -0700)] 
Fix wrapper.exp testcase with stdio gdbserver.

* lib/gdbserver-support.exp (gdbserver_default_get_remote_address):
Add comment.
(gdbserver_default_get_comm_port): New function.
(gdbserver_start): Check if board file provided
"gdbserver,get_comm_port" and use it if so.
* boards/native-stdio-gdbserver.exp (sockethost): Set to "".
(gdb,socketport): Set to "stdio".
(gdbserver,get_comm_port): Set to ${board}_get_comm_port.
(stdio_gdbserver_template): Delete.
(${board}_get_remote_address): Update.
(${board}_build_remote_cmd): Delete.
(${board}_get_comm_port): New function.
(${board}_spawn): Update.
* boards/remote-stdio-gdbserver.exp (${board}_build_remote_cmd):
Delete.
(${board}_get_remote_address): Update.
(${board}_get_comm_port): New function.

10 years agogdb.base/memattr.exp regexp improvements.
Andrew Burgess [Wed, 16 Apr 2014 16:42:29 +0000 (17:42 +0100)] 
gdb.base/memattr.exp regexp improvements.

  https://sourceware.org/ml/gdb-patches/2014-04/msg00210.html

Improve the regexp used in the memattr.exp test so allow for different
memory regions (.data / .bss) being laid out in different orders.

gdb/testsuite/ChangeLog:

* gdb.base/memattr.exp: Improve regexps to handle memory regions
appearing in any order.

10 years agoFix more fallout from TC_CONS_FIX_NEW change
Alan Modra [Wed, 16 Apr 2014 13:28:15 +0000 (22:58 +0930)] 
Fix more fallout from TC_CONS_FIX_NEW change

* config/tc-tilegx.h (TC_CONS_FIX_NEW): Add RELOC arg.
* config/tc-tilepro.h (TC_CONS_FIX_NEW): Likewise.

10 years agoMach-O: Add objdump -P dyld_info to dump dyld data.
Tristan Gingold [Fri, 11 Apr 2014 15:10:03 +0000 (17:10 +0200)] 
Mach-O: Add objdump -P dyld_info to dump dyld data.

include/mach-o/
* loader.h: Add macros for rebase, bind and export constants.

binutils/
* od-macho.c (OPT_DYLD_INFO): New macro.
(options): Add entry for dyld_info.
(mach_o_help): Likewise.
(load_and_dump, dump_dyld_info_rebase, dump_dyld_info_bind)
(dump_dyld_info_export_1, dump_dyld_info_export): New functions.
(bfd_mach_o_dyld_rebase_type_name): New array.
(export_info_data): New struct.
(dump_dyld_info): Add verbose argument.  Dump rebase, bind and
exports data.
(dump_load_command): Adjust dump_dyld_info call.
(mach_o_dump): Handle dyld_info.

10 years agoMach-O: improve objdump -P load output.
Tristan Gingold [Fri, 11 Apr 2014 13:27:10 +0000 (15:27 +0200)] 
Mach-O: improve objdump -P load output.

binutils/
* od-macho.c (dump_header): Display sizeofcmds in decimal too.
(dump_segment): Reformat output.
(dump_dyld_info): Also display end offsets.
(dump_load_command): Add IDX argument, display commands size
and offset, reformat display.
(dump_load_commands): Adjust for added argument.

10 years agoMach-O: add cpu and cpusubtype caps.
Tristan Gingold [Wed, 9 Apr 2014 08:12:45 +0000 (10:12 +0200)] 
Mach-O: add cpu and cpusubtype caps.

include/mach-o/
2014-04-16  Tristan Gingold  <gingold@adacore.com>

* loader.h (BFD_MACH_O_CPU_ARCH_MASK, BFD_MACH_O_CPU_ARCH_ABI64)
(BFD_MACH_O_CPU_SUBTYPE_MASK, BFD_MACH_O_CPU_SUBTYPE_LIB64): Define.

bfd/
2014-04-16  Tristan Gingold  <gingold@adacore.com>

* mach-o-x86-64.c (bfd_mach_o_x86_64_mkobject): Adjust cpusubtype
flag.

10 years agofill ppc476 fixup area
Alan Modra [Wed, 16 Apr 2014 02:17:13 +0000 (11:47 +0930)] 
fill ppc476 fixup area

Stops false positive warnings from scanner.

* elf32-ppc.c (ppc_elf_relocate_section): Fill 476 fixup area
with "ba 0" rather than zeros.

10 years agodaily update
Alan Modra [Wed, 16 Apr 2014 00:01:06 +0000 (09:31 +0930)] 
daily update

10 years ago * gdb.gdb/selftest.exp (do_steps_and_nexts): Don't reference
Doug Evans [Tue, 15 Apr 2014 23:11:32 +0000 (16:11 -0700)] 
* gdb.gdb/selftest.exp (do_steps_and_nexts): Don't reference
uninitialized value of "description".

10 years ago2014-04-15 Sasa Stankovic <Sasa.Stankovic@imgtec.com>
Cary Coutant [Tue, 15 Apr 2014 19:06:29 +0000 (12:06 -0700)] 
2014-04-15  Sasa Stankovic  <Sasa.Stankovic@imgtec.com>

elfcpp/
* mips.h (R _MIPS16_TLS_GD, R_MIPS16_TLS_LDM, R_MIPS16_TLS_DTPREL_HI16,
R_MIPS16_TLS_DTPREL_LO16, R_MIPS16_TLS_GOTTPREL,
R_MIPS16_TLS_TPREL_HI16, R_MIPS16_TLS_TPREL_LO16, R_MICROMIPS_26_S1,
R_MICROMIPS_HI16, R_MICROMIPS_LO16, R_MICROMIPS_GPREL16,
R_MICROMIPS_LITERAL, R_MICROMIPS_GOT16, R_MICROMIPS_PC7_S1,
R_MICROMIPS_PC10_S1, R_MICROMIPS_PC16_S1, R_MICROMIPS_CALL16,
R_MICROMIPS_GOT_DISP, R_MICROMIPS_GOT_PAGE, R_MICROMIPS_GOT_OFST,
R_MICROMIPS_GOT_HI16, R_MICROMIPS_GOT_LO16, R_MICROMIPS_SUB,
R_MICROMIPS_HIGHER, R_MICROMIPS_HIGHEST, R_MICROMIPS_CALL_HI16,
R_MICROMIPS_CALL_LO16, R_MICROMIPS_SCN_DISP, R_MICROMIPS_JALR,
R_MICROMIPS_HI0_LO16, R_MICROMIPS_TLS_GD, R_MICROMIPS_TLS_LDM,
R_MICROMIPS_TLS_DTPREL_HI16, R_MICROMIPS_TLS_DTPREL_LO16,
R_MICROMIPS_TLS_GOTTPREL, R_MICROMIPS_TLS_TPREL_HI16,
R_MICROMIPS_TLS_TPREL_LO16, R_MICROMIPS_GPREL7_S2,
R_MICROMIPS_PC23_S20, R_MIPS_EH): New enums for relocations (mips16 and
micromips).
(STO_MIPS_FLAGS): New enum constant.
(elf_st_is_mips16): New function.
(elf_st_is_micromips): New function.
(is_micromips): New function.
(abi_n32): New function.
(abi_n64): New function.
(ODK_NULL, ODK_REGINFO, ODK_EXCEPTIONS, ODK_PAD, ODK_HWPATCH, ODK_FILL,
ODK_TAGS, ODK_HWAND, ODK_HWOR, ODK_GP_GROUP, ODK_IDENT): New enum
constants.
* elfcpp.h (SHT_MIPS_OPTIONS): New enum constant.

10 years agoRemove unused globals in mi-simplerun.exp.
Keith Seitz [Tue, 15 Apr 2014 19:07:33 +0000 (12:07 -0700)] 
Remove unused globals in mi-simplerun.exp.

2014-04-15  Keith Seitz  <keiths@redhat.com>

* gdb.mi/mi-simplerun.exp (test_breakpoints_creation_and_listing):
Remove unused globals.
(test_running_the_program): Likewise.
(test_controlled_execution): Likewise.
(test_controlling_breakpoints): Likewise.
(test_program_termination): Likewise.

10 years agoAllow target to decide whether to include a section.
Cary Coutant [Tue, 15 Apr 2014 18:24:30 +0000 (11:24 -0700)] 
Allow target to decide whether to include a section.

2014-04-15  Sasa Stankovic  <Sasa.Stankovic@imgtec.com>

gold/
* layout.cc (Layout::include_section): Allow a target to decide
whether to include a section.
* target.h (Target::should_include_section): New function.
(Target::do_should_include_section): New function.

10 years agoAllow target to derive from Copy_relocs class.
Cary Coutant [Tue, 15 Apr 2014 18:19:18 +0000 (11:19 -0700)] 
Allow target to derive from Copy_relocs class.

2014-04-15  Sasa Stankovic  <Sasa.Stankovic@imgtec.com>

gold/
* copy-relocs.cc (Copy_relocs::Copy_reloc_entry::emit): Remove and
inline into ...
(Copy_relocs::emit): ... here.
* copy-relocs.h (Copy_reloc_entry): Change from class to struct.
(Copy_reloc_entry::make_copy_reloc): Change from private to protected.
(Copy_reloc_entry::entries_): Change from private to protected.

10 years agoTest suite cleanup.
Keith Seitz [Tue, 15 Apr 2014 18:47:57 +0000 (11:47 -0700)] 
Test suite cleanup.

2014-04-15  Keith Seitz  <keiths@redhat.com>

* gdb.mi/mi-break.exp (test_tbreak_creation_and_listing): Remove
unused globals.
(test_rbreak_creation_and_listing): Likewise.
(test_ignore_count): Likewise.
(test_error): Likewise.

10 years ago[AArch64] Fix off by one error in instruction relaxation mask.
Marcus Shawcroft [Tue, 15 Apr 2014 16:46:07 +0000 (17:46 +0100)] 
[AArch64] Fix off by one error in instruction relaxation mask.

The AArch64 TLSDESC to IE relaxation code uses a bit mask intended to
ensure that destination register in a relaxed ldr instruction is
always X0.  The mask has an off by one error resulting in the most
significant bit of the destination register being retained in the
relaxed instruction.  The issue generally appears when the compiler
emits TLS accesses code under high register pressure resulting in a
broken code sequence.

10 years agogdb.base/sym-file.exp, hide guts of the custom loader.
Pedro Alves [Tue, 15 Apr 2014 13:02:34 +0000 (14:02 +0100)] 
gdb.base/sym-file.exp, hide guts of the custom loader.

This test uses a simple custom elf loader, implemented in
gdb.base/sym-file-loader.h|c.  This loader doesn't have a dlclose-like
function today, but I'll need one.  But, I found that the guts of the
loader are exposed too much to the client, making the interface more
complicated than necessary.  It's simpler if the loader just exports a
few dlopen/dlsym -style functions.  That's what this patch does.

Tested on x86_86 Fedora 17, native and gdbserver.

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

* gdb.base/sym-file-loader.h: Move inclusion of <inttypes.h>,
<ansidecl.h>, <elf/common.h> and <elf/external.h> to
sym-file-loader.c.
(Elf_External_Phdr, Elf_External_Ehdr, Elf_External_Shdr)
(Elf_External_Sym, Elf_Addr, GET, GETADDR, struct segment): Move
to sym-file-loader.c.
(struct library): Forward declare.
(load_shlib, lookup_function): Change prototypes.
(find_shstrtab, find_strtab, find_shdr, find_symtab)
(translate_offset): Remove declarations.
(get_text_addr): New declaration.
* gdb.base/sym-file-loader.c: Move inclusion of <inttypes.h>,
<ansidecl.h>, <elf/common.h> and <elf/external.h> here from
sym-file-loader.h.
(Elf_External_Phdr, Elf_External_Ehdr, Elf_External_Shdr)
(Elf_External_Sym, Elf_Addr, GET, GETADDR, struct segment): Move
here from sym-file-loader.h.
(struct library): New structure.
(load_shlib, lookup_function): Change prototypes and adjust to
work with a struct library.
(find_shstrtab, find_strtab, find_shdr, find_symtab)
(translate_offset): Make static.
(get_text_addr): New function.
* gdb.base/sym-file-main.c (main): Adjust to new loader interface.

10 years agogdb.base/sym-file-loader.c: Fix typo.
Pedro Alves [Tue, 15 Apr 2014 13:13:08 +0000 (14:13 +0100)] 
gdb.base/sym-file-loader.c: Fix typo.

SELF_LINK, not SELK_LINK...

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

* gdb.base/sym-file-loader.c: Fix typo.  SELF_LINK, not SELK_LINK.

10 years agoMake sym-file.exp work with remote targets and hosts.
Pedro Alves [Mon, 14 Apr 2014 16:23:55 +0000 (17:23 +0100)] 
Make sym-file.exp work with remote targets and hosts.

The main issue here is that this test passes the host's absolute path
to the library to load to the "dlopen"-like routine, which doesn't
work when either the target or the host are remote, unless a shared
filesystem has been set up.

Tests that dynamically load a library solve this by dlopen'ing by
basename, and setting rpath to $ORIGIN.  See gdb_compile.

This test doesn't use dlopen, but instead uses its own simple elf
loader.  The fix is to pass this loader the library basename, and
teach it to look up the library by basename in the executable's
directory as well, i.e., assuming/emulating RPATH=$ORIGIN.

Tested on x86_64 Fedora 17, native and gdbserver.

I looked around in the web to figure out Linux's /proc/self/exe
equivalents in other ELF OSs.  I think I covered all relevant, but if
not, I think it'll be simple enough to add more.  (Note the test is
skipped on non-ELF targets.)

Tested on x86_64 Fedora 17, native and gdbserver.

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

* gdb.base/sym-file-loader.c: Include <limits.h>.
(SELF_LINK): New define.
(get_origin): New function.
(load_shlib): Use it.
* gdb.base/sym-file.exp: Don't early return if the target is
remote.  Use runto_main, and issue fail is that fails.  Use
gdb_load_shlibs.
(shlib_name): Delete.
(lib_so, lib_syms, lib_dlopen): New globals.  Use them throughout.

10 years agogdb.base/sym-file.exp: clean up test messages a bit.
Pedro Alves [Tue, 15 Apr 2014 11:49:51 +0000 (12:49 +0100)] 
gdb.base/sym-file.exp: clean up test messages a bit.

Remove regex characters from test message, and don't refer to
breakpoint numbers in test messages (subsequent patches will add more
breakpoints, changing these numbers).  Result:

 -PASS: gdb.base/sym-file.exp: add-symbol-file .*sym-file-lib\.so addr
 +PASS: gdb.base/sym-file.exp: add-symbol-file sym-file-lib.so addr

 -PASS: gdb.base/sym-file.exp: check if Breakpoint 2 is pending.
 -PASS: gdb.base/sym-file.exp: check if Breakpoint 3 is pending.
 +PASS: gdb.base/sym-file.exp: breakpoint at foo is pending
 +PASS: gdb.base/sym-file.exp: breakpoint at bar is pending

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

* gdb.base/sym-file.exp: Remove regex characters from test
message.  Don't refer to breakpoint numbers in test messages.

10 years agodaily update
Alan Modra [Tue, 15 Apr 2014 00:00:44 +0000 (09:30 +0930)] 
daily update

10 years agoRemove symbol_matches_domain. This fixes
Keith Seitz [Mon, 14 Apr 2014 22:47:15 +0000 (15:47 -0700)] 
Remove symbol_matches_domain. This fixes
PR c++/16253.

symbol_matches_domain was permitting searches for a VAR_DOMAIN
symbol to also match STRUCT_DOMAIN symbols for languages like C++
where STRUCT_DOMAIN symbols also define a typedef of the same name,
e.g., "struct foo {}" introduces a typedef of the name "foo".

Problems occur if there exists both a VAR_DOMAIN and STRUCT_DOMAIN
symbol of the same name. Then it is essentially a race between which
symbol is found first. The other symbol is obscurred.
[This is a relatively common idiom: enum e { ... } e;]

This patchset moves this "language defines a typedef" logic to
lookup_symbol[_in_language], looking first for a symbol in the given
domain and falling back to searching STRUCT_DOMAIN when/if appropriate.

2014-04-14  Keith Seitz  <keiths@redhat.com>

PR c++/16253
* ada-lang.c (ada_symbol_matches_domain): Moved here and renamed
from symbol_matches_domain in symtab.c. All local callers
of symbol_matches_domain updated.
(standard_lookup): If DOMAIN is VAR_DOMAIN and no symbol is found,
search STRUCT_DOMAIN.
(ada_find_any_type_symbol): Do not search STRUCT_DOMAIN
independently.  standard_lookup will do that automatically.
* cp-namespace.c (cp_lookup_symbol_nonlocal): Explain when/why
VAR_DOMAIN searches may return a STRUCT_DOMAIN match.
(cp_lookup_symbol_in_namespace): Likewise.
If no VAR_DOMAIN symbol is found, search STRUCT_DOMAIN.
(cp_lookup_symbol_exports): Explain when/why VAR_DOMAIN searches
may return a STRUCT_DOMAIN match.
(lookup_symbol_file): Search for the class name in STRUCT_DOMAIN.
* cp-support.c: Include language.h.
(inspect_type): Explicitly search STRUCT_DOMAIN before searching
VAR_DOMAIN.
* psymtab.c (match_partial_symbol): Compare the requested
domain with the symbol's domain directly.
(lookup_partial_symbol): Likewise.
* symtab.c (lookup_symbol_in_language): Explain when/why
VAR_DOMAIN searches may return a STRUCT_DOMAIN match.
If no VAR_DOMAIN symbol is found, search STRUCT_DOMAIN for
appropriate languages.
(symbol_matches_domain): Renamed `ada_symbol_matches_domain'
and moved to ada-lang.c
(lookup_block_symbol): Explain that this function only returns
symbol matching the requested DOMAIN.
Compare the requested domain with the symbol's domain directly.
(iterate_over_symbols): Compare the requested domain with the
symbol's domain directly.
* symtab.h (symbol_matches_domain): Remove.

2014-04-14  Keith Seitz  <keiths@redhat.com>

PR c++/16253
* gdb.cp/var-tag.cc: New file.
* gdb.cp/var-tag.exp: New file.
* gdb.dwarf2/dw2-ada-ffffffff.exp: Set the language to C++.
* gdb.dwarf2/dw2-anon-mptr.exp: Likewise.
* gdb.dwarf2/dw2-double-set-die-type.exp: Likewise.
* gdb.dwarf2/dw2-inheritance.exp: Likewise.

10 years agoimplement support for "enum class"
Tom Tromey [Thu, 27 Mar 2014 18:24:27 +0000 (12:24 -0600)] 
implement support for "enum class"

This adds support for the C++11 "enum class" feature.  This is
PR c++/15246.

I chose to use the existing TYPE_DECLARED_CLASS rather than introduce
a new type code.  This seemed both simple and clear to me.

I made overloading support for the new enum types strict.  This is how
it works in C++; and it didn't seem like an undue burden to keep this,
particularly because enum constants are printed symbolically by gdb.

Built and regtested on x86-64 Fedora 20.

2014-04-14  Tom Tromey  <tromey@redhat.com>

PR c++/15246:
* c-exp.y (type_aggregate_p): New function.
(qualified_name, classify_inner_name): Use it.
* c-typeprint.c (c_type_print_base): Handle TYPE_DECLARED_CLASS
and TYPE_TARGET_TYPE of an enum type.
* dwarf2read.c (read_enumeration_type): Set TYPE_DECLARED_CLASS on
an enum type.
(determine_prefix) <case DW_TAG_enumeration_type>: New case;
handle TYPE_DECLARED_CLASS.
* gdbtypes.c (rank_one_type): Handle TYPE_DECLARED_CLASS on enum
types.
* gdbtypes.h (TYPE_DECLARED_CLASS): Update comment.
* valops.c (enum_constant_from_type): New function.
(value_aggregate_elt): Use it.
* cp-namespace.c (cp_lookup_nested_symbol): Handle
TYPE_CODE_ENUM.

2014-04-14  Tom Tromey  <tromey@redhat.com>

* gdb.cp/classes.exp (test_enums): Handle underlying type.
* gdb.dwarf2/enum-type.exp: Add test for enum with underlying
type.
* gdb.cp/enum-class.exp: New file.
* gdb.cp/enum-class.cc: New file.

10 years agoconstify value_aggregate_elt
Tom Tromey [Thu, 27 Mar 2014 18:16:38 +0000 (12:16 -0600)] 
constify value_aggregate_elt

While working on another patch I realized that value_aggregate_elt's
"name" parameter ought to be const.  This patch implements this.

2014-04-14  Tom Tromey  <tromey@redhat.com>

* valops.c (value_aggregate_elt, value_struct_elt_for_reference)
(value_namespace_elt, value_maybe_namespace_elt): Make "name"
const.
* value.h (value_aggregate_elt): Update.

10 years agohandle DW_AT_type on an enumeration
Tom Tromey [Wed, 26 Mar 2014 14:54:56 +0000 (08:54 -0600)] 
handle DW_AT_type on an enumeration

DWARF allows an enumeration type to have a DW_AT_type.  GDB doesn't
recognize this, but there is a patch to change GCC to emit it, and a
DWARF proposal to further allow an enum type with a DW_AT_type to omit
the DW_AT_byte_size.  This patch changes gdb to implement this.

Built and regtested on x86-64 Fedora 20.

2014-04-14  Tom Tromey  <tromey@redhat.com>

* dwarf2read.c (read_enumeration_type): Handle DW_AT_type.

2014-04-14  Tom Tromey  <tromey@redhat.com>

* gdb.dwarf2/enum-type.exp: New file.

10 years agotest: add mi vla test
Sanimir Agovic [Fri, 15 Nov 2013 12:48:00 +0000 (12:48 +0000)] 
test: add mi vla test

testsuite/ChangeLog:

* gdb.mi/mi-vla-c99.exp: New file.
* gdb.mi/vla.c: New file.

10 years agotest: basic c99 vla tests for C primitives
Sanimir Agovic [Fri, 15 Nov 2013 12:47:47 +0000 (12:47 +0000)] 
test: basic c99 vla tests for C primitives

gdb/testsuite/ChangeLog:

* gdb.base/vla-datatypes.c: New file.
* gdb.base/vla-datatypes.exp: New file.

10 years agotest: evaluate pointers to C99 vla correctly.
Sanimir Agovic [Fri, 15 Nov 2013 12:47:44 +0000 (12:47 +0000)] 
test: evaluate pointers to C99 vla correctly.

gdb/testsuite/ChangeLog:

* gdb.base/vla-ptr.c: New file.
* gdb.base/vla-ptr.exp: New file.

10 years agotest: cover subranges with present DW_AT_count attribute
Sanimir Agovic [Tue, 26 Nov 2013 14:47:16 +0000 (14:47 +0000)] 
test: cover subranges with present DW_AT_count attribute

The dwarf attribute DW_AT_count specifies the elements of a subrange.
This test covers subranges with present count but absent upper bound
attribute, both with static and dynamic attribute values.

testsuite/ChangeLog:

* gdb.dwarf2/count.exp: New file.

10 years agovla: evaluate operand of sizeof if its type is a vla
Sanimir Agovic [Wed, 5 Feb 2014 16:22:08 +0000 (16:22 +0000)] 
vla: evaluate operand of sizeof if its type is a vla

The c99 standard in "6.5.3.4 The sizeof operator" states:

 If the type of the operand is a variable length array type, the operand
 is evaluated;[...]

This patch mirrors the following c99 semantic in gdb:

 1| int vla[n][m];
 2| int i = 1;
 3| sizeof(vla[i++][0]); // No sideffect
 4| assert (i == 1);
 5| sizeof(vla[i++]);    // With sideffect
 6| assert (i == 2);

Note: ptype/whatis still do not allow any sideeffects.

This patch was motivated by:

  https://sourceware.org/ml/gdb-patches/2014-01/msg00732.html

gdb/ChangeLog:

* eval.c (evaluate_subexp_for_sizeof): Add enum noside argument.
(evaluate_subexp_standard): Pass noside argument.
(evaluate_subexp_for_sizeof) <BINOP_SUBSCRIPT>: Handle subscript case
if noside equals EVAL_NORMAL. If the subscript yields a vla type
re-evaluate subscript operation with EVAL_NORMAL to enable sideffects.
* gdbtypes.c (resolve_dynamic_bounds): Mark bound as evaluated.
* gdbtypes.h (enum range_flags): Add RANGE_EVALUATED case.

testsuite/ChangeLog:

* gdb.base/vla-sideeffect.c: New file.
* gdb.base/vla-sideeffect.exp: New file.

10 years agovla: resolve dynamic bounds if value contents is a constant byte-sequence
Sanimir Agovic [Tue, 26 Nov 2013 14:35:43 +0000 (14:35 +0000)] 
vla: resolve dynamic bounds if value contents is a constant byte-sequence

A variable location might be a constant value and therefore no inferior memory
access is needed to read the content. In this case try to resolve the type
bounds.

gdb/ChangeLog:

* findvar.c (default_read_var_value): Resolve dynamic bounds if location
points to a constant blob.

10 years agovla: support for DW_AT_count
Sanimir Agovic [Tue, 19 Nov 2013 12:54:24 +0000 (12:54 +0000)] 
vla: support for DW_AT_count

This patch adds support for DW_AT_count as requested in the code review:

  https://sourceware.org/ml/gdb-patches/2013-11/msg00200.html

gdb/ChangeLog:

* dwarf2read.c (read_subrange_type): Convert DW_AT_count to a dynamic
property and store it as the high bound and flag the range accordingly.
* gdbtypes.c (resolve_dynamic_bounds): If range is flagged as
RANGE_UPPER_BOUND_IS_COUNT assign low + high - 1 as the new high bound.
* gdbtypes.h (enum range_flags): New enum.
(struct range_bounds): Add flags member.

10 years agovla: print "variable length" for unresolved dynamic bounds
Sanimir Agovic [Thu, 14 Nov 2013 09:55:52 +0000 (09:55 +0000)] 
vla: print "variable length" for unresolved dynamic bounds

1| void foo (size_t n) {
2|   int vla[n];
3| }

Given the following expression

  (gdb) ptype &vla

Gdb evaluates the expression with EVAL_AVOID_SIDE_EFFECTS and thus
does not resolve the bounds information and misinterprets the high
bound as a constant. The current output is:

  type = int (*)[1289346]

this patch deals with this case and prints:

  type = int (*)[variable length]

instead.

gdb/ChangeLog:

* c-typeprint.c (c_type_print_varspec_suffix): Added
check for not yet resolved high bound. If unresolved, print
"variable length" string to the console instead of random
length.

10 years agovla: update type from newly created value
Sanimir Agovic [Mon, 14 Oct 2013 07:36:13 +0000 (08:36 +0100)] 
vla: update type from newly created value

Constructing a value based on a type and address might change the type
of the newly constructed value. Thus re-fetch type via value_type to ensure
we have the correct type at hand.

gdb/ChangeLog

* ada-lang.c (ada_value_primitive_packed_val): Re-fetch type from value.
(ada_template_to_fixed_record_type_1): Likewise.
(ada_to_fixed_type_1): Likewise.
* cp-valprint.c (cp_print_value_fields_rtti): Likewise.
(cp_print_value): Likewise.
* d-valprint.c (dynamic_array_type): Likewise.
* findvar.c (address_of_variable): Likewise.
* jv-valprint.c (java_value_print): Likewise.
* valops.c (value_ind): Likewise.
* value.c (coerce_ref): Likewise.

10 years agovla: enable sizeof operator for indirection
Sanimir Agovic [Sat, 12 Oct 2013 11:36:16 +0000 (12:36 +0100)] 
vla: enable sizeof operator for indirection

This patch enables the sizeof operator for indirections:

1| void foo (size_t n) {
2|   int vla[n];
3|   int *vla_ptr = &vla;
4| }

(gdb) p sizeof(*vla_ptr)

yields sizeof (size_t) * n.

gdb/ChangeLog:

* eval.c (evaluate_subexp_for_sizeof) <UNOP_IND>: Create an indirect
value and retrieve the dynamic type size.

10 years agovla: enable sizeof operator to work with variable length arrays
Sanimir Agovic [Wed, 9 Oct 2013 14:28:22 +0000 (15:28 +0100)] 
vla: enable sizeof operator to work with variable length arrays

In C99 the sizeof operator computes the size of a variable length array
at runtime (6.5.3.4 The sizeof operator). This patch reflects the semantic
change in the debugger.

We now are able to get the size of a vla:

1| void foo (size_t n) {
2|   int vla[n];
3| }

(gdb) p sizeof(vla)

yields N * sizeof(int).

gdb/ChangeLog:

* eval.c (evaluate_subexp_for_sizeof) <OP_VAR_VALUE>: If the type
passed to sizeof is dynamic evaluate the argument to compute the length.

10 years agotype: add c99 variable length array support
Sanimir Agovic [Wed, 9 Oct 2013 14:28:22 +0000 (15:28 +0100)] 
type: add c99 variable length array support

The dwarf standard allow certain attributes to be expressed as dwarf
expressions rather than constants. For instance upper-/lowerbound attributes.
In case of a c99 variable length array the upperbound is a dynamic attribute.

With this change c99 vla behave the same as with static arrays.

1| void foo (size_t n) {
2|   int ary[n];
3|   memset(ary, 0, sizeof(ary));
4| }

(gdb) print ary
$1 = {0 <repeats 42 times>}

gdb/ChangeLog:

* dwarf2loc.c (dwarf2_locexpr_baton_eval): New function.
(dwarf2_evaluate_property): New function.
* dwarf2loc.h (dwarf2_evaluate_property): New function prototype.
* dwarf2read.c (attr_to_dynamic_prop): New function.
(read_subrange_type): Use attr_to_dynamic_prop to read high bound
attribute.
* gdbtypes.c: Include dwarf2loc.h.
(is_dynamic_type): New function.
(resolve_dynamic_type): New function.
(resolve_dynamic_bounds): New function.
(get_type_length): New function.
(check_typedef): Use get_type_length to compute type length.
* gdbtypes.h (TYPE_HIGH_BOUND_KIND): New macro.
(TYPE_LOW_BOUND_KIND): New macro.
(is_dynamic_type): New function prototype.
* value.c (value_from_contents_and_address): Call resolve_dynamic_type
to resolve dynamic properties of the type. Update comment.
* valops.c (get_value_at, value_at, value_at_lazy): Update comment.

10 years agoAdd return value for non-void function return statements to fix error in clang build.
David Blaikie [Sat, 12 Apr 2014 00:20:49 +0000 (17:20 -0700)] 
Add return value for non-void function return statements to fix error in clang build.

Clang defaults this warning to an error, breaking the build & causing
these tests not to run.

gdb/testsuite/

* gdb.mi/non-stop.c: Add return value for non-void function return
statement.
* gdb.threads/staticthreads.c: Ditto.

10 years agoFix typo in _initialize_alpha_linux_nat prototype
Richard Henderson [Mon, 14 Apr 2014 15:30:56 +0000 (08:30 -0700)] 
Fix typo in _initialize_alpha_linux_nat prototype

* alpha-linux-nat.c (_initialize_alpha_linux_nat): Fix prototype.

10 years agoppc476 plt call stubs
Alan Modra [Mon, 14 Apr 2014 02:18:06 +0000 (11:48 +0930)] 
ppc476 plt call stubs

Fuss over bctr in call stubs.

* elf32-ppc.c (BA): Define
(ppc_elf_link_hash_table_create): Correct default_params.
(write_glink_stub): Pad small plt call stub with "ba 0" rather
than "nop" for ppc476_workaround.
(ppc_elf_finish_dynamic_sections): Likewise for branch table
and __glink_PLTresolve.  Ensure plt call stub at end of page
doesn't allow fall-thru prefetch.

10 years agodaily update
Alan Modra [Mon, 14 Apr 2014 00:00:41 +0000 (09:30 +0930)] 
daily update

10 years agodaily update
Alan Modra [Sun, 13 Apr 2014 00:00:41 +0000 (09:30 +0930)] 
daily update

10 years agoCopy over fix for fetching dynamic type of a reference from python side.
Doug Evans [Sat, 12 Apr 2014 16:09:41 +0000 (09:09 -0700)] 
Copy over fix for fetching dynamic type of a reference from python side.

* guile/scm-value.c (gdbscm_value_dynamic_type): Use coerce_ref to
dereference TYPE_CODE_REF values.

testsuite/
* gdb.guile/scm-value.c: Improve test case.
* gdb.guile/scm-value.exp: Add new test.

10 years agoCompile inline test with -std=gnu89 explicitly to override Clang's default (-std...
David Blaikie [Fri, 11 Apr 2014 19:45:37 +0000 (12:45 -0700)] 
Compile inline test with -std=gnu89 explicitly to override Clang's default (-std=c99)

gdb/testsuite/
* gdb.opt/inline-break.exp: Explicitly specify -std=gnu89 to
override Clang's default.

10 years agodaily update
Alan Modra [Sat, 12 Apr 2014 00:00:56 +0000 (09:30 +0930)] 
daily update

10 years agogdb/testsuite/ChangeLog: Fix path to a few files in previous entries.
Joel Brobecker [Fri, 11 Apr 2014 22:28:08 +0000 (15:28 -0700)] 
gdb/testsuite/ChangeLog: Fix path to a few files in previous entries.

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