Call _bfd_elf_maybe_set_textrel to set DF_TEXTREL by scanning dynamic
relocations in read-only section.
PR ld/26066
* elf32-nios2.c (nios2_elf32_size_dynamic_sections): Call
_bfd_elf_maybe_set_textrel to set DF_TEXTREL.
Don't do anything special with non-loaded, non-alloced sections.
In particular, any relocs in such sections should not affect GOT
and PLT reference counting (ie. we don't allow them to create GOT
or PLT entries), there's no possibility or desire to optimize TLS
relocs, and there's not much point in propagating relocs to shared
libs that the dynamic linker won't relocate.
PR ld/26066
* elf32-nios2.c (nios2_elf32_check_relocs): Skip non-loaded,
non-alloced sections.
Don't generate dynamic relocations for non SEC_ALLOC sections because
run-time loader won't process them.
* elf32-frv.c (elf32_frv_relocate_section): Don't generate
dynamic relocations for non SEC_ALLOC sections.
Don't generate dynamic relocations for non SEC_ALLOC sections because
run-time loader won't process them.
* elf32-arc.c (elf_arc_relocate_section): Don't generate dynamic
relocations for non SEC_ALLOC sections.
While a typedef can be specified in message files for the messages following
with the `MessageIdTypedef` directive, only the last typedef was honored by
windmc. This corrects this behavior, matching mc.exe functionality.
* windmc.h (struct mc_node): Add id_typecast field.
* mcparse.y (message): Initialise the id_typecast field.
* windmc.c (write_dbg): Use the id_typecast field as a parameter
when calling write_dbg_define.
(write_header): Likewise.
When running the gdb/jit-*.exp tests with runtest -v, I get:
...
ERROR: internal buffer is full.
UNRESOLVED: gdb.base/jit-elf-so.exp: one_jit_test-1: maintenance print objfiles
ERROR: internal buffer is full.
UNRESOLVED: gdb.base/jit-elf-so.exp: one_jit_test-2: maintenance print objfiles
ERROR: internal buffer is full.
UNRESOLVED: gdb.base/jit-elf.exp: one_jit_test-1: maintenance print objfiles
ERROR: internal buffer is full.
UNRESOLVED: gdb.base/jit-elf.exp: one_jit_test-2: maintenance print objfiles
ERROR: internal buffer is full.
UNRESOLVED: gdb.base/jit-elf.exp: attach: one_jit_test-2: maintenance print objfiles
ERROR: internal buffer is full.
UNRESOLVED: gdb.base/jit-elf.exp: PIE: one_jit_test-1: maintenance print objfiles
FAIL: gdb.base/jit-reader.exp: jit-reader-load
FAIL: gdb.base/jit-reader.exp: with jit-reader: before mangling: bt works
FAIL: gdb.base/jit-reader.exp: with jit-reader: after mangling: bt works
FAIL: gdb.base/jit-reader.exp: with jit-reader again: jit-reader-load
FAIL: gdb.base/jit-reader.exp: with jit-reader again: bt
...
This is the consequence of the use of global verbose in these tests, which is
used to change the actual test, rather than be more verbose about it.
Fix this by defining a global test_verbose in each test, and using that
instead.
Tested on x86_64-linux using runtest -v.
gdb/testsuite/ChangeLog:
2020-06-03 Tom de Vries <tdevries@suse.de>
PR testsuite/25609
* gdb.base/jit-elf-so.exp: Don't modify testing behaviour based on
value of global verbose.
* gdb.base/jit-elf.exp: Same.
* gdb.base/jit-reader.exp: Same.
* aout64.c (BMAGIC, QMAGIC): Do not define.
* aoutx.h (N_IS_BMAGIC, N_SET_QMAGIC): New defines.
(NAME (aout, some_aout_object_p)): Use N_IS_QMAGIC and N_IS_BMAGIC
to check the file format.
(adjust_z_magic): Use N_SET_QMAGIC to set file format.
* i386aout.c (NO_WRITE_HEADER_KLUDGE): Delete define.
* libaout.h (NO_WRITE_HEADER_KLUDGE): Do not define.
When binutils is compiled with -fsanitize=undefined, many tests with
linker, instead of $CC, fail with undefined symbol references to sanitize
library. Define NOSANTIZE_CFLAGS to -fno-sanitize=all if target compiler
supports it and compile such tests with $NOSANTIZE_CFLAGS.
* testsuite/config/default.exp (NOSANTIZE_CFLAGS): New.
* testsuite/ld-elf/linux-x86.exp: Add $NOSANTIZE_CFLAGS to
tests with run_ld_link_exec_tests.
* testsuite/ld-elf/shared.exp: Add $NOSANTIZE_CFLAGS to tests
with run_ld_link_tests.
* testsuite/ld-elf/tls.exp: Likewise.
* testsuite/ld-elfweak/elfweak.exp: Add $NOSANTIZE_CFLAGS to
tests with ld_link.
* testsuite/ld-gc/gc.exp: Add $NOSANTIZE_CFLAGS to cflags.
* testsuite/ld-plugin/lto.exp: Add $NOSANTIZE_CFLAGS to tests
with run_ld_link_tests.a
* testsuite/ld-plugin/plugin.exp: Append $NOSANTIZE_CFLAGS to
CFLAGS.
* testsuite/ld-selective/selective.exp: Add $NOSANTIZE_CFLAGS
to cflags and cxxflags.
* testsuite/ld-srec/srec.exp: Append $NOSANTIZE_CFLAGS to CC
and CXX.
* testsuite/ld-x86-64/plt-main-ibt-x32.dd: Updated for
-fsanitize=undefined.
* testsuite/ld-x86-64/plt-main-ibt.dd: Likewise.
* testsuite/ld-x86-64/x86-64.exp: Add $NOSANTIZE_CFLAGS to
tests with run_cc_link_tests and run_ld_link_tests.
--export-dynamic-symbol-list is like a dynamic list, but without
the symbolic property for unspecified symbols.
When creating an executable, --export-dynamic-symbol-list is treated
like --dynamic-list.
When creating a shared library, it is treated like --dynamic-list if
-Bsymbolic or --dynamic-list are used, otherwise, it is ignored, so
that references to matched symbols will not be bound to the definitions
within the shared library.
PR ld/25910
* NEWS: Mention --export-dynamic-symbol[-list].
* ld.texi: Document --export-dynamic-symbol[-list].
* ldgram.y: Pass current_dynamic_list_p to
lang_append_dynamic_list.
* ldlang.c (current_dynamic_list_p): New.
(ang_append_dynamic_list): Updated to take a pointer to
struct bfd_elf_dynamic_list * argument instead of using
link_info.dynamic_list.
(lang_append_dynamic_list_cpp_typeinfo): Pass
&link_info.dynamic_list to ang_append_dynamic_list.
(lang_append_dynamic_list_cpp_new): Likewise.
* ldlang.h (current_dynamic_list_p): New.
(lang_append_dynamic_list): Add a pointer to
struct bfd_elf_dynamic_list * argument.
* ldlex.h (option_values): Add OPTION_EXPORT_DYNAMIC_SYMBOL and
OPTION_EXPORT_DYNAMIC_SYMBOL_LIST.
* lexsup.c (ld_options): Add entries for
OPTION_EXPORT_DYNAMIC_SYMBOL and
OPTION_EXPORT_DYNAMIC_SYMBOL_LIST.
(parse_args): Handle --export-dynamic-symbol and
--export-dynamic-symbol-list.
* testsuite/ld-dynamic/export-dynamic-symbol-1.d: New.
* testsuite/ld-dynamic/export-dynamic-symbol-2.d: New.
* testsuite/ld-dynamic/export-dynamic-symbol-glob.d: New.
* testsuite/ld-dynamic/export-dynamic-symbol-list-1.d: New.
* testsuite/ld-dynamic/export-dynamic-symbol-list-2.d: New.
* testsuite/ld-dynamic/export-dynamic-symbol-list-glob.d: New.
* testsuite/ld-dynamic/export-dynamic-symbol.exp: New.
* testsuite/ld-dynamic/export-dynamic-symbol.s: New.
* testsuite/ld-dynamic/foo-bar.list: New.
* testsuite/ld-dynamic/foo.list: New.
* testsuite/ld-dynamic/foo.s: New.
* testsuite/ld-dynamic/fstar.list: New.
* testsuite/ld-elf/dlempty.list: New.
* testsuite/ld-elf/shared.exp: Add tests for
--export-dynamic-symbol and --export-dynamic-symbol-list.
This fixes some minor bugs in the docs for the .insn directive pointed out
by Frédéric Pétrot, and I added a few more cleanups since I was changing
the docs.
gas/
PR 26051
* doc/c-riscv.texi (RISC-V-Formats): Add missing I format using
simm12(rs1). Correct S format to use simm12(rs1). Drop SB and B
formats using simm12(rs1). Correct SB and B to use rs1 and rs2.
Move B before SB. Move J before UJ.
The original report is as follow,
https://sourceware.org/pipermail/binutils/2020-June/111383.html
Inlcude the bfd.h in the include/opcode/riscv.h may cause gdbserver fail
to build. I just want to use the `bfd_boolean` in the opcodes/riscv-opc.c,
but I didn't realize this cause the build failed. Fortunately, I can also
use the `int` as the function return types just like others in the
opcodes/riscv-opc.c.
include/
* opcode/riscv.h: Remove #include "bfd.h". And change the return
types of riscv_get_isa_spec_class and riscv_get_priv_spec_class
from bfd_boolean to int.
opcodes/
* riscv-opc.c (riscv_get_isa_spec_class): Change bfd_boolean to int.
(riscv_get_priv_spec_class): Likewise.
This commit changes the language_data::skip_trampoline function
pointer member variable into a member function of language_defn.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* ada-lang.c (ada_language_data): Delete skip_trampoline
initializer.
* c-lang.c (c_language_data): Likewise.
(cplus_language_data): Likewise.
(cplus_language::skip_trampoline): New member function.
(asm_language_data): Delete skip_trampoline initializer.
(minimal_language_data): Likewise.
* d-lang.c (d_language_data): Likewise.
* f-lang.c (f_language_data): Likewise.
* go-lang.c (go_language_data): Likewise.
* language.c (unk_lang_trampoline): Delete function.
(skip_language_trampoline): Update.
(unknown_language_data): Delete skip_trampoline initializer.
(auto_language_data): Likewise.
* language.h (language_data): Delete skip_trampoline field.
(language_defn::skip_trampoline): New function.
* m2-lang.c (m2_language_data): Delete skip_trampoline
initializer.
* objc-lang.c (objc_skip_trampoline): Delete function, move
implementation to objc_language::skip_trampoline.
(objc_language_data): Delete skip_trampoline initializer.
(objc_language::skip_trampoline): New member function with
implementation from objc_skip_trampoline.
* opencl-lang.c (opencl_language_data): Delete skip_trampoline
initializer.
* p-lang.c (pascal_language_data): Likewise.
* rust-lang.c (rust_language_data): Likewise.
This commit changes the language_data::la_demangle function pointer
member variable into a member function of language_defn.
The only slightly "weird" change in this commit is in f-lang.c, where
I have given the Fortran language a demangle method that is identical
to the default language_defn::demangle. The only reason for this is
to give me somewhere to copy the comment that was previously embedded
within the f_language_data structure.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* ada-lang.c (ada_language_data): Delete la_demangle initializer.
(ada_language::demangle): New member function.
* c-lang.c (c_language_data): Delete la_demangle initializer.
(cplus_language_data): Delete la_demangle initializer.
(cplus_language::demangle): New member function.
(asm_language_data): Delete la_demangle initializer.
(minimal_language_data): Delete la_demangle initializer.
* d-lang.c (d_language_data): Delete la_demangle initializer.
(d_language::demangle): New member function.
* f-lang.c (f_language_data): Delete la_demangle initializer.
(f_language::demangle): New member function.
* go-lang.c (go_language_data): Delete la_demangle initializer.
(go_language::demangle): New member function.
* language.c (language_demangle): Update.
(unk_lang_demangle): Delete.
(unknown_language_data): Delete la_demangle initializer.
(unknown_language::demangle): New member function.
(auto_language_data): Delete la_demangle initializer.
(auto_language::demangle): New member function.
* language.h (language_data): Delete la_demangle field.
(language_defn::demangle): New function.
* m2-lang.c (m2_language_data): Delete la_demangle initializer.
* objc-lang.c (objc_language_data): Delete la_demangle
initializer.
(objc_language::demangle): New member function.
* opencl-lang.c (opencl_language_data): Delete la_demangle
initializer.
* p-lang.c (pascal_language_data): Likewise.
* rust-lang.c (rust_language_data): Likewise.
(rust_language::demangle): New member functi
This commit changes the language_data::la_print_type function pointer
member variable into a member function of language_defn.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* ada-lang.c (ada_language_data): Delete la_print_type
initializer.
(ada_language::print_type): New member function.
* c-lang.c (c_language_data): Delete la_print_type initializer.
(c_language::print_type): New member function.
(cplus_language_data): Delete la_print_type initializer.
(cplus_language::print_type): New member function.
(asm_language_data): Delete la_print_type initializer.
(asm_language::print_type): New member function.
(minimal_language_data): Delete la_print_type initializer.
(minimal_language::print_type): New member function.
* d-lang.c (d_language_data): Delete la_print_type initializer.
(d_language::print_type): New member function.
* f-lang.c (f_language_data): Delete la_print_type initializer.
(f_language::print_type): New member function.
* go-lang.c (go_language_data): Delete la_print_type initializer.
(go_language::print_type): New member function.
* language.c (unk_lang_print_type): Delete.
(unknown_language_data): Delete la_print_type initializer.
(unknown_language::print_type): New member function.
(auto_language_data): Delete la_print_type initializer.
(auto_language::print_type): New member function.
* language.h (language_data): Delete la_print_type field.
(language_defn::print_type): New function.
(LA_PRINT_TYPE): Update.
* m2-lang.c (m2_language_data): Delete la_print_type initializer.
(m2_language::print_type): New member function.
* objc-lang.c (objc_language_data): Delete la_print_type
initializer.
(objc_language::print_type): New member function.
* opencl-lang.c (opencl_print_type): Delete, implementation moved
to opencl_language::print_type.
(opencl_language_data): Delete la_print_type initializer.
(opencl_language::print_type): New member function, implementation
from opencl_print_type.
* p-lang.c (pascal_language_data): Delete la_print_type
initializer.
(pascal_language::print_type): New member function.
* rust-lang.c (rust_print_type): Delete, implementation moved to
rust_language::print_type.
(rust_language_data): Delete la_print_type initializer.
(rust_language::print_type): New member function, implementation
from rust_print_type.
This commit changes the language_data::la_sniff_from_mangled_name
function pointer member variable into a member function of
language_defn.
Previously the la_sniff_from_mangled_name pointer was NULL for some
languages, however, all uses of this function pointer were through the
function language_sniff_from_mangled_name which provided a default
implementation.
This default implementation now becomes the implementation in the base
class language_defn, which is then overridden as required in various
language sub-classes.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* ada-lang.c (ada_sniff_from_mangled_name): Delete function,
implementation moves to...
(ada_language::sniff_from_mangled_name): ...here. Update return
type.
(ada_language_data): Delete la_sniff_from_mangled_name
initializer.
* c-lang.c (c_language_data): Likewise.
(cplus_language_data): Likewise.
(cplus_language::sniff_from_mangled_name): New member function,
implementation taken from gdb_sniff_from_mangled_name.
(asm_language_data): Delete la_sniff_from_mangled_name
initializer.
(minimal_language_data): Likewise.
* cp-support.c (gdb_sniff_from_mangled_name): Delete,
implementation moves to cplus_language::sniff_from_mangled_name.
* cp-support.h (gdb_sniff_from_mangled_name): Delete declaration.
* d-lang.c (d_sniff_from_mangled_name): Delete, implementation
moves to...
(d_language::sniff_from_mangled_name): ...here.
(d_language_data): Delete la_sniff_from_mangled_name initializer.
* f-lang.c (f_language_data): Likewise.
* go-lang.c (go_sniff_from_mangled_name): Delete, implementation
moves to...
(go_language::sniff_from_mangled_name): ...here.
(go_language_data): Delete la_sniff_from_mangled_name initializer.
* language.c (language_sniff_from_mangled_name): Delete.
(unknown_language_data): Delete la_sniff_from_mangled_name
initializer.
(auto_language_data): Likewise.
* language.h (language_data): Delete la_sniff_from_mangled_name
field.
(language_defn::sniff_from_mangled_name): New function.
(language_sniff_from_mangled_name): Delete declaration.
* m2-lang.c (m2_language_data): Delete la_sniff_from_mangled_name
field.
* objc-lang.c (objc_sniff_from_mangled_name): Delete,
implementation moves to...
(objc_language::sniff_from_mangled_name): ...here.
(objc_language_data): Delete la_sniff_from_mangled_name initializer.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_language_data): Likewise.
* rust-lang.c (rust_sniff_from_mangled_name): Delete,
implementation moves to...
(rust_language::sniff_from_mangled_name): ...here.
(rust_language_data): Delete la_sniff_from_mangled_name
initializer.
* symtab.c (symbol_find_demangled_name): Call
sniff_from_mangled_name member function.
This commit changes the language_data::la_get_compile_instance
function pointer member variable into a member function of
language_defn. Unlike previous commits converting fields of
language_data to member function in language_defn, this field is NULL
for some languages. As a result I had to change the API slightly so
that the base language_defn class provides an implementation.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* ada-lang.c (ada_language_data): Delete la_get_compile_instance
initializer.
* c-lang.c (class compile_instance): Declare.
(c_language_data): Delete la_get_compile_instance initializer.
(c_language::get_compile_instance): New member function.
(cplus_language_data): Delete la_get_compile_instance initializer.
(cplus_language::get_compile_instance): New member function.
(asm_language_data): Delete la_get_compile_instance initializer.
(minimal_language_data): Likewise.
* c-lang.h (c_get_compile_context): Update comment.
(cplus_get_compile_context): Update comment.
* compile/compile.c (compile_to_object): Update calls, don't rely
on function pointer being NULL.
* d-lang.c (d_language_data): Delete la_get_compile_instance
initializer.
* f-lang.c (f_language_data): Likewise.
* go-lang.c (go_language_data): Likewise.
* language.c (unknown_language_data): Likewise.
(auto_language_data): Likewise.
* language.h (language_data): Delete la_get_compile_instance field.
(language_defn::get_compile_instance): New member function.
* m2-lang.c (m2_language_data): Delete la_get_compile_instance
initializer.
* objc-lang.c (objc_language_data): Likewise.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_language_data): Likewise.
* rust-lang.c (rust_language_data): Likewise.
This commit changes the language_data::la_iterate_over_symbols
function pointer member variable into a member function of
language_defn.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* ada-lang.c (ada_add_all_symbols): Update comment.
(ada_iterate_over_symbols): Delete, move implementation to...
(ada_language::iterate_over_symbols): ...here, a new member
function, rewrite to use range based for loop.
(ada_language_data): Delete la_iterate_over_symbols initializer.
* c-lang.c (c_language_data): Likewise.
(cplus_language_data): Likewise.
(asm_language_data): Likewise.
(minimal_language_data): Likewise.
* d-lang.c (d_language_data): Likewise.
* f-lang.c (f_language_data): Likewise.
* go-lang.c (go_language_data): Likewise.
* language.c (unknown_language_data): Likewise.
(auto_language_data): Likewise.
* language.h (language_data): Delete la_iterate_over_symbols field.
(language_defn::iterate_over_symbols): New member function.
(LA_ITERATE_OVER_SYMBOLS): Update.
* linespec.c (iterate_over_all_matching_symtabs): Update.
* m2-lang.c (m2_language_data): Delete la_iterate_over_symbols
initializer.
* objc-lang.c (objc_language_data): Likewise.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_language_data): Likewise.
* rust-lang.c (rust_language_data): Likewise.
This commit changes the language_data::la_language_arch_info function
pointer member variable into a member function of language_defn.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* ada-lang.c (ada_language_arch_info): Delete function, move
implementation to...
(ada_language::language_arch_info): ...here, a new member
function.
(ada_language_data): Delete la_language_arch_info.
* c-lang.c (c_language_data): Likewise.
(c_language::language_arch_info): New member function.
(cplus_language_arch_info): Delete function, move
implementation to...
(cplus_language::language_arch_info): ...here, a new member
function.
(cplus_language_data): Delete la_language_arch_info.
(asm_language_data): Likewise.
(asm_language::language_arch_info): New member function.
(minimal_language_data): Delete la_language_arch_info.
(minimal_language::language_arch_info): New member function.
* d-lang.c (d_language_arch_info): Delete function, move
implementation to...
(d_language::language_arch_info): ...here, a new member
function.
(d_language_data): Delete la_language_arch_info.
* f-lang.c (f_language_arch_info): Delete function, move
implementation to...
(f_language::language_arch_info): ...here, a new member
function.
(f_language_data): Delete la_language_arch_info.
* go-lang.c (go_language_arch_info): Delete function, move
implementation to...
(go_language::language_arch_info): ...here, a new member
function.
(go_language_data): Delete la_language_arch_info.
* language.c (unknown_language_data): Likewise.
(unknown_language::language_arch_info): New member function.
(auto_language_data): Delete la_language_arch_info.
(auto_language::language_arch_info): New member function.
(language_gdbarch_post_init): Update call to
la_language_arch_info.
* language.h (language_data): Delete la_language_arch_info
function pointer.
(language_defn::language_arch_info): New function.
* m2-lang.c (m2_language_arch_info): Delete function, move
implementation to...
(m2_language::language_arch_info): ...here, a new member
function.
(m2_language_data): Delete la_language_arch_info.
* objc-lang.c (objc_language_arch_info): Delete function, move
implementation to...
(objc_language::language_arch_info): ...here, a new member
function.
(objc_language_data): Delete la_language_arch_info.
* opencl-lang.c (opencl_language_arch_info): Delete function, move
implementation to...
(opencl_language::language_arch_info): ...here, a new member
function.
(opencl_language_data): Delete la_language_arch_info.
* p-lang.c (pascal_language_arch_info): Delete function, move
implementation to...
(pascal_language::language_arch_info): ...here, a new member
function.
(pascal_language_data): Delete la_language_arch_info.
* rust-lang.c (rust_language_arch_info): Delete function, move
implementation to...
(rust_language::language_arch_info): ...here, a new member
function.
(rust_language_data): Delete la_language_arch_info.
This commit changes the language_data::la_pass_by_reference function
pointer member variable into a member function of language_defn.
The interesting thing in this commit is that I have removed the
default_pass_by_reference function entirely. This function only ever
returned a language_pass_by_ref_info struct in its default state, so
all uses of this function can be replaced by just default
initialisation of a language_pass_by_ref_info variable.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* ada-lang.c (ada_language_data): Delete la_pass_by_reference
initializer.
* c-lang.c (c_language_data): Likewise.
(cplus_language_data): Likewise.
(cplus_language::pass_by_reference_info): New method.
(asm_language_data): Delete la_pass_by_reference initializer.
(minimal_language_data): Likewise.
* cp-abi.c (cp_pass_by_reference): Remove use of
default_pass_by_reference.
* d-lang.c (d_language_data): Likewise.
* f-lang.c (f_language_data): Likewise.
* gnu-v3-abi.c (gnuv3_pass_by_reference): Remove use of
default_pass_by_reference.
* go-lang.c (go_language_data): Likewise.
* language.c (language_pass_by_reference): Update.
(default_pass_by_reference): Delete.
(unknown_language_data): Delete la_pass_by_reference
initializer.
(auto_language_data): Likewise.
* language.h (struct language_data): Delete la_pass_by_reference
field.
(language_defn::pass_by_reference_info): New member function.
(default_pass_by_reference): Delete declaration.
* m2-lang.c (m2_language_data): Delete la_pass_by_reference
initializer.
* objc-lang.c (objc_language_data): Likewise.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_language_data): Likewise.
* rust-lang.c (rust_language_data): Likewise.
This commit changes the language_data::la_read_var_value function
pointer member variable into a member function of language_defn.
An interesting aspect of this change is that the implementation of
language_defn::read_var_value is actually in findvar.c. This is
partly historical, the new language_defn::read_var_value is a rename
of default_read_var_value, which was already in that file, but also,
that is the file that contains the helper functions needed by the
read_var_value method, so it makes sens that the method implementation
should continue to live there (I think).
There should be no user visible changes after this commit.
gdb/ChangeLog:
* ada-lang.c (ada_read_var_value): Delete function, move
implementation to...
(ada_language::read_var_value): ...here.
(ada_language_data): Delete la_read_var_value initializer.
* c-lang.c (c_language_data): Likewise.
(cplus_language_data): Likewise.
(minimal_language_data): Likewise.
* d-lang.c (d_language_data): Likewise.
* f-lang.c (f_language_data): Likewise.
* findvar.c (default_read_var_value): Rename to...
(language_defn::read_var_value): ...this.
* findvar.c (read_var_value): Update header comment, and change to
call member function instead of function pointer.
* go-lang.c (go_language_data): Likewise.
* language.c (unknown_language_data): Delete la_read_var_value
initializer.
(auto_language_data): Likewise.
* language.h (struct language_data): Delete la_read_var_value
field.
(language_defn::read_var_value): New member function.
(default_read_var_value): Delete declaration.
* m2-lang.c (m2_language_data): Delete la_read_var_value
initializer.
* objc-lang.c (objc_language_data): Likewise.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_language_data): Likewise.
* rust-lang.c (rust_language_data): Likewise.
* value.h (default_read_var_value): Delete declaration.
This commit converts all languages to sub-classes of a language_defn
base class.
The motivation for this change is to make it easier to add new methods
onto languages without having to update all of the individual language
structures. In the future it might be possible to move more things,
like expression parsing, into the language class(es) for better
encapsulation, however I have no plans to tackle this in the short
term.
This commit sets up a strategy for transitioning from the current
language system, where each language is an instance of the
language_defn structure, to the class hierarchy system.
The plan is to rename the existing language_defn into language_data,
and make this a base class for the new language_defn class, something
like this:
struct language_data
{
... old language_defn fields here ...
};
struct language_defn : public language_data
{
language_defn (const language_data d)
: language_data (d)
{ .... }
};
Then each existing language, for example ada_language_defn can be
converted into an instance of language_data, and passed into the
constructor of a new language class, something like this:
language_data ada_language_data =
{
... old ada_language_defn values here ...
};
struct ada_language : public language_defn
{
ada_language (ada_language_data)
{ .... }
};
What this means is that immediately after the conversion nothing much
changes. Every language is now its own class, but all the old
language fields still exist and can be accessed in the same way.
In later commits I will convert function pointers from the old
language_defn structure into real class methods on language_defn, with
overrides on sub-classes where needed.
At this point I imagine that those fields of the old language_defn
structure that contained only data will probably remain as data fields
within the new language_data base structure, it is only the methods
that I plan to change initially.
I tweaked how we manage the list of languages a bit, each language is
now registered as it is created, and this resulted in a small number
of changes in language.c.
Most of the changes in the *-lang.c files are identical.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* gdb/ada-lang.c (ada_language_defn): Convert to...
(ada_language_data): ...this.
(class ada_language): New class.
(ada_language_defn): New static global.
* gdb/c-lang.c (c_language_defn): Convert to...
(c_language_data): ...this.
(class c_language): New class.
(c_language_defn): New static global.
(cplus_language_defn): Convert to...
(cplus_language_data): ...this.
(class cplus_language): New class.
(cplus_language_defn): New static global.
(asm_language_defn): Convert to...
(asm_language_data): ...this.
(class asm_language): New class.
(asm_language_defn): New static global.
(minimal_language_defn): Convert to...
(minimal_language_data): ...this.
(class minimal_language): New class.
(minimal_language_defn): New static global.
* gdb/d-lang.c (d_language_defn): Convert to...
(d_language_data): ...this.
(class d_language): New class.
(d_language_defn): New static global.
* gdb/f-lang.c (f_language_defn): Convert to...
(f_language_data): ...this.
(class f_language): New class.
(f_language_defn): New static global.
* gdb/go-lang.c (go_language_defn): Convert to...
(go_language_data): ...this.
(class go_language): New class.
(go_language_defn): New static global.
* gdb/language.c (unknown_language_defn): Remove declaration.
(current_language): Initialize to nullptr, real initialization is
moved to _initialize_language.
(languages): Delete global.
(language_defn::languages): Define.
(set_language_command): Use language_defn::languages.
(set_language): Likewise.
(range_error): Likewise.
(language_enum): Likewise.
(language_def): Likewise.
(add_set_language_command): Use language_def::languages for the
language list, and language_def to lookup language pointers.
(skip_language_trampoline): Use language_defn::languages.
(unknown_language_defn): Convert to...
(unknown_language_data): ...this.
(class unknown_language): New class.
(unknown_language_defn): New static global.
(auto_language_defn): Convert to...
(auto_language_data): ...this.
(class auto_language): New class.
(auto_language_defn): New static global.
(language_gdbarch_post_init): Use language_defn::languages.
(_initialize_language): Initialize current_language.
* gdb/language.h (struct language_defn): Rename to...
(struct language_data): ...this.
(struct language_defn): New.
(auto_language_defn): Delete.
(unknown_language_defn): Delete.
(minimal_language_defn): Delete.
(ada_language_defn): Delete.
(asm_language_defn): Delete.
(c_language_defn): Delete.
(cplus_language_defn): Delete.
(d_language_defn): Delete.
(f_language_defn): Delete.
(go_language_defn): Delete.
(m2_language_defn): Delete.
(objc_language_defn): Delete.
(opencl_language_defn): Delete.
(pascal_language_defn): Delete.
(rust_language_defn): Delete.
* gdb/m2-lang.c (m2_language_defn): Convert to...
(m2_language_data): ...this.
(class m2_language): New class.
(m2_language_defn): New static global.
* gdb/objc-lang.c (objc_language_defn): Convert to...
(objc_language_data): ...this.
(class objc_language): New class.
(objc_language_defn): New static global.
* gdb/opencl-lang.c (opencl_language_defn): Convert to...
(opencl_language_data): ...this.
(class opencl_language): New class.
(opencl_language_defn): New static global.
* gdb/p-lang.c (pascal_language_defn): Convert to...
(pascal_language_data): ...this.
(class pascal_language): New class.
(pascal_language_defn): New static global.
* gdb/rust-exp.y (rust_lex_tests): Use language_def to find
language pointer, update comment format.
* gdb/rust-lang.c (rust_language_defn): Convert to...
(rust_language_data): ...this.
(class rust_language): New class.
(rust_language_defn): New static global.
Consider a gdb_load patch to call the gdb_file_cmd twice:
...
proc gdb_load { arg } {
if { $arg != "" } {
+ set res [gdb_file_cmd $arg]
+ if { $res != 0 } {
+ return $res
+ }
return [gdb_file_cmd $arg]
}
return 0
}
...
With this patch, I run into:
...
(gdb) kill^M
The program is not being run.^M
(gdb) ^M</outputs/gdb.dwarf2/multidictionary/multidictionary^M
<.dwarf2/multidictionary/multidictionary"? (y or n)
ERROR: Couldn't load outputs/gdb.dwarf2/multidictionary/multidictionary \
into gdb (timeout).
p 1^M
Please answer y or n.^M
<.dwarf2/multidictionary/multidictionary"? (y or n) n^M
Not confirmed.^M
(gdb) UNRESOLVED: gdb.dwarf2/multidictionary.exp: GDB is alive \
(got interactive prompt)
...
The problem is that the second file command results in a prompt, which is
normally handled by gdb_file_cmd, but not recognized because the initial part
of the prompt is scrolled out.
This in turn is caused by using gdb_spawn_with_cmdline_opts without a
subsequent "set width 0".
Fix this by avoiding gdb_spawn_with_cmdline_opts, and forcing -readline by
temporarily modifying GDBFLAGS instead.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2020-06-02 Tom de Vries <tdevries@suse.de>
* gdb.dwarf2/multidictionary.exp: Don't use
gdb_spawn_with_cmdline_opts.
There are a number of targets that don't support thin archives (*),
and vms doesn't even support file name extensions other than .obj for
archives containing object files. This patch adjusts the testsuite
to cater for the vms restriction, and reenables testing for non-ELF
alpha targets. That adds a few alpha-dec-vms fails and one
alpha-linuxecoff fail but testsuite fails on those targets are nothing
new.
(*) It might seem like they do if binutils is built with
--enable-plugins but the plugin archive support is broken, causing the
wrong type of archives to be created by ar for those targets.
* testsuite/binutils-all/ar.exp (obj): Set up object file name
extension. Use throughout. Don't completely exclude non-ELF
alpha targets. Run long_filenames test for tic30. Exclude thin
archive tests for aix, ecoff and vms.
* estsuite/binutils-all/objdump.exp (obj): Set up object file name
extension. Use throughout. Don't exclude non-ELF alpha targets
from "bintest.a".
This patch fixes internal errors in (at least) arm and aarch64 GAS
when assembling code that attempts a negative .org. The bug appears
to be a regression introduced in binutils-2.29 by commit 9875b36538.
* write.c (relax_segment): Fix handling of negative offset when
relaxing an rs_org frag.
* testsuite/gas/aarch64/org-neg.d: New test.
* testsuite/gas/aarch64/org-neg.l: Error output for test.
* testsuite/gas/aarch64/org-neg.s: Input for test.
* testsuite/gas/arm/org-neg.d: New test.
* testsuite/gas/arm/org-neg.l: Error output for test.
* testsuite/gas/arm/org-neg.s: Input for test.
Better validity checks, and remove a fuzzer vulnerability of sorts that
targeted the store-immediate-repeat command with a zero length but
very large repeat counts to chew cpu.
* vms-alpha.c (_bfd_vms_slurp_etir): Check bound for the current
command against cmd_length, not the end of record. For
ETIR__C_STO_IMMR check size against cmd_length, mask repeat count
to 32-bits and break out on zero size. Add ETIR__C_STC_LP_PSB
cmd_length test.
After the is-stmt support commit:
commit 8c95582da8
Date: Mon Dec 30 21:04:51 2019 +0000
gdb: Add support for tracking the DWARF line table is-stmt field
A regression was observed where a breakpoint could no longer be placed
in some cases.
Consider a line table like this:
File 1: test.c
File 2: test.h
| Addr | File | Line | Stmt |
|------|------|------|------|
| 1 | 1 | 16 | Y |
| 2 | 1 | 17 | Y |
| 3 | 2 | 21 | Y |
| 4 | 2 | 22 | Y |
| 4 | 1 | 18 | N |
| 5 | 2 | 23 | N |
| 6 | 1 | 24 | Y |
| 7 | 1 | END | Y |
|------|------|------|------|
Before the is-stmt patch GDB would ignore any non-stmt lines, so GDB
built two line table structures:
File 1 File 2
------ ------
| Addr | Line | | Addr | Line |
|------|------| |------|------|
| 1 | 16 | | 3 | 21 |
| 2 | 17 | | 4 | 22 |
| 3 | END | | 6 | END |
| 6 | 24 | |------|------|
| 7 | END |
|------|------|
After the is-stmt patch GDB now records non-stmt lines, so the
generated line table structures look like this:
File 1 File 2
------ ------
| Addr | Line | Stmt | | Addr | Line | Stmt |
|------|------|------| |------|------|------|
| 1 | 16 | Y | | 3 | 21 | Y |
| 2 | 17 | Y | | 4 | 22 | Y |
| 3 | END | Y | | 4 | END | Y |
| 4 | 18 | N | | 5 | 23 | N |
| 5 | END | Y | | 6 | END | Y |
| 6 | 24 | Y | |------|------|------|
| 7 | END | Y |
|------|------|------|
The problem is that in 'File 2', end END marker at address 4 causes
the previous line table entry to be discarded, so we actually end up
with this:
File 2
------
| Addr | Line | Stmt |
|------|------|------|
| 3 | 21 | Y |
| 4 | END | Y |
| 5 | 23 | N |
| 6 | END | Y |
|------|------|------|
When a user tries to place a breakpoint in file 2 at line 22, this is
no longer possible.
The solution I propose here is that we ignore line table entries that
would trigger a change of file if:
1. The new line being added is at the same address as the previous
line, and
2. We have previously seen an is-stmt line at the current address.
The result of this is that GDB switches file, and knows that some line
entry (or entries) are going to be discarded, prefer to keep is-stmt
lines and discard non-stmt lines.
After this commit the lines tables are now:
File 1 File 2
------ ------
| Addr | Line | Stmt | | Addr | Line | Stmt |
|------|------|------| |------|------|------|
| 1 | 16 | Y | | 3 | 21 | Y |
| 2 | 17 | Y | | 4 | 22 | Y |
| 3 | END | Y | | 5 | 23 | N |
| 5 | END | Y | | 6 | END | Y |
| 6 | 24 | Y | |------|------|------|
| 7 | END | Y |
|------|------|------|
We've lost the non-stmt entry for file 1, line 18, but retained the
is-stmt entry for file 2, line 22. The user can now place a
breakpoint at that location.
One problem that came from this commit was the test
gdb.cp/step-and-next-inline.exp, which broke in several places. After
looking at this test again I think that in some cases this test was
only ever passing by pure luck. The debug GCC is producing for this
test is pretty broken. I raised this GCC bug:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94474
for this and disabled one entire half of the test. There are still
some cases in here that do pass, and if/when GCC is fixed it would be
great to enable this test again.
gdb/ChangeLog:
* dwarf2/read.c (class lnp_state_machine) <m_last_address>: New
member variable.
<m_stmt_at_address>: New member variable.
(lnp_state_machine::record_line): Don't record some lines, update
tracking of is_stmt at the same address.
(lnp_state_machine::lnp_state_machine): Initialise new member
variables.
gdb/testsuite/ChangeLog:
* gdb.cp/step-and-next-inline.exp (do_test): Skip all tests in the
use_header case.
* gdb.dwarf2/dw2-inline-header-1.exp: New file.
* gdb.dwarf2/dw2-inline-header-2.exp: New file.
* gdb.dwarf2/dw2-inline-header-3.exp: New file.
* gdb.dwarf2/dw2-inline-header-lbls.c: New file.
* gdb.dwarf2/dw2-inline-header.c: New file.
* gdb.dwarf2/dw2-inline-header.h: New file.
We are using -Werror=missing-declarations, and the _S.h files generated
by mig do not currently include a declaration for the server routine.
gnu-nat.c used to have its own external declarations, but better just
share them between gnu-nat.c and the _S.c files.
Fixes
exc_request_S.c:177:24: error: no previous declaration for ‘exc_server’ [-Werror=missing-declarations]
177 | mig_external boolean_t exc_server
gdb/ChangeLog:
* config/i386/i386gnu.mn [%_S.o %_U.o] (COMPILE.post): Add
"-include gnu-nat-mig.h".
* gnu-nat-mig.h: New file.
* gnu-nat.c: Include "gnu-nat-mig.h".
(exc_server, msg_reply_server, notify_server,
process_reply_server): Remove declarations.
This allows to have the process_stratum_target object at hand for future use in
the gdb API, and only use gnu_target from external calls.
gdb/Changelog:
* gnu-nat.h (inf_validate_procs, inf_suspend, inf_set_traced,
steal_exc_port, proc_get_state, inf_clear_wait, inf_cleanup,
inf_startup, inf_update_suspends, inf_set_pid, inf_steal_exc_ports,
inf_validate_procinfo, inf_validate_task_sc, inf_restore_exc_ports,
inf_set_threads_resume_sc, inf_set_threads_resume_sc_for_signal_thread,
inf_resume, inf_set_step_thread, inf_detach, inf_attach, inf_signal,
inf_continue, make_proc, proc_abort, _proc_free, proc_update_sc,
proc_get_exception_port, proc_set_exception_port, _proc_get_exc_port,
proc_steal_exc_port, proc_restore_exc_port, proc_trace): Move functions
to gnu_nat_target class.
* gnu-nat.c: Likewise.
(inf_update_procs, S_proc_wait_reply, set_task_pause_cmd,
set_task_exc_port_cmd, set_signals_cmd, set_thread_pause_cmd,
set_thread_exc_port_cmd): Call inf_validate_procs through gnu_target
object.
(gnu_nat_target::create_inferior, gnu_nat_target::detach): Pass `this'
instead of `gnu_target'.
This allows to get full backtrace from signal handlers, otherwise the
backtrace stops at the trampoline that calls the handler.
This needs special knowledge how the trampoline records register context
for the sigreturn call after signal handling.
gdb/ChangeLog:
* i386-gnu-tdep.c: Include "gdbcore.h"
(gnu_sigtramp_code, i386_gnu_sc_reg_offset): New arrays.
(GNU_SIGTRAMP_LEN, GNU_SIGTRAMP_TAIL,
I386_GNU_SIGCONTEXT_THREAD_STATE_OFFSET): New macros
(i386_gnu_sigtramp_start, i386_gnu_sigtramp_p,
i386_gnu_sigcontext_addr): New functions
(i386gnu_init_abi): Register i386_gnu_sigtramp_p,
i386_gnu_sigcontext_addr, and i386_gnu_sc_reg_offset in the gdbarch
tdep.
This fixes creating inferiors, which was broken since 5b6d1e4fa
('Multi-target support')
gdb/ChangeLog:
* gnu-nat.c (gnu_nat_target::create_inferior): Move push_target call
before fork_inferior call. Avoid calling it if target_is_pushed returns
true.