deliverable/binutils-gdb.git
10 years ago * gdb.base/callfuncs.c (main): Assign malloc's return value
Luis Machado [Wed, 27 Nov 2013 12:39:26 +0000 (10:39 -0200)] 
* gdb.base/callfuncs.c (main): Assign malloc's return value
and free it afterwards.
* gdb.base/charset-malloc.c (malloc_stub): Likewise.
* gdb.base/printcmds.c (main): Likewise.
* gdb.base/randomize.c (main): Free "p" and change breakpoint
marker position.
* gdb.base/setvar.c (dummy): Assign malloc's return value
and free it afterwards.

10 years agoImprove dump of xdata/pdata on x86_64.
Tristan Gingold [Thu, 21 Nov 2013 11:00:48 +0000 (12:00 +0100)] 
Improve dump of xdata/pdata on x86_64.

bfd/
2013-11-27  Tristan Gingold  <gingold@adacore.com>

* pei-x86_64.c (pex_regs): Make it const.  Add comments.
(pex64_get_runtime_function): Do not split UnwindData.
(pex64_get_unwind_info): Extract the chain and the handler.
(pex64_xdata_print_uwd_codes): Rewritten: do not reverse print
the opcode, handle version 2, add consistency check, make the
code host neutral.
(pex64_dump_xdata): Change arguments to pass the section and its
content.  Handle version 2, change output.
(pex64_bfd_print_pdata): Add comments, load section for xdata.
Avoid duplicate outputs.

include/coff
2013-11-27  Tristan Gingold  <gingold@adacore.com>

* pe.h (struct pex64_runtime_function): Remove isChained.
(UWOP_SAVE_XMM): Add comment.
(struct pex64_unwind_info): Remove extra fields.

10 years agobinutils/testsuite/
Richard Sandiford [Wed, 27 Nov 2013 09:11:06 +0000 (09:11 +0000)] 
binutils/testsuite/
2013-11-27  Matthew Fortune <matthew.fortune@imgtec.com>

* binutils-all/objcopy.exp: Consider mips-mti-elf the same as
mips-sde-elf
* binutils-all/readelf.exp: Likewise

gas/testsuite/
2013-11-27  Matthew Fortune <matthew.fortune@imgtec.com>

* gas/mips/mips.exp: Consider mips-mti-elf the same as mips-sde-elf

ld/testsuite/
2013-11-27  Matthew Fortune <matthew.fortune@imgtec.com>

* ld-mips-elf/mips-elf.exp: Consider mips-mti-elf the same as
mips-sde-elf

10 years agodaily update
Alan Modra [Tue, 26 Nov 2013 23:00:01 +0000 (09:30 +1030)] 
daily update

10 years agoFix a typo
H.J. Lu [Tue, 26 Nov 2013 19:25:25 +0000 (11:25 -0800)] 
Fix a typo

10 years agoAdd HOSTING_SLIBS and use it for -pie
H.J. Lu [Tue, 26 Nov 2013 19:17:08 +0000 (11:17 -0800)] 
Add HOSTING_SLIBS and use it for -pie

ld/

PR ld/16259
* Makefile.am (HOSTING_SLIBS): New.
* configure.host (HOSTING_SLIBS): New.  Used for PIE.
* configure.in (HOSTING_SLIBS): New AC_SUBST.
* Makefile.in: Regenerated.
* configure: Likewise.

ld/testsuite/

PR ld/16259
* config/default.exp (get_target_emul): Also set HOSTING_SLIBS.
* lib/ld-lib.exp (default_ld_link): Use HOSTING_SLIBS for -pie.

10 years agoTighten regexp in gdb.base/setshow.exp
Andrew Burgess [Tue, 26 Nov 2013 16:28:33 +0000 (16:28 +0000)] 
Tighten regexp in gdb.base/setshow.exp

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

gdb/testsuite/ChangeLog

* gdb.base/setshow.exp: Add $gdb_prompt to the patterns in
gdb_test_multiple.

10 years agoFix demangler to handle conversion operators correctly.
ccoutant [Fri, 22 Nov 2013 22:25:49 +0000 (22:25 +0000)] 
Fix demangler to handle conversion operators correctly.

libiberty/
PR other/59195
* cp-demangle.c (struct d_info_checkpoint): New struct.
(struct d_print_info): Add current_template field.
(d_operator_name): Set flag when processing a conversion
operator.
(cplus_demangle_type): When processing <template-args> for
a conversion operator, backtrack if necessary.
(d_expression_1): Renamed from d_expression.
(d_expression): New wrapper around d_expression_1.
(d_checkpoint): New function.
(d_backtrack): New function.
(d_print_init): Initialize current_template.
(d_print_comp): Set current_template.
(d_print_cast): Put current_template in scope for
printing conversion operator name.
(cplus_demangle_init_info): Initialize is_expression and
is_conversion.
* cp-demangle.h (struct d_info): Add is_expression and
is_conversion fields.
* testsuite/demangle-expected: New test cases.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@205292 138bc75d-0d04-0410-961f-82ee72b054a4

10 years agoMark entirely optimized out value as non-lazy.
Andrew Burgess [Tue, 26 Nov 2013 16:21:53 +0000 (16:21 +0000)] 
Mark entirely optimized out value as non-lazy.

If a value is entirely optimized out, then there's nothing for
value_fetch_lazy to fetch.  Sequences like:

 if (value_lazy (retval))
   value_fetch_lazy (retval);

End up allocating the value contents buffer, wasting memory, for no
use.

gdb/ChangeLog
2013-11-26  Andrew Burgess  <aburgess@broadcom.com>

* value.c (allocate_optimized_out_value): Mark value as non-lazy.

10 years agobfd/elfnn-aarch64.c: Handle static links with ifunc correctly.
Will Newton [Mon, 25 Nov 2013 14:44:59 +0000 (14:44 +0000)] 
bfd/elfnn-aarch64.c: Handle static links with ifunc correctly.

The code for handling GOT references to ifunc symbols in static links
was missing.

bfd/ChangeLog:

2013-11-26  Will Newton  <will.newton@linaro.org>

* elfnn-aarch64.c (elfNN_aarch64_finish_dynamic_symbol):
Handle STT_GNU_IFUNC symbols correctly in static links.

ld/testsuite/ChangeLog:

2013-11-26  Will Newton  <will.newton@linaro.org>

* ld-aarch64/aarch64-elf.exp: Add ifunc-22.
* ld-aarch64/ifunc-22.d: New file.
* ld-aarch64/ifunc-22.s: Likewise.

10 years agobfd/elfnn-aarch64.c: Fix miscalculation of GOTPLT offset for ifunc syms.
Will Newton [Mon, 25 Nov 2013 11:07:07 +0000 (11:07 +0000)] 
bfd/elfnn-aarch64.c: Fix miscalculation of GOTPLT offset for ifunc syms.

The .got.plt header size was not being correctly taken into account
when calculating the offset for relocations against ifunc symbols.

bfd/ChangeLog:

2013-11-26  Will Newton  <will.newton@linaro.org>

* elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Ensure
PLT_INDEX is calculated using correct header size.

ld/testsuite/ChangeLog:

2013-11-26  Will Newton  <will.newton@linaro.org>

* ld-aarch64/aarch64-elf.exp: Add ifunc-21 test.
* ld-aarch64/ifunc-21.d: New file.
* ld-aarch64/ifunc-21.s: Likewise.

10 years agorevert patch from 2013-11-22
Tom Tromey [Tue, 26 Nov 2013 14:47:56 +0000 (07:47 -0700)] 
revert patch from 2013-11-22

This reverts da2b2fdf57a96f7a5b6b153e94afb747e212b17f and some
follow-up patches.  They were incorrect.

2013-11-26  Tom Tromey  <tromey@redhat.com>

* dwarf2-frame.c (dwarf2_frame_cache): Revert patch from
2013-11-22.

2013-11-26  Tom Tromey  <tromey@redhat.com>

* gdb.dwarf2/dw2-unspecified-ret-addr.S: Remove.
* gdb.dwarf2/dw2-unspecified-ret-addr.c: Remove.
* gdb.dwarf2/dw2-unspecified-ret-addr.exp: Remove.

10 years agoFix PR16193 - gdbserver aborts.
Walfred Tedeschi [Tue, 26 Nov 2013 08:32:16 +0000 (08:32 +0000)] 
Fix PR16193 - gdbserver aborts.

The MPX patch has broken the I386_XSTATE_SIZE macro.  For AVX machines,
it ends up returning I386_XSTATE_SSE_SIZE.  Where it first reads
I386_XSTATE_AVX_SIZE, it should have read I386_XSTATE_AVX:

 #define I386_XSTATE_SIZE(XCR0) \
     (((XCR0) & I386_XSTATE_BNDCFG) != 0 ? I386_XSTATE_BNDCFG_SIZE \
        : (((XCR0) & I386_XSTATE_BNDREGS) != 0 ? I386_XSTATE_BNDCFG_SIZE \
 -       : (((XCR0) & I386_XSTATE_AVX_SIZE) != 0 ? I386_XSTATE_AVX_SIZE \
 +       : (((XCR0) & I386_XSTATE_AVX) != 0 ? I386_XSTATE_AVX_SIZE \
        : I386_XSTATE_SSE_SIZE)))

The patch goes a step further and improves readability of the macro,
by adding a couple other auxiliary macros.

2013-11-26  Walfred Tedeschi  <walfred.tedeschi@intel.com>

* i386-xstate.h (I386_XSTATE_MPX): New Macro.
(I386_XSTATE_MPX_MASK): Makes use of I386_XSTATE_MPX.
(HAS_MPX): New macro.
(HAS_AVX): New macro.
(I386_XSTATE_SIZE): Uses HAS_MPX and HAS_AVX.

10 years agodaily update
Alan Modra [Mon, 25 Nov 2013 23:00:01 +0000 (09:30 +1030)] 
daily update

10 years agoPR c++/14819: Explicit class:: inside class scope does not work
Keith Seitz [Mon, 25 Nov 2013 21:37:08 +0000 (13:37 -0800)] 
PR c++/14819:  Explicit class:: inside class scope does not work

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

10 years ago2013-11-25 Steve Ellcey <sellcey@mips.com>
Steve Ellcey [Mon, 25 Nov 2013 21:31:43 +0000 (13:31 -0800)] 
2013-11-25  Steve Ellcey  <sellcey@mips.com>

* igen/Makefile.in (igen): Use BUILD_CFLAGS in link.

10 years agoGDB perf test on backtrace
Yao Qi [Fri, 25 Oct 2013 08:12:20 +0000 (16:12 +0800)] 
GDB perf test on backtrace

gdb/testsuite/

2013-11-25  Yao Qi  <yao@codesourcery.com>

* gdb.perf/backtrace.c: New.
* gdb.perf/backtrace.exp: New.
* gdb.perf/backtrace.py: New.

10 years agodaily update
Alan Modra [Sun, 24 Nov 2013 23:00:01 +0000 (09:30 +1030)] 
daily update

10 years agoUse target_read_code in disassemble.
Yao Qi [Fri, 1 Nov 2013 04:28:54 +0000 (12:28 +0800)] 
Use target_read_code in disassemble.

This patch teaches "disassembly" use code cache mechanism to read
target code.

gdb:

2013-11-24  Yao Qi  <yao@codesourcery.com>

* disasm.c (dis_asm_read_memory): Call target_read_code
instead of target_read_memory.

10 years agoset/show code-cache
Yao Qi [Fri, 1 Nov 2013 04:26:10 +0000 (12:26 +0800)] 
set/show code-cache

Similar to stack cache, in this patch, we add
TARGET_OBJECT_CODE_MEMORY to read code from target and add a new
option "set code-cache on|off" to optimize code accesses by
using the target memory cache.

In V4:
 - Remove "without affecting correctness" from NEWS and doc.
 - Replace "ON" with "on" in doc.
 - "access" -> "accesses".

In V3:
 - Rename functions and variables.
 - Update command help, doc and NEWS entry.
 - Invalidate cache on option transitions, to align with
   the behaviour of "stack-cache".  Since cache invalidation is
   transparent to users, users don't know option "stack-cache"
   transitions cause code cache invalidation.

V2 was reviewed by Doug.  There are some changes in V3, so I post it
here.

gdb:

2013-11-24  Yao Qi  <yao@codesourcery.com>

* NEWS: Add note on new "set code-cache" option.
* target-dcache.c (code_cache_enabled_1): New variable.
(code_cache_enabled): New variable.
(show_code_cache, set_code_cache): New function.
(code_cache_enabled_p): New function.
(_initialize_target_dcache): Register command.
* target-dcache.h (code_cache_enabled_p): Declare.
* target.c (memory_xfer_partial_1):Handle
TARGET_OBJECT_CODE_MEMORY and code_cache_enabled.
(target_read_code): New function.
* target.h (enum target_object) <TARGET_OBJECT_CODE_MEMORY>:
New.
(target_read_code): Declare.

gdb/doc:

2013-11-24  Yao Qi  <yao@codesourcery.com>

* gdb.texinfo (Caching Remote Data): Document new
"set/show stack-cache" option.

10 years agoRenaming in target-dcache.c
Yao Qi [Wed, 20 Nov 2013 08:21:47 +0000 (16:21 +0800)] 
Renaming in target-dcache.c

Hi,
This patch does some renamings on "stack-cache" related functions and
variables.

In the review to "code cache" series v2, we have some discussions on the
name of predicate function 'stack_cache_enabled', and have some options,

 1 keep it unchanged, as it is already a predicate clearly,
 2 rename it to stack_cache_enabled_p,
 3 rename it to enable_stack_cache_p,

I choose #2, because 'stack_cache_enabled' is a predicate, but
it's better to add "_p" suffix to stress this.  There are some other
similar patterns used in GDB source, such as unop_user_defined_p
and agent_loaded_p.

Then, I have to rename variable stack_cache_enabled_p to something
else.  The option is "stack-cache", so I'd like to name the variable
associated with this command as "stack_cache".  Similarly, the commands
associated with this command should be renamed to "set_stack_cache"
and "show_stack_cache" respectively.

gdb:

2013-11-24  Yao Qi  <yao@codesourcery.com>

* target-dcache.c (stack_cache_enabled_p_1): Rename to ...
(stack_cache_enabled_1): ... this.  New variable.
(stack_cache_enabled_p): Rename to ...
(stack_cache_enabled): ... this.  New variable.
(set_stack_cache_enabled_p): Rename to ...
(set_stack_cache): ... this.  Update caller.
(show_stack_cache_enabled_p): Rename to ...
(show_stack_cache): ... this.  Update caller.
(stack_cache_enabled): Rename to ...
(stack_cache_enabled_p): ... this.  Update caller.
(_initialize_target_dcache): Replace "data cache" with
"target memory cache".
* target-dcache.h (stack_cache_enabled): Remove declaration.
(stack_cache_enabled_p): Add declaration.

10 years agoGDB perf test on single step
Yao Qi [Fri, 25 Oct 2013 08:09:31 +0000 (16:09 +0800)] 
GDB perf test on single step

gdb/testsuite:

2013-11-24  Yao Qi  <yao@codesourcery.com>

* gdb.perf/single-step.c: New.
* gdb.perf/single-step.exp: New.
* gdb.perf/single-step.py: New.

10 years agoWrite "ON" and "OFF" in lower case in GDB doc.
Yao Qi [Fri, 22 Nov 2013 01:28:42 +0000 (09:28 +0800)] 
Write "ON" and "OFF" in lower case in GDB doc.

gdb/doc:

2013-11-24  Yao Qi  <yao@codesourcery.com>

* gdb.texinfo (Caching Target Data): Replace "ON" with "on".
(Maintenance Commands): Replace "ON" and "OFF" with "on" and
"off" respectively.

10 years ago * gdb.base/ena-dis-br.exp: Add missing quote to "step after continue
Doug Evans [Sun, 24 Nov 2013 00:43:29 +0000 (16:43 -0800)] 
* gdb.base/ena-dis-br.exp: Add missing quote to "step after continue
with ignore count".

10 years agoTest name tweaks for py-value.exp.
Doug Evans [Sun, 24 Nov 2013 00:03:47 +0000 (16:03 -0800)] 
Test name tweaks for py-value.exp.

* gdb.python/py-value.exp (test_lazy_strings): Tweak test names.
(test_subscript_regression): Ditto.
(top level): Run test_subscript_regression for c++ with "c++" prefix.

10 years ago * gdb.python/py-type.exp (test_enums): Fix typo.
Doug Evans [Sat, 23 Nov 2013 23:54:05 +0000 (15:54 -0800)] 
* gdb.python/py-type.exp (test_enums): Fix typo.

10 years ago* gdb.python/py-symbol.exp: Add some comments. Make all test names unique.
Doug Evans [Sat, 23 Nov 2013 23:45:43 +0000 (15:45 -0800)] 
* gdb.python/py-symbol.exp: Add some comments.  Make all test names unique.

10 years ago* gdb.python/py-symbol.exp: Fix whitespace.
Doug Evans [Sat, 23 Nov 2013 23:20:42 +0000 (15:20 -0800)] 
* gdb.python/py-symbol.exp: Fix whitespace.

10 years agoFix long line in earlier entry.
Doug Evans [Sat, 23 Nov 2013 23:15:17 +0000 (15:15 -0800)] 
Fix long line in earlier entry.

10 years ago * gdb.python/python.exp: Don't call skip_python_tests, we still want
Doug Evans [Sat, 23 Nov 2013 23:08:28 +0000 (15:08 -0800)] 
* gdb.python/python.exp: Don't call skip_python_tests, we still want
to test some things in the case where python is not configured in.

10 years agodaily update
Alan Modra [Sat, 23 Nov 2013 23:00:01 +0000 (09:30 +1030)] 
daily update

10 years ago * python/py-frame.c (gdbpy_initialize_frames): Remove FIRST_ERROR,
Doug Evans [Sat, 23 Nov 2013 22:46:43 +0000 (14:46 -0800)] 
* python/py-frame.c (gdbpy_initialize_frames): Remove FIRST_ERROR,
superfluous.

10 years ago * python/py-frame.c (frapy_block): Fix error message text.
Doug Evans [Sat, 23 Nov 2013 22:36:57 +0000 (14:36 -0800)] 
* python/py-frame.c (frapy_block): Fix error message text.

10 years agocli/cli-script.c (multi_line_command_p): New function.
Doug Evans [Sat, 23 Nov 2013 19:47:24 +0000 (11:47 -0800)] 
cli/cli-script.c (multi_line_command_p): New function.

* cli/cli-script.c (multi_line_command_p): New function.
(recurse_read_control_structure, read_command_lines_1): Call it.
(execute_control_command): Consistently have a blank line between
each case.

10 years agoUpdate doc on displayhint in command -var-list-children
Yao Qi [Tue, 19 Nov 2013 11:00:38 +0000 (19:00 +0800)] 
Update doc on displayhint in command -var-list-children

Hi,
When using command -var-list-children, "displayhint" appears in the result of
each child, shown as the following output.

-var-list-children  ss1  ^M
^done,numchild="2",displayhint="pp_ss",children=[child={name="ss1.a",exp="a",numchild="0",type="struct s",thread-id="1",displayhint="pp_s",dynamic="1"},child={name="ss1.b",exp="b",numchild="0",type="struct s",thread-id="1",displayhint="pp_s",dynamic="1"}],has_more="0"

Current doc on command -var-list-children doesn't reflect this.  This
patch is to fix it.

gdb/doc:

2013-11-23  Yao Qi  <yao@codesourcery.com>

* gdb.texinfo (GDB/MI Variable Objects): Add the description
of "displayhint" to the table about child results.

10 years agoAdd check for which library is needed for dlopen.
Cary Coutant [Fri, 22 Nov 2013 23:46:51 +0000 (15:46 -0800)] 
Add check for which library is needed for dlopen.

gold/
PR gold/16203
* configure.ac: Add check for which library is needed for
dlopen.
* configure: Regenerate.

10 years agoUse in-tree assembler for exception_x86_64_bnd_test.
Cary Coutant [Fri, 22 Nov 2013 23:38:24 +0000 (15:38 -0800)] 
Use in-tree assembler for exception_x86_64_bnd_test.

gold/
* testsuite/Makefile.am (exception_x86_64_bnd_test): Use in-tree
assembler.
* testsuite/Makefile.in: Regenerate.

10 years agodaily update
Alan Modra [Fri, 22 Nov 2013 23:00:01 +0000 (09:30 +1030)] 
daily update

10 years agoImport config.sub and config.guess from upstream.
Alan Modra [Fri, 22 Nov 2013 22:25:31 +0000 (08:55 +1030)] 
Import config.sub and config.guess from upstream.

10 years ago2013-11-22 Sterling Augustine <saugustine@google.com>
Sterling Augustine [Fri, 22 Nov 2013 21:55:32 +0000 (13:55 -0800)] 
2013-11-22  Sterling Augustine  <saugustine@google.com>

     PR gdb/16196:
     * valprint.c (read_string): Set new variable fetchlen based on
     fetchlimit and size.  Use it in call to partial_memory_read.
     Update comment.

10 years ago2013-11-22 Sterling Augustine <saugustine@google.com>
Sterling Augustine [Fri, 22 Nov 2013 21:55:32 +0000 (13:55 -0800)] 
2013-11-22  Sterling Augustine  <saugustine@google.com>

     PR gdb/16196:
     * valprint.c (read_string): Set new variable fetchlen based on
     fetchlimit and size.  Use it in call to partial_memory_read.
     Update comment.

10 years agoRename gdb.dwarf2/dw2-bad-cfi.* to gdb.dwarf2/dw2-unspecified-ret-addr.*.
Pedro Alves [Fri, 22 Nov 2013 19:18:28 +0000 (19:18 +0000)] 
Rename gdb.dwarf2/dw2-bad-cfi.* to gdb.dwarf2/dw2-unspecified-ret-addr.*.

gdb/testsuite/
2013-11-22  Pedro Alves  <palves@redhat.com>

* gdb.dwarf2/dw2-bad-cfi.S: Rename to ...
* gdb.dwarf2/dw2-unspecified-ret-addr.S: ... this.  Adjust.
* gdb.dwarf2/dw2-bad-cfi.c: Rename to ...
* gdb.dwarf2/dw2-unspecified-ret-addr.c: ... this.
* gdb.dwarf2/dw2-bad-cfi.exp: Rename to ...
* gdb.dwarf2/dw2-unspecified-ret-addr.exp: ... this.

10 years agoupdate comment in dw2-bad-cfi.S.
Tom Tromey [Fri, 22 Nov 2013 19:08:15 +0000 (12:08 -0700)] 
update comment in dw2-bad-cfi.S.

Pedro asked me to add a comment to dw2-bad-cfi.S explaining the nature
of the badness.

I'm checking this in.

2013-11-22  Tom Tromey  <tromey@redhat.com>

* gdb.dwarf2/dw2-bad-cfi.S: Update comment.

10 years agohandle an unspecified return address column
Tom Tromey [Wed, 13 Nov 2013 18:10:55 +0000 (11:10 -0700)] 
handle an unspecified return address column

Debugging PR 16155 further, I found that the DWARF unwinder found the
function in question, but thought it had no registers saved
(fs->regs.num_regs == 0).

It seems to me that if a frame does not specify the return address
column, or if the return address column is explicitly marked as
DWARF2_FRAME_REG_UNSPECIFIED, then we should set the
"undefined_retaddr" flag and let the DWARF unwinder gracefully stop.

This patch implements that idea.

With this patch the backtrace works properly:

    (gdb) bt
    #0  0x0000007fb7ed485c in nanosleep () from /lib64/libc.so.6
    #1  0x0000007fb7ed4508 in sleep () from /lib64/libc.so.6
    #2  0x00000000004008bc in thread_function (arg=0x4) at threadapply.c:73
    #3  0x0000007fb7fad950 in start_thread () from /lib64/libpthread.so.0
    #4  0x0000007fb7f0956c in clone () from /lib64/libc.so.6

2013-11-22  Tom Tromey  <tromey@redhat.com>

PR backtrace/16155:
* dwarf2-frame.c (dwarf2_frame_cache): Set undefined_retaddr if
the return address column is unspecified.

2013-11-22  Tom Tromey  <tromey@redhat.com>

* gdb.dwarf2/dw2-bad-cfi.c: New file.
* gdb.dwarf2/dw2-bad-cfi.exp: New file.
* gdb.dwarf2/dw2-bad-cfi.S: New file.

10 years agoDetect infinite loop in value_fetch_lazy's lval_register handling.
Tom Tromey [Fri, 22 Nov 2013 17:38:44 +0000 (17:38 +0000)] 
Detect infinite loop in value_fetch_lazy's lval_register handling.

If value_fetch_lazy loops infinitely while unwrapping lval_register
values, it means we either somehow ended up with two frames with the
same ID in the frame chain, or some code is trying to unwind behind
get_prev_frame's back (e.g., a frame unwind sniffer trying to unwind).
In any case, it should always be an internal error to end up in this
situation.

This patch adds a check and throws an internal error if the same frame
is returned.

2013-11-22  Tom Tromey  <tromey@redhat.com>
    Pedro Alves  <palves@redhat.com>

PR backtrace/16155
* value.c (value_fetch_lazy): Internal error if
get_frame_register_value returns the same register.

10 years ago * windres.c (define_resource): Use zero for timestamp, making
Cory Fields [Fri, 22 Nov 2013 14:54:33 +0000 (14:54 +0000)] 
* windres.c (define_resource): Use zero for timestamp, making
output deterministic. time.h include is no longer needed.
* resres.c (res_append_resource): Likewise.

* pe-dll.c (fill_edata): Only use a real timestamp if
--insert-timestamp was used.
* emultempl/pe.em: Add the --insert-timestamp option.
* emultempl/pep.em: Likewise for 64bit.
* ld.texinfo: Document the --insert-timestamp option.

* libcoff-in.h: Add insert_timestamp flag to the pe_data struct.
* libcoff.h: Regenerate.
* peXXigen.c (_bfd_XXi_only_swap_filehdr_out): Only use a real
timestamp if --insert-timestamp was used.

10 years agoMake use of the frame stash to detect wider stack cycles.
Pedro Alves [Thu, 21 Nov 2013 15:20:09 +0000 (15:20 +0000)] 
Make use of the frame stash to detect wider stack cycles.

Given we already have the frame id stash, which holds the ids of all
frames in the chain, detecting corrupted stacks with wide stack cycles
with non-consecutive dup frame ids is just as cheap as just detecting
cycles in consecutive frames:

 #0 frame_id1
 #1 frame_id2
 #2 frame_id3
 #3 frame_id1
 #4 frame_id2
 #5 frame_id3
 #6 frame_id1
 ... forever ...

We just need to check whether the stash already knows about a given
frame id instead of comparing the ids of the previous/this frames.

Tested on x86_64 Fedora 17.

gdb/
2013-11-22  Pedro Alves  <palves@redhat.com>
    Tom Tromey  <tromey@redhat.com>

* frame.c (frame_stash_add): Now returns whether a frame with the
same ID was already known.
(compute_frame_id): New function, factored out from get_frame_id.
(get_frame_id): No longer lazilly compute the frame id here.
(get_prev_frame_if_no_cycle): New function.  Detects wider stack
cycles.
(get_prev_frame_1): Use it instead of get_prev_frame_raw directly,
and checking for stack cycles here.

10 years agoDon't let two frames with the same id end up in the frame chain.
Pedro Alves [Fri, 22 Nov 2013 11:51:59 +0000 (11:51 +0000)] 
Don't let two frames with the same id end up in the frame chain.

The UNWIND_SAME_ID check is done between THIS_FRAME and the next frame
when we go try to unwind the previous frame.  But at this point, it's
already too late -- we ended up with two frames with the same ID in
the frame chain.  Each frame having its own ID is an invariant assumed
throughout GDB.  This patch applies the UNWIND_SAME_ID detection
earlier, right after the previous frame is unwound, discarding the dup
frame if a cycle is detected.

The patch includes a new test that fails before the change.  Before
the patch, the test causes an infinite loop in GDB, after the patch,
the UNWIND_SAME_ID logic kicks in and makes the backtrace stop with:

  Backtrace stopped: previous frame identical to this frame (corrupt stack?)

The test uses dwarf CFI to emulate a corrupted stack with a cycle.  It
has a function with registers marked DW_CFA_same_value (most
importantly RSP/RIP), so that GDB computes the same ID for that frame
and its caller.  IOW, something like this:

 #0 - frame_id_1
 #1 - frame_id_2
 #2 - frame_id_3
 #3 - frame_id_4
 #4 - frame_id_4  <<<< outermost (UNWIND_SAME_ID).

(The test's code is just a copy of dw2-reg-undefined.S /
dw2-reg-undefined.c, adjusted to use DW_CFA_same_value instead of
DW_CFA_undefined, and to mark a different set of registers.)

The infinite loop is here, in value_fetch_lazy:

      while (VALUE_LVAL (new_val) == lval_register && value_lazy (new_val))
{
  frame = frame_find_by_id (VALUE_FRAME_ID (new_val));
...
  new_val = get_frame_register_value (frame, regnum);
}

get_frame_register_value can return a lazy register value pointing to
the next frame.  This means that the register wasn't clobbered by
FRAME; the debugger should therefore retrieve its value from the next
frame.

To be clear, get_frame_register_value unwinds the value in question
from the next frame:

 struct value *
 get_frame_register_value (struct frame_info *frame, int regnum)
 {
   return frame_unwind_register_value (frame->next, regnum);
                                       ^^^^^^^^^^^
 }

In other words, if we get a lazy lval_register, it should have the
frame ID of the _next_ frame, never of FRAME.

At this point in value_fetch_lazy, the whole relevant chunk of the
stack up to frame #4 has already been unwound.  The loop always
"unlazies" lval_registers in the "next/innermost" direction, not in
the "prev/unwind further/outermost" direction.

So say we're looking at frame #4.  get_frame_register_value in frame
#4 can return a lazy register value of frame #3.  So the next
iteration, frame_find_by_id tries to read the register from frame #3.
But, since frame #4 happens to have same id as frame #3,
frame_find_by_id returns frame #4 instead.  Rinse, repeat, and we have
an infinite loop.

This is an old latent problem, exposed by the recent addition of the
frame stash.  Before we had a stash, frame_find_by_id(frame_id_4)
would walk over all frames starting at the current frame, and would
always find #3 first.  The stash happens to return #4 instead:

struct frame_info *
frame_find_by_id (struct frame_id id)
{
  struct frame_info *frame, *prev_frame;

...
  /* Try using the frame stash first.  Finding it there removes the need
     to perform the search by looping over all frames, which can be very
     CPU-intensive if the number of frames is very high (the loop is O(n)
     and get_prev_frame performs a series of checks that are relatively
     expensive).  This optimization is particularly useful when this function
     is called from another function (such as value_fetch_lazy, case
     VALUE_LVAL (val) == lval_register) which already loops over all frames,
     making the overall behavior O(n^2).  */
  frame = frame_stash_find (id);
  if (frame)
    return frame;

  for (frame = get_current_frame (); ; frame = prev_frame)
    {

gdb/
2013-11-22  Pedro Alves  <palves@redhat.com>

PR 16155
* frame.c (get_prev_frame_1): Do the UNWIND_SAME_ID check between
this frame and the new previous frame, not between this frame and
the next frame.

gdb/testsuite/
2013-11-22  Pedro Alves  <palves@redhat.com>

PR 16155
* gdb.dwarf2/dw2-dup-frame.S: New file.
* gdb.dwarf2/dw2-dup-frame.c: New file.
* gdb.dwarf2/dw2-dup-frame.exp: New file.

10 years agoEliminate dwarf2_frame_cache recursion, don't unwind from the dwarf2 sniffer (move...
Pedro Alves [Fri, 22 Nov 2013 13:17:46 +0000 (13:17 +0000)] 
Eliminate dwarf2_frame_cache recursion, don't unwind from the dwarf2 sniffer (move dwarf2_tailcall_sniffer_first elsewhere).

Two rationales, same patch.

TL;DR 1:

 dwarf2_frame_cache recursion is evil.  dwarf2_frame_cache calls
 dwarf2_tailcall_sniffer_first which then recurses into
 dwarf2_frame_cache.

TL;DR 2:

 An unwinder trying to unwind is evil.  dwarf2_frame_sniffer calls
 dwarf2_frame_cache which calls dwarf2_tailcall_sniffer_first which
 then tries to unwind the PC of the previous frame.

Avoid all that by deferring dwarf2_tailcall_sniffer_first until it's
really necessary.

Rationale 1
===========

A frame sniffer should not try to unwind, because that bypasses all
the validation checks done by get_prev_frame.  The UNWIND_SAME_ID
scenario is one such case where GDB is currently broken because (in
part) of this (the next patch adds a test that would fail without
this).

GDB goes into an infinite loop in value_fetch_lazy, here:

      while (VALUE_LVAL (new_val) == lval_register && value_lazy (new_val))
{
  frame = frame_find_by_id (VALUE_FRAME_ID (new_val));
...
  new_val = get_frame_register_value (frame, regnum);
}

(top-gdb) bt
#0  value_fetch_lazy (val=0x11516d0) at ../../src/gdb/value.c:3510
#1  0x0000000000584bd8 in value_optimized_out (value=0x11516d0) at ../../src/gdb/value.c:1096
#2  0x00000000006fe7a1 in frame_register_unwind (frame=0x1492600, regnum=16, optimizedp=0x7fffffffcdec, unavailablep=0x7fffffffcde8, lvalp=0x7fffffffcdd8, addrp=
    0x7fffffffcde0, realnump=0x7fffffffcddc, bufferp=0x7fffffffce10 "@\316\377\377\377\177") at ../../src/gdb/frame.c:940
#3  0x00000000006fea3a in frame_unwind_register (frame=0x1492600, regnum=16, buf=0x7fffffffce10 "@\316\377\377\377\177") at ../../src/gdb/frame.c:990
#4  0x0000000000473b9b in i386_unwind_pc (gdbarch=0xf54660, next_frame=0x1492600) at ../../src/gdb/i386-tdep.c:1771
#5  0x0000000000601dfa in gdbarch_unwind_pc (gdbarch=0xf54660, next_frame=0x1492600) at ../../src/gdb/gdbarch.c:2870
#6  0x0000000000693db5 in dwarf2_tailcall_sniffer_first (this_frame=0x1492600, tailcall_cachep=0x14926f0, entry_cfa_sp_offsetp=0x7fffffffcf00)
    at ../../src/gdb/dwarf2-frame-tailcall.c:389
#7  0x0000000000690928 in dwarf2_frame_cache (this_frame=0x1492600, this_cache=0x1492618) at ../../src/gdb/dwarf2-frame.c:1245
#8  0x0000000000690f46 in dwarf2_frame_sniffer (self=0x8e4980, this_frame=0x1492600, this_cache=0x1492618) at ../../src/gdb/dwarf2-frame.c:1423
#9  0x000000000070203b in frame_unwind_find_by_frame (this_frame=0x1492600, this_cache=0x1492618) at ../../src/gdb/frame-unwind.c:112
#10 0x00000000006fd681 in get_frame_id (fi=0x1492600) at ../../src/gdb/frame.c:408
#11 0x00000000007006c2 in get_prev_frame_1 (this_frame=0xdc1860) at ../../src/gdb/frame.c:1826
#12 0x0000000000700b7a in get_prev_frame (this_frame=0xdc1860) at ../../src/gdb/frame.c:2056
#13 0x0000000000514588 in frame_info_to_frame_object (frame=0xdc1860) at ../../src/gdb/python/py-frame.c:322
#14 0x000000000051784c in bootstrap_python_frame_filters (frame=0xdc1860, frame_low=0, frame_high=-1) at ../../src/gdb/python/py-framefilter.c:1396
#15 0x0000000000517a6f in apply_frame_filter (frame=0xdc1860, flags=7, args_type=CLI_SCALAR_VALUES, out=0xed7a90, frame_low=0, frame_high=-1)
    at ../../src/gdb/python/py-framefilter.c:1492
#16 0x00000000005e77b0 in backtrace_command_1 (count_exp=0x0, show_locals=0, no_filters=0, from_tty=1) at ../../src/gdb/stack.c:1777
#17 0x00000000005e7c0f in backtrace_command (arg=0x0, from_tty=1) at ../../src/gdb/stack.c:1891
#18 0x00000000004e37a7 in do_cfunc (c=0xda4fa0, args=0x0, from_tty=1) at ../../src/gdb/cli/cli-decode.c:107
#19 0x00000000004e683c in cmd_func (cmd=0xda4fa0, args=0x0, from_tty=1) at ../../src/gdb/cli/cli-decode.c:1882
#20 0x00000000006f35ed in execute_command (p=0xcc66c2 "", from_tty=1) at ../../src/gdb/top.c:468
#21 0x00000000005f8853 in command_handler (command=0xcc66c0 "bt") at ../../src/gdb/event-top.c:435
#22 0x00000000005f8e12 in command_line_handler (rl=0xfe05f0 "@") at ../../src/gdb/event-top.c:632
#23 0x000000000074d2c6 in rl_callback_read_char () at ../../src/readline/callback.c:220
#24 0x00000000005f8375 in rl_callback_read_char_wrapper (client_data=0x0) at ../../src/gdb/event-top.c:164
#25 0x00000000005f876a in stdin_event_handler (error=0, client_data=0x0) at ../../src/gdb/event-top.c:375
#26 0x00000000005f72fa in handle_file_event (data=...) at ../../src/gdb/event-loop.c:768
#27 0x00000000005f67a3 in process_event () at ../../src/gdb/event-loop.c:342
#28 0x00000000005f686a in gdb_do_one_event () at ../../src/gdb/event-loop.c:406
#29 0x00000000005f68bb in start_event_loop () at ../../src/gdb/event-loop.c:431
#30 0x00000000005f83a7 in cli_command_loop (data=0x0) at ../../src/gdb/event-top.c:179
#31 0x00000000005eeed3 in current_interp_command_loop () at ../../src/gdb/interps.c:327
#32 0x00000000005ef8ff in captured_command_loop (data=0x0) at ../../src/gdb/main.c:267
#33 0x00000000005ed2f6 in catch_errors (func=0x5ef8e4 <captured_command_loop>, func_args=0x0, errstring=0x8b6554 "", mask=RETURN_MASK_ALL)
    at ../../src/gdb/exceptions.c:524
#34 0x00000000005f0d21 in captured_main (data=0x7fffffffd9e0) at ../../src/gdb/main.c:1067
#35 0x00000000005ed2f6 in catch_errors (func=0x5efb9b <captured_main>, func_args=0x7fffffffd9e0, errstring=0x8b6554 "", mask=RETURN_MASK_ALL)
    at ../../src/gdb/exceptions.c:524
#36 0x00000000005f0d57 in gdb_main (args=0x7fffffffd9e0) at ../../src/gdb/main.c:1076
#37 0x000000000045bb6a in main (argc=4, argv=0x7fffffffdae8) at ../../src/gdb/gdb.c:34
(top-gdb)

GDB is trying to unwind the PC register of the previous frame (frame
#5 above), starting from the frame being sniffed (the THIS frame).
But the THIS frame's unwinder says the PC of the previous frame is
actually the same as the previous's frame's next frame (which is the
same frame we started with, the THIS frame), therefore it returns an
lval_register lazy value with frame set to THIS frame.  And so the
value_fetch_lazy loop never ends.

Rationale 2
===========

As an experiment, I tried making dwarf2-frame.c:read_addr_from_reg use
address_from_register.  That caused a bunch of regressions, but it
actually took me a long while to figure out what was going on.  Turns
out dwarf2-frame.c:read_addr_from_reg is called while computing the
frame's CFA, from within dwarf2_frame_cache.  address_from_register
wants to create a register with frame_id set to the frame being
constructed.  To create the frame id, we again call dwarf2_frame_cache,
which given:

static struct dwarf2_frame_cache *
dwarf2_frame_cache (struct frame_info *this_frame, void **this_cache)
{
...
  if (*this_cache)
    return *this_cache;

returns an incomplete object to the caller:
static void
dwarf2_frame_this_id (struct frame_info *this_frame, void **this_cache,
      struct frame_id *this_id)
{
  struct dwarf2_frame_cache *cache =
    dwarf2_frame_cache (this_frame, this_cache);
...
 (*this_id) = frame_id_build (cache->cfa, get_frame_func (this_frame));
}

As cache->cfa is still 0 (we were trying to compute it!), and
get_frame_id recalls this id from here on, we end up with a broken
frame id in recorded for this frame.  Later, when inspecting locals,
the dwarf machinery needs to know the selected frame's base, which
calls get_frame_base:

CORE_ADDR
get_frame_base (struct frame_info *fi)
{
  return get_frame_id (fi).stack_addr;
}

which as seen above then returns 0 ...

So I gave up using address_from_register.

But, the pain of investigating this made me want to have GDB itself
assert that recursion never happens here.  So I wrote a patch to do
that.  But, it triggers on current mainline, because
dwarf2_tailcall_sniffer_first, called from dwarf2_frame_cache, unwinds
the this_frame.

A sniffer shouldn't be trying to unwind, exactly because of this sort
of tricky issue.  The patch defers calling
dwarf2_tailcall_sniffer_first until it's really necessary, in
dwarf2_frame_prev_register (thus actually outside the sniffer path).
As this makes the call to dwarf2_frame_sniffer in dwarf2_frame_cache
unnecessary again, the patch removes that too.

Tested on x86_64 Fedora 17.

gdb/
2013-11-22  Pedro Alves  <palves@redhat.com>

PR 16155
* dwarf2-frame.c (struct dwarf2_frame_cache)
<checked_tailcall_bottom, entry_cfa_sp_offset,
entry_cfa_sp_offset_p>: New fields.
(dwarf2_frame_cache): Adjust to use the new cache fields instead
of locals.  Don't call dwarf2_tailcall_sniffer_first here.
(dwarf2_frame_prev_register): Call it here, but only once.

10 years agoRevert "Don't let two frames with the same id end up in the frame chain."
Pedro Alves [Fri, 22 Nov 2013 13:46:51 +0000 (13:46 +0000)] 
Revert "Don't let two frames with the same id end up in the frame chain."

This reverts commit be2c48b4d50b992ba83bc51f086e316621a03a14.

10 years agoRevert "Make use of the frame stash to detect wider stack cycles."
Pedro Alves [Fri, 22 Nov 2013 13:46:43 +0000 (13:46 +0000)] 
Revert "Make use of the frame stash to detect wider stack cycles."

This reverts commit f5b0ed3c8ce42b0dd6b6caa0b3d7b7e734311afe.

10 years agoRevert "Eliminate dwarf2_frame_cache recursion, don't unwind from the dwarf2 sniffer...
Pedro Alves [Fri, 22 Nov 2013 13:46:35 +0000 (13:46 +0000)] 
Revert "Eliminate dwarf2_frame_cache recursion, don't unwind from the dwarf2 sniffer (move dwarf2_tailcall_sniffer_first elsewhere)."

This reverts commit 1dc8686c48e72fc02723d44ee0fecde0d233c74e.

10 years agoEliminate dwarf2_frame_cache recursion, don't unwind from the dwarf2 sniffer (move...
Pedro Alves [Fri, 22 Nov 2013 13:17:46 +0000 (13:17 +0000)] 
Eliminate dwarf2_frame_cache recursion, don't unwind from the dwarf2 sniffer (move dwarf2_tailcall_sniffer_first elsewhere).

Two rationales, same patch.

TL;DR 1:

 dwarf2_frame_cache recursion is evil.  dwarf2_frame_cache calls
 dwarf2_tailcall_sniffer_first which then recurses into
 dwarf2_frame_cache.

TL;DR 2:

 An unwinder trying to unwind is evil.  dwarf2_frame_sniffer calls
 dwarf2_frame_cache which calls dwarf2_tailcall_sniffer_first which
 then tries to unwind the PC of the previous frame.

Avoid all that by deferring dwarf2_tailcall_sniffer_first until it's
really necessary.

Rationale 1
===========

A frame sniffer should not try to unwind, because that bypasses all
the validation checks done by get_prev_frame.  The UNWIND_SAME_ID
scenario is one such case where GDB is currently broken because (in
part) of this (the next patch adds a test that would fail without
this).

GDB goes into an infinite loop in value_fetch_lazy, here:

      while (VALUE_LVAL (new_val) == lval_register && value_lazy (new_val))
{
  frame = frame_find_by_id (VALUE_FRAME_ID (new_val));
...
  new_val = get_frame_register_value (frame, regnum);
}

(top-gdb) bt
#0  value_fetch_lazy (val=0x11516d0) at ../../src/gdb/value.c:3510
#1  0x0000000000584bd8 in value_optimized_out (value=0x11516d0) at ../../src/gdb/value.c:1096
#2  0x00000000006fe7a1 in frame_register_unwind (frame=0x1492600, regnum=16, optimizedp=0x7fffffffcdec, unavailablep=0x7fffffffcde8, lvalp=0x7fffffffcdd8, addrp=
    0x7fffffffcde0, realnump=0x7fffffffcddc, bufferp=0x7fffffffce10 "@\316\377\377\377\177") at ../../src/gdb/frame.c:940
#3  0x00000000006fea3a in frame_unwind_register (frame=0x1492600, regnum=16, buf=0x7fffffffce10 "@\316\377\377\377\177") at ../../src/gdb/frame.c:990
#4  0x0000000000473b9b in i386_unwind_pc (gdbarch=0xf54660, next_frame=0x1492600) at ../../src/gdb/i386-tdep.c:1771
#5  0x0000000000601dfa in gdbarch_unwind_pc (gdbarch=0xf54660, next_frame=0x1492600) at ../../src/gdb/gdbarch.c:2870
#6  0x0000000000693db5 in dwarf2_tailcall_sniffer_first (this_frame=0x1492600, tailcall_cachep=0x14926f0, entry_cfa_sp_offsetp=0x7fffffffcf00)
    at ../../src/gdb/dwarf2-frame-tailcall.c:389
#7  0x0000000000690928 in dwarf2_frame_cache (this_frame=0x1492600, this_cache=0x1492618) at ../../src/gdb/dwarf2-frame.c:1245
#8  0x0000000000690f46 in dwarf2_frame_sniffer (self=0x8e4980, this_frame=0x1492600, this_cache=0x1492618) at ../../src/gdb/dwarf2-frame.c:1423
#9  0x000000000070203b in frame_unwind_find_by_frame (this_frame=0x1492600, this_cache=0x1492618) at ../../src/gdb/frame-unwind.c:112
#10 0x00000000006fd681 in get_frame_id (fi=0x1492600) at ../../src/gdb/frame.c:408
#11 0x00000000007006c2 in get_prev_frame_1 (this_frame=0xdc1860) at ../../src/gdb/frame.c:1826
#12 0x0000000000700b7a in get_prev_frame (this_frame=0xdc1860) at ../../src/gdb/frame.c:2056
#13 0x0000000000514588 in frame_info_to_frame_object (frame=0xdc1860) at ../../src/gdb/python/py-frame.c:322
#14 0x000000000051784c in bootstrap_python_frame_filters (frame=0xdc1860, frame_low=0, frame_high=-1) at ../../src/gdb/python/py-framefilter.c:1396
#15 0x0000000000517a6f in apply_frame_filter (frame=0xdc1860, flags=7, args_type=CLI_SCALAR_VALUES, out=0xed7a90, frame_low=0, frame_high=-1)
    at ../../src/gdb/python/py-framefilter.c:1492
#16 0x00000000005e77b0 in backtrace_command_1 (count_exp=0x0, show_locals=0, no_filters=0, from_tty=1) at ../../src/gdb/stack.c:1777
#17 0x00000000005e7c0f in backtrace_command (arg=0x0, from_tty=1) at ../../src/gdb/stack.c:1891
#18 0x00000000004e37a7 in do_cfunc (c=0xda4fa0, args=0x0, from_tty=1) at ../../src/gdb/cli/cli-decode.c:107
#19 0x00000000004e683c in cmd_func (cmd=0xda4fa0, args=0x0, from_tty=1) at ../../src/gdb/cli/cli-decode.c:1882
#20 0x00000000006f35ed in execute_command (p=0xcc66c2 "", from_tty=1) at ../../src/gdb/top.c:468
#21 0x00000000005f8853 in command_handler (command=0xcc66c0 "bt") at ../../src/gdb/event-top.c:435
#22 0x00000000005f8e12 in command_line_handler (rl=0xfe05f0 "@") at ../../src/gdb/event-top.c:632
#23 0x000000000074d2c6 in rl_callback_read_char () at ../../src/readline/callback.c:220
#24 0x00000000005f8375 in rl_callback_read_char_wrapper (client_data=0x0) at ../../src/gdb/event-top.c:164
#25 0x00000000005f876a in stdin_event_handler (error=0, client_data=0x0) at ../../src/gdb/event-top.c:375
#26 0x00000000005f72fa in handle_file_event (data=...) at ../../src/gdb/event-loop.c:768
#27 0x00000000005f67a3 in process_event () at ../../src/gdb/event-loop.c:342
#28 0x00000000005f686a in gdb_do_one_event () at ../../src/gdb/event-loop.c:406
#29 0x00000000005f68bb in start_event_loop () at ../../src/gdb/event-loop.c:431
#30 0x00000000005f83a7 in cli_command_loop (data=0x0) at ../../src/gdb/event-top.c:179
#31 0x00000000005eeed3 in current_interp_command_loop () at ../../src/gdb/interps.c:327
#32 0x00000000005ef8ff in captured_command_loop (data=0x0) at ../../src/gdb/main.c:267
#33 0x00000000005ed2f6 in catch_errors (func=0x5ef8e4 <captured_command_loop>, func_args=0x0, errstring=0x8b6554 "", mask=RETURN_MASK_ALL)
    at ../../src/gdb/exceptions.c:524
#34 0x00000000005f0d21 in captured_main (data=0x7fffffffd9e0) at ../../src/gdb/main.c:1067
#35 0x00000000005ed2f6 in catch_errors (func=0x5efb9b <captured_main>, func_args=0x7fffffffd9e0, errstring=0x8b6554 "", mask=RETURN_MASK_ALL)
    at ../../src/gdb/exceptions.c:524
#36 0x00000000005f0d57 in gdb_main (args=0x7fffffffd9e0) at ../../src/gdb/main.c:1076
#37 0x000000000045bb6a in main (argc=4, argv=0x7fffffffdae8) at ../../src/gdb/gdb.c:34
(top-gdb)

GDB is trying to unwind the PC register of the previous frame (frame
#5 above), starting from the frame being sniffed (the THIS frame).
But the THIS frame's unwinder says the PC of the previous frame is
actually the same as the previous's frame's next frame (which is the
same frame we started with, the THIS frame), therefore it returns an
lval_register lazy value with frame set to THIS frame.  And so the
value_fetch_lazy loop never ends.

Rationale 2
===========

As an experiment, I tried making dwarf2-frame.c:read_addr_from_reg use
address_from_register.  That caused a bunch of regressions, but it
actually took me a long while to figure out what was going on.  Turns
out dwarf2-frame.c:read_addr_from_reg is called while computing the
frame's CFA, from within dwarf2_frame_cache.  address_from_register
wants to create a register with frame_id set to the frame being
constructed.  To create the frame id, we again call dwarf2_frame_cache,
which given:

static struct dwarf2_frame_cache *
dwarf2_frame_cache (struct frame_info *this_frame, void **this_cache)
{
...
  if (*this_cache)
    return *this_cache;

returns an incomplete object to the caller:
static void
dwarf2_frame_this_id (struct frame_info *this_frame, void **this_cache,
      struct frame_id *this_id)
{
  struct dwarf2_frame_cache *cache =
    dwarf2_frame_cache (this_frame, this_cache);
...
 (*this_id) = frame_id_build (cache->cfa, get_frame_func (this_frame));
}

As cache->cfa is still 0 (we were trying to compute it!), and
get_frame_id recalls this id from here on, we end up with a broken
frame id in recorded for this frame.  Later, when inspecting locals,
the dwarf machinery needs to know the selected frame's base, which
calls get_frame_base:

CORE_ADDR
get_frame_base (struct frame_info *fi)
{
  return get_frame_id (fi).stack_addr;
}

which as seen above then returns 0 ...

So I gave up using address_from_register.

But, the pain of investigating this made me want to have GDB itself
assert that recursion never happens here.  So I wrote a patch to do
that.  But, it triggers on current mainline, because
dwarf2_tailcall_sniffer_first, called from dwarf2_frame_cache, unwinds
the this_frame.

A sniffer shouldn't be trying to unwind, exactly because of this sort
of tricky issue.  The patch defers calling
dwarf2_tailcall_sniffer_first until it's really necessary, in
dwarf2_frame_prev_register (thus actually outside the sniffer path).
As this makes the call to dwarf2_frame_sniffer in dwarf2_frame_cache
unnecessary again, the patch removes that too.

Tested on x86_64 Fedora 17.

gdb/
2013-11-22  Pedro Alves  <palves@redhat.com>

PR 16155
* dwarf2-frame.c (struct dwarf2_frame_cache)
<checked_tailcall_bottom, entry_cfa_sp_offset,
entry_cfa_sp_offset_p>: New fields.
(dwarf2_frame_cache): Adjust to use the new cache fields instead
of locals.  Don't call dwarf2_tailcall_sniffer_first here.
(dwarf2_frame_prev_register): Call it here, but only once.

10 years agoMake use of the frame stash to detect wider stack cycles.
Pedro Alves [Thu, 21 Nov 2013 15:20:09 +0000 (15:20 +0000)] 
Make use of the frame stash to detect wider stack cycles.

Tested on x86_64 Fedora 17.

gdb/
2013-11-22  Pedro Alves  <palves@redhat.com>
    Tom Tromey  <tromey@redhat.com>

* frame.c (frame_stash_add): Now returns whether a frame with the
same ID was already known.
(compute_frame_id): New function, factored out from get_frame_id.
(get_frame_id): No longer lazilly compute the frame id here.
(get_prev_frame_if_no_cycle): New function.  Detects wider stack
cycles.
(get_prev_frame_1): Use it instead of get_prev_frame_raw directly,
and checking for stack cycles here.

10 years agoDon't let two frames with the same id end up in the frame chain.
Pedro Alves [Fri, 22 Nov 2013 11:51:59 +0000 (11:51 +0000)] 
Don't let two frames with the same id end up in the frame chain.

The UNWIND_SAME_ID check is done between THIS_FRAME and the next frame
when we go try to unwind the previous frame.  But at this point, it's
already too late -- we ended up with two frames with the same ID in
the frame chain.  Each frame having its own ID is an invariant assumed
throughout GDB.  This patch applies the UNWIND_SAME_ID detection
earlier, right after the previous frame is unwound, discarding the dup
frame if a cycle is detected.

The patch includes a new test that fails before the change.  Before
the patch, the test causes an infinite loop in GDB, after the patch,
the UNWIND_SAME_ID logic kicks in and makes the backtrace stop with:

  Backtrace stopped: previous frame identical to this frame (corrupt stack?)

The test uses dwarf CFI to emulate a corrupted stack with a cycle.  It
has a function with registers marked DW_CFA_same_value (most
importantly RSP/RIP), so that GDB computes the same ID for that frame
and its caller.  IOW, something like this:

 #0 - frame_id_1
 #1 - frame_id_2
 #2 - frame_id_3
 #3 - frame_id_4
 #4 - frame_id_4  <<<< outermost (UNWIND_SAME_ID).

(The test's code is just a copy of dw2-reg-undefined.S /
dw2-reg-undefined.c, adjusted to use DW_CFA_same_value instead of
DW_CFA_undefined, and to mark a different set of registers.)

The infinite loop is here, in value_fetch_lazy:

      while (VALUE_LVAL (new_val) == lval_register && value_lazy (new_val))
{
  frame = frame_find_by_id (VALUE_FRAME_ID (new_val));
...
  new_val = get_frame_register_value (frame, regnum);
}

get_frame_register_value can return a lazy register value pointing to
the next frame.  This means that the register wasn't clobbered by
FRAME; the debugger should therefore retrieve its value from the next
frame.

To be clear, get_frame_register_value unwinds the value in question
from the next frame:

 struct value *
 get_frame_register_value (struct frame_info *frame, int regnum)
 {
   return frame_unwind_register_value (frame->next, regnum);
                                       ^^^^^^^^^^^
 }

In other words, if we get a lazy lval_register, it should have the
frame ID of the _next_ frame, never of FRAME.

At this point in value_fetch_lazy, the whole relevant chunk of the
stack up to frame #4 has already been unwound.  The loop always
"unlazies" lval_registers in the "next/innermost" direction, not in
the "prev/unwind further/outermost" direction.

So say we're looking at frame #4.  get_frame_register_value in frame
#4 can return a lazy register value of frame #3.  So the next
iteration, frame_find_by_id tries to read the register from frame #3.
But, since frame #4 happens to have same id as frame #3,
frame_find_by_id returns frame #4 instead.  Rinse, repeat, and we have
an infinite loop.

This is an old latent problem, exposed by the recent addition of the
frame stash.  Before we had a stash, frame_find_by_id(frame_id_4)
would walk over all frames starting at the current frame, and would
always find #3 first.  The stash happens to return #4 instead:

struct frame_info *
frame_find_by_id (struct frame_id id)
{
  struct frame_info *frame, *prev_frame;

...
  /* Try using the frame stash first.  Finding it there removes the need
     to perform the search by looping over all frames, which can be very
     CPU-intensive if the number of frames is very high (the loop is O(n)
     and get_prev_frame performs a series of checks that are relatively
     expensive).  This optimization is particularly useful when this function
     is called from another function (such as value_fetch_lazy, case
     VALUE_LVAL (val) == lval_register) which already loops over all frames,
     making the overall behavior O(n^2).  */
  frame = frame_stash_find (id);
  if (frame)
    return frame;

  for (frame = get_current_frame (); ; frame = prev_frame)
    {

gdb/
2013-11-22  Pedro Alves  <palves@redhat.com>

PR 16155
* frame.c (get_prev_frame_1): Do the UNWIND_SAME_ID check between
this frame and the new previous frame, not between this frame and
the next frame.

gdb/testsuite/
2013-11-22  Pedro Alves  <palves@redhat.com>

PR 16155
* gdb.dwarf2/dw2-dup-frame.S: New file.
  * gdb.dwarf2/dw2-dup-frame.c: New file.
  * gdb.dwarf2/dw2-dup-frame.exp: New file.

10 years ago * scripttempl/avr.sc: Set .data section's LMA to next available
Senthil Kumar Selvaraj [Fri, 22 Nov 2013 12:00:55 +0000 (12:00 +0000)] 
* scripttempl/avr.sc: Set .data section's LMA to next available
address in text region.

10 years agoMove types_deeply_equal from py-type.c to gdbtypes.c.
Doug Evans [Fri, 22 Nov 2013 04:28:35 +0000 (20:28 -0800)] 
Move types_deeply_equal from py-type.c to gdbtypes.c.

* gdbtypes.c: #include bcache.h, dwarf2loc.h.
(type_equality_entry): Move here from python/py-type.c.
(type_equality_entry_d): Ditto.
(compare_maybe_null_strings, check_types_equal): Ditto.
(check_types_worklist, types_deeply_equal): Ditto.
* gdbtypes.h (types_deeply_equal): Declare.
* python/py-type.c: Remove inclusion of bcache.h, dwarf2loc.h.
(typy_richcompare): Update.

10 years agoCheck has_more in mi_create_dynamic_varobj
Yao Qi [Sun, 10 Nov 2013 02:31:09 +0000 (10:31 +0800)] 
Check has_more in mi_create_dynamic_varobj

Hi,
I find "has_more" is not checked when a dynamic varobj is created in
proc mi_create_dynamic_varobj.  This patch adds the check to
"has_more".

gdb/testsuite:

2013-11-22  Yao Qi  <yao@codesourcery.com>

* lib/mi-support.exp (mi_create_dynamic_varobj): Update
comment and add one more argument "has_more".
* gdb.python/py-mi.exp: Callers update.

10 years agoUse mi_create_floating_varobj
Yao Qi [Sun, 10 Nov 2013 02:30:46 +0000 (10:30 +0800)] 
Use mi_create_floating_varobj

In gdb.python/py-mi.exp, two varobjs container and nscont are created
when pretty-printing is still not enabled, so they are not dynamic
varobj, IIUC.  In this patch, we use mi_create_floating_varobj instead
of mi_create_dynamic_varobj.

gdb/testsuite:

2013-11-22  Yao Qi  <yao@codesourcery.com>

* gdb.python/py-mi.exp: Use mi_create_floating_varobj instead
of mi_create_dynamic_varobj.

10 years agodaily update
Alan Modra [Thu, 21 Nov 2013 23:00:06 +0000 (09:30 +1030)] 
daily update

10 years agold/ChangeLog:
Andrew Pinski [Thu, 21 Nov 2013 00:56:20 +0000 (16:56 -0800)] 
ld/ChangeLog:

* Makefile.am (ALL_64_EMULATION_SOURCES): Add eaarch64linux32.c
and eaarch64linux32b.c
(eaarch64linux32.c): New target.
(eaarch64linux32b.c): Likewise.
* Makefile.in: Regenerate.
* configure.tgt (aarch64_be-*-linux*): Add
aarch64linux32 and aarch64linux32b to targ_extra_libpath.
(aarch64-*-linux*): Likewise.
* emulparams/aarch64elf32.sh (SEPARATE_GOTPLT): Change to 12 (3 words).
* emulparams/aarch64linux32.sh: New file.
* emulparams/aarch64linux32b.sh: New file.

10 years agold/ChangeLog:
Andrew Pinski [Thu, 21 Nov 2013 00:36:36 +0000 (16:36 -0800)] 
ld/ChangeLog:

* configure.tgt (aarch64_be-*-linux*): Split out the linux targets
into targ_extra_libpath.
(aarch64-*-linux*): Likewise.

10 years agoconfig/ * picflag.m4 (m68k-*-*): Use default PIC flag.
schwab [Fri, 15 Nov 2013 17:49:36 +0000 (17:49 +0000)] 
config/ * picflag.m4 (m68k-*-*): Use default PIC flag.

gcc/
* configure: Regenerate.

libada/
* configure: Regenerate.

libgcc/
* configure: Regenerate.

libiberty/
* configure: Regenerate.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@204854 138bc75d-0d04-0410-961f-82ee72b054a4

10 years ago PR ld/16192
Nick Clifton [Thu, 21 Nov 2013 13:29:47 +0000 (13:29 +0000)] 
PR ld/16192
* pe-dll.c (pe_create_runtime_relocator_reference): Zero the
newly allocated idata5 block.

10 years ago * gprof.c (inline_file_names): New variable.
Conrad Hoffmann [Thu, 21 Nov 2013 13:13:06 +0000 (13:13 +0000)] 
* gprof.c (inline_file_names): New variable.
(OPTION_INLINE_FILE_NAMES): Define.
(long_options): Add --inline-file-names.
(usage): Likewise.
(main): Process --inline-file-names.
* gprof.h: Add prototype for inline_file_names.
* utils.c (print_name_only): Handle inline_file_names.
* gprof.texi: Document new command line option.

10 years agoAdd bnd-branch-1 test
H.J. Lu [Thu, 21 Nov 2013 12:53:05 +0000 (04:53 -0800)] 
Add bnd-branch-1 test

* ld-x86-64/mpx.exp: Run bnd-branch-1.
* ld-x86-64/bnd-branch-1.d: New file.
* ld-x86-64/bnd-branch-1.s: Likewise.

10 years agoFix version.dll binutils test on non native platforms
Tristan Gingold [Tue, 19 Nov 2013 13:52:05 +0000 (14:52 +0100)] 
Fix version.dll binutils test on non native platforms

2013-11-21  Tristan Gingold  <gingold@adacore.com>

* binutils-all/dlltool.exp: Add dlltool_gas_flag to version.dll test.

10 years agoDoc 'dynamic' for command -var-list-children
Yao Qi [Tue, 19 Nov 2013 11:11:21 +0000 (19:11 +0800)] 
Doc 'dynamic' for command -var-list-children

Hi,
I find "dynamic=1" appear in the result of each child of the output of
-var-list-children,

  -var-list-children  ss1
  ^done,numchild="2",children=[child={name="ss1.a",exp="a",numchild="0",type="struct s",thread-id="1",dynamic="1"},child={name="ss1.b",exp="b",numchild="0",type="struct s",thread-id="1",dynamic="1"}],has_more="0"

but the doc doesn't mention this.  This patch is to copy the description
of "dynamic=1" here.

gdb/doc:

2013-11-21  Yao Qi  <yao@codesourcery.com>

* gdb.texinfo (GDB/MI Variable Objects): Add attribute 'dynamic'
for the output of command -var-list-children.

10 years agos/see @pxref/@pxref in doc
Yao Qi [Wed, 20 Nov 2013 03:38:49 +0000 (11:38 +0800)] 
s/see @pxref/@pxref in doc

Looks "see" is unnecessary before @pxref.

gdb/doc:

2013-11-21  Yao Qi  <yao@codesourcery.com>

* gdb.texinfo (Caching Target Data): Remove "see" before
@pxref.

10 years ago * linux-low.c (linux_set_resume_request): Fix comment.
Doug Evans [Thu, 21 Nov 2013 01:32:33 +0000 (17:32 -0800)] 
* linux-low.c (linux_set_resume_request): Fix comment.

10 years ago * linux-low.c (resume_status_pending_p): Tweak comment.
Doug Evans [Thu, 21 Nov 2013 00:31:48 +0000 (16:31 -0800)] 
* linux-low.c (resume_status_pending_p): Tweak comment.

10 years agodaily update
Alan Modra [Wed, 20 Nov 2013 23:00:01 +0000 (09:30 +1030)] 
daily update

10 years agoAdd mpx1static, mpx2 and mpx2static tests
H.J. Lu [Wed, 20 Nov 2013 20:35:10 +0000 (12:35 -0800)] 
Add mpx1static, mpx2 and mpx2static tests

* ld-x86-64/mpx.exp (build_tests): Add libmpx2a.a, libmpx2b.a
and libmpx2c.a.
(run_tests): Add mpx1static, mpx2 and mpx2static.
* ld-x86-64/mpx2.out: Likewise.
* ld-x86-64/mpx2a.c: Likewise.
* ld-x86-64/mpx2a.rd: Likewise.
* ld-x86-64/mpx2b.c: Likewise.
* ld-x86-64/mpx2c.c: Likewise.
* ld-x86-64/mpx2c.rd: Likewise.

10 years agoAdd missing ChangeLog entry.
Pedro Alves [Wed, 20 Nov 2013 17:23:39 +0000 (17:23 +0000)] 
Add missing ChangeLog entry.

2013-11-20  Pedro Alves  <palves@redhat.com>

* gdb.base/maint.exp (maint print objfiles): Consume one line at a
time, and run it through all three milestone regexes.

10 years agoget rid of py-value.c:is_intlike (use is_integral_type instead)
Joel Brobecker [Tue, 19 Nov 2013 02:56:00 +0000 (06:56 +0400)] 
get rid of py-value.c:is_intlike (use is_integral_type instead)

is_intlike was mostly duplicating is_integral_type, with the exception
of the handling of TYPE_CODE_PTR when parameter PTR_OK is nonzero.
This patches deletes the is_intlike function, using is_integral_type
instead, and adjusting the two locations where this function gets
called.

The code should remain strictly equivalent.

gdb/ChangeLog:

        * python/py-value.c (is_intlike): Delete.
        (valpy_int): Replace use of CHECK_TYPEDEF and is_intlike
        by use of is_integral_type.
        (valpy_long): Replace use of CHECK_TYPEDEF and is_intlike
        by use of is_integral_type and check for TYPE_CODE_PTR.

10 years agoMake the maint.exp:'maint print objfiles' test less fragile.
Pedro Alves [Wed, 20 Nov 2013 17:12:37 +0000 (17:12 +0000)] 
Make the maint.exp:'maint print objfiles' test less fragile.

I was "lucky" enough that an unrelated patch changed how many symtabs
GDB expands in a plain run to main, and that triggered a latent issue
in this test:

  PASS: gdb.base/maint.exp: maint print objfiles: header
  PASS: gdb.base/maint.exp: maint print objfiles: psymtabs
  FAIL: gdb.base/maint.exp: maint print objfiles: symtabs

The problem is in my case, expect is managing to alway put in the
buffer chunks like this:

  Psymtabs:
  ../../../src/gdb/testsuite/gdb.base/break1.c at 0x1ed2280, ../../../src/gdb/testsuite/gdb.base/break.c at 0x1ed21d0,

  Symtabs:
  ../../../src/gdb/testsuite/gdb.base/break.c at 0x1f044f0, /usr/include/stdio.h at 0x1ed25a0, /usr/include/libio.h at 0x1ed2510, /usr/include/bits/types.h at 0x1ed2480, /usr/lib/gcc/x86_64-redhat-linux/4.7.2/include/stddef.h at 0x1ed23f0,

  Object file /usr/lib/debug/lib64/ld-2.15.so.debug:  Objfile at 0x1f4bff0, bfd at 0x1f2d940, 0 minsyms

  Psymtabs:
  bsearch.c at 0x1f65340, ../sysdeps/x86_64/multiarch/init-arch.c at
  0x1f65290, ...

Note: Psymtabs:/Symtabs:/Psymtabs:.

So, the loop matches the first Psymtabs in the buffer.  Then we're
left with

  ../../../src/gdb/testsuite/gdb.base/break1.c at 0x1ed2280, ../../../src/gdb/testsuite/gdb.base/break.c at 0x1ed21d0,

  Symtabs:
  ../../../src/gdb/testsuite/gdb.base/break.c at 0x1f044f0, /usr/include/stdio.h at 0x1ed25a0, /usr/include/libio.h at 0x1ed2510, /usr/include/bits/types.h at 0x1ed2480, /usr/lib/gcc/x86_64-redhat-linux/4.7.2/include/stddef.h at 0x1ed23f0,

  Object file /usr/lib/debug/lib64/ld-2.15.so.debug:  Objfile at 0x1f4bff0, bfd at 0x1f2d940, 0 minsyms

  Psymtabs:
  bsearch.c at 0x1f65340, ../sysdeps/x86_64/multiarch/init-arch.c at
  0x1f65290, ...

In the next iteration, because the psymtabs regex comes first, we
match with the Psymtabs: line, then of course, end up with just

  bsearch.c at 0x1f65340, ../sysdeps/x86_64/multiarch/init-arch.c at
  0x1f65290, ...

in the buffer.  The "Symtabs:" line is lost.  expect then reads more
gdb output, and manages to again retrieve the same pattern.  Rinse,
repeat, and the test never matches any "Symtab:" line.

We don't know the order the matches lines will appear, so the fix is
to consume one line at a time, and run it through all three milestone
regexes.

gdb/testsuite/
2013-11-20  Pedro Alves  <palves@redhat.com>

* gdb.base/maint.exp (maint print objfiles): Consume one line at a
time, and run it through all three milestone regexes.

10 years ago * scripttempl/elf32msp430.sc (.data): Set the based on the next
Nick Clifton [Wed, 20 Nov 2013 16:51:21 +0000 (16:51 +0000)] 
* scripttempl/elf32msp430.sc (.data): Set the based on the next
free location in the text memory region, not a computation based
upon the size of the text section.  Orphaned sections or other
linker scripts might insert new sections between the .text section
and the .data section.
* scripttempl/elf32msp430_3.sc (.data): Likewise.

10 years agoremove strerror module
Tom Tromey [Wed, 20 Nov 2013 15:19:05 +0000 (08:19 -0700)] 
remove strerror module

This fixes the mingw build breakage reported by Pierre.

I found that the gnulib strerror module somehow requires us to pull in
the gethostname module.  However, pulling in the gethostname module
makes many things break.

I've sent a bug report to gnulib.

Meanwhile, removing the strerror module should not harm gdb and fixes
the build.

I'm checking this in.

2013-11-20  Tom Tromey  <tromey@redhat.com>

* gnulib/update-gnulib.sh (IMPORTED_GNULIB_MODULES): Remove
strerror module.
* gnulib/aclocal.m4: Update.
* gnulib/config.in: Update.
* gnulib/configure: Update.
* gnulib/import/Makefile.am: Update.
* gnulib/import/Makefile.in: Update.
* gnulib/import/errno.in.h: Remove.
* gnulib/import/intprops.h: Remove.
* gnulib/import/m4/errno_h.m4: Remove.
* gnulib/import/m4/gnulib-cache.m4: Update.
* gnulib/import/m4/gnulib-comp.m4: Update.
* gnulib/import/m4/strerror.m4: Remove.
* gnulib/import/m4/sys_socket_h.m4: Remove.
* gnulib/import/strerror-override.c: Remove.
* gnulib/import/strerror-override.h: Remove.
* gnulib/import/strerror.c: Remove.
* gnulib/update-gnulib.sh: Update.

10 years agotest: test eval routines with EVAL_AVOID_SIDE_EFFECTS flag set
Sanimir Agovic [Wed, 20 Nov 2013 13:45:36 +0000 (13:45 +0000)] 
test: test eval routines with EVAL_AVOID_SIDE_EFFECTS flag set

Ensure that certain commands (e.g. whatis/ptype) and sizeof intrinsic
have no side effects (variables cannot be altered).

2013-11-20  Sanimir Agovic  <sanimir.agovic@intel.com>

testsuite/
* gdb.base/eval-avoid-side-effects.exp: New test.

10 years agoset_address_space_data if dcache is NULL.
Yao Qi [Wed, 20 Nov 2013 12:59:47 +0000 (20:59 +0800)] 
set_address_space_data if dcache is NULL.

gdb:

2013-11-20  Yao Qi  <yao@codesourcery.com>

* target-dcache.c (target_dcache_get_or_init): Call
set_address_space_data if 'dcache' is NULL.

10 years agoAdd MPX registers tests.
Walfred Tedeschi [Thu, 5 Sep 2013 09:09:23 +0000 (09:09 +0000)] 
Add MPX registers tests.

2013-11-20  Walfred Tedeschi  <walfred.tedeschi@intel.com>

* common/i386-gcc-cpuid.h (bit_MPX): Synchronize with gcc file.
testsuite/
* gdb.arch/i386-mpx.c: New file
* gdb.arch/i386-mpx.exp: New file.

Change-Id: Ica4c9ee823c8210ca876e31f27dcd8583b660a9f
Signed-off-by: Walfred Tedeschi <walfred.tedeschi@intel.com>
10 years agoAdd pretty-printer for MPX bnd registers.
Walfred Tedeschi [Wed, 20 Nov 2013 12:03:07 +0000 (13:03 +0100)] 
Add pretty-printer for MPX bnd registers.

Boundary length is simpler implemented by means of a pretty
printer. This simplifies users life when examining a bound register.

Changelog:
2013-11-20  Walfred Tedeschi  <walfred.tedeschi@intel.com>

* python/lib/gdb/command/bound_register.py: New file.
* gdb/data-directory/Makefile.in: copy bond_register.py to the right path to
be initialized at gdb startup.
testsuite/
* gdb.python/py-pp-maint.exp: Consider new pretty-print added for registers.

Change-Id: Id4f39845e5ece56c370a1fd4343648909f08b731
Signed-off-by: Walfred Tedeschi <walfred.tedeschi@intel.com>
Conflicts:

gdb/ChangeLog

10 years agoAdd MPX support to gdbserver.
Walfred Tedeschi [Thu, 10 Oct 2013 07:12:49 +0000 (07:12 +0000)] 
Add MPX support to gdbserver.

2013-05-22  Walfred Tedeschi  <walfred.tedeschi@intel.com>

gdbserver/
* Makefile.in: Add i386-mpx.c, i386-mpx-linux.c, amd64-mpx.c,
amd64-mpx-linux.c, x32-mpx.c and x32-mpx-linux.c generation.

* configure.srv (srv_i386_regobj): Add i386-mpx.o.
(srv_i386_linux_regobj): Add i386-mpx-linux.o.
(srv_amd64_regobj): Add amd64-mpx.o.
(srv_amd64_linux_regobj): Add amd64-mpx-linux.o.
(srv_i386_32bit_xmlfiles): Add i386/32bit-mpx.xml.
(srv_i386_64bit_xmlfiles): Add i386/64bit-mpx.xml.

* i387-fp.c (num_pl_bnd_register) Added constant.
(num_pl_bnd_cfg_registers) Added constant.
(struct i387_xsave) Added reserved area and MPX fields.
(i387_cache_to_xsave, i387_xsave_to_cache) Add MPX.

* linux-x86-low.c (init_registers_i386_mpx_linux): Declare new
function.
(tdesc_i386_mpx_linux): Add MPX amd64 target.
(init_registers_amd64_mpx_linux): Declare new function.
(tdesc_amd64_mpx_linux): Add MPX amd64 target.
(x86_64_regmap): Add MPX registers.
(x86_linux_read_description): Add MPX case.
(initialize_low_arch): Initialize MPX targets.

Change-Id: I394d81afa76d11375ce792cefad0ceb9825fb379
Signed-off-by: Walfred Tedeschi <walfred.tedeschi@intel.com>
10 years agoMPX for amd64
Walfred Tedeschi [Wed, 20 Nov 2013 12:02:37 +0000 (13:02 +0100)] 
MPX for amd64

2013-06-24  Walfred Tedeschi  <walfred.tedeschi@intel.com>

* amd64-linux-nat.c (amd64_linux_gregset32_reg_offset):
Add MPX registers.
(amd64_linux_read_description): Add initialization for MPX and
AVX independently.
* amd64-linux-tdep.c: Includes features/i386/amd64-mpx-linux.c.
(amd64_linux_gregset_reg_offset): Add MPX registers.
(amd64_linux_core_read_description): Add initialization for MPX
registers.
(_initialize_amd64_linux_tdep): Initialize MPX targets.
* amd64-linux-tdep.h (AMD64_LINUX_RAX_REGNUM): Set it to the last
register on the list.
(tdesc_amd64_mpx_linux) Add new target for MPX.
* amd64-tdep.c: Includes features/i386/amd64-mpx.c.
(amd64_mpx_names): MPX register names.
(amd64_init_abi): Add MPX register while initializing the ABI.
(_initialize_amd64_tdep): Initialize MPX targets.
* amd64-tdep.h (amd64_regnum): Add MPX registers.
(AMD64_NUM_REGS): Set number of registers taking MPX into account.

Change-Id: I4a785c181e2fb45e4086650b2f87426caeb2f800
Signed-off-by: Walfred Tedeschi <walfred.tedeschi@intel.com>
Conflicts:

gdb/ChangeLog

10 years agoAdd MPX support for i386
Walfred Tedeschi [Wed, 20 Nov 2013 12:02:00 +0000 (13:02 +0100)] 
Add MPX support for i386

2013-11-20  Walfred Tedeschi  <walfred.tedeschi@intel.com>

* i386-linux-nat.c (GETXSTATEREGS_SUPPLIES): Add MPX
registers on the range of registers to be read from
xsave buffer.
(i386_linux_read_description): Add case for MPX.
* i386-linux-tdep.c: Include features/i386/i386-mpx-linux.c.
(i386_linux_gregset_reg_offset): Add MPX registers.
(i386_linux_core_read_description): Initialize also MPX.
(_initialize_i386_linux_tdep): Add mpx initialization.
* i386-tdep.h (gdbarch_tdep): Add fields bnd0r_regnum, bnd0_regnum,
mpx_register_names.
(i386_regnum): Add MPX registers.
(I386_MPX_NUM_REGS): New macro.
(i386_bnd_regnum_p): New function.
* i386-linux-tdep.h (I386_LINUX_NUM_REGS): Set
number of registers to be the number of BNDSTATUS.
(tdesc_i386_mpx_linux): Add description for MPX Linux registers.
* i386-tdep.c: Include features/i386/i386-mpx.c.
(i386_mpx_names): Add MPX register names array.
(i386_bnd_names): Add bnd pseudo register names array.
(i386_bndr_regnum_p): Lookup register numbers for bnd raw
registers.
(i386_bndr_regnum_p): Lookup register numbers for bnd raw registers.
(386_mpx_ctrl_regnum_p): Lookup register numbers for MPX control
registers.
(i386_bnd_type): New function.
(i386_pseudo_register_type): Use i386_bnd_type for bnd pseudo
register types.
(i386_pseudo_register_read_into_value): Add bnd case.
(i386_pseudo_register_write): Add bnd pseudo registers.
(i386_register_reggroup_p): Add MPX register to the group all.
(i386_validate_tdesc_p): Add MPX to the target  description
validation.
(i386_pseudo_register_name): Add bnd pseudo registers.
(i386_gdbarch_init): Add MPX for architecture initialization.
(_initia_initialize_i386_tdep): Add mpx initialization.
* i387-tdep.c (xsave_mpx_offset): New vector for MPX offsets on
XSAVE buffer.
(XSAVE_MPX_ADDR): New macro.
(i387_supply_xsave): Add MPX case.
(i387_collect_xsave): Add MPX case.
* i387-tdep.h (I387_BND0R_REGNUM): New macro.
(I387_BNDCFGU_REGNUM): New macro.
(I387_NUM_MPX_REGS): New macro.
(I387_NUM_BND_REGS): New macro.
(I387_NUM_MPX_CTRL_REGS): New macro.
(I387_MPXEND_REGNUM): New macro.
* common/i386-xstate.h (I386_XSTATE_BNDREGS): New macro.
(I386_XSTATE_BNDCFG): Likewise.
(I386_XSTATE_MPX_MASK): Likewise.
(I386_XSTATE_ALL_MASK): New macro represents flags for all states.
(I386_XSTATE_BNDREGS_SIZE): New macro.
(I386_XSTATE_BNDCFG_SIZE): Likewise.
(I386_XSTATE_SIZE): Adapt for MPX.
(I386_XSTATE_MAX_SIZE): Likewise.

Change-Id: I9ddb7d49434d86fa18eb6b99515203d7c567aefd
Signed-off-by: Walfred Tedeschi <walfred.tedeschi@intel.com>
Conflicts:

gdb/ChangeLog

10 years agoAdd MPX registers XML files.
Walfred Tedeschi [Wed, 20 Nov 2013 12:01:09 +0000 (13:01 +0100)] 
Add MPX registers XML files.

2013-11-20  Walfred Tedeschi  <walfred.tedeschi@intel.com>

* features/i386/Makefile: Adapts for using MPX registers.
* features/i386/32bit-mpx.xml: New file.
* features/i386/64bit-mpx.xml: Likewise.
* features/i386/amd64-mpx-linux.c: Likewise.
* features/i386/amd64-mpx-linux.xml: Likewise.
* features/i386/amd64-mpx.c: Likewise.
* features/i386/amd64-mpx.xml: Likewise.
* features/i386/i386-mpx-linux.c: Likewise.
* features/i386/i386-mpx-linux.xml: Likewise.
* features/i386/i386-mpx.c: Likewise.
* features/i386/i386-mpx.xml: Likewise.
* regformats/i386/amd64-mpx-linux.dat: New file.
* regformats/i386/amd64-mpx.dat: Likewise.
* regformats/i386/i386-mpx-linux.dat: Likewise.
  * regformats/i386/i386-mpx.dat: Likewise.

10 years agoFix conditions in creating a bitfield.
Walfred Tedeschi [Tue, 19 Nov 2013 12:19:30 +0000 (12:19 +0000)] 
Fix conditions in creating a bitfield.

Bitfields are represented by intervals [start, begin]. It means that for an
interval comprised by only one  bit start and end will be equal.
The present condition does not always hold. On the other hand in target-description.c
(tdesc_gdb_type) bitfield is created when "f->type" is null. The routine
maint_print_maint_print_c_tdesc_cmd is modified to follow the same strategy.

2013-11-20  Walfred Tedeschi  <walfred.tedeschi@intel.com>

* target-descriptions.c (maint_print_maint_print_c_tdesc_cmd):
Modified logic of creating a bitfield to be in sync with
tdesc_gdb_type.

testsuite/
* gdb.xml/maint_print_struct.xml (bitfield): Added bitfield having
start and end equal 0.

Change-Id: I8c62db049995f0c0c30606d9696b86afe237cbb9

10 years agogas/testsuite/
Yufeng Zhang [Wed, 20 Nov 2013 11:22:40 +0000 (11:22 +0000)] 
gas/testsuite/

* gas/aarch64/msr.s: Add tests.
* gas/aarch64/msr.d: Update.

include/opcode

* aarch64.h (aarch64_pstatefields): Change element type to
aarch64_sys_reg.

opcodes/

* aarch64-opc.c (aarch64_pstatefields): Update.

10 years agoRevert "Do not issue error messages when parsing a PSTATE register".
Yufeng Zhang [Tue, 19 Nov 2013 18:11:03 +0000 (18:11 +0000)] 
Revert "Do not issue error messages when parsing a PSTATE register".

This reverts commit 03e621be975dacc9cec9f5782698bdb098f6a49c.

10 years agogdb/arm-tdep.c: Remove "Infinite loop detected" error message.
Will Newton [Fri, 8 Nov 2013 16:26:10 +0000 (16:26 +0000)] 
gdb/arm-tdep.c: Remove "Infinite loop detected" error message.

Since as far back as the beginning of the sourceware repository
the ARM port has printed an error "Infinite loop detected" when
the next_pc calculated is the same as the current one, for example
when encountering a branch to the current PC address.

This causes the test gdb.base/random-signal.exp as the error message
is not expected. I have not been able to find a good reason for the
message to be here so remove it and let the test pass.

gdb/ChangeLog:

2013-11-20  Will Newton  <will.newton@linaro.org>

* arm-tdep.c (arm_get_next_pc): Remove "Infinite loop detected"
error message.

10 years agoAssociate target_dcache to address_space.
Yao Qi [Thu, 31 Oct 2013 14:18:10 +0000 (22:18 +0800)] 
Associate target_dcache to address_space.

Hi,
Nowadays, 'target_dcache' is a global variable in GDB, which is not
necessary.  It can be a per-address-space variable.  In this patch, we
associate target_dcache to address_space.

gdb/doc:

2013-11-20  Yao Qi  <yao@codesourcery.com>

* gdb.texinfo (Caching Target Data): Update doc for
per-address-space dcache.

gdb:

2013-11-20  Yao Qi  <yao@codesourcery.com>

* progspace.h (struct address_space_data): Declare.
* target-dcache.c: Include "progspace.h".
(target_dache): Remove.
(target_dcache_aspace_key): New.
(target_dcache_cleanup): New function.
(target_dcache_init_p): Get data through
target_dcache_aspace_key.
(target_dcache_invalidate): Likewise.
(target_dcache_get): Likewise.
(target_dcache_get_or_init): Likewise.
(_initialize_target_dcache): Initialize
target_dcache_aspace_key.

10 years agoAdd REGISTRY for struct address_space.
Yao Qi [Mon, 21 Oct 2013 08:31:17 +0000 (16:31 +0800)] 
Add REGISTRY for struct address_space.

This patch adds REGISTRY for struct address_space.

gdb:

2013-11-20  Yao Qi  <yao@codesourcery.com>

* progspace.c (struct address_space): Update comments.
<REGISTRY_FIELDS>: New fields.
DEFINE_REGISTRY for address_space.
(new_address_space): Call address_space_alloc_data.
(free_address_space): Call address_space_free_data.
* progspace.h: Use DECLARE_REGISTRY.

10 years agoDon't stress 'remote' in "Data Caching" in doc
Yao Qi [Thu, 31 Oct 2013 12:49:49 +0000 (20:49 +0800)] 
Don't stress 'remote' in "Data Caching" in doc

When I try to describe the cache and its related commands (in a
cache-per-address-space world), I find hard to add, because
existing doc is focused on remote debugging, while data cache is used
regardless of the target.  More precisely, GDB cache target data,
instead of remote data.

gdb/doc:

2013-11-20  Yao Qi  <yao@codesourcery.com>

* gdb.texinfo (Data): Rename menu item.
(Caching Remote Data): Rename to ...
(Caching Target Data): ... it.  Update.

10 years agoMove target-dcache out of target.c
Yao Qi [Thu, 31 Oct 2013 08:50:15 +0000 (16:50 +0800)] 
Move target-dcache out of target.c

This patch moves target_dcache related code out of target.c.

gdb:

2013-11-20  Yao Qi  <yao@codesourcery.com>

* Makefile.in (SFILES):Add target-dcache.c.
(HFILES_NO_SRCDIR): Add target-dcache.h.
(COMMON_OBS): Add target-dcache.o.
* dcache.c: Remove inclusion to "target.h".  Include
"target-dcache.h".
* memattr.c: Include "target-dcache.h".
* top.c: Likewise.
* tracepoint.c: Likewise.
* target.c: (stack_cache_enabled_p_1): Move to
target-dcache.c.
(stack_cache_enabled_p): Likewise.
(set_stack_cache_enabled_p): Likewise.
(show_stack_cache_enabled_p): Likewise.
(target_dcache, target_dcache_init_p): Likewise.
(target_dcache_invalidate): Likewise.
(target_dcache_get, target_dcache_get_or_init): Likewise.
(memory_xfer_partial_1): Call function stack_cache_enabled.
(initialize_target): Move code to target-dcache.c.
* target.h (target_dcache_invalidate): Move to
target-dcache.h.
(target_dcache_get): Likewise.
* target-dcache.c: New.
* target-dcache.h: New.

10 years agoDon't update target_dcache if it is not initialized
Yao Qi [Thu, 31 Oct 2013 07:01:33 +0000 (15:01 +0800)] 
Don't update target_dcache if it is not initialized

After previous patch, 'target_dcache' is initialized lazily.  It is
possible that 'target_dcache' is still NULL when GDB writes to memory.
In this case, update to 'target_dcache' can be skipped.

gdb:

2013-11-20  Yao Qi  <yao@codesourcery.com>

* target.c (memory_xfer_partial_1): Update 'target_dcache' if
it is initialized.

10 years agoRemove last_cache
Yao Qi [Tue, 29 Oct 2013 13:34:20 +0000 (21:34 +0800)] 
Remove last_cache

This patch removes global variable 'last_cache', and initialize
'target_dcache' lazily, so that 'target_dcache' can replace
'last_cache'.  No functionalities should be changed after this patch.

gdb:

2013-11-20  Yao Qi  <yao@codesourcery.com>

* dcache.c (last_cache): Remove.
(dcache_free, dcache_init): Update.
(dcache_update):
(dcache_print_line): Add parameter 'dcache'.  Replace
'target_dcache' with 'dcache'.
(dcache_info): Move code to dcache_info_1. Call
'dcache_info_1'.
(dcache_info_1): New function.
(set_dcache_size): Call target_dcache_invalidate.
(set_dcache_line_size): Call target_dcache_invalidate.
* target.c (target_dcache_init_p): New function.
(target_dcache_invalidate): Check target_dcache_init_p first.
(target_dcache_get, target_dcache_get_or_init): New function.
(memory_xfer_partial_1): Adjust.
(initialize_target): Don't initialize 'target_dcache'.
* target.h (struct dcache_struct): Declare.
(target_dcache_get): Declare.

10 years agoMove changelog entry to the right ChangeLog
Yao Qi [Wed, 20 Nov 2013 03:02:17 +0000 (11:02 +0800)] 
Move changelog entry to the right ChangeLog

10 years agoFix *-nacl* target objcopy/strip of binary made with custom linker script
Roland McGrath [Tue, 19 Nov 2013 22:57:54 +0000 (14:57 -0800)] 
Fix *-nacl* target objcopy/strip of binary made with custom linker script

bfd/
* elf-nacl.c (nacl_modify_segment_map): Calculate SIZEOF_HEADERS
when not doing linking (i.e. INFO is a null pointer).

10 years agodaily update
Alan Modra [Tue, 19 Nov 2013 23:00:01 +0000 (09:30 +1030)] 
daily update

10 years agoRe-indent elf_x86_64_section_from_shdr
H.J. Lu [Tue, 19 Nov 2013 21:00:42 +0000 (13:00 -0800)] 
Re-indent elf_x86_64_section_from_shdr

* elf64-x86-64.c (elf_x86_64_section_from_shdr): Re-indent.

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