Commit Graph

97408 Commits

Author SHA1 Message Date
Tom Tromey
ca1df23907 Fix build problem in fputs_maybe_filtered
When merging commit 99f20f ("Fix style bug when paging") to master, I
had to make some changes to get it to compile again.  Unfortunately, I
must not have added these to the index at the correct time, because
they were not committed.

This patch fixes the problem.

gdb/ChangeLog
2019-05-08  Tom Tromey  <tromey@adacore.com>

	* utils.c (fputs_maybe_filtered): Call can_emit_style_escape as a
	method.
2019-05-08 10:35:09 -06:00
Tom Tromey
99f20f0868 Fix style bug when paging
Philippe pointed out a styling bug that would occur in some conditions
when paging:

    https://sourceware.org/ml/gdb-patches/2019-04/msg00101.html

I was finally able to reproduce this, and this patch fixes the bug.

The problem occurred when text overflowed the line, causing a
pagination prompt, but when no wrap column had been set.  In this
case, the current style was reset to show the prompt, but then not
reset back to the previously applied style before emitting the rest of
the line.

The fix is to record the applied style in this case, and re-apply it
afterward -- but only if the pager prompt was emitted, something that
the existing style.exp pointed out on the first, more naive, version
of the patch.

Tested on x86-64 Fedora 29.

gdb/ChangeLog
2019-05-08  Tom Tromey  <tromey@adacore.com>

	* utils.c (fputs_maybe_filtered): Reset style after paging, even
	when no wrap column is set.
2019-05-08 10:32:09 -06:00
Tom Tromey
80e55b1329 Correctly handle non-C-style arrays in c_get_string
A user here noticed that the Python Value.string method did not work
for Ada arrays.  I tracked this down to an oddity in value_as_address
-- namely, it calls coerce_array, but that function will not force
array coercion when the language has c_style_arrays=false, as Ada
does.

This patch fixes the problem by changing c_get_string so that arrays
take the "in GDB's memory" branch.  The actual patch is somewhat more
complicated than you might think, because the caller can request more
array elements than the type allows.  This is normal when the type is
using the C struct hack.

Tested on x86-64 Fedora 29.

gdb/ChangeLog
2019-05-08  Tom Tromey  <tromey@adacore.com>

	* c-lang.c (c_get_string): Handle non-C-style arrays.

gdb/testsuite/ChangeLog
2019-05-08  Tom Tromey  <tromey@adacore.com>

	* gdb.python/py-value.exp (test_value_in_inferior): Add Ada test.
2019-05-08 10:20:06 -06:00
Tom Tromey
9d3421afbb Change ptype/o to print bit offset
Consider this short C example:

    struct inner
    {
      unsigned x;
      unsigned y : 3;
      unsigned z : 3;
    };

    struct outer
    {
      unsigned char o : 3;
      struct inner i __attribute__ ((packed));
    };

When I use "ptype/o" on this, I get:

    (gdb) ptype/o struct outer
    /* offset    |  size */  type = struct outer {
    /*    0: 5   |     1 */    unsigned char o : 3;
    /* XXX  5-bit hole  */
    /*    1      |     8 */    struct inner {
    /*    1      |     4 */        unsigned int x;
    /*    5:29   |     4 */        unsigned int y : 3;
    /*    5:26   |     4 */        unsigned int z : 3;
    /* XXX  2-bit padding  */
    /* XXX  3-byte padding */

				   /* total size (bytes):    8 */
			       } i;

			       /* total size (bytes):    9 */
			     }

In the location of "o" ("0: 5"), the "5" means "there are 5 bits left
relative to the size of the underlying type.

I find this very difficult to follow.  On irc, Sergio said that this
choice came because it is what pahole does.  However, I think it's not
very useful, and maybe is just an artifact of the way that
DW_AT_bit_offset was defined in DWARF 3.

This patch changes ptype/o to print the offset of a bitfield in a more
natural way, that is, using the bit number according to the platform's
bit numbering.

With this patch, the output is now:

    (gdb) ptype/o struct outer
    /* offset    |  size */  type = struct outer {
    /*    0: 0   |     1 */    unsigned char o : 3;
    /* XXX  5-bit hole  */
    /*    1      |     8 */    struct inner {
    /*    1      |     4 */        unsigned int x;
    /*    5: 0   |     4 */        unsigned int y : 3;
    /*    5: 3   |     4 */        unsigned int z : 3;
    /* XXX  2-bit padding  */
    /* XXX  3-byte padding */

				   /* total size (bytes):    8 */
			       } i;

			       /* total size (bytes):    9 */
			     }

This is better, IMO, because now the "offset" of a bitfield is
consistent with the offset of an ordinary member, referring to its
offset from the start of the structure.

gdb/ChangeLog
2019-05-08  Tom Tromey  <tromey@adacore.com>

	* typeprint.c (print_offset_data::update): Print the bit offset,
	not the number of bits remaining.

gdb/doc/ChangeLog
2019-05-08  Tom Tromey  <tromey@adacore.com>

	* gdb.texinfo (Symbols): Document change to ptype/o.

gdb/testsuite/ChangeLog
2019-05-08  Tom Tromey  <tromey@adacore.com>

	* gdb.base/ptype-offsets.exp: Update tests.
2019-05-08 10:15:51 -06:00
Tom Tromey
844333e249 Fix ptype/o comment formatting
I noticed that ptype/o will print:

    /*    3: 3   |     1 */    signed char a4 : 2;
    /* XXX  3-bit hole  */

That is, "*/" at the end of the "hole" message does not line up with
the other comment ends.  I thought it would be a bit nicer if this did
line up, so I fixed it.  Then, to my surprise, I found that I could
not make ptype-offsets.exp fail.

I still am not sure why it doesn't fail, but changing the tests to use
string_to_regexp and changing the quoting helped.  This in turn showed
that some of the existing test cases were wrong, so I've also updated
them here.

gdb/ChangeLog
2019-05-08  Tom Tromey  <tromey@adacore.com>

	* typeprint.c (print_offset_data::maybe_print_hole): Add extra
	padding at end of comment.

gdb/testsuite/ChangeLog
2019-05-08  Tom Tromey  <tromey@adacore.com>

	* gdb.base/ptype-offsets.exp: Use string_to_regexp.  Fix test
	cases.
	* gdb.base/ptype-offsets.cc (struct abc) <my_int_type>: Now
	"short".
2019-05-08 10:15:51 -06:00
Tom Tromey
988915ee7b Fix VLA printing for Ada
While looking at a different Ada problem, I found that printing a
record containing a VLA did not work properly.

I tracked the problem down to dwarf2_evaluate_property trying, and
failing, to compare two types that differed only in qualifiers.

This patch changes dwarf2_evaluate_property to ignore qualifiers when
comparing types.

Tested on x86-64 Fedora 29.

gdb/ChangeLog
2019-05-08  Tom Tromey  <tromey@adacore.com>

	* dwarf2loc.c (dwarf2_evaluate_property) <PROP_ADDR_OFFSET>:
	Compare main types.

gdb/testsuite/ChangeLog
2019-05-08  Tom Tromey  <tromey@adacore.com>

	* gdb.ada/vla.exp: New file.
	* gdb.ada/vla/vla.adb: New file.
2019-05-08 10:12:37 -06:00
Faraz Shahbazker
2379f9c475 Sign-extend start and stop address inputs to objdump
For targets that treat addresses as signed (MIPS/SH64), user-specified
start/stop address limits cannot be compared directly to section VMAs.
We must sign-extend user-specified 32-bit address limits which have
bit 31 set for such targets.

binutils/
	* objdump.c (sign_extend_address): New function.
	(dump_bfd): Sign-extend user-specified start/stop addresses
	for targets that need it.
	* testsuite/binutils-all/objdump.exp: Add tests for objdump
	with start and stop addresses in higher address ranges.
2019-05-08 09:07:35 -07:00
Pekka Sepp?nen
46752c37b0 Fix compile time warning when building the linker in a MinGw32 environment using gcc 8.
PR 24536
	* ldbuildid.c (generate_build_id): Cast return value from
	GetProcAddress in order to avoid a compile time warning.
2019-05-08 16:54:16 +01:00
Nick Clifton
79299211a1 Do not force the m68k-elf linker to fail if it encoutners a non-ELF format file.
PR 24523
	* elf32-m68k.c (elf32_m68k_merge_private_bfd_data): Return TRUE
	rather than FALSE if encountering a non-ELF file.
2019-05-08 14:51:32 +01:00
Alan Modra
762172a4dc gas/elf dwarf2 tests
Make them work for tile, by using ".quad 0" as the simulated
instruction and doubling size of aligns.  The larger aligns tripped
over riscv alignment handling, fixed by adding -mno-relax there.
Also disable link-relax for avr, pru and xtensa, allowing these
targets to pass these tests.  With link-time relaxation enabled,
these targets emit alignment relocations rather than aligning at
assembly time.  This means the assembler doesn't see a change in PC
when it is expected over an alignment frag and thus view numbers are
calculated incorrectly.

	* testsuite/gas/elf/dwarf2-1.s,
	* testsuite/gas/elf/dwarf2-2.s,
	* testsuite/gas/elf/dwarf2-5.s,
	* testsuite/gas/elf/dwarf2-7.s,
	* testsuite/gas/elf/dwarf2-8.s,
	* testsuite/gas/elf/dwarf2-9.s,
	* testsuite/gas/elf/dwarf2-10.s,
	* testsuite/gas/elf/dwarf2-11.s,
	* testsuite/gas/elf/dwarf2-12.s,
	* testsuite/gas/elf/dwarf2-13.s,
	* testsuite/gas/elf/dwarf2-14.s,
	* testsuite/gas/elf/dwarf2-15.s,
	* testsuite/gas/elf/dwarf2-16.s,
	* testsuite/gas/elf/dwarf2-17.s,
	* testsuite/gas/elf/dwarf2-18.s,
	* testsuite/gas/elf/dwarf2-19.s: Double size of align and simulated
	instructions.
	* testsuite/gas/elf/dwarf2-1.d,
	* testsuite/gas/elf/dwarf2-2.d,
	* testsuite/gas/elf/dwarf2-5.d,
	* testsuite/gas/elf/dwarf2-7.d,
	* testsuite/gas/elf/dwarf2-8.d,
	* testsuite/gas/elf/dwarf2-9.d,
	* testsuite/gas/elf/dwarf2-10.d,
	* testsuite/gas/elf/dwarf2-11.d,
	* testsuite/gas/elf/dwarf2-12.d,
	* testsuite/gas/elf/dwarf2-13.d,
	* testsuite/gas/elf/dwarf2-14.d,
	* testsuite/gas/elf/dwarf2-15.d,
	* testsuite/gas/elf/dwarf2-16.d,
	* testsuite/gas/elf/dwarf2-17.d,
	* testsuite/gas/elf/dwarf2-18.d,
	* testsuite/gas/elf/dwarf2-19.d: Use xfail rather than notarget.
	Remove avr, pru, tile, xtensa from xfails.  Update expected output.
	* testsuite/gas/elf/elf.exp: Sort targets.
	(dump_opts): Pass {as -mno-relax} for riscv, {as -mno-link-relax}
	for avr and pru, and {as --no-link-relax} for xtensa to dwarf tests.
	* testsuite/gas/elf/section2.e-miwmmxt: Delete unused file.
2019-05-08 09:40:08 +09:30
Alan Modra
9632a526ca xtensa ignores option --no-link-relax
md_begin happens after md_parse_option.

	* config/tc-xtensa.c (opt_linkrelax): New variable.
	(md_parse_option): Set it here.
	(md_begin): Copy opt_linkrelax to linkrelax.
2019-05-08 09:40:08 +09:30
Alan Modra
9420801e57 PR24520, gprof fails to read compressed debug data
PR 24520
	* corefile.c (core_init): Set BFD_DECOMPRESS.
2019-05-08 09:40:07 +09:30
GDB Administrator
c91f298b52 Automatic date update in version.in 2019-05-08 00:00:21 +00:00
Alexandre Oliva
b654832d0d xfail locview tests on mep that use complex relocs for view numbers
Expressions that compute view numbers that aren't simplified early
enough to a constant end up being selected for representation as
complex relocations, enabled on mep-* targets.

It would be possible to recognize such expressions, that can resolve
to constants, but this problem was hit before, in preexisting tests,
so xfail the new hits similarly.

The new hits were caused by yesterday's patch to dwarf2dbg.c: views in
the beginning of subsections are now computed later, based on the
final views or previous subsections in the same section.

for  gas/ChangeLog

	* testsuite/gas/elf/dwarf2-18.d: Xfail mep-*.
	* testsuite/gas/elf/dwarf2-19.d: Likewise.
2019-05-07 16:34:19 -03:00
Tom de Vries
7bd55dac80 [gdb/testsuite] Fix ls_host return in index-cache.exp
When adding a debug print here in index-cache.exp:
...
 proc_with_prefix test_cache_disabled { cache_dir } {
     lassign [ls_host $cache_dir] ret files_before
+    puts "before: '$files_before'"
+    exit
...
we have:
...
files_before: ''
...

When further adding:
...
 proc_with_prefix test_cache_disabled { cache_dir } {
+    exec touch $cache_dir/foo.1 $cache_dir/foo.2 $cache_dir/foo.3
...
we have:
...
files_before: 'foo.1'
...
while we're expecting file_before to contain foo.[123].

Fix this by making the return statement in ls_host return a list rather than a
string (in accordance with the ls_host documentation), after which we have:
...
files_before: 'foo.1 foo.2 foo.3'
...

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-05-07  Tom de Vries  <tdevries@suse.de>

	* gdb.base/index-cache.exp (ls_host): Fix return statement.
2019-05-07 11:52:17 +02:00
Tom de Vries
75f06e9dc5 [gdb/testsuite] Fix .debug_aranges in watch-loc.c
When running gdb.dlang/watch-loc.exp with target board cc-with-debug-names, we
run into:
...
FAIL: gdb.dlang/watch-loc.exp: disassemble _Dmain (GDB internal error)
...
in more detail:
...
(gdb) disassemble _Dmain
gdb/dwarf2read.c:5293: internal-error: \
  compunit_symtab* dw2_find_pc_sect_compunit_symtab(objfile*, \
  bound_minimal_symbol, CORE_ADDR, obj_section*, int): \
  Assertion `result != NULL' failed.
...

The problem is that the .debug_aranges section in watch-loc.c contains a
debug_info_offset which is set to 0:
...
asm (
  "      .pushsection    .debug_aranges,\"\",%progbits\n"
  "      .4byte  .Laranges_end - .Laranges_start\n"
  ".Laranges_start:\n"
  "      .2byte  0x2\n"
  "      .4byte  0\n"
...
while the compilation unit at offset 0 in the .debug_section in the executable
is in fact not the compilation unit generated from watch-loc-dw.S.

[ Note: this is a non-trivial test-case.  The file watch-loc-dw.S contains a
.debug_info section, but not an .debug_aranges section or any actual code.
The file watch-loc.c contains code and a .debug_aranges section, but no other
debug section.  So, the intent for the .debug_aranges section in watch-loc.c
is to refer to a compilation unit in the .debug_info section in
watch-loc-dw.S. ]

This happens when linked in object files contain dwarf info and are placed in
the .debug_info section before the compilation units generated from
watch-loc.c and watch-loc-dw.S.

Fix this by defining the debug_info_offset field using a label .Lcu1_begin
that defines the start of an empty .debug_section compilation unit:
...
 asm (
+  "      .pushsection    .debug_info,\"\",%progbits\n"
+  ".Lcu1_begin:"
+  "      .popsection\n"
   "      .pushsection    .debug_aranges,\"\",%progbits\n"
   "      .4byte  .Laranges_end - .Laranges_start \n"
   ".Laranges_start:\n"
   "      .2byte  0x2\n"
-  "      .4byte  0\n"
+  "      .4byte  .Lcu1_begin\n"
...
which during linking merges with the start of the .debug_info section of
watch-loc-dw.S.

Tested on x86_64-linux with native, cc-with-gdb-index and cc-with-debug-names.

gdb/testsuite/ChangeLog:

2019-05-07  Tom de Vries  <tdevries@suse.de>

	PR testsuite/24522
	* gdb.dlang/watch-loc.c: Fix debug_info_offset in .debug_aranges
	section.
2019-05-07 10:58:57 +02:00
Tom de Vries
77e7aaa4bd [gdb/testsuite] Fix .debug_aranges in dw2-case-insensitive-debug.S
When running gdb.dwarf2/dw2-case-insensitive.exp with target board
cc-with-debug-names, we run into:
...
FAIL: gdb.dwarf2/dw2-case-insensitive.exp: regexp case-sensitive off \
  (GDB internal error)
...
in more detail:
...
(gdb) info functions fUnC_lang
gdb/dwarf2read.c:5293: internal-error: \
  compunit_symtab* dw2_find_pc_sect_compunit_symtab(objfile*, \
  bound_minimal_symbol, CORE_ADDR, obj_section*, int): \
  Assertion `result != NULL' failed.
...

The problem is that the .debug_aranges section in dw2-case-insensitive-debug.S
contains a debug_info_offset which is set to 0:
...
        .section        .debug_aranges,"",@progbits
        .4byte  .Laranges_end - .Laranges_start
.Laranges_start:
        .2byte  0x2
        .4byte  0
...
while the compilation unit at offset 0 in the .debug_section of the executable
is in fact not the compilation unit generated from
dw2-case-insensitive-debug.S.

This happens when linked in object files contain dwarf info and are placed in
the .debug_info section before the compilation unit generated from
dw2-case-insensitive-debug.S.

Fix this by defining the debug_info_offset field using the label .Lcu1_begin
that defines the start of the compilation unit:
...
-       .4byte  0
+       .4byte  .Lcu1_begin
...

Tested on x86_64-linux with native, cc-with-gdb-index and cc-with-debug-names.

gdb/testsuite/ChangeLog:

2019-05-07  Tom de Vries  <tdevries@suse.de>

	PR testsuite/24522
	* gdb.dwarf2/dw2-case-insensitive-debug.S: Fix debug_info_offset in
	.debug_aranges section.
2019-05-07 10:58:57 +02:00
Tom de Vries
456ba0fa36 [gdb/testsuite] Fix handling of DW_FORM_ref_addr in dwarf assembler
When running gdb.dwarf2/multidictionary.exp with target board cc-with-dwz and
current dwz, we run into a dwz abort:
...
gdb compile failed, gdb/contrib/cc-with-tweaks.sh: line 188: 11484 Aborted \
  (core dumped) $DWZ "$output_file" > /dev/null 2>&1
UNTESTED: gdb.dwarf2/multidictionary.exp: multidictionary.exp
...
The dwz abort (PR dwz/24169) is caused by an invalid DW_FORM_ref_addr in the
multidictionary binary.

The multidictionary binary is build from multidictionary.S which is generated
using the dwarf assembler, and multidictionary.S contains dwarf for 3
compilation units.

In multidictionary0.o (generated from multidictionary.S), we find a concrete
formal parameter DIE:
...
 <2><dc>: Abbrev Number: 4 (DW_TAG_formal_parameter)
    <dd>   DW_AT_abstract_origin: <0xa6>
...
referring to an abstract formal parameter DIE at 0xa6:
...
 <2><a6>: Abbrev Number: 8 (DW_TAG_formal_parameter)
    <a7>   DW_AT_name        : msg
    <ab>   DW_AT_type        : <0x92>
...
but in the multidictionary binary the concrete formal parameter DIE is still
referring to 0xa6:
...
 <2><1a3>: Abbrev Number: 4 (DW_TAG_formal_parameter)
    <1a4>   DW_AT_abstract_origin: <0xa6>
...
while the abstract formal parameter DIE has moved to 0x16d:
...
 <2><16d>: Abbrev Number: 8 (DW_TAG_formal_parameter)
    <16e>   DW_AT_name        : msg
    <172>   DW_AT_type        : <0x159>
...

The concrete formal parameter DIE is specified in multidictionary.S like this:
...
.Llabel21:
        .uleb128        4
        .4byte        .Llabel17 - .Lcu1_begin
...

The problem is that the .Lcu1_begin label is assumed to mark the start of the
.debug_info section in the executable, but in fact it marks the start of the
first compilation unit from multidictionary.S in the executable.  Usually
these two entities are the same, but they are not when linked in object files
contain dwarf info and are placed in the .debug_info section before the
compilation units generated from multidictionary.S.

Fix this in the dwarf assembler by generating instead the label itself:
...
.Llabel21:
        .uleb128        4
        .4byte        .Llabel17
...
resulting in a relocation in the object file:
...
  Offset          Info           Type           Sym. Value    Sym. Name + Addend
0000000000dd  00040000000a R_X86_64_32       0000000000000000 .debug_info + a6
...
and resulting in the correct offset in the executable:
...
 <2><1a3>: Abbrev Number: 4 (DW_TAG_formal_parameter)
    <1a4>   DW_AT_abstract_origin: <0x16d>
...

Tested on x86_64-linux with native and cc-with-dwz.

gdb/testsuite/ChangeLog:

2019-05-07  Tom de Vries  <tdevries@suse.de>

	PR testsuite/24159
	* lib/dwarf.exp: Fix handling of DW_FORM_ref_addr.
2019-05-07 10:38:36 +02:00
Alan Modra
0f1309c8f7 Tidy use_complex_relocs_for
Since I was looking at this I decided to fix the formatting, and
used an old C switch statements trick to factor out common code.

	* symbols.c (use_complex_relocs_for): Formatting.  Factor out
	X_add_symbol tests.
2019-05-07 15:35:53 +09:30
Tom Tromey
26bfd82367 Fix scoped_mmap includes
I noticed that scoped_mmap.h included config.h, and that scoped_mmap.c
included defs.h.  This patch fixes both of these problems.

Tested by the buildbot.

gdb/ChangeLog
2019-05-06  Tom Tromey  <tom@tromey.com>

	* common/scoped_mmap.c: Include common-defs.h.
	* common/scoped_mmap.h: Don't include config.h.
2019-05-06 21:00:52 -06:00
GDB Administrator
c0a57f1536 Automatic date update in version.in 2019-05-07 00:00:24 +00:00
Kevin Buettner
e90a813d96 Fix regression caused by recently added syscall restart code
This line of code...

       *(int64_t *) ptr = *(int32_t *) ptr;

...in linux-x86-low.c is not needed (and does not work correctly)
within a 32-bit executable.  I added an __x86_64__ ifdef (which is
used extensively elsewhere in the file for like purposes) to prevent
this code from being included in 32-bit builds.

It fixes the following regressions when running on native
i686-pc-linux-gnu:

FAIL: gdb.server/abspath.exp: continue to main
FAIL: gdb.server/connect-without-multi-process.exp: multiprocess=auto: continue to main
FAIL: gdb.server/connect-without-multi-process.exp: multiprocess=off: continue to main
FAIL: gdb.server/ext-restart.exp: restart: run to main
FAIL: gdb.server/ext-restart.exp: run to main
FAIL: gdb.server/ext-run.exp: continue to main
FAIL: gdb.server/ext-wrapper.exp: print d
FAIL: gdb.server/ext-wrapper.exp: restart: print d
FAIL: gdb.server/ext-wrapper.exp: restart: run to marker
FAIL: gdb.server/ext-wrapper.exp: run to marker
FAIL: gdb.server/no-thread-db.exp: continue to breakpoint: after tls assignment
FAIL: gdb.server/reconnect-ctrl-c.exp: first: stop with control-c
FAIL: gdb.server/reconnect-ctrl-c.exp: second: stop with control-c
FAIL: gdb.server/run-without-local-binary.exp: run test program until the end
FAIL: gdb.server/server-kill.exp: continue to breakpoint: after server_pid assignment
FAIL: gdb.server/server-kill.exp: tstatus
FAIL: gdb.server/server-run.exp: continue to main

gdb/gdbserver/ChangeLog:

	* linux-x86-low.c (x86_fill_gregset): Don't compile 64-bit
	sign extension code on 32-bit builds.
2019-05-06 11:00:48 -07:00
Faraz Shahbazker
41cee0897b Add load-link, store-conditional paired EVA instructions
Add paired load-link and store-conditional instructions to the
EVA ASE for MIPS32R6[1].  These instructions are optional within
the EVA ASE.  Their presence is indicated by the XNP bit in the
Config5 register.

[1] "MIPS Architecture for Programmers Volume II-A: The MIPS32
     Instruction Set Manual", Imagination Technologies Ltd., Document
     Number: MD00086, Revision 6.06, December 15, 2016, Section 3.2
     "Alphabetical List of Instructions", pp. 230-231, pp. 357-360.

gas/
	* config/tc-mips.c (mips_set_ase): Handle ASE_EVA_R6.
	(macro) <M_LLWPE_AB, M_SCWPE_AB>: New cases.
	(mips_after_parse_args): Translate EVA to EVA_R6.
	* testsuite/gas/mips/ase-errors-1.s: Add new instructions.
	* testsuite/gas/mips/eva.s: Likewise.
	* testsuite/gas/mips/ase-errors-1.l: Check errors for
	 new instructions.
	* testsuite/gas/mips/mipsr6@eva.d: Check new test cases.

include/
	* opcode/mips.h (ASE_EVA_R6): New macro.
	(M_LLWPE_AB, M_SCWPE_AB): New enum values.

opcodes/
	* mips-dis.c (mips_calculate_combination_ases): Add ISA
	argument and set ASE_EVA_R6 appropriately.
	(set_default_mips_dis_options): Pass ISA to above.
	(parse_mips_dis_option): Likewise.
	* mips-opc.c (EVAR6): New macro.
	(mips_builtin_opcodes): Add llwpe, scwpe.

Derived from patch authored by Andrew Bennett <andrew.bennett@imgtec.com>
2019-05-06 06:43:32 -07:00
Alan Modra
be0d3bbbcd sym->sy_value is not valid for struct local_symbol
Fixes this mep-elf error:
gas/elf/dwarf2-19.s: Error: Unknown expression operator (enum 0)
gas/elf/dwarf2-19.s: Error: cannot convert expression symbol .L2 to complex relocation

	* symbols.c (symbol_relc_make_sym): Do not access sym->sy_value
	directly.
2019-05-06 16:23:33 +09:30
Tom de Vries
5a56d6a65f [gdb/testsuite] Fix index-cache.exp with cc-with-{gdb-index,debug-names}
In gdb.base/index-cache.exp, handle the case that binfile contains either a
.gdb_index or .debug_names index section.

Tested on x86_64-linux with native, cc-with-gdb-index and cc-with-debug-names.

gdb/testsuite/ChangeLog:

2019-05-06  Tom de Vries  <tdevries@suse.de>

	* lib/gdb.exp (exec_has_index_section): New proc.
	* gdb.base/index-cache.exp: Handle case that binfile contains an index
	section.
2019-05-06 08:42:24 +02:00
Alan Modra
e1cbf07ac4 PicoJava weak undefined symbols
This fixes the recently added ld-elf/pr24511 test failure on pj-elf.
Incidentally, pj-elf has failed its gas "pj" test since 2005-12-22
(git commit 54758c3e39).  I think that makes the target ripe for
obsolescence.

bfd/
	* elf32-pj.c (pj_elf_reloc): Don't report undefined weak as an error.
ld/
	* testsuite/ld-undefined/weak-undef.exp: Don't xfail pj.
2019-05-06 11:41:28 +09:30
Alan Modra
334d91b940 PowerPC reloc symbols that shouldn't be adjusted
GOT and PLT relocs shouldn't have their symbols replaced with a
section symbol plus added.  Nor should the HIGHA TLS relocations,
which failed to be caught by the range test in ppc_fix_adjustable.

bfd/
	* reloc.c (BFD_RELOC_PPC64_TPREL16_HIGH, BFD_RELOC_PPC64_TPREL16_HIGHA),
	(BFD_RELOC_PPC64_DTPREL16_HIGH, BFD_RELOC_PPC64_DTPREL16_HIGHA):
	Sort before BFD_RELOC_PPC64_DTPREL16_HIGHESTA entry.
gas/
	* config/tc-ppc.c (ppc_fix_adjustable): Exclude all GOT and PLT
	relocs, and VLE sdarel relocs.
	* testsuite/gas/ppc/power4.d: Adjust.
2019-05-06 11:41:28 +09:30
Alexandre Oliva
62e6b7b3b3 [LVu] base subseg head view on prev subseg's tail
Location views at borders between subsegments/subsections in the same
segment/section are computed as if each new subsegment/subsection
started with a forced view reset to zero, but the line number program
does not introduce resets that are not explicitly requested, so if a
subsegment ends at the same address another starts, the line number
program will have a continuity of views at the border address, whereas
the initial view number label in the latter subsegment will be
miscomputed as zero.

This patch delays the assignment of view expressions at subsegment
heads to the time of chaining the frags of subsegments into a single
segment, so that they are set based on the view at the end of the
previous subsegment in the same segment.

The line number program created for the test program had an
unnecessary DW_LNS_advance_pc at the end.  This patch also arranges
for us not to emit it.


for  gas/ChangeLog

	* dwarf2dbg.c (set_or_check_view): Skip heads when assigning
	views of prior locs.
	(dwarf2_gen_line_info_1): Skip heads.
	(size_inc_line_addr, emit_inc_line_addr): Drop
	DW_LNS_advance_pc for zero addr delta.
	(dwarf2_finish): Assign views for heads of segments.
	* testsuite/gas/elf/dwarf2-19.d: New.
	* testsuite/gas/elf/dwarf2-19.s: New.
	* testsuite/gas/elf/elf.exp: Test it.
2019-05-05 23:07:20 -03:00
GDB Administrator
bd1efd7d21 Automatic date update in version.in 2019-05-06 00:00:14 +00:00
GDB Administrator
1231b7b825 Automatic date update in version.in 2019-05-05 00:00:56 +00:00
Tom Tromey
89055eaa12 Remove a VEC from aarch64-tdep.c
This removes a VEC from aarch64-tdep.c, replacing it with a
std::vector.

gdb/ChangeLog
2019-05-04  Tom Tromey  <tom@tromey.com>

	* aarch64-tdep.c (stack_item_t): Remove typedef and DEF_VEC.
	(struct aarch64_call_info): Add initializers.
	<si>: Now a std::vector.
	(pass_on_stack, aarch64_push_dummy_call): Update.
2019-05-04 14:40:55 -06:00
Tom Tromey
5da01df5b5 Remove a VEC from ppc-linux-nat.c
This replaces a VEC in ppc-linux-nat.c with a std::vector.

gdb/ChangeLog
2019-05-04  Simon Marchi  <simon.marchi@efficios.com>
	    Tom Tromey  <tom@tromey.com>

	* ppc-linux-nat.c (thread_points_p): Remove typedef and DEF_VEC.
	(ppc_threads): Now a std::vector.  Now static.
	(hwdebug_find_thread_points_by_tid)
	(ppc_linux_nat_target::low_new_thread, ppc_linux_thread_exit):
	Update.
2019-05-04 14:40:55 -06:00
Tom Tromey
fbdf05a16e Change arc_tdesc_init to return bool
This changes arc_tdesc_init to return bool.

gdb/ChangeLog
2019-05-04  Tom Tromey  <tom@tromey.com>

	* arc-tdep.c (arc_tdesc_init): Return bool.
2019-05-04 14:13:28 -06:00
Tom Tromey
06d16ec977 Use gdb_assert_not_reached in arm-linux-nat.c
This changes arm-linux-nat.c to use gdb_assert_not_reached rather than
an assert of false.

gdb/ChangeLog
2019-05-04  Tom Tromey  <tom@tromey.com>

	* arm-linux-nat.c (arm_linux_nat_target::can_use_hw_breakpoint):
	Use gdb_assert_not_reached.
2019-05-04 14:13:28 -06:00
Tom Tromey
9c05602219 Use "false" in compile_cplus_convert_enum
This changes compile_cplus_convert_enum to use "false".

Note that this variable is never modified, which seems like an error.
I filed PR compile/24473 for this.

gdb/ChangeLog
2019-05-04  Tom Tromey  <tom@tromey.com>

	* compile/compile-cplus-types.c (compile_cplus_convert_enum): Use
	"false".
2019-05-04 14:13:28 -06:00
Tom Tromey
fa9c2a59e3 Use bool, true, and false in arc-tdep.c
This changes arc-tdep.c to use bool, true, and false.

gdb/ChangeLog
2019-05-04  Tom Tromey  <tom@tromey.com>

	* arc-tdep.c (arc_tdesc_init): Use bool.
2019-05-04 14:13:28 -06:00
Tom Tromey
e2eb806a17 Use "false" in select_frame_for_mi
This changes select_frame_for_mi to use "false" rather than "FALSE".

gdb/ChangeLog
2019-05-04  Tom Tromey  <tom@tromey.com>

	* stack.c (select_frame_for_mi): Use "false", not "FALSE".
2019-05-04 14:13:27 -06:00
Tom Tromey
6fe876770a Change valid_command_p to return bool
This changes valid_command_p to return bool.

gdb/ChangeLog
2019-05-04  Tom Tromey  <tom@tromey.com>

	* cli/cli-cmds.c (valid_command_p): Return bool.
2019-05-04 14:13:27 -06:00
Tom Tromey
7f008c9e6a Change valid_user_defined_cmd_name_p to return bool
This changes valid_user_defined_cmd_name_p to return bool.

gdb/ChangeLog
2019-05-04  Tom Tromey  <tom@tromey.com>

	* cli/cli-decode.c (valid_user_defined_cmd_name_p): Return bool.
	* command.h (valid_user_defined_cmd_name_p): Channge return type.
2019-05-04 14:13:27 -06:00
Raul Tambre
b6484282f8 Fix incorrect use of 'is' operator for comparison in python/lib/gdb/command/prompt.py
The 'is' operator is not meant to be used for comparisons. It currently working
is an implementation detail of CPython.  CPython 3.8 has added a SyntaxWarning
for this.
2019-05-04 15:52:20 -04:00
Tom Tromey
af97b4161f Don't derive partial_symbol from general_symbol_info
This patch partly reverts commit 8a6d42345 ("Change representation of
psymbol to flush out accessors"); specifically, it changes
partial_symbol to no longer derive from general_symbol_info.

The basic problem here is that the bcache compares objects bitwise,
and this change made it less likely that the relevant fields in the
psymbol would be fully initialized.  This could be seen by running a
test under valgrind on the Fedora-i686 buildbot.

I considered a simpler patch, namely just zeroing the psymbol's
"value" field in add_psymbol_to_bcache.  However, it wasn't clear to
me that this memset could not then be optimized away by the compiler.

Regression tested by the buildbot.  I think this should go in 8.3 as
well.

gdb/ChangeLog
2019-05-04  Tom Tromey  <tom@tromey.com>

	* psymtab.c (psymbol_name_matches, match_partial_symbol)
	(lookup_partial_symbol, print_partial_symbols)
	(recursively_search_psymtabs, sort_pst_symbols, psymbol_hash)
	(psymbol_compare): Update.
	(add_psymbol_to_bcache): Clear the entire psymbol.
	(maintenance_check_psymtabs): Update.
	* psympriv.h (struct partial_symbol): Don't derive from
	general_symbol_info.
	<obj_section, unrelocated_address, address,
	set_unrelocated_address>: Update.
	<ginfo>: New member.
	* dwarf-index-write.c (write_psymbols, debug_names::insert)
	(debug_names::write_psymbols): Update.
2019-05-04 13:43:50 -06:00
Tom de Vries
9d6d4be89d [gdb/testsuite] Add cc-with-debug-names.exp
Add a target board that makes it easy to run the test suite with a
.debug_names section added to executables.

gdb/ChangeLog:

2019-05-04  Tom de Vries  <tdevries@suse.de>

	* contrib/cc-with-tweaks.sh: Support -n arg.

gdb/testsuite/ChangeLog:

2019-05-04  Tom de Vries  <tdevries@suse.de>

	* boards/cc-with-debug-names.exp: New file.
2019-05-04 10:11:53 +02:00
Alan Modra
27cdfa03b5 m32c padding with nops
m32c_md_end attempted to pad out a code section with nops, but this
was just plain wrong in many ways:
- The padding didn't happen at all if the last section emitted wasn't
  a code section.
- The padding went to the wrong place if subsections were used, and
  the last subseg used wasn't the highest numbered subseg.
- Padding wasn't added to all code sections.
- If the last section was empty, it was padded to 4 bytes.
- The padding didn't go to a 4-byte alignment boundary, instead it
  effectively made the last instruction 4 bytes in size.
- The padding didn't take into account that code sections may have
  contents other than machine instructions.

So, rip it out and handle nop padding properly, also fixing .align
.balign/.p2align in the middle of code.

gas/
	* config/tc-m32c.c (insn_size): Delete static var.
	(md_begin): Don't set it.
	(m32c_md_end): Delete.
	(md_assemble): Add insn_size auto var.
	* config/tc-m32c.h (md_end): Don't define.
	(m32c_md_end): Delete.
	(NOP_OPCODE, HANDLE_ALIGN, MAX_MEM_FOR_RS_ALIGN_CODE): Define.
	* testsuite/gas/all/align.d: Remove m32c from notarget list.
	* testsuite/gas/all/incbin.d: Likewise.
	* testsuite/gas/elf/dwarf2-11.d: Likewise.
	* testsuite/gas/macros/semi.d: Likewise.
	* testsuite/gas/all/gas.exp (do_comment): Similarly.
ld/
	* testsuite/ld-scripts/fill.d: Don't xfail m32c
	* testsuite/ld-scripts/fill16.d: Likewise.
2019-05-04 17:23:18 +09:30
Alan Modra
a288c27099 PR24511, nm should not mark symbols in .init_array as "t"
This patch restricts the section names matched in coff_section_type,
a function that translates section names to symbol type, and arranges
to translate section flags to symbol type before looking at names.
The latter change resulted in various test failures due to improper
section flags being used in tests, and by the plugin support, so fix
that too.

The new test fails on many ELF targets that lack .init/fini_array
in their scripts.  I've just xfailed those.  pru-elf oddly defines
__init_array_begin rather than __init_array_start.  I've left that
target as a FAIL, and pj-elf too which reports an error for undefined
weak symbols.

bfd/
	PR 24511
	* syms.c (coff_section_type): Only allow '.', '$' and numeric
	following the standard section names.
	(bfd_decode_symclass): Prioritize section flag tests in
	decode_section_type before name tests in coff_section_type.
	* plugin.c (bfd_plugin_canonicalize_symtab): Init fake_section
	and fake_common_section using BFD_FAKE_SECTION.  Use "fake" as
	their names and choose standard .text section flags for
	fake_section.
ld/
	PR 24511
	* testsuite/ld-elf/pr14156a.d: Allow for .init/.fini being a
	data section on hppa64.
	* testsuite/ld-elf/pr14156b.d: Likewise.
	* testsuite/ld-scripts/pr18963.t: Map standard sections to set
	output section flags.
	* testsuite/ld-scripts/sane1.t: Likewise.
	* testsuite/ld-elf/init-fini-arrays.s: Reference __init_array_start
	and __fini_array_start.  Define __start et al.
	* testsuite/ld-elf/pr24511.d: New test.
2019-05-04 16:57:33 +09:30
Philippe Waroquiers
66452beb77 Fix leaks by clearing registers and frame caches.
Valgrind reports leaks such as the below in the tests:
gdb.threads/corethreads.exp
gdb.threads/gcore-thread.exp
gdb.ada/task_switch_in_core.exp
gdb.trace/tfile.exp
gdb.base/siginfo-thread.exp

==12701== 1,123 (72 direct, 1,051 indirect) bytes in 1 blocks are definitely lost in loss record 2,928 of 3,247
==12701==    at 0x4C2C4CC: operator new(unsigned long) (vg_replace_malloc.c:344)
==12701==    by 0x5CF771: get_thread_arch_aspace_regcache(ptid_t, gdbarch*, address_space*) (regcache.c:330)
==12701==    by 0x5CF92A: get_thread_regcache (regcache.c:366)
==12701==    by 0x5CF92A: get_current_regcache() (regcache.c:372)
==12701==    by 0x4C7964: get_current_frame() (frame.c:1587)
==12701==    by 0x4C7A3C: get_selected_frame(char const*) (frame.c:1651)
==12701==    by 0x669EAD: print_thread_info_1(ui_out*, char const*, int, int, int) (thread.c:1151)
==12701==    by 0x66A9A1: info_threads_command(char const*, int) (thread.c:1217)
==12701==    by 0x40A878: cmd_func(cmd_list_element*, char const*, int) (cli-decode.c:1892)
...

Fix these leaks by clearing registers and frame caches.
This leak and fix is similar to the leak fixed by 799efbe8e0
2019-05-04 07:22:01 +02:00
Tom Tromey
bde09ab702 Remove "struct" from foreach statements
Some versions of gcc have a bug that causes

    for (struct mumble : something)

... to give a compiler error.  We routinely work around this bug in
gdb, but apparently had not done so in a while.  This patch fixes the
remaining known cases of this problem.

gdb/ChangeLog
2019-05-03  Sandra Loosemore  <sandra@codesourcery.com>
	    Tom Tromey  <tom@tromey.com>

	* dictionary.c (collate_pending_symbols_by_language): Remove
	"struct" from foreach.
	* symtab.c (lookup_global_symbol_from_objfile)
	(lookup_symbol_in_objfile_from_linkage_name): Remove "struct" from
	foreach.
	* ser-tcp.c (net_open): Remove "struct" from foreach.
	* objfiles.c (objfile_relocate, objfile_rebase)
	(objfile_has_symbols): Remove "struct" from foreach.
	* minsyms.c (lookup_minimal_symbol_by_pc_section): Remove "struct"
	from foreach.
	* dwarf2read.c (handle_struct_member_die): Remove "struct" from
	foreach.
	* darwin-nat.c (thread_info_from_private_thread_info): Remove
	"struct" from foreach.
	* ada-lang.c (create_excep_cond_exprs)
	(ada_exception_catchpoint_cond_string): Remove "struct" from
	foreach.
2019-05-03 18:06:37 -06:00
GDB Administrator
b5d5eb444b Automatic date update in version.in 2019-05-04 00:00:19 +00:00
Tom Tromey
222a8d2558 Fix cast of character to enum type in Ada
An internal bug report points out that, when a global character enum
type is used, casting fails, like:

    (gdb) print global_char_enum'('F')
    $1 = 70

The bug here turns out to be that enumerators are qualified, so for
example the mangled name might be "pck__QU48", rather than "QU48".

This patch fixes the problem by only examining the suffix of the
enumerator.  This is ok because the type is already known, and because
the mangling scheme ensures that there won't be clashes.

Tested on x86-64 Fedora 29.

gdb/ChangeLog
2019-05-03  Tom Tromey  <tromey@adacore.com>

	* ada-exp.y (convert_char_literal): Check suffix of each
	enumerator.

gdb/testsuite/ChangeLog
2019-05-03  Tom Tromey  <tromey@adacore.com>

	* gdb.ada/char_enum/pck.ads (Global_Enum_Type): New type.
	* gdb.ada/char_enum/foo.adb: Use Global_Enum_Type.
	* gdb.ada/char_enum.exp: Add test.
2019-05-03 17:04:56 -06:00
Dilyan Palauzov
fcd60b848e Add noyywrap to ada-lex.l
This patch comes from PR ada/21406.  It adds the noyywrap option to
ada-lex.l.  This was already done (by the same author) for other .l
files in the binutils-gdb tree, so it seems reasonably safe.

Tested on x86-64 Fedora 29.

gdb/ChangeLog
2019-05-03  Dilyan Palauzov  <dilyan.palauzov@aegee.org>

	PR ada/21406:
	* ada-exp.y (yywrap): Don't define.
	* ada-lex.l (%option): Add noyywrap
	(yywrap): Remove.
2019-05-03 17:03:56 -06:00
Tom de Vries
0fdfd794d2 [gdb/testsuite] Add cc-with-gdb-index.exp
Add a target board cc-with-gdb-index.exp, to make it easy to run cc-with-tweaks
with CC_WITH_TWEAKS_FLAGS='-i'.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-05-03  Tom de Vries  <tdevries@suse.de>

	* boards/cc-with-gdb-index.exp: New file.
2019-05-03 12:57:58 +02:00