Andreas Schwab [Mon, 20 Aug 2018 14:55:05 +0000 (16:55 +0200)]
Fix invalid strcpy on unterminated buffer
* read.c (do_repeat_with_expander): Use memmove instead of strcpy
on unterminated string buffer.
Alan Modra [Thu, 16 Aug 2018 06:44:12 +0000 (16:14 +0930)]
Use operand->extract to provide defaults for optional PowerPC operands
Most optional operands to powerpc instructions use a default value of
zero, but there are a few exceptions. Those have been handled by
PPC_OPERAND_OPTIONAL_VALUE and an entry in the powerpc_operands table
for the default value, smuggled in the shift field. This patch
changes that to using the operand extract function to provide non-zero
defaults.
I've also moved the code determining whether optional operands are
provided or omitted, to the point the first optional operand is seen,
and allowed for the possibility of optional base register operands
in a future patch.
The patch does change the error you get on invalid assembly like
ld 3,4
You'll now see "missing operand" rather than
"syntax error; end of line, expected `('".
gas/
* config/tc-ppc.c (md_assemble): Delay counting of optional
operands until one is encountered. Allow for the possibility
of optional base regs, ie. PPC_OPERAND_PARENS. Call
ppc_optional_operand_value with extra args.
include/
* opcode/ppc.h (struct powerpc_operand): Correct "insert" comment.
Mention use of "extract" function to provide default value.
(PPC_OPERAND_OPTIONAL_VALUE): Delete.
(ppc_optional_operand_value): Rewrite to use extract function.
opcodes/
* ppc-dis.c (operand_value_powerpc): Init "invalid".
(skip_optional_operands): Count optional operands, and update
ppc_optional_operand_value call.
* ppc-opc.c (extract_dxdn): Remove ATTRIBUTE_UNUSED from used arg.
(extract_vlensi): Likewise.
(extract_fxm): Return default value for missing optional operand.
(extract_ls, extract_raq, extract_tbr): Likewise.
(insert_sxl, extract_sxl): New functions.
(insert_esync, extract_esync): Remove Power9 handling and simplify.
(powerpc_operands <FXM4, TBR>): Delete PPC_OPERAND_OPTIONAL_VALUE
flag and extra entry.
(powerpc_operands <SXL>): Likewise, and use insert_sxl and
extract_sxl.
Alan Modra [Mon, 20 Aug 2018 05:53:38 +0000 (15:23 +0930)]
PowerPC HOWTOs
These take up far too many lines in the files. This patch introduces
a replacement for the HOWTO macro that simplifies the relow howto
initialization. Apart from the two relocs mentioned in the ChangeLog,
no relocation howto is changed.
* elf64-ppc.c (HOW): Define.
(ONES): Delete.
(ppc64_elf_howto_raw): Use HOW to initialize entries.
* elf32-ppc.c (HOW): Define.
(ppc_elf_howto_raw): Use HOW to initialize entries, updating
R_PPC_VLE_REL15 and R_PPC_VLE_REL24 to use bitpos=0.
Alan Modra [Tue, 21 Aug 2018 02:24:29 +0000 (11:54 +0930)]
Pack reloc_howto_struct
This patch uses bitfields in reloc_howto_struct, reducing its size
from 80 to 40 bytes on 64-bit hosts and from 52 to 32 bytes on 32-bit
hosts (with a 32-bit bfd_vma). I've also added a new "negate" field
rather than making the encoded "size" field do double duty as both
a size and a flag.
There was just one use of an encoded size of 8, which according to
bfd_get_reloc_size meant 16 bytes, in vms-alpha.c ALPHA_R_LINKAGE.
See git commit
c3d8e071bf adding ALPHA_R_LINKAGE and git commit
8612a388f7 decoding size 8 in bfd_get_reloc_size. Since no other part
of BFD handles 16 byte relocs, I've removed that encoding and special
cased the ALPHA_R_LINKAGE size in vms-alpha.c.
* reloc.c (reloc_howto_type): Typedef.
(bfd_symbol): Delete forward declaration.
(struct reloc_howto_struct): Add "negate" field. Make "size",
"bitsize", "rightshift", "bitpos", "complain_on_overflow",
"pc_relative", "partial_inplace", and "pcrel_offset" bitfields.
Rearrange for better packing. Revise comments.
(HOWTO): Map to rearranged reloc_howto_struct.
(bfd_get_reloc_size): Delete now unused cases.
(read_reloc, write_reloc): Likewise.
(apply_reloc, _bfd_relocate_contents): Test howto->negate
rather than howto->size < 0 for negated relocation values.
* coff-rs6000.c (xcoff_complain_overflow_bitfield_func): Avoid
signed/unsigned warning.
(xcoff_ppc_relocate_section): Delete "condition is always false"
code.
* coff64-rs6000.c (xcoff64_ppc_relocate_section): Likewise.
* cpu-ns32k.c (do_ns32k_reloc): Adjust to suit reloc_howto_struct
changes.
* vms-alpha.c (_bfd_vms_write_etir, alpha_vms_slurp_relocs): Use
size 16 for ALPHA_R_LINKAGE.
(alpha_howto_table <ALPHA_R_LINKAGE>): Set encoded size and
bitsize to zero.
* bfd-in.h (reloc_howto_type): Delete.
* bfd-in2.h: Regenerate.
Alan Modra [Mon, 20 Aug 2018 10:06:05 +0000 (19:36 +0930)]
Delete NEWHOWTO and tidy some uses of reloc_howto_struct
NEWHOWTO was promised way back in 1991 (git commit
e5683622186).
I doubt it's ever going to be implemented. This patch removes it,
and tidies some reloc howtos. I was going to make some changes to
reloc_howto_struct, so I think it's important that all relocs howtos
are initialized with HOWTO.
* reloc.c (HOWTO): Revise comment.
(NEWHOWTO, HOWTO_PREPARE): Delete.
* coff-arm.c (coff_arm_reloc_type_lookup): Replace const struc
reloc_howto_struct with reloc_howto_type.
* ns32knetbsd.c (MY_bfd_reloc_type_lookup): Likewise.
* vms-alpha.c (alpha_vms_bfd_reloc_type_lookup): Likewise.
* elf-hppa.h (HOW): Define.
(elf_hppa_howto_table): Use it to simplify this table, correcting
name of R_PARISC_LTOFF16WF, R_PARISC_LTOFF_FPTR64, and
R_PARISC_LTOFF_FPTR16DF.
* elf32-mep.c (MEPREL): Use HOWTO.
* bfd-in2.h: Regenerate.
Alan Modra [Mon, 20 Aug 2018 08:46:34 +0000 (18:16 +0930)]
Fix s12z test regexps
Fixes
ERROR: tcl error sourcing .../gas/testsuite/gas/s12z/s12z.exp.
ERROR: couldn't compile regular expression pattern: quantifier operand invalid
run_dump_test expected output lines are regexps.
* testsuite/gas/s12z/bit-manip-invalid.d: Correct regexps.
GDB Administrator [Tue, 21 Aug 2018 00:00:49 +0000 (00:00 +0000)]
Automatic date update in version.in
Simon Marchi [Mon, 20 Aug 2018 02:03:58 +0000 (22:03 -0400)]
Fix formatting in solib-svr4.c
Fix some formatting issues which I have missed during review.
gdb/ChangeLog:
* solib-svr4.c (svr4_exec_displacement): Fix formatting.
Alan Modra [Sun, 19 Aug 2018 23:55:12 +0000 (09:25 +0930)]
Don't init array at run time
When it can be done at compile time.
* mmo.c (valid_mmo_symbol_character_set): Initialize and make
array const.
(mmo_init): Don't init valid_mmo_symbol_character_set.
Alan Modra [Sun, 19 Aug 2018 23:52:28 +0000 (09:22 +0930)]
Tidy bit twiddling
* sh-opc.h (MASK): Simplify.
Alan Modra [Sun, 19 Aug 2018 23:50:11 +0000 (09:20 +0930)]
Balance parentheses in expression
* rs6000-core.c (CORE_COMMONSZ): Balance parentheses in expression.
GDB Administrator [Mon, 20 Aug 2018 00:00:44 +0000 (00:00 +0000)]
Automatic date update in version.in
Michael Spang [Sun, 19 Aug 2018 14:55:58 +0000 (10:55 -0400)]
Fix debugging of stripped PIE executables with padded PT_TLS
Certain PIE executables produced by gold cannot be debugged by gdb after
being stripped. GDB requires program headers of PIE executables to match,
and those checks may fail due to adjustments made during stripping.
One case of this occurs because strip recomputes the memsz of PT_TLS and
does not add alignment, while gold does. This is another variant of PR
11786, so apply the same fix of relaxing the program header matching.
gdb/ChangeLog:
PR gdb/11786
* solib-svr4.c (svr4_exec_displacement): Ignore memsz fields
for PT_TLS segments.
gdb/testsuite/ChangeLog:
PR gdb/11786
* gdb.base/gcore-tls-pie.c: New file.
* gdb.base/gcore-tls-pie.exp: New file.
GDB Administrator [Sun, 19 Aug 2018 00:01:08 +0000 (00:01 +0000)]
Automatic date update in version.in
Kevin Buettner [Tue, 31 Jul 2018 21:45:20 +0000 (14:45 -0700)]
Test case for DW_OP_GNU_variable_value
gdb/testsuite/ChangeLog:
* gdb.dwarf2/varval.c: New file.
* gdb.dwarf2/varval.exp: New file.
Kevin Buettner [Mon, 30 Jul 2018 23:15:34 +0000 (16:15 -0700)]
Add support of DW_OP_GNU_variable_value to DWARF assembler
gdb/testsuite/ChangeLog:
* lib/dwarf.exp: Add support for DW_OP_GNU_variable_value.
Kevin Buettner [Mon, 30 Jul 2018 22:41:56 +0000 (15:41 -0700)]
Add support for DW_OP_GNU_variable_value
This patch adds support for DW_OP_GNU_variable_value to GDB.
Jakub Jelinek provides a fairly expansive discussion of this DWARF
expression opcode in his GCC patch...
https://gcc.gnu.org/ml/gcc-patches/2017-02/msg01499.html
It has also been proposed for addition to the DWARF Standard:
http://www.dwarfstd.org/ShowIssue.php?issue=161109.2
If compiled with a suitable version of GCC, the test case associated
with GCC Bug 77589 uses DW_OP_GNU_variable_value in a DW_AT_byte_stride
expression. Here's a link to the bug:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77589
This is what the DWARF looks like. Look at the last line, which has
the DW_AT_byte_stride expression:
<2><e1>: Abbrev Number: 12 (DW_TAG_variable)
<e2> DW_AT_name : (indirect string, offset: 0x115): span.0
<e6> DW_AT_type : <0x2e>
<ea> DW_AT_artificial : 1
<ea> DW_AT_location : 3 byte block: 91 b0 7f (DW_OP_fbreg: -80)
...
<2><178>: Abbrev Number: 18 (DW_TAG_subrange_type)
<179> DW_AT_lower_bound : 4 byte block: 97 23 20 6 (DW_OP_push_object_address; DW_OP_plus_uconst: 32; DW_OP_deref)
<17e> DW_AT_upper_bound : 4 byte block: 97 23 28 6 (DW_OP_push_object_address; DW_OP_plus_uconst: 40; DW_OP_deref)
<183> DW_AT_byte_stride : 10 byte block: 97 23 18 6 fd e1 0 0 0 1e (DW_OP_push_object_address; DW_OP_plus_uconst: 24; DW_OP_deref; DW_OP_GNU_variable_value: <0xe1>; DW_OP_mul)
A patch to readelf, which I'm also submitting, is required to do this
decoding.
I found that GDB gave me the correct answer for "p c40pt(2)" once I
(correctly) implemented DW_OP_GNU_variable_value.
I also have test case (later in this series) which uses the DWARF
assembler and, therefore, do not rely on having a compiler with this
support.
gdb/ChangeLog:
* dwarf2expr.h (struct dwarf_expr_context): Add virtual method
dwarf_variable_value.
* dwarf2-frame.c (class dwarf_expr_executor):
Add override for dwarf_variable_value.
* dwarf2loc.c (class dwarf_evaluate_loc_desc): Likewise.
(class symbol_needs_eval_context): Likewise.
(indirect_synthetic_pointer): Add forward declaration.
(sect_variable_value): New function.
(dwarf2_compile_expr_to_ax): Add case for DW_OP_GNU_variable_value.
* dwarf2expr.c (dwarf_expr_context::execute_stack_op): Add case
for DW_OP_GNU_variable_value.
John Darrington [Tue, 24 Jul 2018 11:40:21 +0000 (13:40 +0200)]
Opcodes: (BRCLR / BRSET) Disassemble reserved codes instead of aborting.
Bit manipulation instructions which are not normally generated by the
assembler, should nevertheless be decoded by the disassembler.
opcodes/
* s12z-dis.c: BM_RESERVED1 to behave like BM_OPR_REG, and
BM_RESERVED0 like BM_REG_IMM.
John Darrington [Wed, 11 Jul 2018 08:42:01 +0000 (10:42 +0200)]
S12Z: Move opcode header to public include directory.
opcodes/
* s12z.h: Delete.
* s12z-dis.c: Adjust path of included file.
include/
* opcode/s12z.h: New file.
gas/
* config/tc-s12z.c: Adjust path of included file.
Alan Modra [Fri, 17 Aug 2018 05:36:46 +0000 (15:06 +0930)]
Remove duplicate ld testsuite function
It's in binutils/testsuite/lib/binutils-common.exp
* testsuite/ld-elf/elf.exp (is_elf64): Delete.
Alan Modra [Mon, 13 Aug 2018 04:11:18 +0000 (13:41 +0930)]
binutils testsuite strip-13 test
The strip-13 test runs into difficulty using dc.a on some targets.
dc.a writes a power of 2 number of bytes large enough to contain a
target address. On some targets, eg. avr-elf, this can be 2 bytes but
the ELF format used require words of 4 bytes to make up a relocation
entry. There was a hack in the test, duplicating the reloc type into
what is normally the addend to make the test work when little-endian,
but that hack fails for similar big-endian targets.
This patch fixes that problem by arranging to emit 32-bit and 64-bit
ELF relocs using .4byte and .8byte directives, chosen as appropriate
for the ELF size. I've also bumped the reloc number tested to a
higher unused value, and made the number more easily parameterised by
target should that be necessary in the future. Whether REL or RELA
relocs are used is now chosen by a new is_rela readelf test of an
object file, rather than by lists of targets.
* testsuite/lib/binutils-common.exp (is_elf64): Use directory of
input file for readelf.out.
(is_rela): New proc.
* testsuite/binutils-all/objcopy.exp (elf64): Set new variable
from first result of is_elf64 test.
(reloc_format): Set using is_rela.
(strip-13): Pass RELOC and ELF64 to assembler.
(strip-14, strip-15): Use elf64 rather than calling is_elf64 again.
* testsuite/binutils-all/strip-13.d: Run for more targets.
* testsuite/binutils-all/strip-13mips64.s: Use RELOC and set
addend to zero.
* testsuite/binutils-all/strip-13rel.s: Use RELOC and ELF64.
Don't add _NONE reloc.
* testsuite/binutils-all/strip-13rela.s: Likewise.
GDB Administrator [Sat, 18 Aug 2018 00:00:26 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom Tromey [Thu, 16 Aug 2018 00:37:00 +0000 (18:37 -0600)]
Remove "repeat" argument from command_line_input
After the previous patch, all callers pass 0 as the repeat argument to
command_line_input. So, this patch removes it.
gdb/ChangeLog
2018-08-16 Tom Tromey <tom@tromey.com>
* top.c (read_command_file): Update.
(command_line_input): Remove "repeat" argument.
* ada-lang.c (get_selections): Update.
* linespec.c (decode_line_2): Update.
* defs.h (command_line_input): Remove argument.
* cli/cli-script.c (read_next_line): Update.
* python/py-gdb-readline.c: Update.
Tom Tromey [Thu, 16 Aug 2018 00:37:00 +0000 (18:37 -0600)]
Fix use-after-free in number_or_range_parser
-fsanitize=address showed a use-after-free in number_or_range_parser.
The cause was that handle_line_of_input could stash the input into
"saved_command_line", and then this could be freed by reentrant calls.
This fixes the bug by preventing commands that are read by "commands"
from being eligible for repeating.
gdb/ChangeLog
2018-08-17 Tom Tromey <tom@tromey.com>
* cli/cli-script.c (read_next_line): Pass 0 as repeat argument to
command_line_input.
H.J. Lu [Fri, 17 Aug 2018 10:54:05 +0000 (03:54 -0700)]
x86: Remove empty X86_FEATURE_1_AND property
There is no need to generate .note.gnu.property section with empty
X86_FEATURE_1_AND property. This patch adds fixup_gnu_properties
to ELF linker backend so that x86 backend can remove it.
bfd/
PR ld/23515
* elf-bfd.h (elf_backend_data): Add fixup_gnu_properties.
* elf-properties.c (_bfd_elf_link_setup_gnu_properties): Call
backend fixup_gnu_properties if it isn't NULL. Discard
.note.gnu.property section if all properties have been removed.
* elfxx-target.h (elf_backend_fixup_gnu_properties): New.
(elfNN_bed): Initialize fixup_gnu_properties.
* elfxx-x86.c (_bfd_x86_elf_link_fixup_gnu_properties): New
function.
* elfxx-x86.h (_bfd_x86_elf_link_fixup_gnu_properties): New
prototype.
(elf_backend_fixup_gnu_properties): New.
ld/
PR ld/23515
* testsuite/ld-i386/ibt-plt-2a.d: Updated.
* testsuite/ld-i386/ibt-plt-2b.d: Likewise.
* testsuite/ld-x86-64/ibt-plt-2a-x32.d: Likewise.
* testsuite/ld-x86-64/ibt-plt-2a.d: Likewise.
* testsuite/ld-x86-64/ibt-plt-2b-x32.d: Likewise.
* testsuite/ld-x86-64/ibt-plt-2b.d: Likewise.
Alan Hayward [Thu, 16 Aug 2018 14:21:15 +0000 (15:21 +0100)]
Fix asm in testsuite/gdb.arch/aarch64-fp.c
Cannot assume result of first and third ldr will go into x0.
Rewrite asm to be clearer.
gdb/testsuite/
PR gdb/18931:
* gdb.arch/aarch64-fp.c (main): Fix asm registers.
Keith Seitz [Thu, 16 Aug 2018 21:37:49 +0000 (14:37 -0700)]
Use gdb_test_no_output for compile tests expected to pass
There is a small think-o in compile.exp:
if { $srcfile3 != "" } {
gdb_test "p constvar" " = 3"
gdb_test "info addr constvar" {Symbol "constvar" is constant\.}
gdb_test "compile code globalvar = constvar;"; # INCORRECT
gdb_test "print globalvar" " = 3" "print constvar value"
} else {
untested "print constvar value"
}
The line marked INCORRECT runs a simple "compile code" which is expected
to succeed. When this happens, the compile plug-in and GDB will not
output anything. The use of gdb_test matches against anything.
This is certainly not the intent, and this patch corrects the two instances
of this in the file. [The rest of gdb.compile looks okay.]
testsuite/ChangeLog:
* gdb.compile/compile.exp: Use gdb_test_no_output for "compile code"
tests expected to pass.
Alan Modra [Wed, 15 Aug 2018 01:41:59 +0000 (11:11 +0930)]
Correct elf64-ppc.c linkage stub comment and formatting fixes
ppc_stub_long_branch_notoc will never need more than a 32-bit offset
for the r12 offset since the stub target must be in range of a
branch instruction.
* elf64-ppc.c: Correct ppc_stub_long_branch_notoc example.
Formatting.
GDB Administrator [Thu, 16 Aug 2018 00:00:31 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom Tromey [Wed, 15 Aug 2018 16:05:01 +0000 (10:05 -0600)]
Use pulongest in aarch64-linux-tdep.c
While testing a patch on the buildbot, I got this error:
../../binutils-gdb/gdb/aarch64-linux-tdep.c: In function uint64_t aarch64_linux_core_read_vq(gdbarch*, bfd*):
../../binutils-gdb/gdb/aarch64-linux-tdep.c:285:29: error: format %ld expects argument of type long int, but argument 2 has type uint64_t {aka long long unsigned int} [-Werror=format=]
This patch avoids the problem by using pulongest rather than %ld.
This seems safe to me because, if aarch64-linux-tdep.c is included in
the build, then ULONGEST must be a 64-bit type.
gdb/ChangeLog
2018-08-15 Tom Tromey <tom@tromey.com>
* aarch64-linux-tdep.c (aarch64_linux_core_read_vq): Use pulongest.
GDB Administrator [Wed, 15 Aug 2018 00:00:14 +0000 (00:00 +0000)]
Automatic date update in version.in
H.J. Lu [Tue, 14 Aug 2018 16:55:43 +0000 (09:55 -0700)]
x86-64: Display eiz for address with the addr32 prefix
In 64-bit mode, display eiz for address with the addr32 prefix and without
base nor index registers. For
mov -0xccddef(,%eiz,), %rax
disassembler now displays:
67 48 8b 04 25 11 22 33 ff mov -0xccddef(,%eiz,1),%rax
instead of
67 48 8b 04 25 11 22 33 ff addr32 mov 0xffffffffff332211,%rax
gas/
* testsuite/gas/i386/evex-no-scale-64.d: Updated.
* testsuite/gas/i386/x86-64-addr32-intel.d: Likewise.
* testsuite/gas/i386/x86-64-addr32.d: Likewise.
* testsuite/gas/i386/ilp32/x86-64-addr32-intel.d: Likewise.
* testsuite/gas/i386/ilp32/x86-64-addr32.d: Likewise.
* testsuite/gas/i386/x86-64-addr32.s: Add %eiz tests.
opcodes/
* i386-dis.c (OP_E_memory): In 64-bit mode, display eiz for
address with the addr32 prefix and without base nor index
registers.
Jan Vrany [Tue, 14 Aug 2018 13:13:28 +0000 (14:13 +0100)]
MI: Add -a option to the "-data-disassemble" command
The CLI "disassemble" command allows specifying a single address - in
that case the function surrounding that address is disassembled.
This commit adds this feature to the equivalent MI command
"-data-disassemble".
gdb/ChangeLog:
2018-08-14 Jan Vrany <jan.vrany@fit.cvut.cz>
* mi/mi-cmd-disas.c (mi_cmd_disassemble): Add -a option.
If used, use find_pc_partial_function to find address range
to disassemble.
* mi/mi-main.c (mi_cmd_list_features): Report
"data-disassemble-a-option" feature.
* NEWS: Mention new -data-disassemble option -a.
gdb/doc/ChangeLog:
2018-08-14 Jan Vrany <jan.vrany@fit.cvut.cz>
* gdb.texinfo (GDB/MI Data Manipulation): Document
"-data-disassemble -a addr".
(GDB/MI Support Commands): Document "data-disassemble-a-option"
feature.
gdb/testsuite/ChangeLog:
2018-08-14 Jan Vrany <jan.vrany@fit.cvut.cz>
* gdb.mi/mi-disassemble.exp (test_disassembly_only): Add tests for
-data-disassemble -a.
(test_disassembly_bogus_args): Likewise.
Andrew Burgess [Fri, 10 Aug 2018 09:16:32 +0000 (10:16 +0100)]
gdb: Fix instability in thread groups test
In the test script gdb.mi/list-thread-groups-available.exp we ask GDB
to list all thread groups, and match the output against a
regexp. Occasionally, I would see this test fail.
The expected output is a list of entries, each entry looking roughly
like this:
{id="<DECIMAL>",type="process",description="<STRING>",
user="<STRING>",cores=["<DECIMAL>","<DECIMAL>",...]}
All the fields after 'id' and 'type' are optional, and the 'cores'
list can contain 1 or more "<DECIMAL>" entries.
On my machine (Running Fedora 27, kernel 4.17.3-100.fc27.x86_64)
usually the 'description' is a non-empty string, and the 'cores' list
has at least one entry in it. But sometimes, very rarely, I'll see an
entry in the process group list where the 'description' is an empty
string, the 'user' is the string "?", and the 'cores' list is empty.
Such an entry looks like this:
{id="19863",type="process",description="",user="?",cores=[]}
I believe that this is caused by the process exiting while GDB is
scanning /proc for process information. The current code in
gdb/nat/linux-osdata.c is not (I think) resilient against exiting
processes.
This commit adjusts the regex that matches the 'cores' list so that an
empty list is acceptable, with this patch in place the test script
gdb.mi/list-thread-groups-available.exp never fails for me now.
I've only adjusted the cores regexp for the occasion when we have GDB
read information about all processes, its only in this case that we
might encounter an exiting process. When we read information about
two known PIDs, that we know will not exit for the duration of the
test, we require that the core list be non-empty.
gdb/testsuite/ChangeLog:
* gdb.mi/list-thread-groups-available.exp: Update test regexp.
Robert Yang [Tue, 14 Aug 2018 11:22:35 +0000 (12:22 +0100)]
When the assembler reports that the input and output are the same, report the file names involved, in order to help debugging. Also do not equate two files are the same if the have the same inode value but reside on different file systems.
* as.c (main): Improve check for input file matching output file.
GDB Administrator [Tue, 14 Aug 2018 00:00:28 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom Tromey [Fri, 10 Aug 2018 15:03:47 +0000 (09:03 -0600)]
Define _FORTIFY_SOURCE in common-defs.h
This defines _FORTIFY_SOURCE in common-defs.h. This seems like a
sensible safety measure, and also it may help avoid build problems
with -Wunused-result on distros that already define _FORTIFY_SOURCE by
default.
Tested by the buildbot.
gdb/ChangeLog
2018-08-13 Tom Tromey <tom@tromey.com>
* common/common-defs.h (_FORTIFY_SOURCE): Define.
H.J. Lu [Mon, 13 Aug 2018 14:24:31 +0000 (07:24 -0700)]
bfd: Move elf-properties.lo to BFD32_LIBS
commit
6404ab993797d1d6cd3d9e97cc281e3cb6226c12
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Wed Aug 8 21:00:04 2018 -0700
Convert .note.gnu.property section between ELF32 and ELF64
updated bfd_convert_section_size and bfd_convert_section_contents
in bfd.c to call _bfd_elf_convert_gnu_property_size and
_bfd_elf_convert_gnu_properties, which are defined in elf-properties.c.
It led to
bfd.c:2484: undefined reference to `_bfd_elf_convert_gnu_property_size'
for non-ELF targets. Since elf-properties.c is a generic implementation
and doesn't reference any ELF specific functions directly, this patch
moves elf-properties.lo BFD32_LIBS.
Tested for many ELF and non-ELF targets.
PR binutils/23494
* Makefile.am (BFD32_LIBS): Add elf-properties.lo.
(BFD32_LIBS_CFILES): Add elf-properties.c.
(BFD32_BACKENDS): Remove elf-properties.lo.
(BFD32_BACKENDS_CFILES): Remove elf-properties.c.
* configure.ac (elf): Remove elf-properties.lo.
* Makefile.in: Regenerated.
* configure: Likewise.
Alan Hayward [Mon, 13 Aug 2018 10:02:22 +0000 (11:02 +0100)]
Parse SVE registers in aarch64 core file reading/writing
sve_regmap cannot be global static as the size is dependant on the current
vector length.
gdb/
* aarch64-linux-tdep.c (aarch64_linux_supply_sve_regset): New function.
(aarch64_linux_collect_sve_regset): Likewise.
(aarch64_linux_iterate_over_regset_sections): Check for SVE.
* regcache.h (regcache_map_entry_size): New function.
Alan Hayward [Mon, 13 Aug 2018 09:49:51 +0000 (10:49 +0100)]
Detect SVE when reading aarch64 core files
The SVE section in a core file contains a header followed by the registers.
Add defines to easily access the header fields within a buffer.
gdb/
* aarch64-linux-tdep.c (SVE_HEADER_SIZE_LENGTH): Add define.
(SVE_HEADER_MAX_SIZE_LENGTH): Likewise.
(SVE_HEADER_VL_LENGTH): Likewise.
(SVE_HEADER_MAX_VL_LENGTH): Likewise.
(SVE_HEADER_FLAGS_LENGTH): Likewise.
(SVE_HEADER_RESERVED_LENGTH): Likewise.
(SVE_HEADER_SIZE_OFFSET): Likewise.
(SVE_HEADER_MAX_SIZE_OFFSET): Likewise.
(SVE_HEADER_VL_OFFSET): Likewise.
(SVE_HEADER_MAX_VL_OFFSET): Likewise.
(SVE_HEADER_FLAGS_OFFSET): Likewise.
(SVE_HEADER_RESERVED_OFFSET): Likewise.
(SVE_HEADER_SIZE): Likewise.
(aarch64_linux_core_read_vq): Add function.
(aarch64_linux_core_read_description): Check for SVE section.
Alan Hayward [Mon, 13 Aug 2018 09:04:11 +0000 (10:04 +0100)]
Split size in regset section iterators
In the existing code, when using the regset section iteration functions, the
size parameter is used in different ways.
With collect, size is used to create the buffer in which to write the regset.
(see linux-tdep.c::linux_collect_regset_section_cb).
With supply, size is used to confirm the existing regset is the correct size.
If REGSET_VARIABLE_SIZE is set then the regset can be bigger than size.
Effectively, size is the minimum possible size of the regset.
(see corelow.c::get_core_register_section).
There are currently no targets with both REGSET_VARIABLE_SIZE and a collect
function.
In SVE, a corefile can contain one of two formats after the header, both of
which are different sizes. However, when writing a core file, we always want
to write out the full bigger size.
To allow support of collects for REGSET_VARIABLE_SIZE we need two sizes.
This is done by adding supply_size and collect_size.
gdb/
* aarch64-fbsd-tdep.c
(aarch64_fbsd_iterate_over_regset_sections): Add supply_size and
collect_size.
* aarch64-linux-tdep.c
(aarch64_linux_iterate_over_regset_sections): Likewise.
* alpha-linux-tdep.c
(alpha_linux_iterate_over_regset_sections):
* alpha-nbsd-tdep.c
(alphanbsd_iterate_over_regset_sections): Likewise.
* amd64-fbsd-tdep.c
(amd64fbsd_iterate_over_regset_sections): Likewise.
* amd64-linux-tdep.c
(amd64_linux_iterate_over_regset_sections): Likewise.
* arm-bsd-tdep.c
(armbsd_iterate_over_regset_sections): Likewise.
* arm-fbsd-tdep.c
(arm_fbsd_iterate_over_regset_sections): Likewise.
* arm-linux-tdep.c
(arm_linux_iterate_over_regset_sections): Likewise.
* corelow.c (get_core_registers_cb): Likewise.
(core_target::fetch_registers): Likewise.
* fbsd-tdep.c (fbsd_collect_regset_section_cb): Likewise.
* frv-linux-tdep.c (frv_linux_iterate_over_regset_sections): Likewise.
* gdbarch.h (void): Regenerate.
* gdbarch.sh: Add supply_size and collect_size.
* hppa-linux-tdep.c (hppa_linux_iterate_over_regset_sections): Likewise.
* hppa-nbsd-tdep.c (hppanbsd_iterate_over_regset_sections): Likewise.
* hppa-obsd-tdep.c (hppaobsd_iterate_over_regset_sections): Likewise.
* i386-fbsd-tdep.c (i386fbsd_iterate_over_regset_sections): Likewise.
* i386-linux-tdep.c (i386_linux_iterate_over_regset_sections): Likewise.
* i386-tdep.c (i386_iterate_over_regset_sections): Likewise.
* ia64-linux-tdep.c (ia64_linux_iterate_over_regset_sections): Likewise.
* linux-tdep.c (linux_collect_regset_section_cb): Likewise.
* m32r-linux-tdep.c (m32r_linux_iterate_over_regset_sections): Likewise.
* m68k-bsd-tdep.c (m68kbsd_iterate_over_regset_sections): Likewise.
* m68k-linux-tdep.c (m68k_linux_iterate_over_regset_sections): Likewise.
* mips-fbsd-tdep.c (mips_fbsd_iterate_over_regset_sections): Likewise.
* mips-linux-tdep.c (mips_linux_iterate_over_regset_sections): Likewise.
* mips-nbsd-tdep.c (mipsnbsd_iterate_over_regset_sections): Likewise.
* mips64-obsd-tdep.c (mips64obsd_iterate_over_regset_sections): Likewise.
* mn10300-linux-tdep.c (am33_iterate_over_regset_sections): Likewise.
* nios2-linux-tdep.c (nios2_iterate_over_regset_sections): Likewise.
* ppc-fbsd-tdep.c (ppcfbsd_iterate_over_regset_sections): Likewise.
* ppc-linux-tdep.c (ppc_linux_iterate_over_regset_sections): Likewise.
* ppc-nbsd-tdep.c (ppcnbsd_iterate_over_regset_sections): Likewise.
* ppc-obsd-tdep.c (ppcobsd_iterate_over_regset_sections): Likewise.
* riscv-linux-tdep.c (riscv_linux_iterate_over_regset_sections): Likewise.
* rs6000-aix-tdep.c (rs6000_aix_iterate_over_regset_sections): Likewise.
* s390-linux-tdep.c (s390_iterate_over_regset_sections): Likewise.
* score-tdep.c (score7_linux_iterate_over_regset_sections): Likewise.
* sh-tdep.c (sh_iterate_over_regset_sections): Likewise.
* sparc-tdep.c (sparc_iterate_over_regset_sections): Likewise.
* tilegx-linux-tdep.c (tilegx_iterate_over_regset_sections): Likewise.
* vax-tdep.c (vax_iterate_over_regset_sections): Likewise.
* xtensa-tdep.c (xtensa_iterate_over_regset_sections): Likewise.
GDB Administrator [Mon, 13 Aug 2018 00:00:51 +0000 (00:00 +0000)]
Automatic date update in version.in
H.J. Lu [Sun, 12 Aug 2018 12:39:00 +0000 (05:39 -0700)]
ld-x86-64/pr23486b.d: Swap pr23486a.s and pr23486a.s
Swap pr23486a.s and pr23486a.s so that pr23486b.d differs from pr23486a.d.
* testsuite/ld-x86-64/pr23486b.d: Swap pr23486a.s and pr23486a.s.
GDB Administrator [Sun, 12 Aug 2018 00:01:17 +0000 (00:01 +0000)]
Automatic date update in version.in
H.J. Lu [Sat, 11 Aug 2018 21:37:14 +0000 (14:37 -0700)]
x86: Add CpuCMOV and CpuFXSR
There are separate CPUID feature bits for fxsave/fxrstor and cmovCC
instructions. This patch adds CpuCMOV and CpuFXSR to replace Cpu686
on corresponding instructions.
gas/
* config/tc-i386.c (cpu_arch): Add .cmov and .fxsr.
(cpu_noarch): Add nocmov and nofxsr.
* doc/c-i386.texi: Document cmov and fxsr.
opcodes/
* i386-gen.c (cpu_flag_init): Add CpuCMOV and CpuFXSR to
CPU_I686_FLAGS. Add CPU_CMOV_FLAGS, CPU_FXSR_FLAGS,
CPU_ANY_CMOV_FLAGS and CPU_ANY_FXSR_FLAGS.
(cpu_flags): Add CpuCMOV and CpuFXSR.
* i386-opc.tbl: Replace Cpu686 with CpuFXSR on fxsave, fxsave64,
fxrstor and fxrstor64. Replace Cpu686 with CpuCMOV on cmovCC.
* i386-init.h: Regenerated.
* i386-tbl.h: Likewise.
H.J. Lu [Sat, 11 Aug 2018 13:41:33 +0000 (06:41 -0700)]
x86: Properly add X86_ISA_1_NEEDED property
Existing properties may be removed during property merging. We avoid
adding X86_ISA_1_NEEDED property only if existing properties won't be
removed.
bfd/
PR ld/23428
* elfxx-x86.c (_bfd_x86_elf_link_setup_gnu_properties): Don't
add X86_ISA_1_NEEDED property only if existing properties won't
be removed.
ld/
PR ld/23428
* testsuite/ld-elf/dummy.s: New file.
* testsuite/ld-elf/linux-x86.S: Add X86_FEATURE_1_AND property.
* testsuite/ld-elf/linux-x86.exp: Add dummy.s to pr23428.
Alan Modra [Sat, 11 Aug 2018 01:37:07 +0000 (11:07 +0930)]
Factor out common relocation processing
This patch factors out some code common to both bfd_perform_relocation
and bfd_install_relocation, in the process fixing the omission of
"case -1" in bfd_install_relocation.
* reloc.c (bfd_get_reloc_size): Sort switch.
(read_reloc, write_reloc, apply_reloc): New functions.
(bfd_perform_relocation, bfd_install_relocation): Use apply_reloc.
(_bfd_relocate_contents): Use read_reloc and write_reloc.
(_bfd_clear_contents): Likewise.
John Darrington [Thu, 9 Aug 2018 16:46:51 +0000 (18:46 +0200)]
Deal with relocations which are 3 bytes in size
* reloc.c (_bfd_relocate_contents): Handle 3 byte relocs.
(_bfd_clear_contents): Likewise.
(bfd_perform_relocation): Likewise.
(bfd_install_relocation): Likewise.
GDB Administrator [Sat, 11 Aug 2018 00:00:27 +0000 (00:00 +0000)]
Automatic date update in version.in
Simon Marchi [Fri, 10 Aug 2018 22:01:11 +0000 (18:01 -0400)]
Fix forgotten xstrprintf -> string_printf change
The patch
528e157 ("Replace some uses of xstrprintf with string_printf")
forgot to actually change an xstrprintf call to string_printf, this one
fixes it.
gdb/ChangeLog:
* nat/linux-osdata.c (commandline_from_pid): Replace xstrprintf
with string_printf.
H.J. Lu [Fri, 10 Aug 2018 19:21:58 +0000 (12:21 -0700)]
Always clear h->verinfo.verdef when overriding a dynamic definition
When linker defines a symbol to override a dynamic definition, it should
always clear h->verinfo.verdef so that the symbol won't be associated
with the version information from the dynamic object. This happened to
the symbol "_edata" when creating an unversioned dynamic object linking
against:
1. libKF5ConfigCore.so.5.49.0
2. libKF5CoreAddons.so.5.49.0
3. libKF5I18n.so.5.49.0
4. libKF5DBusAddons.so.5.49.0
5. libQt5Xml.so.5.11.1
6. libQt5DBus.so.5.11.1
7. libQt5Core.so.5.11.1
Among them
libQt5Xml.so.5.11.1
299:
000000000003e000 0 NOTYPE GLOBAL DEFAULT 18 _edata@@Qt_5
libQt5DBus.so.5.11.1
597:
0000000000092018 0 NOTYPE GLOBAL DEFAULT 18 _edata@@Qt_5
libQt5Core.so.5.11.1
2292:
00000000004df640 0 NOTYPE GLOBAL DEFAULT 21 _edata@Qt_5
2293:
00000000004df640 0 NOTYPE GLOBAL DEFAULT 21 _edata@Qt_5
The problem is triggered by 2 duplicated entries of _edata@Qt_5 in
libQt5Core.so.5.11.1 which was created by gold. Before this commit,
ld created the dynamic object with "_edata" in its dynamic symbol table
which was linker defined and associated with the version information
from libQt5Core.so.5.11.1. The code in question was there when the
binutils source was imported to sourceware.org. When such a dynamic
object was used later, we got:
/usr/bin/ld: bin/libKF5Service.so.5.49.0: _edata: invalid version 21 (max 0)
/usr/bin/ld: bin/libKF5Service.so.5.49.0: error adding symbols: bad value
Tested with many ELF targets.
PR ld/23499
* elflink.c (bfd_elf_record_link_assignment): Always clear
h->verinfo.verdef when overriding a dynamic definition.
Keith Seitz [Fri, 10 Aug 2018 18:01:24 +0000 (11:01 -0700)]
Use policies for code generation
This patch changes code generation procedures add_code_header,
add_code_footer, and several other language-specific code generation
functions into policies.
gdb/ChangeLog:
* compile/compile-c-support.c (add_code_header, add_code_footer):
Move into policy class.
(c_push_user_expression, pop_user_expression_nop)
(c_add_code_header, c_add_code_footer, c_add_input): New policy class.
(compile_program): New host class.
(c_compile_program): New typedef.
(c_compute_porgram): Use c_compile_program.
Keith Seitz [Fri, 10 Aug 2018 17:53:47 +0000 (10:53 -0700)]
Use unique_ptr for htabs
This patch updates the type-conversion caching in C compile to use
unique pointers. This patch also removes the on-demand allocation of the
symbol error map in favor of initialization, simplifying the code.
gdb/ChangeLog
* compile/compile-internal.h (compile_instance::~compile_instance):
Remove calls to htab_delete.
<m_type_map, m_symbol_err_map>: Switch type to htab_up.
* compile.c (compile_instance::compile_instance): Initialize
htab unique pointers.
(compile_instance::get_cached_type, compile_instance::insert_type)
(compile_instance::error_symbol_once): Update for unique_ptr.
Keith Seitz [Fri, 10 Aug 2018 17:52:13 +0000 (10:52 -0700)]
Move compile_instance to compile.c
This simple patch moves any code related to compile_instance into
compile.c, reserving compile-c-* files strictly for C language support.
gdb/ChangeLog:
* compile/compile-c-symbols.c (struct symbol_error)
(hash_symbol_error, eq_symbol_error, del_symbol_error)
(compile_instance::insert_symbol_error)
(compile_instance::error_symbol_once): Move to ...
* compile/compile.c: ... here.
Keith Seitz [Fri, 10 Aug 2018 17:48:03 +0000 (10:48 -0700)]
Change compile_instance/compile_c_instance into classes
This patch changes structs compile_instance and compile_c_instance into
classes.
Because of the nature of the change, there are a number of unavoidably
mechanical changes buried in here, such as turning variable access of the
POD struct into method calls, removing the struct keyword, and changing
access of the plugin from "c_plugin->operation()" to
"plugin ().operation ()".
There is one "non-trivial" change associated with this patch, though.
The type cache and symbol error maps have been moved into the base class,
believing these facilities would be used other language implementations.
[They are indeed re-used by C++.]
gdb/ChangeLog:
* compile/compile-c-support.c (c_get_compile_context): Use `new'
instead of `new_compile_instance'.
* compile/compile-c-symbols.c (compile_instance::insert_symbol_error):
Update description.
If the symbol error map is not initialized, create it.
(generate_c_for_for_one_symbol): Do not check/initialize
the symbol error map.
* compile/compile-c-types.c (compile_c_instance): Make a class.
Update all callers.
(compile_instance::compile_instance): Initialize the type cache.
(get_cached_type): New function.
(insert_type): Update description.
(compile_c_instance::m_default_cflags): Define.
(convert_type): Update description. Use get_cached_type.
(delete_instance): Moved to destructor.
(new_compile_instance): Moved to constructor.
* compile/compile-c.h (compile_c_instance): Make class inheriting
from compile_instance.
<base>: Remove field.
<type_map, symbol_err_map>: Move to base class.
<c_plugin>: Rename to `m_plugin' and remove pointer type.
* compile/compile-internal.h (compile_instance): Make class.
<type_map_t, symbol_err_map_t>: Define.
<fe>: Rename to `m_gcc_fe'.
<scope, block, gcc_target_options>: Add `m_' prefix.
<m_type_map, m_symbol_err_map>: New fields, moved from
compile_c_instance.
<destroy>: Remove.
(convert_type, new_compile_instance): Remove.
* compile/compile.c (cleanup_compile_instance): Remove.
(compile_to_object): Use unique_ptr to eliminate cleanups.
(compile_instance::set_print_callback, compile_instance::version)
(compile_instance::set_verbose)
(compile_instance::set_driver_filename)
(compile_instance::set_triplet_regexp)
(compile_instance::set_arguments)
(compile_instance::set_source_file)
(compile_instance::compile): Define.
Keith Seitz [Fri, 10 Aug 2018 17:45:36 +0000 (10:45 -0700)]
Add a C++ wrapper for GCC C plug-in
This patch introduces a new class which wraps the GCC C compile plug-in.
It is a little unfortunate that this all happened in between the time that
GCC moved to C++ and GDB moved to C++, leaving us with an ABI promise to
support a C-like interface. The hope is to isolate GDB from some of this
should it change in the future.
Broadly, what this does is replace calls like:
C_CTX (context)->c_ops->operation (C_CTX (context), ...);
with calls that now look like:
context->c_plugin->operation (...);
This API will be further refined in following patches when struct
compile_instance/compile_c_instance are changed into classes.
gdb/ChangeLog:
* Makefile.in (HFILES_NO_SRCDIR): Add compile/gcc-c-plugin.h.
* compile/compile-c-types.c: Define GCC_METHODN macros and include
gcc-c-fe.def to define C plugin.
(delete_instance): Delete `c_plugin'.
(new_compile_instance): Initialize `c_plugin'.
* compile/compile-c.h: Include gcc_c_plugin.h.
(struct compile_c_instance) <c_plugin>: New member.
* gcc-c-plugin.h: New file.
Update all callers with API change.
Keith Seitz [Fri, 10 Aug 2018 17:43:17 +0000 (10:43 -0700)]
Move C-related declarations to compile-c.h
This patch simply moves a bunch of C language-related declarations from
the various compile header files into a new C-specific header, compile-c.h.
gdb/ChangeLog:
* Makefile.in (SUBDIR_GCC_COMPILE_SRCS): Move header files ...
(HFILES_NO_SRCDIR): ... to here.
Add compile-internal.h and compile-c.h.
* compile/compile-c-support.c: Include compile-c.h.
* compile/compile-c-symbols.c: Include compile-c.h.
(generate_c_for_variable_locations): Update comment.
* compile/compile-c-types.c: Include compile-c.h.
* compile/compile-c.h: New file -- moved C language declarations
from other files here.
* compile/compile-internal.h: Do not include hashtab.h or
common/enum-flags.h.
(gcc_qualifiers_flags, struct compile_c_instance, C_CTX)
(gcc_convert_symbol, gcc_symbol_address)
(generate_c_for_variable_locations, c_get_mode_for_size)
(c_get_range_decl_name): Definitions moved to compile-c.h.
* compile/compile-loc2c.c: Include compile-c.h.
Keith Seitz [Fri, 10 Aug 2018 17:41:37 +0000 (10:41 -0700)]
Rename symbol_substitution_name
This patch simply adds a "c_" prefix to symbol_substitution_name to clarify
that this is a C language-related function.
gdb/ChangeLog:
* compile/compile-c-symbols.c (symbol_substitution_name): Rename to ...
(c_symbol_substitution_name): ... this.
Update all callers.
Keith Seitz [Fri, 10 Aug 2018 17:38:56 +0000 (10:38 -0700)]
Return unique_xmalloc_ptr for generate_c_for_variable_locations
This patch eliminates two cleanups in compile/ by changing
generate_c_for_variable_locations so that it returns a unique_ptr.
gdb/ChangeLog:
* compile/compile-c-support.c (c_compute_program): Use
unique_xmalloc_ptr to eliminate cleanup.
* compile/compile-c-symbols.c (generate_c_for_variable_locations):
Return a unique_xmalloc_ptr and eliminate cleanup.
* compile/compile-internal.h (generate_c_for_variable_locations):
Return unique_xmalloc_ptr and update description.
H.J. Lu [Fri, 10 Aug 2018 18:03:50 +0000 (11:03 -0700)]
x86: Don't display --32/--64/--x32 without BFD64
For 32-bit x86 assembler, --64 and --x32 are unsupported if BFD64 is
undefined. Even if BFD64 is defined, --64 and --x32 still may not be
supported if x86-64 support isn't compiled in:
[hjl@gnu-hsw-1 gas]$ ./as-new --64 -o x.o x.s
Assembler messages:
Fatal error: no compiled in support for x86_64
[hjl@gnu-hsw-1 gas]$ ./as-new --x32 -o x.o x.s
Assembler messages:
Fatal error: no compiled in support for 32bit x86_64
[hjl@gnu-hsw-1 gas]$
This patch removes --32/--64/--x32 from md_show_usage if BFD64 is
undefined and runs code64-inval only if BFD64 is undefined.
* config/tc-i386.c (md_show_usage): Don't display --32/--64/--x32
if BFD64 is undefined.
* testsuite/gas/i386/i386.exp (gas_bfd64_check): New.
Run code64-inval if gas_bfd64_check fails.
H.J. Lu [Fri, 10 Aug 2018 17:23:11 +0000 (10:23 -0700)]
x86: Replace evex-no-scale.s with evex-no-scale-[32|64].s
.if is_64bit
vmovaps -1024(%rip), %zmm0
vmovaps 64(,%rax), %zmm0
vmovaps 64(,%riz), %zmm0
.endif
doesn't with i686-elf cross binutils on 64-bit hosts:
evex-no-scale.s: Assembler messages:
evex-no-scale.s:10: Error: bad register name `%rip)'
evex-no-scale.s:11: Error: bad register name `%rax)'
evex-no-scale.s:12: Error: bad register name `%riz)'
This patch replaces evex-no-scale.s with evex-no-scale-32.s and
evex-no-scale-64.s.
* testsuite/gas/i386/evex-no-scale-32.d: Don't use
evex-no-scale.s.
* testsuite/gas/i386/evex-no-scale-64.d: Likewise.
* testsuite/gas/i386/evex-no-scale-32.s: New file.
* testsuite/gas/i386/evex-no-scale-64.s: Likewise.
* testsuite/gas/i386/evex-no-scale.s: Removed.
H.J. Lu [Thu, 9 Aug 2018 11:29:43 +0000 (04:29 -0700)]
Always use align_size as pr_datasz for GNU_PROPERTY_STACK_SIZE
For GNU_PROPERTY_STACK_SIZE, pr_datasz is the same as align_size, which
is 8 bytes for 64-bit ELF binaries and 4 bytes for 32-bit ELF binaries,
Use align_size as pr_datasz for GNU_PROPERTY_STACK_SIZE to convert
.note.gnu.property section.
bfd/
PR binutils/23494
* elf-properties.c (elf_get_gnu_property_section_size): Always
use align_size as pr_datasz for GNU_PROPERTY_STACK_SIZE.
(elf_write_gnu_properties): Likewise.
binutils/
PR binutils/23494
* testsuite/binutils-all/x86-64/pr23494c.s: New file.
* testsuite/binutils-all/x86-64/pr23494e-x32.d: Likewise.
* testsuite/binutils-all/x86-64/pr23494e.d: Likewise.
H.J. Lu [Fri, 10 Aug 2018 14:53:50 +0000 (07:53 -0700)]
Skip PR binutils/23494 tests for nacl targets
PR binutils/23494 tests pass "-O elf64-x86-64" and "-O elf32-x86-64"
to objcopy which may not supported for nacl targets. This patch skips
these tests for nacl targets.
* testsuite/binutils-all/x86-64/pr23494a-x32.d: Skip nacl
targets.
* testsuite/binutils-all/x86-64/pr23494a.d: Likewise.
* testsuite/binutils-all/x86-64/pr23494b-x32.d: Likewise.
* testsuite/binutils-all/x86-64/pr23494b.d: Likewise.
* testsuite/binutils-all/x86-64/pr23494c-x32.d: Likewise.
* testsuite/binutils-all/x86-64/pr23494c.d: Likewise.
* testsuite/binutils-all/x86-64/pr23494d-x32.d: Likewise.
* testsuite/binutils-all/x86-64/pr23494d.d: Likewise.
Alan Hayward [Fri, 10 Aug 2018 09:17:12 +0000 (10:17 +0100)]
Rename size in get_core_register_section
Make it clearer that the size field indicates the size of the section.
gdb/
* corelow.c (core_target::get_core_register_section): Rename
min_size to section_min_size.
GDB Administrator [Fri, 10 Aug 2018 00:00:26 +0000 (00:00 +0000)]
Automatic date update in version.in
Jim Wilson [Thu, 9 Aug 2018 20:37:45 +0000 (13:37 -0700)]
RISC-V: Add configure support for riscv*-linux*.
This adds the target and native configure support, and the NEWS entries for
the new target and native configurations.
gdb/
* Makefile.in (ALL_TARGET_OBS): Add riscv-linux-tdep.c.
(ALLDEPFILES): Add riscv-linux-nat.c, and riscv-linux-tdep.c.
* NEWS: Mention new GNU/Linux RISC-V target.
* configure.host: Add riscv*-*-linux*.
* configure.nat: Add riscv*.
* configure.tgt: Add riscv*-*-linux*.
Jim Wilson [Thu, 9 Aug 2018 20:35:24 +0000 (13:35 -0700)]
RISC-V: Add native linux support.
Add initial native support for riscv*-linux*.
gdb/
* riscv-linux-nat.c: New file.
Jim Wilson [Thu, 9 Aug 2018 20:33:36 +0000 (13:33 -0700)]
RISC-V: Add linux target support.
Add initial target support for riscv*-linux*.
gdb/
* riscv-linux-tdep.c: New file.
Andrew Burgess [Wed, 11 Jul 2018 09:41:55 +0000 (10:41 +0100)]
gdb: Make infrun.c:resume function static
Make the infrun.c:resume function static, and update the header
comment on the infrun.c:proceed function. There should be no user
visible change after this commit.
gdb/ChangeLog:
* infrun.c (resume): Make static, add forward declaration.
(proceed): Update header comment.
* infrun.h (resume): Delete declaration.
Tom Tromey [Thu, 9 Aug 2018 16:46:01 +0000 (10:46 -0600)]
Minor formatting fixes in riscv-tdep.h
This fixes some minor formatting issues in riscv-tdep.h, including one
pointed out by ARI.
ChangeLog
2018-08-09 Tom Tromey <tom@tromey.com>
* riscv-tdep.h: Minor formatting fixes.
Simon Marchi [Thu, 9 Aug 2018 17:17:21 +0000 (13:17 -0400)]
Fix some gettext ARI warnings
ARI produces this warning for the lines touched in this patch:
warning: gettext: All messages should be marked up with _.
However, in these cases, the message is not translatable (they are
syscall names). Adding an extra set of parentheses silences the
warning.
gdb/ChangeLog:
* common/scoped_mmap.c (mmap_file): Silence ARI warning.
* dwarf-index-cache.c (create_dir_and_check): Likewise.
(test_mkdir_recursive): Likewise.
* dwarf-index-write.c (write_psymtabs_to_index): Likewise.
H.J. Lu [Thu, 9 Aug 2018 16:57:11 +0000 (09:57 -0700)]
as --help: Display default option for --elf-stt-common=
* as.c (show_usage): Display default option for --elf-stt-common=.
H.J. Lu [Thu, 9 Aug 2018 16:48:12 +0000 (09:48 -0700)]
x86: Display default x86-specific options for "as --help"
* config/tc-i386.c (md_show_usage): Display default options.
Andrew Burgess [Wed, 25 Jul 2018 16:33:08 +0000 (17:33 +0100)]
gdb: Check element of optimised out vla exists
If a vla is not in memory, and the upper bound is not defined, then we
can't know that an array element exists or not, and we should not try
to access the array element. One case where this happens is for
arrays that have been optimised out, the array will then have
VALUE_LVAL of not_lval, and an undefined upper bound, if we then try
to access an element of this array we will index into random GDB
memory.
An argument could be made that even for arrays that are in inferior
memory, if the upper bound is not defined then we should not try to
access the array element, however, in some of the Fortran tests, it
seems as though we do rely indexing from a base address into an array
which has no bounds defined. In this case GDBs standard protection
for detecting unreadable target memory prevents bad thing happening.
gdb/ChangeLog:
* valarith.c (value_subscripted_rvalue): If an array is not in
memory, and we don't know the upper bound, then we can't know that
the requested element exists or not.
gdb/testsuite/ChangeLog:
* gdb.base/vla-optimized-out.exp: Add new test.
Andrew Burgess [Sat, 28 Jul 2018 19:55:04 +0000 (20:55 +0100)]
gdb: Merge similar tests into a single test script
The three test scripts:
gdb/testsuite/gdb.base/vla-optimized-out.exp
gdb/testsuite/gdb.base/vla-optimized-out-o3.exp
gdb/testsuite/gdb.base/vla-optimized-out-o3-strict.exp
are all pretty similar, with differences in the compile flags used,
and some of the expected results.
Instead of maintaining 3 files, merge them into a single test script,
and use parameters to control the test behaviour.
gdb/testsuite/ChangeLog:
* gdb.base/vla-optimized-out-o3.exp: Delete.
* gdb.base/vla-optimized-out-o3-strict.exp: Delete.
* gdb.base/vla-optimized-out.exp: Extend to cover all of the
deleted tests.
Richard Earnshaw [Thu, 9 Aug 2018 15:51:09 +0000 (16:51 +0100)]
arm - Add some comments about the versions of ARM ELF that define various e_flags values
This patch adds a few comments to include/elf/arm.h to clarify which
versions of the ARM ELF specification defined which headers. Given
that the EABI is pretty ubiquitous these days, I've marked anything
not based on that as deprecated.
There are no plans to remove any deprecated definitions at this time,
but any new development shouldn't be building upon support for
deprecated definitions remaining in the long term.
* elf/arm.h: Updated comments for e_flags definitions.
H.J. Lu [Thu, 9 Aug 2018 04:00:04 +0000 (21:00 -0700)]
Convert .note.gnu.property section between ELF32 and ELF64
.note.gnu.property section has different alignments and section
sizes for 32-bit and 64-bit ELF binaries. This patch updated
bfd_convert_section_size and bfd_convert_section_contents to
properly convert .note.gnu.property section between 32-bit and
64-bit ELF binaries.
bfd/
PR binutils/23494
* bfd.c (bfd_convert_section_size): Check BFD_DECOMPRESS after
calling _bfd_elf_convert_gnu_property_size to convert
.note.gnu.property section size.
(bfd_convert_section_contents): Check BFD_DECOMPRESS after
calling _bfd_elf_convert_gnu_properties to convert
.note.gnu.property section.
* elf-bfd.h (_bfd_elf_convert_gnu_property_size): New prototype.
(_bfd_elf_convert_gnu_properties): Likewise.
* elf-properties.c (elf_get_gnu_property_section_size): New
function.
(elf_write_gnu_properties): Likewise.
(_bfd_elf_convert_gnu_property_size): Likewise.
(_bfd_elf_convert_gnu_properties): Likewise.
(_bfd_elf_link_setup_gnu_properties): Use
elf_get_gnu_property_section_size and elf_write_gnu_properties.
binutils/
PR binutils/23494
* testsuite/binutils-all/x86-64/pr23494a-x32.d: New file.
* testsuite/binutils-all/x86-64/pr23494a.d: Likewise.
* testsuite/binutils-all/x86-64/pr23494a.s: Likewise.
* testsuite/binutils-all/x86-64/pr23494b-x32.d: Likewise.
* testsuite/binutils-all/x86-64/pr23494b.d: Likewise.
* testsuite/binutils-all/x86-64/pr23494b.s: Likewise.
* testsuite/binutils-all/x86-64/pr23494c-x32.d: Likewise.
* testsuite/binutils-all/x86-64/pr23494c.d: Likewise.
* testsuite/binutils-all/x86-64/pr23494d-x32.d: Likewise.
* testsuite/binutils-all/x86-64/pr23494d.d: Likewise.
GDB Administrator [Thu, 9 Aug 2018 00:00:26 +0000 (00:00 +0000)]
Automatic date update in version.in
Simon Marchi [Wed, 8 Aug 2018 22:13:18 +0000 (18:13 -0400)]
Fix some comments in target.c
Fix a typo and add a missing one.
gdb/ChangeLog:
* target.c (str_comma_list_concat_elem): Fix typo in comment.
(target_options_to_string): Add comment.
Tom Tromey [Wed, 8 Aug 2018 17:57:39 +0000 (11:57 -0600)]
Check result of "write"
Some distros enable _FORTIFY_SOURCE by default, which caught a failure
to check the result of "write" in scoped_mmap-selftests.c. This patch
fixes the problem.
ChangeLog
2018-08-08 Tom Tromey <tom@tromey.com>
* unittests/scoped_mmap-selftests.c: Check result of "write".
Jim Wilson [Wed, 8 Aug 2018 17:53:12 +0000 (10:53 -0700)]
RISC-V: Add software single step support.
This adds software single step support that is needed by the linux native port.
This is modeled after equivalent code in the MIPS port.
This also fixes a few bugs in the compressed instruction decode support. Some
instructions are RV32/RV64 specific, and this wasn't being checked. Also, a
few instructions were accidentally using the non-compressed is_* function.
This has been tested on a HiFive Unleashed running Fedora, by putting a
breakpoint on start, typing stepi, and then holding down the return key until
it finishes, and observing that I see everything I expect to see along the way.
There is a problem in _dl_addr where I get into an infinite loop, but it seems
to be some synchronization code that doesn't agree with single step, so I have
to find the end of the loop, put a breakpoint there, continue, and then single
step again until the end.
gdb/
* riscv-tdep.c (enum opcode): Add jump, branch, lr, and sc opcodes.
(decode_register_index_short): New.
(decode_j_type_insn, decode_cj_type_insn): New.
(decode_b_type_insn, decode_cb_type_insn): New.
(riscv_insn::decode): Add support for jumps, branches, lr, and sc. New
local xlen. Check xlen when decoding ambiguous compressed insns. In
compressed decode, use is_c_lui_insn instead of is_lui_insn, and
is_c_sw_insn instead of is_sw_insn.
(riscv_next_pc, riscv_next_pc_atomic_sequence): New.
(riscv_software_single_step): New.
* riscv-tdep.h (riscv_software_single_step): Declare.
Jim Wilson [Wed, 8 Aug 2018 17:48:09 +0000 (10:48 -0700)]
RISC-V: Make riscv_isa_xlen a global function.
This allows the function to be used from riscv OS files, which also need to
depend on XLEN size.
gdb/
* riscv-tdep.c (riscv_isa_xlen): Drop static.
* riscv-tdep.h (riscv_isa_xlen): Add extern declaration.
Kevin Buettner [Mon, 30 Jul 2018 22:35:45 +0000 (15:35 -0700)]
Add support for DW_OP_GNU_variable_value to readelf
As indicated by the subject, this patch adds support for the DWARF
expression opcode DW_OP_GNU_variable_value to readelf.
It's pretty much a copy/paste of DW_OP_call_ref with the obvious name
changes for the printf statements. The FIXME comment comes from that
copy/paste.
binutils/ChangeLog:
* dwarf.c (decode_location_expresion): Add case for
DW_OP_GNU_variable_value.
H.J. Lu [Wed, 8 Aug 2018 13:09:15 +0000 (06:09 -0700)]
x86: Properly merge GNU_PROPERTY_X86_ISA_1_USED
Without the GNU_PROPERTY_X86_ISA_1_USED property, all ISAs may be used.
If a bit in the GNU_PROPERTY_X86_ISA_1_USED property is unset, the
corresponding x86 instruction set isn’t used. When merging properties
from 2 input files and one input file doesn't have the
GNU_PROPERTY_X86_ISA_1_USED property, the output file shouldn't have
it neither. This patch removes the GNU_PROPERTY_X86_ISA_1_USED
property if an input file doesn't have it.
This patch replaces the GNU_PROPERTY_X86_ISA_1_USED property with the
GNU_PROPERTY_X86_ISA_1_NEEDED property which is the minimum ISA
requirement.
bfd/
PR ld/23486
* elfxx-x86.c (_bfd_x86_elf_merge_gnu_properties): Remove
GNU_PROPERTY_X86_ISA_1_USED if an input file doesn't have it.
(_bfd_x86_elf_link_setup_gnu_properties): Adding the
GNU_PROPERTY_X86_ISA_1_NEEDED, instead of
GNU_PROPERTY_X86_ISA_1_USED, property.
ld/
PR ld/23486
* testsuite/ld-i386/i386.exp: Run PR ld/23486 tests.
* testsuite/ld-x86-64/x86-64.exp: Likewise.
* testsuite/ld-i386/pr23486a.d: New file.
* testsuite/ld-i386/pr23486b.d: Likewise.
* testsuite/ld-x86-64/pr23486a-x32.d: Likewise.
* testsuite/ld-x86-64/pr23486a.d: Likewise.
* testsuite/ld-x86-64/pr23486a.s: Likewise.
* testsuite/ld-x86-64/pr23486b-x32.d: Likewise.
* testsuite/ld-x86-64/pr23486b.d: Likewise.
* testsuite/ld-x86-64/pr23486b.s: Likewise.
* testsuite/ld-i386/property-3.r: Remove "x86 ISA used".
* testsuite/ld-i386/property-4.r: Likewise.
* testsuite/ld-i386/property-5.r: Likewise.
* testsuite/ld-i386/property-x86-ibt3a.d: Likewise.
* testsuite/ld-i386/property-x86-ibt3b.d: Likewise.
* testsuite/ld-i386/property-x86-shstk3a.d: Likewise.
* testsuite/ld-i386/property-x86-shstk3b.d: Likewise.
* testsuite/ld-x86-64/property-3.r: Likewise.
* testsuite/ld-x86-64/property-4.r: Likewise.
* testsuite/ld-x86-64/property-5.r: Likewise.
* testsuite/ld-x86-64/property-x86-ibt3a-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-ibt3a.d: Likewise.
* testsuite/ld-x86-64/property-x86-ibt3b-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-ibt3b.d: Likewise.
* testsuite/ld-x86-64/property-x86-shstk3a-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-shstk3a.d: Likewise.
* testsuite/ld-x86-64/property-x86-shstk3b-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-shstk3b.d: Likewise.
Andrew Burgess [Fri, 22 Jun 2018 19:39:26 +0000 (20:39 +0100)]
gdb: Fix assert for extended-remote target (PR gdb/18050)
Consider the following GDB session:
(gdb) target extended-remote :2347
(gdb) file /path/to/exe
(gdb) set remote exec-file /path/to/exe
(gdb) set detach-on-fork off
(gdb) break breakpt
(gdb) run
# ... hits breakpoint
(gdb) info inferiors
Num Description Executable
* 1 process 17001 /path/to/exe
2 process 17002 /path/to/exe
(gdb) kill
(gdb) info inferiors
Num Description Executable
* 1 <null> /path/to/exe
2 process 17002 /path/to/exe
(gdb) target extended-remote :2348
../../src/gdb/thread.c:660: internal-error: thread_info* any_thread_of_process(int): Assertion `pid != 0' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Or, from bug PR gdb/18050:
(gdb) start
(gdb) add-inferior -exec /path/to/exe
(gdb) target extended-remote :2347
../../src/gdb/thread.c:660: internal-error: thread_info* any_thread_of_process(int): Assertion `pid != 0' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
The issue is calling target.c:dispose_inferior with a killed inferior in
the inferior list. This assertion is fixed in this commit.
The new test for this issue only runs on platforms that support
'detach-on-fork', and when using
'--target_board=native-extended-gdbserver'.
gdb/ChangeLog:
PR gdb/18050:
* target.c (dispose_inferior): Don't dispose of inferiors that are
already killed.
gdb/testsuite/ChangeLog:
PR gdb/18050:
* gdb.server/extended-remote-restart.c: New file.
* gdb.server/extended-remote-restart.exp: New file.
Szabolcs Nagy [Wed, 8 Aug 2018 10:14:20 +0000 (11:14 +0100)]
Fix gdb/remote.c build failure
Add const qualifier to fix
/S/gdb/common/gdb_locale.h:35:27: error: deprecated conversion from string constant to 'char*' [-Werror=write-strings]
# define _(String) (String)
^
/S/gdb/remote.c:12844:19: note: in expansion of macro '_'
char *err_msg = _("Tracepoint packet too large for target.");
^
gdb/ChangeLog:
* remote.c (remote_target::download_tracepoint): Change char* to
const char*.
Tulio Magno Quites Machado Filho [Wed, 8 Aug 2018 05:39:23 +0000 (22:39 -0700)]
Fix "may be used uninitialized" warning.
* object.cc (Sized_relobj_file::map_to_kept_section): Initialize
kept_file.
Cary Coutant [Wed, 8 Aug 2018 04:35:12 +0000 (21:35 -0700)]
Properly merge GNU_PROPERTY_X86_ISA_1_USED (x86_64).
gold/
PR ld/23486
* x86_64.cc (Target_x86_64::Target_x86_64): Initialize
object_isa_1_used_.
(Target_x86_64::object_isa_1_used_): New data member.
(Target_x86_64::record_gnu_property): Save ISA_1_USED bits for object.
(Target_x86_64::merge_gnu_properties): Merge ISA_1_USED bits.
Simon Marchi [Wed, 8 Aug 2018 02:45:43 +0000 (22:45 -0400)]
Fix gdb.fortran/nested-funcs.exp failure
Commit
87d6a7aa931f ("Add DWARF index cache") broke
gdb.fortran/nested-funcs.exp. Because of the new "set index-cache"
command, the expression "set index = 42" now fails:
set index = 42
Undefined set index-cache command: "= 42". Try "help set index-cache".
(gdb) PASS: gdb.fortran/nested-funcs.exp: set index = 42
Fix it by changing it to "set variable index = 42". Also, use
gdb_test_no_output to confirm that it worked (since that particular test
wrongfully passed).
gdb/testsuite/ChangeLog:
* gdb.fortran/nested-funcs.exp: Replace "set index = 42" with
"set variable index = 42".
Simon Marchi [Wed, 8 Aug 2018 01:37:40 +0000 (21:37 -0400)]
Make target_options_to_string return an std::string
Return an std::string instead of a char *, saving some manual freeing.
I only manually tested with "set debug target 1" and "set debug lin-lwp
1", since this only deals with debug output.
gdb/ChangeLog:
* target.h (target_options_to_string): Return an std::string.
* target.c (str_comma_list_concat_elem): Return void, use
std::string.
(do_option): Likewise.
(target_options_to_string): Return an std::string.
* linux-nat.c (linux_nat_target::wait): Adjust.
* target-debug.h (target_debug_print_options): Adjust.
GDB Administrator [Wed, 8 Aug 2018 00:00:29 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom Tromey [Tue, 7 Aug 2018 18:07:36 +0000 (12:07 -0600)]
Allow CPPFLAGS to be set on the make command line
While looking into PR build/8751 (which seems to be fixed), I noticed
that it's not possible to change CPPFLAGS for gdb on the "make"
command line. It's reasonable to want to do this sometimes, and I
think this patch should suffice.
gdb/ChangeLog
2018-08-07 Tom Tromey <tom@tromey.com>
* Makefile.in (CPPFLAGS): New variable.
(INTERNAL_CPPFLAGS): Use it.
Simon Marchi [Tue, 7 Aug 2018 22:15:28 +0000 (18:15 -0400)]
Add doc and news for DWARF index cache
New in v3:
- Address Eli's comments.
This patch adds doc and news for the feature introduced by the previous
patch.
gdb/ChangeLog:
* NEWS: Mention the index cache.
gdb/doc/ChangeLog:
* gdb.texinfo (Index Files Speed Up GDB): Add section about
symbol index cache.
Simon Marchi [Tue, 7 Aug 2018 22:14:20 +0000 (18:14 -0400)]
Add DWARF index cache
New in v3:
- Remove things related to the dwarf-5 format.
- Fix compilation on mingw (scoped_mmap.c).
GDB can generate indexes for DWARF debug information, which, when
integrated in the original binary, can speed up loading object files.
This can be done using the gdb-add-index script or directly by the
linker itself. However, not many people know about this. And even
among those who do, because it requires additional steps, I don't know a
lot of people who actually go through that trouble.
To help make using the DWARF index more transparent, this patch
introduces a DWARF index cache. When enabled, loading an index-less
binary in GDB will automatically save an index file in ~/.cache/gdb.
When loading that same object file again, the index file will be looked
up and used to load the DWARF index. You therefore get the benefit of
the DWARF index without having to do additional manual steps or
modifying your build system. When an index section is already present
in the file, GDB will prefer that one over looking up the cache.
When doing my edit-compile-debug cycle, I often debug multiple times the
same build, so the cache helps reducing the load time of the debug
sessions after the first one.
- The saved index file is exactly the same as the output of the "save
gdb-index" command. It is therefore the exact same content that would
be found in the .gdb_index or .debug_names section. We just leave it
as a standalone file instead of merging it in the binary.
- The cache is just a directory with files named after the object
file's build-id. It is not possible to save/load the index for an
object file without build-id in the cache.
- The cache uses the gdb index format. The problem with the dwarf-5
format is that we can generate an addendum to the .debug_str section
that you're supposed to integrate to the original binary. This
complicates a little bit loading the data from the cached index files,
so I would leave this for later.
- The size taken up by ~/.cache/gdb is not limited. I was thinking we
could add configurable limit (like ccache does), but that would come
after. Also, maybe a command to flush the cache.
- The cache is disabled by default. I think once it's been out there
and tested for a while, it could be turned on by default, so that
everybody can enjoy it.
- The code was made to follow the XDG specification: if the
XDG_CACHE_HOME environment variable, it is used, otherwise it falls
back to ~/.cache/gdb. It is possible to change it using "set
index-cache directory". On other OSes than GNU/Linux, ~/.cache may
not be the best place to put such data. On macOS it should probably
default to ~/Library/Caches/... On Windows, %LocalAppData%/... I
don't intend to do this part, but further patches are welcome.
- I think that we need to be careful that multiple instances of GDB
don't interfere with each other (not far fetched at all if you run GDB
in some automated script) and the cache is always coherent (either the
file is not found, or it is found and entirely valid). Writing the
file directly to its final location seems like a recipe for failure.
One GDB could read a file in the index while it is being written by
another GDB. To mitigate this, I made write_psymtabs_to_index write
to temporary files and rename them once it's done. Two GDB instances
writing the index for the same file should not step on each other's
toes (the last file to be renamed will stay). A GDB looking up a file
will only see a complete file or no file. Also, if GDB crashes while
generating the index file, it will leave a work-in-progress file, but
it won't be picked up by other instances looking up in the cache.
gdb/ChangeLog:
* common/pathstuff.h (get_standard_cache_dir): New.
* common/pathstuff.c (get_standard_cache_dir): New.
* build-id.h (build_id_to_string): New.
* dwarf-index-common.h (INDEX4_SUFFIX, INDEX5_SUFFIX,
DEBUG_STR_SUFFIX): Move to here.
* dwarf-index-write.c (INDEX4_SUFFIX, INDEX5_SUFFIX,
DEBUG_STR_SUFFIX): Move from there.
(write_psymtabs_to_index): Make non-static, add basename
parameter. Write to temporary files, rename when done.
(save_gdb_index_command): Adjust call to
write_psymtabs_to_index.
* dwarf2read.h (dwarf2_per_objfile) <index_cache_res>: New
field.
* dwarf2read.c (dwz_file) <index_cache_res>: New field.
(get_gdb_index_contents_from_cache): New.
(get_gdb_index_contents_from_cache_dwz): New.
(dwarf2_initialize_objfile): Read index from cache.
(dwarf2_build_psymtabs): Save to index.
* dwarf-index-cache.h: New file.
* dwarf-index-cache.c: New file.
* dwarf-index-write.h: New file.
gdb/testsuite/ChangeLog:
* boards/index-cache-gdb.exp: New file.
* gdb.dwarf2/index-cache.exp: New file.
* gdb.dwarf2/index-cache.c: New file.
* gdb.base/maint.exp: Check if we are using the index cache.
Simon Marchi [Tue, 7 Aug 2018 22:13:52 +0000 (18:13 -0400)]
Import gnulib's mkdir module
The following patch makes use of the mkdir function. Import the mkdir
gnulib module to ensure proper operation on all platforms.
gdb/ChangeLog:
* gnulib/aclocal.m4: Re-generate.
* gnulib/config.in: Re-generate.
* gnulib/configure: Re-generate.
* gnulib/import/Makefile.am: Re-generate.
* gnulib/import/Makefile.in: Re-generate.
* gnulib/import/m4/gnulib-cache.m4: Re-generate.
* gnulib/import/m4/gnulib-comp.m4: Re-generate.
* gnulib/import/m4/mkdir.m4: New file.
* gnulib/import/mkdir.c: New file.
* gnulib/update-gnulib.sh (IMPORTED_GNULIB_MODULES): Add mkdir
module.
Simon Marchi [Tue, 7 Aug 2018 22:10:29 +0000 (18:10 -0400)]
Introduce mmap_file function
New in v2:
- As Tom pointed out, we don't need to keep the fd around after
mmapping. This simplifies things quite a bit, since we don't need a
new class. It's now just a function that returns a scoped_mmap.
We already have scoped_mmap, which is a thin RAII layer over mmap. If
one simply wants to mmap an entire file for reading, it takes a bit of
boilerplate. This patch introduces the mmap_file function to make this
easier.
gdb/ChangeLog:
* Makefile.in (COMMON_SFILES): Add common/scoped_mmap.c.
* common/scoped_mmap.c: New file.
* common/scoped_mmap.h (destroy): New method.
(~scoped_mmap, reset): Use destroy.
(scoped_mmap): New move constructor.
(mmap_file): New declaration.
* unittests/scoped_mmap-selftests.c (test_normal,
test_invalid_filename, run_tests): New functions.
(_initialize_scoped_mmap_selftests): Register selftest.
Simon Marchi [Tue, 7 Aug 2018 22:08:57 +0000 (18:08 -0400)]
Make index reading functions more modular
New in v3:
- Remove changed to dwarf-5 functions.
The read_gdb_index_from_section and read_debug_names_from_section
functions read the index content, as their names state, from sections of
object files. A following patch will make it possible to read index
content from standalone files.
This patch therefore decouples the code that reads the index content
from the code that processes that content. Functions
dwarf2_read_gdb_index and dwarf2_read_debug_names receive callbacks that
are responsible for providing the index contents (for both the main file
and the potential dwz file).
gdb/ChangeLog:
* dwarf2read.c (read_gdb_index_from_section): Rename to...
(read_gdb_index_from_buffer): ... this. Remove section
parameter, add buffer parameter.
(get_gdb_index_contents_ftype,
get_gdb_index_contents_dwz_ftype): New typedefs.
(dwarf2_read_gdb_index): Add callback parameters to get the
index contents.
(get_gdb_index_contents_from_section): New.
(dwarf2_initialize_objfile): Update call to
dwarf2_read_gdb_index.
Simon Marchi [Tue, 7 Aug 2018 21:43:08 +0000 (17:43 -0400)]
Replace some uses of xstrprintf with string_printf
This patch replaces some simple uses of xstrprintf with with
string_printf, removing the need to do manual memory freeing.
The change in ada-lang.c fixes an apparent memory leak.
Regtested on the buildbot.
gdb/ChangeLog:
* common/filestuff.h (gdb_fopen_cloexec): New overload.
(gdb_open_cloexec): Likewise.
* nat/linux-osdata.c (command_from_pid): Use string_printf.
(commandline_from_pid): Likewise.
(linux_xfer_osdata_threads): Likewise.
(linux_xfer_osdata_fds): Likewise.
* ada-lang.c (is_package_name): Likewise.
* auxv.c (procfs_xfer_auxv): Likewise.
* breakpoint.c (print_one_breakpoint_location): Use
uiout::field_fmt.
(print_one_catch_solib): Use string_printf.
* coff-pe-read.c (add_pe_exported_sym): Likewise.
(add_pe_forwarded_sym): Likewise.
* dwarf2read.c (create_type_unit_group): Likewise.
(build_error_marker_type): Likewise.
* infcall.c (get_function_name): Likewise.
* valprint.c (print_converted_chars_to_obstack): Likewise.
* xtensa-tdep.c (xtensa_register_type): Likewise.
Rainer Orth [Tue, 7 Aug 2018 11:20:40 +0000 (13:20 +0200)]
Support parallel make check with GNU make 4.2+
I noticed that make -jN check would run make check-single when using GNU
make 4.2.1.
In the end, it turned out that this is due to this change from the make
4.2 NEWS file:
* The amount of parallelism can be determined by querying MAKEFLAGS, even when
the job server is enabled (previously MAKEFLAGS would always contain only
"-j", with no number, when job server was enabled).
The fix is trivial: just accept an optional arg to -j in Makefile.in
(saw_dash_j). Tested on i386-pc-solaris2.11 with just make and make
-j/-jN with both make 3.82 and 4.2.1.
* Makefile.in (saw_dash_j): Allow for GNU make 4.2+ passing -jN in
MAKEFLAGS.
Alan Modra [Mon, 6 Aug 2018 12:13:51 +0000 (21:43 +0930)]
PowerPC64 EH info for _notoc linkage stubs
This patch generates EH info for the new _notoc linkage stubs, to
support unwinding from asynchronous signal handlers. Unwinding
through the __tls_get_addr_opt stub was already supported, but that
was just a single stub. With multiple stubs the EH opcodes need to be
emitted and sized when iterating over stubs, so this is done when
emitting and sizing the stub code. Emitting the CIEs and FDEs is done
when sizing the stubs, as we did before in order to have the linker
generated FDEs indexed in .eh_frame_hdr. I moved the final tweaks to
FDEs from ppc64_elf_finish_dynamic_sections to ppc64_elf_build_stubs
simply because it's tidier to be done with them at that point.
bfd/
* elf64-ppc.c (struct map_stub): Delete tls_get_addr_opt_bctrl.
Add lr_restore, eh_size and eh_base.
(eh_advance, eh_advance_size): New functions.
(build_tls_get_addr_stub): Emit EH info for stub.
(ppc_build_one_stub): Likewise for _notoc stubs.
(ppc_size_one_stub): Size EH info for stub.
(group_sections): Init new map_stub fields.
(stub_eh_frame_size): Delete.
(ppc64_elf_size_stubs): Size EH info for stubs. Set up dummy EH
program for stubs.
(ppc64_elf_build_stubs): Reinit new map_stub fields. Set FDE
offset to stub section here..
(ppc64_elf_finish_dynamic_sections): ..rather than here.
ld/
* testsuite/ld-powerpc/notoc.s: Generate some cfi.
* testsuite/ld-powerpc/notoc.d: Adjust.
* testsuite/ld-powerpc/notoc.wf: New file.
* testsuite/ld-powerpc/powerpc.exp: Run "ext" and "notoc" tests
as run_ld_link_tests rather than run_dump_test.