aboutsummaryrefslogtreecommitdiff
path: root/gdb/target-float.c
AgeCommit message (Collapse)AuthorFilesLines
2024-01-12Update copyright year range in header of all files managed by GDBAndrew Burgess1-1/+1
This commit is the result of the following actions: - Running gdb/copyright.py to update all of the copyright headers to include 2024, - Manually updating a few files the copyright.py script told me to update, these files had copyright headers embedded within the file, - Regenerating gdbsupport/Makefile.in to refresh it's copyright date, - Using grep to find other files that still mentioned 2023. If these files were updated last year from 2022 to 2023 then I've updated them this year to 2024. I'm sure I've probably missed some dates. Feel free to fix them up as you spot them.
2023-01-01Update copyright year range in header of all files managed by GDBJoel Brobecker1-1/+1
This commit is the result of running the gdb/copyright.py script, which automated the update of the copyright year range for all source files managed by the GDB project to be updated to include year 2023.
2022-12-21Use toplevel configure for GMP and MPFR for gdbAndrew Pinski1-8/+0
This patch uses the toplevel configure parts for GMP/MPFR for gdb. The only thing is that gdb now requires MPFR for building. Before it was a recommended but not required library. Also this allows building of GMP and MPFR with the toplevel directory just like how it is done for GCC. We now error out in the toplevel configure of the version of GMP and MPFR that is wrong. OK after GDB 13 branches? Build gdb 3 ways: with GMP and MPFR in the toplevel (static library used at that point for both) With only MPFR in the toplevel (GMP distro library used and MPFR built from source) With neither GMP and MPFR in the toplevel (distro libraries used) Changes from v1: * Updated gdb/README and gdb/doc/gdb.texinfo. * Regenerated using unmodified autoconf-2.69 Thanks, Andrew Pinski ChangeLog: * Makefile.def: Add configure-gdb dependencies on all-gmp and all-mpfr. * configure.ac: Split out MPC checking from MPFR. Require GMP and MPFR if the gdb directory exist. * Makefile.in: Regenerate. * configure: Regenerate. gdb/ChangeLog: PR bug/28500 * configure.ac: Remove AC_LIB_HAVE_LINKFLAGS for gmp and mpfr. Use GMPLIBS and GMPINC which is provided by the toplevel configure. * Makefile.in (LIBGMP, LIBMPFR): Remove. (GMPLIBS, GMPINC): Add definition. (INTERNAL_CFLAGS_BASE): Add GMPINC. (CLIBS): Exchange LIBMPFR and LIBGMP for GMPLIBS. * target-float.c: Make the code conditional on HAVE_LIBMPFR unconditional. * top.c: Remove code checking HAVE_LIBMPFR. * configure: Regenerate. * config.in: Regenerate. * README: Update GMP/MPFR section of the config options. * doc/gdb.texinfo: Likewise. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28500
2022-09-21gdb: remove TYPE_LENGTHSimon Marchi1-12/+12
Remove the macro, replace all uses with calls to type::length. Change-Id: Ib9bdc954576860b21190886534c99103d6a47afb
2022-01-01Automatic Copyright Year update after running gdb/copyright.pyJoel Brobecker1-1/+1
This commit brings all the changes made by running gdb/copyright.py as per GDB's Start of New Year Procedure. For the avoidance of doubt, all changes in this commits were performed by the script.
2021-05-27gdb: fix some indentation issuesSimon Marchi1-5/+5
I wrote a small script to spot a pattern of indentation mistakes I saw happened in breakpoint.c. And while at it I ran it on all files and fixed what I found. No behavior changes intended, just indentation and addition / removal of curly braces. gdb/ChangeLog: * Fix some indentation mistakes throughout. gdbserver/ChangeLog: * Fix some indentation mistakes throughout. Change-Id: Ia01990c26c38e83a243d8f33da1d494f16315c6e
2021-01-02gdb: fix typos in comments in target-float.cSimon Marchi1-2/+2
gdb/ChangeLog: * target-float.c: Fix typos. Change-Id: Ib65e90746d0a7c77c3fbead81139facb40b91977
2021-01-01Update copyright year range in all GDB filesJoel Brobecker1-1/+1
This commits the result of running gdb/copyright.py as per our Start of New Year procedure... gdb/ChangeLog Update copyright year range in copyright header of all GDB files.
2020-11-02gdb, gdbserver, gdbsupport: fix leading space vs tabs issuesSimon Marchi1-41/+41
Many spots incorrectly use only spaces for indentation (for example, there are a lot of spots in ada-lang.c). I've always found it awkward when I needed to edit one of these spots: do I keep the original wrong indentation, or do I fix it? What if the lines around it are also wrong, do I fix them too? I probably don't want to fix them in the same patch, to avoid adding noise to my patch. So I propose to fix as much as possible once and for all (hopefully). One typical counter argument for this is that it makes code archeology more difficult, because git-blame will show this commit as the last change for these lines. My counter counter argument is: when git-blaming, you often need to do "blame the file at the parent commit" anyway, to go past some other refactor that touched the line you are interested in, but is not the change you are looking for. So you already need a somewhat efficient way to do this. Using some interactive tool, rather than plain git-blame, makes this trivial. For example, I use "tig blame <file>", where going back past the commit that changed the currently selected line is one keystroke. It looks like Magit in Emacs does it too (though I've never used it). Web viewers of Github and Gitlab do it too. My point is that it won't really make archeology more difficult. The other typical counter argument is that it will cause conflicts with existing patches. That's true... but it's a one time cost, and those are not conflicts that are difficult to resolve. I have also tried "git rebase --ignore-whitespace", it seems to work well. Although that will re-introduce the faulty indentation, so one needs to take care of fixing the indentation in the patch after that (which is easy). gdb/ChangeLog: * aarch64-linux-tdep.c: Fix indentation. * aarch64-ravenscar-thread.c: Fix indentation. * aarch64-tdep.c: Fix indentation. * aarch64-tdep.h: Fix indentation. * ada-lang.c: Fix indentation. * ada-lang.h: Fix indentation. * ada-tasks.c: Fix indentation. * ada-typeprint.c: Fix indentation. * ada-valprint.c: Fix indentation. * ada-varobj.c: Fix indentation. * addrmap.c: Fix indentation. * addrmap.h: Fix indentation. * agent.c: Fix indentation. * aix-thread.c: Fix indentation. * alpha-bsd-nat.c: Fix indentation. * alpha-linux-tdep.c: Fix indentation. * alpha-mdebug-tdep.c: Fix indentation. * alpha-nbsd-tdep.c: Fix indentation. * alpha-obsd-tdep.c: Fix indentation. * alpha-tdep.c: Fix indentation. * amd64-bsd-nat.c: Fix indentation. * amd64-darwin-tdep.c: Fix indentation. * amd64-linux-nat.c: Fix indentation. * amd64-linux-tdep.c: Fix indentation. * amd64-nat.c: Fix indentation. * amd64-obsd-tdep.c: Fix indentation. * amd64-tdep.c: Fix indentation. * amd64-windows-tdep.c: Fix indentation. * annotate.c: Fix indentation. * arc-tdep.c: Fix indentation. * arch-utils.c: Fix indentation. * arch/arm-get-next-pcs.c: Fix indentation. * arch/arm.c: Fix indentation. * arm-linux-nat.c: Fix indentation. * arm-linux-tdep.c: Fix indentation. * arm-nbsd-tdep.c: Fix indentation. * arm-pikeos-tdep.c: Fix indentation. * arm-tdep.c: Fix indentation. * arm-tdep.h: Fix indentation. * arm-wince-tdep.c: Fix indentation. * auto-load.c: Fix indentation. * auxv.c: Fix indentation. * avr-tdep.c: Fix indentation. * ax-gdb.c: Fix indentation. * ax-general.c: Fix indentation. * bfin-linux-tdep.c: Fix indentation. * block.c: Fix indentation. * block.h: Fix indentation. * blockframe.c: Fix indentation. * bpf-tdep.c: Fix indentation. * break-catch-sig.c: Fix indentation. * break-catch-syscall.c: Fix indentation. * break-catch-throw.c: Fix indentation. * breakpoint.c: Fix indentation. * breakpoint.h: Fix indentation. * bsd-uthread.c: Fix indentation. * btrace.c: Fix indentation. * build-id.c: Fix indentation. * buildsym-legacy.h: Fix indentation. * buildsym.c: Fix indentation. * c-typeprint.c: Fix indentation. * c-valprint.c: Fix indentation. * c-varobj.c: Fix indentation. * charset.c: Fix indentation. * cli/cli-cmds.c: Fix indentation. * cli/cli-decode.c: Fix indentation. * cli/cli-decode.h: Fix indentation. * cli/cli-script.c: Fix indentation. * cli/cli-setshow.c: Fix indentation. * coff-pe-read.c: Fix indentation. * coffread.c: Fix indentation. * compile/compile-cplus-types.c: Fix indentation. * compile/compile-object-load.c: Fix indentation. * compile/compile-object-run.c: Fix indentation. * completer.c: Fix indentation. * corefile.c: Fix indentation. * corelow.c: Fix indentation. * cp-abi.h: Fix indentation. * cp-namespace.c: Fix indentation. * cp-support.c: Fix indentation. * cp-valprint.c: Fix indentation. * cris-linux-tdep.c: Fix indentation. * cris-tdep.c: Fix indentation. * darwin-nat-info.c: Fix indentation. * darwin-nat.c: Fix indentation. * darwin-nat.h: Fix indentation. * dbxread.c: Fix indentation. * dcache.c: Fix indentation. * disasm.c: Fix indentation. * dtrace-probe.c: Fix indentation. * dwarf2/abbrev.c: Fix indentation. * dwarf2/attribute.c: Fix indentation. * dwarf2/expr.c: Fix indentation. * dwarf2/frame.c: Fix indentation. * dwarf2/index-cache.c: Fix indentation. * dwarf2/index-write.c: Fix indentation. * dwarf2/line-header.c: Fix indentation. * dwarf2/loc.c: Fix indentation. * dwarf2/macro.c: Fix indentation. * dwarf2/read.c: Fix indentation. * dwarf2/read.h: Fix indentation. * elfread.c: Fix indentation. * eval.c: Fix indentation. * event-top.c: Fix indentation. * exec.c: Fix indentation. * exec.h: Fix indentation. * expprint.c: Fix indentation. * f-lang.c: Fix indentation. * f-typeprint.c: Fix indentation. * f-valprint.c: Fix indentation. * fbsd-nat.c: Fix indentation. * fbsd-tdep.c: Fix indentation. * findvar.c: Fix indentation. * fork-child.c: Fix indentation. * frame-unwind.c: Fix indentation. * frame-unwind.h: Fix indentation. * frame.c: Fix indentation. * frv-linux-tdep.c: Fix indentation. * frv-tdep.c: Fix indentation. * frv-tdep.h: Fix indentation. * ft32-tdep.c: Fix indentation. * gcore.c: Fix indentation. * gdb_bfd.c: Fix indentation. * gdbarch.sh: Fix indentation. * gdbarch.c: Re-generate * gdbarch.h: Re-generate. * gdbcore.h: Fix indentation. * gdbthread.h: Fix indentation. * gdbtypes.c: Fix indentation. * gdbtypes.h: Fix indentation. * glibc-tdep.c: Fix indentation. * gnu-nat.c: Fix indentation. * gnu-nat.h: Fix indentation. * gnu-v2-abi.c: Fix indentation. * gnu-v3-abi.c: Fix indentation. * go32-nat.c: Fix indentation. * guile/guile-internal.h: Fix indentation. * guile/scm-cmd.c: Fix indentation. * guile/scm-frame.c: Fix indentation. * guile/scm-iterator.c: Fix indentation. * guile/scm-math.c: Fix indentation. * guile/scm-ports.c: Fix indentation. * guile/scm-pretty-print.c: Fix indentation. * guile/scm-value.c: Fix indentation. * h8300-tdep.c: Fix indentation. * hppa-linux-nat.c: Fix indentation. * hppa-linux-tdep.c: Fix indentation. * hppa-nbsd-nat.c: Fix indentation. * hppa-nbsd-tdep.c: Fix indentation. * hppa-obsd-nat.c: Fix indentation. * hppa-tdep.c: Fix indentation. * hppa-tdep.h: Fix indentation. * i386-bsd-nat.c: Fix indentation. * i386-darwin-nat.c: Fix indentation. * i386-darwin-tdep.c: Fix indentation. * i386-dicos-tdep.c: Fix indentation. * i386-gnu-nat.c: Fix indentation. * i386-linux-nat.c: Fix indentation. * i386-linux-tdep.c: Fix indentation. * i386-nto-tdep.c: Fix indentation. * i386-obsd-tdep.c: Fix indentation. * i386-sol2-nat.c: Fix indentation. * i386-tdep.c: Fix indentation. * i386-tdep.h: Fix indentation. * i386-windows-tdep.c: Fix indentation. * i387-tdep.c: Fix indentation. * i387-tdep.h: Fix indentation. * ia64-libunwind-tdep.c: Fix indentation. * ia64-libunwind-tdep.h: Fix indentation. * ia64-linux-nat.c: Fix indentation. * ia64-linux-tdep.c: Fix indentation. * ia64-tdep.c: Fix indentation. * ia64-tdep.h: Fix indentation. * ia64-vms-tdep.c: Fix indentation. * infcall.c: Fix indentation. * infcmd.c: Fix indentation. * inferior.c: Fix indentation. * infrun.c: Fix indentation. * iq2000-tdep.c: Fix indentation. * language.c: Fix indentation. * linespec.c: Fix indentation. * linux-fork.c: Fix indentation. * linux-nat.c: Fix indentation. * linux-tdep.c: Fix indentation. * linux-thread-db.c: Fix indentation. * lm32-tdep.c: Fix indentation. * m2-lang.c: Fix indentation. * m2-typeprint.c: Fix indentation. * m2-valprint.c: Fix indentation. * m32c-tdep.c: Fix indentation. * m32r-linux-tdep.c: Fix indentation. * m32r-tdep.c: Fix indentation. * m68hc11-tdep.c: Fix indentation. * m68k-bsd-nat.c: Fix indentation. * m68k-linux-nat.c: Fix indentation. * m68k-linux-tdep.c: Fix indentation. * m68k-tdep.c: Fix indentation. * machoread.c: Fix indentation. * macrocmd.c: Fix indentation. * macroexp.c: Fix indentation. * macroscope.c: Fix indentation. * macrotab.c: Fix indentation. * macrotab.h: Fix indentation. * main.c: Fix indentation. * mdebugread.c: Fix indentation. * mep-tdep.c: Fix indentation. * mi/mi-cmd-catch.c: Fix indentation. * mi/mi-cmd-disas.c: Fix indentation. * mi/mi-cmd-env.c: Fix indentation. * mi/mi-cmd-stack.c: Fix indentation. * mi/mi-cmd-var.c: Fix indentation. * mi/mi-cmds.c: Fix indentation. * mi/mi-main.c: Fix indentation. * mi/mi-parse.c: Fix indentation. * microblaze-tdep.c: Fix indentation. * minidebug.c: Fix indentation. * minsyms.c: Fix indentation. * mips-linux-nat.c: Fix indentation. * mips-linux-tdep.c: Fix indentation. * mips-nbsd-tdep.c: Fix indentation. * mips-tdep.c: Fix indentation. * mn10300-linux-tdep.c: Fix indentation. * mn10300-tdep.c: Fix indentation. * moxie-tdep.c: Fix indentation. * msp430-tdep.c: Fix indentation. * namespace.h: Fix indentation. * nat/fork-inferior.c: Fix indentation. * nat/gdb_ptrace.h: Fix indentation. * nat/linux-namespaces.c: Fix indentation. * nat/linux-osdata.c: Fix indentation. * nat/netbsd-nat.c: Fix indentation. * nat/x86-dregs.c: Fix indentation. * nbsd-nat.c: Fix indentation. * nbsd-tdep.c: Fix indentation. * nios2-linux-tdep.c: Fix indentation. * nios2-tdep.c: Fix indentation. * nto-procfs.c: Fix indentation. * nto-tdep.c: Fix indentation. * objfiles.c: Fix indentation. * objfiles.h: Fix indentation. * opencl-lang.c: Fix indentation. * or1k-tdep.c: Fix indentation. * osabi.c: Fix indentation. * osabi.h: Fix indentation. * osdata.c: Fix indentation. * p-lang.c: Fix indentation. * p-typeprint.c: Fix indentation. * p-valprint.c: Fix indentation. * parse.c: Fix indentation. * ppc-linux-nat.c: Fix indentation. * ppc-linux-tdep.c: Fix indentation. * ppc-nbsd-nat.c: Fix indentation. * ppc-nbsd-tdep.c: Fix indentation. * ppc-obsd-nat.c: Fix indentation. * ppc-ravenscar-thread.c: Fix indentation. * ppc-sysv-tdep.c: Fix indentation. * ppc64-tdep.c: Fix indentation. * printcmd.c: Fix indentation. * proc-api.c: Fix indentation. * producer.c: Fix indentation. * producer.h: Fix indentation. * prologue-value.c: Fix indentation. * prologue-value.h: Fix indentation. * psymtab.c: Fix indentation. * python/py-arch.c: Fix indentation. * python/py-bpevent.c: Fix indentation. * python/py-event.c: Fix indentation. * python/py-event.h: Fix indentation. * python/py-finishbreakpoint.c: Fix indentation. * python/py-frame.c: Fix indentation. * python/py-framefilter.c: Fix indentation. * python/py-inferior.c: Fix indentation. * python/py-infthread.c: Fix indentation. * python/py-objfile.c: Fix indentation. * python/py-prettyprint.c: Fix indentation. * python/py-registers.c: Fix indentation. * python/py-signalevent.c: Fix indentation. * python/py-stopevent.c: Fix indentation. * python/py-stopevent.h: Fix indentation. * python/py-threadevent.c: Fix indentation. * python/py-tui.c: Fix indentation. * python/py-unwind.c: Fix indentation. * python/py-value.c: Fix indentation. * python/py-xmethods.c: Fix indentation. * python/python-internal.h: Fix indentation. * python/python.c: Fix indentation. * ravenscar-thread.c: Fix indentation. * record-btrace.c: Fix indentation. * record-full.c: Fix indentation. * record.c: Fix indentation. * reggroups.c: Fix indentation. * regset.h: Fix indentation. * remote-fileio.c: Fix indentation. * remote.c: Fix indentation. * reverse.c: Fix indentation. * riscv-linux-tdep.c: Fix indentation. * riscv-ravenscar-thread.c: Fix indentation. * riscv-tdep.c: Fix indentation. * rl78-tdep.c: Fix indentation. * rs6000-aix-tdep.c: Fix indentation. * rs6000-lynx178-tdep.c: Fix indentation. * rs6000-nat.c: Fix indentation. * rs6000-tdep.c: Fix indentation. * rust-lang.c: Fix indentation. * rx-tdep.c: Fix indentation. * s12z-tdep.c: Fix indentation. * s390-linux-tdep.c: Fix indentation. * score-tdep.c: Fix indentation. * ser-base.c: Fix indentation. * ser-mingw.c: Fix indentation. * ser-uds.c: Fix indentation. * ser-unix.c: Fix indentation. * serial.c: Fix indentation. * sh-linux-tdep.c: Fix indentation. * sh-nbsd-tdep.c: Fix indentation. * sh-tdep.c: Fix indentation. * skip.c: Fix indentation. * sol-thread.c: Fix indentation. * solib-aix.c: Fix indentation. * solib-darwin.c: Fix indentation. * solib-frv.c: Fix indentation. * solib-svr4.c: Fix indentation. * solib.c: Fix indentation. * source.c: Fix indentation. * sparc-linux-tdep.c: Fix indentation. * sparc-nbsd-tdep.c: Fix indentation. * sparc-obsd-tdep.c: Fix indentation. * sparc-ravenscar-thread.c: Fix indentation. * sparc-tdep.c: Fix indentation. * sparc64-linux-tdep.c: Fix indentation. * sparc64-nbsd-tdep.c: Fix indentation. * sparc64-obsd-tdep.c: Fix indentation. * sparc64-tdep.c: Fix indentation. * stabsread.c: Fix indentation. * stack.c: Fix indentation. * stap-probe.c: Fix indentation. * stubs/ia64vms-stub.c: Fix indentation. * stubs/m32r-stub.c: Fix indentation. * stubs/m68k-stub.c: Fix indentation. * stubs/sh-stub.c: Fix indentation. * stubs/sparc-stub.c: Fix indentation. * symfile-mem.c: Fix indentation. * symfile.c: Fix indentation. * symfile.h: Fix indentation. * symmisc.c: Fix indentation. * symtab.c: Fix indentation. * symtab.h: Fix indentation. * target-float.c: Fix indentation. * target.c: Fix indentation. * target.h: Fix indentation. * tic6x-tdep.c: Fix indentation. * tilegx-linux-tdep.c: Fix indentation. * tilegx-tdep.c: Fix indentation. * top.c: Fix indentation. * tracefile-tfile.c: Fix indentation. * tracepoint.c: Fix indentation. * tui/tui-disasm.c: Fix indentation. * tui/tui-io.c: Fix indentation. * tui/tui-regs.c: Fix indentation. * tui/tui-stack.c: Fix indentation. * tui/tui-win.c: Fix indentation. * tui/tui-winsource.c: Fix indentation. * tui/tui.c: Fix indentation. * typeprint.c: Fix indentation. * ui-out.h: Fix indentation. * unittests/copy_bitwise-selftests.c: Fix indentation. * unittests/memory-map-selftests.c: Fix indentation. * utils.c: Fix indentation. * v850-tdep.c: Fix indentation. * valarith.c: Fix indentation. * valops.c: Fix indentation. * valprint.c: Fix indentation. * valprint.h: Fix indentation. * value.c: Fix indentation. * value.h: Fix indentation. * varobj.c: Fix indentation. * vax-tdep.c: Fix indentation. * windows-nat.c: Fix indentation. * windows-tdep.c: Fix indentation. * xcoffread.c: Fix indentation. * xml-syscall.c: Fix indentation. * xml-tdesc.c: Fix indentation. * xstormy16-tdep.c: Fix indentation. * xtensa-config.c: Fix indentation. * xtensa-linux-nat.c: Fix indentation. * xtensa-linux-tdep.c: Fix indentation. * xtensa-tdep.c: Fix indentation. gdbserver/ChangeLog: * ax.cc: Fix indentation. * dll.cc: Fix indentation. * inferiors.h: Fix indentation. * linux-low.cc: Fix indentation. * linux-nios2-low.cc: Fix indentation. * linux-ppc-ipa.cc: Fix indentation. * linux-ppc-low.cc: Fix indentation. * linux-x86-low.cc: Fix indentation. * linux-xtensa-low.cc: Fix indentation. * regcache.cc: Fix indentation. * server.cc: Fix indentation. * tracepoint.cc: Fix indentation. gdbsupport/ChangeLog: * common-exceptions.h: Fix indentation. * event-loop.cc: Fix indentation. * fileio.cc: Fix indentation. * filestuff.cc: Fix indentation. * gdb-dlfcn.cc: Fix indentation. * gdb_string_view.h: Fix indentation. * job-control.cc: Fix indentation. * signals.cc: Fix indentation. Change-Id: I4bad7ae6be0fbe14168b8ebafb98ffe14964a695
2020-05-14gdb: remove TYPE_CODE macroSimon Marchi1-12/+12
Remove TYPE_CODE, changing all the call sites to use type::code directly. This is quite a big diff, but this was mostly done using sed and coccinelle. A few call sites were done by hand. gdb/ChangeLog: * gdbtypes.h (TYPE_CODE): Remove. Change all call sites to use type::code instead.
2020-01-01Update copyright year range in all GDB files.Joel Brobecker1-1/+1
gdb/ChangeLog: Update copyright year range in all GDB files.
2019-12-13Silence ARI warning about floatformat_to_doubleTom Tromey1-2/+2
This silences ARI at the one spot that is permitted to call floatformat_to_double, and also removes the corresponding "fix" call from gdb_ari.sh -- it was incorrect, and now is not needed. gdb/ChangeLog 2019-12-13 Tom Tromey <tromey@adacore.com> * contrib/ari/gdb_ari.sh: Remove "fix" call for floatformat_to_double. * target-float.c (host_float_ops<T>::from_target): Add ARI comment. Change-Id: I778a17a04da417c113194004dd7de3b1df381266
2019-11-21Adjust byte order variable display/change if DW_AT_endianity is present.Peeter Joot1-3/+3
- Rationale: It is possible for compilers to indicate the desired byte order interpretation of scalar variables using the DWARF attribute: DW_AT_endianity A type flagged with this variable would typically use one of: DW_END_big DW_END_little which instructs the debugger what the desired byte order interpretation of the variable should be. The GCC compiler (as of V6) has a mechanism for setting the desired byte ordering of the fields within a structure or union. For, example, on a little endian target, a structure declared as: struct big { int v; short a[4]; } __attribute__( ( scalar_storage_order( "big-endian" ) ) ); could be used to ensure all the structure members have a big-endian interpretation (the compiler would automatically insert byte swap instructions before and after respective store and load instructions). - To reproduce GCC V8 is required to correctly emit DW_AT_endianity DWARF attributes in all situations when the scalar_storage_order attribute is used. A fix for (dwarf endianity instrumentation) for GCC V6-V7 can be found in the URL field of the following PR: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82509 - Test-case: A new test case (testsuite/gdb.base/endianity.*) is included with this patch. Manual testing for mixed endianity code has also been done with GCC V8. See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82509#c4 - Observed vs. expected: Without this change, using scalar_storage_order that doesn't match the target, such as struct otherendian { int v; } __attribute__( ( scalar_storage_order( "big-endian" ) ) ); would behave like the following on a little endian target: Breakpoint 1 at 0x401135: file endianity.c, line 41. (gdb) run Starting program: /home/pjoot/freeware/t/a.out Missing separate debuginfos, use: debuginfo-install glibc-2.17-292.el7.x86_64 Breakpoint 1, main () at endianity.c:41 41 struct otherendian o = {3}; (gdb) n 43 do_nothing (&o); /* START */ (gdb) p o $1 = {v = 50331648} (gdb) p /x $2 = {v = 0x3000000} whereas with this gdb enhancement we can access the variable with the user specified endianity: Breakpoint 1, main () at endianity.c:41 41 struct otherendian o = {3}; (gdb) p o $1 = {v = 0} (gdb) n 43 do_nothing (&o); /* START */ (gdb) p o $2 = {v = 3} (gdb) p o.v = 4 $3 = 4 (gdb) p o.v $4 = 4 (gdb) x/4xb &o.v 0x7fffffffd90c: 0x00 0x00 0x00 0x04 (observe that the 4 byte int variable has a big endian representation in the hex dump.) gdb/ChangeLog 2019-11-21 Peeter Joot <peeter.joot@lzlabs.com> Byte reverse display of variables with DW_END_big, DW_END_little (DW_AT_endianity) dwarf attributes if different than the native byte order. * ada-lang.c (ada_value_binop): Use type_byte_order instead of gdbarch_byte_order. * ada-valprint.c (printstr): (ada_val_print_string): * ada-lang.c (value_pointer): (ada_value_binop): Use type_byte_order instead of gdbarch_byte_order. * c-lang.c (c_get_string): Use type_byte_order instead of gdbarch_byte_order. * c-valprint.c (c_val_print_array): Use type_byte_order instead of gdbarch_byte_order. * cp-valprint.c (cp_print_class_member): Use type_byte_order instead of gdbarch_byte_order. * dwarf2loc.c (rw_pieced_value): Use type_byte_order instead of gdbarch_byte_order. * dwarf2read.c (read_base_type): Handle DW_END_big, DW_END_little * f-lang.c (f_get_encoding): Use type_byte_order instead of gdbarch_byte_order. * findvar.c (default_read_var_value): Use type_byte_order instead of gdbarch_byte_order. * gdbtypes.c (check_types_equal): Require matching TYPE_ENDIANITY_NOT_DEFAULT if set. (recursive_dump_type): Print TYPE_ENDIANITY_BIG, and TYPE_ENDIANITY_LITTLE if set. (type_byte_order): new function. * gdbtypes.h (TYPE_ENDIANITY_NOT_DEFAULT): New macro. (struct main_type) <flag_endianity_not_default>: New field. (type_byte_order): New function. * infcmd.c (default_print_one_register_info): Use type_byte_order instead of gdbarch_byte_order. * p-lang.c (pascal_printstr): Use type_byte_order instead of gdbarch_byte_order. * p-valprint.c (pascal_val_print): Use type_byte_order instead of gdbarch_byte_order. * printcmd.c (print_scalar_formatted): Use type_byte_order instead of gdbarch_byte_order. * solib-darwin.c (darwin_current_sos): Use type_byte_order instead of gdbarch_byte_order. * solib-svr4.c (solib_svr4_r_ldsomap): Use type_byte_order instead of gdbarch_byte_order. * stap-probe.c (stap_modify_semaphore): Use type_byte_order instead of gdbarch_byte_order. * target-float.c (target_float_same_format_p): Use type_byte_order instead of gdbarch_byte_order. * valarith.c (scalar_binop): (value_bit_index): Use type_byte_order instead of gdbarch_byte_order. * valops.c (value_cast): Use type_byte_order instead of gdbarch_byte_order. * valprint.c (generic_emit_char): (generic_printstr): (val_print_string): Use type_byte_order instead of gdbarch_byte_order. * value.c (unpack_long): (unpack_bits_as_long): (unpack_value_bitfield): (modify_field): (pack_long): (pack_unsigned_long): Use type_byte_order instead of gdbarch_byte_order. * findvar.c (unsigned_pointer_to_address): (signed_pointer_to_address): (unsigned_address_to_pointer): (address_to_signed_pointer): (default_read_var_value): (default_value_from_register): Use type_byte_order instead of gdbarch_byte_order. * gnu-v3-abi.c (gnuv3_make_method_ptr): Use type_byte_order instead of gdbarch_byte_order. * riscv-tdep.c (riscv_print_one_register_info): Use type_byte_order instead of gdbarch_byte_order. gdb/testsuite/ChangeLog 2019-11-21 Peeter Joot <peeter.joot@lzlabs.com> * gdb.base/endianity.c: New test. * gdb.base/endianity.exp: New file. Change-Id: I4bd98c1b4508c2d7c5a5dbb15d7b7b1cb4e667e2
2019-10-18[gdb] Fix more typos in commentsTom de Vries1-1/+1
Fix typos in comments. NFC. Tested on x86_64-linux. gdb/ChangeLog: 2019-10-18 Tom de Vries <tdevries@suse.de> * aarch64-tdep.c: Fix typos in comments. * ada-lang.c: Same. * ada-tasks.c: Same. * alpha-tdep.c: Same. * alpha-tdep.h: Same. * amd64-nat.c: Same. * amd64-windows-tdep.c: Same. * arc-tdep.c: Same. * arc-tdep.h: Same. * arch-utils.c: Same. * arm-nbsd-tdep.c: Same. * arm-tdep.c: Same. * ax-gdb.c: Same. * blockframe.c: Same. * btrace.c: Same. * c-varobj.c: Same. * coff-pe-read.c: Same. * coffread.c: Same. * cris-tdep.c: Same. * darwin-nat.c: Same. * dbxread.c: Same. * dcache.c: Same. * disasm.c: Same. * dtrace-probe.c: Same. * dwarf-index-write.c: Same. * dwarf2-frame-tailcall.c: Same. * dwarf2-frame.c: Same. * dwarf2read.c: Same. * eval.c: Same. * exceptions.c: Same. * fbsd-tdep.c: Same. * findvar.c: Same. * frame.c: Same. * frv-tdep.c: Same. * gnu-v3-abi.c: Same. * go32-nat.c: Same. * h8300-tdep.c: Same. * hppa-tdep.c: Same. * i386-linux-tdep.c: Same. * i386-tdep.c: Same. * ia64-libunwind-tdep.c: Same. * ia64-tdep.c: Same. * infcmd.c: Same. * infrun.c: Same. * linespec.c: Same. * linux-nat.c: Same. * linux-thread-db.c: Same. * machoread.c: Same. * mdebugread.c: Same. * mep-tdep.c: Same. * mn10300-tdep.c: Same. * namespace.c: Same. * objfiles.c: Same. * opencl-lang.c: Same. * or1k-tdep.c: Same. * osabi.c: Same. * ppc-linux-nat.c: Same. * ppc-linux-tdep.c: Same. * ppc-sysv-tdep.c: Same. * printcmd.c: Same. * procfs.c: Same. * record-btrace.c: Same. * record-full.c: Same. * remote-fileio.c: Same. * remote.c: Same. * rs6000-tdep.c: Same. * s12z-tdep.c: Same. * score-tdep.c: Same. * ser-base.c: Same. * ser-go32.c: Same. * skip.c: Same. * sol-thread.c: Same. * solib-svr4.c: Same. * solib.c: Same. * source.c: Same. * sparc-nat.c: Same. * sparc-sol2-tdep.c: Same. * sparc-tdep.c: Same. * sparc64-tdep.c: Same. * stabsread.c: Same. * stack.c: Same. * symfile.c: Same. * symtab.c: Same. * target-descriptions.c: Same. * target-float.c: Same. * thread.c: Same. * utils.c: Same. * valops.c: Same. * valprint.c: Same. * value.c: Same. * varobj.c: Same. * windows-nat.c: Same. * xcoffread.c: Same. * xstormy16-tdep.c: Same. * xtensa-tdep.c: Same. Change-Id: I5175f1b107bfa4e1cdd4a3361ccb4739e53c75c4
2019-09-11Fix float to LONGEST conversion.Ali Tamur1-6/+11
The code used to have undefined behaviour when template parameter is float and host_float is NaN, because it attempted to convert NaN value to LONGEST at the last statement. This frequently caused crashes on tests that checked "info all-registers" (at least when the code is compiled with clang; I didn't test with gdb). gdb/ChangeLog: *target-float.c (host_float_ops<T>::to_longest): Update implementation.
2019-07-10Don't include gdbarch.h from defs.hTom Tromey1-1/+1
I touched symtab.h and was surprised to see how many files were rebuilt. I looked into it a bit, and found that defs.h includes gdbarch.h, which in turn includes many things. gdbarch.h is only needed by a minority ofthe files in gdb, so this patch removes the include from defs.h and updates the fallout. I did "wc -l" on the files in build/gdb/.deps; this patch reduces the line count from 139935 to 137030; so there are definitely future build-time savings here. Note that while I configured with --enable-targets=all, it's possible that some *-nat.c file needs an update. I could not test all of these. The buildbot caught a few problems along these lines. gdb/ChangeLog 2019-07-10 Tom Tromey <tom@tromey.com> * defs.h: Don't include gdbarch.h. * aarch64-ravenscar-thread.c, aarch64-tdep.c, alpha-bsd-tdep.h, alpha-linux-tdep.c, alpha-mdebug-tdep.c, arch-utils.h, arm-tdep.h, ax-general.c, btrace.c, buildsym-legacy.c, buildsym.h, c-lang.c, cli/cli-decode.h, cli/cli-dump.c, cli/cli-script.h, cli/cli-style.h, coff-pe-read.h, compile/compile-c-support.c, compile/compile-cplus.h, compile/compile-loc2c.c, corefile.c, cp-valprint.c, cris-linux-tdep.c, ctf.c, d-lang.c, d-namespace.c, dcache.c, dicos-tdep.c, dictionary.c, disasm-selftests.c, dummy-frame.c, dummy-frame.h, dwarf2-frame-tailcall.c, dwarf2expr.c, expression.h, f-lang.c, frame-base.c, frame-unwind.c, frv-linux-tdep.c, gdbarch-selftests.c, gdbtypes.h, go-lang.c, hppa-nbsd-tdep.c, hppa-obsd-tdep.c, i386-dicos-tdep.c, i386-tdep.h, ia64-vms-tdep.c, interps.h, language.c, linux-record.c, location.h, m2-lang.c, m32r-linux-tdep.c, mem-break.c, memattr.c, mn10300-linux-tdep.c, nios2-linux-tdep.c, objfiles.h, opencl-lang.c, or1k-linux-tdep.c, p-lang.c, parser-defs.h, ppc-tdep.h, probe.h, python/py-record-btrace.c, record-btrace.c, record.h, regcache-dump.c, regcache.h, riscv-fbsd-tdep.c, riscv-linux-tdep.c, rust-exp.y, sh-linux-tdep.c, sh-nbsd-tdep.c, source-cache.c, sparc-nbsd-tdep.c, sparc-obsd-tdep.c, sparc-ravenscar-thread.c, sparc64-fbsd-tdep.c, std-regs.c, target-descriptions.h, target-float.c, tic6x-linux-tdep.c, tilegx-linux-tdep.c, top.c, tracefile.c, trad-frame.c, type-stack.h, ui-style.c, utils.c, utils.h, valarith.c, valprint.c, varobj.c, x86-tdep.c, xml-support.h, xtensa-linux-tdep.c, cli/cli-cmds.h: Update. * s390-linux-nat.c, procfs.c, inf-ptrace.c: Likewise.
2019-01-01Update copyright year range in all GDB files.Joel Brobecker1-1/+1
This commit applies all changes made after running the gdb/copyright.py script. Note that one file was flagged by the script, due to an invalid copyright header (gdb/unittests/basic_string_view/element_access/char/empty.cc). As the file was copied from GCC's libstdc++-v3 testsuite, this commit leaves this file untouched for the time being; a patch to fix the header was sent to gcc-patches first. gdb/ChangeLog: Update copyright year range in all GDB files.
2018-10-04Simple -Wshadow=local fixesTom Tromey1-2/+1
This fixes all the straightforward -Wshadow=local warnings in gdb. A few standard approaches are used here: * Renaming an inner (or outer, but more commonly inner) variable; * Lowering a declaration to avoid a clash; * Moving a declaration into a more inner scope to avoid a clash, including the special case of moving a declaration into a loop header. I did not consider any of the changes in this patch to be particularly noteworthy, though of course they should all still be examined. gdb/ChangeLog 2018-10-04 Tom Tromey <tom@tromey.com> * ctf.c (SET_ARRAY_FIELD): Rename "u32". * p-valprint.c (pascal_val_print): Split inner "i" variable. * xtensa-tdep.c (xtensa_push_dummy_call): Declare "i" in loop header. * xstormy16-tdep.c (xstormy16_push_dummy_call): Declare "val" in more inner scope. * xcoffread.c (read_xcoff_symtab): Rename inner "symbol". * varobj.c (varobj_update): Rename inner "newobj", "type_changed". * valprint.c (generic_emit_char): Rename inner "buf". * valops.c (find_overload_match): Rename inner "temp". (value_struct_elt_for_reference): Declare "v" in more inner scope. * v850-tdep.c (v850_push_dummy_call): Rename "len". * unittests/array-view-selftests.c (run_tests): Rename inner "vec". * tui/tui-stack.c (tui_show_frame_info): Declare "i" in loop header. * tracepoint.c (merge_uploaded_trace_state_variables): Declare "tsv" in more inner scope. (print_one_static_tracepoint_marker): Rename inner "tuple_emitter". * tic6x-tdep.c (tic6x_analyze_prologue): Declare "inst" lower. (tic6x_push_dummy_call): Don't redeclare "addr". * target-float.c: Declare "dto" lower. * symtab.c (lookup_local_symbol): Rename inner "sym". (find_pc_sect_line): Rename inner "pc". * stack.c (print_frame): Don't redeclare "gdbarch". (return_command): Rename inner "gdbarch". * s390-tdep.c (s390_prologue_frame_unwind_cache): Renam inner "sp". * rust-lang.c (rust_internal_print_type): Declare "i" in loop header. * rs6000-tdep.c (ppc_process_record): Rename inner "addr". * riscv-tdep.c (riscv_push_dummy_call): Declare "info" in inner scope. * remote.c (remote_target::update_thread_list): Don't redeclare "tp". (remote_target::process_initial_stop_replies): Rename inner "thread". (remote_target::remote_parse_stop_reply): Don't redeclare "p". (remote_target::wait_as): Don't redeclare "stop_reply". (remote_target::get_thread_local_address): Rename inner "result". (remote_target::get_tib_address): Likewise.
2018-09-05Make -Wformat-nonliteral work with gccTom Tromey1-0/+7
After looking into why the build failed for Simon but not for me, we found that the underlying cause was due to how gcc treats -Wformat-nonliteral. gcc requires -Wformat to be given first; but warning.m4 was not doing this, so -Wformat-nonliteral was not being used. This patch changes warning.m4 to account gcc's requirement. This then showed that the target-float.c build change in the earlier Makefile patch was also incorrect. Simon didn't see this in his build, but gcc now points it out. So, this patch fixes this problem as well. 2018-09-05 Tom Tromey <tom@tromey.com> * warning.m4 (AM_GDB_WARNINGS): Add -Wformat when testing -Wformat-nonliteral. * target-float.c (host_float_ops<T>::to_string) (host_float_ops<T>::from_string): Use DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL. * configure: Rebuild. gdb/gdbserver/ChangeLog 2018-09-05 Tom Tromey <tom@tromey.com> * configure: Rebuild.
2018-01-02Update copyright year range in all GDB filesJoel Brobecker1-1/+1
gdb/ChangeLog: Update copyright year range in all GDB files
2017-12-11[MPFR] Fix regression on 32-bit host systemsUlrich Weigand1-1/+1
When converting parts of the mantissa to MPFR, we need to make sure to do an *unsigned* conversion. Since we convert at most 32 bits at a time, stored in an unsigned long, this doesn't matter on systems where "long" is larger than 32 bits. But on systems where it is 32 bits, we can get conversion errors. gdb/ChangeLog 2017-12-11 Ulrich Weigand <uweigand@de.ibm.com> * target-float.c (mpfr_float_ops::from_target): Use mpfr_set_ui instead of mpfr_set_si to convert mantissa bits.
2017-11-29Define MPFR_USE_INTMAX_T so that mpfr.h assumes intmax_t is available.John Baldwin1-0/+2
mpfr.h uses a non-portable test to guess if intmax_t is available and if API functions using intmax_t should be exposed. Define MPFR_USE_INTMAX_T to override the non-portable test and always expose these functions. This fixes the build on platforms where the test guesses incorrectly. gdb/ChangeLog: * target-float.c [HAVE_LIBMPFR]: Define MPFR_USE_INTMAX_T.
2017-11-22Target FP: Make use of MPFR if availableUlrich Weigand1-0/+569
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.
2017-11-22Target FP: Refactor use of host floating-point arithmeticUlrich Weigand1-422/+630
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.
2017-11-16Refactor endian handling in DFP routinesUlrich Weigand1-39/+31
This patch moves endian conversion into the decimal_from_number and decimal_to_number routines, and removes it from all their callers, making the code simpler overall. No functional change. gdb/ChangeLog: 2017-11-16 Ulrich Weigand <uweigand@de.ibm.com> * target-float.c (decimal_from_number): Add byte_order argument and call match_endianness. Error if unknown floating-point type. (decimal_to_number): Add byte_order argument and call match_endianness. (decimal_from_longest): Update call. Do not call match_endianness. (decimal_from_ulongest): Likewise. (decimal_binop): Likewise. (decimal_is_zero): Likewise. (decimal_compare): Likewise. (decimal_convert): Likewise.
2017-11-06Target FP: Merge doublest.c and dfp.c into target-float.cUlrich Weigand1-2/+1246
Now that all target FP operations are performed via target-float.c, this file remains the sole caller of functions in doublest.c and dfp.c. Therefore, this patch merges the latter files into the former and makes all their function static there. gdb/ChangeLog: 2017-11-06 Ulrich Weigand <uweigand@de.ibm.com> * Makefile.in (SFILES): Remove doublest.c and dfp.c. (HFILES_NO_SRCDIR): Remove doublest.h and dfp.h. (COMMON_OBS): Remove doublest.o and dfp.o. Do not build target-float.c (instead of doublest.c) with -Wformat-nonliteral. * doublest.c: Remove file. * doublest.h: Remove file. * dfp.c: Remove file. * dfp.h: Remove file. * target-float.c: Do not include "doublest.h" and "dfp.h". (DOUBLEST): Move here from doublest.h. (enum float_kind): Likewise. (FLOATFORMAT_CHAR_BIT): Likewise. (FLOATFORMAT_LARGEST_BYTES): Likewise. (floatformat_totalsize_bytes): Move here from doublest.c. Make static. (floatformat_precision): Likewise. (floatformat_normalize_byteorder, get_field, put_field): Likewise. (floatformat_is_negative, floatformat_classify, floatformat_mantissa): Likewise. (host_float_format, host_double_format, host_long_double_format): Likewise. (floatformat_to_string, floatformat_from_string): Likewise. (floatformat_to_doublest): Likewise. Also, inline the original convert_floatformat_to_doublest. (floatformat_from_doublest): Likewise. Also, inline the original convert_floatformat_from_doublest. Include "dpd/decimal128.h", "dpd/decimal64.h", and "dpd/decimal32.h". (MAX_DECIMAL_STRING): Move here from dfp.c. (match_endianness): Likewise. (set_decnumber_context, decimal_check_errors): Likewise. (decimal_from_number, decimal_to_number): Likewise. (decimal_to_string, decimal_from_string): Likewise. Make static. (decimal_from_longest, decimal_from_ulongest): Likewise. (decimal_to_longest): Likewise. (decimal_binop, decimal_is_zero, decimal_compare): Likewise. (decimal_convert): Likewise.
2017-11-06Target FP: Handle interfaces to scripting languagesUlrich Weigand1-0/+57
The last remaing use for DOUBLEST is in the code that interfaces to the scripting languages (Python and Guile). The problem here is that we expose interfaces to convert a GDB value to and from native values of floating-point type in those languages, and those by definition use the host floating-point format. While we cannot completely eliminate conversions to/from the host floating-point format here, we still need to get rid of the uses of value_as_double / value_from_double, since those will go away. This patch implements two new target-float.c routine: - target_float_to_host_double - target_float_from_host_double which convert to/from a host "double". Those should only ever be used where a host "double" is mandated by an external interface. gdb/ChangeLog: 2017-11-06 Ulrich Weigand <uweigand@de.ibm.com> * target-float.c (floatformat_to_host_double): New function. (floatformat_from_host_double): Likewise. (target_float_to_host_double): Likewise. (target_float_from_host_double): Likewise. * target-float.h (target_float_to_host_double): Add prototype. (target_float_from_host_double): Likewise. * guile/scm-value.c: Include "target-float.h". (gdbscm_value_to_real): Use target_float_to_host_double. Handle integer source values via value_as_long. * guile/scm-math.c: Include "target-float.h". Do not include "doublest.h", "dfp.h", and "expression.h". (vlscm_convert_typed_number): Use target_float_from_host_double. (vlscm_convert_number): Likewise. * python/py-value.c (valpy_float): Use target_float_to_host_double. (convert_value_from_python): Use target_float_from_host_double.
2017-11-06Target FP: Add binop and compare routines to target-float.{c,h}Ulrich Weigand1-0/+152
This patch adds the following target floating-point routines: - target_float_binop - target_float_compare which call the equivalent decimal_ routines to handle decimal FP, and call helper routines that currently still go via DOUBLEST to handle binary FP (derived from current valarith.c code). These routines are used to handle both binary and decimal FP types in scalar_binop, value_equal, and value_less, mostly following the method currently used for decimal FP. The existing value_args_as_decimal helper is renamed to value_args_as_target_float and extended to handle both binary and decimal types. The unary operations value_pos and value_neg are also simplified, the former by using a simple copy for all scalar types, the latter by using value_binop (... BINOP_SUB) to implement negation as subtraction from zero. ChangeLog: 2017-11-06 Ulrich Weigand <uweigand@de.ibm.com> * target-float.c: Include <math.h>. (floatformat_binop): New function. (floatformat_compare): Likewise. (target_float_binop): Likewise. (target_float_compare): Likewise. * target-float.h: Include "expression.h". (target_float_binop): Add prototype. (target_float_compare): Likewise. * valarith.c: Do not include "doublest.h" and "dfp.h". Include "common/byte-vector.h". (value_args_as_decimal): Remove, replace by ... (value_args_as_target_float): ... this function. Handle both binary and decimal target floating-point formats. (scalar_binop): Handle both binary and decimal FP using value_args_as_target_float and target_float_binop. (value_equal): Handle both binary and decimal FP using value_args_as_target_float and target_float_compare. (value_less): Likewise. (value_pos): Handle all scalar types as simple copy. (value_neg): Handle all scalar types via BINOP_SUB from 0. * dfp.c (decimal_binop): Throw error instead of internal_error when called with an unsupported operation code.
2017-11-06Target FP: Add conversion routines to target-float.{c,h}Ulrich Weigand1-0/+169
This patch adds the following conversion routines: - target_float_to_longest - target_float_from_longest - target_float_from_ulongest - target_float_convert which call the equivalent decimal_ routines to handle decimal FP, and call helper routines that currently still go via DOUBLEST to handle binary FP. The target_float_convert routine not only handles BFP<->BFP and DFP<->DFP conversions, but also BFP<->DFP, which are implemented by converting to a string and back. These helpers are used in particular to implement conversion from and to FP in value_cast, without going through DOUBLEST there. In order to implement this for the FP<-integer case, the pack_long / pack_unsigned_long routines are extended to support floating-point values as output (thereby allowing use of value_from_[u]longest with a floating-point target type). This latter change also allows simplification of value_one. gdb/ChangeLog: 2017-11-06 Ulrich Weigand <uweigand@de.ibm.com> * target-float.c (floatformat_to_longest): New function. (floatformat_from_longest, floatformat_from_ulongest): Likewise. (floatformat_convert): Likewise. (target_float_to_longest): Likewise. (target_float_from_longest, target_float_from_ulongest): Likewise. (target_float_convert): Likewise. * target-float.h (target_float_to_longest): Add prototype. (target_float_from_longest, target_float_from_ulongest): Likewise. (target_float_convert): Likewise. * value.c (unpack_long): Use target_float_to_longest. (pack_long): Allow FP types. Use target_float_from_longest. (pack_unsigned_long): Likewise using target_float_from_ulongest. * valops.c: Include "target-float.h". Do not include "dfp.h". (value_cast): Handle conversions to FP using target_float_convert, value_from_ulongest, and value_from_longest. (value_one): Use value_from_longest for FP types as well.
2017-11-06Target FP: Add string routines to target-float.{c,h}Ulrich Weigand1-0/+37
This adds target_float_to_string and target_float_from_string, which dispatch to the corresponding floatformat_ or decimal_ routines. Existing users of those routines are changed to use the new target-float routines instead (most of those places already handle both binary and decimal FP). In addition, two other places are changes to use target_float_from_string: - define_symbol in stabsread.c, when parsing a floating-point literal from stabs debug info - gdbarch-selftest.c when initializing a target format values (to eliminate use of DOUBLEST there). gdb/ChangeLog: 2017-11-06 Ulrich Weigand <uweigand@de.ibm.com> * target-float.c (target_float_to_string): New function. (target_float_from_string): New function. * target-float.h (target_float_to_string): Add prototype. (target_float_from_string): Add prototype. * valprint.c: Include "target-float.h". Do not include "doublest.h" and "dfp.h". (print_floating): Use target_float_to_string. * printcmd.c: Include "target-float.h". Do not include "dfp.h". (printf_floating): Use target_float_to_string. * i387-tdep.c: Include "target-float.h". Do not include "doublest.h". (print_i387_value): Use target_float_to_string. * mips-tdep.c: Include "target-float.h". (mips_print_fp_register): Use target_float_to_string. * sh64-tdep.c: Include "target-float.h". (sh64_do_fp_register): Use target_float_to_string. * parse.c: Include "target-float.h". Do not include "doublest.h" and "dfp.h". (parse_float): Use target_float_from_string. * stabsread.c: Include "target-float.h". Do not include "doublest.h". (define_symbol): Use target_float_from_string. * gdbarch-selftests.c: Include "target-float.h". (register_to_value_test): Use target_float_from_string.
2017-11-06Target FP: Introduce target-float.{c,h}Ulrich Weigand1-0/+62
This patch introduces the new set of target floating-point handling routines in target-float.{c,h}. In the end, the intention is that this file will contain support for all operations in target FP format, fully replacing both the current doublest.{c,h} and dfp.{c,h}. To begin with, this patch only adds a target_float_is_zero routine, which handles the equivalent of decimal_is_zero for both binary and decimal FP. For the binary case, to avoid conversion to DOUBLEST, this is implemented using the floatformat_classify routine. However, it turns out that floatformat_classify actually has a bug (it was not used to check for zero before), so this is fixed as well. The new routine is used in both value_logical_not and valpy_nonzero. There is one extra twist: the code previously used value_as_double to convert to DOUBLEST and then compare against zero. That routine performs an extra task: it detects invalid floating-point values and raises an error. In any place where value_as_double is removed in favor of some target-float.c routine, we need to replace that check. To keep this check centralized in one place, I've added a new routine is_floating_value, which returns a boolean determining whether a value's type is floating point (binary or decimal), and if so, also performs the validity check. Since we need to check whether a value is FP before calling any of the target-float routines anyway, this seems a good place to add the check without much code size overhead. In some places where we only want to check for floating-point types and not perform a validity check (e.g. for the *output* of an operation), we can use the new is_floating_type routine (in gdbarch) instead. The validity check itself is done by a new target_float_is_valid routine in target-float, encapsulating floatformat_is_valid. ChangeLog: 2017-11-06 Ulrich Weigand <uweigand@de.ibm.com> * Makefile.c (SFILES): Add target-float.c. (HFILES_NO_SRCDIR): Add target-float.h. (COMMON_OBS): Add target-float.o. * target-float.h: New file. * target-float.c: New file. * doublest.c (floatformat_classify): Fix detection of float_zero. * gdbtypes.c (is_floating_type): New function. * gdbtypes.h (is_floating_type): Add prototype. * value.c: Do not include "floatformat.h". (unpack_double): Use target_float_is_valid. (is_floating_value): New function. * value.h (is_floating_value): Add prototype- * valarith.c: Include "target-float.h". (value_logical_not): Use target_float_is_zero. * python/py-value.c: Include "target-float.h". (valpy_nonzero): Use target_float_is_zero.