deliverable/binutils-gdb.git
9 years agoDon't make PLT entry for R_X86_64_GOTPLT64
H.J. Lu [Thu, 13 Nov 2014 19:36:57 +0000 (11:36 -0800)] 
Don't make PLT entry for R_X86_64_GOTPLT64

* x86_64.cc (Target_x86_64<size>::Scan::global): Don't make PLT
entry for R_X86_64_GOTPLT64.
(Target_x86_64<size>::Relocate::relocate): Update comments for
R_X86_64_GOTPLT64.

9 years agocommon-defs.h: include <stdarg.h> before <stdio.h>
Joel Brobecker [Mon, 6 Oct 2014 18:50:46 +0000 (14:50 -0400)] 
common-defs.h: include <stdarg.h> before <stdio.h>

When trying to build gdbserver on ppc-lynx178, the compiler reports
while trying to compile gdbserver/ax.c that vsprintf is not declared.
Looking at my C99 reference manual (a draft), I see the following
synopsis:

    #include <stdarg.h>
    #include <stdio.h>
    int vsprintf(char * restrict s, [etc]);

Looking at stdio.h on LynxOS-178, if found where vsprintf gets
declared:

    #if defined(__varargs_h) || defined(__stdarg_h) \
            || defined(_VARARGS_H) || defined(_STDARG_H)
    extern int vsprintf             _AP((char *, const char *, va_list));
    #endif

Digging further, I noticed that common-defs.h, which is included
via server.h, includes stdarg.h after including stdio, explaining
why vsprintf does not get declared in this case.

This patch fixes the problem by including stdarg.h before stdio.h.

gdb/ChangeLog:

        * common/common-defs.h: Move <stdarg.h> #include ahead of
        <stdio.h> #include.

Tested on x86_64-linux.

9 years agoCorrect x86 assembler manual
H.J. Lu [Fri, 14 Nov 2014 16:31:37 +0000 (08:31 -0800)] 
Correct x86 assembler manual

* config/tc-i386.c (cpu_arch): Re-arrange avx512* and xsave*
items.

* doc/c-i386.texi: Re-arrange avx512* and xsave*.  Add
clflushopt and se1.  Remove duplicated entries.

9 years agohandle 'iconv's that define EILSEQ to ENOENT
Pedro Alves [Fri, 14 Nov 2014 15:58:09 +0000 (15:58 +0000)] 
handle 'iconv's that define EILSEQ to ENOENT

We're currently pulling gnulib's errno module as a dependency of some
other module.  That provides an errno.h that defines EILSEQ to a
distinct value if the system's errno.h doesn't define it already.

However, GNU iconv does this:

 /* Get errno declaration and values. */
 #include <errno.h>
 /* Some systems, like SunOS 4, don't have EILSEQ. Some systems, like BSD/OS,
    have EILSEQ in a different header.  On these systems, define EILSEQ
    ourselves. */
 #ifndef EILSEQ
 #define EILSEQ @EILSEQ@
 #endif

That's in:

 http://git.savannah.gnu.org/cgit/libiconv.git/tree/include/iconv.h.in

The "different header" mentioned is wchar.h.  This is handled in:

 http://git.savannah.gnu.org/cgit/libiconv.git/tree/m4/eilseq.m4

which defines @EILSEQ@ to ENOENT if EILSEQ isn't found in either
errno.h or wchar.h.

So if iconv sets errno to EILSEQ on such system's, it's really setting
it to ENOENT.  And when we check for EILSEQ, we're checking for
gnulib's value.  The result is we won't detect the error correctly.

As we dropped support for both SunOS 4 or old BSD/OS, maybe we don't
need to care about the wchar.h issue anymore.  Still, AFAICS, gnulib's
m4/errno_h.m4 doesn't know that EILSEQ may be defined in wchar.h, and
so on such systems, ISTM gnulib ends up defining an incompatible
EILSEQ itself, but I think that should be fixed on the gnulib side, by
making it extract the EILSEQ value out of the system's wchar.h, like
GNU iconv does.

So that leaves handling the case of gnulib making up a EILSEQ value,
which we take as meaning the system really doesn't really define it,
which will be the same systems GNU iconv sets errno to ENOENT instead
of EILSEQ.

Looking at glibc's iconv it seems that ENOENT is never used there.
It seems it's safe to always treat ENOENT the same as EILSEQ.

The current EILSEQ definition under PHONY_ICONV is obviously stale as
gnulib garantees there's always a EILSEQ defined.

Tested on x86_64 Fedora 20.

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

* charset.c [PHONY_ICONV && !EILSEQ] (EILSEQ): Don't define.
[!PHONY_ICONV] (gdb_iconv): New function.
[!PHONY_ICONV] (iconv): Redefine to gdb_iconv.

9 years agoFix a null pointer dereference when reading the debug link info from a corrupt file.
Nick Clifton [Fri, 14 Nov 2014 13:39:29 +0000 (13:39 +0000)] 
Fix a null pointer dereference when reading the debug link info from a corrupt file.

PR binutils/17597
* opncls.c (bfd_get_debug_link_info): Avoid reading off the end of
the section.
(bfd_get_alt_debug_link_info): Likewise.

9 years ago[AArch64] Enable CRC feature in GAS for cortex-a53 and cortex-a57.
Marcus Shawcroft [Fri, 14 Nov 2014 12:52:17 +0000 (12:52 +0000)] 
[AArch64] Enable CRC feature in GAS for cortex-a53 and cortex-a57.

9 years agoMore fixes for invalid memory accesses triggered by corrupt binaries.
Nick Clifton [Fri, 14 Nov 2014 12:30:00 +0000 (12:30 +0000)] 
More fixes for invalid memory accesses triggered by corrupt binaries.

PR binutils/17512
* dwarf.c (get_encoded_value): Add an 'end' parameter.  Change the
'data' parameter to a double pointer and return the updated value.
(decode_location_expression): Update call to get_encoded_value.
(frame_need_space): Handle the case where one or both of the
mallocs fails.
(read_cie): Initialise the cie pointer, even if the read fails.
(display_debug_frames): Warn if the calculated block_end is before
the start of the block.  Break the loop if the CIE could not be
read.  Update call to get_encoded_value.  Warn if the read CFA
expressions are too big.

* ieee.c (ieee_archive_p) Skip processing if no bytes are read at
all.
(ieee_object_p): Likewise.

9 years agoFix dw2-ifort-parameter.exp fail with clang
Yao Qi [Fri, 14 Nov 2014 00:53:09 +0000 (08:53 +0800)] 
Fix dw2-ifort-parameter.exp fail with clang

The patch <https://sourceware.org/ml/gdb-patches/2014-03/msg00202.html>
fixed dw2-ifort-parameter.exp on powerpc64 by adding some labels to
get the start and end address of function func.  This should also fix the
fail on thumb mode, however, this style is quite specific to gcc, and
other compiler, such as clang, may not guarantee the order of global
asms and functions.  The test fails with clang:

$ make check RUNTESTFLAGS='dw2-ifort-parameter.exp CC_FOR_TARGET=clang'
(gdb) p/x param^M
No symbol "param" in current context.^M
(gdb) FAIL: gdb.dwarf2/dw2-ifort-parameter.exp: p/x param

With this patch applied, dw2-ifort-parameter.exp still passes for gcc
on arm thumb mode and popwerpc64, and it also passes for clang on
x86_linux.

gdb/testsuite:

2014-11-14  Yao Qi  <yao@codesourcery.com>

* gdb.dwarf2/dw2-ifort-parameter.c: Remove inline asm.
(func): Add label func_label.
* gdb.dwarf2/dw2-ifort-parameter.exp (Dwarf::assemble):
Replace low_pc and high_pc with MACRO_AT_range.
Replace name, low_pc and high_pc with MACRO_AT_func.

9 years agoFix implptr-optimized-out.exp fail
Yao Qi [Fri, 14 Nov 2014 00:53:08 +0000 (08:53 +0800)] 
Fix implptr-optimized-out.exp fail

Hi,
I see the fail in gdb.dwarf2/implptr-optimized-out.exp in thumb mode

(gdb) p p->f^M
No symbol "p" in current context.^M
(gdb) FAIL: gdb.dwarf2/implptr-optimized-out.exp: p p->f

and the crash on powerpc64

(gdb) continue^M
Continuing.^M
^M
Program received signal SIGSEGV, Segmentation fault.^M
0x7d82100810000828 in ?? ()

The cause of both is that we incorrectly set attribute low_pc, since
main isn't resolved to function start address on these targets.

In this patch, we replace attributes name, low_pc and high_pc with
MACRO_AT_func.  The fail on thumb mode is fixed, and crash on
powerpc64 is fixed too.

gdb/testsuite:

2014-11-14  Yao Qi  <yao@codesourcery.com>

* gdb.dwarf2/implptr-optimized-out.exp (Dwarf::assemble):
Replace name, low_pc and high_pc with MACRO_AT_func.

9 years agoUse Dwarf::assemble in implptr-optimized-out.exp
Yao Qi [Fri, 14 Nov 2014 00:53:08 +0000 (08:53 +0800)] 
Use Dwarf::assemble in implptr-optimized-out.exp

This patch is to use dwarf::assemble to generate debug information, and
remove implptr-optimized-out.S as a result.

gdb/testsuite:

2014-11-14  Yao Qi  <yao@codesourcery.com>

* gdb.dwarf2/implptr-optimized-out.exp: Use Dwarf::assemble to
produce debug information.
* gdb.dwarf2/implptr-optimized-out.S: Removed.

9 years agoGet start and end address of main in dwz.exp
Yao Qi [Fri, 14 Nov 2014 00:53:08 +0000 (08:53 +0800)] 
Get start and end address of main in dwz.exp

On arm-none-eabi target thumb mode, I see the following fail,

p the_int^M
$2 = 99^M
(gdb) FAIL: gdb.dwarf2/dwz.exp: p the_int

and on powerpc64 target, we even can't get function main from object
file,

disassemble main^M
No function contains specified address.^M
(gdb) FAIL: gdb.dwarf2/dwz.exp: disassemble main

This patch is to use MACRO_AT_func attribute to get the main's start
address and end address correctly, and also remove some code dwz.exp
getting main's length.  This patch fixes fails on both thumb mode and
powerpc64 target.

PASS: gdb.dwarf2/dwz.exp: p other_int
PASS: gdb.dwarf2/dwz.exp: p the_int

gdb/testsuite:

2014-11-14  Yao Qi  <yao@codesourcery.com>

* gdb.dwarf2/dwz.exp: Remove the code to compile main.c to
object and get function length.
(Dwarf::assemble): Replace name, low_pc and high_pc attributes
with MACRO_AT_func.
(top-level): Replace gdb_compile and clean_restart with
prepare_for_testing.
* gdb.dwarf2/main.c (main): Add label main_label.

9 years agoDW attribute macro MACRO_AT_func and MACRO_AT_range
Yao Qi [Fri, 14 Nov 2014 00:53:08 +0000 (08:53 +0800)] 
DW attribute macro MACRO_AT_func and MACRO_AT_range

This patch addes DW macro attributes MACRO_AT_func and MACRO_AT_range
in dwarf assembler, which emits "DW_AT_low_pc func_start addr" and
"DW_AT_high_pc func_end addr".  func_start and func_end are computed
automatically by proc function_range.

These two attributes are pseudo attribute or macro attribute, which
means they are not standard dwarf attribute in dwarf spec.  Then can
be substituted or expanded to standard attributes or macro attributes.
See details in the comments to them.  Dwarf assembler is extended to
handle them.

Now the attributes name/low_pc/high_pc can be replaced with
MACRO_AT_func like this:

    subprogram {
{name main}
{low_pc main_start addr}
{high_pc main_end addr}
    }

becomes:

    subprogram {
{MACRO_AT_func { main ${srcdir}/${subdir}/${srcfile} }}
    }

users don't have to worry about the start and end of function main, and
they only need to add a label main_label in main.

gdb/testsuite:

2014-11-14  Yao Qi  <yao@codesourcery.com>

* lib/dwarf.exp (function_range): New procedure.
(Dwarf::_handle_macro_at_func): New procedure.
(Dwarf::_handle_macro_at_range): New procedure.
(Dwarf): Handle MACRO_AT_func and MACRO_AT_range.

9 years agoNew proc _handle_attribute
Yao Qi [Fri, 14 Nov 2014 00:53:08 +0000 (08:53 +0800)] 
New proc _handle_attribute

This patch is to move some code to a new procedure _handle_attribute,
which will be used in my following patches.

gdb/testsuite:

2014-11-14  Yao Qi  <yao@codesourcery.com>

* lib/dwarf.exp (_handle_DW_TAG): Move some code to ...
(_handle_attribute): New procedure.

9 years agoPR symtab/17591
Doug Evans [Fri, 14 Nov 2014 00:50:51 +0000 (16:50 -0800)] 
PR symtab/17591

gdb/ChangeLog:

PR symtab/17591
* dwarf2read.c (find_slot_in_mapped_hash): Handle
"(anonymous namespace)".

9 years agodwarf2read.c (update_enumeration_type_from_children): Avoid infinite loop.
Doug Evans [Thu, 13 Nov 2014 23:43:12 +0000 (15:43 -0800)] 
dwarf2read.c (update_enumeration_type_from_children): Avoid infinite loop.

gdb/ChangeLog:

* dwarf2read.c (update_enumeration_type_from_children): Avoid
infinite loop.

9 years agoAdd cast to unsigned int
H.J. Lu [Thu, 13 Nov 2014 20:56:18 +0000 (12:56 -0800)] 
Add cast to unsigned int

* coffcode.h (coff_slurp_line_table): Add cast to unsigned int.

9 years agoRename symbbol to symbol
H.J. Lu [Thu, 13 Nov 2014 20:15:46 +0000 (12:15 -0800)] 
Rename symbbol to symbol

* coffcode.h (coff_pointerize_aux_hook): Fix a typo.

9 years agoMark R_X86_64_GOTPLT64 obsolete
H.J. Lu [Thu, 13 Nov 2014 19:26:47 +0000 (11:26 -0800)] 
Mark R_X86_64_GOTPLT64 obsolete

* x86-64.h (R_X86_64_GOTPLT64): Mark it obsolete.

9 years agoAdd assembler support for @gotplt
H.J. Lu [Thu, 13 Nov 2014 19:07:31 +0000 (11:07 -0800)] 
Add assembler support for @gotplt

Obsolete R_X86_64_GOTPLT64 and treat it the same as R_X86_64_GOT64.

bfd/

PR gas/17598
* elf64-x86-64.c (elf_x86_64_check_relocs): Treat
R_X86_64_GOTPLT64 the same as R_X86_64_GOT64.
(elf_x86_64_relocate_section): Likewise.

gas/

PR gas/17598
* config/tc-i386.c (reloc): Support BFD_RELOC_X86_64_GOTPLT64.

gas/testsuite/

PR gas/17598
* gas/i386/reloc64.s: Add @gotplt check.

* gas/i386/reloc64.d: Updated.
* gas/i386/reloc64.l: Likewise.

ld/testsuite/

PR gas/17598
* ld-x86-64/x86-64.exp: Run gotplt1.

* ld-x86-64/gotplt1.d: New file.
* ld-x86-64/gotplt1.s: Likewise.

9 years agoNEWS: Fix typo.
Jan Kratochvil [Thu, 13 Nov 2014 17:56:48 +0000 (18:56 +0100)] 
NEWS: Fix typo.

gdb/ChangeLog
2014-11-13  Jan Kratochvil  <jan.kratochvil@redhat.com>

* NEWS (maint set target-async): Fix typo.

9 years agoMore fixes for memory access violations whilst scanning corrupt binaries.
Nick Clifton [Thu, 13 Nov 2014 17:46:11 +0000 (17:46 +0000)] 
More fixes for memory access violations whilst scanning corrupt binaries.

PR binutils/17512
* config/obj-coff.c (coff_obj_symbol_new_hook): Set the is_sym
field.

* coffcode.h (coff_ptr_struct): Add is_sym field.
(coff_new_section_hook): Set the is_sym field.
(coff_pointerize_aux_hook): Check the is_sym field.
(coff_print_aux): Likewise.
(coff_compute_section_file_positions): Likewise.
(coff_write_object_contents): Likewise.
(coff_slurp_line_table): Likewise.
(coff_slurp_symbol_table): Likewise.
(CALC_ADDEND): Likewise.
* coffgen.c (coff_renumber_symbols): Likewise.
(coff_mangle_symbols): Likewise.
(coff_fix_symbol_name): Likewise.
(coff_write_symbol): Likewise.
(coff_write_alien_symbol): Likewise.
(coff_write_native_symbol): Likewise.
(coff_write_symbols): Likewise.
(coff_write_linenumbers): Likewise.
(coff_pointerize_aux): Likewise.
(coff_get_normalized_symtab): Likewise.
(coff_get_symbol_info): Likewise.
(bfd_coff_get_syment): Likewise.
(bfd_coff_get_auxent): Likewise.
(coff_print_symbol): Likewise.
(coff_find_nearest_line_with_names): Likewise.
(bfd_coff_set_symbol_class): Likewise.
(coff_make_empty_symbol): Set the is_sym field.
(coff_bfd_make_debug_symbol): Likewise.
* peicode.h (pe_ILF_make_a_symbol): Likewise.
* libcoff.h: Regenerate.
* libcoff-in.h: Regenerate.

9 years ago[AArch64] Remove example processors from GAS.
Marcus Shawcroft [Thu, 13 Nov 2014 16:42:23 +0000 (16:42 +0000)] 
[AArch64] Remove example processors from GAS.

9 years agoMore fixes for readelf problems reading corrupt files.
Nick Clifton [Thu, 13 Nov 2014 10:45:50 +0000 (10:45 +0000)] 
More fixes for readelf problems reading corrupt files.

PR binutils/17531
* readelf.c (process_version_sections): If the read of the version
def information fails, make sure that the external verdef data is
not used.
(get_dynamic_data): Do not attempt to allocate memory for more
dynamic data than there is in the file.  If the read fails, free
the allocated buffer.
(process_symbol_table): Do not print dynamic information if we
were unable to read the dynamic symbol table.
(print_gnu_note): Do not print the note if the descsz is too
small.

9 years agoGDB testsuite: Fix warnings with -std=gnu11
Andreas Arnez [Tue, 28 Oct 2014 12:39:22 +0000 (12:39 +0000)] 
GDB testsuite: Fix warnings with -std=gnu11

Since upstream GCC has changed the default C language dialect to
'gnu11', it yields multiple warnings in the GDB testsuite for missing
function return types and implicit function declarations.  This patch
attempts to fix these.

gdb/testsuite/ChangeLog:

* gdb.ada/cond_lang/foo.c (callme): Add return type.
* gdb.base/call-sc.c (zed): Likewise.
* gdb.base/checkpoint.c (main): Likewise.
* gdb.base/dump.c (main): Likewise.
* gdb.base/gcore.c (main): Likewise.
* gdb.base/huge.c (main): Likewise.
* gdb.base/multi-forks.c (main): Likewise.
* gdb.base/pr10179-a.c (main): Likewise.
* gdb.base/savedregs.c (main): Likewise.
* gdb.base/sigaltstack.c (main): Likewise.
* gdb.base/siginfo.c (main): Likewise.
* gdb.base/structs.c (zed): Likewise.
* gdb.mi/mi-stack.c (callee3, callee2, callee1, main): Likewise.
* gdb.mi/mi-syn-frame.c (main): Likewise.
* gdb.mi/until.c (foo, main): Likewise.
* gdb.base/global-var-nested-by-dso.c (b_main, c_main): Declare.
* gdb.base/solib-weak.c (foo): Declare.
* gdb.base/attach-twice.c: Include stdio.h.
* gdb.base/weaklib1.c: Likewise.
* gdb.base/weaklib2.c: Likewise.
* gdb.base/catch-signal-fork.c: Include stdio.h and sys/wait.h.
* gdb.mi/mi-condbreak-call-thr-state-mt.c: Include stdio.h and
unistd.h.
* gdb.base/attach-pie-misread.c: Include stdlib.h.
* gdb.mi/mi-exit-code.c: Likewise.
* gdb.base/break-interp-lib.c: Include string.h.
* gdb.base/coremaker.c: Likewise.
* gdb.base/testenv.c: Likewise.
* gdb.python/py-finish-breakpoint.c: Likewise.
* gdb.base/inferior-died.c: Include sys/wait.h.
* gdb.base/fileio.c: Include time.h.
* gdb.base/async-shell.c: Include unistd.h.
* gdb.base/dprintf-non-stop.c: Likewise.
* gdb.base/info-os.c: Likewise.
* gdb.mi/mi-console.c: Likewise.
* gdb.mi/watch-nonstop.c: Likewise.
* gdb.python/py-events.c: Likewise.
* gdb.base/async.c (baz): Move up before its invocation.
* gdb.base/code_elim2.c (my_global_func): Likewise.
* gdb.base/skip-solib-lib.c (multiply): Likewise.
* gdb.base/advance.c (func2): Likewise.

9 years agoGDB testsuite: drop non-prototype C function header variants
Andreas Arnez [Fri, 24 Oct 2014 12:07:53 +0000 (12:07 +0000)] 
GDB testsuite: drop non-prototype C function header variants

Remove many old-style function header variants in C source files of
the GDB test suite, using the 'unifdef' tool with '-DPROTOTYPES=1'.

gdb/testsuite/ChangeLog:

* gdb.base/annota1.c: Remove #ifdef PROTOTYPES, keep prototyped
variant.
* gdb.base/annota3.c: Likewise.
* gdb.base/async.c: Likewise.
* gdb.base/average.c: Likewise.
* gdb.base/call-ar-st.c: Likewise.
* gdb.base/call-rt-st.c: Likewise.
* gdb.base/call-sc.c: Likewise.
* gdb.base/call-strs.c: Likewise.
* gdb.base/ending-run.c: Likewise.
* gdb.base/execd-prog.c: Likewise.
* gdb.base/exprs.c: Likewise.
* gdb.base/foll-exec.c: Likewise.
* gdb.base/foll-fork.c: Likewise.
* gdb.base/foll-vfork.c: Likewise.
* gdb.base/funcargs.c: Likewise.
* gdb.base/gcore.c: Likewise.
* gdb.base/jump.c: Likewise.
* gdb.base/langs0.c: Likewise.
* gdb.base/langs1.c: Likewise.
* gdb.base/langs2.c: Likewise.
* gdb.base/mips_pro.c: Likewise.
* gdb.base/nodebug.c: Likewise.
* gdb.base/opaque0.c: Likewise.
* gdb.base/opaque1.c: Likewise.
* gdb.base/recurse.c: Likewise.
* gdb.base/run.c: Likewise.
* gdb.base/scope0.c: Likewise.
* gdb.base/scope1.c: Likewise.
* gdb.base/setshow.c: Likewise.
* gdb.base/setvar.c: Likewise.
* gdb.base/shmain.c: Likewise.
* gdb.base/shr1.c: Likewise.
* gdb.base/shr2.c: Likewise.
* gdb.base/sigall.c: Likewise.
* gdb.base/signals.c: Likewise.
* gdb.base/so-indr-cl.c: Likewise.
* gdb.base/solib2.c: Likewise.
* gdb.base/structs.c: Likewise.
* gdb.base/sum.c: Likewise.
* gdb.base/vforked-prog.c: Likewise.
* gdb.base/watchpoint.c: Likewise.
* gdb.reverse/shr2.c: Likewise.
* gdb.reverse/until-reverse.c: Likewise.
* gdb.reverse/ur1.c: Likewise.
* gdb.reverse/watch-reverse.c: Likewise.

9 years agoDrop non-prototype C function header variants: 'sepdebug' test case
Andreas Arnez [Thu, 23 Oct 2014 11:02:31 +0000 (11:02 +0000)] 
Drop non-prototype C function header variants: 'sepdebug' test case

Remove old-style function header variants from sepdebug.c.  Eliminate
references to the removed locations "breakpoint 9" and "breakpoint 13"
from sepdebug.exp.

gdb/testsuite/ChangeLog:

* gdb.base/sepdebug.c: Remove #ifdef PROTOTYPES, keep prototyped
variant.
* gdb.base/sepdebug.exp: Drop references to removed code.

9 years agoDrop non-prototype C function header variants: 'list' test case
Andreas Arnez [Wed, 22 Oct 2014 17:13:34 +0000 (17:13 +0000)] 
Drop non-prototype C function header variants: 'list' test case

Remove old-style function header variants from list0.h and list1.c.
Fill the removed lines with comments or empty lines, such that the
line numbering is undisturbed.  Changes to the line numbering would
require heavy adjustments to list.exp, where many line numbers are
hard-coded, as well as a fair amount of knowledge about the source
code in and around certain lines.  Thus the dependency on the line
numbering can not be eliminated so easily, and it may not even be a
useful goal for a "list" test case.  Another option might be to adjust
the literal line numbers in list.exp, but even that is not as
straightforward as it may seem, since the test case expects certain
source lines to be exactly n lines apart.

gdb/testsuite/ChangeLog:

* gdb.base/list0.h: Remove #ifdef PROTOTYPES, keep prototyped
variant.  Preserve original line numbering.
* gdb.base/list1.c: Likewise.

9 years agoDrop non-prototype C function header variants: 'break' test case
Andreas Arnez [Wed, 22 Oct 2014 09:24:25 +0000 (09:24 +0000)] 
Drop non-prototype C function header variants: 'break' test case

Remove old-style function headers from break.c and break1.c.  Adjust
break.exp accordingly; in particular eliminate references to the
removed locations "breakpoint 9, 13, and 16" from break.exp.

gdb/testsuite/ChangeLog:

* gdb.base/break.c: Remove #ifdef PROTOTYPES, keep prototyped
variant.
* gdb.base/break1.c: Likewise.
* gdb.base/break.exp: Drop references to removed code.

9 years agoDrop non-prototype C function header variants: solib1.c
Andreas Arnez [Thu, 23 Oct 2014 14:27:57 +0000 (14:27 +0000)] 
Drop non-prototype C function header variants: solib1.c

Clean up solib1.c by removing the #ifdef PROTOTYPES conditional.

gdb/testsuite/ChangeLog:

* gdb.base/solib1.c: Remove #ifdef PROTOTYPES, keep prototyped
variant.

9 years agocallfuncs.exp: Indent perform_all_tests()
Andreas Arnez [Tue, 4 Nov 2014 13:50:42 +0000 (13:50 +0000)] 
callfuncs.exp: Indent perform_all_tests()

The previous patch did not indent perform_all_tests() correctly after
moving the main logic into it, to avoid obscuring the functional
changes.  This patch fixes the indentation.

gdb/testsuite/ChangeLog:

* gdb.base/callfuncs.exp (perform_all_tests): Re-indent.

9 years agoPerform all tests in callfuncs.exp with and without C function prototypes
Andreas Arnez [Tue, 4 Nov 2014 12:55:30 +0000 (12:55 +0000)] 
Perform all tests in callfuncs.exp with and without C function prototypes

In callfuncs.exp, compile callfuncs.c with and without C function
header prototypes and execute all tests after each compilation.

gdb/testsuite/ChangeLog:

* gdb.base/callfuncs.exp: Remove 'prototypes' variable.  Move main
logic into perform_all_tests() and invoke it with and without
function header prototypes.
(do_function_calls): Remove conditional XFAIL for PR 5318.
(rerun_and_prepare): Remove duplicate code.
(perform_all_tests): New.  Main logic moved here.

9 years ago'callfuncs' test case: Fixes in conditionally compiled code
Andreas Arnez [Wed, 22 Oct 2014 17:46:29 +0000 (17:46 +0000)] 
'callfuncs' test case: Fixes in conditionally compiled code

The C source file for the 'callfuncs' test case did not compile with
-DNO_PROTOTYPES or -DPROTOTYPES.  This patch fixes various syntax
errors under #ifdef NO_PROTOTYPES and a small typo under #ifdef
PROTOTYPES.

gdb/testsuite/ChangeLog:

* gdb.base/callfuncs.c (t_float_many_args): Fix syntax error in
code guarded by #ifdef NO_PROTOTYPES.
(t_double_many_args): Likewise.
(DEF_FUNC_MANY_ARGS_1): Likewise.
(DEF_FUNC_VALUES_1): Likewise.
(t_structs_ldc): Renamed from t_structs_fc in conditional code
guarded by #ifdef PROTOTYPES.

9 years agoEliminate literal line numbers in mi-console.exp
Andreas Arnez [Tue, 28 Oct 2014 15:19:08 +0000 (15:19 +0000)] 
Eliminate literal line numbers in mi-console.exp

Remove the literal line number from a regexp in mi-console.exp.  Add
an appropriate eye-catcher to mi-console.c and refer to that instead.

gdb/testsuite/ChangeLog:

* gdb.mi/mi-console.c: Add eye-catcher.
* gdb.mi/mi-console.exp (semihosted_string): Refer to eye-catcher
instead of literal line number.

9 years agoEliminate literal line numbers in shlib-call.exp
Andreas Arnez [Fri, 24 Oct 2014 12:05:10 +0000 (12:05 +0000)] 
Eliminate literal line numbers in shlib-call.exp

Remove the literal line number from a regexp in shlib-call.exp.  Add
an appropriate eye-catcher to shr2.c and refer to that instead.

gdb/testsuite/ChangeLog:

* gdb.base/shr2.c: Add eye-catcher.
* gdb.base/shlib-call.exp: Refer to eye-catcher instead of literal
line number.

9 years agoEliminate literal line numbers in jump.exp
Andreas Arnez [Fri, 24 Oct 2014 11:57:22 +0000 (11:57 +0000)] 
Eliminate literal line numbers in jump.exp

Remove literal line numbers from the regexps in jump.exp.  Add
appropriate eye-catchers to jump.c and refer to those instead.

gdb/testsuite/ChangeLog:

* gdb.base/jump.c: Add eye-catchers.
* gdb.base/jump.exp: Refer to eye-catchers instead of literal line
numbers.

9 years agoEliminate literal line numbers in foll-exec.exp
Andreas Arnez [Fri, 24 Oct 2014 11:04:56 +0000 (11:04 +0000)] 
Eliminate literal line numbers in foll-exec.exp

Remove literal line numbers from the regexps in foll-exec.exp.  Add
appropriate eye-catchers to foll-exec.c and execd-proc.c and refer to
those instead.

gdb/testsuite/ChangeLog:

* gdb.base/execd-prog.c: Add eye-catchers.
* gdb.base/foll-exec.c: Likewise.
* gdb.base/foll-exec.exp: Refer to eye-catchers instead of literal
line numbers.

9 years agoEliminate literal line numbers in ending-run.exp
Andreas Arnez [Fri, 24 Oct 2014 09:24:01 +0000 (09:24 +0000)] 
Eliminate literal line numbers in ending-run.exp

Remove literal line numbers from the regexps in ending-run.exp.  Add
appropriate eye-catchers to ending-run.c and refer to those instead.

gdb/testsuite/ChangeLog:

* gdb.base/ending-run.c: Add eye-catchers.
* gdb.base/ending-run.exp: Refer to eye-catchers instead of
literal line numbers.

9 years agoEliminate literal line numbers in call-rt-st.exp
Andreas Arnez [Fri, 24 Oct 2014 09:15:10 +0000 (09:15 +0000)] 
Eliminate literal line numbers in call-rt-st.exp

Remove literal line numbers from the regexps in call-rt-st.exp.  Add
appropriate eye-catchers to call-rt-st.c and refer to those instead.

gdb/testsuite/ChangeLog:

* gdb.base/call-rt-st.c: Add eye-catchers.
* gdb.base/call-rt-st.exp: Refer to eye-catchers instead of
literal line numbers.

9 years agoEliminate literal line numbers in call-ar-st.exp
Andreas Arnez [Thu, 23 Oct 2014 16:00:21 +0000 (16:00 +0000)] 
Eliminate literal line numbers in call-ar-st.exp

Remove literal line numbers from the regexps in call-ar-st.exp.  Add
appropriate eye-catchers to call-ar-st.c and refer to those instead.

gdb/testsuite/ChangeLog:

* gdb.base/call-ar-st.c: Add eye-catchers.
* gdb.base/call-ar-st.exp: Refer to eye-catchers instead of
literal line numbers.

9 years agoEliminate literal line numbers in dbx.exp
Andreas Arnez [Wed, 29 Oct 2014 18:16:20 +0000 (18:16 +0000)] 
Eliminate literal line numbers in dbx.exp

Remove literal line numbers from the commands and regexps in dbx.exp.
Add appropriate eye-catchers to average.c and sum.c and refer to those
instead.

gdb/testsuite/ChangeLog:

* gdb.base/average.c: Add eye-catchers.
* gdb.base/sum.c: Likewise.
* gdb.base/dbx.exp: Use eye-catchers to determine line numbers for
regexps dynamically.

9 years agoEliminate literal line numbers in so-impl-ld.exp
Andreas Arnez [Thu, 23 Oct 2014 13:56:52 +0000 (13:56 +0000)] 
Eliminate literal line numbers in so-impl-ld.exp

Remove literal line numbers from the regexps in so-impl-ld.exp.  Add
appropriate eye-catchers to solib1.c and refer to those instead.

gdb/testsuite/ChangeLog:

* gdb.base/solib1.c: Add eye-catchers.
* gdb.base/so-impl-ld.exp: Match against eye-catchers instead of
literal line numbers.

9 years agoFix more memory faults uncovered by fuzzing various executables.
Nick Clifton [Wed, 12 Nov 2014 22:39:58 +0000 (22:39 +0000)] 
Fix more memory faults uncovered by fuzzing various executables.

PR binutils/17512
* dwarf.c (read_and_display_attr_value): Check that we do not read
past end.
(display_debug_pubnames_worker): Add range checks.
(process_debug_info): Check for invalid pointer sizes.
(display_loc_list): Likewise.
(display_loc_list_dwo): Likewise.
(display_debug_ranges): Likewise.
(display_debug_aranges): Check for invalid address size.
(read_cie): Add range checks.  Replace call strchr with while loop.
* objdump.c (dump_dwarf): Replace abort with a warning message.
(print_section_stabs): Improve range checks.
* rdcoff.c (coff_get_slot): Use long for indx parameter type.
Add check for an excesively large index.
* rddbg.c (read_section_stabs_debugging_info): Zero terminate the
string table.  Avoid walking off the end of the stabs data.
* stabs.c (parse_stab_string): Add check for a NULL name.

PR binutils/17512
* coffcode.h (coff_slurp_line_table): Set the line number of
corrupt entries to -1.
(coff_slurp_symbol_table): Alway initialise the value of the
symbol.
* coffgen.c (coff_print_symbol): Check that the combined pointer
is valid.
(coff_print_symbol): Do not print negative line numbers.
* peXXigen.c (pe_print_idata): Add range checking displaying
member names.

9 years agoGDBserver: clean up 'cont_thread' handling
Pedro Alves [Wed, 12 Nov 2014 11:17:40 +0000 (11:17 +0000)] 
GDBserver: clean up 'cont_thread' handling

As no place in the backends check cont_thread anymore, we can stop
setting and clearing it in places that resume the target and wait for
events.  Instead simply clear it whenever a new GDB connects.

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

* server.c (cont_thread): Update comment.
(start_inferior, attach_inferior): No longer clear cont_thread.
(handle_v_cont): No longer set cont_thread.
(captured_main): Clear cont_thread each time a GDB connects.

9 years agoGDBserver: don't resume all threads if the Hc thread disapears
Pedro Alves [Wed, 12 Nov 2014 11:17:39 +0000 (11:17 +0000)] 
GDBserver: don't resume all threads if the Hc thread disapears

There's code in linux_wait_1 that resumes all threads if the Hc thread
disappears.  It's the wrong thing to do, as GDB has told GDBserver to
resume only one thread, because e.g., the user has scheduler-locking
enabled, or because GDB was stepping the program over a breakpoint.
Resuming all threads behind GDB's back can't be good in either case.

The right thing to do is to detect that that the (only) resumed thread
is gone, and let GDB know about it.  The Linux backend is already
doing that nowadays, since:

 commit fa96cb382c12b099675c5cc238aaa7352a3fd3d7
 Author:     Pedro Alves <palves@redhat.com>
 AuthorDate: Thu Feb 27 14:30:08 2014 +0000

     Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED).

The backend detects that all resumed threads have disappeared, and
returns TARGET_WAITKIND_NO_RESUMED to the core of GDBserver, which
then reports an error to GDB.

There's no need to frob the passed in ptid to wait for the continue
thread either -- linux_wait_for_event only returns events for resumed
threads.

The badness (of resuming threads) can actually be observed in the
testsuite, if we force-disable vCont support in GDBserver -- before
the patch, gdb.threads/no-unwaited-for-left.exp hangs if we disable
vCont:

 (gdb) continue
 Continuing.
 FAIL: gdb.threads/no-unwaited-for-left.exp: continue to breakpoint: break-here (timeout)
 ... more cascading timeouts ....

After the patch, gdb.threads/no-unwaited-for-left.exp behaves the same
with or without vCont support:

 (gdb) continue
 Continuing.
 [New Thread 32226]
 [Switching to Thread 32226]

 Breakpoint 2, thread_a (arg=0x0) at /home/pedro/gdb/mygit/build/../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28
 28   return 0; /* break-here */
 (gdb) PASS: gdb.threads/no-unwaited-for-left.exp: continue to breakpoint: break-here
...
 continue
 Continuing.
 warning: Remote failure reply: E.No unwaited-for children left.

 [Thread 32222] #1 stopped.
 (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits

Overall, this is also good for getting rid of a RSP detail from the backend.

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

* linux-low.c (linux_wait_1): Don't force a wait for the Hc
thread, and don't resume all threads if the Hc thread has exited.

9 years agoGDBserver: ctrl-c after leader has exited
Pedro Alves [Wed, 12 Nov 2014 11:17:39 +0000 (11:17 +0000)] 
GDBserver: ctrl-c after leader has exited

The target->request_interrupt callback implements the handling for
ctrl-c.  User types ctrl-c in GDB, GDB sends a \003 to the remote
target, and the remote targets stops the program with a SIGINT, just
like if the user typed ctrl-c in GDBserver's terminal.

The trouble is that using kill_lwp(signal_pid, SIGINT) sends the
SIGINT directly to the program's main thread.  If that thread has
exited already, then that kill won't do anything.

Instead, send the SIGINT to the process group, just like GDB
does (see inf-ptrace.c:inf_ptrace_stop).

gdb.threads/leader-exit.exp is extended to cover the scenario.  It
fails against GDBserver before the patch.

Tested on x86_64 Fedora 20, native and GDBserver.

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

* linux-low.c (linux_request_interrupt): Always send a SIGINT to
the process group instead of to a specific LWP.

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

* gdb.threads/leader-exit.exp: Test sending ctrl-c works after the
leader has exited.

9 years agoGarbage collect the infwait_state global
Pedro Alves [Wed, 12 Nov 2014 11:02:11 +0000 (11:02 +0000)] 
Garbage collect the infwait_state global

No longer used since the non-continuable watchpoints handling rework.

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

* infrun.c (enum infwait_states, infwait_state): Delete.

9 years agofix skipping permanent breakpoints
Pedro Alves [Wed, 12 Nov 2014 10:10:49 +0000 (10:10 +0000)] 
fix skipping permanent breakpoints

The gdb.arch/i386-bp_permanent.exp test is currently failing an
assertion recently added:

 (gdb) stepi
 ../../src/gdb/infrun.c:2237: internal-error: resume: Assertion `sig != GDB_SIGNAL_0' failed.
 A problem internal to GDB has been detected,
 further debugging may prove unreliable.
 Quit this debugging session? (y or n)
 FAIL: gdb.arch/i386-bp_permanent.exp: Single stepping past permanent breakpoint. (GDB internal error)

The assertion expects that the only reason we currently need to step a
breakpoint instruction is when we have a signal to deliver.  But when
stepping a permanent breakpoint (with or without a signal) we also
reach this code.

The assertion is correct and the permanent breakpoints skipping code
is wrong.

Consider the case of the user doing "step/stepi" when stopped at a
permanent breakpoint.  GDB's `resume' calls the
gdbarch_skip_permanent_breakpoint hook and then happily continues
stepping:

  /* Normally, by the time we reach `resume', the breakpoints are either
     removed or inserted, as appropriate.  The exception is if we're sitting
     at a permanent breakpoint; we need to step over it, but permanent
     breakpoints can't be removed.  So we have to test for it here.  */
  if (breakpoint_here_p (aspace, pc) == permanent_breakpoint_here)
    {
      gdbarch_skip_permanent_breakpoint (gdbarch, regcache);
    }

But since gdbarch_skip_permanent_breakpoint already advanced the PC
manually, this ends up executing the instruction that is _after_ the
breakpoint instruction.  The user-visible result is that a single-step
steps two instructions.

The gdb.arch/i386-bp_permanent.exp test is actually ensuring that
that's indeed how things work.  It runs to an int3 instruction, does
"stepi", and checks that "leave" was executed with that "stepi".  Like
this:

 (gdb) b *0x0804848c
 Breakpoint 2 at 0x804848c
 (gdb) c
 Continuing.

 Breakpoint 2, 0x0804848c in standard ()
 (gdb) disassemble
 Dump of assembler code for function standard:
    0x08048488 <+0>:     push   %ebp
    0x08048489 <+1>:     mov    %esp,%ebp
    0x0804848b <+3>:     push   %edi
 => 0x0804848c <+4>:     int3
    0x0804848d <+5>:     leave
    0x0804848e <+6>:     ret
    0x0804848f <+7>:     nop
 (gdb) si
 0x0804848e in standard ()
 (gdb) disassemble
 Dump of assembler code for function standard:
    0x08048488 <+0>:     push   %ebp
    0x08048489 <+1>:     mov    %esp,%ebp
    0x0804848b <+3>:     push   %edi
    0x0804848c <+4>:     int3
    0x0804848d <+5>:     leave
 => 0x0804848e <+6>:     ret
    0x0804848f <+7>:     nop
 End of assembler dump.
 (gdb)

One would instead expect that a stepi at 0x0804848c stops at
0x0804848d, _before_ the "leave" is executed.  This commit changes GDB
this way.  Care is taken to make stepping into a signal handler when
the step starts at a permanent breakpoint instruction work correctly.

The patch adjusts gdb.arch/i386-bp_permanent.exp in this direction,
and also makes it work on x86_64 (currently it only works on i*86).

The patch also adds a new gdb.base/bp-permanent.exp test that
exercises many different code paths related to stepping permanent
breakpoints, including the stepping with signals cases.  The test uses
"hack/trick" to make it work on all (or most) platforms -- it doesn't
really hard code a breakpoint instruction.

Tested on x86_64 Fedora 20, native and gdbserver.

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

* infrun.c (resume): Clear the thread's 'stepped_breakpoint' flag.
Rewrite stepping over a permanent breakpoint.
(thread_still_needs_step_over, proceed): Don't set
stepping_over_breakpoint for permanent breakpoints.
(handle_signal_stop): Don't clear stepped_breakpoint.  Also pull
single-step breakpoints out of the target on hardware step
targets.
(process_event_stop_test): If stepping a permanent breakpoint
doesn't hit the step-resume breakpoint, delete the step-resume
breakpoint.
(switch_back_to_stepped_thread): Also check if the stepped thread
has advanced already on hardware step targets.
(currently_stepping): Return true if the thread stepped a
breakpoint.

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

* gdb.arch/i386-bp_permanent.c: New file.
* gdb.arch/i386-bp_permanent.exp: Don't skip on x86_64.
(srcfile): Set to i386-bp_permanent.c.
(top level): Adjust to work in both 32-bit and 64-bit modes.  Test
that stepi does not execute the 'leave' instruction, instead of
testing it does execute.
* gdb.base/bp-permanent.c: New file.
* gdb.base/bp-permanent.exp: New file.

9 years agomake "permanent breakpoints" per location and disableable
Pedro Alves [Wed, 12 Nov 2014 10:10:49 +0000 (10:10 +0000)] 
make "permanent breakpoints" per location and disableable

"permanent"-ness is currently a property of the breakpoint.  But, it
should actually be an implementation detail of a _location_.  Consider
this bit in infrun.c:

  /* Normally, by the time we reach `resume', the breakpoints are either
     removed or inserted, as appropriate.  The exception is if we're sitting
     at a permanent breakpoint; we need to step over it, but permanent
     breakpoints can't be removed.  So we have to test for it here.  */
  if (breakpoint_here_p (aspace, pc) == permanent_breakpoint_here)
    {
      if (gdbarch_skip_permanent_breakpoint_p (gdbarch))
gdbarch_skip_permanent_breakpoint (gdbarch, regcache);
      else
error (_("\
The program is stopped at a permanent breakpoint, but GDB does not know\n\
how to step past a permanent breakpoint on this architecture.  Try using\n\
a command like `return' or `jump' to continue execution."));
    }

This will wrongly skip a non-breakpoint instruction if we have a
multiple location breakpoint where the whole breakpoint was set to
"permanent" because one of the locations happened to be permanent,
even if the one GDB is resuming from is not.

Related, because the permanent breakpoints are only marked as such in
init_breakpoint_sal, we currently miss marking momentary breakpoints
as permanent.  A test added by a following patch trips on that.
Making permanent-ness be per-location, and marking locations as such
in add_location_to_breakpoint, the natural place to do this, fixes
this issue...

... and then exposes a latent issue with mark_breakpoints_out.  It's
clearing the inserted flag of permanent breakpoints.  This results in
assertions failing like this:

 Breakpoint 1, main () at testsuite/gdb.base/callexit.c:32
 32        return 0;
 (gdb) call callexit()
 [Inferior 1 (process 15849) exited normally]
 gdb/breakpoint.c:12854: internal-error: allegedly permanent breakpoint is not actually inserted
 A problem internal to GDB has been detected,
 further debugging may prove unreliable.

The call dummy breakpoint, which is a momentary breakpoint, is set on
top of a manually inserted breakpoint instruction, and so is now
rightfully marked as a permanent breakpoint.  See "Write a legitimate
instruction at the point where the infcall breakpoint is going to be
inserted." comment in infcall.c.

Re. make_breakpoint_permanent.  That's only called by solib-pa64.c.
Permanent breakpoints were actually originally invented for HP-UX [1].
I believe that that call (the only one in the tree) is unnecessary
nowadays, given that nowadays the core breakpoints code analyzes the
instruction under the breakpoint to automatically detect whether it's
setting a breakpoint on top of a breakpoint instruction in the
program.  I know close to nothing about HP-PA/HP-UX, though.

[1] https://sourceware.org/ml/gdb-patches/1999-q3/msg00245.html, and
    https://sourceware.org/ml/gdb-patches/1999-q3/msg00242.html

In addition to the per-location issue, "permanent breakpoints" are
currently always displayed as enabled=='n':

 (gdb) b main
 Breakpoint 3 at 0x40053c: file ../../../src/gdb/testsuite/gdb.arch/i386-permbkpt.S, line 29.
 (gdb) info breakpoints
 Num     Type           Disp Enb Address            What
 3       breakpoint     keep n   0x000000000040053c ../../../src/gdb/testsuite/gdb.arch/i386-permbkpt.S:29

But OTOH they're always enabled; there's no way to disable them...

In turn, this means that if one adds commands to such a breakpoint,
they're _always_ run:

 (gdb) start
 Starting program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.arch/i386-permbkpt
 ...
 Temporary breakpoint 1, main () at ../../../src/gdb/testsuite/gdb.arch/i386-permbkpt.S:29
 29              int3
 (gdb) b main
 Breakpoint 2 at 0x40053c: file ../../../src/gdb/testsuite/gdb.arch/i386-permbkpt.S, line 29.
 (gdb) info breakpoints
 Num     Type           Disp Enb Address            What
 2       breakpoint     keep n   0x000000000040053c ../../../src/gdb/testsuite/gdb.arch/i386-permbkpt.S:29
 (gdb) commands
 Type commands for breakpoint(s) 2, one per line.
 End with a line saying just "end".
 >echo "hello!"
 >end
 (gdb) disable 2
 (gdb) start
 The program being debugged has been started already.
 Start it from the beginning? (y or n) y
 Temporary breakpoint 3 at 0x40053c: file ../../../src/gdb/testsuite/gdb.arch/i386-permbkpt.S, line 29.
 Starting program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.arch/i386-permbkpt

 Breakpoint 2, main () at ../../../src/gdb/testsuite/gdb.arch/i386-permbkpt.S:29
 29              int3
 "hello!"(gdb)

IMO, one should be able to disable such a breakpoint, and GDB should
then behave just like if the user hadn't created the breakpoint in the
first place (that is, report a SIGTRAP).

By making permanent-ness a property of the location, and eliminating
the bp_permanent enum enable_state state ends up fixing that as well.

No tests are added for these changes yet; they'll be added in a follow
up patch, as skipping permanent breakpoints is currently broken and
trips on an assertion in infrun.

Tested on x86_64 Fedora 20, native and gdbserver.

gdb/ChangeLog:
2014-11-12  Pedro Alves  <palves@redhat.com>

Mark locations as permanent, not the whole breakpoint.
* breakpoint.c (remove_breakpoint_1, remove_breakpoint): Adjust.
(mark_breakpoints_out): Don't mark permanent breakpoints as
uninserted.
(breakpoint_init_inferior): Use mark_breakpoints_out.
(breakpoint_here_p): Adjust.
(bpstat_stop_status, describe_other_breakpoints): Remove handling
of permanent breakpoints.
(make_breakpoint_permanent): Mark each location as permanent,
instead of marking the breakpoint.
(add_location_to_breakpoint): If the location is permanent, mark
it as such, and as inserted.
(init_breakpoint_sal): Don't make the breakpoint permanent here.
(bp_location_compare, update_global_location_list): Adjust.
(update_breakpoint_locations): Don't make the breakpoint permanent
here.
(disable_breakpoint, enable_breakpoint_disp): Don't skip permanent
breakpoints.
* breakpoint.h (enum enable_state) <bp_permanent>: Delete field.
(struct bp_location) <permanent>: New field.
* guile/scm-breakpoint.c (bpscm_enable_state_to_string): Remove
reference to bp_permanent.

9 years agoadd a default method for gdbarch_skip_permanent_breakpoint
Pedro Alves [Wed, 12 Nov 2014 10:10:48 +0000 (10:10 +0000)] 
add a default method for gdbarch_skip_permanent_breakpoint

breakpoint.c uses gdbarch_breakpoint_from_pc to determine whether a
breakpoint location points at a permanent breakpoint:

 static int
 bp_loc_is_permanent (struct bp_location *loc)
 {
 ...
   addr = loc->address;
   bpoint = gdbarch_breakpoint_from_pc (loc->gdbarch, &addr, &len);
 ...
  if (target_read_memory (loc->address, target_mem, len) == 0
      && memcmp (target_mem, bpoint, len) == 0)
    retval = 1;
 ...

So I think we should default the gdbarch_skip_permanent_breakpoint
hook to advancing the PC by the length of the breakpoint instruction,
as determined by gdbarch_breakpoint_from_pc.  I believe that simple
implementation does the right thing for most architectures.  If
there's an oddball architecture where that doesn't work, then it
should override the hook, just like it should be overriding the hook
if there was no default anyway.

The only two implementation of skip_permanent_breakpoint are
i386_skip_permanent_breakpoint, for x86, and
hppa_skip_permanent_breakpoint, for PA-RISC/HP-UX

The x86 implementation is trivial, and can clearly be replaced by the
new default.

I don't know about the HP-UX one though, I know almost nothing about
PA.  It may well be advancing the PC ends up being equivalent.
Otherwise, it must be that "jump $pc_after_bp" doesn't work either...

Tested on x86_64 Fedora 20 native and gdbserver.

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

* arch-utils.c (default_skip_permanent_breakpoint): New function.
* arch-utils.h (default_skip_permanent_breakpoint): New
declaration.
* gdbarch.sh (skip_permanent_breakpoint): Now an 'f' function.
Install default_skip_permanent_breakpoint as default method.
* i386-tdep.c (i386_skip_permanent_breakpoint): Delete function.
(i386_gdbarch_init): Don't install it.
* infrun.c (resume): Assume there's always a
gdbarch_skip_permanent_breakpoint implementation.
* gdbarch.h, gdbarch.c: Regenerate.

9 years agoThrow away dodgy coff line number info earlier
Alan Modra [Wed, 12 Nov 2014 04:21:38 +0000 (14:51 +1030)] 
Throw away dodgy coff line number info earlier

PR 17521
* coffcode.h (coff_slurp_line_table): Drop line number info
not preceded by a valid function entry.  Revert last change.

9 years agoFix z80-coff build breakage
Alan Modra [Wed, 12 Nov 2014 04:30:01 +0000 (15:00 +1030)] 
Fix z80-coff build breakage

* config/tc-z80.c (parse_exp_not_indexed, parse_exp): Warning fixes.

9 years agoFix x86 non-ELF build breakage
Alan Modra [Wed, 12 Nov 2014 04:24:23 +0000 (14:54 +1030)] 
Fix x86 non-ELF build breakage

PR ld/17482
* config/tc-i386.c (output_insn): Don't test x86_elf_abi when
not ELF.

9 years agodaily update
Alan Modra [Tue, 11 Nov 2014 23:00:56 +0000 (09:30 +1030)] 
daily update

9 years agoFix invalid memory accesses for more corrupt binary files.
Nick Clifton [Tue, 11 Nov 2014 20:50:03 +0000 (20:50 +0000)] 
Fix invalid memory accesses for more corrupt binary files.

PR binutils/17531
* binutils/readelf.c (dynamic_nent): Change type to size_t.
(slurp_rela_relocs): Use size_t type for nrelas.
(slurp_rel_relocs): Likewise.
(get_program_headers): Improve out of memory error message.
(get_32bit_section_headers): Likewise.
(get_32bit_section_headers): Likewise.
(get_64bit_section_headers): Likewise.
(get_32bit_elf_symbols): Likewise.
(get_64bit_elf_symbols): Likewise.
(process_section_groups): Likewise.
(get_32bit_dynamic_section): Likewise.
(get_64bit_dynamic_section): Likewise.
(process_dynamic_section): Likewise.
(process_version_sections): Likewise.
(get_symbol_index_type): Likewise.
(process_mips_specific): Likewise.
(process_corefile_note_segment): Likewise.
(process_version_sections): Use size_t type for total.
(get_dynamic_data): Change type of number parameter to size_t.
Improve out of memory error messages.
(process_symbol_table): Change type of nbuckets and nchains to
size_t.  Skip processing of sections headers if there are none.
Improve out of memory error messages.

9 years ago * avrtiny.sc: Apply avr.sc fixes.
Denis Chertykov [Tue, 11 Nov 2014 17:44:03 +0000 (20:44 +0300)] 
* avrtiny.sc: Apply avr.sc fixes.

9 years agooops - missed the French translation.
Nick Clifton [Tue, 11 Nov 2014 16:57:28 +0000 (16:57 +0000)] 
oops - missed the French translation.

9 years agoUpdated French and Ukranian translations supplied by the Translation Project.
Nick Clifton [Tue, 11 Nov 2014 16:54:22 +0000 (16:54 +0000)] 
Updated French and Ukranian translations supplied by the Translation Project.

* po/uk.po: Updated Ukranian translation.

* po/fr.po: Updated French translation.

9 years ago[PATCH] treate -specs as both cflags & ldflags
Jiong Wang [Tue, 11 Nov 2014 16:41:37 +0000 (16:41 +0000)] 
[PATCH] treate -specs as both cflags & ldflags

  ld/testsuite/
    * lib/ld-lib.exp (run_ld_link_exec_tests): Append board_cflags if gcc driver
    used as link tool.
    (run_cc_link_exec_tests): Likewise.

9 years agoPrevent a buffer overrun whilst displaying corrupt ARM tags.
Nick Clifton [Tue, 11 Nov 2014 16:15:47 +0000 (16:15 +0000)] 
Prevent a buffer overrun whilst displaying corrupt ARM tags.

PR binutils/17531
* readelf.c (display_arm_attribute): Avoid reading off the end of
the buffer when processing a Tag_nodefaults.

9 years agoMore fixes for invalid memory accesses, uncovered by valgrind and binary fuzzers.
Nick Clifton [Tue, 11 Nov 2014 15:34:27 +0000 (15:34 +0000)] 
More fixes for invalid memory accesses, uncovered by valgrind and binary fuzzers.

PR binutils/17512
* coffcode.h (coff_slurp_line_table): Initialise the parts of the
line number cache that would not be initialised by the copy from
the new line number table.
(coff_classify_symbol): Allow for _bfd_coff_internal_syment_name
returning NULL.
* coffgen.c (coff_get_normalized_symbols): Get the external
symbols before allocating space for the internal symbols, in case
the get fails.
* elf.c (_bfd_elf_slurp_version_tables): Only allocate a verref
array if one is needed.  Likewise with the verdef array.
* peXXigen.c (_bfd_XXi_swap_sym_in): Replace abort()'s with error
messages.
(_bfd_XXi_swap_aux_in): Make sure that all fields of the aux
structure are initialised.
(pe_print_edata): Avoid reading off the end of the data buffer.

9 years agoWarn users about mismatched PID namespaces
Daniel Colascione [Tue, 11 Nov 2014 14:18:23 +0000 (14:18 +0000)] 
Warn users about mismatched PID namespaces

Linux supports multiple "PID namespaces".  Processes in different PID
namespaces have different views of the system process list.  Sometimes,
a single process can appear in more than one PID namespace, but with a
different PID in each.  When GDB and its target are in different PID
namespaces, various features can break due to the mismatch between
what the target believes its PID to be and what GDB believes its PID
to be.  The most visible broken functionality is thread enumeration
silently failing.

This patch explicitly warns users against trying to debug across PID
namespaces.

The patch introduced no new failures in my test suite run on an x86_64
installation of Ubuntu 14.10.  It doesn't include a test: writing an
automated test that exercises this code would be very involved because
CLONE_NEWNS requires CAP_SYS_ADMIN; the easier way to reproduce the
problem is to start a new lxc container.

gdb/
2014-11-11  Daniel Colascione  <dancol@dancol.org>

Warn about cross-PID-namespace debugging.
* nat/linux-procfs.h (linux_proc_pid_get_ns): New prototype.
* nat/linux-procfs.c (linux_proc_pid_get_ns): New function.
* linux-thread-db.c (check_pid_namespace_match): New function.
(thread_db_inferior_created): Call it.

9 years agocoff coff
Alan Modra [Tue, 11 Nov 2014 12:12:03 +0000 (22:42 +1030)] 
coff coff

I missed this use of the loop induction variable outside the loop.

PR binutils/17512
* coffcode.h (coff_slurp_line_table): Use updated lineno_count
when building func_table.

9 years agoAvoid coff OOM
Alan Modra [Tue, 11 Nov 2014 11:06:37 +0000 (21:36 +1030)] 
Avoid coff OOM

bfd_zalloc/bfd_zmalloc to fix uninitialized memory reads is too big a
hammer, when the size allocated depends on user input.  A typical
bfd_alloc, bfd_seek, bfd_bread sequence will give an error or warning
at the point the file read fails when some enormous item as described
by headers is not actually present in the file.  Nice operating system
allow memory overcommit.  But not if you write to the memory.  So
bfd_zalloc can cause an OOM, thrashing, or system hangs.

The patch also fixes a recently introduced endless loop on bad input.

PR binutils/17512
* coffcode.h (coff_slurp_line_table): Don't bfd_zalloc, just
memset the particular bits we need.  Update src after hitting loop
"continue".  Don't count lineno omitted due to invalid symbols in
nbr_func, and update lineno_count.  Init entire terminating
lineno.  Don't both allocating terminator in n_lineno_cache.
Redirect sym->lineno pointer to where n_lineno_cache will be
copied, and free n_lineno_cache.
* pe-mips.c (NUM_HOWTOS): Typo fix.

9 years agold -r abort in _bfd_elf_write_section_eh_frame
Alan Modra [Tue, 11 Nov 2014 09:43:03 +0000 (20:13 +1030)] 
ld -r abort in _bfd_elf_write_section_eh_frame

Turning on .eh_frame processing for ld -r resulted in systemtap
tickling a ld bug.  Triggered by the zero terminator not being added
to .eh_frame in a separate file as it usually is (crtend.o), but
instead being present in the last .eh_frame section along with CIEs
and FDEs.  The 4-byte terminator makes the section size check fail
on 64-bit targets.

* elf-eh-frame (_bfd_elf_write_section_eh_frame): Adjust section
size check to account for possible zero terminator.

9 years agosymmisc.c: Remove trailing whitespace.
Doug Evans [Tue, 11 Nov 2014 01:19:57 +0000 (17:19 -0800)] 
symmisc.c: Remove trailing whitespace.

gdb/ChangeLog:

* symmisc.c (print_objfile_statistics): Remove trailing whitespace.
(maintenance_info_symtabs, maintenance_check_symtabs): Ditto.

9 years agosource.c (select_source_symtab): Rewrite to use ALL_SYMTABS.
Doug Evans [Tue, 11 Nov 2014 00:49:44 +0000 (16:49 -0800)] 
source.c (select_source_symtab): Rewrite to use ALL_SYMTABS.

gdb/ChangeLog:

* source.c (select_source_symtab): Rewrite to use ALL_SYMTABS.

9 years agoPR 17564: Fix objfile search order for static symbols.
Doug Evans [Mon, 10 Nov 2014 23:48:49 +0000 (15:48 -0800)] 
PR 17564: Fix objfile search order for static symbols.

When searching static symbols, gdb would search over all
expanded symtabs of all objfiles, and if that fails only then
would it search all partial/gdb_index tables of all objfiles.
This means that the user could get a random instance of the
symbol depending on what symtabs have been previously expanded.
Now the search is consistent, searching each objfile completely
before proceeding to the next one.

gdb/ChangeLog:

PR symtab/17564
* symtab.c (lookup_symbol_in_all_objfiles): Delete.
(lookup_static_symbol): Move definition to new location and rewrite.
(lookup_symbol_in_objfile): New function.
(lookup_symbol_global_iterator_cb): Call it.

gdb/testsuite/ChangeLog:

PR symtab/17564
* gdb.base/symtab-search-order.exp: New file.
* gdb.base/symtab-search-order.c: New file.
* gdb.base/symtab-search-order-1.c: New file.
* gdb.base/symtab-search-order-shlib-1.c: New file.

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

9 years agobfd/
Richard Sandiford [Mon, 10 Nov 2014 20:49:49 +0000 (20:49 +0000)] 
bfd/
2014-11-10  James Cowgill  <James.Cowgill@imgtec.com>

* elfxx-mips.c (_bfd_mips_elf_section_processing): don't force small
data sections to be PROGBITS

9 years agoMore fixes for assertion failures and out-of-bounds reads by readelf.
Nick Clifton [Mon, 10 Nov 2014 16:32:32 +0000 (16:32 +0000)] 
More fixes for assertion failures and out-of-bounds reads by readelf.

PR binutils/17531
* (ia64_process_unwind): Replace assertion with an error message.
Add range checking for group section indicies.
(hppa_process_unwind): Replace assertion with an error message.
(process_syminfo): Likewise.
(decode_arm_unwind_bytecode): Add range checking.
(dump_section_as_strings): Add more string range checking.
(display_tag_value): Likewise.
(display_arm_attribute): Likewise.
(display_gnu_attribute): Likewise.
(display_tic6x_attribute): Likewise.
(display_msp430x_attribute): Likewise.

9 years agoFix objcopy and strip so that they remove their temporary files even if an error...
Nick Clifton [Mon, 10 Nov 2014 14:28:43 +0000 (14:28 +0000)] 
Fix objcopy and strip so that they remove their temporary files even if an error occurs.

PR binutils/17552
* (copy_archive): Clean up temporary files even if an error
occurs.

9 years agoMore fixes for problems exposed by valgrind and the address sanitizer
Nick Clifton [Mon, 10 Nov 2014 14:18:45 +0000 (14:18 +0000)] 
More fixes for problems exposed by valgrind and the address sanitizer
when displaying the contents of corrupt files.

PR binutils/17521
* coff-i386.c (NUM_HOWTOS): New define.
(RTYPE2HOWTO): Use it.
(coff_i386_rtype_to_howto): Likewise.
(coff_i386_reloc_name_lookup): Likewise.
(CALC_ADDEND): Check that reloc r_type field is valid.
* coff-x86_64.c (NUM_HOWTOS): New define.
(RTYPE2HOWTO): Use it.
(coff_amd64_rtype_to_howto): Likewise.
(coff_amd64_reloc_name_lookup): Likewise.
(CALC_ADDEND): Check that reloc r_type field is valid.
* coffcode.h (coff_slurp_line_table): Check for symbol table
indexing underflow.
(coff_slurp_symbol_table): Use zalloc to ensure that all table
entries are initialised.
* coffgen.c (_bfd_coff_read_string_table): Initialise unused bits
in the string table.  Also ensure that the table is 0 terminated.
(coff_get_normalized_symtab): Check for symbol table indexing
underflow.
* opncls.c (bfd_alloc): Catch the case where a small negative size
can result in only 1 byte being allocated.
(bfd_alloc2): Use bfd_alloc.
* pe-mips.c (NUM_HOWTOS): New define.
(coff_mips_reloc_name_lookup): Use it.
(CALC_ADDEND): Check that reloc r_type field is valid.
* peXXigen.c (_bfd_XXi_swap_aouthdr_in): Initialise unused entries
in the DataDirectory.
(pe_print_idata): Avoid reading beyond the end of the data block
wen printing strings.
(pe_print_edata): Likewise.
Check for table indexing underflow.
* peicode.h (pe_mkobject): Initialise the pe_opthdr field.
(pe_bfd_object_p): Allocate and initialize enough space to hold a
PEAOUTHDR, even if the opt_hdr field specified less.

9 years agoWork around GCC bug 63748
Ulrich Weigand [Mon, 10 Nov 2014 14:11:44 +0000 (15:11 +0100)] 
Work around GCC bug 63748

A recent change to eval.c triggered a GCC bug that causes a false positive
"may be used uninitialized" warning in evaluate_subexp_standard.  This seems
to be triggered by a specific CFG constructed via setjmp and gotos.

While the GCC bug is in the process of being fixed, there are released
compiler versions (in particular GCC 4.9) in the field that show this
problem.  In order to allow compiling GDB with one of those compilers,
this commit slightly reworks the CFG (in an equivalent way) of the
affected function, so that the GCC bug is no longer triggered.

gdb/ChangeLog:

* eval.c (evaluate_subexp_standard): Work around GCC bug 63748.

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

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

10 years agoCorrect buffer overrun test
Alan Modra [Sat, 8 Nov 2014 01:42:08 +0000 (12:12 +1030)] 
Correct buffer overrun test

* peXXigen.c (pe_print_idata): Revert last patch, cast lhs instead.

10 years agoFix a typo in gas/ChangeLog
H.J. Lu [Sat, 8 Nov 2014 01:47:54 +0000 (17:47 -0800)] 
Fix a typo in gas/ChangeLog

10 years agoFix race condition when using --threads with linker plugins.
Evgeniy Dushistov [Sat, 8 Nov 2014 00:12:58 +0000 (16:12 -0800)] 
Fix race condition when using --threads with linker plugins.

2014-11-06  Evgeniy Dushistov  <dushistov@mail.ru>

gold/
* plugin.cc: use lock to searialize calls of Plugin_manager::claim_file
* plugin.h: add lock definition

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

10 years agoCast time value to unsigned long to print
H.J. Lu [Fri, 7 Nov 2014 21:41:02 +0000 (13:41 -0800)] 
Cast time value to unsigned long to print

* readelf.c (process_dynamic_section): Cast time value to unsigned
long to print.

10 years agoCast to unsigned long in range checks
H.J. Lu [Fri, 7 Nov 2014 21:39:15 +0000 (13:39 -0800)] 
Cast to unsigned long in range checks

* peXXigen.c (pe_print_idata): Cast to unsigned long in range
checks.

10 years agoX32: Add REX prefix to encode R_X86_64_GOTTPOFF
H.J. Lu [Fri, 7 Nov 2014 20:22:53 +0000 (12:22 -0800)] 
X32: Add REX prefix to encode R_X86_64_GOTTPOFF

Structions with R_X86_64_GOTTPOFF relocation must be encoded with REX
prefix even if it isn't required by destination register.  Otherwise
linker can't safely perform IE -> LE optimization.

bfd/

PR ld/17482
* elf64-x86-64.c (elf_x86_64_relocate_section): Update comments
for IE->LE transition.

gas/

PR ld/17482
* config/tc-i386.c (output_insn): Add a dummy REX_OPCODE prefix
for structions with R_X86_64_GOTTPOFF relocation for x32 if needed.

gas/testsuite/

PR ld/17482
* gas/i386/ilp32/x32-tls.d: New file.
* gas/i386/ilp32/x32-tls.s: Likewise.

ld/testsuite/

PR ld/17482
* ld-x86-64/tlsie4.dd: Updated.

10 years agogdb.base/sigstep.exp: xfail gdb/17511 on i?86 Linux
Pedro Alves [Fri, 7 Nov 2014 15:20:47 +0000 (15:20 +0000)] 
gdb.base/sigstep.exp: xfail gdb/17511 on i?86 Linux

Running gdb.base/sigstep.exp with --target=i686-pc-linux-gnu on a
64-bit kernel naturally trips on PR gdb/17511 as well, given this is a
kernel bug.

I haven't really tested a real 32-bit kernel/machine, but given the
code in question in the kernel is shared between 32-bit and 64-bit,
I'm quite sure the bug triggers in those cases as well.

So, simply xfail i?86-*-linux* too.

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

PR gdb/17511
* gdb.base/sigstep.exp (in_handler_map) <si+advance>: xfail
i?86-*-linux*.

10 years agoRevert old nexti prologue check and eliminate in_prologue
Pedro Alves [Fri, 7 Nov 2014 13:53:01 +0000 (13:53 +0000)] 
Revert old nexti prologue check and eliminate in_prologue

The in_prologue check in the nexti code is obsolete; this commit
removes that, and then removes the in_prologue function as nothing
else uses it.

Looking at the code in GDB that makes use in_prologue, all we find is
this one caller:

      if ((ecs->event_thread->control.step_over_calls == STEP_OVER_NONE)
  || ((ecs->event_thread->control.step_range_end == 1)
      && in_prologue (gdbarch, ecs->event_thread->prev_pc,
      ecs->stop_func_start)))
{
  /* I presume that step_over_calls is only 0 when we're
     supposed to be stepping at the assembly language level
     ("stepi").  Just stop.  */
  /* Also, maybe we just did a "nexti" inside a prolog, so we
     thought it was a subroutine call but it was not.  Stop as
     well.  FENN */
  /* And this works the same backward as frontward.  MVS */
  end_stepping_range (ecs);
  return;
}

This was added by:

 commit 100a02e1deec2f037a15cdf232f026dc79763bf8
 ...
     From Fernando Nasser:
     * infrun.c (handle_inferior_event): Handle "nexti" inside function
     prologues.

The mailing list thread is here:

  https://sourceware.org/ml/gdb-patches/2001-01/msg00047.html

Not much discussion there, and no test, but looking at the code around
what was patched in that revision, we see that the checks that detect
whether the program has just stepped into a subroutine didn't rely on
the unwinders at all back then.

From 'git show 100a02e1:gdb/infrun.c':

    if (stop_pc == ecs->stop_func_start         /* Quick test */
        || (in_prologue (stop_pc, ecs->stop_func_start) &&
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            !IN_SOLIB_RETURN_TRAMPOLINE (stop_pc, ecs->stop_func_name))
        || IN_SOLIB_CALL_TRAMPOLINE (stop_pc, ecs->stop_func_name)
        || ecs->stop_func_name == 0)
      {
        /* It's a subroutine call.  */

        if ((step_over_calls == STEP_OVER_NONE)
            || ((step_range_end == 1)
                && in_prologue (prev_pc, ecs->stop_func_start)))
          {
            /* I presume that step_over_calls is only 0 when we're
               supposed to be stepping at the assembly language level
               ("stepi").  Just stop.  */
            /* Also, maybe we just did a "nexti" inside a prolog,
               so we thought it was a subroutine call but it was not.
               Stop as well.  FENN */
            stop_step = 1;
            print_stop_reason (END_STEPPING_RANGE, 0);
            stop_stepping (ecs);
            return;
          }

Stripping the IN_SOLIB_RETURN_TRAMPOLINE checks for simplicity, we had:

    if (stop_pc == ecs->stop_func_start         /* Quick test */
        || in_prologue (stop_pc, ecs->stop_func_start)
        || ecs->stop_func_name == 0)
      {
        /* It's a subroutine call.  */

That is, detecting a subroutine call was based on prologue detection
back then.  So the in_prologue check in the current tree only made
sense back then as it was undoing a bad decision the in_prologue check
that used to exist above did.

Today, the check for a subroutine call relies on frame ids instead,
which are stable throughout the function.  So we can just remove the
in_prologue check for nexti, and the whole in_prologue function along
with it.

Tested on x86_64 Fedora 20, and also by nexti-ing manually a prologue.

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

* infrun.c (process_event_stop_test) <subroutine check>: Don't
check if we did a "nexti" inside a prologue.
* symtab.c (in_prologue): Delete function.
* symtab.h (in_prologue): Delete declaration.

10 years agoAdd more fixes for inavlid memory accesses triggered by corrupt files.
Nick Clifton [Fri, 7 Nov 2014 13:39:45 +0000 (13:39 +0000)] 
Add more fixes for inavlid memory accesses triggered by corrupt files.

PR binutils/17531
* readelf.c (get_data): Avoid allocating memory when we know that
the read will fail.
(find_section_by_type): New function.
(get_unwind_section_word): Check for invalid symbol indicies.
Check for invalid reloc types.
(get_32bit_dynamic_section): Add range checks.
(get_64bit_dynamic_section): Add range checks.
(process_dynamic_section): Check for a corrupt time value.
(process_symbol_table): Add range checks.
(dump_section_as_strings): Add string length range checks.
(display_tag_value): Likewise.
(display_arm_attribute): Likewise.
(display_gnu_attribute): Likewise.
(display_tic6x_attribute): Likewise.
(display_msp430x_attribute): Likewise.
(process_mips_specific): Add range check.

10 years agotekhex architecure
Alan Modra [Fri, 7 Nov 2014 10:52:02 +0000 (21:22 +1030)] 
tekhex architecure

is a don't care.

* tekhex.c (tekhex_set_arch_mach): Ignore unknown arch errors.

10 years agotekhex buffer management and symbol types
Alan Modra [Fri, 7 Nov 2014 09:59:43 +0000 (20:29 +1030)] 
tekhex buffer management and symbol types

Dramatically reduces memory consumption and processing time for large
all-zero data segments.  Allows multiple symbol types attached to a
given segment to survive objcopy.

* tekhex.c (CHUNK_SPAN): Define.
(struct data_struct <chunk_init>): Use one byte per span, update
all code accessing this field.
(find_chunk): Add create param, don't create new entry unless set.
(insert_byte): Don't save zeros.
(first_phase): Set section SEC_CODE or SEC_DATA flag depending
on symbol type.  Create an alternate section if both types of
symbol are given.  Attach type '2' and '6' symbols to absolute
section.
(move_section_contents): Fix caching of chunk.  Don't create chunk
when reading, or for writing zeros.
(tekhex_set_section_contents): Don't create initial chunks.
(tekhex_write_object_contents): Use CHUNK_SPAN.

10 years agoaoutx.h tidy
Alan Modra [Fri, 7 Nov 2014 09:48:25 +0000 (20:18 +1030)] 
aoutx.h tidy

Save a multiplication, and any concern that the buffer allocation
might be smaller than the amount read (as it could be if the header
size isn't a multiple of EXTERNAL_NLIST_SIZE).

* aoutx.h (aout_get_external_symbols): Tidy allocation of symbol buffer.

10 years agosymtab.h (lookup_global_symbol): Improve function comment.
Doug Evans [Fri, 7 Nov 2014 07:51:21 +0000 (23:51 -0800)] 
symtab.h (lookup_global_symbol): Improve function comment.

gdb/ChangeLog:

* symtab.h (lookup_global_symbol): Improve function comment.

10 years agoRename lookup_symbol_global to lookup_global_symbol.
Doug Evans [Fri, 7 Nov 2014 07:48:18 +0000 (23:48 -0800)] 
Rename lookup_symbol_global to lookup_global_symbol.

gdb/ChangeLog:

* symtab.c (lookup_global_symbol): Renamed from lookup_symbol_global.
All callers updated.
* symtab.h (lookup_global_symbol): Update decl.
(lookup_static_symbol): Move decl to better location.

10 years agosymtab.c (basic_lookup_symbol_nonlocal): Add comment.
Doug Evans [Fri, 7 Nov 2014 07:34:28 +0000 (23:34 -0800)] 
symtab.c (basic_lookup_symbol_nonlocal): Add comment.

gdb/ChangeLog:

* symtab.c (basic_lookup_symbol_nonlocal): Add comment.

10 years agoRename some "aux" functions.
Doug Evans [Fri, 7 Nov 2014 07:29:49 +0000 (23:29 -0800)] 
Rename some "aux" functions.

"aux" doesn't contribute anything to the name, and it makes the
reader wonder what it's supposed to mean.

gdb/ChangeLog:

* symtab.c (lookup_local_symbol): Renamed from lookup_symbol_aux_local.
All callers updated.
(lookup_symbol_in_all_objfiles): Renamed from
lookup_symbol_aux_symtabs.  All callers updated.
(lookup_symbol_via_quick_fns): Renamed from lookup_symbol_aux_quick.
All callers updated.
(lookup_symbol_in_objfile_symtabs): Renamed from
lookup_symbol_aux_objfile.  All callers updated.

10 years agolookup_symbol_in_block: Renamed from lookup_symbol_aux_block.
Doug Evans [Fri, 7 Nov 2014 07:04:15 +0000 (23:04 -0800)] 
lookup_symbol_in_block: Renamed from lookup_symbol_aux_block.

gdb/ChangeLog:

* symtab.c (lookup_symbol_in_block): Renamed from
lookup_symbol_aux_block.  All callers updated.

10 years agoRename lookup_symbol_static to lookup_symbol_in_static_block,
Doug Evans [Fri, 7 Nov 2014 06:56:46 +0000 (22:56 -0800)] 
Rename lookup_symbol_static to lookup_symbol_in_static_block,
and lookup_static_symbol_aux to lookup_static_symbol.

gdb/ChangeLog:

* symtab.c (lookup_static_symbol): Renamed from
lookup_static_symbol_aux.  All callers updated.
(lookup_symbol_in_static_block): Renamed from lookup_symbol_static.
All callers updated.

10 years agoNew macro ALL_BLOCK_SYMBOLS_WITH_NAME.
Doug Evans [Fri, 7 Nov 2014 06:50:12 +0000 (22:50 -0800)] 
New macro ALL_BLOCK_SYMBOLS_WITH_NAME.

gdb/ChangeLog:

* block.h (ALL_BLOCK_SYMBOLS_WITH_NAME): New macro.
* block.c (block_lookup_symbol): Use it.
* cp-support.c (make_symbol_overload_list_block): Use it.
* symtab.c (iterate_over_symbols): Use it.

10 years agoMove lookup_block_symbol to block.c, rename to block_lookup_symbol.
Doug Evans [Fri, 7 Nov 2014 06:32:25 +0000 (22:32 -0800)] 
Move lookup_block_symbol to block.c, rename to block_lookup_symbol.

There is another function, lookup_symbol_aux_block, and
the names lookup_block_symbol and lookup_symbol_aux_block don't
convey any real difference between them.

The difference is that lookup_block_symbol lives in the lower level
block API, and lookup_symbol_aux_block lives in the higher level symtab API.
This patch makes this distinction clear.

gdb/ChangeLog:

* symtab.c (lookup_block_symbol): Moved to ...
* block.c (block_lookup_symbol):  ... here and renamed.
All callers updated.
* block.h (block_lookup_symbol): Declare.
* symtab.h (lookup_block_symbol): Delete.

10 years agoRevert bfd_get_size checks
Alan Modra [Thu, 6 Nov 2014 23:07:39 +0000 (09:37 +1030)] 
Revert bfd_get_size checks

* archive.c (_bfd_slurp_extended_name_table): Revert bfd_get_size check.
* coffcode.h (coff_set_alignment_hook): Likewise.
(coff_slurp_line_table): Likewise.
* coffgen.c (coff_get_normalized_symtab): Likewise.
(_bfd_coff_get_external_symbols): Likewise.
* elf.c (bfd_elf_get_str_section): Likewise.
* tekhex.c (first_phase): Likewise.

10 years agoUse ALL_PRIMARY_SYMTABS instead of ALL_SYMTABS in some places.
Doug Evans [Fri, 7 Nov 2014 01:27:55 +0000 (17:27 -0800)] 
Use ALL_PRIMARY_SYMTABS instead of ALL_SYMTABS in some places.

Non-primary symtabs share the block vector with their primary symtabs.
In these cases there's no need to use ALL_SYMTABS.

gdb/ChangeLog:

* ada-lang.c (ada_make_symbol_completion_list): Use
ALL_PRIMARY_SYMTABS instead of ALL_SYMTABS.
* symtab.c (lookup_objfile_from_block): Ditto.

10 years agoForgotten ChangeLog entry for previous commit.
Doug Evans [Fri, 7 Nov 2014 01:24:12 +0000 (17:24 -0800)] 
Forgotten ChangeLog entry for previous commit.

gdb/ChangeLog:

* gdbtypes.h (TYPE_CODE_CLASS): Delete.  All uses changed to use
TYPE_CODE_STRUCT.

10 years agoDelete TYPE_CODE_CLASS, it's just an alias of TYPE_CODE_STRUCT.
Doug Evans [Fri, 7 Nov 2014 01:19:06 +0000 (17:19 -0800)] 
Delete TYPE_CODE_CLASS, it's just an alias of TYPE_CODE_STRUCT.

gdb/ChangeLog:

* gdbtypes.h (TYPE_CODE_CLASS): Delete.  All uses changed to use
TYPE_CODE_STRUCT.

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