platform/upstream/binutils.git
10 years agoTLS orphan section placement
Alan Modra [Fri, 24 Jan 2014 12:47:28 +0000 (23:17 +1030)]
TLS orphan section placement

Ensures TLS orphans are placed adjacent to existing TLS sections,
and fixes places where the output_section_statement flags (which might
not be set) were tested when bfd_section flags were available.

* ldlang.c (lang_output_section_find_by_flags): Be careful to
test look->bfd_section->flags if available rather than
look->flags.  Separate SEC_THREAD_LOCAL handling from
SEC_READONLY loop, and rewrite.

10 years agoFixes powerpc64le ld segfaults when --emit-relocs is used.
Alan Modra [Fri, 24 Jan 2014 03:52:10 +0000 (14:22 +1030)]
Fixes powerpc64le ld segfaults when --emit-relocs is used.

ELFv2 needs fewer relocs to annotate plt call stubs.  I correctly
allocated a smaller buffer and wrote the proper relocs, but stupidly
bumped the reloc count as for ELFv1.

* elf64-ppc.c (ppc_build_one_stub): Correct reloc count passed
to get_relocs for ELFv2.

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

10 years agoRemove the display of known MCU names from the MSP430 port of GAS.
Nick Clifton [Thu, 23 Jan 2014 17:08:24 +0000 (17:08 +0000)]
Remove the display of known MCU names from the MSP430 port of GAS.

New MSP430 MCU parts are being created by TI all the time and the
list is basically always out of date.  Instead any name will be
accepted by the -mmcu= command line option.  ISA selection is now
based upon the -mcpu= command line option, just as is done for GCC.

gas/ChangeLog
* config/tc-msp430.c (show_mcu_list): Delete.
(md_parse_option): Accept any MCU name.  Accept several more
variants for the -mcpu option.
(md_show_usage): Do not call show_mcu_list.

10 years agoIssue a linker error if TLS sections are not adjacent
H.J. Lu [Thu, 23 Jan 2014 16:15:17 +0000 (08:15 -0800)]
Issue a linker error if TLS sections are not adjacent

Bad linker script may lead to TLS sections separated by non-TLS sections
in output.  This patch changes linker assert to a linker error to
provide better linker diagnosis.

PR ld/16498
* elf.c (_bfd_elf_map_sections_to_segments): Issue a linker error
if TLS sections are not adjacent.

10 years agoavoid python exception in FrameDecorator.py
Tom Tromey [Wed, 22 Jan 2014 15:52:15 +0000 (08:52 -0700)]
avoid python exception in FrameDecorator.py

This fixes a bug in FrameDecorator.py.

FrameVars seems to assume that Frame.block can return None if there is
no block.  However, it actually throws an exception.

I saw this bug while developing a frame filter, but unfortunately I
don't know how to reproduce it.  It seems to me that the SAL tests in
_is_limited_frame should exclude the bad cases; and in my attempts to
write a test they do.

Nevertheless I think the fix is reasonably obvious and ought to go in.

2014-01-23  Tom Tromey  <tromey@redhat.com>

PR python/16485:
* python/lib/gdb/FrameDecorator.py: (FrameVars.fetch_frame_args):
Handle exception from frame.block.
(FrameVars.fetch_frame_locals): Likewise.

10 years agofix erroneous error-handling in frame filter code
Tom Tromey [Wed, 22 Jan 2014 15:44:41 +0000 (08:44 -0700)]
fix erroneous error-handling in frame filter code

This fixes PR python/16487.

The bug here is that the function-name-handling code in py_print_frame
had a small logic error (really a misplaced closing brace).  This
error could lead to a Py_DECREF(NULL), which crashes.

This patch fixes the bug in the obvious way.

Built and regtested on x86-64 Fedora 18.  New test case included.

2014-01-23  Tom Tromey  <tromey@redhat.com>

PR python/16487:
* python/py-framefilter.c (py_print_frame): Don't call Py_DECREF
on a NULL pointer.  Move "goto error" to correct place.

2014-01-23  Tom Tromey  <tromey@redhat.com>

PR python/16487:
* gdb.python/py-framefilter.exp: Add test using "Error" filter.
* gdb.python/py-framefilter.py (ErrorInName, ErrorFilter): New
classes.

10 years agofix crash in frame filters
Tom Tromey [Wed, 22 Jan 2014 15:10:01 +0000 (08:10 -0700)]
fix crash in frame filters

apply_frame_filter calls ensure_python_env before computing the
gdbarch to use.  This means that python_gdbarch can be NULL while in
Python code, and if a frame filter depends on this somehow (easy to
do), gdb will crash.

The fix is to compute the gdbarch first.

Built and regtested on x86-64 Fedora 18.
New test case included.

2014-01-23  Tom Tromey  <tromey@redhat.com>

PR python/16491:
* python/py-framefilter.c (apply_frame_filter): Call
ensure_python_env after computing gdbarch.

2014-01-23  Tom Tromey  <tromey@redhat.com>

PR python/16491:
* gdb.python/py-framefilter.py (Reverse_Function.function): Read a
string from an inferior frame.
* gdb.python/py-framefilter-mi.exp: Update.

10 years agoUse gdb_byte * instead of void *
Yao Qi [Mon, 16 Dec 2013 06:39:12 +0000 (14:39 +0800)]
Use gdb_byte * instead of void *

This patch changes the argument type to gdb_byte * in order to align
with the to_xfer_partial interface.

gdb:

2014-01-23  Yao Qi  <yao@codesourcery.com>

* target.c (raw_memory_xfer_partial): Change argument type
from void * to gdb_byte *.
(memory_xfer_partial_1, memory_xfer_partial): Likewise.

10 years ago * gdbthread.h (gdb_id_to_thread): Delete, unused.
Doug Evans [Thu, 23 Jan 2014 00:39:29 +0000 (16:39 -0800)]
* gdbthread.h (gdb_id_to_thread): Delete, unused.

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

10 years ago New gdbserver option --debug-format=timestamp.
Doug Evans [Wed, 22 Jan 2014 22:17:39 +0000 (14:17 -0800)]
New gdbserver option --debug-format=timestamp.
* NEWS: Mention it.

gdbserver/
* configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday.
* configure: Regenerate.
* config.in: Regenerate.
* Makefile.in (SFILES): Add debug.c.
(OBS): Add debug.o.
* debug.c: New file.
* debug.h: New file.
* linux-aarch64-low.c (*): Update all debugging printfs to use
debug_printf instead of fprintf.
* linux-arm-low.c (*): Ditto.
* linux-cris-low.c (*): Ditto.
* linux-crisv32-low.c (*): Ditto.
* linux-m32r-low.c (*): Ditto.
* linux-sparc-low.c (*): Ditto.
* linux-x86.c (*): Ditto.
* linux-low.c (*): Ditto.
(linux_wait_1): Add calls to debug_enter, debug_exit.
(linux_wait): Remove redundant debugging printf.
(stop_all_lwps): Add calls to debug_enter, debug_exit.
(linux_resume, unstop_all_lwps): Ditto.
* mem-break.c (*): Update all debugging printfs to use
debug_printf instead of fprintf.
* remote-utils.c (*): Ditto.
* thread-db.c (*): Ditto.
* server.c #include <ctype.h>, "gdb_vecs.h".
(debug_threads): Moved to debug.c.
(*): Update all debugging printfs to use debug_printf instead of
fprintf.
(start_inferior): Replace call to fflush with call to debug_flush.
(monitor_show_help): Mention set debug-format.
(parse_debug_format_options): New function.
(handle_monitor_command): Handle "monitor set debug-format".
(gdbserver_usage): Mention --debug-format.
(main): Parse --debug-format.
* server.h (debug_threads): Declaration moved to debug.h.
#include "debug.h".
* tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of
trace_debug_1 that uses debug_printf.
(tracepoint_look_up_symbols): Update all debugging printfs to use
debug_printf instead of fprintf.

doc/
* gdb.texinfo (Server): Mention --debug-format=all|none|timestamp.
(gdbserver man): Ditto.

testsuite/
* gdb.server/server-mon.exp: Add tests for "set debug-format".

10 years agoAdd .refsym to msp430 backend
DJ Delorie [Wed, 22 Jan 2014 21:41:13 +0000 (16:41 -0500)]
Add .refsym to msp430 backend

* config/tc-msp430.c (msp430_refsym): New: ".refsym <symbol>"
* doc/c-msp430.texi (MSP430 Directives): Document it.

The purpose of this patch is to provide a way for one object file
to require the inclusion of another object, without having to
allocate space for a .word address reference.

10 years agoRemove regzmm from AVX2 gather assert
Michael Zolotukhin [Wed, 22 Jan 2014 19:39:02 +0000 (11:39 -0800)]
Remove regzmm from AVX2 gather assert

Since regzmm can't be used in AVX2 gather instructions, there is no need
to check regzmm in AVX2 gather assert.

2014-01-22  Michael Zolotukhin  <michael.v.zolotukhin@gmail.com>

* config/tc-i386.c (check_VecOperands): Remove regzmm from AVX2
gather assert.

10 years agoAdd check for invalid register in AVX512 gathers
Michael Zolotukhin [Wed, 22 Jan 2014 17:57:31 +0000 (09:57 -0800)]
Add check for invalid register in AVX512 gathers

AVX512 gather instructions shouldn't accept the same register for both
destination and index.

gas/

2014-01-22  Michael Zolotukhin  <michael.v.zolotukhin@gmail.com>

PR gas/16489
* config/tc-i386.c (check_VecOperands): Add check for invalid
register set in AVX512 gathers.

gas/testsuite/

2014-01-22  Michael Zolotukhin  <michael.v.zolotukhin@gmail.com>

PR gas/16489
* gas/i386/vgather-check.s: Add tests for AVX512 gathers.
* gas/i386/x86-64-vgather-check.s: Likewise.
* gas/i386/vgather-check-error.l: Update correspondingly.
* gas/i386/vgather-check-none.d: Likewise.
* gas/i386/vgather-check-warn.d: Likewise.
* gas/i386/vgather-check-warn.e: Likewise.
* gas/i386/vgather-check.d: Likewise.
* gas/i386/x86-64-vgather-check-error.l: Likewise.
* gas/i386/x86-64-vgather-check-none.d: Likewise.
* gas/i386/x86-64-vgather-check-warn.d: Likewise.
* gas/i386/x86-64-vgather-check-warn.e: Likewise.
* gas/i386/x86-64-vgather-check.d: Likewise.

10 years agogdb/ChangeLog:
Andreas Arnez [Wed, 22 Jan 2014 17:54:43 +0000 (18:54 +0100)]
gdb/ChangeLog:
* syscalls/s390x-linux.xml: New file.
* syscalls/s390-linux.xml: New file.
* s390-linux-tdep.c (XML_SYSCALL_FILENAME_S390): New macro.
(XML_SYSCALL_FILENAME_S390X): Likewise.
(op_svc): New enum value for SVC opcode.
(s390_sigtramp_frame_sniffer): Replace literal by 'op_svc'.
(s390_linux_get_syscall_number): New function.
(s390_gdbarch_init): Register '*get_syscall_number' and the
syscall xml file name.
* data-directory/Makefile.in (SYSCALLS_FILES): Add
"s390-linux.xml" and "s390x-linux.xml".
* NEWS: Announce new feature.

gdb/testsuite/ChangeLog:
* gdb.base/catch-syscall.exp: Activate test on s390*-linux.

10 years agoFix regression on s390x with entry-values.exp.
Andreas Arnez [Wed, 22 Jan 2014 15:37:41 +0000 (15:37 +0000)]
Fix regression on s390x with entry-values.exp.

The trace-specific test case 'entry-values' concludes fairly late in
the process that this platform doesn't support trace.  Before that,
there are some platform specifics that don't work on s390x.  The fix
addresses two aspects:

(1) Removal of an excess space character in the regex for the
    disassembly.  This is needed when there is a function alignment
    gap, because then the hex address is immediately followed by a
    colon, like in the first 'nopr' line below:

    (gdb) disassemble foo+50,+10
    Dump of assembler code from 0x32 to 0x3c:
       0x0000000000000032 <foo+50>: br      %r4
       0x0000000000000034:  nopr    %r7
       0x0000000000000036:  nopr    %r7
       0x0000000000000038 <bar+0>:  stmg    %r11,%r15,88(%r15)
    End of assembler dump.

(2) Handling for the s390-specific call instruction.

gdb/testsuite/ChangeLog:
* gdb.trace/entry-values.exp: Remove excess space character from
regex patterns.  Handle s390 call instruction.

10 years agoRe-introduce '_start' labels and add alignment in dw2-dir-file-name test case.
Andreas Arnez [Wed, 22 Jan 2014 15:33:00 +0000 (15:33 +0000)]
Re-introduce '_start' labels and add alignment in dw2-dir-file-name test case.

On ppc64-linux a function symbol does not point to code, but to the
function descriptor.  Thus the previous change for this test case
broke it:

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

This patch reverts to the original method, re-introducing '_start'
symbols.  In addition, it adds sufficient alignment before the label,
such that the label never points into an alignment gap.

gdb/testsuite/ChangeLog:
* gdb.dwarf2/dw2-dir-file-name.c (FUNC): Insert alignment and
define "*_start" label.  Make "name" static.
* gdb.dwarf2/dw2-dir-file-name.exp: Replace references to
${name} by references to ${name}_start.

10 years agoPrevent appending "-g" after "-g3" to compile options in info-macros.exp.
Andreas Arnez [Wed, 22 Jan 2014 15:31:10 +0000 (15:31 +0000)]
Prevent appending "-g" after "-g3" to compile options in info-macros.exp.

When upstream gcc is given a command line with the "-g" option after
"-g3", it doesn't generate a ".debug_macro" section.  This is because
the last option wins, thus downgrading the debug level again.  Without
any macro debug information in the executable, info-macros.exp
obviously produces many failures.

Since the "-g" option is appended by DejaGnu's target_compile whenever
the "debug" option is set, the fix just removes that option.

gdb/testsuite/ChangeLog:
* gdb.base/info-macros.exp: Remove "debug" from the compile
options.

10 years agogdb: xtensa: fix on 64-bit hosts
Baruch Siach [Wed, 22 Jan 2014 13:02:29 +0000 (15:02 +0200)]
gdb: xtensa: fix on 64-bit hosts

On 64-bit hosts unsigned long is 64 bit.  Use uint32_t instead.

gdb/
2014-01-22  Baruch Siach  <baruch@tkos.co.il>

* xtensa-tdep.h (xtensa_elf_greg_t): Change type to uint32_t.

10 years agoxtensa-config.c: missing defs.h include.
Pedro Alves [Wed, 22 Jan 2014 12:01:53 +0000 (12:01 +0000)]
xtensa-config.c: missing defs.h include.

All .c files must start by including defs.h.

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

* xtensa-config.c: Include defs.h.

10 years agoDisplay the reference causing a shared library to be needed
Alan Modra [Wed, 22 Jan 2014 05:35:12 +0000 (16:05 +1030)]
Display the reference causing a shared library to be needed

Adds a section for --as-needed libraries to a linker map file, similar
to what we do for archive libraries.

bfd/
* elflink.c (elf_link_add_object_symbols): Call minfo for --as-needed.
ld/
* ldlang.c (asneeded_list_head, asneeded_list_tail): New vars.
(lang_init): Initialise them.
(lang_print_asneeded): New function.
(lang_process): Call lang_print_asneeded.
* ldlang.h (struct asneeded_minfo): New.
(asneeded_list_tail): Declare.
* ldmain.c (add_archive_element): Improve archive map heading.
* ldmisc.c (minfo): Stash --as-needed info.

10 years agoFix gas build breakage
Alan Modra [Wed, 22 Jan 2014 05:06:27 +0000 (15:36 +1030)]
Fix gas build breakage

* config/tc-tic4x.c (md_shortopts): s/CONST/const/.

10 years agoComment typo
Alan Modra [Wed, 22 Jan 2014 05:04:30 +0000 (15:34 +1030)]
Comment typo

* elf64-ppc.c (STK_LINKER): Comment typo fix.

10 years agoAdd ARI (ok) marker for __func__ reference in common-utils.h
Joel Brobecker [Tue, 21 Jan 2014 10:16:57 +0000 (14:16 +0400)]
Add ARI (ok) marker for __func__ reference in common-utils.h

The ARI script flagged the use of the __func__ variable, which
is normally not allowed (not defined in C90). However, this particular
use is OK, as the reference is only made when __STDC_VERSION__ >=
199901L.  So, add an "ARI:" comment to explicitly OK this use.

gdb/ChangeLog:

        * common/common-utils.h: Add "ARI:" comment beside __func__
        reference.

10 years agoExpand documentation of common-utils.h::FUNCTION_NAME
Joel Brobecker [Tue, 21 Jan 2014 10:20:50 +0000 (14:20 +0400)]
Expand documentation of common-utils.h::FUNCTION_NAME

While looking at this macro, I noticed that it wasn't always necessarily
defined. That prompted me to search the current sources to make sure
that all uses were adequately protected, which they were. But to help
prevent future uses to be made unprotected, this patch expands the
current macro documentation a bit.

gdb/ChangeLog:

        * common/common-utils.h (FUNCTION_NAME): Expand the macro's
        documentation a bit.

10 years agoMiscellaneous ld tidies
Alan Modra [Wed, 22 Jan 2014 02:21:19 +0000 (12:51 +1030)]
Miscellaneous ld tidies

Localise a struct, prevent an unneeded symbol lookup, and fix a
testcase.

ld/
* ld.h (struct map_symbol_def): Move to..
* ldlang.h: ..here.
* ldlang.c (print_assignment): Don't set expld.assign_name to dot.
ld/testsuite/
* ld-scripts/pr14962-2.d: Correct target triple.

10 years agoMake assignments to dot keep an empty output section.
Alan Modra [Wed, 22 Jan 2014 01:13:03 +0000 (11:43 +1030)]
Make assignments to dot keep an empty output section.

An assignment to dot in an output section that allocates space of
course keeps the output section.  Here, I'm changing the behaviour for
assignments that don't allocate space.  The idea is not so much to
allow people to force output of an empty section with ". = .", but
to fix cases where an otherwise empty section has padding added by an
alignment expression that changes with relaxation or .eh_frame
editing.  Such a section might have zero size before relaxation and so
be stripped incorrectly.

ld/
* ld.texinfo (Output Section Discarding): Mention assigning to dot
as a way of keeping otherwise empty sections.
* ldexp.c (is_dot, is_value, is_sym_value, is_dot_ne_0,
is_dot_plus_0, is_align_conditional): New predicates.
(exp_fold_tree_1): Set SEC_KEEP when assigning to dot inside an
output section, except for some special cases.
* scripttempl/elfmicroblaze.sc: Use canonical form to align at
end of .heap and .stack.
ld/testsuite/
* ld-shared/elf-offset.ld: Align end of .bss with canonical form
of ALIGN that allows an empty .bss to be removed.
* ld-arm/arm-dyn.ld: Likewise.
* ld-arm/arm-lib.ld: Likewise.
* ld-elfvsb/elf-offset.ld: Likewise.
* ld-mips-elf/mips-dyn.ld: Likewise.
* ld-mips-elf/mips-lib.ld: Likewise.
* ld-arm/arm-no-rel-plt.ld: Remove duplicate ALIGN.
* ld-powerpc/vle-multiseg-1.ld: Remove ALIGN at start of section.
ALIGN address of section instead.
* ld-powerpc/vle-multiseg-2.ld: Likewise.
* ld-powerpc/vle-multiseg-3.ld: Likewise.
* ld-powerpc/vle-multiseg-4.ld: Likewise.
* ld-powerpc/vle-multiseg-6.ld: Likewise.
* ld-scripts/empty-aligned.d: Check section headers not program
headers.  Remove xfail and notarget.
* ld-scripts/empty-aligned.t: Use canonical ALIGN for end of .text2.

10 years agoCheck incompatible existing default symbol definition
H.J. Lu [Tue, 21 Jan 2014 23:42:43 +0000 (15:42 -0800)]
Check incompatible existing default symbol definition

After resolving a versioned reference, foo@VER1, to a default versioned
definition, foo@@VER1, from a shared object, we also merge it with
the existing regular default symbol definition, foo.  When foo is IFUNC
and foo@@VER1 aren't, we will merge 2 incompatible definitions.  This
patch avoids merging foo@@VER1 definition with foo definition if
one is IFUNC and the other isn't.

10 years agodaily update
Alan Modra [Tue, 21 Jan 2014 23:01:03 +0000 (09:31 +1030)]
daily update

10 years agoEnsure that %func() expressions are outermost terms
DJ Delorie [Tue, 21 Jan 2014 20:12:19 +0000 (15:12 -0500)]
Ensure that %func() expressions are outermost terms

This is to avoid expressions like:  %hi(foo) + 1, which will
not do what you expect.  The complex relocations can handle it,
but the internal fixups can't.

10 years agogdb: Support install-strip target
Roland McGrath [Tue, 21 Jan 2014 19:01:04 +0000 (11:01 -0800)]
gdb: Support install-strip target

gdb/
* configure.ac: Call AM_PROG_INSTALL_STRIP.
* configure: Regenerate.
* aclocal.m4: Regenerate.
* Makefile.in (install_sh, INSTALL_STRIP_PROGRAM, STRIP):
New substituted variables.
(install-strip): New target.
(INSTALL_SCRIPT): New substituted variable.
(FLAGS_TO_PASS): Add it.
(install-only): Use $(INSTALL_SCRIPT) rather than
$(INSTALL_PROGRAM) for gcore.

10 years ago[PATCH] include * ansidecl.h (ANSI_PROTOTYPES, PTRCONST, LONG_DOUBLE, PARAMS) ...
tromey [Tue, 21 Jan 2014 15:09:10 +0000 (15:09 +0000)]
[PATCH] include  * ansidecl.h (ANSI_PROTOTYPES, PTRCONST, LONG_DOUBLE, PARAMS)  (VPARAMS, VA_START, VA_OPEN, VA_CLOSE, VA_FIXEDARG, CONST)  (VOLATILE, SIGNED, PROTO, EXFUN, DEFUN, DEFUN_VOID, AND, DOTS)  (NOARGS): Don't define.  * libiberty.h (expandargv, writeargv): Don't use PARAMS. libiberty  * _doprint.c (checkit): Use stdarg, not VA_* macros.  * asprintf.c (asprintf): Use stdarg, not VA_* macros.  * concat.c (concat_length, concat_copy, concat_copy2, concat)  (reconcat): Use stdarg, not VA_* macros.  * snprintf.c (snprintf): Use stdarg, not VA_* macros.  * vasprintf.c (checkit): Use stdarg, not VA_* macros.  * vsnprintf.c (checkit): Use stdarg, not VA_* macros.

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

10 years agoUpdate comments for the last commit
H.J. Lu [Tue, 21 Jan 2014 13:37:45 +0000 (05:37 -0800)]
Update comments for the last commit

10 years agoDon't check shared/export_dynamic/ref_dynamic for type mismatch
H.J. Lu [Tue, 21 Jan 2014 13:33:48 +0000 (05:33 -0800)]
Don't check shared/export_dynamic/ref_dynamic for type mismatch

There is nothing linker can do when a type mismatched default definition
are made dynamic by info->shared, info->export_dynamic or h->ref_dynamic.
But we do want to avoid exporting it when building PIE.  Let's remove
those checks.

bfd/

PR ld/2404
* elflink.c (_bfd_elf_merge_symbol): Don't check info->shared,
info->export_dynamic, nor !h->ref_dynamic for type mismatch when
adding the default version.

ld/testsuite/

PR ld/2404
* ld-elf/shared.exp: Add a PIE test for PR ld/2404.

10 years agodaily update
Alan Modra [Mon, 20 Jan 2014 23:01:08 +0000 (09:31 +1030)]
daily update

10 years ago[AArch64] Define LP64 BE linker name.
Marcus Shawcroft [Mon, 20 Jan 2014 18:20:04 +0000 (18:20 +0000)]
[AArch64] Define LP64 BE linker name.

10 years ago[AArch64] Define LP64 LE loader name.
Marcus Shawcroft [Mon, 20 Jan 2014 18:18:52 +0000 (18:18 +0000)]
[AArch64] Define LP64 LE loader name.

10 years agobetter packing for command struct
Tom Tromey [Fri, 27 Dec 2013 05:06:27 +0000 (22:06 -0700)]
better packing for command struct

This moves all the bitfields in struct cmd_list_element to be closer
together.  This packs the structure somewhat better.  On a 64 bit
machine, this simple rearrangement saves around 50k at startup.

2014-01-20  Tom Tromey  <tromey@redhat.com>

* cli/cli-decode.h (struct cmd_list_element): Move all bitfields
together.

10 years agoconvert flags to bitfields
Tom Tromey [Fri, 27 Dec 2013 05:04:40 +0000 (22:04 -0700)]
convert flags to bitfields

This changes various flags struct cmd_list_element into bitfields.  In
general I think bitfields are cleaner than flag words, at least in a
case like this where there is no need to pass the flags around
independently of the enclosing struct.

2014-01-20  Tom Tromey  <tromey@redhat.com>

* cli/cli-decode.c (add_cmd, deprecate_cmd, add_alias_cmd)
(add_setshow_cmd_full, delete_cmd, lookup_cmd_1)
(deprecated_cmd_warning, complete_on_cmdlist): Update.
* cli/cli-decode.h (CMD_DEPRECATED, DEPRECATED_WARN_USER)
(MALLOCED_REPLACEMENT, DOC_ALLOCATED): Remove.
(struct cmd_list_element) <flags>: Remove.
<cmd_deprecated, deprecated_warn_user, malloced_replacement,
doc_allocated>: New fields.
<hook_in, allow_unknown, abbrev_flag, type, var_type>: Now
bitfields.
* maint.c (maintenance_do_deprecate): Update.
* top.c (execute_command): Update.

10 years agoAdd a testcase for PR ld/2404
H.J. Lu [Mon, 20 Jan 2014 12:50:47 +0000 (04:50 -0800)]
Add a testcase for PR ld/2404

PR ld/2404 was fixed without a testcase.  This patch to add one.

PR ld/2404
* ld-elf/pr2404.out: New file.
* ld-elf/pr2404a.c: Likewise.
* ld-elf/pr2404b.c: Likewise.

* ld-elf/shared.exp (build_tests): Build libpr2404a.so and
libpr2404b.a.
(run_tests): Run pr2404.

10 years agogdb: xtensa: fix linux ptrace includes
Baruch Siach [Mon, 20 Jan 2014 07:53:12 +0000 (09:53 +0200)]
gdb: xtensa: fix linux ptrace includes

Currently, xtensa code using the Linux ptrace interface only include
sys/ptrace.h.  This file comes from the C library (glibc and uClibc,
at least), and includes a declaration of the ptrace() functions, along
with some cross architecture constants that are mostly copied from the
file located at include/uapi/linux/ptrace.h in recent Linux kernels.

For xtensa specific constants like PTRACE_GETXTREGS and
PTRACE_SETXTREGS the asm/ptrace.h include from the Linux kernel UAPI
is needed.  The code in gdbserver xtensa specific part doesn't call
ptrace() directly, so we can remove the unneeded sys/ptrace.h include.
The gdb xtensa specific code needs both headers, since it calls
ptrace().

gdb/
* xtensa-linux-nat.c: Include asm/ptrace.h.

gdb/gdbserver/
* linux-xtensa-low.c: Include asm/ptrace.h instead of
sys/ptrace.h.

10 years agoAllow self-assignment for absolute symbols defined in a linker script
Alan Modra [Mon, 20 Jan 2014 10:58:42 +0000 (21:28 +1030)]
Allow self-assignment for absolute symbols defined in a linker script

Modifies ld machinery tracking linker script assignments to notice all
assignments, not just those symbols mentioned in DEFINED().

ld/
PR ld/14962
* ldlang.h (struct lang_definedness_hash_entry): Add by_object and
by_script.  Make iteration a single bit field.
(lang_track_definedness, lang_symbol_definition_iteration): Delete.
(lang_symbol_defined): Declare.
* ldlang.c (lang_statement_iteration): Expand comment a little.
(lang_init <lang_definedness_table>): Make it bigger.
(lang_track_definedness, lang_symbol_definition): Delete.
(lang_definedness_newfunc): Update.
(lang_symbol_defined): New function.
(lang_update_definedness): Create entries here.  Do track whether
script definition of symbol is valid, even when also defined in
an object file.
* ldexp.c (fold_name <DEFINED>): Update.
(fold_name <NAME>): Allow self-assignment for absolute symbols
defined in a linker script.
ld/testsuite/
* ld-scripts/pr14962-2.d,
* ld-scripts/pr14962-2.t: New test.
* ld-scripts/expr.exp: Run it.

10 years agoFix duplicate output section statement lookup
Guy Martin [Mon, 20 Jan 2014 03:46:16 +0000 (14:16 +1030)]
Fix duplicate output section statement lookup

Tie output section statements to their associated output section via
output section userdata.  This allows us to avoid hash lookups which
are slower and fail when multiple output sections have the same name.

* ldlang.h (lang_output_section_get): Define.
* ldlang.c (lang_output_section_get): Likewise.
(init_os): Set the output_section userdata to the output
section statement.
* emultempl/hppaelf.em: Use lang_output_section_get instead of
lang_output_section_find where applicable.
* emultempl/aarch64elf.em: Likewise.
* emultempl/aix.em: Likewise.
* emultempl/armelf.em: Likewise.
* emultempl/m68hc1xelf.em: Likewise.
* emultempl/metagelf.em: Likewise.
* emultempl/mipself.em: Likewise.
* emultempl/ppc64elf.em: Likewise.
* emultempl/spuelf.em: Likewise.

10 years agodaily update
Alan Modra [Sun, 19 Jan 2014 23:01:05 +0000 (09:31 +1030)]
daily update

10 years agoMove D demangling routines out of d-lang.c and into d-support.c, which
Iain Buclaw [Sat, 18 Jan 2014 17:27:28 +0000 (17:27 +0000)]
Move D demangling routines out of d-lang.c and into d-support.c, which
is intended to house other D language support functions.

gdb/ChangeLog:
2014-01-17  Iain Buclaw  <ibuclaw@gdcproject.org>

    * Makefile.in (SFILES): Add d-support.c.
    (COMMON_OBS): Add d-support.o.
    * d-lang.h (d_parse_symbol): Add comment, now defined in
    d-support.c.
    * d-lang.c (parse_call_convention)
    (parse_attributes, parse_function_types)
    (parse_function_args, parse_type, parse_identifier)
    (call_convention_p, d_parse_symbol): Move functions to ...
    * d-support.c: ... New file.

10 years agoFix and update D demangling support in gdb to the current mangling ABI.
Iain Buclaw [Sat, 18 Jan 2014 17:22:00 +0000 (17:22 +0000)]
Fix and update D demangling support in gdb to the current mangling ABI.

gdb/ChangeLog:
2014-01-17  Iain Buclaw  <ibuclaw@gdcproject.org>

    * d-lang.h (d_parse_symbol): Add declaration.
    * d-lang.c (extract_identifiers)
    (extract_type_info): Remove functions.
    (parse_call_convention, parse_attributes)
    (parse_function_types, parse_function_args)
    (parse_type, parse_identifier, call_convention_p)
    (d_parse_symbol): New functions.
    (d_demangle): Use d_parse_symbol to demangle D symbols.

gdb/testsuite/ChangeLog:
2014-01-17  Iain Buclaw  <ibuclaw@gdcproject.org>

* gdb.dlang/demangle.exp: New file.

10 years agoDefine all basic data types of D and add them to the primitive type
Iain Buclaw [Sat, 18 Jan 2014 17:18:23 +0000 (17:18 +0000)]
Define all basic data types of D and add them to the primitive type
language vector.

gdb/ChangeLog:
2014-01-17  Iain Buclaw  <ibuclaw@gdcproject.org>

    * d-lang.h (struct builtin_d_type): New data type.
    (builtin_d_type): Add declaration.
    * d-lang.c (d_language_arch_info, build_d_types)
    (builtin_d_type): New functions.
    (enum d_primitive_types): New data type.
    (d_language_defn): Change c_language_arch_info to
    d_language_arch_info.
    (d_type_data): New static variable.
    (_initialize_d_language): Initialize d_type_data.

gdb/testsuite/ChangeLog:
2014-01-17  Iain Buclaw  <ibuclaw@gdcproject.org>

    * gdb.dlang/primitive-types.exp: New file.

10 years agoAdd d_main_name to set the logical entry point for D programs.
Iain Buclaw [Sat, 18 Jan 2014 17:09:43 +0000 (17:09 +0000)]
Add d_main_name to set the logical entry point for D programs.

gdb/ChangeLog:
2014-01-17  Iain Buclaw  <ibuclaw@gdcproject.org>

    * d-lang.h (d_main_name): Add declaration.
    * d-lang.c (d_main_name): New function.
    * symtab.c (find_main_name): Add call to d_main_name.

10 years agoUpdate d_language_defn to reflect that D does not have any style of
Iain Buclaw [Sat, 18 Jan 2014 18:04:08 +0000 (18:04 +0000)]
Update d_language_defn to reflect that D does not have any style of
macro expansion in its language.

gdb/ChangeLog:
2014-01-17  Iain Buclaw  <ibuclaw@gdcproject.org>

    * d-lang.c (d_language_defn): Change macro_expansion_c to
    macro_expansion_no.

10 years agoAdd gdb.dlang to the gdb testsuite for the purpose of creating D
Iain Buclaw [Sat, 18 Jan 2014 16:04:36 +0000 (16:04 +0000)]
Add gdb.dlang to the gdb testsuite for the purpose of creating D
specific tests.

gdb/testsuite/ChangeLog:
2014-01-17  Iain Buclaw  <ibuclaw@gdcproject.org>

    * configure.ac: Create gdb.dlang/Makefile.
    * configure: Regenerate.
    * Makefile.in (ALL_SUBDIRS): Add gdb.dlang.
    * gdb.dlang/Makefile.in: New file.
    * lib/d-support.exp: New file.
    * lib/gdb.exp (skip_d_tests): New proc.

10 years agoAdd myself as a write-after-approval gdb maintainer.
Iain Buclaw [Sat, 18 Jan 2014 18:02:41 +0000 (18:02 +0000)]
Add myself as a write-after-approval gdb maintainer.

gdb/ChangeLog:
2014-01-17  Iain Buclaw  <ibuclaw@gdcproject.org>

    * MAINTAINERS: Add myself as a write-after-approval maintainer.

10 years agodaily update
Alan Modra [Fri, 17 Jan 2014 23:01:09 +0000 (09:31 +1030)]
daily update

10 years agoAdd "volatile" keyword to "struct gdb_exception" declaration
Sergio Durigan Junior [Fri, 17 Jan 2014 21:39:57 +0000 (19:39 -0200)]
Add "volatile" keyword to "struct gdb_exception" declaration

While doing something else, I found that those 2 places were incorrectly
declaring a "struct gdb_exception" without using the "volatile" keyword.
This commit fixes that.

2014-01-17  Sergio Durigan Junior  <sergiodj@redhat.com>

* breakpoint.c (insert_bp_location): Add "volatile" keyword to "struct
gdb_exception" declaration.
* remote.c (getpkt_or_notif_sane): Likewise.

10 years agoAdd delim_string_to_char_ptr_vec.
Doug Evans [Fri, 17 Jan 2014 18:23:29 +0000 (10:23 -0800)]
Add delim_string_to_char_ptr_vec.

* common/gdb_vecs.c (delim_string_to_char_ptr_vec_append): New
function, contents of dirnames_to_char_ptr_vec_append moved here.
(delim_string_to_char_ptr_vec): New function.
(dirnames_to_char_ptr_vec_append): Rewrite.
* common/gdb_vecs.h (delim_string_to_char_ptr_vec): Declare.

10 years agoMove ASSERT_FUNCTION to FUNCTION_NAME.
Doug Evans [Fri, 17 Jan 2014 18:00:07 +0000 (10:00 -0800)]
Move ASSERT_FUNCTION to FUNCTION_NAME.

* common/common-utils.h (FUNCTION_NAME): Renamed from ASSERT_FUNCTION,
and moved here ...
* common/gdb_assert.h (ASSERT_FUNCTION): ... from here.
#include "common-utils.h".
(gdb_assert, gdb_assert_fail, gdb_assert_not_reached): Update.
* common/vec.h (VEC_ASSERT_PASS): Update.
* darwin-nat.h: Replace #include of gdb_assert.h with common-utils.h.
(MACH_CHECK_ERROR): Update.

10 years agoFix PR mention in gdb/gdbserver/ChangeLog's previous change.
Pedro Alves [Fri, 17 Jan 2014 16:28:38 +0000 (16:28 +0000)]
Fix PR mention in gdb/gdbserver/ChangeLog's previous change.

10 years agogas: ARM: Fix encoding of VCVTr.s32.f64 instructions
Will Newton [Thu, 16 Jan 2014 10:08:45 +0000 (10:08 +0000)]
gas: ARM: Fix encoding of VCVTr.s32.f64 instructions

The direct rounding floating-point VCVT instructions introduced in
ARMv8 encode the s32.f64 variant incorrectly. The op bit should be
set to 1 for all signed conversions.

gas/ChangeLog:

2014-01-17  Will Newton  <will.newton@linaro.org>

* config/tc-arm.c (do_vfp_nsyn_cvt_fpv8): Set OP to 1
for the s32.f64 flavours of VCVT.

gas/testsuite/ChangeLog:

2014-01-17  Will Newton  <will.newton@linaro.org>

* gas/arm/armv8-a+fp.d: Correct encoding of vcvta.s32.f64.

10 years agoFix silly ChangeLog entry in previous change.
Pedro Alves [Fri, 17 Jan 2014 15:27:42 +0000 (15:27 +0000)]
Fix silly ChangeLog entry in previous change.

10 years agoFix PR PR16445 - gdbserver build failure on x86.
Pedro Alves [Fri, 17 Jan 2014 13:33:30 +0000 (13:33 +0000)]
Fix PR PR16445 - gdbserver build failure on x86.

If gdb_proc_service.h ends up including linux/elf.h, we'll trip on
duplicate definitions:

 In file included from ../../../gdb/gdbserver/linux-x86-low.c:29:0:
 ../../../gdb/gdbserver/../../include/elf/common.h:36:0: error: "ELFMAG0"
                 redefined [-Werror]
 ... etc ...

Handle this the same way linux-low.c and linux-arm-low.c handle this.

gdb/gdbserver/
2014-01-17  Pedro Alves  <palves@redhat.com>

PR PR16445
* linux-x86-low.c (linux-x86-low.c): Don't include elf/common.h if
ELFMAG0 is defined after including gdb_proc_service.h.

10 years agoAdd comments to gdbarch_address_class_name_to_type_flags.
Simon Marchi [Fri, 17 Jan 2014 09:54:56 +0000 (09:54 +0000)]
Add comments to gdbarch_address_class_name_to_type_flags.

gdb/ChangeLog
2014-01-17  Simon Marchi  <simon.marchi@ericsson.com>

* gdbarch.sh (gdbarch_address_class_name_to_type_flags): Add
comments.
* gdbarch.h: Regenerate.

10 years agoAllow ld target customiser script to force on disk scripts.
Alan Modra [Fri, 17 Jan 2014 00:09:50 +0000 (10:39 +1030)]
Allow ld target customiser script to force on disk scripts.

Mucking with EMULATION_LIBPATH has unwanted side effects.  Allow nds32
emulparams scripts to disable compiled-in scripts naturally, by
setting COMPILE_IN=no.

* genscripts.sh (COMPILE_IN): Don't set if already set.
* emulparams/nds32elf.sh: Don't clear EMULATION_LIBPATH, set
COMPILE_IN=no.
* emulparams/nds32elf16m.sh: Likewise.
* emulparams/nds32elf_linux.sh: Likewise.
* emultempl/aix.em: Test COMPILE_IN value is "yes".
* emultempl/armcoff.em: Likewise.
* emultempl/elf32.em: Likewise.
* emultempl/generic.em: Likewise.
* emultempl/gld960.em: Likewise.
* emultempl/gld960c.em: Likewise.
* emultempl/linux.em: Likewise.
* emultempl/lnk960.em: Likewise.
* emultempl/m68kcoff.em: Likewise.
* emultempl/sunos.em: Likewise.
* emultempl/ticoff.em: Likewise.

10 years ago * dll.c (UNSPECIFIED_CORE_ADDR): New macro.
Doug Evans [Thu, 16 Jan 2014 23:47:43 +0000 (15:47 -0800)]
* dll.c (UNSPECIFIED_CORE_ADDR): New macro.
(match_dll): Use it.

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

10 years agorearrange struct value to save memory
Tom Tromey [Sat, 28 Dec 2013 05:22:07 +0000 (22:22 -0700)]
rearrange struct value to save memory

This patch rearranges struct value a tiny bit, moving the "regnum"
field into a hole.  This saves 8 bytes per value on a 64-bit machine,
and 4 bytes per value on a 32 bit machine.  I think it does not
negatively affect readability or performance.

Built and regtested on x86-64 Fedora 18.

2014-01-16  Tom Tromey  <tromey@redhat.com>

* value.c (struct value) <regnum>: Move earlier.

10 years agoremove extended_remote_create_inferior_1
Tom Tromey [Wed, 18 Dec 2013 15:27:54 +0000 (08:27 -0700)]
remove extended_remote_create_inferior_1

I noticed that extended_remote_create_inferior_1 is called from a
single spot.  This patch unifies the callee and caller.  It's just a
simple cleanup that made the coming refactoring simpler.

2014-01-16  Tom Tromey  <tromey@redhat.com>

* remote.c (extended_remote_create_inferior): Rename from
extended_remote_create_inferior_1.  Add "ops" argument.  Remove
old implementation.

10 years agoFix gdb.trace/mi-traceframe-changed.exp on s390.
Pedro Alves [Thu, 16 Jan 2014 17:43:26 +0000 (17:43 +0000)]
Fix gdb.trace/mi-traceframe-changed.exp on s390.

The test fails on s390 with:

  -trace-find frame-number 0^M
  &"PC not available\n"^M
  ^done,found="1",tracepoint="1",traceframe="0",frame={level="-1",addr="<unavailable>",func="??",args=[]}^M
  (gdb) ^M
  FAIL: gdb.trace/mi-traceframe-changed.exp: tfile: -trace-find frame-number 0

tfile knows to infer the PC from the tracepoint's address if the PC
wasn't collected (tfile_fetch_registers) but, that only works on
targets whose PC register is a raw register, and on s390, the PC
register is a pseudo register.

But even if GDB doesn't know how to infer the value of PC, saying the
current frame is level -1 is a bug:

  ^done,found="1",tracepoint="1",traceframe="0",frame={level="-1",addr="<unavailable>",func="??",args=[]}^M
                                                       ^^^^^^^^^

'-1' is the level of the sentinel frame, which should never be visible.

This is caused by the s390's heuristic unwinder accepting the frame
(the fallback heuristic unwinders _always_ accept the frame), but then
the unwind->this_id method throws that "PC not available\n" error.

IOW, the s390's heuristic unwinder was never adjusted to handle
unavailable register values gracefully, which can happen with e.g., a
trimmed core file too.

This is just the minimal necessary for
<unavailable> frames, which at least gets us:

  (gdb) tfind
  Found trace frame 0, tracepoint 1
  #0  <unavailable> in ?? ()

That is, frame #0 instead of -1.

We could get better info out of "info frame" (this patch makes us show
"outermost"), but this change would still be necessary.

gdb/
2014-01-16  Pedro Alves  <palves@redhat.com>

* s390-linux-tdep.c (s390_frame_unwind_cache): Swallow
NOT_AVAILABLE_ERROR errors while parsing the prologue or reading
the backchain.

10 years agodwarf2read.c (open_and_init_dwp_file): Fix typo in comment.
Doug Evans [Thu, 16 Jan 2014 17:29:10 +0000 (09:29 -0800)]
dwarf2read.c (open_and_init_dwp_file): Fix typo in comment.

10 years agorecord-btrace: add (reverse-)stepping support
Markus Metzger [Mon, 6 May 2013 14:04:46 +0000 (16:04 +0200)]
record-btrace: add (reverse-)stepping support

Provide to_resume and to_wait target methods for the btrace record target
to allow reverse stepping and replay support.

Replay is limited in the sense that only stepping and source correlation
are supported.  We do not record data and thus can not show variables.

Non-stop mode is not working.  Do not allow record-btrace in non-stop mode.

2014-01-16  Markus Metzger  <markus.t.metzger@intel.com>

* btrace.h (btrace_thread_flag): New.
(struct btrace_thread_info) <flags>: New.
* record-btrace.c (record_btrace_resume_thread)
(record_btrace_find_thread_to_move, btrace_step_no_history)
(btrace_step_stopped, record_btrace_start_replaying)
(record_btrace_step_thread, record_btrace_decr_pc_after_break)
(record_btrace_find_resume_thread): New.
(record_btrace_resume, record_btrace_wait): Extend.
(record_btrace_can_execute_reverse): New.
(record_btrace_open): Fail in non-stop mode.
(record_btrace_set_replay): Split into this, ...
(record_btrace_stop_replaying): ... this, ...
(record_btrace_clear_histories): ... and this.
(init_record_btrace_ops): Init to_can_execute_reverse.
* NEWS: Announce it.

testsuite/
* gdb.btrace/delta.exp: Check reverse stepi.
* gdb.btrace/tailcall.exp: Update.  Add stepping tests.
* gdb.btrace/finish.exp: New.
* gdb.btrace/next.exp: New.
* gdb.btrace/nexti.exp: New.
* gdb.btrace/record_goto.c: Add comments.
* gdb.btrace/step.exp: New.
* gdb.btrace/stepi.exp: New.
* gdb.btrace/multi-thread-step.c: New.
* gdb.btrace/multi-thread-step.exp: New.
* gdb.btrace/rn-dl-bind.c: New.
* gdb.btrace/rn-dl-bind.exp: New.
* gdb.btrace/data.c: New.
* gdb.btrace/data.exp: New.
* gdb.btrace/Makefile.in (EXECUTABLES): Add new.

doc/
* gdb.texinfo: Document limited reverse/replay support
for target record-btrace.

10 years agotarget: allow decr_pc_after_break to be defined by the target
Markus Metzger [Wed, 18 Dec 2013 10:09:34 +0000 (11:09 +0100)]
target: allow decr_pc_after_break to be defined by the target

Allow the target to define which value to use in decr_pc_after_break.
It defaults to gdbarch_decr_pc_after_break (GDBARCH).

2014-01-16  Markus Metzger  <markus.t.metzger@intel.com>

* target.h (struct target_ops) <to_decr_pc_after_break>: New.
(forward_target_decr_pc_after_break)
(target_decr_pc_after_break): New.
* target.c (forward_target_decr_pc_after_break)
(target_decr_pc_after_break): New.
* aix-thread.c (aix_thread_wait): Call target_decr_pc_after_break
instead of gdbarch_decr_pc_after_break.
* darwin-nat.c (cancel_breakpoint): Call target_decr_pc_after_break
instead of gdbarch_decr_pc_after_break.
* infrun.c (adjust_pc_after_break): Call target_decr_pc_after_break
instead of gdbarch_decr_pc_after_break.
* linux-nat.c (cancel_breakpoint): Call target_decr_pc_after_break
instead of gdbarch_decr_pc_after_break.
* linux-thread-db.c (check_event): Call target_decr_pc_after_break
instead of gdbarch_decr_pc_after_break.
* record-full.c (record_full_wait_1): Call target_decr_pc_after_break
instead of gdbarch_decr_pc_after_break.

10 years agorecord-btrace: show trace from enable location
Markus Metzger [Tue, 10 Sep 2013 10:27:14 +0000 (12:27 +0200)]
record-btrace: show trace from enable location

The btrace record target shows the branch trace from the location of the first
branch destination.  This is the first BTS records.

After adding incremental updates, we can now add a dummy record for the current
PC when we enable tracing so we show the trace from the location where branch
tracing has been enabled.

2014-01-16  Markus Metzger  <markus.t.metzger@intel.com>

* btrace.c: Include regcache.h.
(btrace_add_pc): New.
(btrace_enable): Call btrace_add_pc.
(btrace_is_empty): New.
* btrace.h (btrace_is_empty): New.
* record-btrace.c (require_btrace, record_btrace_info): Call
btrace_is_empty.

testsuite/
* gdb.btrace/Makefile.in (EXECUTABLES): Add delta.
* gdb.btrace/exception.exp: Update.
* gdb.btrace/instruction_history.exp: Update.
* gdb.btrace/record_goto.exp: Update.
* gdb.btrace/tailcall.exp: Update.
* gdb.btrace/unknown_functions.exp: Update.
* gdb.btrace/delta.exp: New.

10 years agobtrace, gdbserver: read branch trace incrementally
Markus Metzger [Mon, 3 Jun 2013 13:39:35 +0000 (15:39 +0200)]
btrace, gdbserver: read branch trace incrementally

Read branch trace data incrementally and extend the current trace rather than
discarding it and reading the entire trace buffer each time.

If the branch trace buffer overflowed, we can't extend the current trace so we
discard it and start anew by reading the entire branch trace buffer.

2014-01-16  Markus Metzger  <markus.t.metzger@intel.com>

* common/linux-btrace.c (perf_event_read_bts, linux_read_btrace):
Support delta reads.
(linux_disable_btrace): Change return type.
* common/linux-btrace.h (linux_read_btrace): Change parameters
and return type to allow error reporting.  Update users.
(linux_disable_btrace): Change return type.  Update users.
* common/btrace-common.h (btrace_read_type) <BTRACE_READ_DELTA>:
New.
(btrace_error): New.
(btrace_block) <begin>: Comment on BEGIN == 0.
* btrace.c (btrace_compute_ftrace): Start from the end of
the current trace.
(btrace_stitch_trace, btrace_clear_history): New.
(btrace_fetch): Read delta trace, return if replaying.
(btrace_clear): Move clear history code to btrace_clear_history.
(parse_xml_btrace): Throw an error if parsing failed.
* target.h (struct target_ops) <to_read_btrace>: Change parameters
and return type to allow error reporting.
(target_read_btrace): Change parameters and return type to allow
error reporting.
* target.c (target_read_btrace): Update.
* remote.c (remote_read_btrace): Support delta reads.  Pass
errors on.
* NEWS: Announce it.

gdbserver/
* target.h (target_ops) <read_btrace>: Change parameters and
return type to allow error reporting.
* server.c (handle_qxfer_btrace): Support delta reads.  Pass
trace reading errors on.
* linux-low.c (linux_low_read_btrace): Pass trace reading
errors on.
(linux_low_disable_btrace): New.

10 years agorecord-btrace: extend unwinder
Markus Metzger [Wed, 27 Mar 2013 08:49:47 +0000 (09:49 +0100)]
record-btrace: extend unwinder

Extend the always failing unwinder to provide the PC based on the call
structure detected in the branch trace.

The unwinder supports normal frames and tailcall frames.
Inline frames are not supported.

2014-01-16  Markus Metzger  <markus.t.metzger@intel.com>

* record.h (record_btrace_frame_unwind)
(record_btrace_tailcall_frame_unwind): New declarations.
* dwarf2-frame: Include record.h
(dwarf2_frame_cfa): Throw an error for btrace frames.
* record-btrace.c: Include hashtab.h.
(btrace_get_bfun_name): New.
(btrace_call_history): Call btrace_get_bfun_name.
(struct btrace_frame_cache): New.
(bfcache): New.
(bfcache_hash, bfcache_eq, bfcache_new): New.
(btrace_get_frame_function): New.
(record_btrace_frame_unwind_stop_reason): Allow unwinding.
(record_btrace_frame_this_id): Compute own id.
(record_btrace_frame_prev_register): Provide PC, throw_error
for all other registers.
(record_btrace_frame_sniffer): Detect btrace frames.
(record_btrace_tailcall_frame_sniffer): New.
(record_btrace_frame_dealloc_cache): New.
(record_btrace_frame_unwind): Add new functions.
(record_btrace_tailcall_frame_unwind): New.
(_initialize_record_btrace): Allocate cache.
* btrace.c (btrace_clear): Call reinit_frame_cache.
* NEWS: Announce it.

testsuite/
* gdb.btrace/record_goto.exp: Add backtrace test.
* gdb.btrace/tailcall.exp: Add backtrace test.

10 years agorecord-btrace: add record goto target methods
Markus Metzger [Mon, 25 Mar 2013 15:01:33 +0000 (16:01 +0100)]
record-btrace: add record goto target methods

2014-01-16  Markus Metzger  <markus.t.metzger@intel.com>

* record-btrace.c (record_btrace_set_replay)
(record_btrace_goto_begin, record_btrace_goto_end)
(record_btrace_goto): New.
(init_record_btrace_ops): Initialize them.
* NEWS: Announce it.

testsuite/
* gdb.btrace/Makefile.in (EXECUTABLES): Add record_goto.
* gdb.btrace/record_goto.c: New.
* gdb.btrace/record_goto.exp: New.
* gdb.btrace/x86-record_goto.S: New.

10 years agorecord-btrace: provide target_find_new_threads method
Markus Metzger [Fri, 3 May 2013 08:51:13 +0000 (10:51 +0200)]
record-btrace: provide target_find_new_threads method

The "info threads" command tries to read memory, which is not possible during
replay.  This results in an error message and aborts the command without showing
the existing threads.

Provide a to_find_new_threads target method to skip the search while replaying.

2014-01-16  Markus Metzger  <markus.t.metzger@intel.com>

* record-btrace.c (record_btrace_find_new_threads)
(record_btrace_thread_alive): New.
(init_record_btrace_ops): Initialize to_find_new_threads and
to_thread_alive.

10 years agorecord-btrace: add to_wait and to_resume target methods.
Markus Metzger [Mon, 25 Mar 2013 14:44:43 +0000 (15:44 +0100)]
record-btrace: add to_wait and to_resume target methods.

Add simple to_wait and to_resume target methods that prevent stepping when the
current replay position is not at the end of the execution log.

2014-01-16  Markus Metzger  <markus.t.metzger@intel.com>

* record-btrace.c (record_btrace_resume): New.
(record_btrace_wait): New.
(init_record_btrace_ops): Initialize to_wait and to_resume.

10 years agorecord-btrace: provide xfer_partial target method
Markus Metzger [Wed, 24 Apr 2013 11:24:11 +0000 (13:24 +0200)]
record-btrace: provide xfer_partial target method

Provide the xfer_partial target method for the btrace record target.

Only allow memory read accesses to readonly memory while we're replaying,
except for inserting and removing breakpoints.

2014-01-16  Markus Metzger  <markus.t.metzger@intel.com>

* record-btrace.c (record_btrace_xfer_partial)
(record_btrace_insert_breakpoint, record_btrace_remove_breakpoint)
(record_btrace_allow_memory_access): New.
(init_record_btrace_ops): Initialize new methods.
* target.c (raw_memory_xfer_partial): Bail out if target reports
that this memory is not available.

10 years agotarget, breakpoint: allow insert/remove breakpoint to be forwarded
Markus Metzger [Tue, 17 Dec 2013 09:49:03 +0000 (10:49 +0100)]
target, breakpoint: allow insert/remove breakpoint to be forwarded

2014-01-16  Markus Metzger  <markus.t.metzger@intel.com>

* target.h (target_ops) <to_insert_breakpoint>
<to_remove_breakpoint>: Add target_ops parameter.
(forward_target_insert_breakpoint): New.
(forward_target_remove_breakpoint): New.
(memory_remove_breakpoint, memory_insert_breakpoint):
Add target_ops parameter.
* target.c (target_insert_breakpoint): Split into this and ...
(forward_target_insert_breakpoint): ... this.
(target_remove_breakpoint): Split into this and ...
(forward_target_remove_breakpoint): ... this.
(debug_to_insert_breakpoint): Add target_ops parameter.
Call forward_target_insert_breakpoint.
(debug_to_remove_breakpoint): Add target_ops parameter.
Call forward_target_remove_breakpoint.
(update_current_target): Do not inherit or default to_insert_breakpoint
and to_remove_breakpoint.
* corelow.c (ignore): Add target_ops parameter.
* exec.c (ignore): Add target_ops parameter.
* mem-break.c (memory_insert_breakpoint, memory_remove_breakpoint):
Add target_ops parameter.
* monitor.c (monitor_insert_breakpoint, monitor_remove_breakpoint):
Add target_ops parameter.
* nto-procfs.c (procfs_insert_breakpoint, procfs_remove_breakpoint):
Add target_ops parameter.
* record-full.c (record_full_beneath_to_insert_breakpoint)
(record_full_beneath_to_remove_breakpoint, tmp_to_insert_breakpoint)
(tmp_to_remove_breakpoint, record_full_insert_breakpoint)
(record_full_remove_breakpoint, record_full_core_insert_breakpoint)
(record_full_core_remove_breakpoint): Add target_ops parameter.
Update users.
(record_full_beneath_to_insert_breakpoint_ops)
(record_full_beneath_to_remove_breakpoint_ops)
(tmp_to_insert_breakpoint_ops, tmp_to_remove_breakpoint_ops): New.
(record_full_open): Initialize tmp_to_insert_breakpoint_ops,
tmp_to_remove_breakpoint_ops,
record_full_beneath_to_insert_breakpoint_ops, and
record_full_beneath_to_remove_breakpoint_ops.
* remote-m32r-sdi.c (m32r_insert_breakpoint)
(m32r_remove_breakpoint): Add target_ops parameter.
* remote-mips.c (mips_insert_breakpoint, mips_remove_breakpoint):
Add target_ops parameter.
* remote.c (remote_insert_breakpoint, remote_remove_breakpoint):
Add target_ops parameter.

10 years agorecord-btrace, frame: supply target-specific unwinder
Markus Metzger [Mon, 18 Mar 2013 15:47:01 +0000 (16:47 +0100)]
record-btrace, frame: supply target-specific unwinder

Supply a target-specific frame unwinder for the record-btrace target that does
not allow unwinding while replaying.

2013-02-11  Jan Kratochvil  <jan.kratochvil@redhat.com>
            Markus Metzger  <markus.t.metzger@intel.com>

gdb/
* record-btrace.c: Include frame-unwind.h.
(record_btrace_frame_unwind_stop_reason)
(record_btrace_frame_this_id, record_btrace_frame_prev_register)
(record_btrace_frame_sniffer, record_btrace_frame_unwind):
New.
(init_record_btrace_ops): Install it.

10 years agoframe: do not assume unwinding will succeed
Markus Metzger [Mon, 18 Mar 2013 15:43:05 +0000 (16:43 +0100)]
frame: do not assume unwinding will succeed

In get_frame_unwind_stop_reason, remove the assumption that further frame
unwinding will succeed.

gdb/
2013-02-11  Jan Kratochvil  <jan.kratochvil@redhat.com>

* frame.c (get_frame_unwind_stop_reason): Unconditionally call
get_prev_frame_1.

10 years agoframe, cfa: check unwind stop reason first
Markus Metzger [Mon, 18 Mar 2013 15:43:05 +0000 (16:43 +0100)]
frame, cfa: check unwind stop reason first

Swap the unwind stop reason check and the unwinder check to allow
non-dwarf2 frame types to fail with a recoverable error.

gdb/
2013-02-11  Jan Kratochvil  <jan.kratochvil@redhat.com>

* dwarf2-frame.c (dwarf2_frame_cfa): Move UNWIND_UNAVAILABLE check
earlier.

10 years agoframe, backtrace: allow targets to supply a frame unwinder
Markus Metzger [Mon, 18 Mar 2013 15:43:05 +0000 (16:43 +0100)]
frame, backtrace: allow targets to supply a frame unwinder

Allow targets to supply their own target-specific frame unwinders; one for
normal frames and one for tailcall frames.  If a target-specific unwinder
is supplied, it will be chosen before any other unwinder.

The original patch has been split into this and the next two patches.

gdb/
2013-02-11  Jan Kratochvil  <jan.kratochvil@redhat.com>

* frame-unwind.c: Include target.h.
(frame_unwind_try_unwinder): New function with code from ...
(frame_unwind_find_by_frame): ... here.  New variable
unwinder_from_target, call also target_get_unwinder)
(target_get_tailcall_unwinder, and frame_unwind_try_unwinder for it.
* target.c (target_get_unwinder, target_get_tailcall_unwinder): New.
* target.h (struct target_ops): New fields to_get_unwinder and
to_get_tailcall_unwinder.
(target_get_unwinder, target_get_tailcall_unwinder): New declarations.

10 years agorecord-btrace: supply register target methods
Markus Metzger [Thu, 28 Mar 2013 09:38:24 +0000 (10:38 +0100)]
record-btrace: supply register target methods

Supply target methods to allow reading the PC.  Forbid anything else.

2014-01-16  Markus Metzger  <markus.t.metzger@intel.com>

* record-btrace.c (record_btrace_fetch_registers)
(record_btrace_store_registers)
(record_btrace_to_prepare_to_store): New.
(init_record_btrace_ops): Add the above.

10 years agoAdd target_ops argument to to_prepare_to_store
Markus Metzger [Mon, 13 Jan 2014 13:24:50 +0000 (14:24 +0100)]
Add target_ops argument to to_prepare_to_store

2013-12-17  Tom Tromey  <tromey@redhat.com>

* windows-nat.c (windows_prepare_to_store): Add 'self' argument.
* target.h (struct target_ops) <to_prepare_to_store>: Add
argument.
(target_prepare_to_store): Add argument.
* target.c (debug_to_prepare_to_store): Add argument.
(update_current_target): Update.
* remote.c (remote_prepare_to_store): Add 'self' argument.
* remote-sim.c (gdbsim_prepare_to_store): Add 'self' argument.
* remote-mips.c (mips_prepare_to_store): Add 'self' argument.
* remote-m32r-sdi.c (m32r_prepare_to_store): Add 'self' argument.
* record-full.c (record_full_core_prepare_to_store): Add 'self'
argument.
* ravenscar-thread.c (ravenscar_prepare_to_store): Add argument.
* nto-procfs.c (procfs_prepare_to_store): Add 'self' argument.
* monitor.c (monitor_prepare_to_store): Add 'self' argument.
* inf-child.c (inf_child_prepare_to_store): Add 'self' argument.
* go32-nat.c (go32_prepare_to_store): Add 'self' argument.

10 years agobtrace: add replay position to btrace thread info
Markus Metzger [Fri, 26 Apr 2013 06:37:06 +0000 (08:37 +0200)]
btrace: add replay position to btrace thread info

Add a branch trace instruction iterator pointing to the current replay position
to the branch trace thread info struct.

Free the iterator when btrace is cleared.

Start at the replay position for the instruction and function-call histories.

2014-01-16  Markus Metzger  <markus.t.metzger@intel.com>

* btrace.h (replay) <replay>: New.
(btrace_is_replaying): New.
* btrace.c (btrace_clear): Free replay iterator.
(btrace_is_replaying): New.
* record-btrace.c (record_btrace_is_replaying): New.
(record_btrace_info): Print insn number if replaying.
(record_btrace_insn_history): Start at replay position.
(record_btrace_call_history): Start at replay position.
(init_record_btrace_ops): Init to_record_is_replaying.

10 years agorecord-btrace: make ranges include begin and end
Markus Metzger [Wed, 17 Apr 2013 07:39:43 +0000 (09:39 +0200)]
record-btrace: make ranges include begin and end

The "record function-call-history" and "record instruction-history" commands
accept a range "begin, end".  End is not included in both cases.  Include it.

2014-01-16  Markus Metzger  <markus.t.metzger@intel.com>

* record-btrace.c (record_btrace_insn_history_range): Include
end.
(record_btrace_insn_history_from): Adjust range.
(record_btrace_call_history_range): Include
end.
(record_btrace_call_history_from): Adjust range.
* NEWS: Announce changes.

testsuite/
* gdb.btrace/function_call_history.exp: Update tests.
* gdb.btrace/instruction_history.exp: Update tests.

doc/
* gdb.texinfo (Process Record and Replay): Update documentation.

10 years agorecord-btrace: optionally indent function call history
Markus Metzger [Thu, 18 Apr 2013 08:58:05 +0000 (10:58 +0200)]
record-btrace: optionally indent function call history

Add a new modifier /c to the "record function-call-history" command to
indent the function name based on its depth in the call stack.

Also reorder the optional fields to have the indentation at the very beginning.
Prefix the insn range (/i modifier) with "inst ".
Prefix the source line (/l modifier) with "at ".
Change the range syntax from "begin-end" to "begin,end" to allow copy&paste to
the "record instruction-history" and "list" commands.

Adjust the respective tests and add new tests for the /c modifier.

2014-01-16  Markus Metzger  <markus.t.metzger@intel.com>

* record.h (enum record_print_flag)
<record_print_indent_calls>: New.
* record.c (get_call_history_modifiers): Recognize /c modifier.
(_initialize_record): Document /c modifier.
* record-btrace.c (btrace_call_history): Add btinfo parameter.
Reorder fields.  Optionally indent the function name.  Update
all users.
* NEWS: Announce changes.

testsuite/
* gdb.btrace/function_call_history.exp: Fix expected field
order for "record function-call-history".
Add new tests for "record function-call-history /c".
* gdb.btrace/exception.cc: New.
* gdb.btrace/exception.exp: New.
* gdb.btrace/tailcall.exp: New.
* gdb.btrace/x86-tailcall.S: New.
* gdb.btrace/x86-tailcall.c: New.
* gdb.btrace/unknown_functions.c: New.
* gdb.btrace/unknown_functions.exp: New.
* gdb.btrace/Makefile.in (EXECUTABLES): Add new.

doc/
* gdb.texinfo (Process Record and Replay): Document new /c
modifier accepted by "record function-call-history".
Add /i modifier to "record function-call-history" example.

10 years agobtrace: increase buffer size
Markus Metzger [Wed, 10 Apr 2013 11:43:41 +0000 (13:43 +0200)]
btrace: increase buffer size

Try to allocate as much buffer as we can for each thread with a maximum
of 64KB.

2014-01-16  Markus Metzger  <markus.t.metzger@intel.com>

* common/linux-btrace.c (linux_enable_btrace): Enlarge buffer.

10 years agorecord-btrace: start counting at one
Markus Metzger [Mon, 13 May 2013 12:57:42 +0000 (14:57 +0200)]
record-btrace: start counting at one

The record instruction-history and record-function-call-history commands start
counting instructions at zero.  This is somewhat unintuitive when we start
navigating in the recorded instruction history.  Start at one, instead.

2014-01-16  Markus Metzger  <markus.t.metzger@intel.com>

* btrace.c (ftrace_new_function): Start counting at one.
* record-btrace.c (record_btrace_info): Adjust number of calls
and insns.
* NEWS: Announce it.

testsuite/
    * gdb.btrace/instruction_history.exp: Update.
    * gdb.btrace/function_call_history.exp: Update.

10 years agorecord-btrace: fix insn range in function call history
Markus Metzger [Tue, 26 Mar 2013 10:32:20 +0000 (11:32 +0100)]
record-btrace: fix insn range in function call history

With the "/i" modifier, we print the instruction number range in the
"record function-call-history" command as [begin, end).

It would be more intuitive if we printed the range as [begin, end].

2014-01-16  Markus Metzger  <markus.t.metzger@intel.com>

* record-btrace.c (btrace_call_history_insn_range): Print
insn range as [begin, end].

10 years agobtrace: change branch trace data structure
Markus Metzger [Fri, 22 Mar 2013 13:32:47 +0000 (14:32 +0100)]
btrace: change branch trace data structure

The branch trace is represented as 3 vectors:
  - a block vector
  - a instruction vector
  - a function vector

Each vector (except for the first) is computed from the one above.

Change this into a graph where a node represents a sequence of instructions
belonging to the same function and where we have three types of edges to connect
the function segments:
  - control flow
  - same function (instance)
  - call stack

This allows us to navigate in the branch trace.  We will need this for "record
goto" and reverse execution.

This patch introduces the data structure and computes the control flow edges.
It also introduces iterator structs to simplify iterating over the branch trace
in control-flow order.

It also fixes PR gdb/15240 since now recursive calls are handled correctly.
Fix the test that got the number of expected fib instances and also the
function numbers wrong.

The current instruction had been part of the branch trace.  This will look odd
once we start support for reverse execution.  Remove it.  We still keep it in
the trace itself to allow extending the branch trace more easily in the future.

2014-01-16  Markus Metzger  <markus.t.metzger@intel.com>

* btrace.h (struct btrace_func_link): New.
(enum btrace_function_flag): New.
(struct btrace_inst): Rename to ...
(struct btrace_insn): ...this. Update all users.
(struct btrace_func) <ibegin, iend>: Remove.
(struct btrace_func_link): New.
(struct btrace_func): Rename to ...
(struct btrace_function): ...this. Update all users.
(struct btrace_function) <segment, flow, up, insn, insn_offset)
(number, level, flags>: New.
(struct btrace_insn_iterator): Rename to ...
(struct btrace_insn_history): ...this.
Update all users.
(struct btrace_insn_iterator, btrace_call_iterator): New.
(struct btrace_target_info) <btrace, itrace, ftrace>: Remove.
(struct btrace_target_info) <begin, end, level>
<insn_history, call_history>: New.
(btrace_insn_get, btrace_insn_number, btrace_insn_begin)
(btrace_insn_end, btrace_insn_prev, btrace_insn_next)
(btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get)
(btrace_call_number, btrace_call_begin, btrace_call_end)
(btrace_call_prev, btrace_call_next, btrace_call_cmp)
(btrace_find_function_by_number, btrace_set_insn_history)
(btrace_set_call_history): New.
* btrace.c (btrace_init_insn_iterator)
(btrace_init_func_iterator, compute_itrace): Remove.
(ftrace_print_function_name, ftrace_print_filename)
(ftrace_skip_file): Change
parameter to const.
(ftrace_init_func): Remove.
(ftrace_debug): Use new btrace_function fields.
(ftrace_function_switched): Also consider gaining and
losing symbol information).
(ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return)
(ftrace_new_switch, ftrace_find_caller, ftrace_new_function)
(ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall):
New.
(ftrace_new_function): Move. Remove debug print.
(ftrace_update_lines, ftrace_update_insns): New.
(ftrace_update_function): Check for call, ret, and jump.
(compute_ftrace): Renamed to ...
(btrace_compute_ftrace): ...this. Rewritten to compute call
stack.
(btrace_fetch, btrace_clear): Updated.
(btrace_insn_get, btrace_insn_number, btrace_insn_begin)
(btrace_insn_end, btrace_insn_prev, btrace_insn_next)
(btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get)
(btrace_call_number, btrace_call_begin, btrace_call_end)
(btrace_call_prev, btrace_call_next, btrace_call_cmp)
(btrace_find_function_by_number, btrace_set_insn_history)
(btrace_set_call_history): New.
* record-btrace.c (require_btrace): Use new btrace thread
info fields.
(record_btrace_info, btrace_insn_history)
(record_btrace_insn_history, record_btrace_insn_history_range):
Use new btrace thread info fields and new iterator.
(btrace_func_history_src_line): Rename to ...
(btrace_call_history_src_line): ...this. Use new btrace
thread info fields.
(btrace_func_history): Rename to ...
(btrace_call_history): ...this. Use new btrace thread info
fields and new iterator.
(record_btrace_call_history, record_btrace_call_history_range):
Use new btrace thread info fields and new iterator.

testsuite/
* gdb.btrace/function_call_history.exp: Fix expected function
trace.
* gdb.btrace/instruction_history.exp: Initialize traced.
Remove traced_functions.

10 years agoframe: add frame_id_build_unavailable_stack_special
Markus Metzger [Wed, 18 Dec 2013 13:13:54 +0000 (14:13 +0100)]
frame: add frame_id_build_unavailable_stack_special

Add a function to build a frame_id for a frame with unavailable stack
and with a special identifier address.

2014-01-16  Markus Metzger  <markus.t.metzger@intel.com>

* frame.h (frame_id_build_unavailable_stack_special): New.
* frame.c (frame_id_build_unavailable_stack_special): New.

10 years agogdbarch: add instruction predicate methods
Markus Metzger [Fri, 22 Mar 2013 14:56:56 +0000 (15:56 +0100)]
gdbarch: add instruction predicate methods

Add new methods to gdbarch for analyzing the instruction at a given address.
Implement those methods for i386 and amd64 architectures.

This is needed by "record btrace" to detect function calls in the
execution trace.

2014-01-16  Markus Metzger  <markus.t.metzger@intel.com>

* amd64-tdep.c (amd64_classify_insn_at, amd64_insn_is_call)
(amd64_insn_is_ret, amd64_insn_is_jump, amd64_jmp_p): New.
(amd64_init_abi): Add insn_is_call, insn_is_ret, and insn_is_jump
to gdbarch.
* i386-tdep.c (i386_insn_is_call, i386_insn_is_ret)
(i386_insn_is_jump, i386_jmp_p): New.
(i386_gdbarch_init): Add insn_is_call, insn_is_ret, and
insn_is_jump to gdbarch.
* gdbarch.sh (insn_is_call, insn_is_ret, insn_is_jump): New.
* gdbarch.h: Regenerated.
* gdbarch.c: Regenerated.
* arch-utils.h (default_insn_is_call, default_insn_is_ret)
(default_insn_is_jump): New.
* arch-utils.c (default_insn_is_call, default_insn_is_ret)
(default_insn_is_jump): New.

10 years agobtrace: uppercase btrace_read_type
Markus Metzger [Mon, 30 Sep 2013 13:00:16 +0000 (15:00 +0200)]
btrace: uppercase btrace_read_type

2014-01-16  Markus Metzger  <markus.t.metzger@intel.com>

* common/btrace-common.h (btrace_read_type) <btrace_read_all>:
Change to ...
(btrace_read_type) <BTRACE_READ_ALL>: ... this.  Update users.
(btrace_read_type) <btrace_read_new>: Change to ...
(btrace_read_type) <BTRACE_READ_NEW>: ... this.  Update users.

10 years agobtrace, linux: fix memory leak when reading branch trace
Markus Metzger [Mon, 3 Jun 2013 12:32:15 +0000 (14:32 +0200)]
btrace, linux: fix memory leak when reading branch trace

When it takes more than one iteration to read the BTS trace, the trace from the
previous iteration is leaked.  Fix it.

2014-01-16  Markus Metzger  <markus.t.metzger@intel.com>

* common/linux-btrace.c (linux_read_btrace): Free trace from
previous iteration.

10 years agobtrace, test: fix multi-line btrace tests
Markus Metzger [Wed, 18 Dec 2013 13:47:17 +0000 (14:47 +0100)]
btrace, test: fix multi-line btrace tests

For testing multi-line test output, gdb.btrace tests used the following
pattern:

  gdb_test "..." "
  ...\r
  ..."

Change this to:

  gdb_test "..." [join [list \
    "..." \
    "..."] "\r\n"]

Also extract repeated tests into a test function and shorten or remove
test messages.

2014-01-16  Markus Metzger  <markus.t.metzger@intel.com>

testsuite/
* gdb.btrace/function_call_history.exp: Update
* gdb.btrace/instruction_history.exp: Update.

10 years agotest, btrace: update expected text
Markus Metzger [Thu, 16 Jan 2014 08:47:51 +0000 (09:47 +0100)]
test, btrace: update expected text

The error message for starting recording twice changed.
Update the expected text to fix resulting regressions.

2014-01-16  Markus Metzger  <markus.t.metzger@intel.com>

* gdb.btrace/enable.exp: Update expected text.

10 years agoFix testsuite/gdb.dwarf2/dw2-dos-drive.exp on ARM.
Omair Javaid [Thu, 16 Jan 2014 11:00:00 +0000 (11:00 +0000)]
Fix testsuite/gdb.dwarf2/dw2-dos-drive.exp on ARM.

This test currently fails on ARM:

  (gdb) PASS: gdb.dwarf2/dw2-dos-drive.exp: set breakpoint pending off
  break 'z:file.c':func
  Cannot access memory at address 0x0

The error is GDB trying to read the prologue at the breakpoint's
address, and failing:

  38 throw_error() exceptions.c:444 0x0016728c
  37 memory_error() corefile.c:204 0x001d1fcc
  36 read_memory() corefile.c:223 0x001d201a
  35 read_memory_unsigned_integer() corefile.c:312 0x001d2166
  34 arm_skip_prologue() arm-tdep.c:1452 0x00054270

  static CORE_ADDR
  arm_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
  {
  ...
    for (skip_pc = pc; skip_pc < limit_pc; skip_pc += 4)
      {
        inst = read_memory_unsigned_integer (skip_pc, 4, byte_order_for_code);

The test doesn't execute the compiled object's code, so GDB will try
to read memory from the binary's sections.  Instructions on ARM are
4-byte wide, and thus ARM's prologue scanner reads in 4-byte chunks.
As the section 'func' is put at is only 1 byte long, and no other
section is allocated contiguously:

  ...
  Sections:
  Idx Name          Size      VMA       LMA       File off  Algn
    0 .text         00000001  00000000  00000000  00000034  2**0
                    CONTENTS, ALLOC, LOAD, READONLY, CODE
  ...

... the exec target fails the read the 4 bytes.

Fix this by increasing the function's size.

gdb/testsuite/ChangeLog:
2014-01-16  Omair Javaid  <Omair.Javaid@linaro.org>

* gdb.dwarf2/dw2-dos-drive.S: Increase text section size to 4
bytes.

10 years agoSkip directories with LIBPATH_SUFFIX_SKIP suffix
H.J. Lu [Wed, 15 Jan 2014 20:53:04 +0000 (12:53 -0800)]
Skip directories with LIBPATH_SUFFIX_SKIP suffix

On Linux/x86-64, when binutils is configured with --libdir=/usr/lib64,
genscripts.sh treats /usr/lib64 as the default search directory.  It
puts /usr/lib64 in linker scripts for all emulations, like

---
/* Script for -z combreloc: combine and sort reloc sections */
OUTPUT_FORMAT("elf32-i386", "elf32-i386",
      "elf32-i386")
OUTPUT_ARCH(i386)
ENTRY(_start)
SEARCH_DIR("/usr/x86_64-redhat-linux/lib32");
SEARCH_DIR("/usr/i386-redhat-linux/lib32"); SEARCH_DIR("/usr/lib6432");
SEARCH_DIR("/usr/local/lib32"); SEARCH_DIR("/lib32");
SEARCH_DIR("/usr/lib32"); SEARCH_DIR("/usr/i386-redhat-linux/lib");
SEARCH_DIR("/usr/lib64"); SEARCH_DIR("/usr/local/lib");
SEARCH_DIR("/lib"); SEARCH_DIR("/usr/lib");
---

/usr/lib6432 is odd and /usr/lib64 is wrong.  This patch changes
genscripts.sh to check LIBPATH_SUFFIX_SKIP if it is defined.  It
skips directories with LIBPATH_SUFFIX_SKIP suffix.

PR ld/16456
* genscripts.sh: Don't search directory with LIBPATH_SUFFIX_SKIP
suffix.
* emulparams/elf32_x86_64.sh (LIBPATH_SUFFIX_SKIP): Set to 64
for elf32_x86_64 emulation.
* emulparams/elf_i386.sh (LIBPATH_SUFFIX_SKIP): Set to 64
for elf_i386 emulation.

10 years agoTidy ld use of bfd_section userdata.
Alan Modra [Thu, 16 Jan 2014 01:17:25 +0000 (11:47 +1030)]
Tidy ld use of bfd_section userdata.

A long time ago ld made use of userdata to tie an output section to
its lang_input_statement_struct object file.  Some time later Joern
made map file printing of symbols at lot faster, using userdata on
input sections.  That complicated allocation of userdata, and when the
output section use disappeared a year later, the code wasn't properly
cleaned up.  This patch does that cleanup, and also tidies the symbol
printing code to not allocate userdata where it won't be needed.  We
don't print symbols defined in the absolute section or in output
sections.

* ld.h (fat_section_userdata_type, get_userdata): Move to..
* ldlang.h (input_section_userdata_type, get_userdata): ..here.
* ldlang.c (init_map_userdata): Delete.  Fold into..
(sort_def_symbol): ..here.  Don't attach input section userdata
to output sections or global bfd sections.
(lang_map): Don't pre-allocate input section userdata.
(init_os): Don't allocate userdata for output sections.
(print_all_symbols): Update.