• R/O
  • HTTP
  • SSH
  • HTTPS

Liste der Commits

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


users/hjl/pr22393/relro
RSS
Rev. Zeit Autor
391c2c3 users/hjl/pr22393/relro 2018-01-10 02:32:58 H.J. Lu

x86-64: Add tests for -z separate-code -z max-page-size=0x1000

PR ld/22393
* testsuite/ld-x86-64/pr22393-3a.c: New file.
* testsuite/ld-x86-64/pr22393-3a.rd: Likewise.
* testsuite/ld-x86-64/pr22393-3b.c: Likewise.
* testsuite/ld-x86-64/pr22393-3b.rd: Likewise.
* testsuite/ld-x86-64/x86-64.exp: Run tests for -z separate-code
-z max-page-size=0x1000.

37c28ba 2018-01-10 02:28:59 H.J. Lu

ld: Add tests for -z separate-code and -z noseparate-code

Verify that -z separate-code works and -z noseparate-code doesn't disable
-z relro.

PR ld/22393
* testsuite/ld-elf/pr16322.d: Add -z noseparate-code.
* testsuite/ld-elf/pr22393-1.s: New file.
* testsuite/ld-elf/pr22393-1a.d: Likewise.
* testsuite/ld-elf/pr22393-1b.d: Likewise.
* testsuite/ld-elf/pr22393-1c.d: Likewise.
* testsuite/ld-elf/pr22393-1d.d: Likewise.
* testsuite/ld-elf/pr22393-1e.d: Likewise.
* testsuite/ld-elf/pr22393-1f.d: Likewise.
* testsuite/ld-elf/pr22393-2a.c: Likewise.
* testsuite/ld-elf/pr22393-2a.rd: Likewise.
* testsuite/ld-elf/pr22393-2b.c: Likewise.
* testsuite/ld-elf/pr22393-2b.rd: Likewise.
* testsuite/ld-elf/shared.exp: Run tests for -z separate-code.

75f88a3 2018-01-10 02:22:16 H.J. Lu

ld/ppc/spu: Also set expld.textseg.phase to exp_seg_none

* emultempl/ppc32elf.em (ppc_before_allocation): Also set
expld.textseg.phase to exp_seg_none.
* emultempl/ppc64elf.em (prelim_size_sections): Likewise.
* emultempl/spuelf.em (spu_before_allocation): Likewise.

756d9f9 2018-01-10 02:18:24 H.J. Lu

ld: Create a new LOAD segment for separate code-only LOAD segment

When generating separate code and read-only data LOAD segments, create
a new LOAD segment if the previous section contains text and the current
section doesn't or vice versa:

Elf file type is DYN (Shared object file)
Entry point 0x200ff0
There are 7 program headers, starting at offset 52

Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
LOAD 0x000000 0x00000000 0x00000000 0x00200 0x00200 R 0x200000
LOAD 0x000fd0 0x00200fd0 0x00200fd0 0x0002b 0x0002b R E 0x200000
LOAD 0x001000 0x00201000 0x00201000 0x00058 0x00058 R 0x200000
LOAD 0x200f80 0x00400f80 0x00400f80 0x000a0 0x000a0 RW 0x200000
DYNAMIC 0x200f80 0x00400f80 0x00400f80 0x00080 0x00080 RW 0x4
GNU_STACK 0x000000 0x00000000 0x00000000 0x00000 0x00000 RW 0x10
GNU_RELRO 0x200f80 0x00400f80 0x00400f80 0x00080 0x00080 R 0x1

Section to Segment mapping:
Segment Sections...
00 .hash .gnu.hash .dynsym .dynstr .rela.plt
01 .plt .text
02 .rodata .eh_frame
03 .dynamic .got.plt
04 .dynamic
05
06 .dynamic

This is to prevent executing data in read-only sections as instructions.

Also don't put a writable section in a read-only segment if there is a
RELRO segment.

Since there are more than 2 LOAD segments, the minimum file size is
bigger than the maximum page size which is 2MB (0x200000):

-rwxr-xr-x 1 hjl hjl 2104892 Nov 12 11:53 libfoo.so

"-z max-page-size=0x1000" can be used to reduce the maximum page size to
4KB (0x1000):

-rwxr-xr-x 1 hjl hjl 11836 Nov 12 13:22 libfoo.so

Elf file type is DYN (Shared object file)
Entry point 0x1ff0
There are 7 program headers, starting at offset 52

Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
LOAD 0x000000 0x00000000 0x00000000 0x00200 0x00200 R 0x1000
LOAD 0x000fd0 0x00001fd0 0x00001fd0 0x0002b 0x0002b R E 0x1000
LOAD 0x001000 0x00002000 0x00002000 0x00058 0x00058 R 0x1000
LOAD 0x001f80 0x00002f80 0x00002f80 0x000a0 0x000a0 RW 0x1000
DYNAMIC 0x001f80 0x00002f80 0x00002f80 0x00080 0x00080 RW 0x4
GNU_STACK 0x000000 0x00000000 0x00000000 0x00000 0x00000 RW 0x10
GNU_RELRO 0x001f80 0x00002f80 0x00002f80 0x00080 0x00080 R 0x1

Section to Segment mapping:
Segment Sections...
00 .hash .gnu.hash .dynsym .dynstr .rela.plt
01 .plt .text
02 .rodata .eh_frame
03 .dynamic .got.plt
04 .dynamic
05
06 .dynamic

PR ld/22393
* elf.c (_bfd_elf_map_sections_to_segments): When generating
separate code and read-only data LOAD segments, create a new
LOAD segment if the previous section contains text and the
current section doesn't or vice versa. Don't put a writable
section in a read-only segment if there is a RELRO segment.

c91ad02 2018-01-10 02:14:32 H.J. Lu

ld: Add TEXT_SEGMENT_ALIGN/TEXT_SEGMENT_{RELRO_}END

Text-only LOAD segment has the same requirement for segment alignment
and page sizes as GNU_RELRO segment. But for GNU_RELRO segment, the
segment may not end at the same address of the end of data segment. But
text-only LOAD segment is exactly the same as text LOAD segment.

This patch adds TEXT_SEGMENT_ALIGN, TEXT_SEGMENT_RELRO_END and
TEXT_SEGMENT_END, which mimic DATA_SEGMENT_ALIGN, DATA_SEGMENT_RELRO_END
and DATA_SEGMENT_END. They work on text segment, instead of data
segment. TEXT_SEGMENT_ALIGN is placed at the start of text sections.
Both TEXT_SEGMENT_RELRO_END and TEXT_SEGMENT_END are placed at the end
of text sections. TEXT_SEGMENT_ALIGN is created from DATA_SEGMENT_ALIGN
by replacing DATA_SEGMENT_ALIGN with TEXT_SEGMENT_ALIGN. It simply sets
text_start and text_end from TEXT_SEGMENT_ALIGN, TEXT_SEGMENT_RELRO_END
and TEXT_SEGMENT_END the same way as relro_start and relro_end are set
from DATA_SEGMENT_ALIGN, DATA_SEGMENT_RELRO_END and DATA_SEGMENT_END.

include/

PR ld/22393
* bfdlink.h (bfd_link_info): Add text_start and text_end.

ld/

PR ld/22393
* ldexp.c (exp_print_token): Add TEXT_SEGMENT_ALIGN,
TEXT_SEGMENT_RELRO_END and TEXT_SEGMENT_END.
(fold_unary): Handle TEXT_SEGMENT_END.
(fold_binary): Handle TEXT_SEGMENT_RELRO_END and
TEXT_SEGMENT_END.
(exp_unop): Also check TEXT_SEGMENT_END.
* ldexp.h (ldexp_control): Add textseg.
* ldgram.y: Handle TEXT_SEGMENT_ALIGN, TEXT_SEGMENT_RELRO_END
and TEXT_SEGMENT_END.
* ldlang.c (strip_excluded_output_sections): Also set
expld.textseg.phase to exp_seg_none.
(lang_size_sections_1): Also call ldlang_check_relro_region with
&expld.textseg.
(lang_size_relro_segment): Also handle expld.textseg.
(lang_size_sections): Also handle expld.textseg. Set
link_info.text_start and link_info.text_end for -z textonly.
(lang_find_relro_sections): Also check expld.textseg.
* ldlex.l: Add TEXT_SEGMENT_ALIGN, TEXT_SEGMENT_RELRO_END and
TEXT_SEGMENT_END.
* scripttempl/elf.sc (TEXT_SEGMENT_ALIGN): New.
(TEXT_SEGMENT_RELRO_END): Likewise.
(TEXT_SEGMENT_END): Likewise.
Add ${TEXT_SEGMENT_ALIGN} before text sections and add
${TEXT_SEGMENT_RELRO_END}/${TEXT_SEGMENT_END} after text
sections for non-relocatable link.

972d6cb 2018-01-10 02:05:25 H.J. Lu

ld: Add "-z separate-code" option to ELF linker

Code-only LOAD segment has the same requirement for segment alignment
and page sizes as GNU_RELRO segment. But for GNU_RELRO segment, the
segment may not end at the same address of the end of data segment. But
for code-only LOAD segment, it is exactly the same as code LOAD segment.

The new "-z separate-code" option will turn on both separate code read-only
data LOAD segments and GNU_RELRO segment. The new "-z noseparate-code"
option will turn off only separate code and read-only data LOAD segments.
"-z relro" is updated not to turn off separate code and read-only data
LOAD segments. "-z norelro" is updated to turn off both GNU_RELRO segment
as well as separate code and read-only data LOAD segments.

include/

PR ld/22393
* bfdlink.h (bfd_link_info): Change the relro field to 2 bits.

ld/

PR ld/22393
* NEWS: Mention "-z separate-code".
* emultempl/elf32.em (gld${EMULATION_NAME}_get_script): Get
builtin linker scripts and return linker scripts from disk for
"-z separate-code".
(gld${EMULATION_NAME}_handle_option): Set the first bit of
link_info.relro for "-z relro". Clear link_info.relro for
"-z norelro". Set link_info.relro to 2 for "-z separate-code".
Keep only the first bit of link_info.relro for "notextonly".
* genscripts.sh: Generate linker scripts for "-z separate-code".
(LD_FLAG): Set to *textonly for "-z separate-code".
* lexsup.c (elf_shlib_list_options): Update linker help messsages
for "-z relro" and "-z norelro". Add linker help messsages for
"-z separate-code" and "-z noseparate-code".
* ld.texinfo: Update "-z norelro". Document "-z separate-code".

91d8b67 2018-01-09 23:21:59 James Greenhalgh

[Arm] Add CSDB instruction

CSDB is a new instruction which Arm has defined. As it shares the
encoding space with NOP instructions, it is available from Armv3 in
Arm mode, and Armv6T2 in Thumb mode.

OK? If so, please commit on my behalf as I don't have commit rights
over here.

Thanks, James

---
opcodes/

2018-01-09 James Greenhalgh <james.greenhalgh@arm.com>

* arm-dis.c (arm_opcodes): Add csdb.
(thumb32_opcodes): Add csdb.

gas/

2018-01-09 James Greenhalgh <james.greenhalgh@arm.com>

* config/tc-arm.c (insns): Add csdb, enable for Armv3 and above
in Arm execution state, and Armv6T2 and above in Thumb execution
state.
* testsuite/gas/arm/csdb.s: New.
* testsuite/gas/arm/csdb.d: New.
* testsuite/gas/arm/thumb2_it_bad.l: Add csdb.
* testsuite/gas/arm/thumb2_it_bad.s: Add csdb.

be2e7d9 2018-01-09 20:28:04 James Greenhalgh

Add support for the AArch64's CSDB instruction.

CSDB is a new instruction which Arm has defined. It has the same encoding as
HINT #0x14 and is available at all architecture levels.

opcodes * aarch64-tbl.h (aarch64_opcode_table): Add "csdb".
* aarch64-asm-2.c: Regenerate.
* aarch64-dis-2.c: Regenerate.
* aarch64-opc-2.c: Regenerate.

gas * testsuite/gas/aarch64/system.d: Update expected results to expect
CSDB.

b1dc180 2018-01-09 18:02:51 Xavier Roirand

Fix breakpoint add on inlined function using function name.

Using this Ada example:

package B is
procedure Read_Small with Inline_Always;
end B;

package body B is
Total : Natural := 0;
procedure Read_Small is
begin
Total := Total + 1;
end Read_Small;
end B;

and

with B;

procedure M is
begin
B.Read_Small;
end M;

% gnatmake -g -O0 -m m.adb -cargs -gnatn
% gdb m

Inserting a breakpoint on Read_Small inlined function does not work:

(gdb) b read_small
Breakpoint 1 at 0x40250e: file b.adb, line 5.
(gdb) info b
Num Type Disp Enb Address What
1 breakpoint keep y 0x000000000040250e in b.doit at b.adb:5
(gdb)

In this exemple we should have two breakpoints set, one in package B and
the other one in the inlined instance inside procedure M), like below:

(gdb) b read_small
Breakpoint 1 at 0x40250e: b.adb:5. (2 locations)
(gdb) info b
Num Type Disp Enb Address What
1 breakpoint keep y <MULTIPLE>
1.1 y 0x000000000040250e in b.doit at b.adb:5
1.2 y 0x0000000000402540 in m at b.adb:5
(gdb)

Looking at the DWARF info for inlined instance of Read_Small:

<1><1526>: Abbrev Number: 2 (DW_TAG_subprogram)
<1527> DW_AT_name : ([...], offset: 0x1e82): b__read_small
<152b> DW_AT_decl_file : 2
<152c> DW_AT_decl_line : 3
<152d> DW_AT_inline : 3 (declared as inline and inlined)
[...]
<2><1547>: Abbrev Number: 4 (DW_TAG_inlined_subroutine)
<1548> DW_AT_abstract_origin: <0x1526>
<154c> DW_AT_low_pc : 0x402552
<1554> DW_AT_high_pc : 0x2b
<155c> DW_AT_call_file : 1
<155d> DW_AT_call_line : 5
<2><155e>: Abbrev Number: 0

During the parsing of DWARF info in order to produce partial DIE linked
list, the DW_TAG_inlined_subroutine were skipped thus not present in the
final partial dies.
Taking DW_TAG_inlined_subroutine in account during the parsing process
fixes the problem.

gdb/ChangeLog:

* dwarf2read.c (scan_partial_symbols, add_partial_symbol)
(add_partial_subprogram, load_partial_dies): Add
DW_TAG_inlined_subroutine handling.

gdb/testsuite/ChangeLog:

* gdb.ada/bp_inlined_func: New testcase.

6cef73f 2018-01-09 17:05:33 Kuan-Lin Chen

PR22662, nds32: Fix a typographical error.

7615ca1 2018-01-09 10:55:29 Jim Wilson

RISC-V: Fix accidental embedded -shared regressions.

ld/
* testsuite/ld-riscv-elf/c-lui.d: Don't use -shared. Check for _start
instead of .text.
* testsuite/ld-riscv-elf/c-lui.s: Add _start label.
* testsuite/ld-riscv-elf/ld-riscv-elf.exp: Before __global_pointer$
tests, add call to check_shared_lib_support.

933ea65 2018-01-09 09:00:33 GDB Administrator

Automatic date update in version.in

9c4ac40 2018-01-09 00:33:41 Samuel Thibault

hurd: Add enough auxv support for AT_ENTRY for PIE binaries

Add PIE support for hurd, by faking an AT_ENTRY auxv entry. That value
is expected to be read by svr4_exec_displacement, which will propagate
the executable displacement.

gdb/ChangeLog:

* gdb/gnu-nat.c: Include <elf.h> and <link.h>.
(gnu_xfer_auxv): New function.
(gnu_xfer_partial): Call gnu_xfer_auxv when `object' is
TARGET_OBJECT_AUXV.

704a705 2018-01-08 21:37:20 H.J. Lu

x86: Properly encode vmovd with 64-bit memeory

For historical reason, we allow movd/vmovd with 64-bit register and
memeory operands. But for vmovd, we failed to handle 64-bit memeory
operand. This has been gone unnoticed since AT&T syntax always treats
memory operand as 32-bit memory. This patch properly encodes vmovd
with 64-bit memeory operands. It also removes AVX512 vmovd with 64-bit
operands since GCC has

case TYPE_SSEMOV:
switch (get_attr_mode (insn))
{
case MODE_DI:
/* Handle broken assemblers that require movd instead of movq. */
if (!HAVE_AS_IX86_INTERUNIT_MOVQ
&& (GENERAL_REG_P (operands[0]) || GENERAL_REG_P (operands[1])))
return "%vmovd\t{%1, %0|%0, %1}";
return "%vmovq\t{%1, %0|%0, %1}";

and all AVX512 GNU assemblers set HAVE_AS_IX86_INTERUNIT_MOVQ, GCC won't
generate AVX512 vmovd with 64-bit operand.

gas/

PR gas/22681
* testsuite/gas/i386/i386.exp: Run x86-64-movd and
x86-64-movd-intel.
* testsuite/gas/i386/x86-64-movd-intel.d: New file.
* testsuite/gas/i386/x86-64-movd.d: Likewise.
* testsuite/gas/i386/x86-64-movd.s: Likewise.

opcodes/

PR gas/22681
* i386-opc.tbl: Properly encode vmovd with Qword memeory operand.
Remove AVX512 vmovd with 64-bit operands.
* i386-tbl.h: Regenerated.

605fd3c 2018-01-08 19:09:33 Yao Qi

Fix GDBserver build failure when $development is false

When we set bfd/development.sh:$development to false, GDBserver failed to
build,

selftest.o: In function `selftests::run_tests(char const*)':
binutils-gdb/gdb/gdbserver/../common/selftest.c:97:undefined reference to `selftests::reset()'
collect2: error: ld returned 1 exit status

selftest.o shouldn't be compiled and linked when $development is false.
With this patch, in release mode, GDBserver doesn't nothing with option
--selftest,

$ ./gdbserver --selftest=foo
Selftests are not available in a non-development build.
$ ./gdbserver --selftest
Selftests are not available in a non-development build.

gdb/gdbserver:

2018-01-08 Yao Qi <yao.qi@linaro.org>
Simon Marchi <simon.marchi@ericsson.com>

* Makefile.in (OBS): Remove selftest.o.
* configure.ac: Set srv_selftest_objs if $development is true.
(GDBSERVER_DEPFILES): Append $srv_selftest_objs.
* configure: Re-generated.
* server.c (captured_main): Wrap variable selftest_filter with
GDB_SELF_TEST.

gdb/testsuite:

2018-01-08 Simon Marchi <simon.marchi@ericsson.com>

* gdb.server/unittest.exp: Match the output in non-development
mode.

1e5ded6 2018-01-08 19:09:32 Yao Qi

Fix GDB build failure when $development is false

We don't build GDB selftests bits when $development is false. However, if
we turn bfd/development.sh:$development to false, common/selftest.c is
compiled which is not expected. It causes the build failure,

selftest.o: In function `selftests::run_tests(char const*)':
binutils-gdb/gdb/common/selftest.c:97: undefined reference to `selftests::reset()'
collect2: error: ld returned 1 exit status

I fix this issue by putting selftest.o selftest-arch.o into CONFIG_OBS
only when $development is true. After this is fixed, there are other
build failures in maint.c, this patch fixes them as well.

In the release mode, the output of these commands are:

(gdb) maintenance selftest
Selftests are not available in a non-development build.
(gdb) maintenance selftest foo
Selftests are not available in a non-development build.
(gdb) maintenance info selftests
Selftests are not available in a non-development build.

gdb:

2018-01-08 Yao Qi <yao.qi@linaro.org>
Simon Marchi <simon.marchi@ericsson.com>

* Makefile.in (COMMON_SFILES): Remove selftest-arch.c and
common/selftest.c.
(COMMON_OBS): Remove selftest.o.
* configure.ac: Append selftest-arch.c and common/selftest.c to
CONFIG_SRCS. Append selftest-arch.o and selftest.o to COMMON_OBS.
* configure: Re-generated.
* maint.c (maintenance_selftest): Wrap selftests::run_tests with
GDB_SELF_TEST.
(maintenance_info_selftests): Likewise.

gdb/testsuite:

2018-01-08 Simon Marchi <simon.marchi@ericsson.com>

* gdb.gdb/unittest.exp: Match output in non-development mode.

9f86398 2018-01-08 18:39:23 Joel Brobecker

Fix second-to-last gdb/testsuite/ChangeLog entry.

30066b0 2018-01-08 18:38:26 Joel Brobecker

Relax expected output in gdb.ada/access_tagged_param.exp test

One of the tests in gdb.ada/access_tagged_param.exp verifies
the value of the parameters being printed by GDB when stopping
at a breakpoint inside procedure Pck.Inspect.

In particular, one of these parameters is actually generated
internally by the compiler, and does only indirectly depend
on the user-level code. A recent change in AdaCore's compiler
caused the code expansion to change a little bit, and as a result,
the value of that parameter has changed from 2 to 3. This can be
evindenced by looking at the code post expansion, using the -gnatDG
command-line switch to generate the .dg files:

$ gnatmake -g -gnatDG foo.adb
$ vi foo.adb.dg

We can see that the call to pck.inspect used to be:

pck__inspect (P8b, objL => 2);

With a recent version of GNAT Pro, it is now:

pck__inspect (P9b, objL => 3);

This change causes a spurious FAIL when running this testcase.
The objL parameter being, at heart, a simple counter of the nesting
level, this commit relaxes the expected output to accept any single-
digit number. We could accept any decimal, but given the example
program, I dout that number will reach double-digit level. If it
does, we'll double-check that this is normal, and relax the expected
output further.

gdb/testsuite/ChangeLog:

* gdb.ada/access_tagged_param.exp: Relax expected output
for value of "ObjL" in "continue" to pck.inspect breakpoint
test.

Tested on x86_64-linux.

102e936 2018-01-08 18:29:17 Nick Clifton

Add a description of the X86_64 assembler's .largcomm pseudo-op.

PR 22553
* doc/c-i386.texi (i386-Directives): Document the .largecomm
directive.

04bafb1 2018-01-08 13:56:36 Xavier Roirand

(Ada) Fix print of array using non-contiguous enumeration indexes

Consider the following code:

type Index is (Index1, Index2);
Size : constant Integer := 10;
for Index use (Index1 => 1, Index2 => Size);
type Array_Index_Enum is array (Index) of Integer;
my_table : Array_Index_Enum :=(others => 42);

When compiling the code above with a compiler where the GNAT encodings
are turned off (which can be temporarily emulated by using the compiler
switch -fgnat-encodings=minimal), printing this table in gdb leads to:

(gdb) p my_table
$1 = (42, 42, 4203344, 10, -8320, 32767, 4203465, 0, 0, 0)

The displayed content is wrong since the handling part believes
that the length of the array is max index value (10) minus the
first index value (1) i+ 1 = 10 which is wrong since index are not
contiguous in this case.

The right behavior is to detect that the array is using enumeration
index hence parse the enumeration values in order to get the number
of indexes in this array (2 indexes here).

This patch fixes this issue and changes the output as follow:

(gdb) p my_table
$1 = (42, 42)

gdb/ChangeLog:

* ada-valprint.c (val_print_packed_array_elements): Use
proper number of elements when printing an array indexed
by an enumeration type.

gdb/testsuite/ChangeLog (Joel Brobecker <brobecker@adacore.com>):

* gdb.ada/arr_enum_idx_w_gap.exp
* gdb.ada/arr_enum_idx_w_gap/foo_q418_043.adb

Tested on x86_64-linux.

e09efd5 2018-01-08 09:00:33 GDB Administrator

Automatic date update in version.in

518817b 2018-01-08 01:22:46 Simon Marchi

Remove dwarf2_cu::dwarf2_per_objfile

This patch removes the dwarf2_per_objfile field of dwarf2_cu. It is
redundant, since we can access dwarf2_per_objfile through
dwarf2_per_objfile, which is guaranteed to be set.

gdb/ChangeLog:

* dwarf2read.c (struct dwarf2_cu) <dwarf2_per_objfile>: Remove.
(dw2_get_file_names_reader): Adjust.
(lookup_dwo_signatured_type): Adjust.
(lookup_dwp_signatured_type): Adjust.
(lookup_signatured_type): Adjust.
(create_type_unit_group): Adjust.
(get_type_unit_group): Adjust.
(process_psymtab_comp_unit_reader): Adjust.
(build_type_psymtabs_reader): Adjust.
(scan_partial_symbols): Adjust.
(add_partial_symbol): Adjust.
(add_partial_subprogram): Adjust.
(peek_die_abbrev): Adjust.
(fixup_go_packaging): Adjust.
(process_imported_unit_die): Adjust.
(dwarf2_compute_name): Adjust.
(dwarf2_physname): Adjust.
(read_import_statement): Adjust.
(handle_DW_AT_stmt_list): Adjust.
(read_file_scope): Adjust.
(read_func_scope): Adjust.
(read_lexical_block_scope): Adjust.
(read_call_site_scope): Adjust.
(read_variable): Adjust.
(dwarf2_rnglists_process): Adjust.
(dwarf2_ranges_process): Adjust.
(dwarf2_ranges_read): Adjust.
(dwarf2_get_pc_bounds): Adjust.
(dwarf2_record_block_ranges): Adjust.
(dwarf2_add_field): Adjust.
(dwarf2_add_member_fn): Adjust.
(read_structure_type): Adjust.
(process_structure_scope): Adjust.
(read_enumeration_type): Adjust.
(read_array_type): Adjust.
(mark_common_block_symbol_computed): Adjust.
(read_common_block): Adjust.
(read_namespace_type): Adjust.
(read_namespace): Adjust.
(read_module_type): Adjust.
(read_tag_pointer_type): Adjust.
(read_tag_ptr_to_member_type): Adjust.
(read_tag_string_type): Adjust.
(read_subroutine_type): Adjust.
(read_typedef): Adjust.
(read_base_type): Adjust.
(attr_to_dynamic_prop): Adjust.
(read_subrange_type): Adjust.
(read_unspecified_type): Adjust.
(dwarf2_read_abbrevs): Adjust.
(load_partial_dies): Adjust.
(read_partial_die): Adjust.
(find_partial_die): Adjust.
(guess_partial_die_structure_name): Adjust.
(fixup_partial_die): Adjust.
(read_attribute_value): Adjust.
(read_addr_index): Adjust.
(read_addr_index_from_leb128): Adjust.
(read_str_index): Adjust.
(dwarf2_string_attr): Adjust.
(get_debug_line_section): Adjust.
(dwarf_decode_line_header): Adjust.
(lnp_state_machine::check_line_address): Adjust.
(dwarf_decode_lines_1): Adjust.
(dwarf_decode_lines): Adjust.
(dwarf2_start_symtab): Adjust.
(var_decode_location): Adjust.
(new_symbol_full): Adjust.
(dwarf2_const_value_data): Adjust.
(dwarf2_const_value_attr): Adjust.
(dwarf2_const_value): Adjust.
(die_type): Adjust.
(die_containing_type): Adjust.
(build_error_marker_type): Adjust.
(lookup_die_type): Adjust.
(guess_full_die_structure_name): Adjust.
(anonymous_struct_prefix): Adjust.
(determine_prefix): Adjust.
(dwarf2_name): Adjust.
(follow_die_ref_or_sig): Adjust.
(follow_die_offset): Adjust.
(follow_die_ref): Adjust.
(follow_die_sig_1): Adjust.
(follow_die_sig): Adjust.
(get_signatured_type): Adjust.
(get_DW_AT_signature_type): Adjust.
(decode_locdesc): Adjust.
(dwarf_decode_macros): Adjust.
(cu_debug_loc_section): Adjust.
(fill_in_loclist_baton): Adjust.
(dwarf2_symbol_mark_computed): Adjust.
(init_one_comp_unit): Don't assign
dwarf2_cu::dwarf2_per_objfile.
(set_die_type): Adjust.

ed2dc61 2018-01-08 01:22:46 Simon Marchi

Remove dwarf2_per_objfile global

This patch removes the global variable dwarf2_per_objfile. This global
variable is set at the various entry points of dwarf2read.c (using
dw2_setup), and is referred to throughout the file. Instead of passing
data between functions in global variables like this one, it would be
better if the functions that depend on it either received it as argument
or got it from the existing arguments they receive. For example, a
function receiving a reference to a dwarf2_per_cu_data can access it
from dwarf2_per_cu_data::dwarf2_per_objfile.

This patch has been tested on the buildbot.

gdb/ChangeLog:

* dwarf2read.c (struct mapped_debug_names): Add constructor.
<dwarf2_per_objfile>: New field.
(dwarf2_per_objfile): Remove global.
(get_dwarf2_per_objfile): New function.
(set_dwarf2_per_objfile): New function.
(dwarf2_build_psymtabs_hard): Change objfile parameter to
dwarf2_per_objfile.
(abbrev_table_read_table): Add dwarf2_per_objfile parameter.
(read_abbrev_offset): Likewise.
(read_indirect_string): Likewise.
(read_indirect_line_string): Likewise.
(read_indirect_string_at_offset): Likewise.
(read_indirect_string_from_dwz): Likewise.
(dwarf2_find_containing_comp_unit): Change objfile parameter to
dwarf2_per_objfile.
(age_cached_comp_units): Add dwarf2_per_objfile parameter.
(create_all_comp_units): Change objfile parameter to
dwarf2_per_objfile.
(create_all_type_units): Likewise.
(process_queue): Add dwarf2_per_objfile parameter.
(read_and_check_comp_unit_head): Likewise.
(lookup_dwo_unit_in_dwp): Likewise.
(get_dwp_file): Likewise.
(process_cu_includes): Likewise.
(struct free_dwo_file_cleanup_data): New struct.
(dwarf2_has_info): Use get_dwarf2_per_objfile and
set_dwarf2_per_objfile.
(dwarf2_get_dwz_file): Add dwarf2_per_objfile parameter.
(dw2_do_instantiate_symtab): Get dwarf2_per_objfile from
context, adjust calls.
(dw2_instantiate_symtab): Likewise.
(dw2_get_cutu): Add dwarf2_per_objfile parameter.
(dw2_get_cu): Likewise.
(create_cu_from_index_list): Change objfile parameter to
dwarf2_per_objfile.
(create_cus_from_index_list): Get dwarf2_per_objfile from
context, adjust calls.
(create_cus_from_index): Likewise.
(create_signatured_type_table_from_index): Change objfile
parameter to dwarf2_per_objfile.
(create_signatured_type_table_from_debug_names): Change objfile
parameter to dwarf2_per_objfile.
(create_addrmap_from_index): Likewise.
(create_addrmap_from_aranges): Likewise.
(dwarf2_read_index): Use get_dwarf2_per_objfile, adjust calls.
(dw2_setup): Remove.
(dw2_get_file_names_reader): Get dwarf2_per_objfile from
context.
(dw2_find_last_source_symtab): Get dwarf2_per_objfile using
get_dwarf2_per_objfile.
(dw2_forget_cached_source_info): Likewise.
(dw2_map_symtabs_matching_filename): Likewise.
(struct dw2_symtab_iterator) <index>: Remove.
<dwarf2_per_objfile>: New field.
(dw2_symtab_iter_init): Replace index parameter with
dwarf2_per_objfile.
(dw2_symtab_iter_next): Use dwarf2_per_objfile from iter.
(dw2_lookup_symbol): Use get_dwarf2_per_objfile and adjust.
(dw2_print_stats): Likewise.
(dw2_dump): Likewise.
(dw2_expand_symtabs_for_function): Likewise.
(dw2_expand_all_symtabs): Likewise.
(dw2_expand_symtabs_with_fullname): Likewise.
(dw2_expand_marked_cus): Replace index and objfile parameters
with dwarf2_per_objfile.
(dw_expand_symtabs_matching_file_matcher): Add
dwarf2_per_objfile parameter and adjust calls.
(dw2_expand_symtabs_matching): Use get_dwarf2_per_objfile and
adjust calls.
(dw2_find_pc_sect_compunit_symtab): Don't call dw2_setup.
(dw2_map_symbol_filenames): Use get_dwarf2_per_objfile and
adjust calls.
(create_cus_from_debug_names_list): Replace objfile parameter
with dwarf2_per_objfile and adjust calls.
(create_cus_from_debug_names): Likewise.
(dwarf2_read_debug_names): Likewise.
(mapped_debug_names::namei_to_name): Adjust call.
(dw2_debug_names_iterator::next): Likewise.
(dw2_debug_names_iterator::find_vec_in_debug_names): Likewise.
(dw2_debug_names_lookup_symbol): Use get_dwarf2_per_objfile.
(dw2_debug_names_dump): Likewise.
(dw2_debug_names_expand_symtabs_for_function): Likewise.
(dw2_debug_names_expand_symtabs_matching): Likewise.
(dwarf2_initialize_objfile): Likewise.
(dwarf2_build_psymtabs): Likewise.
(get_abbrev_section_for_cu): Get dwarf2_per_objfile from
this_cu.
(error_check_comp_unit_head): Add dwarf2_per_objfile parameter.
(read_and_check_comp_unit_head): Likewise.
(read_abbrev_offset): Likewise.
(create_debug_type_hash_table): Likewise.
(create_debug_types_hash_table): Likewise.
(create_all_type_units): Replace objfile parameter with
dwarf2_per_objfile.
(add_type_unit): Add dwarf2_per_objfile parameter.
(fill_in_sig_entry_from_dwo_entry): Replace objfile parameter
with dwarf2_per_objfile.
(lookup_dwo_signatured_type): Get dwarf2_per_objfile from cu.
(lookup_dwp_signatured_type): Likewise.
(lookup_signatured_type): Likewise.
(read_cutu_die_from_dwo): Likewise.
(init_tu_and_read_dwo_dies): Likewise.
(init_cutu_and_read_dies): Likewise.
(init_cutu_and_read_dies_no_follow): Likewise.
(allocate_type_unit_groups_table): Add objfile parameter.
(create_type_unit_group): Use dwarf2_per_objfile from cu.
(get_type_unit_group): Likewise.
(process_psymtab_comp_unit): Update call.
(build_type_psymtabs_reader): Use dwarf2_per_objfile from cu.
(build_type_psymtabs_1): Add dwarf2_per_objfile parameter.
(print_tu_stats): Likewise.
(build_type_psymtab_dependencies): Use dwarf2_per_objfile passed
in void* parameter.
(build_type_psymtabs): Change objfile parameter to
dwarf2_per_objfile.
(process_skeletonless_type_unit): Use dwarf2_per_objfile
passed in void* parameter.
(process_skeletonless_type_units): Change objfile parameter to
dwarf2_per_objfile.
(set_partial_user): Likewise.
(dwarf2_build_psymtabs_hard): Likewise.
(read_comp_units_from_section): Likewise.
(create_all_comp_units): Likewise.
(scan_partial_symbols): Update calls.
(add_partial_symbol): Likewise.
(dwarf2_read_symtab): Use get_dwarf2_per_objfile.
(maybe_queue_comp_unit): Use dwarf2_read_symtab from cu.
(process_queue): Add dwarf2_per_objfile parameter.
(get_compunit_symtab): Use dwarf2_per_objfile from cu.
(compute_compunit_symtab_includes): Likewise.
(process_cu_includes): Add dwarf2_per_objfile parameter.
(process_full_comp_unit): Use dwarf2_per_objfile from cu.
(process_full_type_unit): Likewise.
(process_imported_unit_die): Update call.
(handle_DW_AT_stmt_list): Use dwarf2_per_objfile from cu.
(read_file_scope): Likewise.
(allocate_dwo_file_hash_table): Add objfile parameter.
(lookup_dwo_file_slot): Add dwarf2_per_objfile parameter.
(create_cus_hash_table): Likewise.
(create_dwp_hash_table): Likewise.
(create_dwo_unit_in_dwp_v1): Likewise.
(create_dwp_v2_section): Likewise.
(create_dwo_unit_in_dwp_v2): Likewise.
(lookup_dwo_unit_in_dwp): Likewise.
(try_open_dwop_file): Likewise.
(open_dwo_file): Likewise. Use dwarf2_per_objfile from cu.
(open_and_init_dwo_file): Use dwarf2_per_objfile from cu, update
cleanup to include a reference to dwarf2_per_objfile.
(open_dwp_file): Add dwarf2_per_objfile parameter.
(open_and_init_dwp_file): Likewise.
(get_dwp_file): Likewise.
(lookup_dwo_cutu): Use dwarf2_per_objfile from cu.
(queue_and_load_all_dwo_tus): Update call.
(free_dwo_file_cleanup): Use dwarf2_per_objfile from cleanup
data.
(dwarf2_rnglists_process): Use dwarf2_per_objfile from cu.
(dwarf2_ranges_process): Likewise.
(dwarf2_get_pc_bounds): Likewise.
(mark_common_block_symbol_computed): Likewise.
(abbrev_table_read_table): Add dwarf2_per_objfile parameter.
(dwarf2_read_abbrevs): Update call.
(read_partial_die): Use dwarf2_per_objfile from cu.
(find_partial_die): Likewise.
(fixup_partial_die): Likewise.
(read_attribute_value): Likewise.
(read_indirect_string_at_offset_from): Add objfile parameter.
(read_indirect_string_at_offset): Add dwarf2_per_objfile
parameter.
(read_indirect_string_from_dwz): Add objfile parameter.
(read_indirect_string): Add objfile parameter.
(read_addr_index_1): Add dwarf2_per_objfile parameter.
(read_addr_index): Use dwarf2_per_objfile from cu.
(dwarf2_read_addr_index): Use dwarf2_per_objfile from cu, don't
call dw2_setup.
(read_str_index): Use dwarf2_per_objfile from cu.
(get_debug_line_section): Likewise.
(read_formatted_entries): Add dwarf2_per_objfile parameter.
(dwarf_decode_line_header): Use dwarf2_per_objfile from cu.
(new_symbol_full): Use dwarf2_per_objfile from cu.
(build_error_marker_type): Likewise.
(lookup_die_type): Likewise.
(determine_prefix): Likewise.
(follow_die_offset): Likewise.
(dwarf2_fetch_die_loc_sect_off): Use get_dwarf2_per_objfile.
(dwarf2_fetch_constant_bytes): Don't call dw2_setup.
(dwarf2_fetch_die_type_sect_off): Likewise.
(dwarf2_get_die_type): Likewise.
(follow_die_sig_1): Use dwarf2_per_objfile from cu.
(get_signatured_type): Likewise.
(get_DW_AT_signature_type): Likewise.
(dwarf_decode_macro_bytes): Add dwarf2_per_objfile parameter.
(dwarf_decode_macros): Use dwarf2_per_objfile from cu.
(cu_debug_loc_section): Likewise.
(fill_in_loclist_baton): Likewise.
(dwarf2_symbol_mark_computed): Likewise.
(dwarf2_find_containing_comp_unit): Change objfile parameter to
dwarf2_per_objfile.
(free_cached_comp_units): Use dwarf2_per_objfile passed in void*
parameter.
(age_cached_comp_units): Add dwarf2_per_objfile parameter.
(free_one_cached_comp_unit): Use dwarf2_per_objfile from cu.
(dwarf2_free_objfile): Use get_dwarf2_per_objfile.
(set_die_type): Use dwarf2_free_objfile from cu.
(get_die_type_at_offset): Likewise.
(dwarf2_per_objfile_free): Don't assign global variable.
(debug_names) <constructor>: Add dwarf2_per_objfile
parameter, update m_debugstrlookup construction.
(debug_names::debug_str_lookup): Add dwarf2_per_objfile
parameter.
<m_dwarf2_per_objfile>: New field.
<lookup>: Use m_dwarf2_per_objfile.
(check_dwarf64_offsets): Add dwarf2_per_objfile parameter.
(psyms_seen_size): Likewise.
(write_gdbindex): Replace objfile parameter with
dwarf2_per_objfile.
(write_debug_names): Likewise.
(write_psymtabs_to_index): Likewise.
(save_gdb_index_command): Use get_dwarf2_per_objfile, update
calls.

e3b9454 2018-01-08 01:22:45 Simon Marchi

Replace objfile field in dwarf2_cu and dwarf2_per_cu_data with dwarf2_per_objfile

The next patch aims to remove the dwarf2_per_objfile global. In many
functions, we need to find a way to get a reference to the current
dwarf2_per_objfile through the objects passed in parameters. Often, we have
access to a dwarf2_cu or a dwarf2_per_cu_data. These objects have a reference
to the objfile, through which we can get the dwarf2_per_objfile:

dwarf2_per_objfile = ((struct dwarf2_per_objfile *)
objfile_data (objfile, dwarf2_objfile_data_key));

However, this is a bit cumbersome to do all over the place. It would be
more logical if the dwarf2_cu and dwarf2_per_cu_data had a reference to
their dwarf2_per_objfile, which would then have a reference to the
objfile. It would be more in line with the object hierarchy, where
dwarf2_per_objfile owns the dwarf2_per_cu_data instances. We could
even remove the reference dwarf2_cu has to dwarf2_per_objfile, since we
can access dwarf2_per_objfile through dwarf2_cu::per_cu.

In a graphical way, references would look like this after the current
patch:

objfile <--- dwarf2_per_objfile <--- dwarf2_per_cu_data
| ^
| |
`- dwarf2_cu

This patch has been tested on the buildbot.

gdb/ChangeLog:

* dwarf2read.c (struct dwarf2_cu) <objfile>: Remove.
<dwarf2_per_objfile>: New field.
(struct dwarf2_per_cu_data) <objfile>: Remove.
<dwarf2_per_objfile>: New field.
(create_cu_from_index_list): Assign dwarf2_per_objfile instead
of objfile.
(create_signatured_type_table_from_index): Likewise.
(create_debug_type_hash_table): Likewise.
(fill_in_sig_entry_from_dwo_entry): Likewise.
(lookup_dwo_unit): Access objfile through dwarf2_per_objfile.
(create_type_unit_group): Assign dwarf2_per_objfile instead of
objfile.
(create_partial_symtab): Access objfile through
dwarf2_per_objfile.
(process_psymtab_comp_unit_reader): Likewise.
(read_comp_units_from_section): Likewise.
(scan_partial_symbols): Likewise.
(add_partial_symbol): Likewise.
(add_partial_subprogram): Likewise.
(peek_die_abbrev): Likewise.
(fixup_go_packaging): Likewise.
(process_full_comp_unit): Likewise.
(process_full_type_unit): Likewise.
(process_imported_unit_die): Likewise.
(dwarf2_compute_name): Likewise.
(dwarf2_physname): Likewise.
(read_import_statement): Likewise.
(create_cus_hash_table): Assign dwarf2_physname instead of
objfile.
(read_func_scope): Access objfile through dwarf2_per_objfile.
(read_lexical_block_scope): Likewise.
(read_call_site_scope): Likewise.
(read_variable): Likewise.
(dwarf2_rnglists_process): Likewise.
(dwarf2_ranges_process): Likewise.
(dwarf2_ranges_read): Likewise.
(dwarf2_record_block_ranges): Likewise.
(dwarf2_add_field): Likewise.
(dwarf2_add_member_fn): Likewise.
(read_structure_type): Likewise.
(process_structure_scope): Likewise.
(read_enumeration_type): Likewise.
(read_array_type): Likewise.
(read_common_block): Likewise.
(read_namespace_type): Likewise.
(read_namespace): Likewise.
(read_module_type): Likewise.
(read_tag_pointer_type): Likewise.
(read_tag_ptr_to_member_type): Likewise.
(read_tag_string_type): Likewise.
(read_subroutine_type): Likewise.
(read_typedef): Likewise.
(read_base_type): Likewise.
(attr_to_dynamic_prop): Likewise.
(read_subrange_type): Likewise.
(read_unspecified_type): Likewise.
(load_partial_dies): Likewise.
(read_partial_die): Likewise.
(find_partial_die): Likewise.
(guess_partial_die_structure_name): Likewise.
(fixup_partial_die): Likewise.
(read_attribute_value): Likewise.
(read_addr_index_from_leb128): Likewise.
(dwarf2_read_addr_index): Likewise.
(dwarf2_string_attr): Likewise.
(lnp_state_machine::check_line_address): Likewise.
(dwarf_decode_lines_1): Likewise.
(dwarf_decode_lines): Likewise.
(dwarf2_start_symtab): Likewise.
(var_decode_location): Likewise.
(new_symbol_full): Likewise.
(dwarf2_const_value_data): Likewise.
(dwarf2_const_value_attr): Likewise.
(dwarf2_const_value): Likewise.
(die_type): Likewise.
(die_containing_type): Likewise.
(lookup_die_type): Likewise.
(guess_full_die_structure_name): Likewise.
(anonymous_struct_prefix): Likewise.
(dwarf2_name): Likewise.
(follow_die_ref_or_sig): Likewise.
(follow_die_offset): Likewise.
(follow_die_ref): Likewise.
(dwarf2_fetch_die_loc_sect_off): Likewise.
(dwarf2_fetch_constant_bytes): Likewise.
(dwarf2_fetch_die_type_sect_off): Likewise.
(dwarf2_get_die_type): Likewise.
(follow_die_sig): Likewise.
(decode_locdesc): Likewise.
(dwarf2_per_cu_objfile): Likewise.
(dwarf2_per_cu_text_offset): Likewise.
(init_one_comp_unit): Assign dwarf2_per_objfile instead of
objfile.
(set_die_type): Access objfile through
dwarf2_per_objfile.

2cc0503 2018-01-08 00:50:48 Simon Marchi

Make parse_debug_format_options return an std::string

This avoid having to manually free the return value.

gdb/gdbserver/ChangeLog:

* server.c (parse_debug_format_options): Return std::string.
(handle_monitor_command, captured_main): Adjust.

b01ba14 2018-01-08 00:48:21 Simon Marchi

Replace VEC(converted_character_d) with std::vector

This patch changes the usage of VEC(converted_character_d) to use an
std::vector instead. This allows getting rid of a cleanup.

gdb/ChangeLog:

* valprint.c (converted_character_d): Remove typedef.
(DEF_VEC_O (converted_character_d)): Remove.
(count_next_character): Use std::vector.
(print_converted_chars_to_obstack): Likewise.
(generic_printstr): Likewise.

4d0fdd9 2018-01-07 23:38:16 Simon Marchi

Replace VEC(gdb_xml_value_s) with std::vector

This patch replaces VEC(gdb_xml_value_s), which is passed to XML
visitors, with an std::vector. In order to be able to remove the
cleanup in gdb_xml_parser::start_element, the gdb_xml_parser structure
is made to own the value with a gdb::unique_xmalloc_ptr.

This patch has been tested on the buildbot.

gdb/ChangeLog:

* xml-support.h (struct gdb_xml_value): Add constructor.
<value>: Change type to unique_xmalloc_ptr.
(gdb_xml_value_s): Remove typedef.
(DEF_VEC_O (gdb_xml_value_s)): Remove.
(gdb_xml_element_start_handler): Change parameter type to
std::vector.
(xml_find_attribute): Likewise.
* xml-support.c (xml_find_attribute): Change parameter type to
std::vector and adjust.
(gdb_xml_values_cleanup): Remove.
(gdb_xml_parser::start_element): Adjust to std::vector.
(xinclude_start_include): Change paraeter type to std::vector
and adjust.
* btrace.c (check_xml_btrace_version): Likewise.
(parse_xml_btrace_block): Likewise.
(parse_xml_btrace_pt_config_cpu): Likewise.
(parse_xml_btrace_pt): Likewise.
(parse_xml_btrace_conf_bts): Likewise.
(parse_xml_btrace_conf_pt): Likewise.
* memory-map.c (memory_map_start_memory): Likewise.
(memory_map_start_property): Likewise.
* osdata.c (osdata_start_osdata): Likewise.
(osdata_start_item): Likewise.
(osdata_start_column): Likewise.
* remote.c (start_thread): Likewise.
* solib-aix.c (library_list_start_library): Likewise.
(library_list_start_list): Likewise.
* solib-svr4.c (library_list_start_library): Likewise.
(svr4_library_list_start_list): Likewise.
* solib-target.c (library_list_start_segment): Likewise.
(library_list_start_section): Likewise.
(library_list_start_library): Likewise.
(library_list_start_list): Likewise.
* tracepoint.c (traceframe_info_start_memory): Likewise.
(traceframe_info_start_tvar): Likewise.
* xml-syscall.c (syscall_start_syscall): Likewise.
* xml-tdesc.c (tdesc_start_target): Likewise.
(tdesc_start_feature): Likewise.
(tdesc_start_reg): Likewise.
(tdesc_start_union): Likewise.
(tdesc_start_struct): Likewise.
(tdesc_start_flags): Likewise.
(tdesc_start_enum): Likewise.
(tdesc_start_field): Likewise.
(tdesc_start_enum_value): Likewise.
(tdesc_start_vector): Likewise.

f979c73 2018-01-07 23:25:33 Simon Marchi

Remove xmethod_worker::clone

I think that the clone method of xmethod_worker can be removed. It is
only used in find_overload_match, to clone an xmethod we want to
keep. Instead, we can just std::move it out of the vector and into
value_from_xmethod. value_from_xmethod creates a value that will own
the xmethod_worker from that point. Other xmethod_workers left in the
vector will get destroyed when the vector gets destroyed, but the chosen
one will keep living inside the value struct.

gdb/ChangeLog:

* extension.h (struct xmethod_worker) <clone>: Remove.
* python/py-xmethods.c (struct python_xmethod_worker) <clone>:
Remove.
(python_xmethod_worker::clone): Remove.
* valops.c (find_overload_match): Use std::move instead of
clone.

ba18742 2018-01-07 23:25:32 Simon Marchi

C++ify xmethod_worker, get rid of VEC(xmethod_worker_ptr)

The initial goal of this patch was to remove the usage of
VEC(xmethod_worker_ptr) and corresponding cleanups. I ended up having
to C++ify the xmethod_worker code, to be able to have xmethod_workers
free their data in destructors, and therefore be able to use vectors of
xmethod_worker unique_ptr.

The operations in extension_language_ops that act on one instance of
xmethod_worker (get result type, get args type, invoke) are transformed
to methods of xmethod_worker. xmethod_worker becomes an abstract base
class with virtual pure methods which python_xmethod_worker implements.
The only xmethod-related operation left in extension_language_ops is
get_matching_xmethod_workers, which returns a list of xmethod_workers.

The changes are relatively straightforward, but here are some notes on
things that may raise eyebrows:

- I was not really comfortable with the value_of_xmethod function. At
first it looks like a simple getter, so I considered making it a
method of xmethod_worker. But actually it creates a value and
transfers the ownership of the xmethod_worker to it. It would be a
bit weird and error-prone if calling a method on an object silently
removed the ownership of the object from the caller. To reflect the
behavior more accurately, I renamed it to value_from_xmethod and made
it accept an rvalue-reference (so the caller knows it gives away the
ownership). I noticed the backlink from xmethod_worker to its owning
value was not used, so I removed it.

- Some code, like get_matching_xmethod_workers, made each callee fill
a new vector, which was then merged in the result vector. I think
it's safe if we always pass the same vector around, and each
implementation just appends to it.

- The clone operation does not seem particularly useful, it is removed
in the following patch.

gdb/ChangeLog:

* extension-priv.h (enum ext_lang_rc): Remove, move to extension.h.
(struct extension_language_ops) <clone_xmethod_worker_data>: Remove.
<free_xmethod_worker_data>: Remove.
<get_matching_xmethod_workers>: Chance VEC to std::vector.
<get_xmethod_arg_types>: Remove.
<get_xmethod_result_type>: Remove.
<invoke_xmethod>: Remove.
* extension.c (new_xmethod_worker): Remove.
(clone_xmethod_worker): Remove.
(get_matching_xmethod_workers): Return void, pass std::vector by
pointer.
(get_xmethod_arg_types): Rename to...
(xmethod_worker::get_arg_types): ... this, and adjust.
(get_xmethod_result_type): Rename to...
(xmethod_worker::get_result_type): ... this, and adjust.
(invoke_xmethod): Remove.
(free_xmethod_worker): Remove.
(free_xmethod_worker_vec): Remove.
* extension.h (enum ext_lang_rc): Move here from
extension-priv.h.
(struct xmethod_worker): Add constructor and destructor.
<data>: Remove.
<value>: Remove.
<invoke, clone, do_get_result_type, do_get_arg_types>: New
virtual pure methods.
<get_arg_types, get_result_type>: New methods.
(xmethod_worker_ptr): Remove typedef.
(DEF_VEC_P (xmethod_worker_ptr)): Remove.
(xmethod_worker_vec): Remove typedef.
(xmethod_worker_up): New typedef.
(invoke_xmethod): Remove.
(clone_xmethod_worker): Remove.
(free_xmethod_worker): Remove.
(free_xmethod_worker_vec): Remove.
(get_xmethod_arg_types): Remove.
(get_xmethod_result_type): Remove.
* valops.c (find_method_list): Use std::vector, don't use
intermediate vector.
(value_find_oload_method_list): Use std::vector.
(find_overload_match): Use std::vector.
(find_oload_champ): Use std::vector.
* value.c (value_free): Use operator delete.
(value_of_xmethod): Rename to...
(value_from_xmethod): ... this. Don't assign
xmethod_worker::value, take rvalue-reference.
(result_type_of_xmethod): Adjust.
(call_xmethod): Adjust.
* value.h: Include extension.h.
(struct xmethod_worker): Don't forward-declare.
(value_of_xmethod): Rename to...
(value_from_xmethod): ... this, take rvalue-reference.
* python/py-xmethods.c (struct gdbpy_worker_data): Rename to...
(struct python_xmethod_worker): ... this, add constructor and
destructor.
<invoke, clone, do_get_arg_types, do_get_result_type>: Implement.
(gdbpy_free_xmethod_worker_data): Rename to...
(python_xmethod_worker::~python_xmethod_worker): ... this and
adjust.
(gdbpy_clone_xmethod_worker_data): Rename to...
(python_xmethod_worker::clone): ... this and adjust.
(gdbpy_get_matching_xmethod_workers): Use std::vector, don't use
temporary vector.
(gdbpy_get_xmethod_arg_types): Rename to...
(python_xmethod_worker::do_get_arg_types): ... this and adjust.
(gdbpy_get_xmethod_result_type): Rename to...
(python_xmethod_worker::do_get_result_type): ... this and
adjust.
(gdbpy_invoke_xmethod): Rename to...
(python_xmethod_worker::invoke): ... this and adjust.
(new_python_xmethod_worker): Rename to...
(python_xmethod_worker::python_xmethod_worker): ... this and
adjust.
* python/python-internal.h (gdbpy_clone_xmethod_worker_data):
Remove.
(gdbpy_free_xmethod_worker_data): Remove.
(gdbpy_get_matching_xmethod_workers): Use std::vector.
(gdbpy_get_xmethod_arg_types): Remove.
(gdbpy_get_xmethod_result_type): Remove.
(gdbpy_invoke_xmethod): Remove.
* python/python.c (python_extension_ops): Remove obsolete
callbacks.

d672364 2018-01-07 09:00:33 GDB Administrator

Automatic date update in version.in