Commit Graph

92319 Commits

Author SHA1 Message Date
Simon Marchi 7ca51576b9 xtensa-xtregs: Fix formatting issues
Fix a few formatting issues in that file.

gdb/ChangeLog:

	* xtensa-xtregs.c: Fix formatting issues.
2017-10-29 13:02:29 -04:00
Simon Marchi c1342859dc xtensa-xtregs: Constify field
Fix:

In file included from /home/emaisin/src/binutils-gdb/gdb/xtensa-linux-nat.c:46:0:
/home/emaisin/src/binutils-gdb/gdb/xtensa-xtregs.c:37:1: error: ISO C++ forbids converting a string constant to 'char*' [-Werror=write-strings]
 };
 ^

gdb/ChangeLog:

	* xtensa-xtregs.c (xtensa_regtable_t) <name>: Constify.
2017-10-29 01:13:33 -04:00
GDB Administrator 692af22719 Automatic date update in version.in 2017-10-29 00:00:25 +00:00
Maksim Dzabraev 484d8d361d Make gdb.selected_thread().inferior return a new reference
thpy_get_inferior function should return a new reference to the
existing inferior object, and therefore should increment its refcount.

Fixed bug looks like this.
If multiple time call gdb.selected_thread ().inferior, gdb throws exception:

(gdb) pi gdb.selected_thread().inferior
<gdb.Inferior object at 0x7f1952bea698>
(gdb) pi gdb.selected_thread().inferior
Python Exception <type 'exceptions.AttributeError'> 'NoneType' object
has no attribute 'inferior':
Error while executing Python code.
(gdb) info threads
  Id   Target Id         Frame
* 1    Thread 0x7f54f0474740 (LWP 584) "mc" 0x00007f54ef055c33 in
2017-10-28 14:19:08 -04:00
Alan Modra d91f0b20e5 PR22361 readelf buffer overflow on fuzzed archive header
PR 22361
	* readelf.c (process_archive_index_and_symbols): Ensure ar_size
	field is zero terminated for strtoul.
	(setup_archive, get_archive_member_name): Likewise.
2017-10-28 22:12:46 +10:30
Alan Modra c0e331c794 PR22300, Abort in elf32_hppa_relocate_section building polyml
polyml produces object files with the wrong OS/ABI for hppa-linux.
This, along with the fact that elf32-hppa.c is using the strictest
backend relocs_compatible, results in wrong merging of ELF symbols.

So, remove the relocs_compatible check in _bfd_elf_merge_symbol.
_bfd_elf_merge_symbol is only called nowadays from within blocks
protected by is_elf_hash_table, so "we are doing an ELF link" as the
removed comment says, is true.

Also relax relocs_compatible for hppa and powerpc.  relocs_compatible
is used for more than just merging symbols, as the name suggests.
This allows objects that are in fact reasonably compatible to be
linked.

	PR 22300
	* elflink.c (_bfd_elf_merge_symbol): Remove relocs_compatible check.
	* elf32-hppa.c (elf_backend_relocs_compatible): Define.
	* elf32-ppc.c (elf_backend_relocs_compatible): Define.
	* elf64-ppc.c (elf_backend_relocs_compatible): Define.
2017-10-28 22:11:40 +10:30
Simon Marchi bac608e7e1 Remove find_inferior usage for thread_search
Replace it with for_each_thread.  While at it, we can inline the
callback code.  One little change is that I am using the
prev_general_thread variable instead of current_gen_ptid, since they
should have the same value.

gdb/gdbserver/ChangeLog:

	* target.c (struct thread_search): Remove.
	(thread_search_callback): Remove.
	(prepare_to_access_memory): Use for_each_thread instead of
	find_inferior.  Inline code from thread_search_callback.
2017-10-27 23:44:12 -04:00
Simon Marchi eaddb42592 Remove usage of find_inferior in resume
Change find_inferior with find_thread.  Since we can now pass arguments
directly instead of through a void pointer, we don't need the
visit_actioned_threads_data structure anymore.

gdb/gdbserver/ChangeLog:

	* server.c (struct visit_actioned_threads_data): Remove.
	(visit_actioned_threads): Change prototype to take arguments
	directly.
	(resume): Use find_thread instead of find_inferior.
2017-10-27 23:43:11 -04:00
Simon Marchi 99078d344d Remove usages of find_inferior in handle_status
Replace one with find_thread, the other with for_each_thread.

gdb/gdbserver/ChangeLog:

	* server.c (queue_stop_reply_callback): Change prototype, return
	void.
	(find_status_pending_thread_callback): Remove.
	(handle_status): Replace find_inferior with find_thread and
	for_each_thread.
2017-10-27 23:41:49 -04:00
Simon Marchi b5540b5f2b common-utils-selftests.c: Add ATTRIBUTE_PRINTF
Fix this, when building with clang:

/home/emaisin/src/binutils-gdb/gdb/unittests/common-utils-selftests.c:50:40: error: format string is not a string literal [-Werror,-Wformat-nonliteral]
  std::string result = string_vprintf (fmt, vp);
                                       ^~~
gdb/ChangeLog:

	* unittests/common-utils-selftests.c (format): Add
	ATTRIBUTE_PRINTF.
2017-10-27 23:36:45 -04:00
Simon Marchi 5a9dcda14c C++ify xml-syscall.c
This patch C++ifies the structures in xml-syscall.c, by using
std::vector instead of VEC, and std::string instead of char*.
Using a unique_ptr in syscall_parse_xml allows to remove a cleanup.

Something that seems strange with the existing code, if you look at
syscalls_info_free_syscalls_desc and
syscalls_info_free_syscall_group_desc, they free the structure elements
(the strings and vectors), but they don't free the syscall_desc and
syscall_group_desc structure themselves.  I don't see anything freeing
those currently.  Any idea why?  According to the comment above
syscalls_info_free_syscall_group_desc, it kinda looks like it's on
purpose.  With this patch, those structures are deleted when the vector
that contains them gets deleted.

The only time I'm aware a syscalls_info structure gets deleted is in the
case the data directory changes during runtime, in init_syscalls_info.
If tried that use case (including under valgrind):

 (gdb) catch syscall
 (gdb) set data-directory another-data-directory
 (gdb) catch syscall

I confirmed that the syscalls_info structure got deleted and recreated,
and everything seemed fine.

Regtested on the buildbot.

gdb/ChangeLog:

	* xml-syscall.c (struct syscall_desc): Add constructor.
	<name>: Change type to std::string.
	(syscall_desc_up): New typedef.
	(syscall_desc_p): Remove typeder.
	(DEF_VEC_P(syscall_desc_p)): Remove.
	(struct syscall_group_desc): Add constructor.
	<name>: Change type to std::string.
	<syscalls>: Change type to std::vector.
	(syscall_group_desc_up): New typedef.
	(syscall_group_desc_p): Remove typedef.
	(DEF_VEC_P(syscall_group_desc_p)): Remove.
	(struct syscalls_info) <syscalls>: Change type to std::vector of
	unique_ptr.
	<groups>: Likewise.
	<my_gdb_datadir>: Change type to std::string.
	(syscalls_info_up): New typedef.
	(allocate_syscalls_info): Remove.
	(syscalls_info_free_syscalls_desc): Remove.
	(syscalls_info_free_syscall_group_desc): Remove.
	(free_syscalls_info): Remove.
	(make_cleanup_free_syscalls_info): Remove.
	(syscall_group_create_syscall_group_desc): Adjust.
	(syscall_group_add_syscall): Adjust.
	(syscall_create_syscall_desc): Adjust.
	(syscall_parse_xml): Adjust, use unique_ptr instead of cleanup.
	(init_syscalls_info): Adjust.
	(syscall_group_get_group_by_name): Adjust.
	(xml_get_syscall_number): Adjust.
	(xml_get_syscall_name): Adjust.
	(xml_list_of_syscalls): Adjust.
	(xml_list_syscalls_by_group): Adjust.
	(xml_list_of_groups): Adjust.
2017-10-27 22:23:48 -04:00
Simon Marchi 45461e0dca Get rid of VEC(probe_p)
Replace the remaining usages of VEC(probe_p) with std::vector.

Regtested on the buildbot.

gdb/ChangeLog:

	* probe.h: Don't include gdb_vecs.h.
	(DEF_VEC_P (probe_p)): Remove.
	(find_probes_in_objfile): Return an std::vector.
	* probe.c (find_probes_in_objfile): Likewise.
	* breakpoint.c (breakpoint_objfile_data)
	<longjmp_probes>: Change type to std::vector.
	<exception_probes>: Likewise.
	(free_breakpoint_probes): Don't manually free vectors.
	(create_longjmp_master_breakpoint): Adjust.
	(create_exception_master_breakpoint): Adjust.
	* solib-svr4.c (svr4_create_probe_breakpoints): Change
	parameter type, adjust.
	(svr4_create_solib_event_breakpoints): Adjust.
2017-10-27 22:12:01 -04:00
Simon Marchi 43dce43945 Allocate breakpoint_objfile_data with new
Allocate with new and free with delete.  This allows using an
std::vector in the following patch.

I renamed free_breakpoint_probes to free_breakpoint_objfile_data,
because it now doesn't only free the probes vector, but also the
breakpoint_objfile_data structure itself.

gdb/ChangeLog:

	* breakpoint.c (breakpoint_objfile_data): Initialize fields.
	(get_breakpoint_objfile_data): Allocate breakpoint_objfile_data
	with new.
	(free_breakpoint_probes): Rename to ...
	(free_breakpoint_objfile_data): ... this, and call delete on
	bp_objfile_data..
2017-10-27 22:01:21 -04:00
Simon Marchi 6a1b9516d8 Get rid of VEC(loaded_script_ptr)
Direct replacement with std::vector.  This allows removing a cleanup as
well.

Regtested on the buildbot.

gdb/ChangeLog:

	* auto-load.c: Don't include gdb_vecs.h, include algorithm.
	(loaded_script_ptr): Remove typedef.
	(DEF_VEC_P (loaded_script_ptr)): Remove.
	(struct collect_matching_scripts_data): Add constructor.
	<scripts_p>: Change type to (pointer to) std::vector.
	(collect_matching_scripts_data): Adjust.
	(sort_scripts_by_name): Make suitable for std::sort.
	(print_scripts): Don't sort vector, adjust to std::vector.
	(auto_load_info_scripts): Sort vectors, adjust to std::vector.
2017-10-27 21:55:43 -04:00
Simon Marchi 593e3209f3 Get rid of VEC(filename_language)
This patch removes VEC(filename_language), replacing its usage with
std::vector.  filename_language::ext is changed to an std::string at the
same time.

Regtested on the buildbot.

gdb/ChangeLog:

	* symfile.c (filename_language): Make struct, not typedef.  Add
	constructor.
	<ext>: Change type to std::string.
	(DEF_VEC_O (filename_language)): Remove.
	(filename_language_table): Change type to std::vector.
	(add_filename_language): Adjust.
	(set_ext_lang_command): Adjust.
	(info_ext_lang_command): Adjust.
	(deduce_language_from_filename): Adjust.
	(class scoped_restore_filename_language_table): Remove.
	(test_filename_language): Use scoped_restore.
	(test_set_ext_lang_command): Use scoped_restore, adjust to
	std::vector change.
2017-10-27 21:47:30 -04:00
Simon Marchi 32fa66eb88 Add tests for filename_language
The next patch touches the filename_language area, but I noticed there
is no test exercising that.  This patch adds some selftests for
add_filename_language, deduce_language_from_filename and
set_ext_lang_command.  Because these tests add entries to the global
filename_language_table vector, it is not possible to run them
successfully multiple times in a same GDB instance.  They can
potentially interfere with each other for the same reason.  I therefore
added the scoped_restore_filename_language_table class that is used to
make sure tests leave that global vector in the same state they found it
(it is replaced in the following patch by a simple scoped_restore).

gdb/ChangeLog:

	* symfile.c: Include selftest.h.
	(class scoped_restore_filename_language_table): New.
	(test_filename_language): New test.
	(test_set_ext_lang_command): New test.
	(_initialize_symfile): Register tests.
2017-10-27 21:46:49 -04:00
GDB Administrator af5f32f82b Automatic date update in version.in 2017-10-28 00:00:30 +00:00
Keith Seitz 4a27f119f5 Use SaL symbol name when reporting breakpoint locations
Currently, "info break" can show some (perhaps) unexpected results when
setting a breakpoint on an inlined function:

(gdb) list
1	#include <stdio.h>
2
3	static inline void foo()
4	{
5	        printf("Hello world\n");
6	}
7
8	int main()
9	{
10	        foo();
11	        return 0;
12	}
13
(gdb) b foo
Breakpoint 1 at 0x400434: file foo.c, line 5.
(gdb) i b
Num     Type           Disp Enb Address            What
1       breakpoint     keep y   0x0000000000400434 in main at foo.c:5

GDB reported that we understood what "foo" was, but we then report that the
breakpoint is actually set in main. While that is literally true, we can
do a little better.

This is accomplished by copying the symbol for which the breakpoint was set
into the bp_location.  From there, print_breakpoint_location can use this
information to print out symbol information (if available) instead of calling
find_pc_sect_function.

With the patch installed,

(gdb) i b
Num     Type           Disp Enb Address            What
1       breakpoint     keep y   0x0000000000400434 in foo at foo.c:5

gdb/ChangeLog:

	* breakpoint.c (print_breakpoint_location): Use the symbol saved
	in the bp_location, falling back to find_pc_sect_function when
	needed.
	(add_location_to_breakpoint): Save sal->symbol.
	* breakpoint.h (struct bp_location) <symbol>: New field.
	* symtab.c (find_function_start_sal): Save the symbol into the SaL.
	* symtab.h (struct symtab_and_line) <symbol>: New field.

gdb/testsuite/ChangeLog:

	* gdb.opt/inline-break.exp (break_info_1): New procedure.
	Test "info break" for every inlined function breakpoint.
2017-10-27 10:57:23 -07:00
Yao Qi bb11dd5839 [AArch64] Mark LR clobbered by BL in inline asm
LR is a caller-save register, so, if inline asm does BL (which touches
LR), we should mark LR clobbered.

gdb/testsuite:

2017-10-27  Yao Qi  <yao.qi@linaro.org>

	* gdb.arch/insn-reloc.c (can_relocate_bl): Mark "x30" clobbered.
2017-10-27 15:29:24 +01:00
Simon Marchi 32ef30002c dwarf: Read register number as unsigned in DW_CFA_def_cfa*
When displaying the .debug_frame section, the register numbers in the
DW_CFA_def_cfa* statements are read as signed numbers.  I have come
across a target that has register 121, encoded as 0x79 in unsigned LEB128.
Interpreting this as signed results in -7, which makes readelf display
"r-7".

The DWARF5 standard (6.4.2.2) states that the register numbers should be
treated as unsigned LEB128.

Simply replacing READ_SLEB with READ_ULEB resulted in warnings like
these:

/home/emaisin/src/binutils-gdb/binutils/dwarf.c: In function ‘display_debug_frames’:
/home/emaisin/src/binutils-gdb/binutils/dwarf.c:355:17: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
       if ((var) != _val)     \
                 ^
/home/emaisin/src/binutils-gdb/binutils/dwarf.c:7866:8: note: in expansion of macro ‘READ_ULEB’
        READ_ULEB (fc->cfa_reg);
        ^
... so I also changed Frame_Chunk::cfa_reg to an unsigned int.

binutils/ChangeLog:

	* dwarf.c (struct Frame_Chunk) <cfa_reg>: Change type to
	unsigned int.
	(display_debug_frames): Read CFA reg as an unsigned number.
2017-10-27 09:01:36 -04:00
Simon Marchi 7453e6b2ea Add PR mention to previous commit 2017-10-27 08:58:43 -04:00
Patrick Frants a43f3893f6 Fix broken recursion detection when printing static members
Recursion detection for static members was broken.  The implementation
uses a growing (and shrinking) obstack object to simulate a stack of
addresses (CORE_ADDR).  Pushing addresses is implemented by calling
obstack_grow(), while popping is implemented by calling obstack_free().
The latter is problematic because obstack_free() expects a pointer to
the base of an object.  When popping elements of the stack however,
obstack_free() was called with the new top, which potentially is not the
same as the base of the stack.  This is unintended use and the effect is
that obstack->next_free and obstack->object_base members are assigned
the value of the new top, which equals an empty stack.  Summary: popping
elements would always result in an empty stack, which breaks the
recursion detection.

The fix shrinks the stack using obstack_blank_fast() with a negative
value as described at the bottom of this page:
https://gcc.gnu.org/onlinedocs/libiberty/Extra-Fast-Growing.html "You
can use obstack_blank_fast with a “negative” size argument to make the
current object smaller.  Just don’t try to shrink it beyond zero
length—there’s no telling what will happen if you do that. Earlier
versions of obstacks allowed you to use obstack_blank to shrink objects.
This will no longer work."

The reproducer is added to gdb.cp/classes.exp, which fails without this
patch.

gdb/ChangeLog:

	* cp-valprint.c (cp_print_value_fields): Use obstack_blank_fast
	to rewind obstack.

gdb/testsuite/ChangeLog:

	* gdb.cp/classes.exp (test_static_members): Test printing
	Outer::instance.
	* gdb.cp/classes.c (struct Inner, struct Outer): New.
	(Inner::instance, Outer::instance): New.
2017-10-26 22:26:08 -04:00
GDB Administrator 95904ac43c Automatic date update in version.in 2017-10-27 00:00:28 +00:00
Pedro Alves 23cc4e1b28 Garbage collect remote.c:remote_async_terminal_ours_p
remote.c:remote_async_terminal_ours_p stopped being useful after
048094accc ("target remote: Don't rely on immediate_quit (introduce
quit handlers)") and commit 41fd2b0f5d ("Make input_fd be per UI"),
which turned remote's terminal_inferior/ours methods into nops.

gdb/ChangeLog:
2017-10-26  Pedro Alves  <palves@redhat.com>

	* remote.c (remote_async_terminal_ours_p): Delete.
	(remote_open_1, remote_terminal_inferior, remote_terminal_ours):
	Remove references to 'remote_async_terminal_ours_p'.
2017-10-26 19:53:03 +01:00
H.J. Lu 514f60231c x86: Check invalid XMM register in AVX512 gathers
Extend invalid register check for AVX512 gathers to XMM register.

	PR gas/22352
	* config/tc-i386.c (check_VecOperands): Also check XMM register
	for invalid register in AVX512 gathers.
	* testsuite/gas/i386/vgather-check.s: Add tests for AVX512
	gathers with XMM register.
	* testsuite/gas/i386/x86-64-vgather-check.s: Likewise.
	* testsuite/gas/i386/vgather-check-error.l: Updated.
	* testsuite/gas/i386/vgather-check-none.d: Likewise.
	* testsuite/gas/i386/vgather-check-warn.d: Likewise.
	* testsuite/gas/i386/vgather-check-warn.e: Likewise.
	* testsuite/gas/i386/vgather-check.d: Likewise.
	* testsuite/gas/i386/x86-64-vgather-check-error.l: Likewise.
	* testsuite/gas/i386/x86-64-vgather-check-none.d: Likewise.
	* testsuite/gas/i386/x86-64-vgather-check-warn.d: Likewise.
	* testsuite/gas/i386/x86-64-vgather-check-warn.e: Likewise.
	* testsuite/gas/i386/x86-64-vgather-check.d: Likewise.
2017-10-26 11:18:25 -07:00
Renlin Li 506981afaf [PR21703]Adjust pr21703 tests on various targets.
xfail tests for certain targets.
Check shared library support for shared test.
Relax pr21703-r.sd and pr21703-shared.sd with additional "#..." pattern lines.

ld/

	* testsuite/ld-elf/elf.exp: xfail pr21703 tests on specific targets.
	Only run shared lib test for targets which support it.
	* testsuite/ld-elf/pr21703-r.sd: Adjust the expected output.
	* testsuite/ld-elf/pr21703-shared.sd: Likewise.
2017-10-26 15:43:44 +01:00
James Greenhalgh 4062f504eb As Alan predicted at https://sourceware.org/ml/binutils/2017-10/msg00137.html the values in some Arm tests need updating after recent changes. These looked a bit spooky at first, but they are just a difference in the order we emit veneers and far jumps, so are not so scary after all.
Checked with an arm-none-eabi tester and an arm-none-linux-gnueabi tester with no issues.

	* testsuite/ld-arm/cortex-a8-far.d: Update expected disassembly.
	* testsuite/ld-arm/farcall-group-size2: Likewise.
	* testsuite/ld-arm/farcall-group.d: Likewise.
2017-10-26 11:30:40 +01:00
Yao Qi 6abc18bbbf Remove regular_breakpoint_inserted_here_p declaration
There is no regular_breakpoint_inserted_here_p definition at all, so
this patch removes the declaration.

gdb:

2017-10-26  Yao Qi  <yao.qi@linaro.org>

	* breakpoint.h (regular_breakpoint_inserted_here_p): Remove.
2017-10-26 09:53:38 +01:00
Yao Qi bd5225139c const-fy breakpoint_ops->breakpoint_hit parameter aspace
gdb:

2017-10-26  Yao Qi  <yao.qi@linaro.org>

	* break-catch-sig.c (signal_catchpoint_breakpoint_hit): Make
	aspace const.
	* break-catch-syscall.c (breakpoint_hit_catch_syscall):
	Likewise.
	* breakpoint.c (bpstat_check_location): Remove cast.
	(breakpoint_hit_catch_fork): Make aspce const.
	(breakpoint_hit_catch_solib): Likewise.
	(breakpoint_hit_catch_exec): Likewise.
	(breakpoint_hit_ranged_breakpoint): Likewise.
	(breakpoint_hit_watchpoint): Likewise.
	(base_breakpoint_breakpoint_hit): Likewise.
	(bkpt_breakpoint_hit): Likewise.
	(dprintf_breakpoint_hit): Likewise.
	(tracepoint_breakpoint_hit): Likewise.
	* breakpoint.h (breakpoint_ops) <breakpoint_hit>: Likewise.
2017-10-26 09:46:16 +01:00
Yao Qi accd0bcdfe const-fy function parameter struct address_space *aspace
This patch changes the parameter "struct address_space *aspace" to "const
address_space *aspace" in many functions.

gdb:

2017-10-26  Yao Qi  <yao.qi@linaro.org>

	* breakpoint.c (breakpoint_location_address_match): Change
	"struct address_space *" to "const address_space".
	(breakpoint_location_address_range_overlap): Likewise.
	(breakpoint_here_p): Likewise.
	(breakpoint_in_range_p): Likewise.
	(moribund_breakpoint_here_p): Likewise.
	(bp_location_inserted_here_p): Likewise.
	(software_breakpoint_inserted_here_p): Likewise.
	(hardware_breakpoint_inserted_here_p): Likewise.
	(hardware_watchpoint_inserted_in_range): Likewise.
	(bpstat_check_location): Likewise.
	(bpstat_stop_status): Likewise.
	(breakpoint_address_match): Likewise.
	(breakpoint_address_match_range): Likewise.
	(breakpoint_location_address_match): Likewise.
	(breakpoint_location_address_range_overlap): Likewise.
	(insert_single_step_breakpoint): Likewise.
	(breakpoint_has_location_inserted_here): Likewise.
	(single_step_breakpoint_inserted_here_p): Likewise.
	(pc_at_non_inline_function): Likewise.
	* breakpoint.h (bpstat_stop_status): Update declaration.
	(breakpoint_here_p): Likewise.
	(breakpoint_in_range_p): Likewise.
	(moribund_breakpoint_here_p): Likewise.
	(breakpoint_inserted_here_p): Likewise.
	(software_breakpoint_inserted_here_p): Likewise.
	(hardware_breakpoint_inserted_here_p): Likewise.
	(breakpoint_has_location_inserted_here): Likewise.
	(single_step_breakpoint_inserted_here_p): Likewise.
	(hardware_watchpoint_inserted_in_range): Likewise.
	(breakpoint_address_match): Likewise.
	(insert_single_step_breakpoint): Likewise.
	(pc_at_non_inline_function): Likewise.
	* gdbthread.h (thread_has_single_step_breakpoint_here): Likewise.
	* record.c (record_check_stopped_by_breakpoint): Likewise.
	* record.h (record_check_stopped_by_breakpoint): Likewise.
	* thread.c (thread_has_single_step_breakpoint_here): Likewise.
2017-10-26 09:46:16 +01:00
GDB Administrator ca3e4ea52d Automatic date update in version.in 2017-10-26 00:00:22 +00:00
Hans-Peter Nilsson 238c141b98 testsuite/gas/all/fill-1.s: Use L2 rather than .L2.
For some targets, like mmix-knuth-mmixware, .L2 (and .L1) are invalid
symbols.
2017-10-26 01:12:32 +02:00
H.J. Lu 8df93cb565 ld: Correct -z ibt documentation
* ld.texinfo: Correct -z ibt.
2017-10-25 08:44:54 -07:00
Yao Qi ac7936dfd0 s/get_regcache_arch (regcache)/regcache->arch ()/g
This patches removes get_regcache_arch, and use regache->arch () instead.
The motivation of this change is that I am going to move some basic stuff
into a base class of regcache.  I don't need to update "client" code
regcache->arch ().  On the other hand, this patch shortens the code a
little bit.

gdb:

2017-10-25  Yao Qi  <yao.qi@linaro.org>

	* aarch32-linux-nat.c (aarch32_gp_regcache_supply): Use
	regcache->arch () instead get_regcache_arch.
	* aarch64-fbsd-nat.c (aarch64_fbsd_fetch_inferior_registers):
	Likewise.
	(aarch64_fbsd_store_inferior_registers): Likewise.
	* aarch64-linux-nat.c (fetch_gregs_from_thread): Likewise.
	(store_gregs_to_thread): Likewise.
	(fetch_fpregs_from_thread): Likewise.
	(store_fpregs_to_thread): Likewise.
	* aarch64-tdep.c (aarch64_extract_return_value): Likewise.
	(aarch64_store_return_value): Likewise.
	(aarch64_software_single_step): Likewise.
	* aix-thread.c (aix_thread_wait): Likewise.
	(supply_reg32): Likewise.
	(supply_sprs64): Likewise.
	(supply_sprs32): Likewise.
	(fill_gprs64): Likewise.
	(fill_gprs32): Likewise.
	(fill_sprs64): Likewise.
	(fill_sprs32): Likewise.
	(store_regs_user_thread): Likewise.
	(store_regs_kernel_thread): Likewise.
	* alpha-bsd-nat.c (alphabsd_fetch_inferior_registers): Likewise.
	(alphabsd_store_inferior_registers): Likewise.
	* alpha-tdep.c (alpha_extract_return_value): Likewise.
	(alpha_store_return_value): Likewise.
	(alpha_deal_with_atomic_sequence): Likewise.
	(alpha_next_pc): Likewise.
	(alpha_software_single_step): Likewise.
	* amd64-bsd-nat.c (amd64bsd_fetch_inferior_registers): Likewise.
	(amd64bsd_store_inferior_registers): Likewise.
	* amd64-linux-nat.c (amd64_linux_fetch_inferior_registers):
	Likewise.
	(amd64_linux_store_inferior_registers): Likewise.
	* amd64-nat.c (amd64_supply_native_gregset): Likewise.
	(amd64_collect_native_gregset): Likewise.
	* amd64-obsd-tdep.c (amd64obsd_supply_uthread): Likewise.
	(amd64obsd_collect_uthread): Likewise.
	* amd64-tdep.c (amd64_supply_fpregset): Likewise.
	(amd64_collect_fpregset): Likewise.
	(amd64_supply_fxsave): Likewise.
	(amd64_supply_xsave): Likewise.
	(amd64_collect_fxsave): Likewise.
	(amd64_collect_xsave): Likewise.
	* arc-tdep.c (arc_write_pc): Likewise.
	* arch-utils.c (default_skip_permanent_breakpoint): Likewise.
	* arm-fbsd-nat.c (arm_fbsd_fetch_inferior_registers): Likewise.
	(arm_fbsd_store_inferior_registers): Likewise.
	* arm-linux-nat.c (fetch_vfp_regs): Likewise.
	(store_vfp_regs): Likewise.
	(arm_linux_fetch_inferior_registers): Likewise.
	(arm_linux_store_inferior_registers): Likewise.
	* arm-linux-tdep.c (arm_linux_supply_gregset): Likewise.
	(arm_linux_sigreturn_next_pc): Likewise.
	(arm_linux_get_next_pcs_syscall_next_pc): Likewise.
	* arm-nbsd-nat.c (arm_supply_gregset): Likewise.
	(fetch_register): Likewise.
	(store_register): Likewise.
	* arm-tdep.c (arm_is_thumb): Likewise.
	(displaced_in_arm_mode): Likewise.
	(bx_write_pc): Likewise.
	(arm_get_next_pcs_addr_bits_remove): Likewise.
	(arm_software_single_step): Likewise.
	(arm_extract_return_value): Likewise.
	(arm_store_return_value): Likewise.
	(arm_write_pc): Likewise.
	* bfin-tdep.c (bfin_extract_return_value): Likewise.
	* bsd-uthread.c (bsd_uthread_fetch_registers): Likewise.
	(bsd_uthread_store_registers): Likewise.
	* core-regset.c (fetch_core_registers): Likewise.
	* corelow.c (get_core_registers): Likewise.
	* cris-tdep.c (cris_store_return_value): Likewise.
	(cris_extract_return_value): Likewise.
	(find_step_target): Likewise.
	(find_step_target): Likewise.
	(cris_software_single_step): Likewise.
	* ctf.c (ctf_fetch_registers): Likewise.
	* darwin-nat.c (cancel_breakpoint): Likewise.
	* fbsd-tdep.c (fbsd_collect_thread_registers): Likewise.
	* frv-tdep.c (frv_extract_return_value): Likewise.
	* ft32-tdep.c (ft32_store_return_value): Likewise.
	(ft32_extract_return_value): Likewise.
	* go32-nat.c (fetch_register): Likewise.
	(go32_fetch_registers): Likewise.
	(go32_store_registers): Likewise.
	(store_register): Likewise.
	* h8300-tdep.c (h8300_extract_return_value): Likewise.
	(h8300_store_return_value): Likewise.
	* hppa-linux-nat.c (fetch_register): Likewise.
	(store_register): Likewise.
	(hppa_linux_fetch_inferior_registers): Likewise.
	(hppa_linux_store_inferior_registers): Likewise.
	* i386-darwin-nat.c (i386_darwin_fetch_inferior_registers): Likewise.
	(i386_darwin_store_inferior_registers): Likewise.
	* i386-gnu-nat.c (gnu_fetch_registers): Likewise.
	(gnu_store_registers): Likewise.
	* i386-linux-nat.c (fetch_register): Likewise.
	(store_register): Likewise.
	(supply_gregset): Likewise.
	(fill_gregset): Likewise.
	(i386_linux_fetch_inferior_registers): Likewise.
	(i386_linux_store_inferior_registers): Likewise.
	(i386_linux_resume): Likewise.
	* i386-linux-tdep.c (i386_linux_get_syscall_number_from_regcache):
	Likewise.
	* i386-nto-tdep.c (i386nto_supply_gregset): Likewise.
	* i386-obsd-nat.c (i386obsd_supply_pcb): Likewise.
	* i386-obsd-tdep.c (i386obsd_supply_uthread): Likewise.
	(i386obsd_collect_uthread): Likewise.
	* i386-tdep.c (i386_mmx_regnum_to_fp_regnum): Likewise.
	(i386_supply_gregset): Likewise.
	(i386_collect_gregset): Likewise.
	(i386_supply_fpregset): Likewise.
	(i386_collect_fpregset): Likewise.
	(i386_mpx_bd_base): Likewise.
	* i386-v4-nat.c	(supply_fpregset): Likewise.
	(fill_fpregset): Likewise.
	* i387-tdep.c (i387_supply_fsave): Likewise.
	(i387_collect_fsave): Likewise.
	(i387_supply_fxsave): Likewise.
	(i387_collect_fxsave): Likewise.
	(i387_supply_xsave): Likewise.
	(i387_collect_xsave): Likewise.
	* ia64-linux-nat.c (ia64_linux_fetch_registers): Likewise.
	(ia64_linux_store_registers): Likewise.
	* ia64-tdep.c (ia64_access_rse_reg): Likewise.
	(ia64_extract_return_value): Likewise.
	(ia64_store_return_value): Likewise.
	(find_func_descr): Likewise.
	* inf-child.c (inf_child_fetch_inferior_registers): Likewise.
	* inf-ptrace.c (inf_ptrace_fetch_registers): Likewise.
	(inf_ptrace_store_registers): Likewise.
	* infrun.c (use_displaced_stepping): Likewise.
	(displaced_step_prepare_throw): Likewise.
	(resume): Likewise.
	(proceed): Likewise.
	(do_target_wait): Likewise.
	(adjust_pc_after_break): Likewise.
	(handle_inferior_event_1): Likewise.
	(handle_signal_stop): Likewise.
	(save_infcall_suspend_state): Likewise.
	(restore_infcall_suspend_state): Likewise.
	* iq2000-tdep.c (iq2000_extract_return_value): Likewise.
	* jit.c (jit_frame_prev_register): Likewise.
	* linux-nat.c (save_stop_reason): Likewise.
	(linux_nat_wait_1): Likewise.
	(resume_stopped_resumed_lwps): Likewise.
	* linux-record.c (record_linux_sockaddr): Likewise.
	(record_linux_msghdr): Likewise.
	(record_linux_system_call): Likewise.
	* linux-tdep.c (linux_collect_thread_registers): Likewise.
	* lm32-tdep.c (lm32_extract_return_value): Likewise.
	(lm32_store_return_value): Likewise.
	* m32c-tdep.c (m32c_read_flg): Likewise.
	(m32c_pseudo_register_read): Likewise.
	(m32c_pseudo_register_write): Likewise.
	* m32r-linux-tdep.c (m32r_linux_supply_gregset): Likewise.
	(m32r_linux_collect_gregset): Likewise.
	* m32r-tdep.c (m32r_store_return_value): Likewise.
	(m32r_extract_return_value): Likewise.
	* m68k-bsd-nat.c (m68kbsd_supply_fpregset): Likewise.
	(m68kbsd_collect_fpregset): Likewise.
	* m68k-bsd-tdep.c (m68kbsd_supply_fpregset): Likewise.
	* m68k-linux-nat.c (fetch_register): Likewise.
	(old_fetch_inferior_registers): Likewise.
	(old_store_inferior_registers): Likewise.
	(store_regs): Likewise.
	* m68k-tdep.c (m68k_svr4_extract_return_value): Likewise.
	(m68k_svr4_store_return_value): Likewise.
	* m88k-tdep.c (m88k_store_arguments): Likewise.
	* mi/mi-main.c (mi_cmd_data_list_changed_registers): Likewise.
	(mi_cmd_data_write_register_values): Likewise.
	* mips-fbsd-nat.c (mips_fbsd_fetch_inferior_registers): Likewise.
	(mips_fbsd_store_inferior_registers): Likewise.
	* mips-fbsd-tdep.c (mips_fbsd_supply_fpregs): Likewise.
	(mips_fbsd_supply_gregs): Likewise.
	(mips_fbsd_collect_fpregs): Likewise.
	(mips_fbsd_collect_gregs): Likewise.
	(mips_fbsd_supply_fpregset): Likewise.
	(mips_fbsd_collect_fpregset): Likewise.
	(mips_fbsd_supply_gregset): Likewise.
	(mips_fbsd_collect_gregset): Likewise.
	* mips-linux-nat.c (supply_gregset): Likewise.
	(fill_gregset): Likewise.
	(supply_fpregset): Likewise.
	(fill_fpregset): Likewise.
	* mips-linux-tdep.c (mips_supply_gregset): Likewise.
	(mips_fill_gregset): Likewise.
	(mips_supply_fpregset): Likewise.
	(mips_fill_fpregset): Likewise.
	(mips64_supply_gregset): Likewise.
	(micromips_linux_sigframe_validate): Likewise.
	* mips-nbsd-nat.c (mipsnbsd_fetch_inferior_registers): Likewise.
	(mipsnbsd_fetch_inferior_registers): Likewise.
	(mipsnbsd_store_inferior_registers): Likewise.
	* mips-nbsd-tdep.c (mipsnbsd_supply_fpregset): Likewise.
	(mipsnbsd_supply_gregset): Likewise.
	(mipsnbsd_iterate_over_regset_sections): Likewise.
	(mipsnbsd_supply_reg): Likewise.
	(mipsnbsd_supply_fpreg): Likewise.
	* mips-tdep.c (mips_in_frame_stub): Likewise.
	(mips_dummy_id): Likewise.
	(is_octeon_bbit_op): Likewise.
	(micromips_bc1_pc): Likewise.
	(extended_mips16_next_pc): Likewise.
	(mips16_next_pc): Likewise.
	(deal_with_atomic_sequence): Likewise.
	* moxie-tdep.c (moxie_process_readu): Likewise.
	* nios2-tdep.c (nios2_get_next_pc): Likewise.
	* nto-procfs.c (procfs_store_registers): Likewise.
	* ppc-fbsd-nat.c (ppcfbsd_fetch_inferior_registers): Likewise.
	(ppcfbsd_store_inferior_registers): Likewise.
	* ppc-linux-nat.c (fetch_vsx_register): Likewise.
	(fetch_altivec_register): Likewise.
	(get_spe_registers): Likewise.
	(fetch_spe_register): Likewise.
	(fetch_altivec_registers): Likewise.
	(fetch_all_gp_regs): Likewise.
	(fetch_all_fp_regs): Likewise.
	(store_vsx_register): Likewise.
	(store_altivec_register): Likewise.
	(set_spe_registers): Likewise.
	(store_spe_register): Likewise.
	(store_altivec_registers): Likewise.
	(store_all_gp_regs): Likewise.
	(store_all_fp_regs): Likewise.
	* ppc-linux-tdep.c (ppc_linux_supply_gregset): Likewise.
	(ppc_linux_collect_gregset): Likewise.
	(ppc_canonicalize_syscall): Likewise.
	(ppc_linux_record_signal): Likewise.
	(ppu2spu_prev_register): Likewise.
	* ppc-nbsd-nat.c (ppcnbsd_supply_pcb): Likewise.
	* ppc-obsd-nat.c (ppcobsd_fetch_registers): Likewise.
	(ppcobsd_store_registers): Likewise.
	* ppc-ravenscar-thread.c (ppc_ravenscar_generic_fetch_registers):
	Likewise.
	(ppc_ravenscar_generic_store_registers): Likewise.
	* procfs.c (procfs_fetch_registers): Likewise.
	(procfs_store_registers): Likewise.
	* ravenscar-thread.c (ravenscar_fetch_registers): Likewise.
	(ravenscar_store_registers): Likewise.
	(ravenscar_prepare_to_store): Likewise.
	* record-btrace.c (record_btrace_fetch_registers): Likewise.
	* record-full.c (record_full_wait_1): Likewise.
	(record_full_registers_change): Likewise.
	(record_full_store_registers): Likewise.
	(record_full_core_fetch_registers): Likewise.
	(record_full_save): Likewise.
	(record_full_goto_insn): Likewise.
	* regcache.c (regcache_register_size): Likewise.
	(get_regcache_arch): Remove.
	(regcache_read_pc): Likewise.
	* regcache.h (get_regcache_arch): Remove.
	* remote-sim.c (gdbsim_fetch_register): Likewise.
	(gdbsim_store_register): Likewise.
	* remote.c (fetch_register_using_p): Likewise.
	(send_g_packet): Likewise.
	(remote_prepare_to_store): Likewise.
	(store_registers_using_G): Likewise.
	* reverse.c (save_bookmark_command): Likewise.
	(goto_bookmark_command): Likewise.
	* rs6000-aix-tdep.c (branch_dest): Likewise.
	* rs6000-nat.c (rs6000_ptrace64): Likewise.
	(fetch_register): Likewise.
	* rs6000-tdep.c (ppc_supply_reg): Likewise.
	(ppc_collect_reg): Likewise.
	(ppc_collect_gregset): Likewise.
	(ppc_collect_fpregset): Likewise.
	(ppc_collect_vsxregset): Likewise.
	(ppc_collect_vrregset): Likewise.
	(ppc_displaced_step_hw_singlestep): Likewise.
	(rs6000_pseudo_register_read): Likewise.
	(rs6000_pseudo_register_write): Likewise.
	* s390-linux-nat.c (supply_gregset): Likewise.
	(fill_gregset): Likewise.
	(s390_linux_fetch_inferior_registers): Likewise.
	* s390-linux-tdep.c (s390_write_pc): Likewise.
	(s390_software_single_step): Likewise.
	(s390_all_but_pc_registers_record): Likewise.
	(s390_linux_syscall_record): Likewise.
	* sentinel-frame.c (sentinel_frame_prev_arch): Likewise.
	* sh-nbsd-nat.c (shnbsd_fetch_inferior_registers): Likewise.
	(shnbsd_store_inferior_registers): Likewise.
	* sh-tdep.c (sh_extract_return_value_nofpu): Likewise.
	(sh_extract_return_value_fpu): Likewise.
	(sh_store_return_value_nofpu): Likewise.
	(sh_corefile_supply_regset): Likewise.
	(sh_corefile_collect_regset): Likewise.
	* sh64-tdep.c (sh64_extract_return_value): Likewise.
	(sh64_store_return_value): Likewise.
	* sparc-linux-tdep.c (sparc32_linux_collect_core_fpregset): Likewise.
	* sparc-nat.c (sparc_fetch_inferior_registers): Likewise.
	(sparc_store_inferior_registers): Likewise.
	* sparc-ravenscar-thread.c (register_in_thread_descriptor_p): Likewise.
	(sparc_ravenscar_prepare_to_store): Likewise.
	* sparc-tdep.c (sparc32_store_arguments): Likewise.
	(sparc_analyze_control_transfer): Likewise.
	(sparc_step_trap): Likewise.
	(sparc_software_single_step): Likewise.
	(sparc32_gdbarch_init): Likewise.
	(sparc_supply_rwindow): Likewise.
	(sparc_collect_rwindow): Likewise.
	* sparc64-linux-tdep.c (sparc64_linux_collect_core_fpregset): Likewise.
	* sparc64-nbsd-nat.c (sparc64nbsd_supply_gregset): Likewise.
	(sparc64nbsd_collect_gregset): Likewise.
	(sparc64nbsd_supply_fpregset): Likewise.
	(sparc64nbsd_collect_fpregset): Likewise.
	* sparc64-tdep.c (sparc64_store_arguments): Likewise.
	(sparc64_supply_gregset): Likewise.
	(sparc64_collect_gregset): Likewise.
	(sparc64_supply_fpregset): Likewise.
	(sparc64_collect_fpregset): Likewise.
	* spu-linux-nat.c (spu_fetch_inferior_registers): Likewise.
	* spu-tdep.c (spu_unwind_sp): Likewise.
	(spu2ppu_prev_register): Likewise.
	(spu_memory_remove_breakpoint): Likewise.
	* stack.c (return_command): Likewise.
	* tic6x-tdep.c (tic6x_extract_signed_field): Likewise.
	* tracefile-tfile.c (tfile_fetch_registers): Likewise.
	* tracefile.c (trace_save_ctf): Likewise.
	* windows-nat.c (do_windows_fetch_inferior_registers): Likewise.
	(do_windows_store_inferior_registers): Likewise.
	(windows_resume): Likewise.
	* xtensa-linux-nat.c (fill_gregset): Likewise.
	(supply_gregset_reg): Likewise.
	* xtensa-tdep.c (xtensa_register_write_masked): Likewise.
	(xtensa_register_read_masked): Likewise.
	(xtensa_supply_gregset): Likewise.
	(xtensa_extract_return_value): Likewise.
	(xtensa_store_return_value): Likewise.
2017-10-25 16:37:03 +01:00
Ulrich Weigand edd079d9f6 Target FP: Use target format throughout expression parsing
When parsing floating-point literals, the language parsers currently
use parse_float or some equivalent routine to parse the input string
into a DOUBLEST, which is then stored within a OP_DOUBLE expression
node.  When evaluating the expression, the OP_DOUBLE is finally
converted into a value in target format.

On the other hand, *decimal* floating-point literals are parsed
directly into target format and stored that way in a OP_DECFLOAT
expression node.  In order to eliminate the DOUBLEST, this patch
therefore unifies the handling of binary and decimal floating-
point literals and stores them both in target format within a
new OP_FLOAT expression node, replacing both OP_DOUBLE and
OP_DECFLOAT.

In order to store literals in target format, the parse_float
routine needs to know the type of the literal.  All parsers
therefore need to be changed to determine the appropriate type
(e.g. by detecting suffixes) *before* calling parse_float,
instead of after it as today.  However, this change is mostly
straightforward -- again, this is already done for decimal FP
today.

The core of the literal parsing is moved into a new routine
floatformat_from_string, mirroring floatformat_to_string.
The parse_float routine now calls either floatformat_from_string
or decimal_from_sting, allowing it to handle any type of FP
literal.

All language parsers need to be updated.  Some notes on
specific changes to the various languages:

- C: Decimal FP is now handled in parse_float, and no longer
  needs to be handled specially.

- D: Straightforward.

- Fortran: Still used a hard-coded "atof", also replaced by
  parse_float now.  Continues to always use builtin_real_s8
  as the type of literal, even though this is probably wrong.

- Go: This used to handle "f" and "l" suffixes, even though
  the Go language actually doesn't support those.  I kept this
  support for now -- maybe revisit later.  Note the the GDB
  test suite for some reason actually *verifies* that GDB supports
  those unsupported suffixes ...

- Pascal: Likewise -- this handles suffixes that are not
  supported in the language standard.

- Modula-2: Like Fortran, used to use "atof".

- Rust: Mostly straightforward, except for a unit-testing hitch.
  The code use to set a special "unit_testing" flag which would
  cause "rust_type" to always return NULL.  This makes it not
  possible to encode a literal into target format (which type?).
  The reason for this flag appears to have been that during
  unit testing, there is no "rust_parser" context set up, which
  means no "gdbarch" is available to use its types.  To fix this,
  I removed the unit_testing flag, and instead simply just set up
  a dummy rust_parser context during unit testing.

- Ada: This used to check sizeof (DOUBLEST) to determine which
  type to use for floating-point literal.  This seems questionable
  to begin with (since DOUBLEST is quite unrelated to target formats),
  and in any case we need to get rid of DOUBLEST.  I'm now simply
  always using the largest type (builtin_long_double).

gdb/ChangeLog:
2017-10-25  Ulrich Weigand  <uweigand@de.ibm.com>

	* doublest.c (floatformat_from_string): New function.
	* doublest.h (floatformat_from_string): Add prototype.

	* std-operator.def (OP_DOUBLE, OP_DECFLOAT): Remove, replace by ...
	(OP_FLOAT): ... this.
	* expression.h: Do not include "doublest.h".
	(union exp_element): Replace doubleconst and decfloatconst by
	new element floatconst.
	* ada-lang.c (resolve_subexp): Handle OP_FLOAT instead of OP_DOUBLE.
	(ada_evaluate_subexp): Likewise.
	* eval.c (evaluate_subexp_standard): Handle OP_FLOAT instead of
	OP_DOUBLE and OP_DECFLOAT.
	* expprint.c (print_subexp_standard): Likewise.
	(dump_subexp_body_standard): Likewise.
	* breakpoint.c (watchpoint_exp_is_const): Likewise.

	* parse.c: Include "dfp.h".
	(write_exp_elt_dblcst, write_exp_elt_decfloatcst): Remove.
	(write_exp_elt_floatcst): New function.
	(operator_length_standard): Handle OP_FLOAT instead of OP_DOUBLE
	and OP_DECFLOAT.
	(operator_check_standard): Likewise.
	(parse_float): Do not accept suffix.  Take type as input.  Return bool.
	Return target format buffer instead of host DOUBLEST.
	Use floatformat_from_string and decimal_from_string to parse
	either binary or decimal floating-point types.
	(parse_c_float): Remove.
	* parser-defs.h: Do not include "doublest.h".
	(write_exp_elt_dblcst, write_exp_elt_decfloatcst): Remove.
	(write_exp_elt_floatcst): Add prototype.
	(parse_float): Update prototype.
	(parse_c_float): Remove.

	* c-exp.y: Do not include "dfp.h".
	(typed_val_float): Use byte buffer instead of DOUBLEST.
	(typed_val_decfloat): Remove.
	(DECFLOAT): Remove.
	(FLOAT): Use OP_FLOAT and write_exp_elt_floatcst.
	(parse_number): Update to new parse_float interface.
	Parse suffixes and determine type before calling parse_float.
	Handle decimal and binary FP types the same way.

	* d-exp.y (typed_val_float): Use byte buffer instead of DOUBLEST.
	(FLOAT_LITERAL): Use OP_FLOAT and write_exp_elt_floatcst.
	(parse_number): Update to new parse_float interface.
	Parse suffixes and determine type before calling parse_float.

	* f-exp.y: Replace dval by typed_val_float.
	(FLOAT): Use OP_FLOAT and write_exp_elt_floatcst.
	(parse_number): Use parse_float instead of atof.

	* go-exp.y (typed_val_float): Use byte buffer instead of DOUBLEST.
	(parse_go_float): Remove.
	(FLOAT): Use OP_FLOAT and write_exp_elt_floatcst.
	(parse_number): Call parse_float instead of parse_go_float.
	Parse suffixes and determine type before calling parse_float.

	* p-exp.y (typed_val_float): Use byte buffer instead of DOUBLEST.
	(FLOAT): Use OP_FLOAT and write_exp_elt_floatcst.
	(parse_number): Update to new parse_float interface.
	Parse suffixes and determine type before calling parse_float.

	* m2-exp.y: Replace dval by byte buffer val.
	(FLOAT): Use OP_FLOAT and write_exp_elt_floatcst.
	(parse_number): Call parse_float instead of atof.

	* rust-exp.y (typed_val_float): Use byte buffer instead of DOUBLEST.
	(lex_number): Call parse_float instead of strtod.
	(ast_dliteral): Use OP_FLOAT instead of OP_DOUBLE.
	(convert_ast_to_expression): Handle OP_FLOAT instead of OP_DOUBLE.
	Use write_exp_elt_floatcst.
	(unit_testing): Remove static variable.
	(rust_type): Do not check unit_testing.
	(rust_lex_tests): Do not set uint_testing.  Set up dummy rust_parser.

	* ada-exp.y (type_float, type_double): Remove.
	(typed_val_float): Use byte buffer instead of DOUBLEST.
	(FLOAT): Use OP_FLOAT and write_exp_elt_floatcst.
	* ada-lex.l (processReal): Use parse_float instead of sscanf.
2017-10-25 15:32:23 +02:00
Alan Modra e5d70d6b5a PR22348, conflicting global vars in crx and cr16
include/
	PR 22348
	* opcode/cr16.h (instruction): Delete.
	(cr16_words, cr16_allWords, cr16_currInsn): Delete.
	* opcode/crx.h (crx_cst4_map): Rename from cst4_map.
	(crx_cst4_maps): Rename from cst4_maps.
	(crx_no_op_insn): Rename from no_op_insn.
	(instruction): Delete.
opcodes/
	PR 22348
	* cr16-dis.c (cr16_cinvs, instruction, cr16_currInsn): Make static.
	(cr16_words, cr16_allWords, processing_argument_number): Likewise.
	(imm4flag, size_changed): Likewise.
	* crx-dis.c (crx_cinvs, NUMCINVS, instruction, currInsn): Likewise.
	(words, allWords, processing_argument_number): Likewise.
	(cst4flag, size_changed): Likewise.
	* crx-opc.c (crx_cst4_map): Rename from cst4_map.
	(crx_cst4_maps): Rename from cst4_maps.
	(crx_no_op_insn): Rename from no_op_insn.
gas/
	PR 22348
	* config/tc-crx.c (instruction, output_opcode): Make static.
	(relocatable, ins_parse, cur_arg_num): Likewise.
	(parse_insn): Adjust for renamed opcodes globals.
	(check_range): Likewise
2017-10-25 22:14:58 +10:30
Alan Hayward cc628f3dbb Add common AARCH64 REGNUM defines
gdb/
	* aarch64-tdep.h (enum aarch64_regnum): Remove.
	* arch/aarch64.h: New file.

gdbserver/
	* linux-aarch64-low.c (aarch64_fill_gregset): Replace defines
	with REGNO.
	(aarch64_store_gregset): Likewise.
	(aarch64_fill_fpregset): Likewise.
	(aarch64_store_fpregset): Likewise.
2017-10-25 09:06:41 +01:00
Alan Modra e601d38b7c Allow for __gnu_lto_slim prefixed with extra "_"
Some targets prefix global symbols with "_".

bfd/
	* archive.c (_bfd_compute_and_write_armap): Match "__gnu_lto_slim"
	optionally prefixed with "_".
	* linker.c (_bfd_generic_link_add_one_symbol): Likewise.
binutils/
	* nm.c (filter_symbols): Match "__gnu_lto_slim" optionally prefixed
	with "_".
gold/
	* symtab.cc (Symbol_table::add_from_relobj): Match "__gnu_lto_slim"
	optionally prefixed with "_".
ld/
	* testsuite/ld-plugin/lto-3r.d: Match "__gnu_lto_v" optionally
	prefixed with "_".
	* testsuite/ld-plugin/lto-5r.d: Likewise.
2017-10-25 15:32:52 +10:30
Alan Modra 94092126a0 Yet another fill-1 test fix
tic4x fails due to being a 4 octets per byte target, while tic54x is 2
octets per byte.

mmix still fails with
fill-1.s:4: Error: unknown pseudo-op: `.l1:'
fill-1.s:6: Error: unknown pseudo-op: `.l2:'
fill-1.s:3: Error: .space specifies non-absolute value

and if the labels are changed to L1 and L2 then mep-elf fails with
fill-1.s:3: Error: .space specifies non-absolute value

Since both of those look like they ought to be investigated by the
target maintainers, I'm tweaking the test to fail on both targets.

	* testsuite/gas/all/fill-1.d: Exclude tic4x and tic54x.
	* testsuite/gas/all/fill-1.s: Use L1 rather than .L1.
2017-10-25 15:31:58 +10:30
GDB Administrator 711f5e559e Automatic date update in version.in 2017-10-25 00:00:26 +00:00
Hans-Peter Nilsson db283f4401 Fix format typos in previous previous ld/ChangeLog entry 2017-10-25 00:46:24 +02:00
Hans-Peter Nilsson 2e30886f1f testsuite/ld-riscv-elf/ld-riscv-elf.exp: Fix typo for istarget. 2017-10-25 00:45:05 +02:00
Pedro Alves 792ccf005f Fix racy test in gdb.base/new-ui.exp
I noticed gdb.base/new-ui.exp failing once here with:

 FAIL: gdb.base/new-ui.exp: do_test: delete all breakpoints on extra console (got interactive prompt)
 FAIL: gdb.base/new-ui.exp: do_test: main console: next causes no spurious output on other console
 FAIL: gdb.base/new-ui.exp: do_test: main console: breakpoint hit reported on other console

The problem is 100% reproducible with check-read1:
  $ make check-read1 TESTS="gdb.*/new-ui.exp"

testsuite/gdb.log shows:
  delete
  Delete all breakpoints? (y or n) [answered Y; input not from terminal]
  (gdb) FAIL: gdb.base/new-ui.exp: do_test: delete all breakpoints on extra console (got interactive prompt)

This commit fixes the problem.

gdb/testsuite/ChangeLog:
2017-10-24  Pedro Alves  <palves@redhat.com>

	* gdb.base/new-ui.exp (do_test): Split "delete all breakpoints on
	extra console" test in two stages.
2017-10-24 23:22:56 +01:00
Andrew Waterman 63a25ea0de RISC-V: Fix disassembly of c.addi4spn, c.addi16sp, c.lui when imm=0
These are all invalid instructions, so they should not disassemble.

opcodes/ChangeLog

2017-10-24  Andrew Waterman  <andrew@sifive.com>

        * riscv-opc.c (match_c_addi16sp) : New function.
        (match_c_addi4spn): New function.
        (match_c_lui): Don't allow 0-immediate encodings.
        (riscv_opcodes) <addi>: Use the above functions.
        <add>: Likewise.
        <c.addi4spn>: Likewise.
        <c.addi16sp>: Likewise.

gas/ChangeLog

2017-10-24  Andrew Waterman  <andrew@sifive.com>

        * testsuite/gas/riscv/c-addi16sp-fail.d: New test.
        testsuite/gas/riscv/c-addi16sp-fail.l: Likewise.
        testsuite/gas/riscv/c-addi16sp-fail.s: Likewise.
        testsuite/gas/riscv/c-addi4spn-fail.d: Likewise.
        testsuite/gas/riscv/c-addi4spn-fail.l: Likewise.
        testsuite/gas/riscv/c-addi4spn-fail.s: Likewise.
        testsuite/gas/riscv/riscv.exp: Add new tests.
2017-10-24 09:47:36 -07:00
Ulrich Weigand 09a7c6aa7a Use const reference for decimal_from_string argument
No functional change.

gdb/ChangeLog:
2017-10-24  Ulrich Weigand  <uweigand@de.ibm.com>

	* dfp.h (decimal_from_string): Use const reference for argument.
	* dfp.c (decimal_from_string): Likewise.
2017-10-24 18:34:41 +02:00
Ulrich Weigand 8ba0dd515c Target FP printing: Use floatformat_to_string in tdep code
A few tdep files use target-specific printing routines to output values in
the floating-point registers.  To get rid of host floating-point code,
this patch changes them to use floatformat_to_string instead.

No functional change intended, the resulting output should look the same.

ChangeLog:
2017-10-24  Ulrich Weigand  <uweigand@de.ibm.com>

	* i387-tdep.c (print_i387_value): Use floatformat_to_string.
	* sh64-tdep.c (sh64_do_fp_register): Likewise.
	* mips-tdep.c (mips_print_fp_register): Likewise.
2017-10-24 18:01:39 +02:00
Ulrich Weigand 16e812b29e Target FP printing: Simplify and fix ui_printf
This patch adds support for handling format strings to both
floatformat_to_string and decimal_to_string, and then uses
those routines to implement ui_printf formatted printing.

There is already a subroutine printf_decfloat that ui_printf uses to
handle decimal FP.  This is renamed to printf_floating and updated
to handle both binary and decimal FP.  This includes the following
set of changes:

- printf_decfloat currently parses the format string again to determine
  the intended target format.  This seems superfluous since the common
  parsing code in parse_format_string already did this, but then did
  not pass the result on to its users.  Fixed by splitting the decfloat_arg
  argument class into three distinct classes, and passing them through.

- Now we can rename printf_decfloat to printf_floating and also call it
  for the argument classes representing binary FP types.

- The code will now use the argclass to detect the type the value should
  be printed at, and converts the input value to this type if necessary.
  To remain compatible with current behavior, for binary FP the code
  instead tries to re-interpret the input value as a FP type of the
  same size if that exists.  (Maybe this behavior is more confusing
  than useful -- but this can be changed later if we want to ...)

- Finally, we can use floatformat_to_string / decimal_to_string passing
  the format string to perform the formatted output using the desired
  target FP type.

Note that we no longer generate different code depending on whether or not
the host supports "long double" -- this check is obsolete anyway since C++11
mandates "long double", and in any case a %lg format string is intended to
refer to the *target* long double type, not the host version.

Note also that formatted printing of DFP numbers may not work correctly,
since it attempts to use the host printf to do so (and makes unwarranted
assumptions about the host ABI while doing so!).  This is no change to
the current behavior -- I simply moved the code from printf_decfloat to
the decimal_to_string routine in dfp.c.  If we want to fix it in the
future, that is a more appropriate place anyway.

ChangeLog:
2017-10-24  Ulrich Weigand  <uweigand@de.ibm.com>

	* common/format.h (enum argclass): Replace decfloat_arg by
	dec32float_arg, dec64float_arg, and dec128float_arg.
	* common/format.c (parse_format_string): Update to return
	new decimal float argument classes.

	* printcmd.c (printf_decfloat): Rename to ...
	(printf_floating): ... this.  Add argclass argument, and use it
	instead of parsing the format string again.  Add support for
	binary floating-point values, using floatformat_to_string.
	Convert value to the target format if it doesn't already match.
	(ui_printf): Call printf_floating instead of printf_decfloat,
	also for double_arg / long_double_arg.  Pass argclass.

	* dfp.c (decimal_to_string): Add format string argument.
	* dfp.h (decimal_to_string): Likewise.

	* doublest.c (floatformat_to_string): Add format string argument.
	* doublest.h (floatformat_to_string): Likewise.
2017-10-24 18:00:50 +02:00
Ulrich Weigand fdf0cbc2b7 Target FP printing: Simplify and fix print_floating
The print_floating routine currently makes a lot of assumptions about host
and target floating point formats.  This patch cleans up many of those.

One problem is that print_floating may currently be called with types
that are not actually floating-point types, and it tries hard to output
those as floating-point values anyway.  However, there is only one single
caller of print_floating where this can ever happen: print_scalar_formatted.
And in fact, it is much simpler to handle the case where the value to be
printed is not already of floating-point type right there.

So this patch changes print_scalar_formatted to handle the 'f' format
as follows:

- If the value to be printed is already of floating-point type, just
  call print_floating on it.

- Otherwise, if there is a standard target floating-point type of
  the same size as the value, call print_floating using that type.

- Otherwise, just print the value as if the 'f' format had not been
  specified at all.

This has the overall effect to printing everything the same way as
the old code did, but is overall a lot simpler.  (Also, it would
allow us to change the above strategy more easily, if that might
be a more intuitive user interface.  For example, in the third
case above, maybe an error would be more appropriate?)

Given that change, print_floating can become much simpler.  In particular,
we now always have a floating-point format that we can consult.  This
means we can use the floating-point format to programmatically determine
the number of digits necessary to print the value.

The current code uses a hard-coded value of 9, 17, or 35 digits.  Note
that this matches the DECIMAL_DIG values for IEEE-32, IEEE-64, and
IEEE-128.  (Actually, for IEEE-128 the correct value is 36 -- the 35
seems to be an oversight.)  The DECIMAL_DIG value is defined to be
the smallest number so that any number in the target format, when
printed to this number of digits and then scanned back into a binary
floating-point number, will result in the original value.

Now that we always have a FP format, we can just compute the DECIMAL_DIG
value using the formula from the C standard.  This will be correct for
*all* FP formats, not just the above list, and it will be correct (as
opposed to current code) if the target formats differ from the host ones.

The patch moves the new logic to a new floatformat_to_string routine
(analogous to the existing decimal_to_string).  The print_floating
routine now calls floatformat_to_string or decimal_to_string, making
the separate print_decimal_floating and generic_val_print_decfloat routines
unnecessary.

gdb/ChangeLog:
2017-10-24  Ulrich Weigand  <uweigand@de.ibm.com>

	* doublest.c (floatformat_precision): New routine.
	(floatformat_to_string): Likewise.
	* doublest.c (floatformat_to_string): Add prototype.

	* printcmd.c (print_scalar_formatted): Only call print_floating
	on floating-point types.
	* valprint.c: Do not include "floatformat.h".
	(generic_val_print_decfloat): Remove.
	(generic_val_print): Call generic_val_print_float for both
	TYPE_CODE_FLT and TYPE_CODE_DECFLOAT.
	(print_floating): Use floatformat_to_string.  Handle decimal float.
	(print_decimal_floating): Remove, merge into floatformat_to_string.
	* value.h (print_decimal_floating): Remove.

	* Makefile.in: Do not build doublest.c with -Wformat-nonliteral.
2017-10-24 17:59:22 +02:00
Andrew Waterman 3342be5dab RISC-V: Only relax to C.LUI when imm != 0 and rd != 0/2
This matches the ISA specification.  This also adds two tests: one to
make sure the assembler rejects invalid 'c.lui's, and one to make sure
we only relax valid 'c.lui's.

bfd/ChangeLog

2017-10-24  Andrew Waterman  <andrew@sifive.com>

        * elfnn-riscv.c (_bfd_riscv_relax_lui): Don't relax to c.lui
        when rd is x0.

include/ChangeLog

2017-10-24  Andrew Waterman  <andrew@sifive.com>

        * opcode/riscv.h (VALID_RVC_LUI_IMM): c.lui can't load the
        immediate 0.

gas/ChangeLog

2017-10-24  Andrew Waterman  <andrew@sifive.com>

        * testsuite/gas/riscv/c-lui-fail.d: New testcase.
        gas/testsuite/gas/riscv/c-lui-fail.l: Likewise.
        gas/testsuite/gas/riscv/c-lui-fail.s: Likewise.
        gas/testsuite/gas/riscv/riscv.exp: Likewise.

ld/ChangeLog

2017-10-24  Andrew Waterman  <andrew@sifive.com>

        * ld/testsuite/ld-riscv-elf/c-lui.d: New testcase.
        ld/testsuite/ld-riscv-elf/c-lui.s: Likewise.
        ld/testsuite/ld-riscv-elf/ld-riscv-elf.exp: New test suite.
2017-10-24 08:02:46 -07:00
Palmer Dabbelt 3779bbe01b Fix my previous gas/ChangeLog entry 2017-10-24 08:02:42 -07:00