Sudakshina Das [Wed, 13 Mar 2019 11:09:10 +0000 (11:09 +0000)]
[BFD, LD, AArch64, 3/3] Add --pac-plt to enable PLTs protected with PAC.
This is part of the patch series to add support for BTI and
PAC in AArch64 linker.
1) This patch adds new definitions of PAC enabled PLTs
and both BTI and PAC enabled PLTs.
2) It also defines the new dynamic tag DT_AARCH64_PAC_PLT
for the PAC enabled PLTs.
3) This patch adds a new ld command line option: --pac-plt.
In the presence of this option, the linker uses the PAC
enabled PLTs and marks with DT_AARCH64_PAC_PLT.
4) In case both BTI and PAC are enabled the linker should
pick PLTs enabled with both and also use dynamic tags for both.
All these are made according to the new AArch64 ELF ABI
https://developer.arm.com/docs/ihi0056/latest/elf-for-the-arm-64-bit-architecture-aarch64-abi-2018q4
*** bfd/ChangeLog ***
2019-03-13 Sudakshina Das <sudi.das@arm.com>
* elfnn-aarch64.c (PLT_PAC_ENTRY_SIZE, PLT_PAC_SMALL_ENTRY_SIZE): New.
(PLT_BTI_PAC_ENTRY_SIZE, PLT_BTI_PAC_SMALL_ENTRY_SIZE): New.
(setup_plt_values): Account for PAC or PAC and BTI enabled PLTs.
(elfNN_aarch64_size_dynamic_sections): Add checks for PLT_BTI_PAC
and PLT_PAC_PLT.
(elfNN_aarch64_finish_dynamic_sections): Account for PLT_BTI_PAC.
(get_plt_type): Add case for DT_AARCH64_PAC_PLT.
(elfNN_aarch64_plt_sym_val): Add cases for PLT_BTI_PAC and PLT_PAC.
*** binutils/ChangeLog ***
2019-03-13 Sudakshina Das <sudi.das@arm.com>
* readelf.c (get_aarch64_dynamic_type): Add case for
DT_AARCH64_PAC_PLT.
(dynamic_section_aarch64_val): Likewise.
*** include/ChangeLog ***
2019-03-13 Sudakshina Das <sudi.das@arm.com>
* elf/aarch64.h (DT_AARCH64_PAC_PLT): New.
*** ld/ChangeLog ***
2019-03-13 Sudakshina Das <sudi.das@arm.com>
* NEWS: Document --pac-plt.
* emultempl/aarch64elf.em (OPTION_PAC_PLT): New.
(PARSE_AND_LIST_LONGOPTS, PARSE_AND_LIST_OPTIONS): Add pac-plt.
(PARSE_AND_LIST_ARGS_CASES): Handle OPTION_PAC_PLT.
* testsuite/ld-aarch64/aarch64-elf.exp: Add the following tests.
* testsuite/ld-aarch64/bti-pac-plt-1.d: New test.
* testsuite/ld-aarch64/bti-pac-plt-2.d: New test.
* testsuite/ld-aarch64/pac-plt-1.d: New test.
* testsuite/ld-aarch64/pac-plt-2.d: New test.
* testsuite/ld-aarch64/bti-plt-1.s: Add .ifndef directive.
Sudakshina Das [Wed, 13 Mar 2019 10:54:30 +0000 (10:54 +0000)]
[BFD, LD, AArch64, 2/3] Add --force-bti to enable BTI and to select BTI enabled PLTs
This is part of the patch series to add support for BTI and
PAC in AArch64 linker.
1) This patch adds a new ld command line option: --force-bti.
In the presence of this option, the linker enables BTI with the
GNU_PROPERTY_AARCH64_FEATURE_1_BTI feature. This gives out warning
in case of missing gnu notes for BTI in inputs.
2) It also defines a new set of BTI enabled PLTs. These are used either
when all the inputs are marked with GNU_PROPERTY_AARCH64_FEATURE_1_BTI
or when the new --force-bti option is used. This required adding new
fields in elf_aarch64_link_hash_table so that we could make the PLT
related information more generic.
3) It also defines a dynamic tag DT_AARCH64_BTI_PLT. The linker uses
this whenever it picks BTI enabled PLTs.
All these are made according to the new AArch64 ELF ABI
https://developer.arm.com/docs/ihi0056/latest/elf-for-the-arm-64-bit-architecture-aarch64-abi-2018q4
*** bfd/ChangeLog ***
2019-03-13 Sudakshina Das <sudi.das@arm.com>
Szabolcs Nagy <szabolcs.nagy@arm.com>
* bfd-in.h (aarch64_plt_type, aarch64_enable_bti_type): New.
(aarch64_bti_pac_info): New.
(bfd_elf64_aarch64_set_options): Add aarch64_bti_pac_info argument.
(bfd_elf32_aarch64_set_options): Likewise.
* bfd-in2.h: Regenerate
* elfnn-aarch64.c (PLT_BTI_ENTRY_SIZE): New.
(PLT_BTI_SMALL_ENTRY_SIZE, PLT_BTI_TLSDESC_ENTRY_SIZE): New.
(elfNN_aarch64_small_plt0_bti_entry): New.
(elfNN_aarch64_small_plt_bti_entry): New.
(elfNN_aarch64_tlsdesc_small_plt_bti_entry): New.
(elf_aarch64_obj_tdata): Add no_bti_warn and plt_type fields.
(elf_aarch64_link_hash_table): Add plt0_entry, plt_entry and
tlsdesc_plt_entry_size fields.
(elfNN_aarch64_link_hash_table_create): Initialise the new fields.
(setup_plt_values): New helper function.
(bfd_elfNN_aarch64_set_options): Use new bp_info to set plt sizes and
bti enable type.
(elfNN_aarch64_allocate_dynrelocs): Use new size members instead of
fixed macros.
(elfNN_aarch64_size_dynamic_sections): Likewise and add checks.
(elfNN_aarch64_create_small_pltn_entry): Use new generic pointers
to plt stubs instead of fixed ones and update filling them according
to the need for bti.
(elfNN_aarch64_init_small_plt0_entry): Likewise.
(elfNN_aarch64_finish_dynamic_sections): Likewise.
(get_plt_type, elfNN_aarch64_get_synthetic_symtab): New.
(elfNN_aarch64_plt_sym_val): Update size accordingly.
(elfNN_aarch64_link_setup_gnu_properties): Set up plts if BTI GNU NOTE
is set.
(bfd_elfNN_get_synthetic_symtab): Define.
(elfNN_aarch64_merge_gnu_properties): Give out warning with --force-bti
and mising BTI NOTE SECTION.
*** binutils/ChangeLog ***
2019-03-13 Sudakshina Das <sudi.das@arm.com>
Szabolcs Nagy <szabolcs.nagy@arm.com>
* readelf.c (get_aarch64_dynamic_type): New.
(get_dynamic_type): Use above for EM_AARCH64.
(dynamic_section_aarch64_val): New.
(process_dynamic_section): Use above for EM_AARCH64.
*** include/ChangeLog ***
2019-03-13 Sudakshina Das <sudi.das@arm.com>
Szabolcs Nagy <szabolcs.nagy@arm.com>
* elf/aarch64.h (DT_AARCH64_BTI_PLT): New.
*** ld/ChangeLog ***
2019-03-13 Sudakshina Das <sudi.das@arm.com>
Szabolcs Nagy <szabolcs.nagy@arm.com>
* NEWS: Document --force-bti.
* emultempl/aarch64elf.em (plt_type, bti_type, OPTION_FORCE_BTI): New.
(PARSE_AND_LIST_SHORTOPTS, PARSE_AND_LIST_OPTIONS): Add force-bti.
(PARSE_AND_LIST_ARGS_CASES): Handle OPTION_FORCE_BTI.
* testsuite/ld-aarch64/aarch64-elf.exp: Add all the tests below.
* testsuite/ld-aarch64/bti-plt-1.d: New test.
* testsuite/ld-aarch64/bti-plt-1.s: New test.
* testsuite/ld-aarch64/bti-plt-2.s: New test.
* testsuite/ld-aarch64/bti-plt-2.d: New test.
* testsuite/ld-aarch64/bti-plt-3.d: New test.
* testsuite/ld-aarch64/bti-plt-4.d: New test.
* testsuite/ld-aarch64/bti-plt-5.d: New test.
* testsuite/ld-aarch64/bti-plt-6.d: New test.
* testsuite/ld-aarch64/bti-plt-7.d: New test.
* testsuite/ld-aarch64/bti-plt-so.s: New test.
* testsuite/ld-aarch64/bti-plt.ld: New test.
Sudakshina Das [Wed, 13 Mar 2019 10:42:27 +0000 (10:42 +0000)]
[BFD, LD, AArch64, 1/3] Add support for GNU PROPERTIES in AArch64 for BTI and PAC
This is part of the patch series to add support for BTI and
PAC in AArch64 linker.
This patch implements the following:
1) This extends in the gnu property support in the linker for
AArch64 by defining backend hooks for elf_backend_setup_gnu_properties,
elf_backend_merge_gnu_properties and elf_backend_parse_gnu_properties.
2) It defines AArch64 specific GNU property
GNU_PROPERTY_AARCH64_FEATURE_1_AND and 2 bit for BTI and PAC in it.
3) It also adds support in readelf.c to read and print these new
GNU properties in AArch64.
All these are made according to the new AArch64 ELF ABI
https://developer.arm.com/docs/ihi0056/latest/elf-for-the-arm-64-bit-architecture-aarch64-abi-2018q4
*** bfd/ChangeLog ***
2019-03-13 Sudakshina Das <sudi.das@arm.com>
* elf-properties.c (_bfd_elf_link_setup_gnu_properties): Exclude
linker created inputs from merge.
* elfnn-aarch64.c (struct elf_aarch64_obj_tdata): Add field for
GNU_PROPERTY_AARCH64_FEATURE_1_AND properties.
(elfNN_aarch64_link_setup_gnu_properties): New.
(elfNN_aarch64_merge_gnu_properties): New.
(elf_backend_setup_gnu_properties): Define for AArch64.
(elf_backend_merge_gnu_properties): Likewise.
* elfxx-aarch64.c (_bfd_aarch64_elf_link_setup_gnu_properties): Define.
(_bfd_aarch64_elf_parse_gnu_properties): Define.
(_bfd_aarch64_elf_merge_gnu_properties): Define.
* elfxx-aarch64.h (_bfd_aarch64_elf_link_setup_gnu_properties): Declare.
(_bfd_aarch64_elf_parse_gnu_properties): Declare.
(_bfd_aarch64_elf_merge_gnu_properties): Declare.
(elf_backend_parse_gnu_properties): Define for AArch64.
*** binutils/ChangeLog ***
2019-03-13 Sudakshina Das <sudi.das@arm.com>
* readelf.c (decode_aarch64_feature_1_and): New.
(print_gnu_property_note): Add case for AArch64 gnu notes.
*** include/ChangeLog ***
2019-03-13 Sudakshina Das <sudi.das@arm.com>
* elf/common.h (GNU_PROPERTY_AARCH64_FEATURE_1_AND): New.
(GNU_PROPERTY_AARCH64_FEATURE_1_BTI): New.
(GNU_PROPERTY_AARCH64_FEATURE_1_PAC): New.
*** ld/ChangeLog ***
2019-03-13 Sudakshina Das <sudi.das@arm.com>
* NEWS: Document GNU_PROPERTY_AARCH64_FEATURE_1_BTI and
GNU_PROPERTY_AARCH64_FEATURE_1_PAC.
* testsuite/ld-aarch64/aarch64-elf.exp: Add run commands for new tests.
* testsuite/ld-aarch64/property-bti-pac1.d: New test.
* testsuite/ld-aarch64/property-bti-pac1.s: New test.
* testsuite/ld-aarch64/property-bti-pac2.d: New test.
* testsuite/ld-aarch64/property-bti-pac2.s: New test.
* testsuite/ld-aarch64/property-bti-pac3.d: New test.
H.J. Lu [Wed, 13 Mar 2019 06:38:15 +0000 (14:38 +0800)]
x86: Properly set IBT and SHSTK properties for -z ibt/shstk
There should be no AND properties if some input doesn't have them. We
should set IBT and SHSTK properties for -z ibt and -z shstk if needed.
bfd/
PR ld/24322
* elfxx-x86.c (_bfd_x86_elf_merge_gnu_properties): Properly
merge GNU_PROPERTY_X86_FEATURE_1_[IBT|SHSTK].
ld/
PR ld/24322
* testsuite/ld-i386/i386.exp: Run PR ld/24322 tests.
* testsuite/ld-x86-64/x86-64.exp: Likewise.
* testsuite/ld-i386/pr24322a.d: New file.
* testsuite/ld-i386/pr24322b.d: Likewise.
* testsuite/ld-x86-64/pr24322a-x32.d: Likewise.
* testsuite/ld-x86-64/pr24322a.d: Likewise.
* testsuite/ld-x86-64/pr24322b-x32.d: Likewise.
* testsuite/ld-x86-64/pr24322b.d: Likewise.
* testsuite/ld-x86-64/pr24322a.s: Likewise.
* testsuite/ld-x86-64/pr24322b.s: Likewise.
* testsuite/ld-x86-64/pr24322c.s: Likewise.
Christian Eggers [Sun, 10 Mar 2019 18:21:58 +0000 (19:21 +0100)]
dwarf2: Align relocation within .debug_line section
All relocations specify a byte address. As dwarf debug information is
organized in octets, some relocations may not be aligned. While it
might be possible to define special relocations that operate at an
octet offset from their address, it's easier to ensure the relocations
are aligned by padding with "nop" statements.
In most dwarf sections this requirement is already fulfilled, only
relocations for symbol address within the .debug_line section can be
misaligned.
* dwarf2dbg.c (out_set_addr): Align relocation within .debug_line.
Christian Eggers [Sun, 10 Mar 2019 18:21:57 +0000 (19:21 +0100)]
dwarf2: Pad size of .debug_line section.
As all dwarf debug information is organized in octets, the size of all
dwarf sections must be aligned to OCTETS_PER_BYTE. Most DWARF sections
meet this requirement, only the .debug_line section can reach an
arbitrary octet size.
In order to align the size to a multiple of OCTETS_PER_BYTE, the section
is padded with "nop" statements at the end.
* dwarf2dbg.c (out_debug_line): Pad size of .debug_line section.
Christian Eggers [Sun, 10 Mar 2019 18:21:56 +0000 (19:21 +0100)]
dwarf2: Use octets for .debug_string offsets
Like other dwarf2 offsets, also the string offsets in the .debug_info
section which points into the .debug_str section must be expressed in
octets instead of bytes.
* dwarf2dbg.c (out_debug_str): Use octets for .debug_string pointers.
Christian Eggers [Sun, 10 Mar 2019 18:21:55 +0000 (19:21 +0100)]
dwarf2: Use octets for .debug_line prologue
Like the u32 size field at the beginning of the section, also the
prologue size must be expressed in octets.
* dwarf2dbg.c (out_debug_line): Use octets for .debug_line prologue.
Christian Eggers [Sun, 10 Mar 2019 18:21:54 +0000 (19:21 +0100)]
dwarf2: Use octets for dwarf2 headers
The content of the dwarf2 sections .debug_line, .debug_aranges and
.debug_info starts with an u32 containing the the size of the remaining
data. According to the dwarf2 specification this value must be expressed
in octets instead of bytes.
* dwarf2dbg.c (out_debug_line): Use octets for dwarf2 headers.
(out_debug_aranges, out_debug_info): Likewise.
Christian Eggers [Sun, 10 Mar 2019 18:21:53 +0000 (19:21 +0100)]
Symbols with octets value
Up to now, all symbol values are in units of bytes, where a "byte" can
consist of one or more octets (e.g. 8 bit or 16 bit).
Allow to specfiy that the "unit" of a newly created symbol is octets
(exactly 8 bit), instead of bytes.
* symbols.h (symbol_temp_new_now_octets): Declare.
(symbol_set_value_now_octets, symbol_octets_p): Declare.
* symbols.c (struct symbol_flags): New member sy_octets.
(symbol_temp_new_now_octets): New function.
(resolve_symbol_value): Return octets instead of bytes if
sy_octets is set.
(symbol_set_value_now_octets): New function.
(symbol_octets_p): New function.
Christian Eggers [Sun, 10 Mar 2019 18:21:52 +0000 (19:21 +0100)]
dwarf2: Fix calculation of line info offset
The units of the value returned by "frag_now_fix()" and "size" do not
match. "frag_now_fix()" returns bytes (can be 8, 16 or 32 bit), while
"size" is octets (exactly 8 bit).
* dwarf2dbg.c (dwarf2_emit_insn): Fix calculation of line info offset.
GDB Administrator [Wed, 13 Mar 2019 00:00:16 +0000 (00:00 +0000)]
Automatic date update in version.in
John Baldwin [Tue, 12 Mar 2019 20:56:53 +0000 (13:56 -0700)]
The NEWS file had two "New targets" sections for 8.3.
gdb/ChangeLog:
* NEWS: Combine separate "New targets" sections for 8.3.
John Baldwin [Tue, 12 Mar 2019 20:39:02 +0000 (13:39 -0700)]
Support TLS variables on FreeBSD/powerpc.
Derive the pointer to the DTV array from the %r2 register on 32-bit
powerpc and %r13 on 64-bit powerpc.
gdb/ChangeLog:
* ppc-fbsd-tdep.c (ppcfbsd_get_thread_local_address): New.
(ppcfbsd_init_abi): Install gdbarch
"fetch_tls_load_module_address" and "get_thread_local_address"
methods.
John Baldwin [Tue, 12 Mar 2019 20:39:02 +0000 (13:39 -0700)]
Support TLS variables on FreeBSD/riscv.
Derive the pointer to the DTV array from the tp register.
gdb/ChangeLog:
* riscv-fbsd-tdep.c (riscv_fbsd_get_thread_local_address): New.
(riscv_fbsd_init_abi): Install gdbarch
"fetch_tls_load_module_address" and "get_thread_local_address"
methods.
John Baldwin [Tue, 12 Mar 2019 20:39:02 +0000 (13:39 -0700)]
Support TLS variables on FreeBSD/i386.
Derive the pointer to the DTV array from the gs_base register. As
with FreeBSD/amd64, gs_base is currently only available via the native
target.
gdb/ChangeLog:
* i386-fbsd-tdep.c (i386fbsd_get_thread_local_address): New.
(i386fbsd_init_abi): Install gdbarch
"fetch_tls_load_module_address" and "get_thread_local_address"
methods.
John Baldwin [Tue, 12 Mar 2019 20:39:02 +0000 (13:39 -0700)]
Support TLS variables on FreeBSD/amd64.
Use the fs_base register to fetch the address of a thread's tcb and
calculate the address of the DTV array. This value is then passed to
fbsd_get_thread_local_address to compute the final variable address.
Note that fs_base is currently only available via the native target as
core dumps on FreeBSD do not store the value of fs_base.
gdb/ChangeLog:
* amd64-fbsd-tdep.c (amd64fbsd_get_thread_local_address): New.
(amd64fbsd_init_abi): Install gdbarch
"fetch_tls_load_module_address" and "get_thread_local_address"
methods.
John Baldwin [Tue, 12 Mar 2019 20:39:02 +0000 (13:39 -0700)]
Add a helper function to resolve TLS variable addresses for FreeBSD.
The fbsd_get_thread_local_address function accepts the base address of
a thread's DTV array and the base address of an object file's link map
and uses this to compute a TLS variable's address. FreeBSD
architectures use an architecture-specific method to determine the
address of the DTV array pointer and call this helper function to
perform the rest of the address calculation.
* fbsd-tdep.c (fbsd_pspace_data_handle): New variable.
(struct fbsd_pspace_data): New type.
(get_fbsd_pspace_data, fbsd_pspace_data_cleanup)
(fbsd_read_integer_by_name, fbsd_fetch_rtld_offsets)
(fbsd_get_tls_index, fbsd_get_thread_local_address): New function.
(_initialize_fbsd_tdep): Initialize 'fbsd_pspace_data_handle'.
* fbsd-tdep.c (fbsd_get_thread_local_address): New prototype.
John Baldwin [Tue, 12 Mar 2019 20:39:02 +0000 (13:39 -0700)]
Add a more general version of lookup_struct_elt_type.
lookup_struct_elt is a new function which returns a tuple of
information about a component of a structure or union. The returned
tuple contains a pointer to the struct field object for the component
as well as a bit offset of that field within the structure. If the
field names a field in an anonymous substructure, the offset is the
"global" offset relative to the original structure type. If noerr is
set, then the returned tuple will set the field pointer to NULL to
indicate a missing component rather than throwing an error.
lookup_struct_elt_type is now reimplemented in terms of this new
function. It simply returns the type of the returned field.
gdb/ChangeLog:
* gdbtypes.c (lookup_struct_elt): New function.
(lookup_struct_elt_type): Reimplement via lookup_struct_elt.
* gdbtypes.h (struct struct_elt): New type.
(lookup_struct_elt): New prototype.
John Baldwin [Tue, 12 Mar 2019 20:39:02 +0000 (13:39 -0700)]
Remove code disabled since at least 1999 from lookup_struct_elt_type.
Update the comment above the function to reflect the code removal and
document the existing behavior.
gdb/ChangeLog:
* gdbtypes.c (lookup_struct_elt_type): Update comment and
remove disabled code block.
John Baldwin [Tue, 12 Mar 2019 20:39:02 +0000 (13:39 -0700)]
Add a new gdbarch method to resolve the address of TLS variables.
Permit TLS variable addresses to be resolved purely by an ABI rather
than requiring a target method. This doesn't try the target method if
the ABI function is present (even if the ABI function fails) to
simplify error handling.
gdb/ChangeLog:
* gdbarch.sh (get_thread_local_address): New method.
* gdbarch.h, gdbarch.c: Regenerate.
* target.c (target_translate_tls_address): Use
gdbarch_get_thread_local_address if present instead of
target::get_thread_local_address.
John Baldwin [Tue, 12 Mar 2019 20:39:02 +0000 (13:39 -0700)]
Update comment for target::get_thread_local_address.
There isn't an 'objfile' parameter, instead 'load_module_addr' is used
to indicate the executable or shared library. Also, the function
throws errors rather than returning error values.
gdb/ChangeLog:
* target.h (target::get_thread_local_address): Update comment.
John Baldwin [Tue, 12 Mar 2019 20:39:02 +0000 (13:39 -0700)]
Handle an edge case for minisym TLS variable lookups.
If a TLS variable is provided by a minisym from a separate debug file,
the separate debug file is passed to
gdbarch_fetch_tls_load_module_address. However, the object files
stored in the shared object list are the original object files, not
the separate debug object files. In this case,
svr4_fetch_objfile_link_map was failing to find the link map entry
since the debug object file is not in its internal list, only the
original object file.
gdb/ChangeLog:
* solib-svr4.c (svr4_fetch_objfile_link_map): Look for
objfile->separate_debug_objfile_backlink if not NULL.
John Baldwin [Tue, 12 Mar 2019 20:39:02 +0000 (13:39 -0700)]
Support fs_base and gs_base on FreeBSD/i386.
The i386 BSD native target uses the same ptrace operations
(PT_[GS]ET[FG]SBASE) as the amd64 BSD native target to fetch and store
the registers.
The amd64 BSD native now uses 'tdep->fsbase_regnum' instead of
hardcoding AMD64_FSBASE_REGNUM and AMD64_GSBASE_REGNUM to support
32-bit targets. In addition, the store operations explicitly zero the
new register value before fetching it from the register cache to
ensure 32-bit values are zero-extended.
gdb/ChangeLog:
* amd64-bsd-nat.c (amd64bsd_fetch_inferior_registers): Use
tdep->fsbase_regnum instead of constants for fs_base and gs_base.
(amd64bsd_store_inferior_registers): Likewise.
* amd64-fbsd-nat.c (amd64_fbsd_nat_target::read_description):
Enable segment base registers.
* i386-bsd-nat.c (i386bsd_fetch_inferior_registers): Use
PT_GETFSBASE and PT_GETGSBASE.
(i386bsd_store_inferior_registers): Use PT_SETFSBASE and
PT_SETGSBASE.
* i386-fbsd-nat.c (i386_fbsd_nat_target::read_description): Enable
segment base registers.
* i386-fbsd-tdep.c (i386fbsd_core_read_description): Likewise.
John Baldwin [Tue, 12 Mar 2019 20:39:02 +0000 (13:39 -0700)]
Support the fs_base and gs_base registers on i386.
As on amd64, these registers hold the base address of the fs and gs
segments, respectively. For i386 these two registers are 32 bits.
gdb/ChangeLog:
* amd64-fbsd-nat.c (amd64_fbsd_nat_target::read_description):
Update calls to i386_target_description to add 'segments'
parameter.
* amd64-tdep.c (amd64_init_abi): Set tdep->fsbase_regnum. Don't
add segment base registers.
* arch/i386.c (i386_create_target_description): Add 'segments'
parameter to enable segment base registers.
* arch/i386.h (i386_create_target_description): Likewise.
* features/i386/32bit-segments.xml: New file.
* features/i386/32bit-segments.c: Generate.
* i386-fbsd-nat.c (i386_fbsd_nat_target::read_description): Update
call to i386_target_description to add 'segments' parameter.
* i386-fbsd-tdep.c (i386fbsd_core_read_description): Likewise.
* i386-go32-tdep.c (i386_go32_init_abi): Likewise.
* i386-linux-tdep.c (i386_linux_read_description): Likewise.
* i386-tdep.c (i386_validate_tdesc_p): Add segment base registers
if feature is present.
(i386_gdbarch_init): Pass I386_NUM_REGS to set_gdbarch_num_regs.
Add 'segments' parameter to call to i386_target_description.
(i386_target_description): Add 'segments' parameter to enable
segment base registers.
(_initialize_i386_tdep) [GDB_SELF_TEST]: Add 'segments' parameter
to call to i386_target_description.
* i386-tdep.h (struct gdbarch_tdep): Add 'fsbase_regnum'.
(enum i386_regnum): Add I386_FSBASE_REGNUM and I386_GSBASE_REGNUM.
Define I386_NUM_REGS.
(i386_target_description): Add 'segments' parameter to enable
segment base registers.
gdb/gdbserver/ChangeLog:
* linux-x86-tdesc.c (i386_linux_read_description): Update call to
i386_create_target_description for 'segments' parameter.
* lynx-i386-low.c (lynx_i386_arch_setup): Likewise.
* nto-x86-low.c (nto_x86_arch_setup): Likewise.
* win32-i386-low.c (i386_arch_setup): Likewise.
Andrew Burgess [Thu, 7 Mar 2019 13:20:37 +0000 (13:20 +0000)]
gdb/testsuite: Prepare for DejaGnu 1.6.2
Changes in DejaGnu 1.6.2 mean that our testsuite will no longer run.
This is because of some confusion over how the gdb.exp file is
handled.
The gdb.exp file is really the tool init file, which is loaded from
within the DejaGnu core, and it should not be loaded directly from any
other file in the testsuite.
DejaGnu tries to prevent the same library being loaded twice by
remembering the names of library files as they are loaded. Until
recently loading the tool init file in DejaGnu was very similar to
loading a library file, as a result, loading the gdb.exp tool init
file simply recorded 'gdb.exp' as having been loaded, future attempts
to load 'gdb.exp' as a library would then be ignored (as the file was
marked as already loaded).
DejaGnu has now changed so that it supports having both a tool init
file and a library with the same name, something that was not possible
before. What this means however is that when the core loads the
'gdb.exp' tool init file it no longer marks the library 'gdb.exp' as
having been loaded. When we then execute 'load_lib gdb.exp' we then
try to reload the 'gdb.exp' file.
Unfortunately our gdb.exp file can only be loaded once. It use of
'rename cd builtin_cd' means that a second attempt to load this file
will fail.
This was discussed on the DejaGnu list here:
http://lists.gnu.org/archive/html/dejagnu/2019-03/msg00000.html
and the suggested advice is that, unless we have some real requirement
to load the tool init file twice, we should remove calls to 'load_lib
gdb.exp' and rely on DejaGnu to load the file for us, which is what
this patch does.
I've tested with native X86-64/GNU Linux and see no regressions.
gdb/testsuite/ChangeLog:
* config/default.exp: Remove 'load_lib gdb.exp'.
* config/monitor.exp: Likewise.
* config/sid.exp: Likewise.
* config/sim.exp: Likewise.
* config/slite.exp: Likewise.
* config/unix.exp: Likewise.
* gdb.base/default.exp: Remove unhelpful comment.
Eli Zaretskii [Tue, 12 Mar 2019 17:47:23 +0000 (19:47 +0200)]
Fix MinGW build with source-highlight
gdb/ChangeLog
2019-03-12 Eli Zaretskii <eliz@gnu.org>
PR/24325
* source-cache.c: #undef open and close, to avoid unresolved
externals during linking.
Tom Tromey [Tue, 12 Mar 2019 17:03:03 +0000 (11:03 -0600)]
Make remote.c ptid constants "const"
This changes magic_null_ptid, not_sent_ptid, and any_thread_ptid to be
"const". This is a minor improvement that makes it so these can't be
accidentally modified.
Tested by rebuilding. I'm checking this in.
gdb/ChangeLog
2019-03-12 Tom Tromey <tromey@adacore.com>
* remote.c (magic_null_ptid, not_sent_ptid, any_thread_ptid): Now
const. Add initializers.
(_initialize_remote): Don't initialize ptid globals.
Pedro Alves [Tue, 12 Mar 2019 16:56:02 +0000 (16:56 +0000)]
Fix test-cp-name-parser build, parser_fprintf undefined
$ make test-cp-name-parser
...
test-cp-name-parser.o: In function `yy_symbol_print(_IO_FILE*, int, YYSTYPE const*, cpname_state*)':
build/gdb/cp-name-parser.c.tmp:1335: undefined reference to `parser_fprintf(_IO_FILE*, char const*, ...)'
build/gdb/cp-name-parser.c.tmp:1339: undefined reference to `parser_fprintf(_IO_FILE*, char const*, ...)'
test-cp-name-parser.o: In function `yy_stack_print(short*, short*)':
build/gdb/cp-name-parser.c.tmp:1350: undefined reference to `parser_fprintf(_IO_FILE*, char const*, ...)'
build/gdb/cp-name-parser.c.tmp:1354: undefined reference to `parser_fprintf(_IO_FILE*, char const*, ...)'
build/gdb/cp-name-parser.c.tmp:1356: undefined reference to `parser_fprintf(_IO_FILE*, char const*, ...)'
build/gdb/cp-name-parser.c.tmp:1376: more undefined references to `parser_fprintf(_IO_FILE*, char const*, ...)' follow
collect2: error: ld returned 1 exit status
make: *** [Makefile:1833: test-cp-name-parser] Error 1
gdb/ChangeLog:
2019-03-12 Pedro Alves <palves@redhat.com>
* yy-remap.h [TEST_CPNAMES] (YYFPRINTF): Don't define.
Pedro Alves [Tue, 12 Mar 2019 16:56:02 +0000 (16:56 +0000)]
Fix test-cp-name-parser build, unused variable
$ make test-cp-name-parser
...
CXX test-cp-name-parser.o
src/gdb/cp-name-parser.y: In function ‘int gdb::main(int, char**)’:
src/gdb/cp-name-parser.y:2137:6: error: unused variable ‘len’ [-Werror=unused-variable]
int len;
^~~
cc1plus: all warnings being treated as errors
gdb/ChangeLog:
2019-03-12 Pedro Alves <palves@redhat.com>
* cp-name-parser.y (main): Remove unused 'len' variable.
Tom Tromey [Mon, 4 Mar 2019 19:05:47 +0000 (12:05 -0700)]
Make null_ptid and minus_one_ptid "const"
This makes null_ptid and minus_one_ptid "const". I think this is an
improvement because it means they can't be accidentally modified.
2019-03-12 Tom Tromey <tromey@adacore.com>
* common/ptid.c (null_ptid, minus_one_ptid): Now const.
* common/ptid.h (null_ptid, minus_one_ptid): Now const.
Tom Tromey [Mon, 4 Mar 2019 19:05:03 +0000 (12:05 -0700)]
Change iterate_over_lwps to take a gdb::function_view
This changes iterate_over_lwps to use a gdb::function_view. This was
needed in order to make null_ptid and minus_one_ptid 'const'.
gdb/ChangeLog
2019-03-12 Tom Tromey <tromey@adacore.com>
* linux-nat.c (iterate_over_lwps): Update.
(stop_callback): Remove parameter.
(stop_wait_callback, detach_callback, resume_set_callback)
(select_singlestep_lwp_callback, set_ignore_sigint)
(status_callback, resumed_callback, resume_clear_callback)
(kill_callback, kill_wait_callback, linux_nat_stop_lwp): Remove
data parameter.
(linux_nat_target::detach, linux_nat_target::resume)
(linux_stop_and_wait_all_lwps, select_event_lwp)
(linux_nat_filter_event, linux_nat_wait_1)
(linux_nat_target::kill, linux_nat_target::stop)
(linux_nat_target::stop): Update.
(linux_nat_resume_callback): Change type.
(resume_stopped_resumed_lwps, count_events_callback)
(select_event_lwp_callback): Likewise.
(linux_stop_lwp, linux_nat_stop_lwp): Update.
* arm-linux-nat.c (struct update_registers_data): Remove.
(update_registers_callback): Change type.
(arm_linux_insert_hw_breakpoint1): Update.
* nat/x86-linux-dregs.c (update_debug_registers_callback): Remove
parameter.
(x86_linux_dr_set_addr): Update.
(x86_linux_dr_set_control): Update.
* nat/linux-nat.h (iterate_over_lwps_ftype): Remove parameter.
(iterate_over_lwps): Use gdb::function_view.
* nat/aarch64-linux-hw-point.c (struct
aarch64_dr_update_callback_param): Remove.
(debug_reg_change_callback): Change type.
(aarch64_notify_debug_reg_change): Update.
* s390-linux-nat.c (s390_refresh_per_info): Update.
gdb/gdbserver/ChangeLog
2019-03-12 Tom Tromey <tromey@adacore.com>
* linux-low.c (iterate_over_lwps): Update.
Alan Modra [Tue, 12 Mar 2019 05:49:25 +0000 (16:19 +1030)]
Don't use bfd_get_file_size in objdump
Compressed debug sections can have uncompressed sizes that exceed the
original file size, so we can't use bfd_get_file_size. objdump also
used bfd_get_file_size to limit reloc section size, but I believe the
underlying bug causing the PR22508 out of bounds buffer access was
that we had an integer overflow when calculating the reloc buffer
size. I've fixed that instead in most of the backends, som and
vms-alpha being the exceptions. SOM and vmd-alpha have rather more
serious bugs in their slurp_relocs routines that would need fixing
first if we want to fuss about making them safe against fuzzed object
files.
The patch also fixes a number of other potential overflows by using
the bfd_alloc2/malloc2/zalloc2 memory allocation functions.
bfd/
* coffcode.h (buy_and_read): Delete unnecessary forward decl. Add
nmemb parameter. Use bfd_alloc2.
(coff_slurp_line_table): Use bfd_alloc2. Update buy_and_read calls.
Delete assertion.
(coff_slurp_symbol_table): Use bfd_alloc2 and bfd_zalloc2.
(coff_slurp_reloc_table): Use bfd_alloc2. Update buy_and_read calls.
* coffgen.c (coff_get_reloc_upper_bound): Ensure size calculation
doesn't overflow.
* elf.c (bfd_section_from_shdr): Use bfd_zalloc2. Style fix.
(assign_section_numbers): Style fix.
(swap_out_syms): Use bfd_malloc2.
(_bfd_elf_get_reloc_upper_bound): Ensure size calculation doesn't
overflow.
(_bfd_elf_make_empty_symbol): Style fix.
(elfobj_grok_stapsdt_note_1): Formatting.
* elfcode.h (elf_object_p): Use bfd_alloc2.
(elf_write_relocs, elf_write_shdrs_and_ehdr): Likewise.
(elf_slurp_symbol_table): Use bfd_zalloc2.
(elf_slurp_reloc_table): Use bfd_alloc2.
(_bfd_elf_bfd_from_remote_memory): Use bfd_malloc2.
* elf64-sparc (elf64_sparc_get_reloc_upper_bound): Ensure
size calculation doesn't overflow.
(elf64_sparc_get_dynamic_reloc_upper_bound): Likewise.
* mach-o.c (bfd_mach_o_get_reloc_upper_bound): Likewise.
* pdp11.c (get_reloc_upper_bound): Copy aoutx.h version.
binutils/
* objdump.c (load_specific_debug_section): Don't compare section
size against file size.
(dump_relocs_in_section): Don't compare reloc size against file size.
Print "failed to read relocs" on bfd_get_reloc_upper_bound error.
Andreas Krebbel [Tue, 12 Mar 2019 13:23:10 +0000 (14:23 +0100)]
Add missing changelogs for previous commits.
Andreas Krebbel [Tue, 12 Mar 2019 13:09:55 +0000 (14:09 +0100)]
S/390: arch13: Adjust to recent changes
opcodes/ChangeLog:
2019-03-12 Andreas Krebbel <krebbel@linux.ibm.com>
* s390-opc.txt: Rename selhhhr to selfhr. Remove optional operand
from vstrszb, vstrszh, and vstrszf.
gas/ChangeLog:
2019-03-12 Andreas Krebbel <krebbel@linux.ibm.com>
* testsuite/gas/s390/zarch-arch13.s: Adjust testcase to optable changes.
* testsuite/gas/s390/zarch-arch13.d: Likewise.
Andreas Krebbel [Tue, 12 Mar 2019 13:09:55 +0000 (14:09 +0100)]
S/390: arch13: Add instruction descriptions
opcodes/ChangeLog:
2019-03-12 Andreas Krebbel <krebbel@linux.ibm.com>
* s390-opc.txt: Add instruction descriptions.
GDB Administrator [Tue, 12 Mar 2019 00:00:20 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom Tromey [Mon, 11 Mar 2019 16:22:17 +0000 (10:22 -0600)]
Remove redundant assignment from dwarf2_find_containing_comp_unit
dwarf2_find_containing_comp_unit has two assignments to "this_cu" in
quick succession, both of which are just:
this_cu = dwarf2_per_objfile->all_comp_units[low];
... with no intervening assignments.
This patch removes the second assignment. I'm checking this in as
obvious. Tested on x86-64 Fedora 29.
gdb/ChangeLog
2019-03-11 Tom Tromey <tromey@adacore.com>
* dwarf2read.c (dwarf2_find_containing_comp_unit): Remove
redundant assignment to "this_cu".
GDB Administrator [Mon, 11 Mar 2019 00:00:22 +0000 (00:00 +0000)]
Automatic date update in version.in
GDB Administrator [Sun, 10 Mar 2019 00:01:08 +0000 (00:01 +0000)]
Automatic date update in version.in
Simon Marchi [Fri, 8 Mar 2019 15:15:12 +0000 (10:15 -0500)]
Remove unnecessary cases from rank_one_type's switch
We return INCOMPATIBLE_TYPE_BADNESS for all these type codes, so we might as
well just let them go to the default case.
Incidentally, this patch also makes this false positive error go away when
compiling with gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0, default compiler on
Ubuntu 18.04.
CXX gdbtypes.o
/home/smarchi/src/binutils-gdb/gdb/gdbtypes.c: In function ‘rank rank_one_type(type*, type*, value*)’:
/home/smarchi/src/binutils-gdb/gdb/gdbtypes.c:4259:1: error: control reaches end of non-void function [-Werror=return-type]
}
^
gdb/ChangeLog:
* gdbtypes.c (rank_one_type): Remove unnecessary cases from switch.
Simon Marchi [Fri, 8 Mar 2019 15:15:11 +0000 (10:15 -0500)]
Split rank_one_type_parm_set from rank_one_type
gdb/ChangeLog:
* gdbtypes.c (rank_one_type_parm_set): New function extracted
from...
(rank_one_type): ... this.
Simon Marchi [Fri, 8 Mar 2019 15:15:11 +0000 (10:15 -0500)]
Split rank_one_type_parm_struct from rank_one_type
gdb/ChangeLog:
* gdbtypes.c (rank_one_type_parm_struct): New function extracted
from...
(rank_one_type): ... this.
Simon Marchi [Fri, 8 Mar 2019 15:15:11 +0000 (10:15 -0500)]
Split rank_one_type_parm_complex from rank_one_type
gdb/ChangeLog:
* gdbtypes.c (rank_one_type_parm_complex): New function extracted
from...
(rank_one_type): ... this.
Simon Marchi [Fri, 8 Mar 2019 15:15:10 +0000 (10:15 -0500)]
Split rank_one_type_parm_float from rank_one_type
gdb/ChangeLog:
* gdbtypes.c (rank_one_type_parm_float): New function extracted
from...
(rank_one_type): ... this.
Simon Marchi [Fri, 8 Mar 2019 15:15:10 +0000 (10:15 -0500)]
Split rank_one_type_parm_bool from rank_one_type
gdb/ChangeLog:
* gdbtypes.c (rank_one_type_parm_bool): New function extracted
from...
(rank_one_type): ... this.
Simon Marchi [Fri, 8 Mar 2019 15:15:09 +0000 (10:15 -0500)]
Split rank_one_type_parm_range from rank_one_type
gdb/ChangeLog:
* gdbtypes.c (rank_one_type_parm_range): New function extracted
from...
(rank_one_type): ... this.
Simon Marchi [Fri, 8 Mar 2019 15:15:09 +0000 (10:15 -0500)]
Split rank_one_type_parm_char from rank_one_type
gdb/ChangeLog:
* gdbtypes.c (rank_one_type_parm_char): New function extracted
from...
(rank_one_type): ... this.
Simon Marchi [Fri, 8 Mar 2019 15:15:09 +0000 (10:15 -0500)]
Split rank_one_type_parm_enum from rank_one_type
gdb/ChangeLog:
* gdbtypes.c (rank_one_type_parm_enum): New function extracted
from...
(rank_one_type): ... this.
Simon Marchi [Fri, 8 Mar 2019 15:15:08 +0000 (10:15 -0500)]
Split rank_one_type_parm_int from rank_one_type
gdb/ChangeLog:
* gdbtypes.c (rank_one_type_parm_int): New function extracted
from...
(rank_one_type): ... this.
Simon Marchi [Fri, 8 Mar 2019 15:15:08 +0000 (10:15 -0500)]
Split rank_one_type_parm_func from rank_one_type
gdb/ChangeLog:
* gdbtypes.c (rank_one_type_parm_func): New function extracted
from...
(rank_one_type): ... this.
Simon Marchi [Fri, 8 Mar 2019 15:15:08 +0000 (10:15 -0500)]
Split rank_one_type_parm_array from rank_one_type
gdb/ChangeLog:
* gdbtypes.c (rank_one_type_parm_array): New function extracted
from...
(rank_one_type): ... this.
Simon Marchi [Fri, 8 Mar 2019 15:15:07 +0000 (10:15 -0500)]
Split rank_one_type_parm_ptr from rank_one_type
gdb/ChangeLog:
* gdbtypes.c (rank_one_type_parm_ptr): New function extracted
from...
(rank_one_type): ... this.
Philippe Waroquiers [Sat, 9 Mar 2019 11:25:11 +0000 (12:25 +0100)]
Ensure 'help set/show print inferior-events' shows the example events.
Without this patch, the help stops after 'e.g.' :
(gdb) apropos \(inferior\|thread\) event
set print inferior-events -- Set printing of inferior events (e.g.
set print thread-events -- Set printing of thread events (such as thread start and exit)
show print inferior-events -- Show printing of inferior events (e.g.
show print thread-events -- Show printing of thread events (such as thread start and exit)
Using the same notation as for the thread evenets (i.e. 'such as') gives:
(gdb) apropos \(inferior\|thread\) event
set print inferior-events -- Set printing of inferior events (such as inferior start and exit)
set print thread-events -- Set printing of thread events (such as thread start and exit)
show print inferior-events -- Show printing of inferior events (such as inferior start and exit)
show print thread-events -- Show printing of thread events (such as thread start and exit)
Eli Zaretskii [Sat, 9 Mar 2019 06:44:56 +0000 (08:44 +0200)]
Support styling on native MS-Windows console
gdb/ChangeLog:
2019-03-08 Eli Zaretskii <eliz@gnu.org>
PR/24315
* utils.c (can_emit_style_escape) [_WIN32]: Don't disable styling
on MS-Windows if $TERM is not defined.
* cli/cli-style.c: Set cli_styling to 1 in the MinGW build.
* posix-hdep.c (gdb_console_fputs):
* mingw-hdep.c (rgb_to_16colors, gdb_console_fputs): New
functions.
* ui-file.h (gdb_console_fputs): Add prototype.
* ui-file.c (stdio_file::puts): Call gdb_console_fputs, and fall
back to fputs only if the former returns zero.
GDB Administrator [Sat, 9 Mar 2019 00:00:30 +0000 (00:00 +0000)]
Automatic date update in version.in
Alan Modra [Fri, 8 Mar 2019 12:11:55 +0000 (22:41 +1030)]
PR24311, FAIL: S-records with constructors
Not padding string merge section output to its alignment can cause
failures of the S-record tests when input string merge sections are
padded, since the ELF linker output for the single string section
would shrink compared to the SREC linker output. That might result in
following sections having different addresses.
On the other hand, padding string merge section output when input
string merge sections are *not* padded can also cause failures, in
this case due to the ELF linker output for the string section being
larger (due to padding) than the SREC linker output.
It would be better to write a more robust test, but it is also nice
to leave input unchanged when no string merges occur.
PR 24311
* merge.c (merge_strings): Return secinfo. Don't pad section
to alignment here.
(_bfd_merge_sections): Pad section to alignment here, if input
sections contributing to merged output all pad to alignment.
Formatting.
GDB Administrator [Fri, 8 Mar 2019 00:00:42 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom Tromey [Thu, 7 Mar 2019 11:20:19 +0000 (04:20 -0700)]
C++-ify bcache
This somewhat C++-ifies bcache. It replaces bcache_xmalloc and
bcache_xfree with constructors; changes some functions into methods;
and changes various structures to include a bcache directly (as
opposed to a pointer to a bcache).
Tested by the buildbot.
gdb/ChangeLog
2019-03-07 Tom Tromey <tom@tromey.com>
* symmisc.c (print_symbol_bcache_statistics): Update.
(print_objfile_statistics): Update.
* symfile.c (allocate_symtab): Update.
* stabsread.c: Don't include bcache.h.
* psymtab.h (struct psymbol_bcache): Don't declare.
(class psymtab_storage) <psymbol_cache>: Now a bcache.
(psymbol_bcache_init, psymbol_bcache_free)
(psymbol_bcache_get_bcache): Don't declare.
* psymtab.c (struct psymbol_bcache): Remove.
(psymtab_storage::psymtab_storage): Update.
(psymtab_storage::~psymtab_storage): Update.
(psymbol_bcache_init, psymbol_bcache_free)
(psymbol_bcache_get_bcache, psymbol_bcache_full): Remove.
(add_psymbol_to_bcache): Update.
(allocate_psymtab): Update.
* objfiles.h (struct objfile_per_bfd_storage) <filename_cache,
macro_cache>: No longer pointers.
* objfiles.c (get_objfile_bfd_data): Don't call bcache_xmalloc.
(free_objfile_per_bfd_storage): Don't call bcache_xfree.
* macrotab.c (macro_bcache): Update.
* macroexp.c: Don't include bcache.h.
* gdbtypes.c (check_types_worklist): Update.
(types_deeply_equal): Remove TRY/CATCH. Update.
* elfread.c (elf_symtab_read): Update.
* dwarf2read.c: Don't include bcache.h.
* buildsym.c (buildsym_compunit::get_macro_table): Update.
* bcache.h (bcache, bcache_full, bcache_xffree, bcache_xmalloc)
(print_bcache_statistics, bcache_memory_used): Don't declare.
(struct bcache): Move from bcache.c. Add constructor, destructor,
methods. Rename all data members.
* bcache.c (struct bcache): Move to bcache.h.
(bcache::expand_hash_table): Rename from expand_hash_table.
(bcache): Remove.
(bcache::insert): Rename from bcache_full.
(bcache::compare): Rename from bcache_compare.
(bcache_xmalloc): Remove.
(bcache::~bcache): Rename from bcache_xfree.
(bcache::print_statistics): Rename from print_bcache_statistics.
(bcache::memory_used): Rename from bcache_memory_used.
Pedro Alves [Thu, 7 Mar 2019 16:35:06 +0000 (16:35 +0000)]
Fix normal_stop latent bug
TARGET_WAITKIND_NO_RESUMED doesn't have an associated event thread, so
we shouldn't be referring to inferior_thread() assuming it points to
one.
This was caught on the multi-target branch, where we always switch to
no-thread-selected whenever we start handling an event, exactly to
catch places that incorrectly use "inferior_ptid/inferior_thread()"
without switching to the right event thread / target.
Here, on the branch, we assert in inferior_thread() because
TARGET_WAITKIND_NO_RESUMED doesn't have an associated event thread, so
inferior_ptid is still null_ptid.
gdb/ChangeLog:
2019-03-07 Pedro Alves <palves@redhat.com>
* infrun.c (normal_stop): Also check for
TARGET_WAITKIND_NO_RESUMED before referring to inferior_thread().
Andrew Burgess [Thu, 7 Mar 2019 14:53:37 +0000 (14:53 +0000)]
gdb: Move value_from_host_double into value.c and make more use of it
The function value_from_host_double can be moved from f-lang.c into
value.c as a generally useful function, and then used more widely.
Tested on X86-64/GNU Linux with no regressions.
gdb/ChangeLog:
* f-lang.c (value_from_host_double): Moved to...
* value.c (value_from_host_double): ...here.
* value.h (value_from_host_double): Declare.
* guile/scm-math.c (vlscm_convert_typed_number): Use
value_from_host_double.
(vlscm_convert_number): Likewise.
* guile/scm-value.c (gdbscm_value_to_real): Likewise.
* python/py-value.c (convert_value_from_python): Likewise.
GDB Administrator [Thu, 7 Mar 2019 00:00:23 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom Tromey [Mon, 28 Jan 2019 17:51:01 +0000 (10:51 -0700)]
Use SCOPE_EXIT in write_gcore_file
This replaces a TRY/CATCH in write_gcore_file with a use of SCOPE_EXIT
instead. I find that this is simpler to understand.
2019-03-06 Tom Tromey <tom@tromey.com>
* gcore.c (write_gcore_file): Use SCOPE_EXIT.
Tom Tromey [Thu, 24 Jan 2019 16:58:29 +0000 (09:58 -0700)]
Remove free_current_contents
free_current_contents is no longer used, so this patch removes it.
2019-03-06 Tom Tromey <tom@tromey.com>
* utils.h (free_current_contents): Don't declare.
* utils.c (free_current_contents): Remove.
Tom Tromey [Thu, 24 Jan 2019 16:56:49 +0000 (09:56 -0700)]
Remove basic cleanup code
This removes the basic cleanup code: make_cleanups, do_cleanups,
discard_cleanups, and friends. This code is no longer needed, as
nothing in gdb makes an ordinary cleanup. Final cleanups are still
needed.
2019-03-06 Tom Tromey <tom@tromey.com>
* top.c (quit_force): Update.
* main.c (captured_command_loop): Update.
* common/new-op.c (operator new): Update.
* common/common-exceptions.c (struct catcher)
<save_cleanup_chain>: Remove member.
(exceptions_state_mc_init): Update.
(exception_try_scope_entry): Return nullptr.
(exception_try_scope_exit, exception_rethrow)
(throw_exception_sjlj, throw_exception_cxx): Update.
* common/cleanups.h (make_cleanup, make_cleanup_dtor)
(all_cleanups, do_cleanups, discard_cleanups)
(discard_final_cleanups, save_cleanups, save_final_cleanups)
(restore_cleanups, restore_final_cleanups): Don't declare.
(do_final_cleanups): Remove parameter.
* common/cleanups.c (cleanup_chain, make_cleanup)
(make_cleanup_dtor, all_cleanups, do_cleanups)
(discard_my_cleanups, discard_cleanups)
(discard_final_cleanups, save_my_cleanups, save_cleanups)
(save_final_cleanups, restore_my_cleanups, restore_cleanups)
(null_cleanup): Remove.
(do_final_cleanups): Remove parameter.
Tom Tromey [Thu, 14 Feb 2019 23:10:01 +0000 (16:10 -0700)]
Use unique_xmalloc_ptr in remote.c
This removes a cleanup from remote.c, replacing it with
unique_xmalloc_ptr.
2019-03-06 Tom Tromey <tom@tromey.com>
* remote.c (remote_target::remote_parse_stop_reply): Use
unique_xmalloc_ptr.
Tom Tromey [Thu, 24 Jan 2019 16:51:19 +0000 (09:51 -0700)]
Remove last cleanups from stabsread.c
This removes the last cleanups from stabsread.c. Similar code in
dwarf2read.c was C++-ified, but considering that stabs are deprecated,
it seemed simpler to just change these allocations to use an obstack
and leave the data structures in place.
This patch renames field_info to stabs_field_info -- adding a
constructor here provoked a bug due to the resulting ODR violation.
2019-03-06 Tom Tromey <tom@tromey.com>
* stabsread.c (struct stabs_field_info): Rename from field_info.
<list, fnlist>: Add initializers.
<obstack>: New member.
(read_member_functions, read_struct_fields, read_baseclasses):
Allocate on obstack. Don't use cleanups.
(read_one_struct_field, read_member_functions, read_struct_fields)
(read_baseclasses, read_tilde_fields, attach_fn_fields_to_type)
(attach_fields_to_type, read_cpp_abbrev, read_member_functions)
(read_struct_type): Update.
Tom Tromey [Thu, 24 Jan 2019 13:43:45 +0000 (06:43 -0700)]
Remove last cleanup from linux-namespaces.c
This removes the last cleanup from linux-namespaces.c, replacing it
with a use of SCOPE_EXIT.
2019-03-06 Tom Tromey <tom@tromey.com>
* nat/linux-namespaces.c (linux_mntns_access_fs): Use SCOPE_EXIT.
* common/filestuff.h (make_cleanup_close): Don't declare.
* common/filestuff.c (do_close_cleanup, make_cleanup_close):
Remove.
Tom Tromey [Thu, 24 Jan 2019 13:38:59 +0000 (06:38 -0700)]
Remove last cleanup solib-aix.c
This removes the last cleanup solib-aix.c, replacing it with a use of
make_scope_exit.
2019-03-06 Tom Tromey <tom@tromey.com>
* solib-aix.c: Use make_scope_exit.
Tom Tromey [Thu, 24 Jan 2019 13:41:12 +0000 (06:41 -0700)]
Remove last cleanups from solib-svr4.c
This removes the last cleanups from solib-svr4.c, replacing them with
uses of make_scope_exit.
2019-03-06 Tom Tromey <tom@tromey.com>
* solib-svr4.c (svr4_parse_libraries, svr4_current_sos_direct):
Use make_scope_exit.
Tom Tromey [Thu, 24 Jan 2019 05:23:15 +0000 (22:23 -0700)]
Remove cleanup from solib-svr4.c
This removes a cleanup from solib-svr4.c, replacing it with
make_scope_exit.
2019-03-06 Tom Tromey <tom@tromey.com>
* solib-svr4.c (disable_probes_interface): Remove parameter.
(svr4_handle_solib_event): Use make_scope_exit.
Tom Tromey [Thu, 24 Jan 2019 05:20:04 +0000 (22:20 -0700)]
Remove last cleanup from gdbserver
This removes the last cleanup from gdbserver, replacing it with
SCOPE_EXIT. This could perhaps be done in a different way, but this
approach was direct and obviously correct.
2019-03-06 Tom Tromey <tom@tromey.com>
* server.c (detach_or_kill_for_exit_cleanup): Remove parameter.
(captured_main): Use SCOPE_EXIT.
Tom Tromey [Thu, 24 Jan 2019 05:16:53 +0000 (22:16 -0700)]
C++ify remote notification code
This C++ifies the remote notification code -- replacing function
pointers with virtual methods and using unique_ptr. This allows for
the removal of some cleanups.
2019-03-06 Tom Tromey <tom@tromey.com>
* remote.c (struct stop_reply_deleter): Remove.
(stop_reply_up): Update.
(struct stop_reply): Derive from notif_event. Don't typedef.
<regcache>: Now a std::vector.
(stop_reply_xfree): Remove.
(stop_reply::~stop_reply): Rename from stop_reply_dtr.
(remote_notif_stop_alloc_reply): Return a unique_ptr. Use new.
(remote_target::discard_pending_stop_replies): Use delete.
(remote_target::remote_parse_stop_reply): Update.
(remote_target::process_stop_reply): Update.
* remote-notif.h (struct notif_event): Add virtual destructor.
Remove "dtr" member.
(struct notif_client) <alloc_event>: Return a unique_ptr.
(notif_event_xfree): Don't declare.
(notif_event_up): New typedef.
* remote-notif.c (remote_notif_ack, remote_notif_parse): Update.
(notif_event_xfree, do_notif_event_xfree): Remove.
(remote_notif_state_xfree): Update.
Tom Tromey [Wed, 23 Jan 2019 23:28:28 +0000 (16:28 -0700)]
Change displaced_step_clear_cleanup to a forward_scope_exit
This changes displaced_step_clear_cleanup to be a forward_scope_exit
and updates the callers.
gdb/ChangeLog
2019-03-06 Tom Tromey <tom@tromey.com>
* infrun.c (displaced_step_clear_cleanup): Now a
forward_scope_exit type.
(displaced_step_prepare_throw): Update.
(displaced_step_fixup): Update.
Tom Tromey [Wed, 23 Jan 2019 22:11:42 +0000 (15:11 -0700)]
Update two cleanup comments
This updates another couple of comments to remove mentions of
cleanups.
gdb/ChangeLog
2019-03-06 Tom Tromey <tom@tromey.com>
* inferior.h (class inferior): Update comment.
* gdbthread.h (class thread_info): Update comment.
Tom Tromey [Sun, 19 Aug 2018 17:50:44 +0000 (11:50 -0600)]
Remove cleanups from coffread.c
This removes the remaining cleanups from coffread.c.
Tested by the buildbot and also some manual testing.
This version includes the fix provided by Joel.
gdb/ChangeLog
2019-03-06 Joel Brobecker <brobecker@adacore.com>
Tom Tromey <tom@tromey.com>
* stabsread.h (struct stab_section_list): Remove.
(coffstab_build_psymtabs): Update.
* dbxread.c (symbuf_sections): Now a std::vector.
(sect_idx): New global.
(fill_symbuf): Update.
(coffstab_build_psymtabs): Change type of stabsects parameter.
Update.
* coffread.c (struct coff_symfile_info) <stabsects>: Now a
std::vector.
(linetab, linetab_offset, linetab_size, stringtab): Move earlier.
(coff_locate_sections): Update.
(coff_symfile_read): Remove cleanups. Update.
(init_stringtab): Add storage parameter.
(free_stringtab, free_stringtab_cleanup): Remove.
(init_lineno): Add storage parameter.
(free_linetab, free_linetab_cleanup): Remove.
Pedro Alves [Wed, 6 Mar 2019 18:29:19 +0000 (18:29 +0000)]
Eliminate fork_info::clobber_regs
All fork_save_infrun_state callers pass '1' as CLOBBER_REGS nowadays.
The larger hunk in fork_save_infrun_state is just a reindentation.
gdb/ChangeLog:
2019-03-06 Pedro Alves <palves@redhat.com>
* linux-fork.c (fork_info::clobber_regs): Delete.
(fork_load_infrun_state): Remove reference to 'clobber_regs'.
(fork_save_infrun_state): Remove 'clobber_regs' parameter. Update
comment. Adjust.
(scoped_switch_fork_info::scoped_switch_fork_info)
(checkpoint_command, linux_fork_context): Adjust
fork_save_infrun_state calls.
Pedro Alves [Wed, 6 Mar 2019 18:29:19 +0000 (18:29 +0000)]
linux-fork.c: rewrite inf_has_multiple_threads
There's no need to iterate over all threads of all inferiors here.
gdb/ChangeLog:
2019-03-06 Pedro Alves <palves@redhat.com>
* linux-fork.c (inf_has_multiple_thread_cb): Delete.
(inf_has_multiple_threads): Return 'bool' and rewrite using
inferior_info::threads().
Pedro Alves [Wed, 6 Mar 2019 18:29:18 +0000 (18:29 +0000)]
C++ify fork_info, use std::list
- Convert new_fork and free_fork to fork_info ctor/dtor.
- Use std::list.
gdb/ChangeLog:
2019-03-06 Pedro Alves <palves@redhat.com>
* linux-fork.c: Include <list>.
(fork_list): Now a std::list instance.
(fork_info): Add ctor, dtor, and in-class initialize all fields.
(forks_exist_p, find_last_fork): Adjust.
(new_fork): Delete.
(one_fork_p): New.
(add_fork): Adjust.
(free_fork): Delete, folded into fork_info::~fork_info().
(delete_fork, find_fork_ptid, find_fork_id, find_fork_pid):
Adjust.
(init_fork_list): Delete.
(linux_fork_killall, linux_fork_mourn_inferior)
(linux_fork_detach, info_checkpoints_command): Adjust.
(_initialize_linux_fork): No longer call init_fork_list.
Pedro Alves [Wed, 6 Mar 2019 18:29:17 +0000 (18:29 +0000)]
Make "checkpoint" not rely on inferior_ptid
Don't rely on "inferior_ptid" deep within add_fork. In the
multi-target branch, I'm forcing inferior_ptid to null_ptid early in
infrun event handling to make sure we don't inadvertently rely on the
current thread/target when we shouldn't, and that caught some bad or
unnecessary assumptions throughout.
gdb/ChangeLog:
2019-03-06 Pedro Alves <palves@redhat.com>
* linux-fork.c (new_fork): New, split out of ...
(add_fork): ... this. Return void. Move "first fork" special
case from here, to ...
(checkpoint_command): ... here.
* linux-linux.h (add_fork): Return void.
Andrew Burgess [Mon, 21 Jan 2019 15:10:55 +0000 (15:10 +0000)]
gdb/fortran: Handle older TYPE*SIZE typenames
This patch adds support for the older TYPE*SIZE typenames that are
still around in older code.
For implementation this currently reuses the kind mechanism, as under
gFortran the kind number is equivalent to the size, however, this is
not necessarily true for all compilers. If the rules for other
compilers are better understood then this code might need to be
improved slightly to allow for a distinction between size and kind,
however, adding this extra complexity now seems pointless.
gdb/ChangeLog:
* f-exp.y (direct_abs_decl): Handle TYPE*SIZE type names.
gdb/testsuite/ChangeLog:
* gdb.fortran/type-kinds.exp: Extend to cover TYPE*SIZE cases.
Andrew Burgess [Fri, 18 Jan 2019 14:44:48 +0000 (14:44 +0000)]
gdb/fortran: Add support for the ABS intrinsic function
Adds support for the abs intrinsic function, this requires adding a
new pattern to the Fortran parser. Currently only float and integer
argument types are supported to ABS, complex is still not supported,
this can be added later if needed.
gdb/ChangeLog:
* f-exp.y: New token, UNOP_INTRINSIC.
(exp): New pattern using UNOP_INTRINSIC token.
(f77_keywords): Add 'abs' keyword.
* f-lang.c: Add 'target-float.h' and 'math.h' includes.
(value_from_host_double): New function.
(evaluate_subexp_f): Support UNOP_ABS.
gdb/testsuite/ChangeLog:
* gdb.fortran/intrinsics.exp: Extend to cover ABS.
Andrew Burgess [Fri, 18 Jan 2019 11:24:24 +0000 (11:24 +0000)]
gdb/fortran: Use TYPE_CODE_CHAR for character types
Switch to using TYPE_CODE_CHAR for character types. This appears to
have little impact on the test results as gFortran uses the
DW_TAG_string_type to represent all character variables (as far as I
can see). The only place this has an impact is when the user casts a
variable to a character type, in which case GDB does now use the CHAR
type, and prints the variable as both a value and a character, for
example, before:
(gdb) p ((character) 97)
$1 = 97
and after:
(gdb) p ((character) 97)
$1 = 97 'a'
gdb/ChangeLog:
* f-lang.c (build_fortran_types): Use TYPE_CODE_CHAR for character
types.
gdb/testsuite/ChangeLog:
* gdb.fortran/type-kinds.exp: Update expected results.
Andrew Burgess [Thu, 17 Jan 2019 16:31:56 +0000 (16:31 +0000)]
gdb/fortran: Add builtin 8-byte integer type with (kind=8) support
Add a new builtin type, an 8-byte integer, and allow GDB to parse
'integer (kind=8)', returning the new 8-byte integer.
gdb/ChangeLog:
* f-exp.y (convert_to_kind_type): Handle integer (kind=8).
* f-lang.c (build_fortran_types): Setup builtin_integer_s8.
* f-lang.h (struct builtin_f_type): Add builtin_integer_s8 field.
gdb/testsuite/ChangeLog:
* gdb.fortran/type-kinds.exp: Test new integer type kind.
Andrew Burgess [Thu, 17 Jan 2019 16:30:35 +0000 (16:30 +0000)]
gdb/fortran: Expand the set of types that support (kind=N)
Expand the number of types that can be adjusted with a (kind=N) type
extension.
gdb/ChangeLog:
* f-exp.y (convert_to_kind_type): Handle more type kinds.
gdb/testsuite/ChangeLog:
* gdb.fortran/type-kinds.exp (test_cast_1_to_type_kind): New
function.
(test_basic_parsing_of_type_kinds): Expand types tested.
(test_parsing_invalid_type_kinds): New function.
Andrew Burgess [Wed, 16 Jan 2019 16:42:10 +0000 (16:42 +0000)]
gdb/fortran: Add Fortran 'kind' intrinsic and keyword
The 'kind' keyword has two uses in Fortran, it is the name of a
builtin intrinsic function, and it is also a keyword used to create a
type of a specific kind.
This commit adds support for using kind as an intrinsic function, and
also adds some initial support for using kind to create types of a
specific kind.
This commit only allows the creation of the type 'character(kind=1)',
however, it will be easy enough to extend this in future to support
more type kinds.
The kind of any expression can be queried using the kind intrinsic
function. At the moment the kind returned corresponds to the size of
the type, this matches how gfortran handles kinds. However, the
correspondence between kind and type size depends on the compiler
and/or the specific target, so this might not be correct for
everyone. If we want to support different compilers/targets in future
the code to compute the kind from a type will need to be updated.
gdb/ChangeLog:
* expprint.c (dump_subexp_body_standard): Support UNOP_KIND.
* f-exp.y: Define 'KIND' token.
(exp): New pattern for KIND expressions.
(ptype): Handle types with a kind extension.
(direct_abs_decl): Extend to spot kind extensions.
(f77_keywords): Add 'kind' to the list.
(push_kind_type): New function.
(convert_to_kind_type): New function.
* f-lang.c (evaluate_subexp_f): Support UNOP_KIND.
* parse.c (operator_length_standard): Likewise.
* parser-defs.h (enum type_pieces): Add tp_kind.
* std-operator.def: Add UNOP_KIND.
gdb/testsuite/ChangeLog:
* gdb.fortran/intrinsics.exp: New file.
* gdb.fortran/intrinsics.f90: New file.
* gdb.fortran/type-kinds.exp: New file.
Andrew Burgess [Thu, 17 Jan 2019 14:42:15 +0000 (14:42 +0000)]
gdb/fortran: Enable debugging of the Fortran parser
This commit allows 'set debug parser on' to work for the Fortran
parser.
gdb/ChangeLog:
* f-exp.y (f_parse): Set yydebug.
Andrew Burgess [Wed, 16 Jan 2019 16:16:59 +0000 (16:16 +0000)]
gdb/fortran: Add new function to evaluate Fortran expressions
This is an initial restructure, it adds a new function in which
Fortran specific expressions can be evaluated. No Fortran specific
expressions are added with this commit though, so for now, the new
function just forwards all expressions to the default expression
handler, as such, there should be no user visible changes after this
commit. However, the new function will be useful in later commits.
gdb/ChangeLog:
* f-lang.c (evaluate_subexp_f): New function.
(exp_descriptor_f): New global.
(f_language_defn): Use exp_descriptor_f instead of
exp_descriptor_standard.
Andrew Burgess [Wed, 16 Jan 2019 15:30:54 +0000 (15:30 +0000)]
gdb/fortran: Simplify handling of Fortran dot operations and keywords
Use strncasecmp to compare Fortran dot operations (like .AND.) and for
the keywords list. This allows for some duplication to be removed
from the token arrays. I've also performed whitespace cleanup around
the code I've changed.
I have added some tests to ensure that upper and lowercase dot
operations are correctly tested. The keywords list remains always
lowercase for now.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* f-exp.y (struct token): Add comments.
(dot_ops): Remove uppercase versions and the end marker.
(f77_keywords): Likewise.
(yylex): Use ARRAY_SIZE to iterate over dot_ops, assert all
entries in the dot_ops array are case insensitive, and use
strncasecmp to compare strings. Also some whitespace cleanup in
this area. Similar for the f77_keywords array, except entries in
this list might be case sensitive.
gdb/testsuite/ChangeLog:
* gdb.fortran/dot-ops.exp: New file.
Andrew Burgess [Wed, 16 Jan 2019 13:36:46 +0000 (13:36 +0000)]
gdb/fortran: Cleanup code for parsing logical constants
This patch cleans up the code used for parsing the Fortran logical
constants '.TRUE.' and '.FALSE.'. Instead of listing both upper and
lowercase versions of these strings we now use strncasecmp.
I've also switched to use ARRAY_SIZE for the array iteration, and I've
cleaned up whitespace in the vicinity of the code I've changed.
Finally, I've added a test to ensure that both the upper and lower
case versions of the logical constants are understood by GDB,
something that was missing previously.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* f-exp.y (struct f77_boolean_val): Add comments.
(boolean_values): Remove uppercase versions, and end marker.
(yylex): Use ARRAY_SIZE for iterating over boolean_values array,
and use strncasecmp to achieve case insensitivity. Additionally,
perform whitespace cleanup around this code.
gdb/testsuite/ChangeLog:
* gdb.fortran/types.exp (test_logical_literal_types_accepted):
Check upper and lower case logical literals.
Andrew Burgess [Wed, 16 Jan 2019 13:20:28 +0000 (13:20 +0000)]
gdb/fortran: Remove some duplicate tests
Make the test names unique in gdb.fortran/types.exp by removing a few
duplicate tests.
gdb/testsuite/ChangeLog:
* gdb.fortran/types.exp (test_float_literal_types_accepted):
Remove duplicate tests.
Nick Bowler [Wed, 6 Mar 2019 15:20:29 +0000 (15:20 +0000)]
Allow the use of the ORIGIN and LENGTH attributes in expressions inside MEMORY regions.
PR 24289
* ldexp.c (fold_name): Allow lookups of the LENGTH and ORIGIN
attributes during the first phase.
Tom Tromey [Wed, 6 Mar 2019 14:55:42 +0000 (07:55 -0700)]
Fix remote-sim.c build after warn-unused-result change
John Darrington pointed out that commit
18cb7c9f3 ("Introduce
ATTRIBUTE_UNUSED_RESULT and use it") broke the build:
/home/john/binutils-gdb/gdb/remote-sim.c: In function 'void gdbsim_target_open(const char*, int)':
/home/john/binutils-gdb/gdb/remote-sim.c:765:18: error: ignoring return value of 'char** gdb_argv::release()', declared with attribute warn_unused_result [-Werror=unused-result]
This patch fixes the problem by arranging to use the result of the
release method.
Tested by rebuilding with a simulator enabled.
gdb/ChangeLog
2019-03-06 Tom Tromey <tromey@adacore.com>
* remote-sim.c (gdbsim_target_open): Use result of
gdb_argv::release.
Alan Hayward [Wed, 6 Mar 2019 09:52:08 +0000 (09:52 +0000)]
Testsuite: Ensure changing directory does not break the log file
get_compiler_info switches to a new log file before checking the compiler
to ensure the checks are not logged. Afterwards it restores back to using
the original log file. However, the logfile uses a relative path name -
if the current test has changed the current directory then all further
output for the test will be lost. This can confuse the code that collates
the main gdb.log file at the end of a FORCE_PARALLEL run.
fullpath-expand.exp calls gdb_compile after changing the current directory.
The "Ensure stack protection is off for GCC" patch added a call to
get_compiler_info from inside of gdb_compile, causing log file collection
to break for FORCE_PARALLEL runs.
The ideal solution would be to ensure the log file is always created using
an absolute path name. However, this is set at multiple points in
Makefile.in and in some instances just relies on dejagnu common code to set
the log file directory to "."
The simpler and safer solution is to override the builtin cd function. The
new function checks the current log file and if the path is relative, then
it resets the logging using an absolute path. Finally it calls the builtin
cd. This ensures get_compiler_info (and any other code) can correctly
backup and restore the current log file.
gdb/testsuite/ChangeLog:
* lib/gdb.exp (builtin_cd): rename of cd.
(cd): Override builtin.
Nick Clifton [Wed, 6 Mar 2019 09:43:15 +0000 (09:43 +0000)]
Fix a segmentation fault triggered by disassembling an EFi file with source included.
* dwarf2.c (_bfd_dwarf2_find_symbol_bias): Check for a NULL symbol
table pointer.
* coffgen.c (coff_find_nearest_line_with_names): Do not call
_bfd_dwarf2_find_symbol_bias if there is no symbol table available.
https://bugzilla.redhat.com/show_bug.cgi?id=1685727
Richard Bunt [Wed, 6 Mar 2019 08:23:00 +0000 (08:23 +0000)]
Fortran function calls with arguments
Prior to this patch, calling functions on the inferior with arguments and
then using these arguments within a function resulted in an invalid
memory access. This is because Fortran arguments are typically passed as
pointers to values.
It is possible to call Fortran functions, but memory must be allocated in
the inferior, so a pointer can be passed to the function, and the
language must be set to C to enable C-style casting. This is cumbersome
and not a pleasant debug experience.
This patch implements the GNU Fortran argument passing conventions with
caveats. Firstly, it does not handle the VALUE attribute as there is
insufficient DWARF information to determine when this is the case.
Secondly, functions with optional parameters can only be called with all
parameters present. Both these cases are marked as KFAILS in the test.
Since the GNU Fortran argument passing convention has been implemented,
there is no guarantee that this patch will work correctly, in all cases,
with other compilers.
Despite these limitations, this patch improves the ease with which
functions can be called in many cases, without taking away the existing
approach of calling with the language set to C.
Regression tested on x86_64, aarch64 and POWER9 with GCC 7.3.0.
Regression tested with Ada on x86_64.
Regression tested with native-extended-gdbserver target board.
gdb/ChangeLog:
* eval.c (evaluate_subexp_standard): Call Fortran argument
wrapping logic.
* f-lang.c (struct value): A value which can be passed into a
Fortran function call.
(fortran_argument_convert): Wrap Fortran arguments in a pointer
where appropriate.
(struct type): Value ready for a Fortran function call.
(fortran_preserve_arg_pointer): Undo check_typedef, the pointer
is needed.
* f-lang.h (fortran_argument_convert): Declaration.
(fortran_preserve_arg_pointer): Declaration.
* infcall.c (value_arg_coerce): Call Fortran argument logic.
gdb/testsuite/ChangeLog:
* gdb.fortran/function-calls.exp: New file.
* gdb.fortran/function-calls.f90: New test.
GDB Administrator [Wed, 6 Mar 2019 00:00:46 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom Tromey [Tue, 5 Mar 2019 21:58:24 +0000 (14:58 -0700)]
Remove some Python 3 #ifs
A recent patch from Kevin Buettner taught me that the PyBytes API is
available on Python 2. This patch removes a couple of related #ifs in
the Python code.
Tested on x86-64 Fedora 29, using both Python 3.7 and Python 2.7.
gdb/ChangeLog
2019-03-05 Tom Tromey <tromey@adacore.com>
* python/py-prettyprint.c (print_string_repr): Remove #if.
* python/py-utils.c (unicode_to_encoded_string): Remove #if.
Tom Tromey [Mon, 4 Mar 2019 20:37:59 +0000 (13:37 -0700)]
Change the_dummy_target to be a global
While debugging gdb, I printed the target stack and got:
(top-gdb) p g_target_stack
$10 = {
m_top = thread_stratum,
m_stack = {0x142b0b0, 0x13da600 <exec_ops>, 0x1c70690, 0x13d63b0 <ravenscar_ops>, 0x0, 0x0, 0x0}
}
(This is clearly from before the change to make ravenscar
multi-target-capable.)
Here, 0x142b0b0 is the singleton dummy target. It seems to me that
since this is always a singleton, it would be a bit nicer if it were a
global, so that it would be noted in the above.
This patch implements this idea, and now I get:
(top-gdb) p g_target_stack
$2 = {
m_top = dummy_stratum,
m_stack = {0x1f1b040 <the_dummy_target>, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}
}
I did not do the same for the debug target. It didn't seem as useful
to me.
gdb/ChangeLog
2019-03-05 Tom Tromey <tromey@adacore.com>
* target.c (the_dummy_target): Move later. Change type to
"dummy_target".
(initialize_targets): Don't initialize the_dummy_target.
Simon Marchi [Tue, 5 Mar 2019 19:00:42 +0000 (14:00 -0500)]
Small fix to gdb.Value constructor doc
The synopsis of the two-parameters form of the gdb.Value constructor is
currently shown as
Value.__init__ (val, [, type ])
in the documentation.
First, there is an extra comma, which I think we can remove in any
case.
Then, since the type parameter is not optional, I would not put in
between square brackets. Those usually indicate that something is
optional.
With this patch, it appears as:
Value.__init__ (val, type)
gdb/doc/ChangeLog:
* python.texi (Values From Inferior): Change synopsys of the
second form of Value.__init__.