Phil Muldoon [Thu, 16 Nov 2017 14:14:03 +0000 (14:14 +0000)]
Add Python rbreak command.
gdb/Changelog
2017-11-16 Phil Muldoon <pmuldoon@redhat.com>
* python/python.c (gdbpy_rbreak): New function.
* NEWS: Document Python rbreak feature.
testsuite/Changelog
2017-11-16 Phil Muldoon <pmuldoon@redhat.com>
* gdb.python/py-rbreak.exp: New file.
* gdb.python/py-rbreak.c: New file.
* gdb.python/py-rbreak-func2.c: New file.
doc/Changelog
2017-11-16 Phil Muldoon <pmuldoon@redhat.com>
* python.texi (Basic Python): Add rbreak documentation.
Nick Clifton [Thu, 16 Nov 2017 13:06:22 +0000 (13:06 +0000)]
Prevent a possible seg-fault in the section merging code, by always creating a padding buffer.
* merge.c (sec_merge_emit): Always create padding buffer. Add
asserts to make sure that the buffer is long enough.
Jan Beulich [Thu, 16 Nov 2017 12:56:45 +0000 (13:56 +0100)]
x86: ignore high register select bit(s) in 32- and 16-bit modes
While commits
9889cbb14e ("Check invalid mask registers") and
abfcb414b9 ("X86: Ignore REX_B bit for 32-bit XOP instructions") went a
bit into the right direction, this wasn't quite enough:
- VEX.vvvv has its high bit ignored
- EVEX.vvvv has its high bit ignored together with EVEX.v'
- the high bits of {,E}VEX.vvvv should not be prematurely zapped, to
allow proper checking of them when the fields has to hold al ones
- when the high bits of an immediate specify a register, bit 7 is
ignored
Pedro Alves [Thu, 16 Nov 2017 11:57:01 +0000 (11:57 +0000)]
Fix gdb.base/starti.exp racy test
This commit fixes a couple problems with gdb.base/starti.exp, causing
spurious FAILs.
The first is a double-prompt problem:
~~~
(gdb) PASS: gdb.base/starti.exp: hook-stop
starti
[....]
gdb_expect_list pattern: /\$1 = 0/
$1 = 0
gdb_expect_list pattern: //
0x00007ffff7ddcc80 in _start () from /lib64/ld-linux-x86-64.so.2
(gdb) # EXPECTED PROMPT
(gdb) PASS: gdb.base/starti.exp: starti # ANOTHER PROMPT!
break main
~~~
This happens because the test uses gdb_test_sequence with no command,
like this:
gdb_test_sequence "" "starti" {
"Program stopped."
"\\$1 = 0"
}
but gdb_test_sequence doesn't have a check for empty command like
gdb_test_multiple does, and so sends "\n" to GDB:
proc gdb_test_sequence { command test_name expected_output_list } {
global gdb_prompt
if { $test_name == "" } {
set test_name $command
}
lappend expected_output_list ""; # implicit ".*" before gdb prompt
send_gdb "$command\n"
return [gdb_expect_list $test_name "$gdb_prompt $" $expected_output_list]
}
"starti" is a no-repeat command, so pressing <ret> just makes another
prompt appear, confusing the following gdb_test/gdb_test_multiple/etc.
Even with that fixed, the testcase is still racy though.
The second problem is that sometimes the "continue" test times out
here:
~~~
continue
Continuing.
$2 = 1
gdb_expect_list pattern: /.*Breakpoint .*main \(\) at .*starti.c.*/
Breakpoint 1, main () at /home/pedro/src/gdb/testsuite/gdb.base/starti.c:29
29 return 0;
(gdb) gdb_expect_list pattern: //
* hung here *
~~~
The problem is that the too-greedy ".*" trailing match in
gdb_expect_list's pattern ends up consuming GDB's prompt too soon.
Fix that by removing the unnecessary trailing ".*". While at it,
remove all ".*"s to be stricter.
Tested on x86_64 GNU/Linux.
gdb/testsuite/ChangeLog:
2017-11-16 Pedro Alves <palves@redhat.com>
* gdb.base/starti.exp ("continue" test): Remove ".*"s from
pattern.
* lib/gdb.exp (gdb_test_sequence): Don't send empty command to
GDB.
Jan Beulich [Thu, 16 Nov 2017 11:28:06 +0000 (12:28 +0100)]
ix86/Intel: don't require memory operand size specifier for PTWRITE
Other than in 64-bit mode, in 32- and 16-bit modes operand size isn't
ambiguous.
H.J. Lu [Thu, 16 Nov 2017 10:50:33 +0000 (02:50 -0800)]
i386: Replace .code64/.code32 with .byte
Since .code64 directive isn't available for 32-bit BFD and ELF directive
isn't available for non-ELF directive, we should avoid them.
* testsuite/gas/i386/noextreg.s: Replace .code64/.code32 and
64-bit instructions with .byte. Remove ELF directive.
Yao Qi [Thu, 16 Nov 2017 10:17:25 +0000 (10:17 +0000)]
Remove non-linux tic6x target descriptions
They are not used by GDB nor by GDBserver. This patch removes them.
gdb:
2017-11-16 Yao Qi <yao.qi@linaro.org>
* features/tic6x-c62x.xml: Remove.
* features/tic6x-c64x.xml: Remove.
* features/tic6x-c64xp.xml: Remove.
Alan Hayward [Thu, 16 Nov 2017 10:05:21 +0000 (10:05 +0000)]
Allow osabi to be optional in target descriptions
gdbserver/
* tdesc.c (tdesc_get_features_xml): Allow null osabi.
Yao Qi [Thu, 16 Nov 2017 10:05:27 +0000 (10:05 +0000)]
Fix tic6x-uclinux GDBserver build failure
I can't find a c6x-uclinux c++ compiler, so I use my host g++ to build
tic6x-uclinux GDBserver, and find the following build failures. They are
not target specific, so I believe they are real errors. This patch fixes
them.
../binutils-gdb/gdb/gdbserver/linux-tic6x-low.c:313:34: error: invalid
conversion from 'void*' to 'tic6x_register*' [-fpermissive]
union tic6x_register *regset = buf;
^
../binutils-gdb/gdb/gdbserver/linux-tic6x-low.c: In function 'void tic6x_store_gregset(regcache*, const void*)':
../binutils-gdb/gdb/gdbserver/linux-tic6x-low.c:324:40: error: invalid
conversion from 'const void*' to 'const tic6x_register*' [-fpermissive]
const union tic6x_register *regset = buf;
^
../binutils-gdb/gdb/gdbserver/linux-tic6x-low.c: At global scope:
../binutils-gdb/gdb/gdbserver/linux-tic6x-low.c:359:28: error: redefinition of 'usrregs_info tic6x_usrregs_info'
static struct usrregs_info tic6x_usrregs_info =
^
../binutils-gdb/gdb/gdbserver/linux-tic6x-low.c:186:28: note: 'usrregs_info tic6x_usrregs_info' previously declared here
static struct usrregs_info tic6x_usrregs_info;
^
gdb/gdbserver:
2017-11-16 Yao Qi <yao.qi@linaro.org>
* linux-tic6x-low.c (tic6x_fill_gregset): Cast buf.
(tic6x_store_gregset): Likewise.
(tic6x_usrregs_info): Move it up.
GDB Administrator [Thu, 16 Nov 2017 00:00:23 +0000 (00:00 +0000)]
Automatic date update in version.in
John Baldwin [Wed, 15 Nov 2017 19:36:42 +0000 (11:36 -0800)]
Include <array> to declare std::array<>.
gdb/ChangeLog:
* symtab.h: Include <array>.
John Baldwin [Wed, 15 Nov 2017 19:35:15 +0000 (11:35 -0800)]
Constify the 'arg' passed to commands in bsd-kvm.c.
gdb/ChangeLog:
* bsd-kvm.c (bsd_kvm_cmd): Constify 'arg'.
(bsd_kvm_proc_cmd): Likewise.
Simon Marchi [Wed, 15 Nov 2017 14:22:48 +0000 (09:22 -0500)]
tui-win: Replace VEC with std::vector
This patch replaces an instance of VEC (const_char_ptr) with
std::vector<const char *>. Tested by running gdb.tui/completion.exp,
which exercises this function.
gdb/ChangeLog:
* tui/tui-win.c (window_name_completer): Replace VEC with
std::vector.
Simon Marchi [Wed, 15 Nov 2017 16:07:02 +0000 (11:07 -0500)]
Fix gdb.tui/completion.exp test
When I run it locally, the test gdb.tui/completion.exp test fails
because of a timeout:
Running /home/emaisin/src/binutils-gdb/gdb/testsuite/gdb.tui/completion.exp ...
FAIL: gdb.tui/completion.exp: completion of layout names: tab completion (timeout)
The problem seems to be this regex, which confirms that after doing
layout<TAB>, "layout" is printed again after the gdb prompt:
-re "^$input_line$"
The problem is that there's a trailing space in the output after
"layout". Since the regex has an anchored end (the $), it doesn't
match. Adding a space fixes the test.
gdb/testsuite/ChangeLog:
* gdb.tui/completionn.exp (test_tab_completion): Add space in
regex.
Tamar Christina [Wed, 15 Nov 2017 15:56:23 +0000 (15:56 +0000)]
Separate the new FP16 instructions backported from Armv8.4-a to Armv8.2-a into a new flag order to distinguish them from the rest of the already existing optional FP16 instructions in Armv8.2-a.
The new flag "+fp16fml" is available from Armv8.2-a and implies +fp16 and is mandatory
from Armv8.4-a.
gas/
* config/tc-arm.c (arm_ext_fp16_fml, fp16fml): New.
(do_neon_fmac_maybe_scalar_long): Use arm_ext_fp16_fml.
* doc/c-arm.texi (fp16, fp16fml): New.
* testsuite/gas/arm/armv8_2-a-fp16.d (fp16): Make fp16fml.
* testsuite/gas/arm/armv8_3-a-fp16.d (fp16): Make fp16fml.
* testsuite/gas/arm/armv8_2-a-fp16-illegal.d (fp16): Make fp16fml.
* testsuite/gas/arm/armv8_2-a-fp16-thumb2.d (fp16): Make fp16fml.
include/
* opcode/arm.h: (ARM_EXT2_FP16_FML): New.
(ARM_AEXT2_V8_4A): Add ARM_EXT2_FP16_FML.
Andrew Cagney [Wed, 15 Nov 2017 15:26:59 +0000 (10:26 -0500)]
Remove no-longer applicable maintainer entries
2017-11-15 Andrew Cagney <cagney@gnu.org>
* MAINTAINERS: Remove no-longer applicable entries.
Andrew Cagney [Wed, 15 Nov 2017 15:12:12 +0000 (10:12 -0500)]
Move self to Past Maintainers.
2017-11-15 Andrew Cagney <cagney@gnu.org>
* MAINTAINERS: Move self to Past Maintainers.
Yao Qi [Wed, 15 Nov 2017 12:03:03 +0000 (12:03 +0000)]
Remove features/nios2-linux.c
tdesc_nios2_linux is not used at all. Remove features/nios2-linux.c,
and don't generate it anymore.
gdb:
2017-11-15 Yao Qi <yao.qi@linaro.org>
* features/Makefile (XMLTOC): Remove nios2-linux.xml.
* features/nios2-linux.c: Remove.
* nios2-linux-tdep.c (_initialize_nios2_linux_tdep): Don't call
initialize_tdesc_nios2_linux.
Alan Modra [Wed, 15 Nov 2017 11:53:22 +0000 (22:23 +1030)]
objcopy memory leak
PR 22426
* objcopy.c (copy_main): Free tmpname.
Alan Modra [Wed, 15 Nov 2017 11:46:08 +0000 (22:16 +1030)]
Handle ' and I format flags
Also a little tidying and error checking.
* bfd.c (union _bfd_doprnt_args): Add "Bad".
(_bfd_doprnt): Handle more flags.
(_bfd_doprnt_scan): Likewise. Tidy setting of args array.
(error_handler_internal): Init args type to Bad.
Nick Clifton [Wed, 15 Nov 2017 11:34:03 +0000 (11:34 +0000)]
Add support to readelf and objdump for following links to separate debug information files.
Hi Guys,
I am applying the rather large patch attached to this email to enhance
the readelf and objdump programs so that they now have the ability to
follow links to separate debug info files. (As requested by PR
15152). So for example whereas before we had this output:
$ readelf -wi main.exe
Contents of the .debug_info section:
[...]
<15> DW_AT_comp_dir : (alt indirect string, offset: 0x30c)
[...]
With the new option enabled we get:
$ readelf -wiK main.exe
main.exe: Found separate debug info file: dwz.debug
Contents of the .debug_info section (loaded from main.exe):
[...]
<15> DW_AT_comp_dir : (alt indirect string, offset: 0x30c) /home/nickc/Downloads/dwzm
[...]
The link following feature also means that we can get two lots of
output if the same section exists in both the main file and the
separate debug info file:
$ readelf -wiK main.exe
main.exe: Found separate debug info file: dwz.debug
Contents of the .debug_info section (loaded from main.exe):
[...]
Contents of the .debug_info section (loaded from dwz.debug):
[...]
The patch also adds the ability to display the contents of debuglink
sections:
$ readelf -wk main.exe
Contents of the .gnu_debugaltlink section:
Separate debug info file: dwz.debug
Build-ID (0x14 bytes):
c4 a8 89 8d 64 cf 70 8a 35 68 21 f2 ed 24 45 3e 18 7a 7a 93
Naturally there are long versions of these options (=follow-links and
=links). The documentation has been updated as well, and since both
readelf and objdump use the same set of debug display options, I have
moved the text into a separate file. There are also a couple of new
binutils tests to exercise the new behaviour.
There are a couple of missing features in the current patch however,
although I do intend to address them in follow up submissions:
Firstly the code does not check the build-id inside separate debug
info files when it is searching for a file specified by a
.gnu_debugaltlink section. It just assumes that if the file is there,
then it contains the information being sought.
Secondly I have not checked the DWARF-5 version of these link
features, so there will probably be code to add there.
Thirdly I have only implemented link following for the
DW_FORM_GNU_strp_alt format. Other alternate formats (eg
DW_FORM_GNU_ref_alt) have yet to be implemented.
Lastly, whilst implementing this feature I found it necessary to move
some of the global variables used by readelf (eg section_headers) into
a structure that can be passed around. I have moved all of the global
variables that were necessary to get the patch working, but I need to
complete the operation and move the remaining, file-specific variables
(eg dynamic_strings).
Cheers
Nick
binutils PR 15152
* dwarf.h (enum dwarf_section_display_enum): Add gnu_debuglink,
gnu_debugaltlink and separate_debug_str.
(struct dwarf_section): Add filename field.
Add prototypes for load_separate_debug_file, close_debug_file and
open_debug_file.
* dwarf.c (do_debug_links): New.
(do_follow_links): New.
(separate_debug_file, separate_debug_filename): New.
(fetch_alt_indirect_string): New function. Retrieves a string
from the debug string table in the separate debug info file.
(read_and_display_attr_value): Use it with DW_FORM_GNU_strp_alt.
(load_debug_section_with_follow): New function. Like
load_debug_section, but if the first attempt fails, then tries
again in the separate debug info file.
(introduce): New function.
(process_debug_info): Use load_debug_section_with_follow and
introduce.
(load_debug_info): Likewise.
(display_debug_lines_raw): Likewise.
(display_debug_lines_decoded): Likewise.
(display_debug_macinfo): Likewise.
(display_debug_macro): Likewise.
(display_debug_abbrev): Likewise.
(display_debug_loc): Likewise.
(display_debug_str): Likewise.
(display_debug_aranges): Likewise.
(display_debug_addr); Likewise.
(display_debug_frames): Likewise.
(display_gdb_index): Likewise.
(process_cu_tu_index): Likewise.
(load_cu_tu_indexes): Likewise.
(display_debug_links): New function. Displays the contents of a
.gnu_debuglink or .gnu_debugaltlink section.
(calc_gnu_debuglink_ctc32):New function. Calculates a CRC32
value.
(check_gnu_debuglink): New function. Checks the CRC of a
potential separate debug info file.
(parse_gnu_debuglink): New function. Reads a CRC value out of a
.gnu_debuglink section.
(check_gnu_debugaltlink): New function.
(parse_gnu_debugaltlink): New function. Reads the build-id value
out of a .gnu_debugaltlink section.
(load_separate_debug_info): New function. Finds and loads a
separate debug info file.
(load_separate_debug_file): New function. Attempts to find and
follow a link to a separate debug info file.
(free_debug_memory): Free the separate debug info file
information.
(opts_table): Add "follow-links" and "links".
(dwarf_select_sections_by_letters): Add "k" and "K".
(debug_displays): Reformat. Add .gnu-debuglink and
.gnu_debugaltlink.
Add an extra entry for .debug_str in a separate debug info file.
* doc/binutils.texi: Move description of debug dump features
common to both readelf and objdump into...
* objdump.c (usage): Add -Wk and -WK.
(load_specific_debug_section): Initialise the filename field in
the dwarf_section structure.
(close_debug_file): New function.
(open_debug_file): New function.
(dump_dwarf): Load and dump the separate debug info sections.
* readelf.c (struct filedata): New structure. Contains various
variables that used to be global:
(current_file_size, string_table, string_table_length, elf_header)
(section_headers, program_headers, dump_sects, num_dump_sects):
Move into filedata structure.
(cmdline): New global variable. Contains list of sections to dump
by number, as specified on the command line.
Add filedata parameter to most functions.
(load_debug_section): Load the string table if it has not already
been retrieved.
(close_file): New function.
(close_debug_file): New function.
(open_file): New function.
(open_debug_file): New function.
(process_object): Process sections in any separate debug info files.
* doc/debug.options.texi: New file. Add description of =links and
=follow-links options.
* NEWS: Mention the new feature.
* elfcomm.c: Have the byte gte functions take a const pointer.
* elfcomm.h: Update prototypes.
* testsuite/binutils-all/dw5.W: Update expected output.
* testsuite/binutils-all/objdump.WL: Update expected output.
* testsuite/binutils-all/objdump.exp: Add test of -WK and -Wk.
* testsuite/binutils-all/readelf.exp: Add test of -wK and -wk.
* testsuite/binutils-all/readelf.k: New file.
* testsuite/binutils-all/objdump.Wk: New file.
* testsuite/binutils-all/objdump.WK2: New file.
* testsuite/binutils-all/linkdebug.s: New file.
* testsuite/binutils-all/debuglink.s: New file.
gas * testsuite/gas/avr/large-debug-line-table.d: Update expected
output.
* testsuite/gas/elf/dwarf2-11.d: Likewise.
* testsuite/gas/elf/dwarf2-12.d: Likewise.
* testsuite/gas/elf/dwarf2-13.d: Likewise.
* testsuite/gas/elf/dwarf2-14.d: Likewise.
* testsuite/gas/elf/dwarf2-15.d: Likewise.
* testsuite/gas/elf/dwarf2-16.d: Likewise.
* testsuite/gas/elf/dwarf2-17.d: Likewise.
* testsuite/gas/elf/dwarf2-18.d: Likewise.
* testsuite/gas/elf/dwarf2-5.d: Likewise.
* testsuite/gas/elf/dwarf2-6.d: Likewise.
* testsuite/gas/elf/dwarf2-7.d: Likewise.
ld * testsuite/ld-avr/gc-section-debugline.d: Update expected
output.
Alan Hayward [Wed, 15 Nov 2017 09:59:12 +0000 (09:59 +0000)]
Better make rule for arch/ files built for IPA
gdbserver/
* Makefile.in: Update arch rules.
* configure.srv: Explicitly mark arch/ files.
Yao Qi [Wed, 15 Nov 2017 09:36:51 +0000 (09:36 +0000)]
Fix M68HC11_NUM_REGS
M68HC11_LAST_HARD_REG is 8, but m68hc11 register number is started from 0,
so there are 9 raw registers, but M68HC11_NUM_REGS is 8 by mistake.
My following unit test can find this issue (GDB is built with asan)
=================================================================
==15555==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x602000113150 at pc 0x51393f bp 0x7fffcec36f60 sp 0x7fffcec36f58
WRITE of size 2 at 0x602000113150 thread T0
#0 0x51393e in m68hc11_pseudo_register_read gdb/m68hc11-tdep.c:320
#1 0xc4b620 in gdbarch_pseudo_register_read(gdbarch*, regcache*, int, unsigned char*) gdb/gdbarch.c:1974
#2 0xddad88 in regcache::cooked_read(int, unsigned char*) gdb/regcache.c:710
#3 0xddff2b in cooked_read_test gdb/regcache.c:1850
#4 0xdf8cfb in selftests::gdbarch_selftest::operator()() const gdb/selftest-arch.c:73
gdb:
2017-11-15 Yao Qi <yao.qi@linaro.org>
* m68hc11-tdep.c (M68HC11_NUM_REGS): Change it to
M68HC11_LAST_HARD_REG + 1.
Jan Beulich [Wed, 15 Nov 2017 07:52:05 +0000 (08:52 +0100)]
x86: use correct register names
VEX.W may be legitimately set (and is then ignored by the CPU) for
non-64-bit code. Don't print 64-bit register names in such a case, by
utilizing that REX_W would never be set for non-64-bit code, and that
it is being set from VEX.W by generic decoding.
A test for this is going to be introduced in the next patch of this
series.
Jan Beulich [Wed, 15 Nov 2017 07:51:03 +0000 (08:51 +0100)]
x86: drop VEXI4_Fixup()
The low four bits of an immediate being set when the high bits specify a
fourth register operand is not a problem: CPUs ignore these bits rather
than raising #UD. Take care of incrementing codep in OP_EX_VexW()
instead.
Jan Beulich [Wed, 15 Nov 2017 07:48:51 +0000 (08:48 +0100)]
x86-64: don't allow use of %axl as accumulator
Just like %cxl can't be used as shift count register. Otherwise for
consistency %cxl would need to gain "ShiftCount" and use of both ought
to properly cause REX prefixes to be emitted.
Alan Modra [Wed, 15 Nov 2017 01:05:21 +0000 (11:35 +1030)]
ld einfo positional arg support
To allow translators to reorder values in translated strings. This
should mean that all binutils messages now have support for
reordering.
Note to translators: Not all % letters take arguments, so for example
the following only has two arguments, the two %s strings.
"%P%F: output format %s cannot represent section called %s: %E\n"
You could reorder this if you liked to:
"%P%F: %E: section %2$s cannot be represented in output format %1$s\n"
einfo lacks support for flags, field width, precision and length
modifier (apart from %ld and %lu) so don't try to use them in
translations. Both ld and bfd lack support to use a positional arg
twice. These features could be added if needed..
* ldmisc.c (vfinfo): Support up to 9 positional args.
Jim Wilson [Wed, 15 Nov 2017 01:23:14 +0000 (17:23 -0800)]
First part of fix for riscv gas lns-common-1 failure.
gas/
* testsuite/gas/lns/lns.exp (lns-common-1): Add riscv*-*-* to alt list.
Jim Wilson [Wed, 15 Nov 2017 01:07:32 +0000 (17:07 -0800)]
Add modified file I missed in last commit.
Jim Wilson [Wed, 15 Nov 2017 01:02:43 +0000 (17:02 -0800)]
Fix riscv ld testsuite failure for compressed1d.
ld/
* testsuite/ld-elf/compress1-alt.s: New.
* testsuite/ld-elf/compressed1d-alt.d: New.
* testsuite/ld-elf/compressed1d.d: Add riscv*-*-* to notarget list.
GDB Administrator [Wed, 15 Nov 2017 00:00:25 +0000 (00:00 +0000)]
Automatic date update in version.in
Paul Carroll [Tue, 14 Nov 2017 22:37:37 +0000 (17:37 -0500)]
Fix 'xfered>0' assertion in target.c for remote connection
We have a customer who is using a Corelis gdb server to connect to gdb.
Occasionally, the gdb server will send a 0-byte block of memory for a
read. When this happens, gdb gives an assertion from target.c:
internal-error: target_xfer_partial: Assertion `*xfered_len > 0' failed.
This problem is almost identical to that fixed in
https://sourceware.org/ml/gdb-patches/2014-02/msg00636.html
In this case, remote.c needs to be modified to return TARGET_XFER_EOF
instead of TARGET_XFER_OK or TARGET_XFER_UNAVAILABLE when 0 bytes are
transferred.
gdb/ChangeLog:
PR gdb/22388
* remote.c (remote_write_bytes_aux, remote_read_bytes_1,
remote_read_bytes, remote_write_qxfer, remote_xfer_partial):
Return TARGET_XFER_EOF if size of returned data is 0.
Simon Marchi [Tue, 14 Nov 2017 21:42:08 +0000 (16:42 -0500)]
Fix mem region parsing regression and add test
In my patch
Get rid of VEC (mem_region)
a664f67e50eff30198097d51cec0ec4690abb2a1
I introduced a regression, where the length of the memory region is
assigned to the "hi" field. It should obviously be computed as "start +
length". To my defense, no test had caught this :). As a penance, I
wrote one.
gdb/ChangeLog:
* Makefile.in (SUBDIR_UNITTESTS_SRCS): Add
memory-map-selftests.c.
(SUBDIR_UNITTESTS_OBS): Add memory-map-selftests.o.
* memory-map.c (memory_map_start_memory): Fix computation of hi
address.
* unittests/memory-map-selftests.c: New file.
Alan Modra [Tue, 14 Nov 2017 08:17:34 +0000 (18:47 +1030)]
PR22431, powerpc64 ld segfault when .plt discarded
The fix for the PR is to not use input_section->output_section->owner
to get to the output bfd, but use the output bfd directly since it is
available nowadays in struct bfd_link_info.
I thought it worth warning when non-empty dynamic sections are
discarded too, which meant a tweak to one of the ld tests to avoid the
warning.
bfd/
PR 22431
* elf64-ppc.c (ppc64_elf_size_dynamic_sections): Warn on discarding
non-empty dynamic section.
(ppc_build_one_stub): Take elf_gp from output bfd, not output
section owner.
(ppc_size_one_stub, ppc64_elf_next_toc_section): Likewise.
ld/
* testsuite/ld-elf/note-3.t: Don't discard .got.
Alan Modra [Sun, 12 Nov 2017 07:11:50 +0000 (17:41 +1030)]
ld-ifunc non-PIC tests
* testsuite/ld-ifunc/ifunc.exp: Ensure non-PIC tests are really
not PIE by default gcc options.
Jan Beulich [Tue, 14 Nov 2017 07:43:26 +0000 (08:43 +0100)]
x86: add disassembler support for XOP VPCOM* pseudo-ops
Matching up with the assembler, which already supports them.
Jan Beulich [Tue, 14 Nov 2017 07:42:26 +0000 (08:42 +0100)]
x86: add support for AVX-512 VPCMP*{B,W} pseudo-ops
... matching up with VPCMP*{D,Q}.
Jan Beulich [Tue, 14 Nov 2017 07:40:48 +0000 (08:40 +0100)]
x86: string insns don't allow displacements
Remove the misleading indicators from the table.
Alan Modra [Tue, 14 Nov 2017 00:32:57 +0000 (11:02 +1030)]
Inconsistent .eh_frame_hdr on powerpc64
There is code in bfd/elf-eh-frame.c and ld/emultempl/elf32.em that
checks for the presence of eh_frame info by testing for a section
named .eh_frame sized more than 8 bytes. The size test is to exclude
a zero terminator. A similar check in elf64-ppc.c wrongly just tested
for non-zero size before creating the linker generated .eh_frame
describing plt call and other linkage stubs. The intention was to not
generate that info unless there was some user .eh_frame. (No user
.eh_frame implies the user doesn't care about exception handling.)
Because the test in elf64-ppc.c was wrong, ld generated the stub
.eh_frame just on finding a zero .eh_frame terminator in crtend.o, but
didn't generate the corresponding .eh_frame_hdr.
* elf64-ppc.c (ppc64_elf_size_stubs): Correct test for user
.eh_frame info.
Simon Marchi [Tue, 14 Nov 2017 03:06:02 +0000 (22:06 -0500)]
gdb.opt/inline-locals.exp: Remove trailing parentheses in test names
Test names should not end with parentheses, since the buildbot strips
those.
gdb/testsuite/ChangeLog:
* gdb.opt/inline-locals.exp: Remove trailing parentheses from
test names.
GDB Administrator [Tue, 14 Nov 2017 00:00:24 +0000 (00:00 +0000)]
Automatic date update in version.in
H.J. Lu [Mon, 13 Nov 2017 16:19:10 +0000 (08:19 -0800)]
ld: Replace exp_dataseg_none with exp_seg_none
* emultempl/ppc32elf.em (ppc_before_allocation): Replace
exp_dataseg_none with exp_seg_none.
* emultempl/ppc64elf.em (prelim_size_sections): Likewise.
* emultempl/spuelf.em (spu_before_allocation): Likewise.
Andreas Schwab [Mon, 13 Nov 2017 14:46:09 +0000 (15:46 +0100)]
Enable hardware single step for m68k in GDBServer
* linux-m68k-low.c (m68k_supports_hardware_single_step): New
function.
(struct linux_target_ops) <supports_hardware_single_step>: Initialize.
Jan Beulich [Mon, 13 Nov 2017 11:27:45 +0000 (12:27 +0100)]
gas/arm64: don't emit stack pointer symbol table entries
Without this change, all of
mov z0.b, p0/m, wsp
mov z0.b, wsp
mov z0.d, p0/m, sp
mov z0.d, sp
insert stray symbols into the symbol table.
Jan Beulich [Mon, 13 Nov 2017 11:26:48 +0000 (12:26 +0100)]
gas/ia64: fix testsuite failures
Commit
dd90581873 ("Place .shstrtab section after .symtab and .strtab,
thus restoring monotonically incre... ") adjusted section numbers, but
forgot to adjust sh_link references from relocation and group section
table entries.
Additionally some other (perhaps subsequent) change appears to have
added .rel.* and .rela.* sections to their respective groups, which
requires some further adjustments to group-2.d. I assume this additional
breakage wasn't noticed because the test was already failing at that
time.
This makes the gas testsuite complete successfully again for me in a
cross build on ix86-linux; there continue to be quite a few ld failures.
Jan Beulich [Mon, 13 Nov 2017 11:26:12 +0000 (12:26 +0100)]
PE: don't corrupt section flags when linking from ELF objects
Linking EFI executables from ELF object files can result in corrupted
COFF section flags if the section's alignment is too high. Issue a
diagnostic in that case, erroring out if this is not a final link, and
make sure only in-range values get written to the output image.
While doing this also make tic80 use the generic alignment macros
instead of custom #ifdef-ary.
No testsuite regressions for the range of COFF/PE targets that actually
cross-build in the first place on x86-64-linux.
Jan Beulich [Mon, 13 Nov 2017 11:22:21 +0000 (12:22 +0100)]
x86: don't default variable shift count insns to 8-bit operand size
Just like %dx in I/O instructions isn't suitable to derive operand size
information, %cl source operands of shift instructions aren't.
Jan Beulich [Mon, 13 Nov 2017 11:21:29 +0000 (12:21 +0100)]
x86: {f,}xsave64 / {f,}xrstor64 / xsaveopt64 should not allow q suffix
Just like is the case for xsave{s,c}64 and xrstors64 already. I wonder
though why xsave{s,c} and xrstors don't allow for the q suffix, other
than the other insns without the "64" suffix do.
Jan Beulich [Mon, 13 Nov 2017 11:20:30 +0000 (12:20 +0100)]
x86/Intel: don't mistake riz/eiz as base register
Just like we make rsp/esp a base register even if it comes second, make
riz/eiz an index register even if it comes first.
Jan Beulich [Mon, 13 Nov 2017 11:19:34 +0000 (12:19 +0100)]
x86-64/Intel: issue diagnostic for out of range displacement
... rather than silently dropping it altogether.
i386_finalize_displacement() expects baseindex to already be set, so
the respective statement needs to be moved up. This then also allows a
subsequent conditional to be simplified.
For this to not regress on 32-bit addressing, break out address size
guessing from i386_index_check(), invoking the new function earlier so
that i386_finalize_displacement() has i.prefix[ADDR_PREFIX] available.
i386_addressing_mode () in turn needs i.base_reg / i.index_reg set
earlier.
H.J. Lu [Sat, 11 Nov 2017 15:02:30 +0000 (07:02 -0800)]
ld: Add ldlang_check_relro_region/update lang_find_relro_sections_1
Extract GNU_RELRO region check into a new funtion and pass a pointer to
seg_align_type to lang_find_relro_sections_1 so that they can also be
used for text-only LOAD segment.
* ldlang.c (lang_size_sections_1): Extract GNU_RELRO region check
into ...
(ldlang_check_relro_region): New function.
(lang_find_relro_sections_1): Add an argument for pointer to
seg_align_type and replace expld.dataseg with the pointer.
(lang_find_relro_sections): Pass address of expld.dataseg to
lang_find_relro_sections_1.
H.J. Lu [Mon, 13 Nov 2017 01:23:22 +0000 (17:23 -0800)]
cl
H.J. Lu [Mon, 13 Nov 2017 01:22:15 +0000 (17:22 -0800)]
ld: Add lang_size_relro_segment
Break lang_size_sections down into separate functions so that they can
also be used for text-only LOAD segment. lang_size_relro_segment will
call lang_size_relro_segment_1 and lang_size_segment for both GNU_RELRO
segment and text-only LOAD segment.
* ldlang.c (lang_size_segment): New function.
(lang_size_relro_segment_1): Likewise.
(lang_size_relro_segment): Likewise.
(lang_size_sections): Rewrite to call lang_size_relro_segment.
H.J. Lu [Mon, 13 Nov 2017 01:20:09 +0000 (17:20 -0800)]
ld: Add fold_segment_align/fold_segment_relro_end/fold_segment_end
Extract DATA_SEGMENT_END/DATA_SEGMENT_ALIGN/DATA_SEGMENT_RELRO_END cases
for GNU_RELRO segment into separate functions so that they can also be
used for text-only LOAD segment.
* ldexp.c (fold_unary): Extract the DATA_SEGMENT_END case to ...
(fold_segment_end): New function.
(fold_binary): Extract the DATA_SEGMENT_ALIGN case to ...
(fold_segment_align): New function.
(fold_binary): Extract the DATA_SEGMENT_RELRO_END case to ...
(fold_segment_relro_end): New function.
H.J. Lu [Mon, 13 Nov 2017 01:17:47 +0000 (17:17 -0800)]
ld: Update phase_enum/relro_enum and add seg_align_type
Update GNU_RELRO date type so that they can also be used for text-only
LOAD segment.
* ldexp.h (phase_enum): Rename exp_dataseg_none,
exp_dataseg_align_seen, exp_dataseg_relro_seen,
exp_dataseg_end_seen, exp_dataseg_relro_adjust,
exp_dataseg_adjust and exp_dataseg_done to exp_seg_none,
exp_seg_align_seen, exp_seg_relro_seen, exp_seg_end_seen,
exp_seg_relro_adjust, exp_seg_adjust and exp_seg_done.
(relro_enum): Rename exp_dataseg_relro_none,
exp_dataseg_relro_start and exp_dataseg_relro_end to
exp_seg_relro_none, exp_seg_relro_start and exp_seg_relro_end.
(seg_align_type): New struct type.
(ldexp_control): Use seg_align_type.
* ldexp.c (fold_unary): Updated.
(fold_binary): Likewise.
* ldlang.c (strip_excluded_output_sections): Likewise.
(lang_size_sections_1): Likewise.
(lang_size_sections): Likewise.
H.J. Lu [Mon, 13 Nov 2017 01:03:50 +0000 (17:03 -0800)]
ld: Remove PF_X from PT_PHDR segment
It was reasonable to mark PT_PHDR segment with PF_X for compatibility
with UnixWare and Solaris linkers 20 years ago. But it is inappropriate
today when the primary OS of GNU ld is Linux. This patch removes PF_X
from PT_PHDR segment as gold does.
Tested natively on Linux/x86 as well as crosss-binutils for alpha-linux,
ia64-linux, powerpc64-linux, powerpc-linux, s390-linux, s390x-linux,
sparc64-linux and sparc-linux.
bfd/
PR ld/22423
* elf.c (_bfd_elf_map_sections_to_segments): Remove PF_X from
PT_PHDR segment.
ld/
PR ld/22423
* testsuite/ld-alpha/tlsbin.rd: Replace "R E " with "R +" for
PT_PHDR segment.
* testsuite/ld-alpha/tlsbinr.rd: Likewise.
* testsuite/ld-ia64/tlsbin.rd: Likewise.
* testsuite/ld-powerpc/tlsexe.r: Likewise.
* testsuite/ld-powerpc/tlsexe32.r: Likewise.
* testsuite/ld-powerpc/tlsexetoc.r: Likewise.
* testsuite/ld-s390/tlsbin.rd: Likewise.
* testsuite/ld-s390/tlsbin_64.rd: Likewise.
* testsuite/ld-sparc/tlssunbin32.rd: Likewise.
* testsuite/ld-sparc/tlssunbin64.rd: Likewise.
* testsuite/ld-elf/pr22423.d: New test.
GDB Administrator [Mon, 13 Nov 2017 00:00:24 +0000 (00:00 +0000)]
Automatic date update in version.in
H.J. Lu [Sun, 12 Nov 2017 15:25:26 +0000 (07:25 -0800)]
ld: Add OTHER_PLT_SECTIONS
OTHER_PLT_SECTIONS contains sections which should be placed right after
.plt section.
* emulparams/elf32_x86_64.sh (TINY_READONLY_SECTION): Renamed
to ...
(OTHER_PLT_SECTIONS): This.
* emulparams/elf_i386.sh: Likewise.
* emulparams/elf_iamcu.sh: Likewise.
* emulparams/elf_x86_64.sh: Likewise.
* scripttempl/elf.sc: Place ${OTHER_PLT_SECTIONS} just after
.plt.
Alan Modra [Sun, 12 Nov 2017 03:42:41 +0000 (14:12 +1030)]
weakdef list handling
The existing code allowed common and indirect symbols to pass an
assert, but then read root.u.def which is not valid for anything
besides defined and weakdef symbols. The garbage root.u.def.section
pointer read can't possibly match pointers stored at the same location
for indirect and common symbols, so we would always have left
u.weakdef NULL.
* elflink.c (elf_link_add_object_symbols): Ignore anything but
defined and defweak symbols when setting up weakdefs.
Alan Modra [Sun, 12 Nov 2017 07:14:15 +0000 (17:44 +1030)]
non_got_ref after adjust_dynamic_relocs
This patch was aimed at a FIXME in elf32-hppa.c, the ludicrous and
confusing fact that non_got_ref after adjust_dynamic_relocs in that
backend means precisely the inverse of what it means before
adjust_dynamic_relocs. Before, when non_got_ref is set it means there
are dynamic relocs, after, if non_got_ref is clear it means "keep
dynamic relocs" and later, "has dynamic relocs". There is a reason
why it was done that way.. Some symbols that may have dynamic
relocations pre-allocated in check_relocs turn out to not be dynamic,
and then are not seen by the backend adjust_dynamic_symbols. We want
those symbols to lose their dynamic relocs when non-pic, so it's handy
that non_got_ref means the opposite after adjust_dynamic_relocs. But
it's really confusing.
Most other targets, like ppc32, don't always set non_got_ref on
non-GOT references that have dynamic relocations. This is because the
primary purpose of non_got_ref before adjust_dynamic_relocs is to flag
symbols that might need to be copied to .dynbss, and there are
relocation types that may require dyn_relocs but clearly cannot have
symbols copied into .dynbss, for example, TLS relocations.
Why do we need a flag after adjust_dynamic_relocs to say "keep
dynamic relocations"? Well, you can discard most unwanted dyn_relocs
in the backend adjust_dynamic_relocs, and for those symbols that
aren't seen by the backend adjust_dynamic_relocs, in
allocate_dynrelocs based on a flag set by adjust_dynamic relocs,
dynamic_adjusted. That doesn't solve all our difficulties though.
relocate_section needs to know whether a symbol has dyn_relocs, and
many targets transfer dyn_relocs to a weakdef if the symbol has one.
The transfer means relocate_section can't test dyn_relocs itself and
the weakdef field has been overwritten by that time. So non_got_ref
is used to flag "this symbol has dynamic relocations" for
relocate_section.
Confused still? Well, let's hope the comments I've added help clarify
things.. The patch also fixes a case where we might wrongly emit
dynamic relocations in an executable for common and undefined symbols.
* elf32-hppa.c (elf32_hppa_adjust_dynamic_symbol): Set non_got_ref
to keep dyn_relocs, clear to discard. Comment.
(allocate_dynrelocs): Always clear non_got_ref when clearing
dyn_relocs in non-pic case. Invert non_got_ref test. Also test
dynamic_adjusted and ELF_COMMON_DEF_P. Move code deleting
dyn_relocs on undefined syms to handle for non-pic too.
(elf32_hppa_relocate_section): Simplify test for non-pic dyn relocs.
* elf32-ppc.c (ppc_elf_adjust_dynamic_symbol): Set non_got_ref
to keep dyn_relocs, clear to discard. Comment.
(allocate_dynrelocs): Always clear non_got_ref when clearing
dyn_relocs in non-pic case. Invert non_got_ref test. Also test
dynamic_adjusted and ELF_COMMON_DEF_P. Move code deleting
dyn_relocs on undefined syms to handle for non-pic too.
(ppc_elf_relocate_section): Simplify test for non-pic dyn relocs.
* elf64-ppc.c (ppc64_elf_adjust_dynamic_symbol): Discard
dyn_relocs here. Don't bother setting non_got_ref. Comment.
(allocate_dynrelocs): Delete special handling of non-pic ELFv2
ifuncs. Move code deleting dyn_relocs on undefined symbols to
handle for non-pic too. Don't test non_got_ref. Do test
dynamic_adjusted and ELF_COMMON_DEF_P.
GDB Administrator [Sun, 12 Nov 2017 00:00:18 +0000 (00:00 +0000)]
Automatic date update in version.in
Jim Wilson [Sat, 11 Nov 2017 03:24:45 +0000 (19:24 -0800)]
Fix riscv binutils xfail for debug_ranges test.
binutils/
* testsuite/binutils-all/objdump.exp: Expect the debug_ranges test to
pass.
GDB Administrator [Sat, 11 Nov 2017 00:00:20 +0000 (00:00 +0000)]
Automatic date update in version.in
GDB Administrator [Fri, 10 Nov 2017 00:00:28 +0000 (00:00 +0000)]
Automatic date update in version.in
Pedro Alves [Thu, 9 Nov 2017 22:44:10 +0000 (22:44 +0000)]
Fix racy output matching in gdb.tui/tui-completion.exp
'make check-read1 TESTS="gdb.tui/tui-completion.exp"' exposes this test race:
(gdb) PASS: gdb.tui/completion.exp: set max-completions unlimited
layout ^G
asm next prev regs split src
(gdb) FAIL: gdb.tui/completion.exp: completion of layout names: tab completion
Quit
(gdb) PASS: gdb.tui/completion.exp: completion of layout names: quit command input
focus ^G
cmd next prev src
(gdb) FAIL: gdb.tui/completion.exp: completion of focus command: tab completion
Quit
This is caused by expecting "$gdb_prompt layout $".
gdb_test_multiple's internal prompt regexp can match first if expect's
internal buffer is filled with partial output. Fix that by splitting
the gdb_test_multiple in question in two. Since the same problem/code
appears twice in the file, factor out a common procedure.
gdb/testsuite/ChangeLog:
2017-11-09 Pedro Alves <palves@redhat.com>
* gdb.tui/tui-completion.exp (test_tab_completion): New procedure,
factored out from ...
(top level): ... here, and adjusted to avoid expecting beyond the
prompt in a single gdb_test_multiple.
Pedro Alves [Thu, 9 Nov 2017 22:44:09 +0000 (22:44 +0000)]
Fix racy output matching in gdb.base/multi-attach.exp, gdb.server/ext-{attach, restart, ext-run}.exp
This commit fixes this same problem in several places:
(gdb) PASS: gdb.multi/multi-attach.exp: backtrace 2
kill
Kill the program being debugged? (y or n) y
(gdb) FAIL: gdb.multi/multi-attach.exp: kill inferior 2 (got interactive prompt)
This is just another case of the gdb_test_multiple's internal "got
interactive prompt" pattern matching because the testcase misses
matching enough.
gdb/testsuite/ChangeLog:
2017-11-09 Pedro Alves <palves@redhat.com>
* gdb.multi/multi-attach.exp ("kill" test): Match the whole query
output.
* gdb.server/ext-attach.exp ("kill" test): Likewise.
* gdb.server/ext-restart.exp ("kill" test): Likewise.
* gdb.server/ext-run.exp ("kill" test): Likewise.
* gdb.server/ext-wrapper.exp ("kill" test): Likewise.
Pedro Alves [Thu, 9 Nov 2017 22:44:09 +0000 (22:44 +0000)]
Fix racy output matching in gdb.base/cpcompletion.exp
With:
$ make check-read1 TESTS="gdb.cp/cpcompletion.exp"
we get (from gdb.log):
(gdb) complete break Foo::
break Foo::Foo()
break Foo::Foofoo()
break Foo::get_foo()
break Foo::set_foo(int)
break Foo::~Foo()
(gdb) FAIL: gdb.cp/cpcompletion.exp: complete class methods (Foo not found)
The problem is that the
"break ${class}::\[A-Za-z0-9_~\]+"
regexp patches partial input, like:
break Foo::F
break Foo::Fo
break Foo::Foo
etc.
Fix that by expecting each whole line.
gdb/testsuite/ChangeLog:
2017-11-09 Pedro Alves <palves@redhat.com>
* gdb.cp/cpcompletion.exp (test_class_complete): Tighten regex to
match till end of line.
Pedro Alves [Thu, 9 Nov 2017 22:44:08 +0000 (22:44 +0000)]
Fix racy output matching in gdb.base/memattr.exp
Testing with:
$ make check-read1 TESTS="gdb.base/memattr.exp"
Exposes a testcase bug that can result in racy fails:
info mem
Using user-defined memory regions.
Num Enb Low Addr High Addr Attrs
1 y 0x0000000000601060 0x0000000000601160 wo nocache
2 y 0x0000000000601180 0x0000000000601280 ro nocache
4 y 0x0000000000601280 0x0000000000601380 rw nocache
3 y 0x0000000000601380 0x0000000000601480 rw nocache
5 y 0x0000000000601480 0x0000000000601580 rw nocache
(gdb) FAIL: gdb.base/memattr.exp: info mem (1)
The problem is that:
"Attrs\[^\n\r]*.."
matches:
"Attrs \r"
when the output buffer is filled with partial output like this:
"info mem\r\nUsing user-defined memory regions.\r\nNum Enb Low Addr High Addr Attrs \r"
gdb/testsuite/ChangeLog:
2017-11-09 Pedro Alves <palves@redhat.com>
* gdb.base/memattr.exp: Tighten regexes to match the end line.
Pedro Alves [Thu, 9 Nov 2017 22:44:08 +0000 (22:44 +0000)]
Fix racy output matching in gdb.base/completion.exp
Testing with:
$ make check-read1 TESTS="gdb.base/completion.exp"
Exposes a testcase bug that can result in racy fails:
FAIL: gdb.base/completion.exp: command-name completion limiting using tab character
ERROR: Undefined command "".
FAIL: gdb.base/completion.exp: symbol-name completion limiting using tab character
FAIL: gdb.base/completion.exp: symbol-name completion limiting using complete command
testsuite/gdb.log shows:
(gdb) PASS: gdb.base/completion.exp: set max-completions 5
p^G
passcount path print print-object printf
*** List may be truncated, max-completions reached. ***
(gdb) FAIL: gdb.base/completion.exp: command-name completion limiting using tab character
pcomplete p
Undefined command: "pcomplete". Try "help".
(gdb) ERROR: Undefined command "".
The problem is that the expect buffer can get filled with partial
output that ends in the gdb prompt, and so the default FAIL inside
gdb_test_multiple matches.
Fix that by splitting the gdb_test_multiple in two stages. Since that
is done in more than one place in the testcase, move the otherwise
duplicate code to helper procedures.
gdb/testsuite/ChangeLog:
2017-11-09 Pedro Alves <palves@redhat.com>
* gdb.base/completion.exp (ignore_and_resync, test_tab_complete):
New procedures, factored out from ...
(top level): ... here, and adjusted to avoid expecting beyond the
prompt in one go.
Pedro Alves [Thu, 9 Nov 2017 22:44:08 +0000 (22:44 +0000)]
Fix racy output matching in gdb.asm/asm-source.exp
Testing with:
$ make check-read1 TESTS="gdb.asm/asm-source.exp"
Exposes a testcase bug that can result in racy fails:
(gdb) PASS: gdb.asm/asm-source.exp: next over foo3
return
Make selected stack frame return now? (y or n) y
n
#0 main () at /home/pedro/gdb/mygit/src/gdb/testsuite/gdb.asm/asmsrc1.s:53
53 gdbasm_exit0
(gdb) FAIL: gdb.asm/asm-source.exp: return from foo2 (got interactive prompt)
n
The problem is that the "return now\?.*" regex can match partial
output like this:
"Make selected stack frame return no"
and then we send the 'y' too early, and then the next time around we
hit gdb_test_multiple's internal "got interactive prompt" regex.
Also, note we match "return no" instead of "return now" because the
regex is missing one quote level.
gdb/testsuite/ChangeLog:
2017-11-09 Pedro Alves <palves@redhat.com>
* gdb.asm/asm-source.exp ("kill" test): Match the whole query
output. Fix '?' match.
H.J. Lu [Thu, 9 Nov 2017 22:36:51 +0000 (14:36 -0800)]
ld: Reformat emultempl/elf32.em
Reformat emultempl/elf32.em to generate consistent codes.
* emultempl/elf32.em (gld${EMULATION_NAME}_get_script): Reformat
to generate consistent codes.
Joel Brobecker [Thu, 9 Nov 2017 19:58:37 +0000 (11:58 -0800)]
fix typos in ada-lang.c comment
gdb/ChangeLog:
* ada-lang.c: Fix some typos in the general command documenting
how Ada expressions are being evaluated and how their result
is printed.
Jim Wilson [Thu, 9 Nov 2017 17:43:59 +0000 (09:43 -0800)]
Fix riscv dwarf2-10 gas testsuite failure.
gas/
* testsuite/gas/elf/dwarf2-10.l: Accept optional line number in error.
Tamar Christina [Thu, 9 Nov 2017 15:50:56 +0000 (15:50 +0000)]
Enable the Dot Product extension by default for Armv8.4-a.
include/
* opcode/aarch64.h (AARCH64_ARCH_V8_4): Enable DOTPROD.
gas/testsuite
* gas/aarch64/dotproduct_armv8_4.s: New.
* gas/aarch64/dotproduct_armv8_4.d: New.
Tamar Christina [Thu, 9 Nov 2017 15:48:43 +0000 (15:48 +0000)]
Add assembler and disassembler support for the new Armv8.4-a registers for AArch64.
Some of these instructions have been back-ported as optional extensions to
Armv8.2-a and higher, but others are only available for Armv8.4-a.
opcodes/
* aarch64-opc.c (aarch64_sys_regs): Add ARMv8.4-a registers;
dit, vstcr_el2, vsttbr_el2, cnthvs_tval_el2, cnthvs_cval_el2,
cnthvs_ctl_el2, cnthps_tval_el2, cnthps_cval_el2, cnthps_ctl_el2,
sder32_el2, vncr_el2.
(aarch64_sys_reg_supported_p): Likewise.
(aarch64_pstatefields): Add dit register.
(aarch64_pstatefield_supported_p): Likewise.
(aarch64_sys_regs_tlbi): Add vmalle1os, vae1os, aside1os, vaae1os,
vale1os, vaale1os, ipas2e1os, ipas2le1os, vae2os, vale2os, vmalls12e1os,
vae3os, vale3os, alle2os, alle1os, alle3os, rvae1, rvaae1, rvale1,
rvaale1, rvae1is, rvaae1is, rvale1is, rvaale1is, rvae1os, rvaae1os,
rvale1os, rvaale1os, ripas2e1is, ripas2le1is, ripas2e1, ripas2le1,
ripas2e1os, ripas2le1os, rvae2, rvale2, rvae2is, rvale2is, rvae2os,
rvale2os, rvae3, rvale3, rvae3is, rvale3is, rvae3os, rvale3os.
gas/testsuite
* gas/aarch64/armv8_4-a-registers-illegal.d: New.
* gas/aarch64/armv8_4-a-registers-illegal.l: New.
* gas/aarch64/armv8_4-a-registers-illegal.s: New.
* gas/aarch64/armv8_4-a-registers.d: New.
* gas/aarch64/armv8_4-a-registers.s: New.
Tamar Christina [Thu, 9 Nov 2017 15:45:00 +0000 (15:45 +0000)]
Add the operand encoding types for the new Armv8.2-a back-ported instructions. These are to be used later when the new instructions are added.
opcodes/
* aarch64-tbl.h (QL_SHA512UPT, QL_V2SAME2D, QL_V3SAME2D): New.
(QL_V4SAME16B, QL_V4SAME4S, QL_XAR, QL_SM3TT, QL_V3FML2S): New.
(QL_V3FML4S, QL_V2FML2S, QL_V2FML4S, QL_RMIF, QL_SETF): New.
(QL_STLW, QL_STLX): New.
Tamar Christina [Thu, 9 Nov 2017 15:22:30 +0000 (15:22 +0000)]
Adds the new Fields and Operand types for the new instructions in Armv8.4-a.
gas/
* config/tc-aarch64.c (process_omitted_operand):
Add AARCH64_OPND_Va, AARCH64_OPND_SM3_IMM2
and AARCH64_OPND_IMM_2.
(parse_operands): Add AARCH64_OPND_Va, AARCH64_OPND_SM3_IMM2,
AARCH64_OPND_IMM_2, AARCH64_OPND_MASK
and AARCH64_OPND_ADDR_OFFSET.
include/
* opcode/aarch64.h:
(aarch64_opnd): Add AARCH64_OPND_Va, AARCH64_OPND_MASK,
AARCH64_OPND_IMM_2, AARCH64_OPND_ADDR_OFFSET
and AARCH64_OPND_SM3_IMM2.
(aarch64_insn_class): Add cryptosm3 and cryptosm4.
(arch64_feature_set): Make uint64_t.
opcodes/
* aarch64-asm.h (ins_addr_offset): New.
* aarch64-asm.c (aarch64_ins_reglane): Add cryptosm3.
(aarch64_ins_addr_offset): New.
* aarch64-asm-2.c: Regenerate.
* aarch64-dis.h (ext_addr_offset): New.
* aarch64-dis.c (aarch64_ext_reglane): Add cryptosm3.
(aarch64_ext_addr_offset): New.
* aarch64-dis-2.c: Regenerate.
* aarch64-opc.h (aarch64_field_kind): Add FLD_imm6_2,
FLD_imm4_2 and FLD_SM3_imm2.
* aarch64-opc.c (fields): Add FLD_imm6_2,
FLD_imm4_2 and FLD_SM3_imm2.
(operand_general_constraint_met_p): Add AARCH64_OPND_ADDR_OFFSET.
(aarch64_print_operand): Add AARCH64_OPND_Va, AARCH64_OPND_SM3_IMM2,
AARCH64_OPND_MASK, AARCH64_OPND_IMM_2 and AARCH64_OPND_ADDR_OFFSET.
* aarch64-opc-2.c (Va, MASK, IMM_2, ADDR_OFFSET, SM3_IMM2): New.
* aarch64-tbl.h
(aarch64_opcode_table): Add Va, MASK, IMM_2, ADDR_OFFSET, SM3_IMM2.
Tom Tromey [Thu, 2 Nov 2017 18:48:44 +0000 (12:48 -0600)]
Simplify the psymbol hash function
This patch simplifies the psymbol_hash function, by changing it not to
examine the contents of the symbol's name. This change just mirrors
what psymbol_compare already does -- it is checking for name equality,
which is ok because symbol names are interned in symbol_set_names.
This change speeds up psymbol reading. "gdb -nx -batch gdb"
previously took ~1.8 seconds on my machine, and with this patch it now
takes ~1.7 seconds.
gdb/ChangeLog
2017-11-09 Tom Tromey <tom@tromey.com>
* psymtab.c (psymbol_hash): Do not hash string contents.
(psymbol_compare): Add comment.
Tom Tromey [Wed, 1 Nov 2017 17:15:06 +0000 (11:15 -0600)]
Speed up dict_hash
This speeds up dict_hash a bit, by moving the "TKB" check into the
switch in the loop.
For "gdb -nx -readnow -batch gdb", this improves the time from ~9.8s
before to ~8.5s afterward.
gdb/ChangeLog
2017-11-09 Tom Tromey <tom@tromey.com>
* dictionary.c (dict_hash): Move "TKB" check into the "switch".
Tamar Christina [Thu, 9 Nov 2017 11:21:31 +0000 (11:21 +0000)]
Split the ARM Crypto ISA extensions for AES and SHA1+2 into their own options (+aes and +sha2). The reason for the split is because with the introduction of Armv8.4-a the implementation of AES has explicitly been made independent of the implementation of the other crypto extensions.
gas * config/tc-aarch64.c (aarch64_arch_option_table): Add armv8.4-a.
(aarch64_features): Added SM4 and SHA3.
include * opcode/aarch64.h:
(AARCH64_FEATURE_V8_4, AARCH64_FEATURE_SM4): New.
(AARCH64_ARCH_V8_4, AARCH64_FEATURE_SHA3): New.
opcodes * aarch64-tbl.h
(aarch64_feature_v8_4, aarch64_feature_crypto_v8_2): New.
(aarch64_feature_sm4, aarch64_feature_sha3): New.
(aarch64_feature_fp_16_v8_2): New.
(ARMV8_4, SHA3, SM4, CRYPTO_V8_2, FP_F16_V8_2): New.
(V8_4_INSN, CRYPTO_V8_2_INSN): New.
(SHA3_INSN, SM4_INSN, FP16_V8_2_INSN): New.
Nick Clifton [Thu, 9 Nov 2017 10:28:32 +0000 (10:28 +0000)]
Change the type of the aarch64_feature_set typedef to unsigned long long so that it will work on 32-bit hosts.
* opcode/aarch64.h (aarch64_feature_set): Change type to unsigned
long long.
Joel Brobecker [Fri, 3 Mar 2017 16:31:13 +0000 (17:31 +0100)]
local variable watchpoint not deleted after leaving scope
When debugging an Ada program, and inserting a watchpoint tracking
a local variable, the watchpoint doesn't get automatically deleted
upon leaving that variable's scope. This watchpoint then starts
creating problems later on, when trying to resume the program's
execution from a location outside of the watchpoint's scope:
(gdb) c
Continuing.
Breakpoint 2, foo_p708_025 () at foo_p708_025.adb:7
7 Do_Nothing (Val);
(gdb) n
No frame is currently executing in block pck.get_val.
Command aborted.
(gdb) c
Continuing.
No frame is currently executing in block pck.get_val.
Command aborted.
The expected output is the following:
- The program's execution after the first continue should stop
as soon as we reach the end of the watchpoint's scope, and
the debugger should be deleting it.
- Then we can continue until reaching breakpoint 2 above;
- After which we should be able to do next/continue as usual.
The reason the watchpoint is not automatically deleted at scope exit
is because the watchpoint is not marked as being scope-specific
(b->exp_valid_block is equal NULL), and this is because the
symbol lookup for our local variable failed to set the innermost_block
global variable during the lookup.
More precisely, if we look at watch_command_1, we do the following:
innermost_block = NULL;
[...]
exp = parse_exp_1 (&arg, 0, 0, 0);
[...]
exp_valid_block = innermost_block;
Currently, innermost_block stays NULL after the call to parse_exp_1.
Digging further, this innermost_block is typically set during symbol
lookup when the symbol is considered to have a frame-relative address.
For instance, in c-exp.y, we see some code like the following:
if (symbol_read_needs_frame (sym.symbol))
{
if (innermost_block == 0
|| contained_in (sym.block,
innermost_block))
innermost_block = sym.block;
}
We actually have the exact same mechanism in ada-exp.y, except
that it vhas accidently been turned off. See write_var_from_sym,
where we start with:
if (orig_left_context == NULL && symbol_read_needs_frame (sym))
{
if (innermost_block == 0
|| contained_in (block, innermost_block))
innermost_block = block;
}
In this case, orig_left_context is a parameter, and looking at
the point of call in write_var_or_type, we see:
if (nsyms == 1)
{
write_var_from_sym (par_state, block, syms[0].block,
syms[0].symbol);
In the call above, the paramater we are interested in is "block",
which is a parameter for write_var_or_type as well, except we
explicitly override its value at the beginning when found to be NULL:
if (block == NULL)
block = expression_context_block;
So the block we pass to write_var_from_sym is not NULL, and
we therefore don't set innermost_block, which leads to the watchpoint
no longer being marked as scope-specific.
The handling of orig_left_context in write_var_from_sym was there
to handle the case where a user writes an expression where the symbol
is qualified with a scope (Eg: "function::variable"). But it appears
that handling this is specifically here is no longer necessary,
so this patch simply removes that parameter and the associated check,
and then updates all the points of calls.
Interestingly, this also affects GDB/MI, and in particular varobjs,
because local variables are now properly reported as having a block,
which causes the associated varob to have a "thread-id" field.
This patch also adjusts a couple of Ada/gdb-mi tests.
gdb/ChangeLog:
* ada-exp.y (write_var_from_sym): Remove parameter
"orig_left_context". Update all callers.
gdb/testsuite/ChangeLog:
* gdb.ada/scoped_watch: New testcase.
* gdb.ada/watch_arg.exp: Adjust expected behavior to the behavior
which is actually correct.
* gdb.ada/mi_interface.exp: Add missing thread-id in expected varobj.
* gdb.ada/mi_var_array.exp: Add missing thread-id in expected varobj.
Simon Marchi [Thu, 9 Nov 2017 00:42:08 +0000 (19:42 -0500)]
Make encode_actions_rsp use std::vector
Currently, encode_actions_rsp returns two malloc'ed arrays of malloc'ed
strings (char *) by pointer. Change this to use
std::vector<std::string>. This eliminates some cleanups in remote.c.
Regtested on the buildbot.
gdb/ChangeLog:
* tracepoint.h (class collection_list) <stringify>: Return
std::vector<std::string>.
(encode_actions_rsp): Change parameters to
std::vector<std::string> *.
* tracepoint.c (collection_list::stringify): Return
std::vector<std::string> and adjust accordingly.
(encode_actions_rsp): Changee parameters to
std::vector<std::string> and adjust accordingly.
* remote.c (free_actions_list),
free_actions_list_cleanup_wrapper): Remove.
(remote_download_tracepoint): Adjust to std::vector.
H.J. Lu [Wed, 8 Nov 2017 23:56:54 +0000 (15:56 -0800)]
gold: Ignore def/ref from a dynamic object for special symbols
Since special symbol must be defined in a regular object, definition
from a dynamic object should be ignored. If special symbol has the
hidden or internal visibility, reference from a dynamic object should
also be ignored. Also __start and __stop symbols in a dynamic object
shouldn't be preempted.
PR gold/22291
* layout.cc (Layout::define_section_symbols): Use STV_PROTECTED
for __start and __stop symbols.
* symtab.cc (Symbol_table::define_special_symbol): Add an
argument, visibility. Ignore definition and reference from
a dynamic object, depending on visibility.
(Symbol_table::do_define_in_output_data): Pass visibility to
define_special_symbol.
(Symbol_table::do_define_in_output_segment): Likewise.
(Symbol_table::do_define_as_constant): Likewise.
(Symbol_table::add_undefined_symbol_from_command_line): Pass
STV_DEFAULT to define_special_symbol.
* symtab.h (Symbol_table::define_special_symbol): Add an
argument, visibility.
GDB Administrator [Thu, 9 Nov 2017 00:00:11 +0000 (00:00 +0000)]
Automatic date update in version.in
Pedro Alves [Wed, 8 Nov 2017 23:42:11 +0000 (23:42 +0000)]
Avoid expensive complaint calls when complaints are disabled
Running perf on "gdb -nx -readnow -batch gdb", I'm seeing a lot of
time (24%.75!) spent in gettext, via complaints. 'perf report -g' shows:
- 86.23% 0.00% gdb gdb [.] gdb_main
- gdb_main
- 85.60% catch_command_errors
symbol_file_add_main_adapter
symbol_file_add_main
symbol_file_add_main_1
symbol_file_add
- symbol_file_add_with_addrs
- 84.31% dw2_expand_all_symtabs
- dw2_instantiate_symtab
- 83.79% dw2_do_instantiate_symtab
- 70.85% process_die
- 41.11% dwarf_decode_macros
- 41.09% dwarf_decode_macro_bytes
- 39.74% dwarf_decode_macro_bytes
>>>>>>>>>>>>>>>>>>>>>>> + 24.75% __dcigettext <<<<<<<
+ 7.37% macro_define_object_internal
+ 3.16% macro_define_function
0.77% splay_tree_insert
+ 0.76% savestring
+ 0.58% free
0.53% read_indirect_string_at_offset_from
0.54% macro_define_object_internal
0.51% macro_start_file
+ 25.57% process_die
+ 4.07% dwarf_decode_lines
+ 4.28% compute_delayed_physnames
+ 3.85% end_symtab_from_static_block
+ 3.38% load_cu
+ 1.29% end_symtab_get_static_block
+ 0.52% do_my_cleanups
+ 1.29% read_symbols
+ 0.54% gdb_init
The problem is that we're always computing the arguments to pass to
complaint, including passing the format strings through gettext, even
when complaints are disabled. As seen above, gettext can be quite
expensive.
Fix this by wrapping complaint in a macro that skips the real
complaint call when complaints are disabled.
This improves "gdb -nx -readnow -batch gdb" from
~11.0s => ~7.8s with -O2 -g3, and
~6.0s => ~5.3s with -O2 -g.
w/ gcc 5.3.1, on x86_64, for me.
gdb/ChangeLog:
2017-11-08 Pedro Alves <palves@redhat.com>
* complaints.c (stop_whining): Make extern.
(complaint): Rename to ...
(complaint_internal): ... this.
* complaints.h (complaint): Rename to ...
(complaint_internal): ... this.
(complaint): Reimplement as macro around complaint_internal.
gdb/testsuite/ChangeLog:
2017-11-08 Pedro Alves <palves@redhat.com>
* gdb.gdb/complaints.exp (test_initial_complaints)
(test_serial_complaints, test_short_complaints): Call
complaint_internal instead of complaint.
James Clarke [Wed, 8 Nov 2017 23:13:53 +0000 (15:13 -0800)]
Fix problems with -r.
The fix committed for PR gold/19291 ended up breaking other cases. The
commit added adjustment code to write_local_symbols, but in many cases
compute_final_local_value_internal had already subtracted the output
section's address. To fix this, all other adjustments are now removed, so
only the one in write_local_symbols is left.
gold/
PR gold/22266
* object.cc (Sized_relobj_file::compute_final_local_value_internal):
Drop relocatable parameter and stop adjusting output value based on
it.
(Sized_relobj_file::compute_final_local_value): Stop passing
relocatable to compute_final_local_value_internal.
(Sized_relobj_file::do_finalize_local_symbols): Ditto.
* object.h (Sized_relobj_file::compute_final_local_value_internal):
Drop relocatable parameter.
Eric Christopher [Wed, 8 Nov 2017 22:03:55 +0000 (14:03 -0800)]
Apply:
2017-11-08 Kyle Butt <iteratee@google.com>
* object.cc (do_find_special_sections): Fix a thinko with memmem return
values and check for != NULL rather than == 0.
Djordje Todorovic [Wed, 8 Nov 2017 21:19:05 +0000 (21:19 +0000)]
Add test for fetching TLS from core file
A correct PID is needed by `libthread_db' library supplied with
glibc repository revisions before commit
c579f48edba8 ("Remove
cached PID/TID in clone") or versions before 2.25 release for
GDB to fetch value of TLS variable from core file. On MIPS
platforms it was omitted and fetching value of TLS variable was not
available.
This adds a new test in order to be sure if GDB on native platforms
can successfully fetch value of TLS variable.
gdb/testsuite:
* gdb.threads/tls-core.c: New file.
* gdb.threads/tls-core.exp: Likewise.
Djordje Todorovic [Wed, 8 Nov 2017 21:19:05 +0000 (21:19 +0000)]
BFD: Extract PID from MIPS core dump file
On MIPS o32, n32 and n64 platforms, PID information was not
correctly propagated from core dump file to internal GDB
structures. This patch fixes that behavior.
A correct PID is needed by `libthread_db' library supplied with
glibc repository revisions before commit
c579f48edba8 ("Remove
cached PID/TID in clone") or released versions before 2.25 for
GDB to fetch value of TLS variable from core file.
bfd/ChangeLog:
* elf32-mips.c (elf32_mips_grok_psinfo): Extract core->pid.
* elf64-mips.c (elf64_mips_grok_psinfo): Likewise.
* elfn32-mips.c (elf32_mips_grok_psinfo): Likewise.
Djordje Todorovic [Wed, 8 Nov 2017 21:19:05 +0000 (21:19 +0000)]
BFD: Write Linux core PRSTATUS note into MIPS core file
On MIPS o32, n32 and n64 platforms information such as PID was not
correctly written into core file from GDB.
This fixes that behavior.
bfd/ChangeLog:
* elf32-mips.c (elf32_mips_write_core_note): New function.
(elf_backend_write_core_note): New macro.
* elf64-mips.c (elf64_mips_write_core_note): New function.
(elf_backend_write_core_note): New macro.
* elfn32-mips.c (elf32_mips_write_core_note): New function.
(elf_backend_write_core_note): New macro.
Tom Tromey [Fri, 3 Nov 2017 20:55:39 +0000 (14:55 -0600)]
Remove symbolp vector
This removes the symbolp typedef from dwarf2read.c and converts the
associated VEC uses to std::vector. This fixes a latent possible
memory leak if an exception were thrown, because there were no
cleanups installed for these VECs.
Regression tested on the buildbot.
gdb/ChangeLog
2017-11-08 Tom Tromey <tom@tromey.com>
* dwarf2read.c (symbolp): Remove typedef.
(read_func_scope): Use std::vector.
(process_structure_scope): Use std::vector.
Pedro Alves [Wed, 8 Nov 2017 14:22:34 +0000 (14:22 +0000)]
Make the linespec/location completer ignore data symbols
Currently "b foo[TAB]" offers data symbols as completion candidates.
This doesn't make sense, since you can't set a breakpoint on data
symbols, only on code symbols.
(gdb) b globa[TAB]
(gdb) b global [ENTER]
Function "global" not defined.
Make breakpoint pending on future shared library load? (y or [n]) n
(gdb) info symbol global
global in section .rodata
So this patch makes linespec completion ignore data symbols.
gdb/ChangeLog:
2017-11-08 Pedro Alves <palves@redhat.com>
* ada-lang.c (ada_make_symbol_completion_list): Use
completion_skip_symbol.
* symtab.c (symbol_is_function_or_method(minimal_symbol*)): New.
(symbol_is_function_or_method(symbol*)): New.
(add_symtab_completions): Add complete_symbol_mode parameter. Use
completion_skip_symbol.
(default_collect_symbol_completion_matches_break_on): Use
completion_skip_symbol. Pass down mode.
(collect_file_symbol_completion_matches): Pass down mode.
* symtab.h (symbol_is_function_or_method): New declarations.
(completion_skip_symbol): New template function.
Pedro Alves [Wed, 8 Nov 2017 14:22:34 +0000 (14:22 +0000)]
Use search_domain::FUNCTIONS_DOMAIN when setting breakpoints
While working on C++ support for wild matching, I noticed that
attaching to my system's Firefox (which uses .gdb_index), setting a
break at main and bailing, like:
$ gdb --batch -q -p `pidof firefox` -ex "b main"
would get substancially slower. It'd take around 20s when currently
it takes 3s.
The problem is that gdb would expand more symtabs than currently,
because Firefox has symbols named like "nsHtml5Atoms::main",
"nsGkAtoms::main", etc., which given wild matching, match.
However, these are not function symbols, [they're "(nsIAtom *)"], so
it seems silly that they'd cause expansion in the first place.
The .gdb_index code (dwarf2read.c:dw2_expand_marked_cus) filters out
symbols matches based on search_domain:
case VARIABLES_DOMAIN:
if (symbol_kind != GDB_INDEX_SYMBOL_KIND_VARIABLE)
continue;
break;
case FUNCTIONS_DOMAIN:
if (symbol_kind != GDB_INDEX_SYMBOL_KIND_FUNCTION)
continue;
break;
case TYPES_DOMAIN:
if (symbol_kind != GDB_INDEX_SYMBOL_KIND_TYPE)
continue;
break;
default:
break;
however, we're currently passing down search_domain::ALL_DOMAIN when
we know we're looking for functions, for no good reason. This patch
fixes that.
It seems like search_domain is underutilized throughout, but I'll
leave using it more for another pass.
gdb/ChangeLog:
2017-11-08 Pedro Alves <palves@redhat.com>
* linespec.c (iterate_over_all_matching_symtabs): Add
search_domain parameter. Pass it down to expand_symtabs_matching.
(decode_objc): Request FUNCTIONS_DOMAIN symbols only.
(lookup_prefix_sym): Adjust by passing ALL_DOMAIN as
search_domain.
(add_all_symbol_names_from_pspace): Add search_domain parameter.
Pass it down.
(find_method, find_function_symbols): Request FUNCTIONS_DOMAIN
symbols.
(add_matching_symbols_to_info): Add search_domain parameter. Pass
it down.
Pedro Alves [Wed, 8 Nov 2017 14:22:34 +0000 (14:22 +0000)]
Simplify completion_list_add_name | remove sym_text / sym_text_len
sym_text_len existed to strip parameters out of the lookup name. Now
that that's handled by the lookup_name_info objects, the
sym_text/sym_text_len parameters are no longer necessary.
gdb/ChangeLog:
2017-11-08 Pedro Alves <palves@redhat.com>
* ada-lang.c (ada_make_symbol_completion_list): Remove text and
text_len locals and don't pass them down.
* symtab.c (completion_list_add_name): Remove
sym_text/sym_text_len parameters and adjust.
(completion_list_add_symbol, completion_list_add_msymbol)
(completion_list_objc_symbol, completion_list_add_fields)
(add_symtab_completions): Likewise.
(default_collect_symbol_completion_matches_break_on)
(collect_file_symbol_completion_matches): Remove sym_text_len
local and don't pass it down.
* symtab.h (completion_list_add_name): Remove
sym_text/sym_text_len parameters.
Pedro Alves [Wed, 8 Nov 2017 14:49:10 +0000 (14:49 +0000)]
lookup_name_info::make_ignore_params
A few places in the completion code look for a "(" to find a
function's parameter list, in order to strip it, because psymtabs (and
gdb index) don't include parameter info in the symbol names.
See compare_symbol_name and
default_collect_symbol_completion_matches_break_on.
This is too naive. Consider:
ns_overload2_test::([TAB]
We'd want to complete that to:
ns_overload2_test::(anonymous namespace)::struct_overload2_test
Or:
b (anonymous namespace)::[TAB]
That currently completes to:
b (anonymous namespace)
Which is obviously broken. This patch makes that work.
Also, the current compare_symbol_name hack means that while this
works:
"b function([TAB]" -> "b function()"
This does not:
"b function ([TAB]"
This patch fixes that. Whitespace "ignoring" now Just Works, i.e.,
assuming a symbol named "function(int, long)", this:
b function ( int , lon[TAB]
completes to:
b function ( int , long)
To address all of this, this patch builds on top of the rest of the
series, and pushes the responsibility of stripping parameters from a
lookup name to the new lookup_name_info object, where we can apply
per-language rules. Also note that we now only make a version of the
lookup name with parameters stripped out where it's actually required
to do that, in the psymtab and GDB index code.
For C++, the right way to strip parameters is with "cp_remove_params",
which uses a real parser (cp-name-parser.y) to split the name into a
component tree and then discards parameters.
The trouble for completion is that in that case we have an incomplete
name, like "foo::func(int" and thus cp_remove_params throws an error.
This patch sorts that by adding a cp_remove_params_if_any variant of
cp_remove_params that tries removing characters from the end of the
string until cp_remove_params works. So cp_remove_params_if_any
behaves like this:
With a complete name:
"foo::func(int)" => foo::func(int) # cp_remove_params_1 succeeds the first time.
With an incomplete name:
"foo::func(int" => NULL # cp_remove_params fails the first time.
"foo::func(in" => NULL # and again...
"foo::func(i" => NULL # and again...
"foo::func(" => NULL # and again...
"foo::func" => "foo::func" # success!
Note that even if this approach removes significant rightmost
characters, it's still OK, because this parameter stripping is only
necessary for psymtabs and gdb index, where we're determining whether
to expand a symbol table. Say cp_remove_params_if_any returned
"foo::" above for "foo::func(int". That'd cause us to expand more
symtabs than ideal (because we'd expand all symtabs with symbols that
start with "foo::", not just "foo::func"), but then when we actually
look for completion matches, we'd still use the original lookup name,
with parameter information ["foo::func(int"], and thus we'll return no
false positive to the user. Whether the stripping works as intended
and doesn't strip too much is thus covered by a unit test instead of a
testsuite test.
The "if_any" part of the name refers to the fact that while
cp_remove_params returns NULL if the input name has no parameters in
the first place, like:
"foo::func" => NULL # cp_remove_params
cp_remove_params_if_any still returns the function name:
"foo::func" => "foo::func" # cp_remove_params_if_any
gdb/ChangeLog:
2017-11-08 Pedro Alves <palves@redhat.com>
* Makefile.in (SUBDIR_UNITTESTS_SRCS): Add
unittests/lookup_name_info-selftests.c.
(SUBDIR_UNITTESTS_OBS): Add lookup_name_info-selftests.o.
* cp-support.c: Include "selftest.h".
(cp_remove_params_1): Rename from cp_remove_params. Add
'require_param' parameter, and handle it.
(cp_remove_params): Reimplement.
(cp_remove_params_if_any): New.
(selftests::quote): New.
(selftests::check_remove_params): New.
(selftests::test_cp_remove_params): New.
(_initialize_cp_support): Install
selftests::test_cp_remove_params.
* cp-support.h (cp_remove_params_if_any): Declare.
* dwarf2read.c :Include "selftest.h".
(dw2_expand_symtabs_matching_symbol): Use
lookup_name_info::make_ignore_params.
(selftests::dw2_expand_symtabs_matching::mock_mapped_index)
(selftests::dw2_expand_symtabs_matching::string_or_null)
(selftests::dw2_expand_symtabs_matching::check_match)
(selftests::dw2_expand_symtabs_matching::test_symbols)
(selftests::dw2_expand_symtabs_matching::run_test): New.
(_initialize_dwarf2_read): Register
selftests::dw2_expand_symtabs_matching::run_test.
* psymtab.c (psym_expand_symtabs_matching): Use
lookup_name_info::make_ignore_params.
* symtab.c (demangle_for_lookup_info::demangle_for_lookup_info):
If the lookup name wants to ignore parameters, strip them.
(compare_symbol_name): Remove sym_text/sym_text_len parameters and
code handling '('.
(completion_list_add_name): Don't pass down sym_text/sym_text_len.
(default_collect_symbol_completion_matches_break_on): Don't try to
strip parameters.
* symtab.h (lookup_name_info::lookup_name_info): Add
'ignore_parameters' parameter.
(lookup_name_info::ignore_parameters)
(lookup_name_info::make_ignore_params): New methods.
(lookup_name_info::m_ignore_parameters): New field.
* unittests/lookup_name_info-selftests.c: New file.
Pedro Alves [Wed, 8 Nov 2017 14:22:32 +0000 (14:22 +0000)]
Reorder/reindent dw2_expand_symtabs_matching & friends
The previous patch had added dw2_expand_symtabs_matching_symbol and
dw2_expand_marked_cus forward declarations and did not reindent
dw2_expand_marked_cus to avoid moving the code around while changing
it at the same time.
gdb/ChangeLog:
2017-11-08 Pedro Alves <palves@redhat.com>
* dwarf2read.c (dw2_expand_marked_cus)
(dw2_expand_symtabs_matching_symbol): Remove forward declarations.
(dw2_expand_symtabs_matching): Move further below.
(dw2_expand_marked_cus): Reindent.
Pedro Alves [Wed, 8 Nov 2017 14:22:32 +0000 (14:22 +0000)]
Optimize .gdb_index symbol name searching
As mentioned in the previous patch, .gdb_index name lookup got
significantly slower with the previous patch.
This patch addresses that, and in the process makes .gdb_index name
searching faster than what we had before the previous patch, even.
Using the same test:
$ cat script.cmd
set pagination off
set $count = 0
while $count < 400
complete b string_prin
printf "count = %d\n", $count
set $count = $count + 1
end
$ time gdb --batch -q ./gdb-with-index -ex "source script.cmd"
I got, before the previous patch (-O2, x86-64):
real 0m1.773s
user 0m1.737s
sys 0m0.040s
and after this patch:
real 0m1.361s
user 0m1.315s
sys 0m0.040s
The basic idea here is simple: instead of always iterating over all
the symbol names in the index, we build an accelerator/sorted name
table and binary search names in it.
Later in the series, we'll want to support wild matching for C++ too,
so this mechanism already considers that. For example, say that
you're looking up functions/methods named "func", no matter the
containing namespace/class. If we sorted the table by qualified name,
then we obviously wouldn't be able to find those symbols with a binary
search:
func
ns1::a::b::func
ns1::b::func
ns2::func
(function symbol names in .gdb_index have no parameter info, like psymbols)
To address that out, we put an entry for each name component in the
sorted table. something like this:
Table Entry Actual symbol
---------------------------------
func func
func ns1::a::b::func
b::func ns1::a::b::func
a::b::func ns1::a::b::func
ns1::a::b::func ns1::a::b::func
func ns1::b::func
b::func ns1::b::func
ns1::b::func ns1::b::func
func ns2::func
ns2::func ns2::func
Which sorted results in this:
Table Entry Actual symbol
---------------------------------
a::b::func ns1::a::b::func
b::func ns1::a::b::func
b::func ns1::b::func
func func
func ns1::a::b::func
func ns1::b::func
func ns2::func
ns1::a::b::func ns1::a::b::func
ns1::b::func ns1::b::func
ns2::func ns2::func
And we can binary search this.
Note that a binary search approach works for both completion and
regular lookup, while a name hashing approach only works for normal
symbol looking, since obviously "fun" and "func" have different
hashes.
At first I was a bit wary of these tables potentially growing GDB's
memory significantly. But I did an experiment that convinced it's not
a worry at all. I hacked gdb to count the total number of entries in
all the tables, attached that gdb to my system/Fedora's Firefox
(Fedora's debug packages uses .gdb_index), did "set max-completions
unlimited", and then hit "b [TAB]" to cause everything to expand.
That resulted in 1351355 name_components. Each entry takes 8 bytes,
so that's
10810840 bytes (ignoring std::vector overhead), or ~10.3 MB.
That's IMO too small to worry about, given GDB was using over 7400MB
total at that point. I.e., we're talking about 0.1% increase.
dw2_expand_symtabs_matching unit tests covering this will be added in
a follow up patch.
If the size of this table turns out to be a concern, I have an idea to
reduce the size of the table further at the expense of a bit more code
-- the vast majority of the name offsets are either 0 or fit in
8-bits:
total name_component = 1351355, of which,
name_component::name_offset instances need 0 bits = 679531
name_component::name_offset instances need 8 bits = 669526
name_component::name_offset instances need 16 bits = 2298
name_component::name_offset instances need 32 bits = 0
name_component::idx instances need 0 bits = 51
name_component::idx instances need 8 bits = 8361
name_component::idx instances need 16 bits = 280329
name_component::idx instances need 32 bits = 1062614
so we could have separate tables for 0 name_offset, 8-bit name_offset
and 32-bit name_offset. That'd give us roughly:
679531 * 0 + 669526 * 1 + 2298 * 4 + 1062614 * 4 = 4929174, or ~4.7MB
with only 8-bit and 32-bit tables, that'd be:
1349057 * 1 + 2298 * 4 + 4 * 1351355 = 6763669 bytes, or ~6.5MB.
I don't think we need to bother though.
I also timed:
$ time gdb --batch -q -p `pidof firefox`
$ time gdb --batch -q -p `pidof firefox` -ex "b main"
$ time gdb --batch -q -p `pidof firefox` -ex "set max-completion unlimited" -ex "complete b "
and compared before previous patch vs this patch, and I didn't see a
significant difference, seemingly because time to read debug info
dominates. The "complete b " variant of the test takes ~2min
currently... (I have a follow up series that speeds that up
somewhat.)
gdb/ChangeLog:
2017-11-08 Pedro Alves <palves@redhat.com>
* dwarf2read.c (byte_swap, MAYBE_SWAP): Move higher up in file.
(struct name_component): New.
(mapped_index::name_components): New field.
(mapped_index::symbol_name_at): New method.
(dwarf2_read_index): Call mapped_index ctor.
(dw2_map_matching_symbols): Add comment about name_components
table.
(dw2_expand_symtabs_matching): Factor part to...
(dw2_expand_symtabs_matching_symbol): ... this new function.
Build name components table, and lookup symbols in it before
calling the name matcher.
(dw2_expand_marked_cus): New, factored out from
dw2_expand_symtabs_matching.
(dwarf2_per_objfile_free): Call the mapped_index's dtor.
Pedro Alves [Wed, 8 Nov 2017 14:22:32 +0000 (14:22 +0000)]
Introduce lookup_name_info and generalize Ada's FULL/WILD name matching
Summary:
- This is preparation for supporting wild name matching on C++ too.
- This is also preparation for TAB-completion fixes.
- Makes symbol name matching (think strcmp_iw) be based on a per-language method.
- Merges completion and non-completion name comparison (think
language_ops::la_get_symbol_name_cmp generalized).
- Avoid re-hashing lookup name multiple times
- Centralizes preparing a name for lookup (Ada name encoding / C++ Demangling),
both completion and non-completion.
- Fixes Ada latent bug with verbatim name matches in expressions
- Makes ada-lang.c use common|symtab.c completion code a bit more.
Ada's wild matching basically means that
"(gdb) break foo"
will find all methods named "foo" in all packages. Translating to
C++, it's roughly the same as saying that "break klass::method" sets
breakpoints on all "klass::method" methods of all classes, no matter
the namespace. A following patch will teach GDB about fullname vs
wild matching for C++ too. This patch is preparatory work to get
there.
Another idea here is to do symbol name matching based on the symbol
language's algorithm. I.e., avoid dependency on current language set.
This allows for example doing
(gdb) b foo::bar< int > (<tab>
and having gdb name match the C++ symbols correctly even if the
current language is C or Assembly (or Rust, or Ada, or ...), which can
easily happen if you step into an Assembly/C runtime library frame.
By encapsulating all the information related to a lookup name in a
class, we can also cache hash computation for a given language in the
lookup name object, to avoid recomputing it over and over.
Similarly, because we don't really know upfront which languages the
lookup name will be matched against, for each language we store the
lookup name transformed into a search name. E.g., for C++, that means
demangling the name. But for Ada, it means encoding the name. This
actually forces us to centralize all the different lookup name
encoding in a central place, resulting in clearer code, IMO. See
e.g., the new ada_lookup_name_info class.
The lookup name -> symbol search name computation is also done only
once per language.
The old language->la_get_symbol_name_cmp / symbol_name_cmp_ftype are
generalized to work with both completion, and normal symbol look up.
At some point early on, I had separate completion vs non-completion
language vector entry points, but a single method ends up being better
IMO for simplifying things -- the more we merge the completion /
non-completion name lookup code paths, the less changes for bugs
causing completion vs normal lookup finding different symbols.
The ada-lex.l change is necessary because when doing
(gdb) p <UpperCase>
then the name that is passed to write_ write_var_or_type ->
ada_lookup_symbol_list misses the "<>", i.e., it's just "UpperCase",
and we end up doing a wild match against "UpperCase" lowercased by
ada_lookup_name_info's constructor. I.e., "uppercase" wouldn't ever
match "UpperCase", and the symbol lookup fails.
This wouldn't cause any regression in the testsuite, but I added a new
test that would pass before the patch and fail after, if it weren't
for that fix.
This is latent bug that happens to go unnoticed because that
particular path was inconsistent with the rest of Ada symbol lookup by
not lowercasing the lookup name.
Ada's symbol_completion_add is deleted, replaced by using common
code's completion_list_add_name. To make the latter work for Ada, we
needed to add a new output parameter, because Ada wants to return back
a custom completion candidates that are not the symbol name.
With this patch, minimal symbol demangled name hashing is made
consistent with regular symbol hashing. I.e., it now goes via the
language vector's search_name_hash method too, as I had suggested in a
previous patch.
dw2_expand_symtabs_matching / .gdb_index symbol names were a
challenge. The problem is that we have no way to telling what is the
language of each symbol name found in the index, until we expand the
corresponding full symbol, which is off course what we're trying to
avoid. Language information is simply not considered in the index
format... Since the symbol name hashing and comparison routines are
per-language, we now have a problem. The patch sorts this out by
matching each name against all languages. This is inneficient, and
indeed slows down completion several times. E.g., with:
$ cat script.cmd
set pagination off
set $count = 0
while $count < 400
complete b string_prin
printf "count = %d\n", $count
set $count = $count + 1
end
$ time gdb --batch -q ./gdb-with-index -ex "source script-string_printf.cmd"
I get, before patch (-O2, x86-64):
real 0m1.773s
user 0m1.737s
sys 0m0.040s
While after patch (-O2, x86-64):
real 0m9.843s
user 0m9.482s
sys 0m0.034s
However, the following patch will optimize this, and will actually
make this use case faster compared to the "before patch" above:
real 0m1.321s
user 0m1.285s
sys 0m0.039s
gdb/ChangeLog:
2017-11-08 Pedro Alves <palves@redhat.com>
* ada-lang.c (ada_encode): Rename to ..
(ada_encode_1): ... this. Add throw_errors parameter and handle
it.
(ada_encode): Reimplement.
(match_name): Delete, folded into full_name.
(resolve_subexp): No longer pass the encoded name to
ada_lookup_symbol_list.
(should_use_wild_match): Delete.
(name_match_type_from_name): New.
(ada_lookup_simple_minsym): Use lookup_name_info and the
language's symbol_name_matcher_ftype.
(add_symbols_from_enclosing_procs, ada_add_local_symbols)
(ada_add_block_renamings): Adjust to use lookup_name_info.
(ada_lookup_name): New.
(add_nonlocal_symbols, ada_add_all_symbols)
(ada_lookup_symbol_list_worker, ada_lookup_symbol_list)
(ada_iterate_over_symbols): Adjust to use lookup_name_info.
(ada_name_for_lookup): Delete.
(ada_lookup_encoded_symbol): Construct a verbatim name.
(wild_match): Reverse sense of return type. Use bool.
(full_match): Reverse sense of return type. Inline bits of old
match_name here.
(ada_add_block_symbols): Adjust to use lookup_name_info.
(symbol_completion_match): Delete, folded into...
(ada_lookup_name_info::matches): ... .this new method.
(symbol_completion_add): Delete.
(ada_collect_symbol_completion_matches): Add name_match_type
parameter. Adjust to use lookup_name_info and
completion_list_add_name.
(get_var_value, ada_add_global_exceptions): Adjust to use
lookup_name_info.
(ada_get_symbol_name_cmp): Delete.
(do_wild_match, do_full_match): New functions.
(ada_lookup_name_info::ada_lookup_name_info): New method.
(ada_symbol_name_matches, ada_get_symbol_name_matcher): New
functions.
(ada_language_defn): Install ada_get_symbol_name_matcher.
* ada-lex.l (processId): If name starts with '<', copy it
verbatim.
* block.c (block_iter_match_step, block_iter_match_first)
(block_iter_match_next, block_lookup_symbol)
(block_lookup_symbol_primary, block_find_symbol): Adjust to use
lookup_name_info.
* block.h (block_iter_match_first, block_iter_match_next)
(ALL_BLOCK_SYMBOLS_WITH_NAME): Adjust to use lookup_name_info.
* c-lang.c (c_language_defn, cplus_language_defn)
(asm_language_defn, minimal_language_defn): Adjust comments to
refer to la_get_symbol_name_matcher.
* completer.c (complete_files_symbols)
(collect_explicit_location_matches, symbol_completer): Pass a
symbol_name_match_type down.
* completer.h (class completion_match, completion_match_result):
New classes.
(completion_tracker::reset_completion_match_result): New method.
(completion_tracker::m_completion_match_result): New field.
* cp-support.c (make_symbol_overload_list_block): Adjust to use
lookup_name_info.
(cp_fq_symbol_name_matches, cp_get_symbol_name_matcher): New
functions.
* cp-support.h (cp_get_symbol_name_matcher): New declaration.
* d-lang.c: Adjust comments to refer to
la_get_symbol_name_matcher.
* dictionary.c (dict_vector) <iter_match_first, iter_match_next>:
Adjust to use lookup_name_info.
(dict_iter_match_first, dict_iter_match_next)
(iter_match_first_hashed, iter_match_next_hashed)
(iter_match_first_linear, iter_match_next_linear): Adjust to work
with a lookup_name_info.
* dictionary.h (dict_iter_match_first, dict_iter_match_next):
Likewise.
* dwarf2read.c (dw2_lookup_symbol): Adjust to use lookup_name_info.
(dw2_map_matching_symbols): Adjust to use symbol_name_match_type.
(gdb_index_symbol_name_matcher): New class.
(dw2_expand_symtabs_matching) Adjust to use lookup_name_info and
gdb_index_symbol_name_matcher. Accept a NULL symbol_matcher.
* f-lang.c (f_collect_symbol_completion_matches): Adjust to work
with a symbol_name_match_type.
(f_language_defn): Adjust comments to refer to
la_get_symbol_name_matcher.
* go-lang.c (go_language_defn): Adjust comments to refer to
la_get_symbol_name_matcher.
* language.c (default_symbol_name_matcher)
(language_get_symbol_name_matcher): New functions.
(unknown_language_defn, auto_language_defn): Adjust comments to
refer to la_get_symbol_name_matcher.
* language.h (symbol_name_cmp_ftype): Delete.
(language_defn) <la_collect_symbol_completion_matches>: Add match
type parameter.
<la_get_symbol_name_cmp>: Delete field.
<la_get_symbol_name_matcher>: New field.
<la_iterate_over_symbols>: Adjust to use lookup_name_info.
(default_symbol_name_matcher, language_get_symbol_name_matcher):
Declare.
* linespec.c (iterate_over_all_matching_symtabs)
(iterate_over_file_blocks): Adjust to use lookup_name_info.
(find_methods): Add language parameter, and use lookup_name_info
and the language's symbol_name_matcher_ftype.
(linespec_complete_function): Adjust.
(lookup_prefix_sym): Use lookup_name_info.
(add_all_symbol_names_from_pspace): Adjust.
(find_superclass_methods): Add language parameter and pass it
down.
(find_method): Pass symbol language down.
(find_linespec_symbols): Don't demangle or Ada encode here.
(search_minsyms_for_name): Add lookup_name_info parameter.
(add_matching_symbols_to_info): Add name_match_type parameter.
Use lookup_name_info.
* m2-lang.c (m2_language_defn): Adjust comments to refer to
la_get_symbol_name_matcher.
* minsyms.c: Include <algorithm>.
(add_minsym_to_demangled_hash_table): Remove table parameter and
add objfile parameter. Use search_name_hash, and add language to
demangled languages vector.
(struct found_minimal_symbols): New struct.
(lookup_minimal_symbol_mangled, lookup_minimal_symbol_demangled):
New functions.
(lookup_minimal_symbol): Adjust to use them. Don't canonicalize
input names here. Use lookup_name_info instead. Lookup up
demangled names once for each language in the demangled names
vector.
(iterate_over_minimal_symbols): Use lookup_name_info. Lookup up
demangled names once for each language in the demangled names
vector.
(build_minimal_symbol_hash_tables): Adjust.
* minsyms.h (iterate_over_minimal_symbols): Adjust to pass down a
lookup_name_info.
* objc-lang.c (objc_language_defn): Adjust comment to refer to
la_get_symbol_name_matcher.
* objfiles.h: Include <vector>.
(objfile_per_bfd_storage) <demangled_hash_languages>: New field.
* opencl-lang.c (opencl_language_defn): Adjust comment to refer to
la_get_symbol_name_matcher.
* p-lang.c (pascal_language_defn): Adjust comment to refer to
la_get_symbol_name_matcher.
* psymtab.c (psym_lookup_symbol): Use lookup_name_info.
(match_partial_symbol): Use symbol_name_match_type,
lookup_name_info and psymbol_name_matches.
(lookup_partial_symbol): Use lookup_name_info.
(map_block): Use symbol_name_match_type and lookup_name_info.
(psym_map_matching_symbols): Use symbol_name_match_type.
(psymbol_name_matches): New.
(recursively_search_psymtabs): Use lookup_name_info and
psymbol_name_matches. Rename 'kind' parameter to 'domain'.
(psym_expand_symtabs_matching): Use lookup_name_info. Rename
'kind' parameter to 'domain'.
* rust-lang.c (rust_language_defn): Adjust comment to refer to
la_get_symbol_name_matcher.
* symfile-debug.c (debug_qf_map_matching_symbols)
(debug_qf_map_matching_symbols): Use symbol_name_match_type.
(debug_qf_expand_symtabs_matching): Use lookup_name_info.
* symfile.c (expand_symtabs_matching): Use lookup_name_info.
* symfile.h (quick_symbol_functions) <map_matching_symbols>:
Adjust to use symbol_name_match_type.
<expand_symtabs_matching>: Adjust to use lookup_name_info.
(expand_symtabs_matching): Adjust to use lookup_name_info.
* symmisc.c (maintenance_expand_symtabs): Use
lookup_name_info::match_any ().
* symtab.c (symbol_matches_search_name): New.
(eq_symbol_entry): Adjust to use lookup_name_info and the
language's matcher.
(demangle_for_lookup_info::demangle_for_lookup_info): New.
(lookup_name_info::match_any): New.
(iterate_over_symbols, search_symbols): Use lookup_name_info.
(compare_symbol_name): Add language, lookup_name_info and
completion_match_result parameters, and use them.
(completion_list_add_name): Make extern. Add language and
lookup_name_info parameters. Use them.
(completion_list_add_symbol, completion_list_add_msymbol)
(completion_list_objc_symbol): Add lookup_name_info parameters and
adjust. Pass down language.
(completion_list_add_fields): Add lookup_name_info parameters and
adjust. Pass down language.
(add_symtab_completions): Add lookup_name_info parameters and
adjust.
(default_collect_symbol_completion_matches_break_on): Add
name_match_type parameter, and use it. Use lookup_name_info.
(default_collect_symbol_completion_matches)
(collect_symbol_completion_matches): Add name_match_type
parameter, and pass it down.
(collect_symbol_completion_matches_type): Adjust.
(collect_file_symbol_completion_matches): Add name_match_type
parameter, and use lookup_name_info.
* symtab.h: Include <string> and "common/gdb_optional.h".
(enum class symbol_name_match_type): New.
(class ada_lookup_name_info): New.
(struct demangle_for_lookup_info): New.
(class lookup_name_info): New.
(symbol_name_matcher_ftype): New.
(SYMBOL_MATCHES_SEARCH_NAME): Use symbol_matches_search_name.
(symbol_matches_search_name): Declare.
(MSYMBOL_MATCHES_SEARCH_NAME): Delete.
(default_collect_symbol_completion_matches)
(collect_symbol_completion_matches)
(collect_file_symbol_completion_matches): Add name_match_type
parameter.
(iterate_over_symbols): Use lookup_name_info.
(completion_list_add_name): Declare.
* utils.c (enum class strncmp_iw_mode): Moved to utils.h.
(strncmp_iw_with_mode): Now extern.
* utils.h (enum class strncmp_iw_mode): Moved from utils.c.
(strncmp_iw_with_mode): Declare.
gdb/testsuite/ChangeLog:
2017-11-08 Pedro Alves <palves@redhat.com>
* gdb.ada/complete.exp (p <Exported_Capitalized>): New test.
(p Exported_Capitalized): New test.
(p exported_capitalized): New test.
Pedro Alves [Wed, 8 Nov 2017 15:07:56 +0000 (15:07 +0000)]
Per-language symbol name hashing algorithm
Currently, we have a mess of symbol name hashing/comparison routines.
There's msymbol_hash for mangled names, and dict_hash and
msymbol_hash_iw for demangled names. Then there's strcmp_iw,
strcmp_iw_ordered and Ada's full_match/wild_match, which all have to
agree with the hashing routines. That's why dict_hash is really about
Ada names. From the inconsistency department, minimal symbol hashing
doesn't go via dict_hash, so Ada's wild matching can't ever work with
minimal symbols.
This patch starts fixing this, by doing two things:
#1 - adds a language vector method to let each language decide how to
compute a symbol name hash.
#2 - makes dictionaries know the language of the symbols they hold,
and then use the dictionaries language to decide which hashing
method to use.
For now, this is just scaffolding, since all languages install the
default method. The series will make C++ install its own hashing
method later on, and will add per-language symbol name comparison
routines too.
This patch was originally based on a patch that Keith wrote for the
libcc1/C++ WIP support.
gdb/ChangeLog:
2017-11-08 Keith Seitz <keiths@redhat.com>
Pedro Alves <palves@redhat.com>
* ada-lang.c (ada_language_defn): Install
default_search_name_hash.
* buildsym.c (struct buildsym_compunit): <language>: New field.
(finish_block_internal): Pass language when creating dictionaries.
(start_buildsym_compunit, start_symtab): New language parameters.
Use them.
(restart_symtab): Pass down compilation unit's language.
* buildsym.h (enum language): Forward declare.
(start_symtab): New 'language' parameter.
* c-lang.c (c_language_defn, cplus_language_defn)
(asm_language_defn, minimal_language_defn): Install
default_search_name_hash.
* coffread.c (coff_start_symtab): Adjust.
* d-lang.c (d_language_defn): Install default_search_name_hash.
* dbxread.c (struct symloc): Add 'pst_language' field.
(PST_LANGUAGE): Define.
(start_psymtab, read_ofile_symtab): Use it.
(process_one_symbol): New 'language' parameter. Pass it down.
* dictionary.c (struct dictionary) <language>: New field.
(DICT_LANGUAGE): Define.
(dict_create_hashed, dict_create_hashed_expandable)
(dict_create_linear, dict_create_linear_expandable): New parameter
'language'. Set the dictionary's language.
(iter_match_first_hashed): Adjust to rename.
(insert_symbol_hashed): Assert we don't see mismatching
languages. Adjust to rename.
(dict_hash): Rename to ...
(default_search_name_hash): ... this and make extern.
* dictionary.h (struct language_defn): Forward declare.
(dict_create_hashed): New parameter 'language'.
* dwarf2read.c (dwarf2_start_symtab): Pass down language.
* f-lang.c (f_language_defn): Install default_search_name_hash.
* go-lang.c (go_language_defn): Install default_search_name_hash.
* jit.c (finalize_symtab): Pass compunit's language to dictionary
creation.
* language.c (unknown_language_defn, auto_language_defn):
* language.h (language_defn::la_search_name_hash): New field.
(default_search_name_hash): Declare.
* m2-lang.c (m2_language_defn): Install default_search_name_hash.
* mdebugread.c (new_block): New parameter 'language'.
* mdebugread.c (parse_symbol): Pass symbol language to block
allocation.
(psymtab_to_symtab_1): Pass down language.
(new_symtab): Pass compunit's language to block allocation.
* objc-lang.c (objc_language_defn): Install
default_search_name_hash.
* opencl-lang.c (opencl_language_defn):
* p-lang.c (pascal_language_defn): Install
default_search_name_hash.
* rust-lang.c (rust_language_defn): Install
default_search_name_hash.
* stabsread.h (enum language): Forward declare.
(process_one_symbol): Add 'language' parameter.
* symtab.c (search_name_hash): New function.
* symtab.h (search_name_hash): Declare.
* xcoffread.c (read_xcoff_symtab): Pass language to start_symtab.