register_changed_p actually returns bool, but return type is still int.
This patch changes the return type to bool. The caller of
register_changed_p also checked whether the return value can be negative,
which is not needed now. Such check was added in fb40c2090 in 2000,
at that moment, register_changed_p returns -1 when
read_relative_register_raw_bytes fails. I can tell from its name that
it reads register contents, but we don't have this function called inside
register_changed_p, and the regcache is read-only.
gdb:
2017-11-24 Yao Qi <yao.qi@linaro.org>
* mi/mi-main.c (mi_cmd_data_list_changed_registers): Remove
local 'changed'. Remove error.
(register_changed_p): Change return type to bool.
This patch changes tic6x target descriptions to be more flexible. Rebuild
tic6x-uclinux GDBserver with my x86 g++, and the unit test passes.
gdb:
2017-11-24 Yao Qi <yao.qi@linaro.org>
* arch/tic6x.c: New file.
* arch/tic6x.h: New file.
* features/Makefile (FEATURE_XMLFILES): Add tic6x-c6xp.xml,
tic6x-core.xml and tic6x-gp.xml.
* features/tic6x-c6xp.c: Generated.
* features/tic6x-core.c: Generated.
* features/tic6x-gp.c: Generated.
* target-descriptions.c (maint_print_c_tdesc_cmd): Match
"tic6x-".
gdb/gdbserver:
2017-11-24 Yao Qi <yao.qi@linaro.org>
* configure.srv: Set $srv_regobj for tic6x-linux.
* linux-tic6x-low.c: Include "arch/tic6x.h" and "tdesc.h".
(tic6x_read_description): Move some code to tic6x_arch_setup.
(tic6x_tdesc_test): New function.
(initialize_low_arch): Call selftests::register_test.
For one the register type used for masking should be validated. And then
we shouldn't accept input producing encodings which will #UD when
executed, as is the case when EVEX.Z is set while EVEX.AAA is zero.
Commit
C++ify osdata
479f8de1b3
introduced a memory leak. We allocate std::vectors and insert them in a
map, but never free them. Instead, the map value type can be
std::vector objects directly.
gdb/ChangeLog:
* mi/mi-main.c (list_available_thread_groups): Change map value
type to std::vector.
While working on the previous patch, I renamed variables whose type I
changed to let the compiler help me find their usages, but I forgot to
rename one back to its original name. This patch fixes it.
gdb/ChangeLog:
* varobj.c (struct varobj_dynamic) <children_requested_>: Rename
back to...
<children_requested>: ... this.
(varobj_get_num_children, varobj_update): Adjust.
clang accepts option -g3 too. I checked the manual of xlc and icc, looks
they don't accept -g3 option, so I don't pass -g3 for them.
gdb/testsuite:
2017-11-23 Yao Qi <yao.qi@linaro.org>
* gdb.base/macscp.exp: Append -g3 to additional_flags for clang.
I did this for powerpc64 a while ago. Not moving weak symbol
dyn_relocs to the strong alias makes for a much simpler test for
dynamic relocs in relocate_section.
This patch implements the change for powerpc and hppa. Other targets
could benefit from similar changes.
* elf32-hppa.c (pc_dynrelocs): Define.
(elf32_hppa_copy_indirect_symbol): Don't copy dyn_relocs to weakdefs.
(alias_readonly_dynrelocs): New function.
(elf32_hppa_adjust_dynamic_symbol): Don't clear non_got_ref to
indicate dyn_relocs should be discarded, discard them here.
Use alias_readonly_dynrelocs.
(allocate_dynrelocs): Don't test or clear non_got_ref.
(elf32_hppa_relocate_section): Simplify test for dynamic relocs.
* elf32-ppc.c (ppc_elf_copy_indirect_symbol): Don't copy dyn_relocs
to weakdefs.
(alias_readonly_dynrelocs, pc_dynrelocs): New functions.
(ppc_elf_adjust_dynamic_symbol): Don't clear non_got_ref to
indicate dyn_relocs should be discarded, discard them here.
Use alias_readonly_dynrelocs.
(allocate_dynrelocs): Don't test or clear non_got_ref.
(ppc_elf_relocate_section): Simplify test for dynamic relocs.
Now that u.alias is circular, weakref just duplicates its function.
Also, function symbols shouldn't be on the alias list so there is no
need to use alias_readonly_dynrelocs with them.
* elf64-ppc.c (struct ppc_link_hash_entry): Delete weakref field.
(ppc64_elf_copy_indirect_symbol): Don't set weakref.
(alias_readonly_dynrelocs): Use u.alias rather than weakref.
(ppc64_elf_adjust_dynamic_symbol): Don't use
alias_readonly_dynrelocs for function symbols.
This makes the elf_link_hash_entry weakdef field, currently used to
point from a weak symbol to a strong alias, a circular list so that
all aliases can be found from any of them. A new flag, is_weakalias,
distinguishes the weak symbol from a strong alias, and is used in all
places where we currently test u.weakdef != NULL.
With the original u.weakdef handling it was possible to have two or
more weak symbols pointing via u.weakdef to a strong definition.
Obviously that situation can't map to a circular list; One or more of
the weak symbols must point at another weak alias rather than the
strong definition. To handle that, I've added an accessor function to
return the strong definition.
* elf-bfd.h (struct elf_link_hash_entry): Add is_weakalias.
Rename u.weakdef to u.alias and update comment.
(weakdef): New static inline function.
* elflink.c (bfd_elf_record_link_assignment) Test is_weakalias
rather than u.weakdef != NULL, and use weakdef function.
(_bfd_elf_adjust_dynamic_symbol): Likewise.
(_bfd_elf_fix_symbol_flags): Likewise. Clear is_weakalias on
all aliases if def has been overridden in a regular object, not
u.weakdef.
(elf_link_add_object_symbols): Delete new_weakdef flag. Test
is_weakalias and use weakdef. Set is_weakalias and circular
u.alias. Update comments.
(_bfd_elf_gc_mark_rsec): Test is_weakalias rather than
u.weakdef != NULL and use weakdef function.
* elf-m10300.c (_bfd_mn10300_elf_adjust_dynamic_symbol): Test
is_weakalias rather than u.weakdef != NULL and use weakdef
function. Assert that def is strong defined.
* elf32-arc.c (elf_arc_adjust_dynamic_symbol): Likewise.
* elf32-arm.c (elf32_arm_adjust_dynamic_symbol): Likewise.
* elf32-bfin.c (elf32_bfinfdpic_adjust_dynamic_symbol): Likewise.
(bfin_adjust_dynamic_symbol): Likewise.
* elf32-cr16.c (_bfd_cr16_elf_adjust_dynamic_symbol): Likewise.
* elf32-cris.c (elf_cris_adjust_dynamic_symbol): Likewise.
* elf32-frv.c (elf32_frvfdpic_adjust_dynamic_symbol): Likewise.
* elf32-hppa.c (elf32_hppa_adjust_dynamic_symbol): Likewise.
* elf32-i370.c (i370_elf_adjust_dynamic_symbol): Likewise.
* elf32-lm32.c (lm32_elf_adjust_dynamic_symbol): Likewise.
* elf32-m32r.c (m32r_elf_adjust_dynamic_symbol): Likewise.
* elf32-m68k.c (elf_m68k_adjust_dynamic_symbol): Likewise.
* elf32-metag.c (elf_metag_adjust_dynamic_symbol): Likewise.
* elf32-microblaze.c (microblaze_elf_adjust_dynamic_symbol): Likewise.
* elf32-nds32.c (nds32_elf_adjust_dynamic_symbol): Likewise.
* elf32-nios2.c (nios2_elf32_adjust_dynamic_symbol): Likewise.
* elf32-or1k.c (or1k_elf_adjust_dynamic_symbol): Likewise.
* elf32-ppc.c (ppc_elf_adjust_dynamic_symbol): Likewise.
* elf32-s390.c (elf_s390_adjust_dynamic_symbol): Likewise.
* elf32-score.c (s3_bfd_score_elf_adjust_dynamic_symbol): Likewise.
* elf32-score7.c (s7_bfd_score_elf_adjust_dynamic_symbol): Likewise.
* elf32-sh.c (sh_elf_adjust_dynamic_symbol): Likewise.
* elf32-tic6x.c (elf32_tic6x_adjust_dynamic_symbol): Likewise.
* elf32-tilepro.c (tilepro_elf_gc_mark_hook): Likewise.
(tilepro_elf_adjust_dynamic_symbol): Likewise.
* elf32-vax.c (elf_vax_adjust_dynamic_symbol): Likewise.
* elf32-xtensa.c (elf_xtensa_adjust_dynamic_symbol): Likewise.
* elf64-alpha.c (elf64_alpha_adjust_dynamic_symbol): Likewise.
* elf64-hppa.c (elf64_hppa_adjust_dynamic_symbol): Likewise.
* elf64-ia64-vms.c (elf64_ia64_adjust_dynamic_symbol): Likewise.
* elf64-ppc.c (ppc64_elf_gc_mark_hook): Likewise.
(ppc64_elf_adjust_dynamic_symbol): Likewise.
* elf64-s390.c (elf_s390_adjust_dynamic_symbol): Likewise.
* elf64-sh64.c (sh64_elf64_adjust_dynamic_symbol): Likewise.
* elfnn-aarch64.c (elfNN_aarch64_adjust_dynamic_symbol): Likewise.
* elfnn-ia64.c (elfNN_ia64_adjust_dynamic_symbol): Likewise.
* elfnn-riscv.c (riscv_elf_adjust_dynamic_symbol): Likewise.
* elfxx-mips.c (_bfd_mips_elf_adjust_dynamic_symbol): Likewise.
* elfxx-sparc.c (_bfd_sparc_elf_gc_mark_hook): Likewise.
(_bfd_sparc_elf_adjust_dynamic_symbol): Likewise.
* elfxx-tilegx.c (tilegx_elf_gc_mark_hook): Likewise.
(tilegx_elf_adjust_dynamic_symbol): Likewise.
* elfxx-x86.c (_bfd_x86_elf_adjust_dynamic_symbol): Likewise.
In the latest git version of mingw-w64, one can set the default
libmsvcrt.a to actually be the import library of another CRT version,
to facilitate switching to ucrtbase.dll. In these versions, the
traditional libmsvcrt.a (for linking to msvcrt.dll) is also provided
with the name libmsvcrt-os.a.
The import libraries for the CRT also contain a number of compatibility
wrapper functions. The ones in libmsvcrt.a have so far been excluded
automatically since they in most cases come with a corresponding
__imp_foo function. None of these make sense to export automatically
from a DLL though, so add these libraries to the exclude list.
libucrtbase.a contains a number of compatibility wrapper functions
that don't have a corresponding __imp_foo symbol, which cause
these symbols to be exported from DLLs.
This can be worked around on the mingw-w64 side by adding extra
__imp_ symbols, but since they aren't strictly necessary for linking
to succeed, it's probably better long-term to add these libraries to
the exclusion list.
ld * pe-dll.c (autofilter_liblist): Add libmsvcrt, libmsvcrt-os and
libucrtbase.
Despite EVEX encodings not being available in real and VM86 modes,
16-bit addressing still needs to be handled properly for 16-bit
protected mode as well as 16-bit addressing in 32-bit mode. Neither
should displacements be dropped silently by the assembler, nor should
the disassembler fail to correctly scale 8-bit displacements.
Except for %eip-relative addressing, where we don't have a suitable
relocation type silently wrapping at the 4G boundary, consistently
force use of R_X86_64_32 (in ELF terms) instead of its sign-extending
counterpart. This wasn't right in case there was no base register in
the addressing expression.
Make the assembler recognize UD0, supporting only the newer form
expecting a ModR/M byte.
Make assembler and disassembler properly emit / expect a ModR/M byte for
UD1.
For the testsuite, as arch-4 already tests all UDn, avoid producing a
huge delta for other tests using UD2B by making them use UD2 instead.
Multiple errors are more confusing than helpful, as the more generic
one often implies a sufficiently different adjustment than would
actually be needed to fix the code. Additionally it makes it more
cumbersome to add missing error checks, as the testsuite then needs
extra updating.
This patch converts the DTrace probe
interface (gdb/dtrace-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct dtrace_probe' to 'class
dtrace_probe', and a new 'class dtrace_static_probe_ops' to replace the
use of 'dtrace_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the dtrace-probe interface.
There are several helper functions used to parse parts of a dtrace
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I wasn't able to test these modifications because the current test
framework for DTrace probes is not working. See
<https://sourceware.org/bugzilla/show_bug.cgi?id=22420>.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
* dtrace-probe.c (struct probe_ops dtrace_probe_ops): Delete.
(struct dtrace_probe_arg) <dtrace_probe_arg>: New constructor.
<type_str>: Convert to 'std::string'.
<expr>: Convert to 'expression_up'.
(dtrace_probe_arg_s): Delete type and VEC.
(dtrace_probe_enabler_s): Likewise.
(struct dtrace_probe): Replace by...
(class dtrace_static_probe_ops): ...this and...
(class dtrace_probe): ...this.
(dtrace_probe_is_linespec): Rename to...
(dtrace_static_probe_ops::is_linespec): ...this. Adjust code
to reflect change.
(dtrace_process_dof_probe): Use 'std::vector' instead of VEC.
Adjust code. Create new instance of 'dtrace_probe'.
(dtrace_build_arg_exprs): Rename to...
(dtrace_probe::build_arg_exprs): ...this. Adjust code to
reflect change.
(dtrace_get_probes): Rename to...
(dtrace_static_probe_ops::get_probes): ...this. Adjust code
to reflect change.
(dtrace_get_arg): Rename to...
(dtrace_probe::get_arg_by_number): ...this. Adjust code to
reflect change.
(dtrace_probe_is_enabled): Rename to...
(dtrace_probe::is_enabled): ...this. Adjust code to reflect
change.
(dtrace_get_probe_address): Rename to...
(dtrace_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(dtrace_get_probe_argument_count): Rename to...
(dtrace_probe::get_argument_count): ...this. Adjust code to
reflect change.
(dtrace_can_evaluate_probe_arguments): Rename to...
(dtrace_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(dtrace_evaluate_probe_argument): Rename to...
(dtrace_probe::evaluate_argument): ...this. Adjust code to
reflect change.
(dtrace_compile_to_ax): Rename to...
(dtrace_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(dtrace_probe_destroy): Delete.
(dtrace_type_name): Rename to...
(dtrace_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(dtrace_probe::get_static_ops): New method.
(dtrace_gen_info_probes_table_header): Rename to...
(dtrace_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(dtrace_gen_info_probes_table_values): Rename to...
(dtrace_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(dtrace_enable_probe): Rename to...
(dtrace_probe::enable_probe): ...this. Adjust code to reflect
change.
(dtrace_disable_probe): Rename to...
(dtrace_probe::disable_probe): ...this. Adjust code to reflect
change.
(struct probe_ops dtrace_probe_ops): Delete.
(info_probes_dtrace_command): Call 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_dtrace_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
This patch converts the generic probe interface (gdb/probe.[ch]) to
C++, and also performs some cleanups that were on my TODO list for a
while.
The main changes were the conversion of 'struct probe' to 'class
probe', and 'struct probe_ops' to 'class static_probe_ops'. The
former now contains all the "dynamic", generic methods that act on a
probe + the generic data related to it; the latter encapsulates a
bunch of "static" methods that relate to the probe type, but not to a
specific probe itself.
I've had to do a few renamings (e.g., on 'struct bound_probe' the
field is called 'probe *prob' now, instead of 'struct probe *probe')
because GCC was complaining about naming the field using the same name
as the class. Nothing major, though. Generally speaking, the logic
behind and the design behind the code are the same.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
* break-catch-throw.c (fetch_probe_arguments): Use
'probe.prob' instead of 'probe.probe'.
* breakpoint.c (create_longjmp_master_breakpoint): Call
'can_evaluate_arguments' and 'get_relocated_address' methods
from probe.
(create_exception_master_breakpoint): Likewise.
(add_location_to_breakpoint): Use 'sal->prob' instead of
'sal->probe'.
(bkpt_probe_insert_location): Call 'set_semaphore' method from
probe.
(bkpt_probe_remove_location): Likewise, for 'clear_semaphore'.
* elfread.c (elf_get_probes): Use 'static_probe_ops' instead
of 'probe_ops'.
(probe_key_free): Call 'delete' on probe.
(check_exception_resume): Use 'probe.prob' instead of
'probe.probe'.
* location.c (string_to_event_location_basic): Call
'probe_linespec_to_static_ops'.
* probe.c (class any_static_probe_ops): New class.
(any_static_probe_ops any_static_probe_ops): New variable.
(parse_probes_in_pspace): Receive 'static_probe_ops' as
argument. Adjust code to reflect change.
(parse_probes): Use 'static_probe_ops' instead of
'probe_ops'. Adjust code to reflect change.
(find_probes_in_objfile): Call methods to get name and
provider from probe.
(find_probe_by_pc): Use 'result.prob' instead of
'result.probe'. Call 'get_relocated_address' method from
probe.
(collect_probes): Adjust comment and argument list to receive
'static_probe_ops' instead of 'probe_ops'. Adjust code to
reflect change. Call necessary methods from probe.
(compare_probes): Call methods to get name and provider from
probes.
(gen_ui_out_table_header_info): Receive 'static_probe_ops'
instead of 'probe_ops'. Use 'std::vector' instead of VEC,
adjust code accordingly.
(print_ui_out_not_applicables): Likewise.
(info_probes_for_ops): Rename to...
(info_probes_for_spops): ...this. Receive 'static_probe_ops'
as argument instead of 'probe_ops'. Adjust code. Call
necessary methods from probe.
(info_probes_command): Use 'info_probes_for_spops'.
(enable_probes_command): Pass correct argument to
'collect_probes'. Call methods from probe.
(disable_probes_command): Likewise.
(get_probe_address): Move to 'any_static_probe_ops::get_address'.
(get_probe_argument_count): Move to
'any_static_probe_ops::get_argument_count'.
(can_evaluate_probe_arguments): Move to
'any_static_probe_ops::can_evaluate_arguments'.
(evaluate_probe_argument): Move to
'any_static_probe_ops::evaluate_argument'.
(probe_safe_evaluate_at_pc): Use 'probe.prob' instead of
'probe.probe'.
(probe_linespec_to_ops): Rename to...
(probe_linespec_to_static_ops): ...this. Adjust code.
(probe_any_is_linespec): Rename to...
(any_static_probe_ops::is_linespec): ...this.
(probe_any_get_probes): Rename to...
(any_static_probe_ops::get_probes): ...this.
(any_static_probe_ops::type_name): New method.
(any_static_probe_ops::gen_info_probes_table_header): New
method.
(compute_probe_arg): Use 'pc_probe.prob' instead of
'pc_probe.probe'. Call methods from probe.
(compile_probe_arg): Likewise.
(std::vector<const probe_ops *> all_probe_ops): Delete.
(std::vector<const static_probe_ops *> all_static_probe_ops):
New variable.
(_initialize_probe): Use 'all_static_probe_ops' instead of
'all_probe_ops'.
* probe.h (struct info_probe_column) <field_name>: Delete
extraneous newline
(info_probe_column_s): Delete type and VEC.
(struct probe_ops): Delete. Replace with...
(class static_probe_ops): ...this and...
(clas probe): ...this.
(struct bound_probe) <bound_probe>: Delete extraneous
newline. Adjust constructor to receive 'probe' instead of
'struct probe'.
<probe>: Rename to...
<prob>: ...this. Delete extraneous newline.
<objfile>: Delete extraneous newline.
(register_probe_ops): Delete unused prototype.
(info_probes_for_ops): Rename to...
(info_probes_for_spops): ...this. Adjust comment.
(get_probe_address): Move to 'probe::get_address'.
(get_probe_argument_count): Move to
'probe::get_argument_count'.
(can_evaluate_probe_arguments): Move to
'probe::can_evaluate_arguments'.
(evaluate_probe_argument): Move to 'probe::evaluate_argument'.
* solib-svr4.c (struct svr4_info): Adjust comment.
(struct probe_and_action) <probe>: Rename to...
<prob>: ...this.
(register_solib_event_probe): Receive 'probe' instead of
'struct probe' as argument. Use 'prob' instead of 'probe'
when applicable.
(solib_event_probe_action): Call 'get_argument_count' method
from probe. Adjust comment.
(svr4_handle_solib_event): Adjust comment. Call
'evaluate_argument' method from probe.
(svr4_create_probe_breakpoints): Call 'get_relocated_address'
from probe.
(svr4_create_solib_event_breakpoints): Use 'probe' instead of
'struct probe'. Call 'can_evaluate_arguments' from probe.
* symfile.h: Forward declare 'class probe' instead of 'struct
probe'.
* symtab.h: Likewise.
(struct symtab_and_line) <probe>: Rename to...
<prob>: ...this.
* tracepoint.c (start_tracing): Use 'prob' when applicable.
Call probe methods.
(stop_tracing): Likewise.
A recent patch introduced a call to warning, and the string used
had a trailing newline, which is not correct; the nightly ARI run
caught it, so this patch removes it.
gdb/ChangeLog:
* ravenscar-thread.c (ravenscar_inferior_created): Remove
trailing newline at end of string in call to warning.
Tested on powerpc-eabispe, no regression.
This patch c++ifies the osdata structure: osdata_column, osdata_item and
osdata. char* are replaced with std::string and VEC are replaced with
std::vector. This allows to get rid of a great deal of cleanup and
free'ing code.
I replaced the splay tree in list_available_thread_groups with an
std::map. Unless there's a good advantage to keep using a splay tree,
I think using the standard type should make things simpler to
understand.
gdb/ChangeLog:
* osdata.h: Include vector isntead of vec.h.
(osdata_column_s): Remove typedef.
(struct osdata_column): Add constructor.
<name, value>: Change type to std::string.
(DEF_VEC_O (osdata_column_s)): Remove.
(osdata_item_s): Remove typedef.
(struct osdata_item) <columns>: Change type to std::vector.
(DEF_VEC_O (osdata_item_s)): Remove.
(struct osdata): Add constructor.
<type>: Change type to std::string.
<items>: Change type to std::vector.
(osdata_p): Remove typedef.
(DEF_VEC_P (osdata_p)): Remove.
(osdata_parse): Return a unique_ptr.
(osdata_free): Remove.
(make_cleanup_osdata_free): Remove.
(get_osdata): Return a unique_ptr.
(get_osdata_column): Return pointer to std::string, take a
reference to osdata_item as parameter.
* osdata.c (struct osdata_parsing_data) <osdata>: Change type to
unique_ptr.
<property_name>: Change type to std::string.
(osdata_start_osdata): Allocate osdata with new and adjust.
(osdata_start_item): Adjust.
(osdata_start_column): Adjust.
(osdata_end_column): Adjust.
(clear_parsing_data): Remove.
(osdata_parse): Return a unique_ptr and adjust, remove cleanup.
(osdata_item_clear): Remove.
(get_osdata): return a unique_ptr and adjust.
(get_osdata_column): Return a pointer to std::string and adjust.
(info_osdata): Adjust.
* mi/mi-main.c: Include <map>.
(free_vector_of_osdata_items): Remove.
(list_available_thread_groups): Adjust, use std::map instead of
splay tree.
Currently, optimized out variables are not shown when doing "info
locals". Some users found that confusing, thinking GDB forgot to print
their variable. This patch adds them to the "info locals" output. I
added a test in gdb.dwarf2 to test for that behavior. I think doing a
synthetic DWARF test is the easiest way to have an optimized out local
variable for sure.
However, this change reveals what I think is a bug in GDB, see:
http://lists.dwarfstd.org/pipermail/dwarf-discuss-dwarfstd.org/2017-September/004394.html
This patch marks the tests in inline-locals.exp that start failing as
KFAIL. I'd like to tackle this bug eventually, but I don't have the
time right now. I think it's still better to show an extra erroneous
entry than to not show the optimized out variables at all. I haven't
created a bug in bugzilla yet, but if we agree it's indeed a bug, I'll
create one and update the setup_kfail lines with the actual bug number
before pushing.
gdb/ChangeLog:
* stack.c (iterate_over_block_locals): Add LOC_OPTIMIZED_OUT
case in switch.
gdb/testsuite/ChangeLog:
* gdb.opt/inline-locals.exp: Mark tests as KFAIL.
* gdb.dwarf2/info-locals-optimized-out.exp: New file.
* gdb.dwarf2/info-locals-optimized-out.c: New file.
This patch replaces makes varobj_update return an std::vector, and
updates the fallouts.
To make that easier, the varobj_update_result is c++ified a bit. I
added a constructor and initialized its fields in-class. The newobj
vector is also made an std::vector, so that it's automatically freed
when varobj_update_result is destroyed and handled correctly by the
default move constructor. I disabled copy constructor and assignment
for that structure, because normally it never needs to be copied, only
moved.
As a result, the newobj parameter of update_dynamic_varobj_children must
be changed to an std::vector. The patch converts the other vector
parameters of update_dynamic_varobj_children to std::vector. It's not
strictly necessary to do it in the same patch, but I think it makes
sense to do it.
gdb/ChangeLog:
* varobj.h (struct varobj_update_result): Add constructor, add
move constructor, disable copy and assign, initialize fields.
<newobj>: Change type to std::vector.
(varobj_update): Return std::vector.
* varobj.c (install_dynamic_child): Change VEC parameters to
std::vector and adjust.
(update_dynamic_varobj_children): Likewise.
(varobj_update): Return std::vector and adjust.
* mi/mi-cmd-var.c (varobj_update_one): Adjust to vector changes.
This patch makes the children field of varobj an std::vector, and
updates the fallout.
One note is that varobj::parent must be made non-const. The reason is
that when a child deletes itself, it modifies its writes NULL to its
slot in its parent's children vector. With the VEC, the const didn't
made the parent's children vector content const, only the pointer to it,
but with std::vector, even the content is.
gdb/ChangeLog:
* varobj.h (struct varobj) <parent>: Remove const.
<children>: Change type to std::vector.
(varobj_list_children): Return std::vector const reference.
(varobj_restrict_range): Change parameter type to std::vector
const reference.
* varobj.c (varobj_has_more): Adjust.
(varobj_restrict_range): Change parameter type to std::vector
const reference and adjust.
(install_dynamic_child): Adjust.
(update_dynamic_varobj_children): Adjust.
(varobj_list_children): Return std::vector const reference and
adjust.
(varobj_add_child): Adjust.
(update_type_if_necessary): Adjust.
(varobj_update): Adjust.
(delete_variable_1): Adjust.
* ada-varobj.c (ada_value_has_mutated): Adjust.
* mi/mi-cmd-var.c (mi_cmd_var_list_children): Adjust.
This patch does a basic c++ification or the varobj data structure.
- varobj: add constructor and destructor, initialize fields
- varobj_root: initialize fields
- varobj_dynamic: initialize fields
This allows getting rid of new_variable, new_root_variable.
free_variable essentially becomes varobj's destructor. This also allows
getting rid of a cleanup, make_cleanup_free_variable, which was only
used in varobj_create in case the varobj creation fails. It is replaced
with a unique_ptr.
gdb/ChangeLog:
* varobj.h (struct varobj): Add constructor and destructor,
initialize fields.
* varobj.c (struct varobj_root): Initialize fields.
(struct varobj_dynamic): Initialize fields.
(varobj_create): Use unique_ptr instead of cleanup. Create
varobj with new instead of new_root_variable.
(delete_variable_1): Free variable with delete instead of
free_variable.
(create_child_with_value): Create variable with new instead of
new_variable.
(varobj::varobj): New.
(varobj::~varobj): New (body mostly coming from free_variable).
(new_variable): Remove.
(free_variable): Remove.
(do_free_variable_cleanup): Remove.
(make_cleanup_free_variable): Remove.
* as.c: Include write.h.
(common_emul_init): Use FAKE_LABEL_NAME.
* ecoff.c (add_file, ecoff_directive_end, ecoff_directive_loc):
Likewise.
(ecoff_build_symbols): Use FAKE_LABEL_CHAR.
* expr.c (get_symbol_name): Use FAKE_LABEL_CHAR. Accept only if
input_from_string is TRUE.
* read.c (input_from_string): New.
(read_symbol_name): Use FAKE_LABEL_CHAR. Accept only if
input_from_string is TRUE.
(temp_ilp): Set input_from_string to TRUE.
(restore_ilp): Set input_from_string to FALSE.
* read.h (input_from_string): Declare.
* symbols.c: Include write.h
(S_IS_LOCAL): Check for FAKE_LABEL_CHAR.
(symbol_relc_make_sym): Fix comment refering to default fake label
string.
* write.h (FAKE_LABEL_CHAR): New.
* config/tc-riscv.h (FAKE_LABEL_CHAR): Define.
* testsuite/gas/all/err-fakelabel.s: New.
"pthreads" in the right flag to pass in prepare_for_testing to linker,
instead of additional_flags. Without this patch, the test case can't be
complied by clang.
gdb compile failed, clang: warning: -lpthread: 'linker' input unused
gdb/testsuite:
2017-11-22 Yao Qi <yao.qi@linaro.org>
* gdb.base/info-os.exp: Pass pthreads.
* gdb.multi/multi-attach.exp: Likewise.
gdb.dwarf2/pr10770.exp can be used for non-gcc compiler, at least clang.
This patch removes the restriction to only use gcc. If other compilers,
like xlc or icc, can't compile the .c file, test result is not changed.
gdb/testsuite:
2017-11-22 Yao Qi <yao.qi@linaro.org>
* gdb.dwarf2/pr10770.exp: Remove code skipping non-gcc
compiler.
-pie is a linker flag, it should be passed via "ldflags", instead
of "additional_flags". Otherwise, clang complains,
clang: warning: argument unused during compilation: '-pie'
gdb/testsuite:
2017-11-22 Yao Qi <yao.qi@linaro.org>
* gdb.base/attach-pie-noexec.exp: Pass "-pie" in ldflags.
* gdb.base/break-interp.exp: Likewise.
* gdb.base/jit-attach-pie.exp: Likewise.
Uses of reg_expected_msgs rely on each arm_reg_type enumerator to have a
message entry in the same order as the enumerator declaration. This is
not clearly stated in the definition of both the arm_reg_type enum and
the reg_expected_msgs. Worse, there is nothing to ensure both are kept
in sync.
As an attempt towards this, this patch uses C99 array designators to
ensure that each message is associated with the right arm_reg_type. A
comment is also added near the definition of arm_reg_type to point to
the reg_expected_msgs array. Finally, the array is synced with
arm_reg_type by adding the missing error message for REG_TYPE_RNB.
2017-11-22 Thomas Preud'homme <thomas.preudhomme@arm.com>
gas/
* config/tc-arm.c (arm_reg_type): Comment on the link with
reg_expected_msgs.
(reg_expected_msgs): Initialize using array designators with
arm_reg_type index.
This second patch introduces mfpr_float_ops, an new implementation
of target_float_ops. This implements precise emulation of target
floating-point formats using the MPFR library. This is then used
to perform operations on types that do not match any host type.
Note that use of MPFR is still not required. The patch adds
a configure option --with-mpfr similar to --with-expat. If use of
MPFR is disabled via the option or MPFR is not available, code will
fall back to current behavior. This means that operations on types
that do not match any host type will be implemented on the host
long double type instead.
A new test case verifies that we can correctly print the largest
__float128 value now.
gdb/ChangeLog:
2017-11-22 Ulrich Weigand <uweigand@de.ibm.com>
* NEWS: Document use of GNU MPFR.
* README: Likewise.
* Makefile.in (LIBMPFR): Add define.
(CLIBS): Add $(LIBMPFR).
* configure.ac: Add --with-mpfr configure option.
* configure: Regenerate.
* config.in: Regenerate.
* target-float.c [HAVE_LIBMPFR]: Include <mpfr.h>.
(class mpfr_float_ops): New type.
(mpfr_float_ops::from_target): Two new overloaded functions.
(mpfr_float_ops::to_target): Likewise.
(mpfr_float_ops::to_string): New function.
(mpfr_float_ops::from_string): Likewise.
(mpfr_float_ops::to_longest): Likewise.
(mpfr_float_ops::from_longest): Likewise.
(mpfr_float_ops::from_ulongest): Likewise.
(mpfr_float_ops::to_host_double): Likewise.
(mpfr_float_ops::from_host_double): Likewise.
(mpfr_float_ops::convert): Likewise.
(mpfr_float_ops::binop): Likewise.
(mpfr_float_ops::compare): Likewise.
(get_target_float_ops): Use mpfr_float_ops if available.
gdb/doc/ChangeLog:
2017-11-22 Ulrich Weigand <uweigand@de.ibm.com>
* gdb.texinfo (Requirements): Document use of GNU MPFR.
gdb/testsuite/ChangeLog:
2017-11-22 Ulrich Weigand <uweigand@de.ibm.com>
* gdb.base/float128.c (large128): New variable.
* gdb.base/float128.exp: Add test to print largest __float128 value.
Prepare for using MPFR to implement floating-point arithmetic by
refactoring the way host floating-point arithmetic is currently used.
In particular, fix the following two problems that cause different
(and incorrect) results due to using host arithmetic:
- Current processing always uses host "long double", and then converts
back to the actual target format. This may introduce rounding errors.
- Conversion of FP values to LONGEST simply does a host C++ type cast.
However the result of such a cast is undefined if the source value
is outside the representable range. MPFR always has defined behavior
here (returns the minimum or maximum representable value).
To fix the first issue, I've now created not just one set of routines
using host FP arithmetic (on long double), but instead three different
sets of routines, one each for host float, double, and long double.
Operations can then be performed in the desired type directly, avoiding
the extra rounding step. Using C++ templates, the three sets can all
share the same source code without duplication.
To fix the second issue, I'm simply enforcing the same conversion rule
(which makes sense anyway) when converting out-of-range values from
FP to LONGEST.
To contain the code complexity with the variety of options now possible,
I've created a new class "target_float_ops". There are a total of five
separate implementations of this:
host_float_ops<float> Implemented via host FP in given type
host_float_ops<double>
host_float_ops<long double>
mpfr_float_ops Implemented via MPFR if available
decimal_float_ops Implemented via libdecnumber
Note instead of using the DOUBLEST define, this always just uses the
"long double" data type. But since we now require C++11 anyway, this
type must in any case be avaialble unconditionally.
Most target floating-point operations simply dispatch to a (virtual)
member routine of this class. Which implementation to choose is
determined from the target types involved, and whether they match
some host type or not. E.g. any operation on a single type that
matches a host type is performed in that type. Operations involving
two types that both match host types are performed in the larger one
(according to C/C++ implicit conversion rules). Operations that
involve any type that does not match a host type are performed using
MPFR. (And of course operations involving decimal FP are performed
using libdecnumber.)
This first patch implements the refactoring of target-float.c as
described above, introduing the host_float_ops and decimal_float_ops
classes, and using them. Use of MPFR is introduced in the second patch.
A bit of special-case handling code is moved around to as to avoid
code duplication between host_float_ops and mpfr_float_ops.
Note that due to the changes mentioned above, I've had to update (fix)
the floating-point register values tested in the gdb.arch/vsx-regs.exp
test case. (The new values now work both with host arithmetic and MPFR.)
gdb/ChangeLog:
2017-11-22 Ulrich Weigand <uweigand@de.ibm.com>
* target-float.c: Do not include <math.h>.
Include <cmath> and <limits>.
(DOUBLEST): Do not define.
(class target_float_ops): New type.
(class host_float_ops): New templated type.
(class decimal_float_ops): New type.
(floatformat_to_doublest): Rename to ...
(host_float_ops<T>::from_target): ... this. Use template type T
instead of DOUBLEST. Use C++ math routines. Update recursive calls.
(host_float_ops<T>::from_target): New overload using a type argument.
(floatformat_from_doublest): Rename to ...
(host_float_ops<T>::to_target): ... this. Use template type T
instead of DOUBLEST. Use C++ math routines. Update recursive calls.
(host_float_ops<T>::to_target): New overload using a type argument.
(floatformat_printf_format): New function.
(struct printf_length_modifier): New templated type.
(floatformat_to_string): Rename to ...
(host_float_ops<T>::to_string): ... this. Use type instead of
floatformat argument. Use floatformat_printf_format and
printf_length_modifier. Remove special handling of invalid numbers,
infinities and NaN (moved to target_float_to_string).
(struct scanf_length_modifier): New templated type.
(floatformat_from_string): Rename to ...
(host_float_ops<T>::from_string): ... this. Use type instead of
floatformat argument. Use scanf_length_modifier.
(floatformat_to_longest): Rename to ...
(host_float_ops<T>::to_longest): ... this. Use type instead of
floatformat argument. Handle out-of-range values deterministically.
(floatformat_from_longest): Rename to ...
(host_float_ops<T>::from_longest): ... this. Use type instead of
floatformat argument.
(floatformat_from_ulongest): Rename to ...
(host_float_ops<T>::from_ulongest): ... this. Use type instead of
floatformat argument.
(floatformat_to_host_double): Rename to ...
(host_float_ops<T>::to_host_double): ... this. Use type instead of
floatformat argument.
(floatformat_from_host_double): Rename to ...
(host_float_ops<T>::from_host_double): ... this. Use type instead of
floatformat argument.
(floatformat_convert): Rename to ...
(host_float_ops<T>::convert): ... this. Use type instead of
floatformat arguments. Remove handling of no-op conversions.
(floatformat_binop): Rename to ...
(host_float_ops<T>::binop): ... this. Use type instead of
floatformat arguments.
(floatformat_compare): Rename to ...
(host_float_ops<T>::compare): ... this. Use type instead of
floatformat arguments.
(match_endianness): Use type instead of length/byte_order arguments.
(set_decnumber_context): Likewise.
(decimal_from_number): Likewise. Update calls.
(decimal_to_number): Likewise.
(decimal_is_zero): Likewise. Update calls. Move to earlier in file.
(decimal_float_ops::to_host_double): New dummy function.
(decimal_float_ops::from_host_double): Likewise.
(decimal_to_string): Rename to ...
(decimal_float_ops::to_string): ... this. Use type instead of
length/byte_order arguments. Update calls.
(decimal_from_string): Rename to ...
(decimal_float_ops::from_string): ... this. Use type instead of
length/byte_order arguments. Update calls.
(decimal_from_longest): Rename to ...
(decimal_float_ops::from_longest): ... this. Use type instead of
length/byte_order arguments. Update calls.
(decimal_from_ulongest): Rename to ...
(decimal_float_ops::from_ulongest): ... this. Use type instead of
length/byte_order arguments. Update calls.
(decimal_to_longest): Rename to ...
(decimal_float_ops::to_longest): ... this. Use type instead of
length/byte_order arguments. Update calls.
(decimal_binop): Rename to ...
(decimal_float_ops::binop): ... this. Use type instead of
length/byte_order arguments. Update calls.
(decimal_compare): Rename to ...
(decimal_float_ops::compare): ... this. Use type instead of
length/byte_order arguments. Update calls.
(decimal_convert): Rename to ...
(decimal_float_ops::convert): ... this. Use type instead of
length/byte_order arguments. Update calls.
(target_float_same_category_p): New function.
(target_float_same_format_p): Likewise.
(target_float_format_length): Likewise.
(enum target_float_ops_kind): New type.
(get_target_float_ops_kind): New function.
(get_target_float_ops): Three new overloaded functions.
(target_float_is_zero): Update call.
(target_float_to_string): Add special handling of invalid numbers,
infinities and NaN (moved from floatformat_to_string). Use
target_float_ops callback.
(target_float_from_string): Use target_float_ops callback.
(target_float_to_longest): Likewise.
(target_float_from_longest): Likewise.
(target_float_from_ulongest): Likewise.
(target_float_to_host_double): Likewise.
(target_float_from_host_double): Likewise.
(target_float_convert): Add special case for no-op conversions.
Use target_float_ops callback.
(target_float_binop): Use target_float_ops callback.
(target_float_compare): Likewise.
gdb/testsuite/ChangeLog:
2017-11-22 Ulrich Weigand <uweigand@de.ibm.com>
* gdb.arch/vsx-regs.exp: Update register content checks.