binutils-gdb/gdb/findvar.c

1100 lines
33 KiB
C
Raw Normal View History

/* Find a variable's value in memory, for GDB, the GNU debugger.
Copyright (C) 1986-2020 Free Software Foundation, Inc.
1999-07-07 22:19:36 +02:00
This file is part of GDB.
1999-07-07 22:19:36 +02:00
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
1999-07-07 22:19:36 +02:00
(at your option) any later version.
1999-07-07 22:19:36 +02:00
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
1999-07-07 22:19:36 +02:00
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
Revert the header-sorting patch Andreas Schwab and John Baldwin pointed out some bugs in the header sorting patch; and I noticed that the output was not correct when limited to a subset of files (a bug in my script). So, I'm reverting the patch. I may try again after fixing the issues pointed out. gdb/ChangeLog 2019-04-05 Tom Tromey <tom@tromey.com> Revert the header-sorting patch. * ft32-tdep.c: Revert. * frv-tdep.c: Revert. * frv-linux-tdep.c: Revert. * frame.c: Revert. * frame-unwind.c: Revert. * frame-base.c: Revert. * fork-child.c: Revert. * findvar.c: Revert. * findcmd.c: Revert. * filesystem.c: Revert. * filename-seen-cache.h: Revert. * filename-seen-cache.c: Revert. * fbsd-tdep.c: Revert. * fbsd-nat.h: Revert. * fbsd-nat.c: Revert. * f-valprint.c: Revert. * f-typeprint.c: Revert. * f-lang.c: Revert. * extension.h: Revert. * extension.c: Revert. * extension-priv.h: Revert. * expprint.c: Revert. * exec.h: Revert. * exec.c: Revert. * exceptions.c: Revert. * event-top.c: Revert. * event-loop.c: Revert. * eval.c: Revert. * elfread.c: Revert. * dwarf2read.h: Revert. * dwarf2read.c: Revert. * dwarf2loc.c: Revert. * dwarf2expr.h: Revert. * dwarf2expr.c: Revert. * dwarf2-frame.c: Revert. * dwarf2-frame-tailcall.c: Revert. * dwarf-index-write.h: Revert. * dwarf-index-write.c: Revert. * dwarf-index-common.c: Revert. * dwarf-index-cache.h: Revert. * dwarf-index-cache.c: Revert. * dummy-frame.c: Revert. * dtrace-probe.c: Revert. * disasm.h: Revert. * disasm.c: Revert. * disasm-selftests.c: Revert. * dictionary.c: Revert. * dicos-tdep.c: Revert. * demangle.c: Revert. * dcache.h: Revert. * dcache.c: Revert. * darwin-nat.h: Revert. * darwin-nat.c: Revert. * darwin-nat-info.c: Revert. * d-valprint.c: Revert. * d-namespace.c: Revert. * d-lang.c: Revert. * ctf.c: Revert. * csky-tdep.c: Revert. * csky-linux-tdep.c: Revert. * cris-tdep.c: Revert. * cris-linux-tdep.c: Revert. * cp-valprint.c: Revert. * cp-support.c: Revert. * cp-namespace.c: Revert. * cp-abi.c: Revert. * corelow.c: Revert. * corefile.c: Revert. * continuations.c: Revert. * completer.h: Revert. * completer.c: Revert. * complaints.c: Revert. * coffread.c: Revert. * coff-pe-read.c: Revert. * cli-out.h: Revert. * cli-out.c: Revert. * charset.c: Revert. * c-varobj.c: Revert. * c-valprint.c: Revert. * c-typeprint.c: Revert. * c-lang.c: Revert. * buildsym.c: Revert. * buildsym-legacy.c: Revert. * build-id.h: Revert. * build-id.c: Revert. * btrace.c: Revert. * bsd-uthread.c: Revert. * breakpoint.h: Revert. * breakpoint.c: Revert. * break-catch-throw.c: Revert. * break-catch-syscall.c: Revert. * break-catch-sig.c: Revert. * blockframe.c: Revert. * block.c: Revert. * bfin-tdep.c: Revert. * bfin-linux-tdep.c: Revert. * bfd-target.c: Revert. * bcache.c: Revert. * ax-general.c: Revert. * ax-gdb.h: Revert. * ax-gdb.c: Revert. * avr-tdep.c: Revert. * auxv.c: Revert. * auto-load.c: Revert. * arm-wince-tdep.c: Revert. * arm-tdep.c: Revert. * arm-symbian-tdep.c: Revert. * arm-pikeos-tdep.c: Revert. * arm-obsd-tdep.c: Revert. * arm-nbsd-tdep.c: Revert. * arm-nbsd-nat.c: Revert. * arm-linux-tdep.c: Revert. * arm-linux-nat.c: Revert. * arm-fbsd-tdep.c: Revert. * arm-fbsd-nat.c: Revert. * arm-bsd-tdep.c: Revert. * arch-utils.c: Revert. * arc-tdep.c: Revert. * arc-newlib-tdep.c: Revert. * annotate.h: Revert. * annotate.c: Revert. * amd64-windows-tdep.c: Revert. * amd64-windows-nat.c: Revert. * amd64-tdep.c: Revert. * amd64-sol2-tdep.c: Revert. * amd64-obsd-tdep.c: Revert. * amd64-obsd-nat.c: Revert. * amd64-nbsd-tdep.c: Revert. * amd64-nbsd-nat.c: Revert. * amd64-nat.c: Revert. * amd64-linux-tdep.c: Revert. * amd64-linux-nat.c: Revert. * amd64-fbsd-tdep.c: Revert. * amd64-fbsd-nat.c: Revert. * amd64-dicos-tdep.c: Revert. * amd64-darwin-tdep.c: Revert. * amd64-bsd-nat.c: Revert. * alpha-tdep.c: Revert. * alpha-obsd-tdep.c: Revert. * alpha-nbsd-tdep.c: Revert. * alpha-mdebug-tdep.c: Revert. * alpha-linux-tdep.c: Revert. * alpha-linux-nat.c: Revert. * alpha-bsd-tdep.c: Revert. * alpha-bsd-nat.c: Revert. * aix-thread.c: Revert. * agent.c: Revert. * addrmap.c: Revert. * ada-varobj.c: Revert. * ada-valprint.c: Revert. * ada-typeprint.c: Revert. * ada-tasks.c: Revert. * ada-lang.c: Revert. * aarch64-tdep.c: Revert. * aarch64-ravenscar-thread.c: Revert. * aarch64-newlib-tdep.c: Revert. * aarch64-linux-tdep.c: Revert. * aarch64-linux-nat.c: Revert. * aarch64-fbsd-tdep.c: Revert. * aarch64-fbsd-nat.c: Revert. * aarch32-linux-nat.c: Revert.
2019-04-06 21:38:10 +02:00
#include "symtab.h"
#include "gdbtypes.h"
#include "frame.h"
Revert the header-sorting patch Andreas Schwab and John Baldwin pointed out some bugs in the header sorting patch; and I noticed that the output was not correct when limited to a subset of files (a bug in my script). So, I'm reverting the patch. I may try again after fixing the issues pointed out. gdb/ChangeLog 2019-04-05 Tom Tromey <tom@tromey.com> Revert the header-sorting patch. * ft32-tdep.c: Revert. * frv-tdep.c: Revert. * frv-linux-tdep.c: Revert. * frame.c: Revert. * frame-unwind.c: Revert. * frame-base.c: Revert. * fork-child.c: Revert. * findvar.c: Revert. * findcmd.c: Revert. * filesystem.c: Revert. * filename-seen-cache.h: Revert. * filename-seen-cache.c: Revert. * fbsd-tdep.c: Revert. * fbsd-nat.h: Revert. * fbsd-nat.c: Revert. * f-valprint.c: Revert. * f-typeprint.c: Revert. * f-lang.c: Revert. * extension.h: Revert. * extension.c: Revert. * extension-priv.h: Revert. * expprint.c: Revert. * exec.h: Revert. * exec.c: Revert. * exceptions.c: Revert. * event-top.c: Revert. * event-loop.c: Revert. * eval.c: Revert. * elfread.c: Revert. * dwarf2read.h: Revert. * dwarf2read.c: Revert. * dwarf2loc.c: Revert. * dwarf2expr.h: Revert. * dwarf2expr.c: Revert. * dwarf2-frame.c: Revert. * dwarf2-frame-tailcall.c: Revert. * dwarf-index-write.h: Revert. * dwarf-index-write.c: Revert. * dwarf-index-common.c: Revert. * dwarf-index-cache.h: Revert. * dwarf-index-cache.c: Revert. * dummy-frame.c: Revert. * dtrace-probe.c: Revert. * disasm.h: Revert. * disasm.c: Revert. * disasm-selftests.c: Revert. * dictionary.c: Revert. * dicos-tdep.c: Revert. * demangle.c: Revert. * dcache.h: Revert. * dcache.c: Revert. * darwin-nat.h: Revert. * darwin-nat.c: Revert. * darwin-nat-info.c: Revert. * d-valprint.c: Revert. * d-namespace.c: Revert. * d-lang.c: Revert. * ctf.c: Revert. * csky-tdep.c: Revert. * csky-linux-tdep.c: Revert. * cris-tdep.c: Revert. * cris-linux-tdep.c: Revert. * cp-valprint.c: Revert. * cp-support.c: Revert. * cp-namespace.c: Revert. * cp-abi.c: Revert. * corelow.c: Revert. * corefile.c: Revert. * continuations.c: Revert. * completer.h: Revert. * completer.c: Revert. * complaints.c: Revert. * coffread.c: Revert. * coff-pe-read.c: Revert. * cli-out.h: Revert. * cli-out.c: Revert. * charset.c: Revert. * c-varobj.c: Revert. * c-valprint.c: Revert. * c-typeprint.c: Revert. * c-lang.c: Revert. * buildsym.c: Revert. * buildsym-legacy.c: Revert. * build-id.h: Revert. * build-id.c: Revert. * btrace.c: Revert. * bsd-uthread.c: Revert. * breakpoint.h: Revert. * breakpoint.c: Revert. * break-catch-throw.c: Revert. * break-catch-syscall.c: Revert. * break-catch-sig.c: Revert. * blockframe.c: Revert. * block.c: Revert. * bfin-tdep.c: Revert. * bfin-linux-tdep.c: Revert. * bfd-target.c: Revert. * bcache.c: Revert. * ax-general.c: Revert. * ax-gdb.h: Revert. * ax-gdb.c: Revert. * avr-tdep.c: Revert. * auxv.c: Revert. * auto-load.c: Revert. * arm-wince-tdep.c: Revert. * arm-tdep.c: Revert. * arm-symbian-tdep.c: Revert. * arm-pikeos-tdep.c: Revert. * arm-obsd-tdep.c: Revert. * arm-nbsd-tdep.c: Revert. * arm-nbsd-nat.c: Revert. * arm-linux-tdep.c: Revert. * arm-linux-nat.c: Revert. * arm-fbsd-tdep.c: Revert. * arm-fbsd-nat.c: Revert. * arm-bsd-tdep.c: Revert. * arch-utils.c: Revert. * arc-tdep.c: Revert. * arc-newlib-tdep.c: Revert. * annotate.h: Revert. * annotate.c: Revert. * amd64-windows-tdep.c: Revert. * amd64-windows-nat.c: Revert. * amd64-tdep.c: Revert. * amd64-sol2-tdep.c: Revert. * amd64-obsd-tdep.c: Revert. * amd64-obsd-nat.c: Revert. * amd64-nbsd-tdep.c: Revert. * amd64-nbsd-nat.c: Revert. * amd64-nat.c: Revert. * amd64-linux-tdep.c: Revert. * amd64-linux-nat.c: Revert. * amd64-fbsd-tdep.c: Revert. * amd64-fbsd-nat.c: Revert. * amd64-dicos-tdep.c: Revert. * amd64-darwin-tdep.c: Revert. * amd64-bsd-nat.c: Revert. * alpha-tdep.c: Revert. * alpha-obsd-tdep.c: Revert. * alpha-nbsd-tdep.c: Revert. * alpha-mdebug-tdep.c: Revert. * alpha-linux-tdep.c: Revert. * alpha-linux-nat.c: Revert. * alpha-bsd-tdep.c: Revert. * alpha-bsd-nat.c: Revert. * aix-thread.c: Revert. * agent.c: Revert. * addrmap.c: Revert. * ada-varobj.c: Revert. * ada-valprint.c: Revert. * ada-typeprint.c: Revert. * ada-tasks.c: Revert. * ada-lang.c: Revert. * aarch64-tdep.c: Revert. * aarch64-ravenscar-thread.c: Revert. * aarch64-newlib-tdep.c: Revert. * aarch64-linux-tdep.c: Revert. * aarch64-linux-nat.c: Revert. * aarch64-fbsd-tdep.c: Revert. * aarch64-fbsd-nat.c: Revert. * aarch32-linux-nat.c: Revert.
2019-04-06 21:38:10 +02:00
#include "value.h"
#include "gdbcore.h"
#include "inferior.h"
Sort includes for files gdb/[a-f]*.[chyl]. This patch sorts the include files for the files [a-f]*.[chyl]. The patch was written by a script. Tested by the buildbot. I will follow up with patches to sort the remaining files, by sorting a subset, testing them, and then checking them in. gdb/ChangeLog 2019-04-05 Tom Tromey <tom@tromey.com> * ft32-tdep.c: Sort headers. * frv-tdep.c: Sort headers. * frv-linux-tdep.c: Sort headers. * frame.c: Sort headers. * frame-unwind.c: Sort headers. * frame-base.c: Sort headers. * fork-child.c: Sort headers. * findvar.c: Sort headers. * findcmd.c: Sort headers. * filesystem.c: Sort headers. * filename-seen-cache.h: Sort headers. * filename-seen-cache.c: Sort headers. * fbsd-tdep.c: Sort headers. * fbsd-nat.h: Sort headers. * fbsd-nat.c: Sort headers. * f-valprint.c: Sort headers. * f-typeprint.c: Sort headers. * f-lang.c: Sort headers. * extension.h: Sort headers. * extension.c: Sort headers. * extension-priv.h: Sort headers. * expprint.c: Sort headers. * exec.h: Sort headers. * exec.c: Sort headers. * exceptions.c: Sort headers. * event-top.c: Sort headers. * event-loop.c: Sort headers. * eval.c: Sort headers. * elfread.c: Sort headers. * dwarf2read.h: Sort headers. * dwarf2read.c: Sort headers. * dwarf2loc.c: Sort headers. * dwarf2expr.h: Sort headers. * dwarf2expr.c: Sort headers. * dwarf2-frame.c: Sort headers. * dwarf2-frame-tailcall.c: Sort headers. * dwarf-index-write.h: Sort headers. * dwarf-index-write.c: Sort headers. * dwarf-index-common.c: Sort headers. * dwarf-index-cache.h: Sort headers. * dwarf-index-cache.c: Sort headers. * dummy-frame.c: Sort headers. * dtrace-probe.c: Sort headers. * disasm.h: Sort headers. * disasm.c: Sort headers. * disasm-selftests.c: Sort headers. * dictionary.c: Sort headers. * dicos-tdep.c: Sort headers. * demangle.c: Sort headers. * dcache.h: Sort headers. * dcache.c: Sort headers. * darwin-nat.h: Sort headers. * darwin-nat.c: Sort headers. * darwin-nat-info.c: Sort headers. * d-valprint.c: Sort headers. * d-namespace.c: Sort headers. * d-lang.c: Sort headers. * ctf.c: Sort headers. * csky-tdep.c: Sort headers. * csky-linux-tdep.c: Sort headers. * cris-tdep.c: Sort headers. * cris-linux-tdep.c: Sort headers. * cp-valprint.c: Sort headers. * cp-support.c: Sort headers. * cp-namespace.c: Sort headers. * cp-abi.c: Sort headers. * corelow.c: Sort headers. * corefile.c: Sort headers. * continuations.c: Sort headers. * completer.h: Sort headers. * completer.c: Sort headers. * complaints.c: Sort headers. * coffread.c: Sort headers. * coff-pe-read.c: Sort headers. * cli-out.h: Sort headers. * cli-out.c: Sort headers. * charset.c: Sort headers. * c-varobj.c: Sort headers. * c-valprint.c: Sort headers. * c-typeprint.c: Sort headers. * c-lang.c: Sort headers. * buildsym.c: Sort headers. * buildsym-legacy.c: Sort headers. * build-id.h: Sort headers. * build-id.c: Sort headers. * btrace.c: Sort headers. * bsd-uthread.c: Sort headers. * breakpoint.h: Sort headers. * breakpoint.c: Sort headers. * break-catch-throw.c: Sort headers. * break-catch-syscall.c: Sort headers. * break-catch-sig.c: Sort headers. * blockframe.c: Sort headers. * block.c: Sort headers. * bfin-tdep.c: Sort headers. * bfin-linux-tdep.c: Sort headers. * bfd-target.c: Sort headers. * bcache.c: Sort headers. * ax-general.c: Sort headers. * ax-gdb.h: Sort headers. * ax-gdb.c: Sort headers. * avr-tdep.c: Sort headers. * auxv.c: Sort headers. * auto-load.c: Sort headers. * arm-wince-tdep.c: Sort headers. * arm-tdep.c: Sort headers. * arm-symbian-tdep.c: Sort headers. * arm-pikeos-tdep.c: Sort headers. * arm-obsd-tdep.c: Sort headers. * arm-nbsd-tdep.c: Sort headers. * arm-nbsd-nat.c: Sort headers. * arm-linux-tdep.c: Sort headers. * arm-linux-nat.c: Sort headers. * arm-fbsd-tdep.c: Sort headers. * arm-fbsd-nat.c: Sort headers. * arm-bsd-tdep.c: Sort headers. * arch-utils.c: Sort headers. * arc-tdep.c: Sort headers. * arc-newlib-tdep.c: Sort headers. * annotate.h: Sort headers. * annotate.c: Sort headers. * amd64-windows-tdep.c: Sort headers. * amd64-windows-nat.c: Sort headers. * amd64-tdep.c: Sort headers. * amd64-sol2-tdep.c: Sort headers. * amd64-obsd-tdep.c: Sort headers. * amd64-obsd-nat.c: Sort headers. * amd64-nbsd-tdep.c: Sort headers. * amd64-nbsd-nat.c: Sort headers. * amd64-nat.c: Sort headers. * amd64-linux-tdep.c: Sort headers. * amd64-linux-nat.c: Sort headers. * amd64-fbsd-tdep.c: Sort headers. * amd64-fbsd-nat.c: Sort headers. * amd64-dicos-tdep.c: Sort headers. * amd64-darwin-tdep.c: Sort headers. * amd64-bsd-nat.c: Sort headers. * alpha-tdep.c: Sort headers. * alpha-obsd-tdep.c: Sort headers. * alpha-nbsd-tdep.c: Sort headers. * alpha-mdebug-tdep.c: Sort headers. * alpha-linux-tdep.c: Sort headers. * alpha-linux-nat.c: Sort headers. * alpha-bsd-tdep.c: Sort headers. * alpha-bsd-nat.c: Sort headers. * aix-thread.c: Sort headers. * agent.c: Sort headers. * addrmap.c: Sort headers. * ada-varobj.c: Sort headers. * ada-valprint.c: Sort headers. * ada-typeprint.c: Sort headers. * ada-tasks.c: Sort headers. * ada-lang.c: Sort headers. * aarch64-tdep.c: Sort headers. * aarch64-ravenscar-thread.c: Sort headers. * aarch64-newlib-tdep.c: Sort headers. * aarch64-linux-tdep.c: Sort headers. * aarch64-linux-nat.c: Sort headers. * aarch64-fbsd-tdep.c: Sort headers. * aarch64-fbsd-nat.c: Sort headers. * aarch32-linux-nat.c: Sort headers.
2019-04-03 04:04:24 +02:00
#include "target.h"
Revert the header-sorting patch Andreas Schwab and John Baldwin pointed out some bugs in the header sorting patch; and I noticed that the output was not correct when limited to a subset of files (a bug in my script). So, I'm reverting the patch. I may try again after fixing the issues pointed out. gdb/ChangeLog 2019-04-05 Tom Tromey <tom@tromey.com> Revert the header-sorting patch. * ft32-tdep.c: Revert. * frv-tdep.c: Revert. * frv-linux-tdep.c: Revert. * frame.c: Revert. * frame-unwind.c: Revert. * frame-base.c: Revert. * fork-child.c: Revert. * findvar.c: Revert. * findcmd.c: Revert. * filesystem.c: Revert. * filename-seen-cache.h: Revert. * filename-seen-cache.c: Revert. * fbsd-tdep.c: Revert. * fbsd-nat.h: Revert. * fbsd-nat.c: Revert. * f-valprint.c: Revert. * f-typeprint.c: Revert. * f-lang.c: Revert. * extension.h: Revert. * extension.c: Revert. * extension-priv.h: Revert. * expprint.c: Revert. * exec.h: Revert. * exec.c: Revert. * exceptions.c: Revert. * event-top.c: Revert. * event-loop.c: Revert. * eval.c: Revert. * elfread.c: Revert. * dwarf2read.h: Revert. * dwarf2read.c: Revert. * dwarf2loc.c: Revert. * dwarf2expr.h: Revert. * dwarf2expr.c: Revert. * dwarf2-frame.c: Revert. * dwarf2-frame-tailcall.c: Revert. * dwarf-index-write.h: Revert. * dwarf-index-write.c: Revert. * dwarf-index-common.c: Revert. * dwarf-index-cache.h: Revert. * dwarf-index-cache.c: Revert. * dummy-frame.c: Revert. * dtrace-probe.c: Revert. * disasm.h: Revert. * disasm.c: Revert. * disasm-selftests.c: Revert. * dictionary.c: Revert. * dicos-tdep.c: Revert. * demangle.c: Revert. * dcache.h: Revert. * dcache.c: Revert. * darwin-nat.h: Revert. * darwin-nat.c: Revert. * darwin-nat-info.c: Revert. * d-valprint.c: Revert. * d-namespace.c: Revert. * d-lang.c: Revert. * ctf.c: Revert. * csky-tdep.c: Revert. * csky-linux-tdep.c: Revert. * cris-tdep.c: Revert. * cris-linux-tdep.c: Revert. * cp-valprint.c: Revert. * cp-support.c: Revert. * cp-namespace.c: Revert. * cp-abi.c: Revert. * corelow.c: Revert. * corefile.c: Revert. * continuations.c: Revert. * completer.h: Revert. * completer.c: Revert. * complaints.c: Revert. * coffread.c: Revert. * coff-pe-read.c: Revert. * cli-out.h: Revert. * cli-out.c: Revert. * charset.c: Revert. * c-varobj.c: Revert. * c-valprint.c: Revert. * c-typeprint.c: Revert. * c-lang.c: Revert. * buildsym.c: Revert. * buildsym-legacy.c: Revert. * build-id.h: Revert. * build-id.c: Revert. * btrace.c: Revert. * bsd-uthread.c: Revert. * breakpoint.h: Revert. * breakpoint.c: Revert. * break-catch-throw.c: Revert. * break-catch-syscall.c: Revert. * break-catch-sig.c: Revert. * blockframe.c: Revert. * block.c: Revert. * bfin-tdep.c: Revert. * bfin-linux-tdep.c: Revert. * bfd-target.c: Revert. * bcache.c: Revert. * ax-general.c: Revert. * ax-gdb.h: Revert. * ax-gdb.c: Revert. * avr-tdep.c: Revert. * auxv.c: Revert. * auto-load.c: Revert. * arm-wince-tdep.c: Revert. * arm-tdep.c: Revert. * arm-symbian-tdep.c: Revert. * arm-pikeos-tdep.c: Revert. * arm-obsd-tdep.c: Revert. * arm-nbsd-tdep.c: Revert. * arm-nbsd-nat.c: Revert. * arm-linux-tdep.c: Revert. * arm-linux-nat.c: Revert. * arm-fbsd-tdep.c: Revert. * arm-fbsd-nat.c: Revert. * arm-bsd-tdep.c: Revert. * arch-utils.c: Revert. * arc-tdep.c: Revert. * arc-newlib-tdep.c: Revert. * annotate.h: Revert. * annotate.c: Revert. * amd64-windows-tdep.c: Revert. * amd64-windows-nat.c: Revert. * amd64-tdep.c: Revert. * amd64-sol2-tdep.c: Revert. * amd64-obsd-tdep.c: Revert. * amd64-obsd-nat.c: Revert. * amd64-nbsd-tdep.c: Revert. * amd64-nbsd-nat.c: Revert. * amd64-nat.c: Revert. * amd64-linux-tdep.c: Revert. * amd64-linux-nat.c: Revert. * amd64-fbsd-tdep.c: Revert. * amd64-fbsd-nat.c: Revert. * amd64-dicos-tdep.c: Revert. * amd64-darwin-tdep.c: Revert. * amd64-bsd-nat.c: Revert. * alpha-tdep.c: Revert. * alpha-obsd-tdep.c: Revert. * alpha-nbsd-tdep.c: Revert. * alpha-mdebug-tdep.c: Revert. * alpha-linux-tdep.c: Revert. * alpha-linux-nat.c: Revert. * alpha-bsd-tdep.c: Revert. * alpha-bsd-nat.c: Revert. * aix-thread.c: Revert. * agent.c: Revert. * addrmap.c: Revert. * ada-varobj.c: Revert. * ada-valprint.c: Revert. * ada-typeprint.c: Revert. * ada-tasks.c: Revert. * ada-lang.c: Revert. * aarch64-tdep.c: Revert. * aarch64-ravenscar-thread.c: Revert. * aarch64-newlib-tdep.c: Revert. * aarch64-linux-tdep.c: Revert. * aarch64-linux-nat.c: Revert. * aarch64-fbsd-tdep.c: Revert. * aarch64-fbsd-nat.c: Revert. * aarch32-linux-nat.c: Revert.
2019-04-06 21:38:10 +02:00
#include "symfile.h" /* for overlay functions */
#include "regcache.h"
#include "user-regs.h"
Revert the header-sorting patch Andreas Schwab and John Baldwin pointed out some bugs in the header sorting patch; and I noticed that the output was not correct when limited to a subset of files (a bug in my script). So, I'm reverting the patch. I may try again after fixing the issues pointed out. gdb/ChangeLog 2019-04-05 Tom Tromey <tom@tromey.com> Revert the header-sorting patch. * ft32-tdep.c: Revert. * frv-tdep.c: Revert. * frv-linux-tdep.c: Revert. * frame.c: Revert. * frame-unwind.c: Revert. * frame-base.c: Revert. * fork-child.c: Revert. * findvar.c: Revert. * findcmd.c: Revert. * filesystem.c: Revert. * filename-seen-cache.h: Revert. * filename-seen-cache.c: Revert. * fbsd-tdep.c: Revert. * fbsd-nat.h: Revert. * fbsd-nat.c: Revert. * f-valprint.c: Revert. * f-typeprint.c: Revert. * f-lang.c: Revert. * extension.h: Revert. * extension.c: Revert. * extension-priv.h: Revert. * expprint.c: Revert. * exec.h: Revert. * exec.c: Revert. * exceptions.c: Revert. * event-top.c: Revert. * event-loop.c: Revert. * eval.c: Revert. * elfread.c: Revert. * dwarf2read.h: Revert. * dwarf2read.c: Revert. * dwarf2loc.c: Revert. * dwarf2expr.h: Revert. * dwarf2expr.c: Revert. * dwarf2-frame.c: Revert. * dwarf2-frame-tailcall.c: Revert. * dwarf-index-write.h: Revert. * dwarf-index-write.c: Revert. * dwarf-index-common.c: Revert. * dwarf-index-cache.h: Revert. * dwarf-index-cache.c: Revert. * dummy-frame.c: Revert. * dtrace-probe.c: Revert. * disasm.h: Revert. * disasm.c: Revert. * disasm-selftests.c: Revert. * dictionary.c: Revert. * dicos-tdep.c: Revert. * demangle.c: Revert. * dcache.h: Revert. * dcache.c: Revert. * darwin-nat.h: Revert. * darwin-nat.c: Revert. * darwin-nat-info.c: Revert. * d-valprint.c: Revert. * d-namespace.c: Revert. * d-lang.c: Revert. * ctf.c: Revert. * csky-tdep.c: Revert. * csky-linux-tdep.c: Revert. * cris-tdep.c: Revert. * cris-linux-tdep.c: Revert. * cp-valprint.c: Revert. * cp-support.c: Revert. * cp-namespace.c: Revert. * cp-abi.c: Revert. * corelow.c: Revert. * corefile.c: Revert. * continuations.c: Revert. * completer.h: Revert. * completer.c: Revert. * complaints.c: Revert. * coffread.c: Revert. * coff-pe-read.c: Revert. * cli-out.h: Revert. * cli-out.c: Revert. * charset.c: Revert. * c-varobj.c: Revert. * c-valprint.c: Revert. * c-typeprint.c: Revert. * c-lang.c: Revert. * buildsym.c: Revert. * buildsym-legacy.c: Revert. * build-id.h: Revert. * build-id.c: Revert. * btrace.c: Revert. * bsd-uthread.c: Revert. * breakpoint.h: Revert. * breakpoint.c: Revert. * break-catch-throw.c: Revert. * break-catch-syscall.c: Revert. * break-catch-sig.c: Revert. * blockframe.c: Revert. * block.c: Revert. * bfin-tdep.c: Revert. * bfin-linux-tdep.c: Revert. * bfd-target.c: Revert. * bcache.c: Revert. * ax-general.c: Revert. * ax-gdb.h: Revert. * ax-gdb.c: Revert. * avr-tdep.c: Revert. * auxv.c: Revert. * auto-load.c: Revert. * arm-wince-tdep.c: Revert. * arm-tdep.c: Revert. * arm-symbian-tdep.c: Revert. * arm-pikeos-tdep.c: Revert. * arm-obsd-tdep.c: Revert. * arm-nbsd-tdep.c: Revert. * arm-nbsd-nat.c: Revert. * arm-linux-tdep.c: Revert. * arm-linux-nat.c: Revert. * arm-fbsd-tdep.c: Revert. * arm-fbsd-nat.c: Revert. * arm-bsd-tdep.c: Revert. * arch-utils.c: Revert. * arc-tdep.c: Revert. * arc-newlib-tdep.c: Revert. * annotate.h: Revert. * annotate.c: Revert. * amd64-windows-tdep.c: Revert. * amd64-windows-nat.c: Revert. * amd64-tdep.c: Revert. * amd64-sol2-tdep.c: Revert. * amd64-obsd-tdep.c: Revert. * amd64-obsd-nat.c: Revert. * amd64-nbsd-tdep.c: Revert. * amd64-nbsd-nat.c: Revert. * amd64-nat.c: Revert. * amd64-linux-tdep.c: Revert. * amd64-linux-nat.c: Revert. * amd64-fbsd-tdep.c: Revert. * amd64-fbsd-nat.c: Revert. * amd64-dicos-tdep.c: Revert. * amd64-darwin-tdep.c: Revert. * amd64-bsd-nat.c: Revert. * alpha-tdep.c: Revert. * alpha-obsd-tdep.c: Revert. * alpha-nbsd-tdep.c: Revert. * alpha-mdebug-tdep.c: Revert. * alpha-linux-tdep.c: Revert. * alpha-linux-nat.c: Revert. * alpha-bsd-tdep.c: Revert. * alpha-bsd-nat.c: Revert. * aix-thread.c: Revert. * agent.c: Revert. * addrmap.c: Revert. * ada-varobj.c: Revert. * ada-valprint.c: Revert. * ada-typeprint.c: Revert. * ada-tasks.c: Revert. * ada-lang.c: Revert. * aarch64-tdep.c: Revert. * aarch64-ravenscar-thread.c: Revert. * aarch64-newlib-tdep.c: Revert. * aarch64-linux-tdep.c: Revert. * aarch64-linux-nat.c: Revert. * aarch64-fbsd-tdep.c: Revert. * aarch64-fbsd-nat.c: Revert. * aarch32-linux-nat.c: Revert.
2019-04-06 21:38:10 +02:00
#include "block.h"
#include "objfiles.h"
#include "language.h"
Move DWARF code to dwarf2/ subdirectory This moves all the remaining DWARF code to the new dwarf2 subdirectory. This is just a simple renaming, with updates to includes as needed. gdb/ChangeLog 2020-02-08 Tom Tromey <tom@tromey.com> * dwarf2/expr.c: Rename from dwarf2expr.c. * dwarf2/expr.h: Rename from dwarf2expr.h. * dwarf2/frame-tailcall.c: Rename from dwarf2-frame-tailcall.c. * dwarf2/frame-tailcall.h: Rename from dwarf2-frame-tailcall.h. * dwarf2/frame.c: Rename from dwarf2-frame.c. * dwarf2/frame.h: Rename from dwarf2-frame.h. * dwarf2/index-cache.c: Rename from dwarf-index-cache.c. * dwarf2/index-cache.h: Rename from dwarf-index-cache.h. * dwarf2/index-common.c: Rename from dwarf-index-common.c. * dwarf2/index-common.h: Rename from dwarf-index-common.h. * dwarf2/index-write.c: Rename from dwarf-index-write.c. * dwarf2/index-write.h: Rename from dwarf-index-write.h. * dwarf2/loc.c: Rename from dwarf2loc.c. * dwarf2/loc.h: Rename from dwarf2loc.h. * dwarf2/read.c: Rename from dwarf2read.c. * dwarf2/read.h: Rename from dwarf2read.h. * dwarf2/abbrev.c, aarch64-tdep.c, alpha-tdep.c, amd64-darwin-tdep.c, arc-tdep.c, arm-tdep.c, bfin-tdep.c, compile/compile-c-symbols.c, compile/compile-cplus-symbols.c, compile/compile-loc2c.c, cris-tdep.c, csky-tdep.c, findvar.c, gdbtypes.c, guile/scm-type.c, h8300-tdep.c, hppa-bsd-tdep.c, hppa-linux-tdep.c, i386-darwin-tdep.c, i386-linux-tdep.c, i386-tdep.c, iq2000-tdep.c, m32c-tdep.c, m68hc11-tdep.c, m68k-tdep.c, microblaze-tdep.c, mips-tdep.c, mn10300-tdep.c, msp430-tdep.c, nds32-tdep.c, nios2-tdep.c, or1k-tdep.c, riscv-tdep.c, rl78-tdep.c, rs6000-tdep.c, rx-tdep.c, s12z-tdep.c, s390-tdep.c, score-tdep.c, sh-tdep.c, sparc-linux-tdep.c, sparc-tdep.c, sparc64-linux-tdep.c, sparc64-tdep.c, tic6x-tdep.c, tilegx-tdep.c, v850-tdep.c, xstormy16-tdep.c, xtensa-tdep.c: Update. * Makefile.in (COMMON_SFILES): Update. (HFILES_NO_SRCDIR): Update. Change-Id: Ied9ce1436cd27ac4a4cffef10ec92e396f181928
2020-02-08 21:40:54 +01:00
#include "dwarf2/loc.h"
Rename common to gdbsupport This is the next patch in the ongoing series to move gdbsever to the top level. This patch just renames the "common" directory. The idea is to do this move in two parts: first rename the directory (this patch), then move the directory to the top. This approach makes the patches a bit more tractable. I chose the name "gdbsupport" for the directory. However, as this patch was largely written by sed, we could pick a new name without too much difficulty. Tested by the buildbot. gdb/ChangeLog 2019-07-09 Tom Tromey <tom@tromey.com> * contrib/ari/gdb_ari.sh: Change common to gdbsupport. * configure: Rebuild. * configure.ac: Change common to gdbsupport. * gdbsupport: Rename from common. * acinclude.m4: Change common to gdbsupport. * Makefile.in (CONFIG_SRC_SUBDIR, COMMON_SFILES) (HFILES_NO_SRCDIR, stamp-version, ALLDEPFILES): Change common to gdbsupport. * aarch64-tdep.c, ada-lang.c, ada-lang.h, agent.c, alloc.c, amd64-darwin-tdep.c, amd64-dicos-tdep.c, amd64-fbsd-nat.c, amd64-fbsd-tdep.c, amd64-linux-nat.c, amd64-linux-tdep.c, amd64-nbsd-tdep.c, amd64-obsd-tdep.c, amd64-sol2-tdep.c, amd64-tdep.c, amd64-windows-tdep.c, arch-utils.c, arch/aarch64-insn.c, arch/aarch64.c, arch/aarch64.h, arch/amd64.c, arch/amd64.h, arch/arm-get-next-pcs.c, arch/arm-linux.c, arch/arm.c, arch/i386.c, arch/i386.h, arch/ppc-linux-common.c, arch/riscv.c, arch/riscv.h, arch/tic6x.c, arm-tdep.c, auto-load.c, auxv.c, ax-gdb.c, ax-general.c, ax.h, breakpoint.c, breakpoint.h, btrace.c, btrace.h, build-id.c, build-id.h, c-lang.h, charset.c, charset.h, cli/cli-cmds.c, cli/cli-cmds.h, cli/cli-decode.c, cli/cli-dump.c, cli/cli-option.h, cli/cli-script.c, coff-pe-read.c, command.h, compile/compile-c-support.c, compile/compile-c.h, compile/compile-cplus-symbols.c, compile/compile-cplus-types.c, compile/compile-cplus.h, compile/compile-loc2c.c, compile/compile.c, completer.c, completer.h, contrib/ari/gdb_ari.sh, corefile.c, corelow.c, cp-support.c, cp-support.h, cp-valprint.c, csky-tdep.c, ctf.c, darwin-nat.c, debug.c, defs.h, disasm-selftests.c, disasm.c, disasm.h, dtrace-probe.c, dwarf-index-cache.c, dwarf-index-cache.h, dwarf-index-write.c, dwarf2-frame.c, dwarf2expr.c, dwarf2loc.c, dwarf2read.c, event-loop.c, event-top.c, exceptions.c, exec.c, extension.h, fbsd-nat.c, features/aarch64-core.c, features/aarch64-fpu.c, features/aarch64-pauth.c, features/aarch64-sve.c, features/i386/32bit-avx.c, features/i386/32bit-avx512.c, features/i386/32bit-core.c, features/i386/32bit-linux.c, features/i386/32bit-mpx.c, features/i386/32bit-pkeys.c, features/i386/32bit-segments.c, features/i386/32bit-sse.c, features/i386/64bit-avx.c, features/i386/64bit-avx512.c, features/i386/64bit-core.c, features/i386/64bit-linux.c, features/i386/64bit-mpx.c, features/i386/64bit-pkeys.c, features/i386/64bit-segments.c, features/i386/64bit-sse.c, features/i386/x32-core.c, features/riscv/32bit-cpu.c, features/riscv/32bit-csr.c, features/riscv/32bit-fpu.c, features/riscv/64bit-cpu.c, features/riscv/64bit-csr.c, features/riscv/64bit-fpu.c, features/tic6x-c6xp.c, features/tic6x-core.c, features/tic6x-gp.c, filename-seen-cache.h, findcmd.c, findvar.c, fork-child.c, gcore.c, gdb_bfd.c, gdb_bfd.h, gdb_proc_service.h, gdb_regex.c, gdb_select.h, gdb_usleep.c, gdbarch-selftests.c, gdbthread.h, gdbtypes.h, gnu-nat.c, go32-nat.c, guile/guile.c, guile/scm-ports.c, guile/scm-safe-call.c, guile/scm-type.c, i386-fbsd-nat.c, i386-fbsd-tdep.c, i386-go32-tdep.c, i386-linux-nat.c, i386-linux-tdep.c, i386-tdep.c, i387-tdep.c, ia64-libunwind-tdep.c, ia64-linux-nat.c, inf-child.c, inf-ptrace.c, infcall.c, infcall.h, infcmd.c, inferior-iter.h, inferior.c, inferior.h, inflow.c, inflow.h, infrun.c, infrun.h, inline-frame.c, language.h, linespec.c, linux-fork.c, linux-nat.c, linux-tdep.c, linux-thread-db.c, location.c, machoread.c, macrotab.h, main.c, maint.c, maint.h, memattr.c, memrange.h, mi/mi-cmd-break.h, mi/mi-cmd-env.c, mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-interp.c, mi/mi-main.c, mi/mi-parse.h, minsyms.c, mips-linux-tdep.c, namespace.h, nat/aarch64-linux-hw-point.c, nat/aarch64-linux-hw-point.h, nat/aarch64-linux.c, nat/aarch64-sve-linux-ptrace.c, nat/amd64-linux-siginfo.c, nat/fork-inferior.c, nat/linux-btrace.c, nat/linux-btrace.h, nat/linux-namespaces.c, nat/linux-nat.h, nat/linux-osdata.c, nat/linux-personality.c, nat/linux-procfs.c, nat/linux-ptrace.c, nat/linux-ptrace.h, nat/linux-waitpid.c, nat/mips-linux-watch.c, nat/mips-linux-watch.h, nat/ppc-linux.c, nat/x86-dregs.c, nat/x86-dregs.h, nat/x86-linux-dregs.c, nat/x86-linux.c, nto-procfs.c, nto-tdep.c, objfile-flags.h, objfiles.c, objfiles.h, obsd-nat.c, observable.h, osdata.c, p-valprint.c, parse.c, parser-defs.h, ppc-linux-nat.c, printcmd.c, probe.c, proc-api.c, procfs.c, producer.c, progspace.h, psymtab.h, python/py-framefilter.c, python/py-inferior.c, python/py-ref.h, python/py-type.c, python/python.c, record-btrace.c, record-full.c, record.c, record.h, regcache-dump.c, regcache.c, regcache.h, remote-fileio.c, remote-fileio.h, remote-sim.c, remote.c, riscv-tdep.c, rs6000-aix-tdep.c, rust-exp.y, s12z-tdep.c, selftest-arch.c, ser-base.c, ser-event.c, ser-pipe.c, ser-tcp.c, ser-unix.c, skip.c, solib-aix.c, solib-target.c, solib.c, source-cache.c, source.c, source.h, sparc-nat.c, spu-linux-nat.c, stack.c, stap-probe.c, symfile-add-flags.h, symfile.c, symfile.h, symtab.c, symtab.h, target-descriptions.c, target-descriptions.h, target-memory.c, target.c, target.h, target/waitstatus.c, target/waitstatus.h, thread-iter.h, thread.c, tilegx-tdep.c, top.c, top.h, tracefile-tfile.c, tracefile.c, tracepoint.c, tracepoint.h, tui/tui-io.c, ui-file.c, ui-out.h, unittests/array-view-selftests.c, unittests/child-path-selftests.c, unittests/cli-utils-selftests.c, unittests/common-utils-selftests.c, unittests/copy_bitwise-selftests.c, unittests/environ-selftests.c, unittests/format_pieces-selftests.c, unittests/function-view-selftests.c, unittests/lookup_name_info-selftests.c, unittests/memory-map-selftests.c, unittests/memrange-selftests.c, unittests/mkdir-recursive-selftests.c, unittests/observable-selftests.c, unittests/offset-type-selftests.c, unittests/optional-selftests.c, unittests/parse-connection-spec-selftests.c, unittests/ptid-selftests.c, unittests/rsp-low-selftests.c, unittests/scoped_fd-selftests.c, unittests/scoped_mmap-selftests.c, unittests/scoped_restore-selftests.c, unittests/string_view-selftests.c, unittests/style-selftests.c, unittests/tracepoint-selftests.c, unittests/unpack-selftests.c, unittests/utils-selftests.c, unittests/xml-utils-selftests.c, utils.c, utils.h, valarith.c, valops.c, valprint.c, value.c, value.h, varobj.c, varobj.h, windows-nat.c, x86-linux-nat.c, xml-support.c, xml-support.h, xml-tdesc.h, xstormy16-tdep.c, xtensa-linux-nat.c, dwarf2read.h: Change common to gdbsupport. gdb/gdbserver/ChangeLog 2019-07-09 Tom Tromey <tom@tromey.com> * configure: Rebuild. * configure.ac: Change common to gdbsupport. * acinclude.m4: Change common to gdbsupport. * Makefile.in (SFILES, OBS, GDBREPLAY_OBS, IPA_OBJS) (version-generated.c, gdbsupport/%-ipa.o, gdbsupport/%.o): Change common to gdbsupport. * ax.c, event-loop.c, fork-child.c, gdb_proc_service.h, gdbreplay.c, gdbthread.h, hostio-errno.c, hostio.c, i387-fp.c, inferiors.c, inferiors.h, linux-aarch64-tdesc-selftest.c, linux-amd64-ipa.c, linux-i386-ipa.c, linux-low.c, linux-tic6x-low.c, linux-x86-low.c, linux-x86-tdesc-selftest.c, linux-x86-tdesc.c, lynx-i386-low.c, lynx-low.c, mem-break.h, nto-x86-low.c, regcache.c, regcache.h, remote-utils.c, server.c, server.h, spu-low.c, symbol.c, target.h, tdesc.c, tdesc.h, thread-db.c, tracepoint.c, win32-i386-low.c, win32-low.c: Change common to gdbsupport.
2019-05-06 04:29:24 +02:00
#include "gdbsupport/selftest.h"
/* Basic byte-swapping routines. All 'extract' functions return a
host-format integer from a target-format integer at ADDR which is
LEN bytes long. */
#if TARGET_CHAR_BIT != 8 || HOST_CHAR_BIT != 8
/* 8 bit characters are a pretty safe assumption these days, so we
assume it throughout all these swapping routines. If we had to deal with
9 bit characters, we would need to make len be in bits and would have
to re-write these routines... */
1999-07-07 22:19:36 +02:00
you lose
#endif
extract/store integer function template This patch converts functions extract_{unsigned,signed}_integer to a function template extract_integer, which has two instantiations. It also does the similar changes to store__{unsigned,signed}_integer, regcache::raw_read_{unsigned,signed}, regcache::raw_write_{unsigned,signed}, regcache::cooked_read_{unsigned,signed}, regcache::cooked_write_{unsigned,signed}. This patch was posted here https://sourceware.org/ml/gdb-patches/2017-05/msg00492.html but the problem was fixed in a different way. However, I think the patch is still useful to shorten the code. gdb: 2017-06-16 Alan Hayward <alan.hayward@arm.com> Pedro Alves <palves@redhat.com> Yao Qi <yao.qi@linaro.org> * defs.h (RequireLongest): New. (extract_integer): Declare function template. (extract_signed_integer): Remove the declaration, but define it static inline. (extract_unsigned_integer): Likewise. (store_integer): Declare function template. (store_signed_integer): Remove the declaration, but define it static inline. (store_unsigned_integer): Likewise. * findvar.c (extract_integer): New function template. (extract_signed_integer): Remove. (extract_unsigned_integer): Remove. (extract_integer<LONGEST>, extract_integer<ULONGEST>): Explicit instantiations. (store_integer): New function template. (store_signed_integer): Remove. (store_unsigned_integer): Remove. (store_integer): Explicit instantiations. * regcache.c (regcache_raw_read_signed): Update. (regcache::raw_read): New function. (regcache::raw_read_signed): Remove. (regcache::raw_read_unsigned): Remove. (regcache_raw_read_unsigned): Update. (regcache_raw_write_unsigned): Update. (regcache::raw_write_signed): Remove. (regcache::raw_write): New function. (regcache_cooked_read_signed): Update. (regcache::raw_write_unsigned): Remove. (regcache::cooked_read_signed): Remove. (regcache_cooked_read_unsigned): Update. (regcache::cooked_read_unsigned): Remove. (regcache_cooked_write_signed): Update. (regcache_cooked_write_unsigned): Update. * regcache.h (regcache) <raw_read_signed>: Remove. <raw_write_signed, raw_read_unsigned, raw_write_unsigned>: Remove. <raw_read, raw_write>: New. <cooked_read_signed, cooked_write_signed>: Remove. <cooked_write_unsigned, cooked_read_unsigned>: Remove. <cooked_read, cooked_write>: New. * sh64-tdep.c (sh64_pseudo_register_read): Update. (sh64_pseudo_register_write): Update.
2017-06-16 16:38:42 +02:00
template<typename T, typename>
T
extract_integer (const gdb_byte *addr, int len, enum bfd_endian byte_order)
{
typename std::make_unsigned<T>::type retval = 0;
const unsigned char *p;
const unsigned char *startaddr = addr;
const unsigned char *endaddr = startaddr + len;
extract/store integer function template This patch converts functions extract_{unsigned,signed}_integer to a function template extract_integer, which has two instantiations. It also does the similar changes to store__{unsigned,signed}_integer, regcache::raw_read_{unsigned,signed}, regcache::raw_write_{unsigned,signed}, regcache::cooked_read_{unsigned,signed}, regcache::cooked_write_{unsigned,signed}. This patch was posted here https://sourceware.org/ml/gdb-patches/2017-05/msg00492.html but the problem was fixed in a different way. However, I think the patch is still useful to shorten the code. gdb: 2017-06-16 Alan Hayward <alan.hayward@arm.com> Pedro Alves <palves@redhat.com> Yao Qi <yao.qi@linaro.org> * defs.h (RequireLongest): New. (extract_integer): Declare function template. (extract_signed_integer): Remove the declaration, but define it static inline. (extract_unsigned_integer): Likewise. (store_integer): Declare function template. (store_signed_integer): Remove the declaration, but define it static inline. (store_unsigned_integer): Likewise. * findvar.c (extract_integer): New function template. (extract_signed_integer): Remove. (extract_unsigned_integer): Remove. (extract_integer<LONGEST>, extract_integer<ULONGEST>): Explicit instantiations. (store_integer): New function template. (store_signed_integer): Remove. (store_unsigned_integer): Remove. (store_integer): Explicit instantiations. * regcache.c (regcache_raw_read_signed): Update. (regcache::raw_read): New function. (regcache::raw_read_signed): Remove. (regcache::raw_read_unsigned): Remove. (regcache_raw_read_unsigned): Update. (regcache_raw_write_unsigned): Update. (regcache::raw_write_signed): Remove. (regcache::raw_write): New function. (regcache_cooked_read_signed): Update. (regcache::raw_write_unsigned): Remove. (regcache::cooked_read_signed): Remove. (regcache_cooked_read_unsigned): Update. (regcache::cooked_read_unsigned): Remove. (regcache_cooked_write_signed): Update. (regcache_cooked_write_unsigned): Update. * regcache.h (regcache) <raw_read_signed>: Remove. <raw_write_signed, raw_read_unsigned, raw_write_unsigned>: Remove. <raw_read, raw_write>: New. <cooked_read_signed, cooked_write_signed>: Remove. <cooked_write_unsigned, cooked_read_unsigned>: Remove. <cooked_read, cooked_write>: New. * sh64-tdep.c (sh64_pseudo_register_read): Update. (sh64_pseudo_register_write): Update.
2017-06-16 16:38:42 +02:00
if (len > (int) sizeof (T))
2005-02-10 Andrew Cagney <cagney@gnu.org> Mark up all error and warning messages. * ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update. * bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update. * core-aout.c, core-regset.c, corefile.c, corelow.c: Update. * cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update. * dbxread.c, demangle.c, doublest.c, dsrec.c: Update. * dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update. * dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update. * event-top.c, exec.c, expprint.c, f-lang.c: Update. * f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update. * frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update. * gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update. * hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update. * hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update. * hpread.c, hpux-thread.c, i386-linux-nat.c: Update. * i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update. * i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update. * ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update. * infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update. * inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update. * kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update. * linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update. * m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update. * m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update. * maint.c, mdebugread.c, mem-break.c, memattr.c: Update. * mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update. * nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update. * observer.c, ocd.c, p-lang.c, p-typeprint.c: Update. * p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update. * ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update. * remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update. * remote-rdp.c, remote-sim.c, remote-st.c: Update. * remote-utils.c, remote-utils.h, remote.c: Update. * rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update. * ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update. * sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update. * solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update. * solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update. * somread.c, somsolib.c, source.c, stabsread.c: Update. * stack.c, std-regs.c, symfile-mem.c, symfile.c: Update. * symmisc.c, symtab.c, target.c, thread.c, top.c: Update. * tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update. * uw-thread.c, valarith.c, valops.c, valprint.c: Update. * value.c, varobj.c, version.in, win32-nat.c, wince.c: Update. * xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update. * cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update. * cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update. * mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update. * mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update. * mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update. * tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
error (_("\
That operation is not available on integers of more than %d bytes."),
extract/store integer function template This patch converts functions extract_{unsigned,signed}_integer to a function template extract_integer, which has two instantiations. It also does the similar changes to store__{unsigned,signed}_integer, regcache::raw_read_{unsigned,signed}, regcache::raw_write_{unsigned,signed}, regcache::cooked_read_{unsigned,signed}, regcache::cooked_write_{unsigned,signed}. This patch was posted here https://sourceware.org/ml/gdb-patches/2017-05/msg00492.html but the problem was fixed in a different way. However, I think the patch is still useful to shorten the code. gdb: 2017-06-16 Alan Hayward <alan.hayward@arm.com> Pedro Alves <palves@redhat.com> Yao Qi <yao.qi@linaro.org> * defs.h (RequireLongest): New. (extract_integer): Declare function template. (extract_signed_integer): Remove the declaration, but define it static inline. (extract_unsigned_integer): Likewise. (store_integer): Declare function template. (store_signed_integer): Remove the declaration, but define it static inline. (store_unsigned_integer): Likewise. * findvar.c (extract_integer): New function template. (extract_signed_integer): Remove. (extract_unsigned_integer): Remove. (extract_integer<LONGEST>, extract_integer<ULONGEST>): Explicit instantiations. (store_integer): New function template. (store_signed_integer): Remove. (store_unsigned_integer): Remove. (store_integer): Explicit instantiations. * regcache.c (regcache_raw_read_signed): Update. (regcache::raw_read): New function. (regcache::raw_read_signed): Remove. (regcache::raw_read_unsigned): Remove. (regcache_raw_read_unsigned): Update. (regcache_raw_write_unsigned): Update. (regcache::raw_write_signed): Remove. (regcache::raw_write): New function. (regcache_cooked_read_signed): Update. (regcache::raw_write_unsigned): Remove. (regcache::cooked_read_signed): Remove. (regcache_cooked_read_unsigned): Update. (regcache::cooked_read_unsigned): Remove. (regcache_cooked_write_signed): Update. (regcache_cooked_write_unsigned): Update. * regcache.h (regcache) <raw_read_signed>: Remove. <raw_write_signed, raw_read_unsigned, raw_write_unsigned>: Remove. <raw_read, raw_write>: New. <cooked_read_signed, cooked_write_signed>: Remove. <cooked_write_unsigned, cooked_read_unsigned>: Remove. <cooked_read, cooked_write>: New. * sh64-tdep.c (sh64_pseudo_register_read): Update. (sh64_pseudo_register_write): Update.
2017-06-16 16:38:42 +02:00
(int) sizeof (T));
/* Start at the most significant end of the integer, and work towards
the least significant. */
* defs.h (extract_signed_integer, extract_unsigned_integer, extract_long_unsigned_integer, store_signed_integer, store_unsigned_integer): Add BYTE_ORDER parameter. * findvar.c (extract_signed_integer, extract_unsigned_integer, extract_long_unsigned_integer, store_signed_integer, store_unsigned_integer): Add BYTE_ORDER parameter. Use it instead of current_gdbarch. * gdbcore.h (read_memory_integer, safe_read_memory_integer, read_memory_unsigned_integer, write_memory_signed_integer, write_memory_unsigned_integer): Add BYTE_ORDER parameter. * corefile.c (struct captured_read_memory_integer_arguments): Add BYTE_ORDER member. (safe_read_memory_integer): Add BYTE_ORDER parameter. Store it into struct captured_read_memory_integer_arguments. (do_captured_read_memory_integer): Pass it to read_memory_integer. (read_memory_integer): Add BYTE_ORDER parameter. Pass it to extract_signed_integer. (read_memory_unsigned_integer): Add BYTE_ORDER parameter. Pass it to extract_unsigned_integer. (write_memory_signed_integer): Add BYTE_ORDER parameter. Pass it to store_signed_integer. (write_memory_unsigned_integer): Add BYTE_ORDER parameter. Pass it to store_unsigned_integer. * target.h (get_target_memory_unsigned): Add BYTE_ORDER parameter. * target.c (get_target_memory_unsigned): Add BYTE_ORDER parameter. Pass it to extract_unsigned_integer. Update calls to extract_signed_integer, extract_unsigned_integer, extract_long_unsigned_integer, store_signed_integer, store_unsigned_integer, read_memory_integer, read_memory_unsigned_integer, safe_read_memory_integer, write_memory_signed_integer, write_memory_unsigned_integer, and get_target_memory_unsigned to pass byte order: * ada-lang.c (ada_value_binop): Update. * ada-valprint.c (char_at): Update. * alpha-osf1-tdep.c (alpha_osf1_sigcontext_addr): Update. * alpha-tdep.c (alpha_lds, alpha_sts, alpha_push_dummy_call, alpha_extract_return_value, alpha_read_insn, alpha_get_longjmp_target): Update. * amd64-linux-tdep.c (amd64_linux_sigcontext_addr): Update. * amd64obsd-tdep.c (amd64obsd_supply_uthread, amd64obsd_collect_uthread, amd64obsd_trapframe_cache): Update. * amd64-tdep.c (amd64_push_dummy_call, amd64_analyze_prologue, amd64_frame_cache, amd64_sigtramp_frame_cache, fixup_riprel, amd64_displaced_step_fixup): Update. * arm-linux-tdep.c (arm_linux_sigreturn_init, arm_linux_rt_sigreturn_init, arm_linux_supply_gregset): Update. * arm-tdep.c (thumb_analyze_prologue, arm_skip_prologue, arm_scan_prologue, arm_push_dummy_call, thumb_get_next_pc, arm_get_next_pc, arm_extract_return_value, arm_store_return_value, arm_return_value): Update. * arm-wince-tdep.c (arm_pe_skip_trampoline_code): Update. * auxv.c (default_auxv_parse): Update. * avr-tdep.c (avr_address_to_pointer, avr_pointer_to_address, avr_scan_prologue, avr_extract_return_value, avr_frame_prev_register, avr_push_dummy_call): Update. * bsd-uthread.c (bsd_uthread_check_magic, bsd_uthread_lookup_offset, bsd_uthread_wait, bsd_uthread_thread_alive, bsd_uthread_extra_thread_info): Update. * c-lang.c (c_printstr, print_wchar): Update. * cp-valprint.c (cp_print_class_member): Update. * cris-tdep.c (cris_sigcontext_addr, cris_sigtramp_frame_unwind_cache, cris_push_dummy_call, cris_scan_prologue, cris_store_return_value, cris_extract_return_value, find_step_target, dip_prefix, sixteen_bit_offset_branch_op, none_reg_mode_jump_op, move_mem_to_reg_movem_op, get_data_from_address): Update. * dwarf2expr.c (dwarf2_read_address, execute_stack_op): Update. * dwarf2-frame.c (execute_cfa_program): Update. * dwarf2loc.c (find_location_expression): Update. * dwarf2read.c (dwarf2_const_value): Update. * expprint.c (print_subexp_standard): Update. * findvar.c (unsigned_pointer_to_address, signed_pointer_to_address, unsigned_address_to_pointer, address_to_signed_pointer, read_var_value): Update. * frame.c (frame_unwind_register_signed, frame_unwind_register_unsigned, get_frame_memory_signed, get_frame_memory_unsigned): Update. * frame-unwind.c (frame_unwind_got_constant): Update. * frv-linux-tdep.c (frv_linux_pc_in_sigtramp, frv_linux_sigcontext_reg_addr, frv_linux_sigtramp_frame_cache): Update. * frv-tdep.c (frv_analyze_prologue, frv_skip_main_prologue, frv_extract_return_value, find_func_descr, frv_convert_from_func_ptr_addr, frv_push_dummy_call): Update. * f-valprint.c (f_val_print): Update. * gnu-v3-abi.c (gnuv3_decode_method_ptr, gnuv3_make_method_ptr): Update. * h8300-tdep.c (h8300_is_argument_spill, h8300_analyze_prologue, h8300_push_dummy_call, h8300_extract_return_value, h8300h_extract_return_value, h8300_store_return_value, h8300h_store_return_value): Update. * hppabsd-tdep.c (hppabsd_find_global_pointer): Update. * hppa-hpux-nat.c (hppa_hpux_fetch_register, hppa_hpux_store_register): Update. * hppa-hpux-tdep.c (hppa32_hpux_in_solib_call_trampoline, hppa64_hpux_in_solib_call_trampoline, hppa_hpux_in_solib_return_trampoline, hppa_hpux_skip_trampoline_code, hppa_hpux_sigtramp_frame_unwind_cache, hppa_hpux_sigtramp_unwind_sniffer, hppa32_hpux_find_global_pointer, hppa64_hpux_find_global_pointer, hppa_hpux_search_pattern, hppa32_hpux_search_dummy_call_sequence, hppa64_hpux_search_dummy_call_sequence, hppa_hpux_supply_save_state, hppa_hpux_unwind_adjust_stub): Update. * hppa-linux-tdep.c (insns_match_pattern, hppa_linux_find_global_pointer): Update. * hppa-tdep.c (hppa_in_function_epilogue_p, hppa32_push_dummy_call, hppa64_convert_code_addr_to_fptr, hppa64_push_dummy_call, skip_prologue_hard_way, hppa_frame_cache, hppa_fallback_frame_cache, hppa_pseudo_register_read, hppa_frame_prev_register_helper, hppa_match_insns): Update. * hpux-thread.c (hpux_thread_fetch_registers): Update. * i386-tdep.c (i386bsd_sigcontext_addr): Update. * i386-cygwin-tdep.c (core_process_module_section): Update. * i386-darwin-nat.c (i386_darwin_sstep_at_sigreturn, amd64_darwin_sstep_at_sigreturn): Update. * i386-darwin-tdep.c (i386_darwin_sigcontext_addr, amd64_darwin_sigcontext_addr): Likewise. * i386-linux-nat.c (i386_linux_sigcontext_addr): Update. * i386nbsd-tdep.c (i386nbsd_sigtramp_cache_init): Update. * i386-nto-tdep.c (i386nto_sigcontext_addr): Update. * i386obsd-nat.c (i386obsd_supply_pcb): Update. * i386obsd-tdep.c (i386obsd_supply_uthread, i386obsd_collect_uthread, i386obsd_trapframe_cache): Update. * i386-tdep.c (i386_displaced_step_fixup, i386_follow_jump, i386_analyze_frame_setup, i386_analyze_prologue, i386_skip_main_prologue, i386_frame_cache, i386_sigtramp_frame_cache, i386_get_longjmp_target, i386_push_dummy_call, i386_pe_skip_trampoline_code, i386_svr4_sigcontext_addr, i386_fetch_pointer_argument): Update. * i387-tdep.c (i387_supply_fsave): Update. * ia64-linux-tdep.c (ia64_linux_sigcontext_register_address): Update. * ia64-tdep.c (ia64_pseudo_register_read, ia64_pseudo_register_write, examine_prologue, ia64_frame_cache, ia64_frame_prev_register, ia64_sigtramp_frame_cache, ia64_sigtramp_frame_prev_register, ia64_access_reg, ia64_access_rse_reg, ia64_libunwind_frame_this_id, ia64_libunwind_frame_prev_register, ia64_libunwind_sigtramp_frame_this_id, ia64_libunwind_sigtramp_frame_prev_register, ia64_find_global_pointer, find_extant_func_descr, find_func_descr, ia64_convert_from_func_ptr_addr, ia64_push_dummy_call, ia64_dummy_id, ia64_unwind_pc): Update. * iq2000-tdep.c (iq2000_pointer_to_address, iq2000_address_to_pointer, iq2000_scan_prologue, iq2000_extract_return_value, iq2000_push_dummy_call): Update. * irix5nat.c (fill_gregset): Update. * jv-lang.c (evaluate_subexp_java): Update. * jv-valprint.c (java_value_print): Update. * lm32-tdep.c (lm32_analyze_prologue, lm32_push_dummy_call, lm32_extract_return_value, lm32_store_return_value): Update. * m32c-tdep.c (m32c_push_dummy_call, m32c_return_value, m32c_skip_trampoline_code, m32c_m16c_address_to_pointer, m32c_m16c_pointer_to_address): Update. * m32r-tdep.c (m32r_store_return_value, decode_prologue, m32r_skip_prologue, m32r_push_dummy_call, m32r_extract_return_value): Update. * m68hc11-tdep.c (m68hc11_pseudo_register_read, m68hc11_pseudo_register_write, m68hc11_analyze_instruction, m68hc11_push_dummy_call): Update. * m68linux-tdep.c (m68k_linux_pc_in_sigtramp, m68k_linux_get_sigtramp_info, m68k_linux_sigtramp_frame_cache): Update. * m68k-tdep.c (m68k_push_dummy_call, m68k_analyze_frame_setup, m68k_analyze_register_saves, m68k_analyze_prologue, m68k_frame_cache, m68k_get_longjmp_target): Update. * m88k-tdep.c (m88k_fetch_instruction): Update. * mep-tdep.c (mep_pseudo_cr32_read, mep_pseudo_csr_write, mep_pseudo_cr32_write, mep_get_insn, mep_push_dummy_call): Update. * mi/mi-main.c (mi_cmd_data_write_memory): Update. * mips-linux-tdep.c (mips_linux_get_longjmp_target, supply_32bit_reg, mips64_linux_get_longjmp_target, mips64_fill_gregset, mips64_fill_fpregset, mips_linux_in_dynsym_stub): Update. * mipsnbdsd-tdep.c (mipsnbsd_get_longjmp_target): Update. * mips-tdep.c (mips_fetch_instruction, fetch_mips_16, mips_eabi_push_dummy_call, mips_n32n64_push_dummy_call, mips_o32_push_dummy_call, mips_o64_push_dummy_call, mips_single_step_through_delay, mips_skip_pic_trampoline_code, mips_integer_to_address): Update. * mn10300-tdep.c (mn10300_analyze_prologue, mn10300_push_dummy_call): Update. * monitor.c (monitor_supply_register, monitor_write_memory, monitor_read_memory_single): Update. * moxie-tdep.c (moxie_store_return_value, moxie_extract_return_value, moxie_analyze_prologue): Update. * mt-tdep.c (mt_return_value, mt_skip_prologue, mt_select_coprocessor, mt_pseudo_register_read, mt_pseudo_register_write, mt_registers_info, mt_push_dummy_call): Update. * objc-lang.c (read_objc_method, read_objc_methlist_nmethods, read_objc_methlist_method, read_objc_object, read_objc_super, read_objc_class, find_implementation_from_class): Update. * ppc64-linux-tdep.c (ppc64_desc_entry_point, ppc64_linux_convert_from_func_ptr_addr, ppc_linux_sigtramp_cache): Update. * ppcobsd-tdep.c (ppcobsd_sigtramp_frame_sniffer, ppcobsd_sigtramp_frame_cache): Update. * ppc-sysv-tdep.c (ppc_sysv_abi_push_dummy_call, do_ppc_sysv_return_value, ppc64_sysv_abi_push_dummy_call, ppc64_sysv_abi_return_value): Update. * ppc-linux-nat.c (ppc_linux_auxv_parse): Update. * procfs.c (procfs_auxv_parse): Update. * p-valprint.c (pascal_val_print): Update. * regcache.c (regcache_raw_read_signed, regcache_raw_read_unsigned, regcache_raw_write_signed, regcache_raw_write_unsigned, regcache_cooked_read_signed, regcache_cooked_read_unsigned, regcache_cooked_write_signed, regcache_cooked_write_unsigned): Update. * remote-m32r-sdi.c (m32r_fetch_register): Update. * remote-mips.c (mips_wait, mips_fetch_registers, mips_xfer_memory): Update. * rs6000-aix-tdep.c (rs6000_push_dummy_call, rs6000_return_value, rs6000_convert_from_func_ptr_addr, branch_dest, rs6000_software_single_step): Update. * rs6000-tdep.c (rs6000_in_function_epilogue_p, ppc_displaced_step_fixup, ppc_deal_with_atomic_sequence, bl_to_blrl_insn_p, rs6000_fetch_instruction, skip_prologue, rs6000_skip_main_prologue, rs6000_skip_trampoline_code, rs6000_frame_cache): Update. * s390-tdep.c (s390_pseudo_register_read, s390_pseudo_register_write, s390x_pseudo_register_read, s390x_pseudo_register_write, s390_load, s390_backchain_frame_unwind_cache, s390_sigtramp_frame_unwind_cache, extend_simple_arg, s390_push_dummy_call, s390_return_value): Update. * scm-exp.c (scm_lreadr): Update. * scm-lang.c (scm_get_field, scm_unpack): Update. * scm-valprint.c (scm_val_print): Update. * score-tdep.c (score_breakpoint_from_pc, score_push_dummy_call, score_fetch_inst): Update. * sh64-tdep.c (look_for_args_moves, sh64_skip_prologue_hard_way, sh64_analyze_prologue, sh64_push_dummy_call, sh64_extract_return_value, sh64_pseudo_register_read, sh64_pseudo_register_write, sh64_frame_prev_register): Update: * sh-tdep.c (sh_analyze_prologue, sh_push_dummy_call_fpu, sh_push_dummy_call_nofpu, sh_extract_return_value_nofpu, sh_store_return_value_nofpu, sh_in_function_epilogue_p): Update. * solib-darwin.c (darwin_load_image_infos): Update. * solib-frv.c (fetch_loadmap, lm_base, frv_current_sos, enable_break2, find_canonical_descriptor_in_load_object): Update. * solib-irix.c (extract_mips_address, fetch_lm_info, irix_current_sos, irix_open_symbol_file_object): Update. * solib-som.c (som_solib_create_inferior_hook, link_map_start, som_current_sos, som_open_symbol_file_object): Update. * solib-sunos.c (SOLIB_EXTRACT_ADDRESS, LM_ADDR, LM_NEXT, LM_NAME): Update. * solib-svr4.c (read_program_header, scan_dyntag_auxv, solib_svr4_r_ldsomap): Update. * sparc64-linux-tdep.c (sparc64_linux_step_trap): Update. * sparc64obsd-tdep.c (sparc64obsd_supply_uthread, sparc64obsd_collect_uthread): Update. * sparc64-tdep.c (sparc64_pseudo_register_read, sparc64_pseudo_register_write, sparc64_supply_gregset, sparc64_collect_gregset): Update. * sparc-linux-tdep.c (sparc32_linux_step_trap): Update. * sparcobsd-tdep.c (sparc32obsd_supply_uthread, sparc32obsd_collect_uthread): Update. * sparc-tdep.c (sparc_fetch_wcookie, sparc32_push_dummy_code, sparc32_store_arguments, sparc32_return_value, sparc_supply_rwindow, sparc_collect_rwindow): Update. * spu-linux-nat.c (parse_spufs_run): Update. * spu-tdep.c (spu_pseudo_register_read_spu, spu_pseudo_register_write_spu, spu_pointer_to_address, spu_analyze_prologue, spu_in_function_epilogue_p, spu_frame_unwind_cache, spu_push_dummy_call, spu_software_single_step, spu_get_longjmp_target, spu_get_overlay_table, spu_overlay_update_osect, info_spu_signal_command, info_spu_mailbox_list, info_spu_dma_cmdlist, info_spu_dma_command, info_spu_proxydma_command): Update. * stack.c (print_frame_nameless_args, frame_info): Update. * symfile.c (read_target_long_array, simple_read_overlay_table, simple_read_overlay_region_table): Update. * target.c (debug_print_register): Update. * tramp-frame.c (tramp_frame_start): Update. * v850-tdep.c (v850_analyze_prologue, v850_push_dummy_call, v850_extract_return_value, v850_store_return_value, * valarith.c (value_binop, value_bit_index): Update. * valops.c (value_cast): Update. * valprint.c (val_print_type_code_int, val_print_string, read_string): Update. * value.c (unpack_long, unpack_double, unpack_field_as_long, modify_field, pack_long): Update. * vax-tdep.c (vax_store_arguments, vax_push_dummy_call, vax_skip_prologue): Update. * xstormy16-tdep.c (xstormy16_push_dummy_call, xstormy16_analyze_prologue, xstormy16_in_function_epilogue_p, xstormy16_resolve_jmp_table_entry, xstormy16_find_jmp_table_entry, xstormy16_pointer_to_address, xstormy16_address_to_pointer): Update. * xtensa-tdep.c (extract_call_winsize, xtensa_pseudo_register_read, xtensa_pseudo_register_write, xtensa_frame_cache, xtensa_push_dummy_call, call0_track_op, call0_frame_cache): Update. * dfp.h (decimal_to_string, decimal_from_string, decimal_from_integral, decimal_from_floating, decimal_to_doublest, decimal_is_zero): Add BYTE_ORDER parameter. (decimal_binop): Add BYTE_ORDER_X, BYTE_ORDER_Y, and BYTE_ORDER_RESULT parameters. (decimal_compare): Add BYTE_ORDER_X and BYTE_ORDER_Y parameters. (decimal_convert): Add BYTE_ORDER_FROM and BYTE_ORDER_TO parameters. * dfp.c (match_endianness): Add BYTE_ORDER parameter. Use it instead of current_gdbarch. (decimal_to_string, decimal_from_integral, decimal_from_floating, decimal_to_doublest, decimal_is_zero): Add BYTE_ORDER parameter. Pass it to match_endianness. (decimal_binop): Add BYTE_ORDER_X, BYTE_ORDER_Y, and BYTE_ORDER_RESULT parameters. Pass them to match_endianness. (decimal_compare): Add BYTE_ORDER_X and BYTE_ORDER_Y parameters. Pass them to match_endianness. (decimal_convert): Add BYTE_ORDER_FROM and BYTE_ORDER_TO parameters. Pass them to match_endianness. * valarith.c (value_args_as_decimal): Add BYTE_ORDER_X and BYTE_ORDER_Y output parameters. (value_binop): Update call to value_args_as_decimal. Update calls to decimal_to_string, decimal_from_string, decimal_from_integral, decimal_from_floating, decimal_to_doublest, decimal_is_zero, decimal_binop, decimal_compare and decimal_convert to pass/receive byte order: * c-exp.y (parse_number): Update. * printcmd.c (printf_command): Update. * valarith.c (value_args_as_decimal, value_binop, value_logical_not, value_equal, value_less): Update. * valops.c (value_cast, value_one): Update. * valprint.c (print_decimal_floating): Update. * value.c (unpack_long, unpack_double): Update. * python/python-value.c (valpy_nonzero): Update. * ada-valprint.c (char_at): Add BYTE_ORDER parameter. (printstr): Update calls to char_at. (ada_val_print_array): Likewise. * valprint.c (read_string): Add BYTE_ORDER parameter. (val_print_string): Update call to read_string. * c-lang.c (c_get_string): Likewise. * charset.h (target_wide_charset): Add BYTE_ORDER parameter. * charset.c (target_wide_charset): Add BYTE_ORDER parameter. Use it instead of current_gdbarch. * printcmd.c (printf_command): Update calls to target_wide_charset. * c-lang.c (charset_for_string_type): Add BYTE_ORDER parameter. Pass to target_wide_charset. Use it instead of current_gdbarch. (classify_type): Add BYTE_ORDER parameter. Pass to charset_for_string_type. Allow NULL encoding pointer. (print_wchar): Add BYTE_ORDER parameter. (c_emit_char): Update calls to classify_type and print_wchar. (c_printchar, c_printstr): Likewise. * gdbarch.sh (in_solib_return_trampoline): Convert to type "m". * gdbarch.c, gdbarch.h: Regenerate. * arch-utils.h (generic_in_solib_return_trampoline): Add GDBARCH parameter. * arch-utils.c (generic_in_solib_return_trampoline): Likewise. * hppa-hpux-tdep.c (hppa_hpux_in_solib_return_trampoline): Likewise. * rs6000-tdep.c (rs6000_in_solib_return_trampoline): Likewise. (rs6000_skip_trampoline_code): Update call. * alpha-tdep.h (struct gdbarch_tdep): Add GDBARCH parameter to dynamic_sigtramp_offset and pc_in_sigtramp callbacks. (alpha_read_insn): Add GDBARCH parameter. * alpha-tdep.c (alpha_lds, alpha_sts): Add GDBARCH parameter. (alpha_register_to_value): Pass architecture to alpha_sts. (alpha_extract_return_value): Likewise. (alpha_value_to_register): Pass architecture to alpha_lds. (alpha_store_return_value): Likewise. (alpha_read_insn): Add GDBARCH parameter. (alpha_skip_prologue): Pass architecture to alpha_read_insn. (alpha_heuristic_proc_start): Likewise. (alpha_heuristic_frame_unwind_cache): Likewise. (alpha_next_pc): Likewise. (alpha_sigtramp_frame_this_id): Pass architecture to tdep->dynamic_sigtramp_offset callback. (alpha_sigtramp_frame_sniffer): Pass architecture to tdep->pc_in_sigtramp callback. * alphafbsd-tdep.c (alphafbsd_pc_in_sigtramp): Add GDBARCH parameter. (alphafbsd_sigtramp_offset): Likewise. * alpha-linux-tdep.c (alpha_linux_sigtramp_offset_1): Add GDBARCH parameter. Pass to alpha_read_insn. (alpha_linux_sigtramp_offset): Add GDBARCH parameter. Pass to alpha_linux_sigtramp_offset_1. (alpha_linux_pc_in_sigtramp): Add GDBARCH parameter. Pass to alpha_linux_sigtramp_offset. (alpha_linux_sigcontext_addr): Pass architecture to alpha_read_insn and alpha_linux_sigtramp_offset. * alphanbsd-tdep.c (alphanbsd_sigtramp_offset): Add GDBARCH parameter. (alphanbsd_pc_in_sigtramp): Add GDBARCH parameter. Pass to alphanbsd_sigtramp_offset. * alphaobsd-tdep.c (alphaobsd_sigtramp_offset): Add GDBARCH parameter. (alphaobsd_pc_in_sigtramp): Add GDBARCH parameter. Pass to alpha_read_insn. (alphaobsd_sigcontext_addr): Pass architecture to alphaobsd_sigtramp_offset. * alpha-osf1-tdep.c (alpha_osf1_pc_in_sigtramp): Add GDBARCH parameter. * amd64-tdep.c (amd64_analyze_prologue): Add GDBARCH parameter. (amd64_skip_prologue): Pass architecture to amd64_analyze_prologue. (amd64_frame_cache): Likewise. * arm-tdep.c (SWAP_SHORT, SWAP_INT): Remove. (thumb_analyze_prologue, arm_skip_prologue, arm_scan_prologue, thumb_get_next_pc, arm_get_next_pc): Do not use SWAP_ macros. * arm-wince-tdep.c: Include "frame.h". * avr-tdep.c (EXTRACT_INSN): Remove. (avr_scan_prologue): Add GDBARCH argument, inline EXTRACT_INSN. (avr_skip_prologue): Pass architecture to avr_scan_prologue. (avr_frame_unwind_cache): Likewise. * cris-tdep.c (struct instruction_environment): Add BYTE_ORDER member. (find_step_target): Initialize it. (get_data_from_address): Add BYTE_ORDER parameter. (bdap_prefix): Pass byte order to get_data_from_address. (handle_prefix_assign_mode_for_aritm_op): Likewise. (three_operand_add_sub_cmp_and_or_op): Likewise. (handle_inc_and_index_mode_for_aritm_op): Likewise. * frv-linux-tdep.c (frv_linux_pc_in_sigtramp): Add GDBARCH parameter. (frv_linux_sigcontext_reg_addr): Pass architecture to frv_linux_pc_in_sigtramp. (frv_linux_sigtramp_frame_sniffer): Likewise. * h8300-tdep.c (h8300_is_argument_spill): Add GDBARCH parameter. (h8300_analyze_prologue): Add GDBARCH parameter. Pass to h8300_is_argument_spill. (h8300_frame_cache, h8300_skip_prologue): Pass architecture to h8300_analyze_prologue. * hppa-tdep.h (struct gdbarch_tdep): Add GDBARCH parameter to in_solib_call_trampoline callback. (hppa_in_solib_call_trampoline): Add GDBARCH parameter. * hppa-tdep.c (hppa64_convert_code_addr_to_fptr): Add GDBARCH parameter. (hppa64_push_dummy_call): Pass architecture to hppa64_convert_code_addr_to_fptr. (hppa_match_insns): Add GDBARCH parameter. (hppa_match_insns_relaxed): Add GDBARCH parameter. Pass to hppa_match_insns. (hppa_skip_trampoline_code): Pass architecture to hppa_match_insns. (hppa_in_solib_call_trampoline): Add GDBARCH parameter. Pass to hppa_match_insns_relaxed. (hppa_stub_unwind_sniffer): Pass architecture to tdep->in_solib_call_trampoline callback. * hppa-hpux-tdep.c (hppa_hpux_search_pattern): Add GDBARCH parameter. (hppa32_hpux_search_dummy_call_sequence): Pass architecture to hppa_hpux_search_pattern. * hppa-linux-tdep.c (insns_match_pattern): Add GDBARCH parameter. (hppa_linux_sigtramp_find_sigcontext): Add GDBARCH parameter. Pass to insns_match_pattern. (hppa_linux_sigtramp_frame_unwind_cache): Pass architecture to hppa_linux_sigtramp_find_sigcontext. (hppa_linux_sigtramp_frame_sniffer): Likewise. (hppa32_hpux_in_solib_call_trampoline): Add GDBARCH parameter. (hppa64_hpux_in_solib_call_trampoline): Likewise. * i386-tdep.c (i386_follow_jump): Add GDBARCH parameter. (i386_analyze_frame_setup): Add GDBARCH parameter. (i386_analyze_prologue): Add GDBARCH parameter. Pass to i386_follow_jump and i386_analyze_frame_setup. (i386_skip_prologue): Pass architecture to i386_analyze_prologue and i386_follow_jump. (i386_frame_cache): Pass architecture to i386_analyze_prologue. (i386_pe_skip_trampoline_code): Add FRAME parameter. * i386-tdep.h (i386_pe_skip_trampoline_code): Add FRAME parameter. * i386-cygwin-tdep.c (i386_cygwin_skip_trampoline_code): Pass frame to i386_pe_skip_trampoline_code. * ia64-tdep.h (struct gdbarch_tdep): Add GDBARCH parameter to sigcontext_register_address callback. * ia64-tdep.c (ia64_find_global_pointer): Add GDBARCH parameter. (ia64_find_unwind_table): Pass architecture to ia64_find_global_pointer. (find_extant_func_descr): Add GDBARCH parameter. (find_func_descr): Pass architecture to find_extant_func_descr and ia64_find_global_pointer. (ia64_sigtramp_frame_init_saved_regs): Pass architecture to tdep->sigcontext_register_address callback. * ia64-linux-tdep.c (ia64_linux_sigcontext_register_address): Add GDBARCH parameter. * iq2000-tdep.c (iq2000_scan_prologue): Add GDBARCH parameter. (iq2000_frame_cache): Pass architecture to iq2000_scan_prologue. * lm32-tdep.c (lm32_analyze_prologue): Add GDBARCH parameter. (lm32_skip_prologue, lm32_frame_cache): Pass architecture to lm32_analyze_prologue. * m32r-tdep.c (decode_prologue): Add GDBARCH parameter. (m32r_skip_prologue): Pass architecture to decode_prologue. * m68hc11-tdep.c (m68hc11_analyze_instruction): Add GDBARCH parameter. (m68hc11_scan_prologue): Pass architecture to m68hc11_analyze_instruction. * m68k-tdep.c (m68k_analyze_frame_setup): Add GDBARCH parameter. (m68k_analyze_prologue): Pass architecture to m68k_analyze_frame_setup. * m88k-tdep.c (m88k_fetch_instruction): Add BYTE_ORDER parameter. (m88k_analyze_prologue): Add GDBARCH parameter. Pass byte order to m88k_fetch_instruction. (m88k_skip_prologue): Pass architecture to m88k_analyze_prologue. (m88k_frame_cache): Likewise. * mep-tdep.c (mep_get_insn): Add GDBARCH parameter. (mep_analyze_prologue): Pass architecture to mep_get_insn. * mips-tdep.c (mips_fetch_instruction): Add GDBARCH parameter. (mips32_next_pc): Pass architecture to mips_fetch_instruction. (deal_with_atomic_sequence): Likewise. (unpack_mips16): Add GDBARCH parameter, pass to mips_fetch_instruction. (mips16_scan_prologue): Likewise. (mips32_scan_prologue): Likewise. (mips16_in_function_epilogue_p): Likewise. (mips32_in_function_epilogue_p): Likewise. (mips_about_to_return): Likewise. (mips_insn16_frame_cache): Pass architecture to mips16_scan_prologue. (mips_insn32_frame_cache): Pass architecture to mips32_scan_prologue. (mips_skip_prologue): Pass architecture to mips16_scan_prologue and mips32_scan_prologue. (mips_in_function_epilogue_p): Pass architecture to mips16_in_function_epilogue_p and mips32_in_function_epilogue_p. (heuristic_proc_start): Pass architecture to mips_fetch_instruction and mips_about_to_return. (mips_skip_mips16_trampoline_code): Pass architecture to mips_fetch_instruction. (fetch_mips_16): Add GDBARCH parameter. (mips16_next_pc): Pass architecture to fetch_mips_16. (extended_mips16_next_pc): Pass architecture to unpack_mips16 and fetch_mips_16. * objc-lang.c (read_objc_method, read_objc_methlist_nmethods, read_objc_methlist_method, read_objc_object, read_objc_super, read_objc_class): Add GDBARCH parameter. (find_implementation_from_class): Add GDBARCH parameter, pass to read_objc_class, read_objc_methlist_nmethods, and read_objc_methlist_method. (find_implementation): Add GDBARCH parameter, pass to read_objc_object and find_implementation_from_class. (resolve_msgsend, resolve_msgsend_stret): Pass architecture to find_implementation. (resolve_msgsend_super, resolve_msgsend_super_stret): Pass architecture to read_objc_super and find_implementation_from_class. * ppc64-linux-tdep.c (ppc64_desc_entry_point): Add GDBARCH parameter. (ppc64_standard_linkage1_target, ppc64_standard_linkage2_target, ppc64_standard_linkage3_target): Pass architecture to ppc64_desc_entry_point. * rs6000-tdep.c (bl_to_blrl_insn_p): Add BYTE_ORDER parameter. (skip_prologue): Pass byte order to bl_to_blrl_insn_p. (rs6000_fetch_instruction): Add GDBARCH parameter. (rs6000_skip_stack_check): Add GDBARCH parameter, pass to rs6000_fetch_instruction. (skip_prologue): Pass architecture to rs6000_fetch_instruction. * remote-mips.c (mips_store_word): Return old_contents as host integer value instead of target bytes. * s390-tdep.c (struct s390_prologue_data): Add BYTE_ORDER member. (s390_analyze_prologue): Initialize it. (extend_simple_arg): Add GDBARCH parameter. (s390_push_dummy_call): Pass architecture to extend_simple_arg. * scm-lang.c (scm_get_field): Add BYTE_ORDER parameter. * scm-lang.h (scm_get_field): Add BYTE_ORDER parameter. (SCM_CAR, SCM_CDR): Pass SCM_BYTE_ORDER to scm_get_field. * scm-valprint.c (scm_scmval_print): Likewise. (scm_scmlist_print, scm_ipruk, scm_scmval_print): Define SCM_BYTE_ORDER. * sh64-tdep.c (look_for_args_moves): Add GDBARCH parameter. (sh64_skip_prologue_hard_way): Add GDBARCH parameter, pass to look_for_args_moves. (sh64_skip_prologue): Pass architecture to sh64_skip_prologue_hard_way. * sh-tdep.c (sh_analyze_prologue): Add GDBARCH parameter. (sh_skip_prologue): Pass architecture to sh_analyze_prologue. (sh_frame_cache): Likewise. * solib-irix.c (extract_mips_address): Add GDBARCH parameter. (fetch_lm_info, irix_current_sos, irix_open_symbol_file_object): Pass architecture to extract_mips_address. * sparc-tdep.h (sparc_fetch_wcookie): Add GDBARCH parameter. * sparc-tdep.c (sparc_fetch_wcookie): Add GDBARCH parameter. (sparc_supply_rwindow, sparc_collect_rwindow): Pass architecture to sparc_fetch_wcookie. (sparc32_frame_prev_register): Likewise. * sparc64-tdep.c (sparc64_frame_prev_register): Likewise. * sparc32nbsd-tdep.c (sparc32nbsd_sigcontext_saved_regs): Likewise. * sparc64nbsd-tdep.c (sparc64nbsd_sigcontext_saved_regs): Likewise. * spu-tdep.c (spu_analyze_prologue): Add GDBARCH parameter. (spu_skip_prologue): Pass architecture to spu_analyze_prologue. (spu_virtual_frame_pointer): Likewise. (spu_frame_unwind_cache): Likewise. (info_spu_mailbox_list): Add BYTE_ORER parameter. (info_spu_mailbox_command): Pass byte order to info_spu_mailbox_list. (info_spu_dma_cmdlist): Add BYTE_ORER parameter. (info_spu_dma_command, info_spu_proxydma_command): Pass byte order to info_spu_dma_cmdlist. * symfile.c (read_target_long_array): Add GDBARCH parameter. (simple_read_overlay_table, simple_read_overlay_region_table, simple_overlay_update_1): Pass architecture to read_target_long_array. * v850-tdep.c (v850_analyze_prologue): Add GDBARCH parameter. (v850_frame_cache): Pass architecture to v850_analyze_prologue. * xstormy16-tdep.c (xstormy16_analyze_prologue): Add GDBARCH parameter. (xstormy16_skip_prologue, xstormy16_frame_cache): Pass architecture to xstormy16_analyze_prologue. (xstormy16_resolve_jmp_table_entry): Add GDBARCH parameter. (xstormy16_find_jmp_table_entry): Likewise. (xstormy16_skip_trampoline_code): Pass architecture to xstormy16_resolve_jmp_table_entry. (xstormy16_pointer_to_address): Likewise. (xstormy16_address_to_pointer): Pass architecture to xstormy16_find_jmp_table_entry. * xtensa-tdep.c (call0_track_op): Add GDBARCH parameter. (call0_analyze_prologue): Add GDBARCH parameter, pass to call0_track_op. (call0_frame_cache): Pass architecture to call0_analyze_prologue. (xtensa_skip_prologue): Likewise.
2009-07-02 19:25:59 +02:00
if (byte_order == BFD_ENDIAN_BIG)
{
p = startaddr;
extract/store integer function template This patch converts functions extract_{unsigned,signed}_integer to a function template extract_integer, which has two instantiations. It also does the similar changes to store__{unsigned,signed}_integer, regcache::raw_read_{unsigned,signed}, regcache::raw_write_{unsigned,signed}, regcache::cooked_read_{unsigned,signed}, regcache::cooked_write_{unsigned,signed}. This patch was posted here https://sourceware.org/ml/gdb-patches/2017-05/msg00492.html but the problem was fixed in a different way. However, I think the patch is still useful to shorten the code. gdb: 2017-06-16 Alan Hayward <alan.hayward@arm.com> Pedro Alves <palves@redhat.com> Yao Qi <yao.qi@linaro.org> * defs.h (RequireLongest): New. (extract_integer): Declare function template. (extract_signed_integer): Remove the declaration, but define it static inline. (extract_unsigned_integer): Likewise. (store_integer): Declare function template. (store_signed_integer): Remove the declaration, but define it static inline. (store_unsigned_integer): Likewise. * findvar.c (extract_integer): New function template. (extract_signed_integer): Remove. (extract_unsigned_integer): Remove. (extract_integer<LONGEST>, extract_integer<ULONGEST>): Explicit instantiations. (store_integer): New function template. (store_signed_integer): Remove. (store_unsigned_integer): Remove. (store_integer): Explicit instantiations. * regcache.c (regcache_raw_read_signed): Update. (regcache::raw_read): New function. (regcache::raw_read_signed): Remove. (regcache::raw_read_unsigned): Remove. (regcache_raw_read_unsigned): Update. (regcache_raw_write_unsigned): Update. (regcache::raw_write_signed): Remove. (regcache::raw_write): New function. (regcache_cooked_read_signed): Update. (regcache::raw_write_unsigned): Remove. (regcache::cooked_read_signed): Remove. (regcache_cooked_read_unsigned): Update. (regcache::cooked_read_unsigned): Remove. (regcache_cooked_write_signed): Update. (regcache_cooked_write_unsigned): Update. * regcache.h (regcache) <raw_read_signed>: Remove. <raw_write_signed, raw_read_unsigned, raw_write_unsigned>: Remove. <raw_read, raw_write>: New. <cooked_read_signed, cooked_write_signed>: Remove. <cooked_write_unsigned, cooked_read_unsigned>: Remove. <cooked_read, cooked_write>: New. * sh64-tdep.c (sh64_pseudo_register_read): Update. (sh64_pseudo_register_write): Update.
2017-06-16 16:38:42 +02:00
if (std::is_signed<T>::value)
{
/* Do the sign extension once at the start. */
retval = ((LONGEST) * p ^ 0x80) - 0x80;
++p;
}
for (; p < endaddr; ++p)
retval = (retval << 8) | *p;
}
else
{
p = endaddr - 1;
extract/store integer function template This patch converts functions extract_{unsigned,signed}_integer to a function template extract_integer, which has two instantiations. It also does the similar changes to store__{unsigned,signed}_integer, regcache::raw_read_{unsigned,signed}, regcache::raw_write_{unsigned,signed}, regcache::cooked_read_{unsigned,signed}, regcache::cooked_write_{unsigned,signed}. This patch was posted here https://sourceware.org/ml/gdb-patches/2017-05/msg00492.html but the problem was fixed in a different way. However, I think the patch is still useful to shorten the code. gdb: 2017-06-16 Alan Hayward <alan.hayward@arm.com> Pedro Alves <palves@redhat.com> Yao Qi <yao.qi@linaro.org> * defs.h (RequireLongest): New. (extract_integer): Declare function template. (extract_signed_integer): Remove the declaration, but define it static inline. (extract_unsigned_integer): Likewise. (store_integer): Declare function template. (store_signed_integer): Remove the declaration, but define it static inline. (store_unsigned_integer): Likewise. * findvar.c (extract_integer): New function template. (extract_signed_integer): Remove. (extract_unsigned_integer): Remove. (extract_integer<LONGEST>, extract_integer<ULONGEST>): Explicit instantiations. (store_integer): New function template. (store_signed_integer): Remove. (store_unsigned_integer): Remove. (store_integer): Explicit instantiations. * regcache.c (regcache_raw_read_signed): Update. (regcache::raw_read): New function. (regcache::raw_read_signed): Remove. (regcache::raw_read_unsigned): Remove. (regcache_raw_read_unsigned): Update. (regcache_raw_write_unsigned): Update. (regcache::raw_write_signed): Remove. (regcache::raw_write): New function. (regcache_cooked_read_signed): Update. (regcache::raw_write_unsigned): Remove. (regcache::cooked_read_signed): Remove. (regcache_cooked_read_unsigned): Update. (regcache::cooked_read_unsigned): Remove. (regcache_cooked_write_signed): Update. (regcache_cooked_write_unsigned): Update. * regcache.h (regcache) <raw_read_signed>: Remove. <raw_write_signed, raw_read_unsigned, raw_write_unsigned>: Remove. <raw_read, raw_write>: New. <cooked_read_signed, cooked_write_signed>: Remove. <cooked_write_unsigned, cooked_read_unsigned>: Remove. <cooked_read, cooked_write>: New. * sh64-tdep.c (sh64_pseudo_register_read): Update. (sh64_pseudo_register_write): Update.
2017-06-16 16:38:42 +02:00
if (std::is_signed<T>::value)
{
/* Do the sign extension once at the start. */
retval = ((LONGEST) * p ^ 0x80) - 0x80;
--p;
}
for (; p >= startaddr; --p)
retval = (retval << 8) | *p;
}
return retval;
}
extract/store integer function template This patch converts functions extract_{unsigned,signed}_integer to a function template extract_integer, which has two instantiations. It also does the similar changes to store__{unsigned,signed}_integer, regcache::raw_read_{unsigned,signed}, regcache::raw_write_{unsigned,signed}, regcache::cooked_read_{unsigned,signed}, regcache::cooked_write_{unsigned,signed}. This patch was posted here https://sourceware.org/ml/gdb-patches/2017-05/msg00492.html but the problem was fixed in a different way. However, I think the patch is still useful to shorten the code. gdb: 2017-06-16 Alan Hayward <alan.hayward@arm.com> Pedro Alves <palves@redhat.com> Yao Qi <yao.qi@linaro.org> * defs.h (RequireLongest): New. (extract_integer): Declare function template. (extract_signed_integer): Remove the declaration, but define it static inline. (extract_unsigned_integer): Likewise. (store_integer): Declare function template. (store_signed_integer): Remove the declaration, but define it static inline. (store_unsigned_integer): Likewise. * findvar.c (extract_integer): New function template. (extract_signed_integer): Remove. (extract_unsigned_integer): Remove. (extract_integer<LONGEST>, extract_integer<ULONGEST>): Explicit instantiations. (store_integer): New function template. (store_signed_integer): Remove. (store_unsigned_integer): Remove. (store_integer): Explicit instantiations. * regcache.c (regcache_raw_read_signed): Update. (regcache::raw_read): New function. (regcache::raw_read_signed): Remove. (regcache::raw_read_unsigned): Remove. (regcache_raw_read_unsigned): Update. (regcache_raw_write_unsigned): Update. (regcache::raw_write_signed): Remove. (regcache::raw_write): New function. (regcache_cooked_read_signed): Update. (regcache::raw_write_unsigned): Remove. (regcache::cooked_read_signed): Remove. (regcache_cooked_read_unsigned): Update. (regcache::cooked_read_unsigned): Remove. (regcache_cooked_write_signed): Update. (regcache_cooked_write_unsigned): Update. * regcache.h (regcache) <raw_read_signed>: Remove. <raw_write_signed, raw_read_unsigned, raw_write_unsigned>: Remove. <raw_read, raw_write>: New. <cooked_read_signed, cooked_write_signed>: Remove. <cooked_write_unsigned, cooked_read_unsigned>: Remove. <cooked_read, cooked_write>: New. * sh64-tdep.c (sh64_pseudo_register_read): Update. (sh64_pseudo_register_write): Update.
2017-06-16 16:38:42 +02:00
/* Explicit instantiations. */
template LONGEST extract_integer<LONGEST> (const gdb_byte *addr, int len,
enum bfd_endian byte_order);
template ULONGEST extract_integer<ULONGEST> (const gdb_byte *addr, int len,
enum bfd_endian byte_order);
/* Sometimes a long long unsigned integer can be extracted as a
LONGEST value. This is done so that we can print these values
better. If this integer can be converted to a LONGEST, this
function returns 1 and sets *PVAL. Otherwise it returns 0. */
int
2005-05-19 Andrew Cagney <cagney@gnu.org> * defs.h (extract_signed_integer, extract_unsigned_integer) (extract_long_unsigned_integer, extract_typed_address) (store_signed_integer, store_unsigned_integer) (store_typed_address): Use gdb_byte for byte buffer parameters. (push_bytes, push_word): Delete declaration. * valops.c (push_bytes, push_word): Delete function. * findvar.c (extract_signed_integer, extract_unsigned_integer) (extract_typed_address, store_signed_integer) (store_unsigned_integer): Update. Index: defs.h =================================================================== RCS file: /cvs/src/src/gdb/defs.h,v retrieving revision 1.185 diff -p -u -r1.185 defs.h --- defs.h 9 May 2005 17:20:18 -0000 1.185 +++ defs.h 19 May 2005 17:54:12 -0000 @@ -1042,27 +1042,25 @@ enum { MAX_REGISTER_SIZE = 16 }; /* In findvar.c. */ -extern LONGEST extract_signed_integer (const void *, int); +extern LONGEST extract_signed_integer (const gdb_byte *, int); -extern ULONGEST extract_unsigned_integer (const void *, int); +extern ULONGEST extract_unsigned_integer (const gdb_byte *, int); -extern int extract_long_unsigned_integer (const void *, int, LONGEST *); +extern int extract_long_unsigned_integer (const gdb_byte *, int, LONGEST *); -extern CORE_ADDR extract_typed_address (const void *buf, struct type *type); +extern CORE_ADDR extract_typed_address (const gdb_byte *buf, + struct type *type); -extern void store_signed_integer (void *, int, LONGEST); +extern void store_signed_integer (gdb_byte *, int, LONGEST); -extern void store_unsigned_integer (void *, int, ULONGEST); +extern void store_unsigned_integer (gdb_byte *, int, ULONGEST); -extern void store_typed_address (void *buf, struct type *type, CORE_ADDR addr); +extern void store_typed_address (gdb_byte *buf, struct type *type, + CORE_ADDR addr); /* From valops.c */ -extern CORE_ADDR push_bytes (CORE_ADDR, char *, int); - -extern CORE_ADDR push_word (CORE_ADDR, ULONGEST); - extern int watchdog; /* Hooks for alternate command interfaces. */ Index: findvar.c =================================================================== RCS file: /cvs/src/src/gdb/findvar.c,v retrieving revision 1.91 diff -p -u -r1.91 findvar.c --- findvar.c 14 May 2005 06:07:41 -0000 1.91 +++ findvar.c 19 May 2005 17:54:12 -0000 @@ -49,7 +49,7 @@ you lose #endif LONGEST -extract_signed_integer (const void *addr, int len) +extract_signed_integer (const gdb_byte *addr, int len) { LONGEST retval; const unsigned char *p; @@ -83,7 +83,7 @@ That operation is not available on integ } ULONGEST -extract_unsigned_integer (const void *addr, int len) +extract_unsigned_integer (const gdb_byte *addr, int len) { ULONGEST retval; const unsigned char *p; @@ -117,16 +117,18 @@ That operation is not available on integ function returns 1 and sets *PVAL. Otherwise it returns 0. */ int -extract_long_unsigned_integer (const void *addr, int orig_len, LONGEST *pval) +extract_long_unsigned_integer (const gdb_byte *addr, int orig_len, + LONGEST *pval) { - char *p, *first_addr; + const gdb_byte *p; + const gdb_byte *first_addr; int len; len = orig_len; if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG) { - for (p = (char *) addr; - len > (int) sizeof (LONGEST) && p < (char *) addr + orig_len; + for (p = addr; + len > (int) sizeof (LONGEST) && p < addr + orig_len; p++) { if (*p == 0) @@ -138,9 +140,9 @@ extract_long_unsigned_integer (const voi } else { - first_addr = (char *) addr; - for (p = (char *) addr + orig_len - 1; - len > (int) sizeof (LONGEST) && p >= (char *) addr; + first_addr = addr; + for (p = addr + orig_len - 1; + len > (int) sizeof (LONGEST) && p >= addr; p--) { if (*p == 0) @@ -164,7 +166,7 @@ extract_long_unsigned_integer (const voi /* Treat the bytes at BUF as a pointer of type TYPE, and return the address it represents. */ CORE_ADDR -extract_typed_address (const void *buf, struct type *type) +extract_typed_address (const gdb_byte *buf, struct type *type) { if (TYPE_CODE (type) != TYPE_CODE_PTR && TYPE_CODE (type) != TYPE_CODE_REF) @@ -177,11 +179,11 @@ extract_typed_address (const void *buf, void -store_signed_integer (void *addr, int len, LONGEST val) +store_signed_integer (gdb_byte *addr, int len, LONGEST val) { - unsigned char *p; - unsigned char *startaddr = (unsigned char *) addr; - unsigned char *endaddr = startaddr + len; + gdb_byte *p; + gdb_byte *startaddr = addr; + gdb_byte *endaddr = startaddr + len; /* Start at the least significant end of the integer, and work towards the most significant. */ @@ -204,7 +206,7 @@ store_signed_integer (void *addr, int le } void -store_unsigned_integer (void *addr, int len, ULONGEST val) +store_unsigned_integer (gdb_byte *addr, int len, ULONGEST val) { unsigned char *p; unsigned char *startaddr = (unsigned char *) addr; @@ -233,7 +235,7 @@ store_unsigned_integer (void *addr, int /* Store the address ADDR as a pointer of type TYPE at BUF, in target form. */ void -store_typed_address (void *buf, struct type *type, CORE_ADDR addr) +store_typed_address (gdb_byte *buf, struct type *type, CORE_ADDR addr) { if (TYPE_CODE (type) != TYPE_CODE_PTR && TYPE_CODE (type) != TYPE_CODE_REF) Index: valops.c =================================================================== RCS file: /cvs/src/src/gdb/valops.c,v retrieving revision 1.157 diff -p -u -r1.157 valops.c --- valops.c 9 May 2005 21:20:35 -0000 1.157 +++ valops.c 19 May 2005 17:54:12 -0000 @@ -933,54 +933,6 @@ value_ind (struct value *arg1) return 0; /* For lint -- never reached */ } -/* Pushing small parts of stack frames. */ - -/* Push one word (the size of object that a register holds). */ - -CORE_ADDR -push_word (CORE_ADDR sp, ULONGEST word) -{ - int len = DEPRECATED_REGISTER_SIZE; - char buffer[MAX_REGISTER_SIZE]; - - store_unsigned_integer (buffer, len, word); - if (INNER_THAN (1, 2)) - { - /* stack grows downward */ - sp -= len; - write_memory (sp, buffer, len); - } - else - { - /* stack grows upward */ - write_memory (sp, buffer, len); - sp += len; - } - - return sp; -} - -/* Push LEN bytes with data at BUFFER. */ - -CORE_ADDR -push_bytes (CORE_ADDR sp, char *buffer, int len) -{ - if (INNER_THAN (1, 2)) - { - /* stack grows downward */ - sp -= len; - write_memory (sp, buffer, len); - } - else - { - /* stack grows upward */ - write_memory (sp, buffer, len); - sp += len; - } - - return sp; -} - /* Create a value for an array by allocating space in the inferior, copying the data into that space, and then setting up an array value.
2005-05-19 19:55:53 +02:00
extract_long_unsigned_integer (const gdb_byte *addr, int orig_len,
* defs.h (extract_signed_integer, extract_unsigned_integer, extract_long_unsigned_integer, store_signed_integer, store_unsigned_integer): Add BYTE_ORDER parameter. * findvar.c (extract_signed_integer, extract_unsigned_integer, extract_long_unsigned_integer, store_signed_integer, store_unsigned_integer): Add BYTE_ORDER parameter. Use it instead of current_gdbarch. * gdbcore.h (read_memory_integer, safe_read_memory_integer, read_memory_unsigned_integer, write_memory_signed_integer, write_memory_unsigned_integer): Add BYTE_ORDER parameter. * corefile.c (struct captured_read_memory_integer_arguments): Add BYTE_ORDER member. (safe_read_memory_integer): Add BYTE_ORDER parameter. Store it into struct captured_read_memory_integer_arguments. (do_captured_read_memory_integer): Pass it to read_memory_integer. (read_memory_integer): Add BYTE_ORDER parameter. Pass it to extract_signed_integer. (read_memory_unsigned_integer): Add BYTE_ORDER parameter. Pass it to extract_unsigned_integer. (write_memory_signed_integer): Add BYTE_ORDER parameter. Pass it to store_signed_integer. (write_memory_unsigned_integer): Add BYTE_ORDER parameter. Pass it to store_unsigned_integer. * target.h (get_target_memory_unsigned): Add BYTE_ORDER parameter. * target.c (get_target_memory_unsigned): Add BYTE_ORDER parameter. Pass it to extract_unsigned_integer. Update calls to extract_signed_integer, extract_unsigned_integer, extract_long_unsigned_integer, store_signed_integer, store_unsigned_integer, read_memory_integer, read_memory_unsigned_integer, safe_read_memory_integer, write_memory_signed_integer, write_memory_unsigned_integer, and get_target_memory_unsigned to pass byte order: * ada-lang.c (ada_value_binop): Update. * ada-valprint.c (char_at): Update. * alpha-osf1-tdep.c (alpha_osf1_sigcontext_addr): Update. * alpha-tdep.c (alpha_lds, alpha_sts, alpha_push_dummy_call, alpha_extract_return_value, alpha_read_insn, alpha_get_longjmp_target): Update. * amd64-linux-tdep.c (amd64_linux_sigcontext_addr): Update. * amd64obsd-tdep.c (amd64obsd_supply_uthread, amd64obsd_collect_uthread, amd64obsd_trapframe_cache): Update. * amd64-tdep.c (amd64_push_dummy_call, amd64_analyze_prologue, amd64_frame_cache, amd64_sigtramp_frame_cache, fixup_riprel, amd64_displaced_step_fixup): Update. * arm-linux-tdep.c (arm_linux_sigreturn_init, arm_linux_rt_sigreturn_init, arm_linux_supply_gregset): Update. * arm-tdep.c (thumb_analyze_prologue, arm_skip_prologue, arm_scan_prologue, arm_push_dummy_call, thumb_get_next_pc, arm_get_next_pc, arm_extract_return_value, arm_store_return_value, arm_return_value): Update. * arm-wince-tdep.c (arm_pe_skip_trampoline_code): Update. * auxv.c (default_auxv_parse): Update. * avr-tdep.c (avr_address_to_pointer, avr_pointer_to_address, avr_scan_prologue, avr_extract_return_value, avr_frame_prev_register, avr_push_dummy_call): Update. * bsd-uthread.c (bsd_uthread_check_magic, bsd_uthread_lookup_offset, bsd_uthread_wait, bsd_uthread_thread_alive, bsd_uthread_extra_thread_info): Update. * c-lang.c (c_printstr, print_wchar): Update. * cp-valprint.c (cp_print_class_member): Update. * cris-tdep.c (cris_sigcontext_addr, cris_sigtramp_frame_unwind_cache, cris_push_dummy_call, cris_scan_prologue, cris_store_return_value, cris_extract_return_value, find_step_target, dip_prefix, sixteen_bit_offset_branch_op, none_reg_mode_jump_op, move_mem_to_reg_movem_op, get_data_from_address): Update. * dwarf2expr.c (dwarf2_read_address, execute_stack_op): Update. * dwarf2-frame.c (execute_cfa_program): Update. * dwarf2loc.c (find_location_expression): Update. * dwarf2read.c (dwarf2_const_value): Update. * expprint.c (print_subexp_standard): Update. * findvar.c (unsigned_pointer_to_address, signed_pointer_to_address, unsigned_address_to_pointer, address_to_signed_pointer, read_var_value): Update. * frame.c (frame_unwind_register_signed, frame_unwind_register_unsigned, get_frame_memory_signed, get_frame_memory_unsigned): Update. * frame-unwind.c (frame_unwind_got_constant): Update. * frv-linux-tdep.c (frv_linux_pc_in_sigtramp, frv_linux_sigcontext_reg_addr, frv_linux_sigtramp_frame_cache): Update. * frv-tdep.c (frv_analyze_prologue, frv_skip_main_prologue, frv_extract_return_value, find_func_descr, frv_convert_from_func_ptr_addr, frv_push_dummy_call): Update. * f-valprint.c (f_val_print): Update. * gnu-v3-abi.c (gnuv3_decode_method_ptr, gnuv3_make_method_ptr): Update. * h8300-tdep.c (h8300_is_argument_spill, h8300_analyze_prologue, h8300_push_dummy_call, h8300_extract_return_value, h8300h_extract_return_value, h8300_store_return_value, h8300h_store_return_value): Update. * hppabsd-tdep.c (hppabsd_find_global_pointer): Update. * hppa-hpux-nat.c (hppa_hpux_fetch_register, hppa_hpux_store_register): Update. * hppa-hpux-tdep.c (hppa32_hpux_in_solib_call_trampoline, hppa64_hpux_in_solib_call_trampoline, hppa_hpux_in_solib_return_trampoline, hppa_hpux_skip_trampoline_code, hppa_hpux_sigtramp_frame_unwind_cache, hppa_hpux_sigtramp_unwind_sniffer, hppa32_hpux_find_global_pointer, hppa64_hpux_find_global_pointer, hppa_hpux_search_pattern, hppa32_hpux_search_dummy_call_sequence, hppa64_hpux_search_dummy_call_sequence, hppa_hpux_supply_save_state, hppa_hpux_unwind_adjust_stub): Update. * hppa-linux-tdep.c (insns_match_pattern, hppa_linux_find_global_pointer): Update. * hppa-tdep.c (hppa_in_function_epilogue_p, hppa32_push_dummy_call, hppa64_convert_code_addr_to_fptr, hppa64_push_dummy_call, skip_prologue_hard_way, hppa_frame_cache, hppa_fallback_frame_cache, hppa_pseudo_register_read, hppa_frame_prev_register_helper, hppa_match_insns): Update. * hpux-thread.c (hpux_thread_fetch_registers): Update. * i386-tdep.c (i386bsd_sigcontext_addr): Update. * i386-cygwin-tdep.c (core_process_module_section): Update. * i386-darwin-nat.c (i386_darwin_sstep_at_sigreturn, amd64_darwin_sstep_at_sigreturn): Update. * i386-darwin-tdep.c (i386_darwin_sigcontext_addr, amd64_darwin_sigcontext_addr): Likewise. * i386-linux-nat.c (i386_linux_sigcontext_addr): Update. * i386nbsd-tdep.c (i386nbsd_sigtramp_cache_init): Update. * i386-nto-tdep.c (i386nto_sigcontext_addr): Update. * i386obsd-nat.c (i386obsd_supply_pcb): Update. * i386obsd-tdep.c (i386obsd_supply_uthread, i386obsd_collect_uthread, i386obsd_trapframe_cache): Update. * i386-tdep.c (i386_displaced_step_fixup, i386_follow_jump, i386_analyze_frame_setup, i386_analyze_prologue, i386_skip_main_prologue, i386_frame_cache, i386_sigtramp_frame_cache, i386_get_longjmp_target, i386_push_dummy_call, i386_pe_skip_trampoline_code, i386_svr4_sigcontext_addr, i386_fetch_pointer_argument): Update. * i387-tdep.c (i387_supply_fsave): Update. * ia64-linux-tdep.c (ia64_linux_sigcontext_register_address): Update. * ia64-tdep.c (ia64_pseudo_register_read, ia64_pseudo_register_write, examine_prologue, ia64_frame_cache, ia64_frame_prev_register, ia64_sigtramp_frame_cache, ia64_sigtramp_frame_prev_register, ia64_access_reg, ia64_access_rse_reg, ia64_libunwind_frame_this_id, ia64_libunwind_frame_prev_register, ia64_libunwind_sigtramp_frame_this_id, ia64_libunwind_sigtramp_frame_prev_register, ia64_find_global_pointer, find_extant_func_descr, find_func_descr, ia64_convert_from_func_ptr_addr, ia64_push_dummy_call, ia64_dummy_id, ia64_unwind_pc): Update. * iq2000-tdep.c (iq2000_pointer_to_address, iq2000_address_to_pointer, iq2000_scan_prologue, iq2000_extract_return_value, iq2000_push_dummy_call): Update. * irix5nat.c (fill_gregset): Update. * jv-lang.c (evaluate_subexp_java): Update. * jv-valprint.c (java_value_print): Update. * lm32-tdep.c (lm32_analyze_prologue, lm32_push_dummy_call, lm32_extract_return_value, lm32_store_return_value): Update. * m32c-tdep.c (m32c_push_dummy_call, m32c_return_value, m32c_skip_trampoline_code, m32c_m16c_address_to_pointer, m32c_m16c_pointer_to_address): Update. * m32r-tdep.c (m32r_store_return_value, decode_prologue, m32r_skip_prologue, m32r_push_dummy_call, m32r_extract_return_value): Update. * m68hc11-tdep.c (m68hc11_pseudo_register_read, m68hc11_pseudo_register_write, m68hc11_analyze_instruction, m68hc11_push_dummy_call): Update. * m68linux-tdep.c (m68k_linux_pc_in_sigtramp, m68k_linux_get_sigtramp_info, m68k_linux_sigtramp_frame_cache): Update. * m68k-tdep.c (m68k_push_dummy_call, m68k_analyze_frame_setup, m68k_analyze_register_saves, m68k_analyze_prologue, m68k_frame_cache, m68k_get_longjmp_target): Update. * m88k-tdep.c (m88k_fetch_instruction): Update. * mep-tdep.c (mep_pseudo_cr32_read, mep_pseudo_csr_write, mep_pseudo_cr32_write, mep_get_insn, mep_push_dummy_call): Update. * mi/mi-main.c (mi_cmd_data_write_memory): Update. * mips-linux-tdep.c (mips_linux_get_longjmp_target, supply_32bit_reg, mips64_linux_get_longjmp_target, mips64_fill_gregset, mips64_fill_fpregset, mips_linux_in_dynsym_stub): Update. * mipsnbdsd-tdep.c (mipsnbsd_get_longjmp_target): Update. * mips-tdep.c (mips_fetch_instruction, fetch_mips_16, mips_eabi_push_dummy_call, mips_n32n64_push_dummy_call, mips_o32_push_dummy_call, mips_o64_push_dummy_call, mips_single_step_through_delay, mips_skip_pic_trampoline_code, mips_integer_to_address): Update. * mn10300-tdep.c (mn10300_analyze_prologue, mn10300_push_dummy_call): Update. * monitor.c (monitor_supply_register, monitor_write_memory, monitor_read_memory_single): Update. * moxie-tdep.c (moxie_store_return_value, moxie_extract_return_value, moxie_analyze_prologue): Update. * mt-tdep.c (mt_return_value, mt_skip_prologue, mt_select_coprocessor, mt_pseudo_register_read, mt_pseudo_register_write, mt_registers_info, mt_push_dummy_call): Update. * objc-lang.c (read_objc_method, read_objc_methlist_nmethods, read_objc_methlist_method, read_objc_object, read_objc_super, read_objc_class, find_implementation_from_class): Update. * ppc64-linux-tdep.c (ppc64_desc_entry_point, ppc64_linux_convert_from_func_ptr_addr, ppc_linux_sigtramp_cache): Update. * ppcobsd-tdep.c (ppcobsd_sigtramp_frame_sniffer, ppcobsd_sigtramp_frame_cache): Update. * ppc-sysv-tdep.c (ppc_sysv_abi_push_dummy_call, do_ppc_sysv_return_value, ppc64_sysv_abi_push_dummy_call, ppc64_sysv_abi_return_value): Update. * ppc-linux-nat.c (ppc_linux_auxv_parse): Update. * procfs.c (procfs_auxv_parse): Update. * p-valprint.c (pascal_val_print): Update. * regcache.c (regcache_raw_read_signed, regcache_raw_read_unsigned, regcache_raw_write_signed, regcache_raw_write_unsigned, regcache_cooked_read_signed, regcache_cooked_read_unsigned, regcache_cooked_write_signed, regcache_cooked_write_unsigned): Update. * remote-m32r-sdi.c (m32r_fetch_register): Update. * remote-mips.c (mips_wait, mips_fetch_registers, mips_xfer_memory): Update. * rs6000-aix-tdep.c (rs6000_push_dummy_call, rs6000_return_value, rs6000_convert_from_func_ptr_addr, branch_dest, rs6000_software_single_step): Update. * rs6000-tdep.c (rs6000_in_function_epilogue_p, ppc_displaced_step_fixup, ppc_deal_with_atomic_sequence, bl_to_blrl_insn_p, rs6000_fetch_instruction, skip_prologue, rs6000_skip_main_prologue, rs6000_skip_trampoline_code, rs6000_frame_cache): Update. * s390-tdep.c (s390_pseudo_register_read, s390_pseudo_register_write, s390x_pseudo_register_read, s390x_pseudo_register_write, s390_load, s390_backchain_frame_unwind_cache, s390_sigtramp_frame_unwind_cache, extend_simple_arg, s390_push_dummy_call, s390_return_value): Update. * scm-exp.c (scm_lreadr): Update. * scm-lang.c (scm_get_field, scm_unpack): Update. * scm-valprint.c (scm_val_print): Update. * score-tdep.c (score_breakpoint_from_pc, score_push_dummy_call, score_fetch_inst): Update. * sh64-tdep.c (look_for_args_moves, sh64_skip_prologue_hard_way, sh64_analyze_prologue, sh64_push_dummy_call, sh64_extract_return_value, sh64_pseudo_register_read, sh64_pseudo_register_write, sh64_frame_prev_register): Update: * sh-tdep.c (sh_analyze_prologue, sh_push_dummy_call_fpu, sh_push_dummy_call_nofpu, sh_extract_return_value_nofpu, sh_store_return_value_nofpu, sh_in_function_epilogue_p): Update. * solib-darwin.c (darwin_load_image_infos): Update. * solib-frv.c (fetch_loadmap, lm_base, frv_current_sos, enable_break2, find_canonical_descriptor_in_load_object): Update. * solib-irix.c (extract_mips_address, fetch_lm_info, irix_current_sos, irix_open_symbol_file_object): Update. * solib-som.c (som_solib_create_inferior_hook, link_map_start, som_current_sos, som_open_symbol_file_object): Update. * solib-sunos.c (SOLIB_EXTRACT_ADDRESS, LM_ADDR, LM_NEXT, LM_NAME): Update. * solib-svr4.c (read_program_header, scan_dyntag_auxv, solib_svr4_r_ldsomap): Update. * sparc64-linux-tdep.c (sparc64_linux_step_trap): Update. * sparc64obsd-tdep.c (sparc64obsd_supply_uthread, sparc64obsd_collect_uthread): Update. * sparc64-tdep.c (sparc64_pseudo_register_read, sparc64_pseudo_register_write, sparc64_supply_gregset, sparc64_collect_gregset): Update. * sparc-linux-tdep.c (sparc32_linux_step_trap): Update. * sparcobsd-tdep.c (sparc32obsd_supply_uthread, sparc32obsd_collect_uthread): Update. * sparc-tdep.c (sparc_fetch_wcookie, sparc32_push_dummy_code, sparc32_store_arguments, sparc32_return_value, sparc_supply_rwindow, sparc_collect_rwindow): Update. * spu-linux-nat.c (parse_spufs_run): Update. * spu-tdep.c (spu_pseudo_register_read_spu, spu_pseudo_register_write_spu, spu_pointer_to_address, spu_analyze_prologue, spu_in_function_epilogue_p, spu_frame_unwind_cache, spu_push_dummy_call, spu_software_single_step, spu_get_longjmp_target, spu_get_overlay_table, spu_overlay_update_osect, info_spu_signal_command, info_spu_mailbox_list, info_spu_dma_cmdlist, info_spu_dma_command, info_spu_proxydma_command): Update. * stack.c (print_frame_nameless_args, frame_info): Update. * symfile.c (read_target_long_array, simple_read_overlay_table, simple_read_overlay_region_table): Update. * target.c (debug_print_register): Update. * tramp-frame.c (tramp_frame_start): Update. * v850-tdep.c (v850_analyze_prologue, v850_push_dummy_call, v850_extract_return_value, v850_store_return_value, * valarith.c (value_binop, value_bit_index): Update. * valops.c (value_cast): Update. * valprint.c (val_print_type_code_int, val_print_string, read_string): Update. * value.c (unpack_long, unpack_double, unpack_field_as_long, modify_field, pack_long): Update. * vax-tdep.c (vax_store_arguments, vax_push_dummy_call, vax_skip_prologue): Update. * xstormy16-tdep.c (xstormy16_push_dummy_call, xstormy16_analyze_prologue, xstormy16_in_function_epilogue_p, xstormy16_resolve_jmp_table_entry, xstormy16_find_jmp_table_entry, xstormy16_pointer_to_address, xstormy16_address_to_pointer): Update. * xtensa-tdep.c (extract_call_winsize, xtensa_pseudo_register_read, xtensa_pseudo_register_write, xtensa_frame_cache, xtensa_push_dummy_call, call0_track_op, call0_frame_cache): Update. * dfp.h (decimal_to_string, decimal_from_string, decimal_from_integral, decimal_from_floating, decimal_to_doublest, decimal_is_zero): Add BYTE_ORDER parameter. (decimal_binop): Add BYTE_ORDER_X, BYTE_ORDER_Y, and BYTE_ORDER_RESULT parameters. (decimal_compare): Add BYTE_ORDER_X and BYTE_ORDER_Y parameters. (decimal_convert): Add BYTE_ORDER_FROM and BYTE_ORDER_TO parameters. * dfp.c (match_endianness): Add BYTE_ORDER parameter. Use it instead of current_gdbarch. (decimal_to_string, decimal_from_integral, decimal_from_floating, decimal_to_doublest, decimal_is_zero): Add BYTE_ORDER parameter. Pass it to match_endianness. (decimal_binop): Add BYTE_ORDER_X, BYTE_ORDER_Y, and BYTE_ORDER_RESULT parameters. Pass them to match_endianness. (decimal_compare): Add BYTE_ORDER_X and BYTE_ORDER_Y parameters. Pass them to match_endianness. (decimal_convert): Add BYTE_ORDER_FROM and BYTE_ORDER_TO parameters. Pass them to match_endianness. * valarith.c (value_args_as_decimal): Add BYTE_ORDER_X and BYTE_ORDER_Y output parameters. (value_binop): Update call to value_args_as_decimal. Update calls to decimal_to_string, decimal_from_string, decimal_from_integral, decimal_from_floating, decimal_to_doublest, decimal_is_zero, decimal_binop, decimal_compare and decimal_convert to pass/receive byte order: * c-exp.y (parse_number): Update. * printcmd.c (printf_command): Update. * valarith.c (value_args_as_decimal, value_binop, value_logical_not, value_equal, value_less): Update. * valops.c (value_cast, value_one): Update. * valprint.c (print_decimal_floating): Update. * value.c (unpack_long, unpack_double): Update. * python/python-value.c (valpy_nonzero): Update. * ada-valprint.c (char_at): Add BYTE_ORDER parameter. (printstr): Update calls to char_at. (ada_val_print_array): Likewise. * valprint.c (read_string): Add BYTE_ORDER parameter. (val_print_string): Update call to read_string. * c-lang.c (c_get_string): Likewise. * charset.h (target_wide_charset): Add BYTE_ORDER parameter. * charset.c (target_wide_charset): Add BYTE_ORDER parameter. Use it instead of current_gdbarch. * printcmd.c (printf_command): Update calls to target_wide_charset. * c-lang.c (charset_for_string_type): Add BYTE_ORDER parameter. Pass to target_wide_charset. Use it instead of current_gdbarch. (classify_type): Add BYTE_ORDER parameter. Pass to charset_for_string_type. Allow NULL encoding pointer. (print_wchar): Add BYTE_ORDER parameter. (c_emit_char): Update calls to classify_type and print_wchar. (c_printchar, c_printstr): Likewise. * gdbarch.sh (in_solib_return_trampoline): Convert to type "m". * gdbarch.c, gdbarch.h: Regenerate. * arch-utils.h (generic_in_solib_return_trampoline): Add GDBARCH parameter. * arch-utils.c (generic_in_solib_return_trampoline): Likewise. * hppa-hpux-tdep.c (hppa_hpux_in_solib_return_trampoline): Likewise. * rs6000-tdep.c (rs6000_in_solib_return_trampoline): Likewise. (rs6000_skip_trampoline_code): Update call. * alpha-tdep.h (struct gdbarch_tdep): Add GDBARCH parameter to dynamic_sigtramp_offset and pc_in_sigtramp callbacks. (alpha_read_insn): Add GDBARCH parameter. * alpha-tdep.c (alpha_lds, alpha_sts): Add GDBARCH parameter. (alpha_register_to_value): Pass architecture to alpha_sts. (alpha_extract_return_value): Likewise. (alpha_value_to_register): Pass architecture to alpha_lds. (alpha_store_return_value): Likewise. (alpha_read_insn): Add GDBARCH parameter. (alpha_skip_prologue): Pass architecture to alpha_read_insn. (alpha_heuristic_proc_start): Likewise. (alpha_heuristic_frame_unwind_cache): Likewise. (alpha_next_pc): Likewise. (alpha_sigtramp_frame_this_id): Pass architecture to tdep->dynamic_sigtramp_offset callback. (alpha_sigtramp_frame_sniffer): Pass architecture to tdep->pc_in_sigtramp callback. * alphafbsd-tdep.c (alphafbsd_pc_in_sigtramp): Add GDBARCH parameter. (alphafbsd_sigtramp_offset): Likewise. * alpha-linux-tdep.c (alpha_linux_sigtramp_offset_1): Add GDBARCH parameter. Pass to alpha_read_insn. (alpha_linux_sigtramp_offset): Add GDBARCH parameter. Pass to alpha_linux_sigtramp_offset_1. (alpha_linux_pc_in_sigtramp): Add GDBARCH parameter. Pass to alpha_linux_sigtramp_offset. (alpha_linux_sigcontext_addr): Pass architecture to alpha_read_insn and alpha_linux_sigtramp_offset. * alphanbsd-tdep.c (alphanbsd_sigtramp_offset): Add GDBARCH parameter. (alphanbsd_pc_in_sigtramp): Add GDBARCH parameter. Pass to alphanbsd_sigtramp_offset. * alphaobsd-tdep.c (alphaobsd_sigtramp_offset): Add GDBARCH parameter. (alphaobsd_pc_in_sigtramp): Add GDBARCH parameter. Pass to alpha_read_insn. (alphaobsd_sigcontext_addr): Pass architecture to alphaobsd_sigtramp_offset. * alpha-osf1-tdep.c (alpha_osf1_pc_in_sigtramp): Add GDBARCH parameter. * amd64-tdep.c (amd64_analyze_prologue): Add GDBARCH parameter. (amd64_skip_prologue): Pass architecture to amd64_analyze_prologue. (amd64_frame_cache): Likewise. * arm-tdep.c (SWAP_SHORT, SWAP_INT): Remove. (thumb_analyze_prologue, arm_skip_prologue, arm_scan_prologue, thumb_get_next_pc, arm_get_next_pc): Do not use SWAP_ macros. * arm-wince-tdep.c: Include "frame.h". * avr-tdep.c (EXTRACT_INSN): Remove. (avr_scan_prologue): Add GDBARCH argument, inline EXTRACT_INSN. (avr_skip_prologue): Pass architecture to avr_scan_prologue. (avr_frame_unwind_cache): Likewise. * cris-tdep.c (struct instruction_environment): Add BYTE_ORDER member. (find_step_target): Initialize it. (get_data_from_address): Add BYTE_ORDER parameter. (bdap_prefix): Pass byte order to get_data_from_address. (handle_prefix_assign_mode_for_aritm_op): Likewise. (three_operand_add_sub_cmp_and_or_op): Likewise. (handle_inc_and_index_mode_for_aritm_op): Likewise. * frv-linux-tdep.c (frv_linux_pc_in_sigtramp): Add GDBARCH parameter. (frv_linux_sigcontext_reg_addr): Pass architecture to frv_linux_pc_in_sigtramp. (frv_linux_sigtramp_frame_sniffer): Likewise. * h8300-tdep.c (h8300_is_argument_spill): Add GDBARCH parameter. (h8300_analyze_prologue): Add GDBARCH parameter. Pass to h8300_is_argument_spill. (h8300_frame_cache, h8300_skip_prologue): Pass architecture to h8300_analyze_prologue. * hppa-tdep.h (struct gdbarch_tdep): Add GDBARCH parameter to in_solib_call_trampoline callback. (hppa_in_solib_call_trampoline): Add GDBARCH parameter. * hppa-tdep.c (hppa64_convert_code_addr_to_fptr): Add GDBARCH parameter. (hppa64_push_dummy_call): Pass architecture to hppa64_convert_code_addr_to_fptr. (hppa_match_insns): Add GDBARCH parameter. (hppa_match_insns_relaxed): Add GDBARCH parameter. Pass to hppa_match_insns. (hppa_skip_trampoline_code): Pass architecture to hppa_match_insns. (hppa_in_solib_call_trampoline): Add GDBARCH parameter. Pass to hppa_match_insns_relaxed. (hppa_stub_unwind_sniffer): Pass architecture to tdep->in_solib_call_trampoline callback. * hppa-hpux-tdep.c (hppa_hpux_search_pattern): Add GDBARCH parameter. (hppa32_hpux_search_dummy_call_sequence): Pass architecture to hppa_hpux_search_pattern. * hppa-linux-tdep.c (insns_match_pattern): Add GDBARCH parameter. (hppa_linux_sigtramp_find_sigcontext): Add GDBARCH parameter. Pass to insns_match_pattern. (hppa_linux_sigtramp_frame_unwind_cache): Pass architecture to hppa_linux_sigtramp_find_sigcontext. (hppa_linux_sigtramp_frame_sniffer): Likewise. (hppa32_hpux_in_solib_call_trampoline): Add GDBARCH parameter. (hppa64_hpux_in_solib_call_trampoline): Likewise. * i386-tdep.c (i386_follow_jump): Add GDBARCH parameter. (i386_analyze_frame_setup): Add GDBARCH parameter. (i386_analyze_prologue): Add GDBARCH parameter. Pass to i386_follow_jump and i386_analyze_frame_setup. (i386_skip_prologue): Pass architecture to i386_analyze_prologue and i386_follow_jump. (i386_frame_cache): Pass architecture to i386_analyze_prologue. (i386_pe_skip_trampoline_code): Add FRAME parameter. * i386-tdep.h (i386_pe_skip_trampoline_code): Add FRAME parameter. * i386-cygwin-tdep.c (i386_cygwin_skip_trampoline_code): Pass frame to i386_pe_skip_trampoline_code. * ia64-tdep.h (struct gdbarch_tdep): Add GDBARCH parameter to sigcontext_register_address callback. * ia64-tdep.c (ia64_find_global_pointer): Add GDBARCH parameter. (ia64_find_unwind_table): Pass architecture to ia64_find_global_pointer. (find_extant_func_descr): Add GDBARCH parameter. (find_func_descr): Pass architecture to find_extant_func_descr and ia64_find_global_pointer. (ia64_sigtramp_frame_init_saved_regs): Pass architecture to tdep->sigcontext_register_address callback. * ia64-linux-tdep.c (ia64_linux_sigcontext_register_address): Add GDBARCH parameter. * iq2000-tdep.c (iq2000_scan_prologue): Add GDBARCH parameter. (iq2000_frame_cache): Pass architecture to iq2000_scan_prologue. * lm32-tdep.c (lm32_analyze_prologue): Add GDBARCH parameter. (lm32_skip_prologue, lm32_frame_cache): Pass architecture to lm32_analyze_prologue. * m32r-tdep.c (decode_prologue): Add GDBARCH parameter. (m32r_skip_prologue): Pass architecture to decode_prologue. * m68hc11-tdep.c (m68hc11_analyze_instruction): Add GDBARCH parameter. (m68hc11_scan_prologue): Pass architecture to m68hc11_analyze_instruction. * m68k-tdep.c (m68k_analyze_frame_setup): Add GDBARCH parameter. (m68k_analyze_prologue): Pass architecture to m68k_analyze_frame_setup. * m88k-tdep.c (m88k_fetch_instruction): Add BYTE_ORDER parameter. (m88k_analyze_prologue): Add GDBARCH parameter. Pass byte order to m88k_fetch_instruction. (m88k_skip_prologue): Pass architecture to m88k_analyze_prologue. (m88k_frame_cache): Likewise. * mep-tdep.c (mep_get_insn): Add GDBARCH parameter. (mep_analyze_prologue): Pass architecture to mep_get_insn. * mips-tdep.c (mips_fetch_instruction): Add GDBARCH parameter. (mips32_next_pc): Pass architecture to mips_fetch_instruction. (deal_with_atomic_sequence): Likewise. (unpack_mips16): Add GDBARCH parameter, pass to mips_fetch_instruction. (mips16_scan_prologue): Likewise. (mips32_scan_prologue): Likewise. (mips16_in_function_epilogue_p): Likewise. (mips32_in_function_epilogue_p): Likewise. (mips_about_to_return): Likewise. (mips_insn16_frame_cache): Pass architecture to mips16_scan_prologue. (mips_insn32_frame_cache): Pass architecture to mips32_scan_prologue. (mips_skip_prologue): Pass architecture to mips16_scan_prologue and mips32_scan_prologue. (mips_in_function_epilogue_p): Pass architecture to mips16_in_function_epilogue_p and mips32_in_function_epilogue_p. (heuristic_proc_start): Pass architecture to mips_fetch_instruction and mips_about_to_return. (mips_skip_mips16_trampoline_code): Pass architecture to mips_fetch_instruction. (fetch_mips_16): Add GDBARCH parameter. (mips16_next_pc): Pass architecture to fetch_mips_16. (extended_mips16_next_pc): Pass architecture to unpack_mips16 and fetch_mips_16. * objc-lang.c (read_objc_method, read_objc_methlist_nmethods, read_objc_methlist_method, read_objc_object, read_objc_super, read_objc_class): Add GDBARCH parameter. (find_implementation_from_class): Add GDBARCH parameter, pass to read_objc_class, read_objc_methlist_nmethods, and read_objc_methlist_method. (find_implementation): Add GDBARCH parameter, pass to read_objc_object and find_implementation_from_class. (resolve_msgsend, resolve_msgsend_stret): Pass architecture to find_implementation. (resolve_msgsend_super, resolve_msgsend_super_stret): Pass architecture to read_objc_super and find_implementation_from_class. * ppc64-linux-tdep.c (ppc64_desc_entry_point): Add GDBARCH parameter. (ppc64_standard_linkage1_target, ppc64_standard_linkage2_target, ppc64_standard_linkage3_target): Pass architecture to ppc64_desc_entry_point. * rs6000-tdep.c (bl_to_blrl_insn_p): Add BYTE_ORDER parameter. (skip_prologue): Pass byte order to bl_to_blrl_insn_p. (rs6000_fetch_instruction): Add GDBARCH parameter. (rs6000_skip_stack_check): Add GDBARCH parameter, pass to rs6000_fetch_instruction. (skip_prologue): Pass architecture to rs6000_fetch_instruction. * remote-mips.c (mips_store_word): Return old_contents as host integer value instead of target bytes. * s390-tdep.c (struct s390_prologue_data): Add BYTE_ORDER member. (s390_analyze_prologue): Initialize it. (extend_simple_arg): Add GDBARCH parameter. (s390_push_dummy_call): Pass architecture to extend_simple_arg. * scm-lang.c (scm_get_field): Add BYTE_ORDER parameter. * scm-lang.h (scm_get_field): Add BYTE_ORDER parameter. (SCM_CAR, SCM_CDR): Pass SCM_BYTE_ORDER to scm_get_field. * scm-valprint.c (scm_scmval_print): Likewise. (scm_scmlist_print, scm_ipruk, scm_scmval_print): Define SCM_BYTE_ORDER. * sh64-tdep.c (look_for_args_moves): Add GDBARCH parameter. (sh64_skip_prologue_hard_way): Add GDBARCH parameter, pass to look_for_args_moves. (sh64_skip_prologue): Pass architecture to sh64_skip_prologue_hard_way. * sh-tdep.c (sh_analyze_prologue): Add GDBARCH parameter. (sh_skip_prologue): Pass architecture to sh_analyze_prologue. (sh_frame_cache): Likewise. * solib-irix.c (extract_mips_address): Add GDBARCH parameter. (fetch_lm_info, irix_current_sos, irix_open_symbol_file_object): Pass architecture to extract_mips_address. * sparc-tdep.h (sparc_fetch_wcookie): Add GDBARCH parameter. * sparc-tdep.c (sparc_fetch_wcookie): Add GDBARCH parameter. (sparc_supply_rwindow, sparc_collect_rwindow): Pass architecture to sparc_fetch_wcookie. (sparc32_frame_prev_register): Likewise. * sparc64-tdep.c (sparc64_frame_prev_register): Likewise. * sparc32nbsd-tdep.c (sparc32nbsd_sigcontext_saved_regs): Likewise. * sparc64nbsd-tdep.c (sparc64nbsd_sigcontext_saved_regs): Likewise. * spu-tdep.c (spu_analyze_prologue): Add GDBARCH parameter. (spu_skip_prologue): Pass architecture to spu_analyze_prologue. (spu_virtual_frame_pointer): Likewise. (spu_frame_unwind_cache): Likewise. (info_spu_mailbox_list): Add BYTE_ORER parameter. (info_spu_mailbox_command): Pass byte order to info_spu_mailbox_list. (info_spu_dma_cmdlist): Add BYTE_ORER parameter. (info_spu_dma_command, info_spu_proxydma_command): Pass byte order to info_spu_dma_cmdlist. * symfile.c (read_target_long_array): Add GDBARCH parameter. (simple_read_overlay_table, simple_read_overlay_region_table, simple_overlay_update_1): Pass architecture to read_target_long_array. * v850-tdep.c (v850_analyze_prologue): Add GDBARCH parameter. (v850_frame_cache): Pass architecture to v850_analyze_prologue. * xstormy16-tdep.c (xstormy16_analyze_prologue): Add GDBARCH parameter. (xstormy16_skip_prologue, xstormy16_frame_cache): Pass architecture to xstormy16_analyze_prologue. (xstormy16_resolve_jmp_table_entry): Add GDBARCH parameter. (xstormy16_find_jmp_table_entry): Likewise. (xstormy16_skip_trampoline_code): Pass architecture to xstormy16_resolve_jmp_table_entry. (xstormy16_pointer_to_address): Likewise. (xstormy16_address_to_pointer): Pass architecture to xstormy16_find_jmp_table_entry. * xtensa-tdep.c (call0_track_op): Add GDBARCH parameter. (call0_analyze_prologue): Add GDBARCH parameter, pass to call0_track_op. (call0_frame_cache): Pass architecture to call0_analyze_prologue. (xtensa_skip_prologue): Likewise.
2009-07-02 19:25:59 +02:00
enum bfd_endian byte_order, LONGEST *pval)
{
2005-05-19 Andrew Cagney <cagney@gnu.org> * defs.h (extract_signed_integer, extract_unsigned_integer) (extract_long_unsigned_integer, extract_typed_address) (store_signed_integer, store_unsigned_integer) (store_typed_address): Use gdb_byte for byte buffer parameters. (push_bytes, push_word): Delete declaration. * valops.c (push_bytes, push_word): Delete function. * findvar.c (extract_signed_integer, extract_unsigned_integer) (extract_typed_address, store_signed_integer) (store_unsigned_integer): Update. Index: defs.h =================================================================== RCS file: /cvs/src/src/gdb/defs.h,v retrieving revision 1.185 diff -p -u -r1.185 defs.h --- defs.h 9 May 2005 17:20:18 -0000 1.185 +++ defs.h 19 May 2005 17:54:12 -0000 @@ -1042,27 +1042,25 @@ enum { MAX_REGISTER_SIZE = 16 }; /* In findvar.c. */ -extern LONGEST extract_signed_integer (const void *, int); +extern LONGEST extract_signed_integer (const gdb_byte *, int); -extern ULONGEST extract_unsigned_integer (const void *, int); +extern ULONGEST extract_unsigned_integer (const gdb_byte *, int); -extern int extract_long_unsigned_integer (const void *, int, LONGEST *); +extern int extract_long_unsigned_integer (const gdb_byte *, int, LONGEST *); -extern CORE_ADDR extract_typed_address (const void *buf, struct type *type); +extern CORE_ADDR extract_typed_address (const gdb_byte *buf, + struct type *type); -extern void store_signed_integer (void *, int, LONGEST); +extern void store_signed_integer (gdb_byte *, int, LONGEST); -extern void store_unsigned_integer (void *, int, ULONGEST); +extern void store_unsigned_integer (gdb_byte *, int, ULONGEST); -extern void store_typed_address (void *buf, struct type *type, CORE_ADDR addr); +extern void store_typed_address (gdb_byte *buf, struct type *type, + CORE_ADDR addr); /* From valops.c */ -extern CORE_ADDR push_bytes (CORE_ADDR, char *, int); - -extern CORE_ADDR push_word (CORE_ADDR, ULONGEST); - extern int watchdog; /* Hooks for alternate command interfaces. */ Index: findvar.c =================================================================== RCS file: /cvs/src/src/gdb/findvar.c,v retrieving revision 1.91 diff -p -u -r1.91 findvar.c --- findvar.c 14 May 2005 06:07:41 -0000 1.91 +++ findvar.c 19 May 2005 17:54:12 -0000 @@ -49,7 +49,7 @@ you lose #endif LONGEST -extract_signed_integer (const void *addr, int len) +extract_signed_integer (const gdb_byte *addr, int len) { LONGEST retval; const unsigned char *p; @@ -83,7 +83,7 @@ That operation is not available on integ } ULONGEST -extract_unsigned_integer (const void *addr, int len) +extract_unsigned_integer (const gdb_byte *addr, int len) { ULONGEST retval; const unsigned char *p; @@ -117,16 +117,18 @@ That operation is not available on integ function returns 1 and sets *PVAL. Otherwise it returns 0. */ int -extract_long_unsigned_integer (const void *addr, int orig_len, LONGEST *pval) +extract_long_unsigned_integer (const gdb_byte *addr, int orig_len, + LONGEST *pval) { - char *p, *first_addr; + const gdb_byte *p; + const gdb_byte *first_addr; int len; len = orig_len; if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG) { - for (p = (char *) addr; - len > (int) sizeof (LONGEST) && p < (char *) addr + orig_len; + for (p = addr; + len > (int) sizeof (LONGEST) && p < addr + orig_len; p++) { if (*p == 0) @@ -138,9 +140,9 @@ extract_long_unsigned_integer (const voi } else { - first_addr = (char *) addr; - for (p = (char *) addr + orig_len - 1; - len > (int) sizeof (LONGEST) && p >= (char *) addr; + first_addr = addr; + for (p = addr + orig_len - 1; + len > (int) sizeof (LONGEST) && p >= addr; p--) { if (*p == 0) @@ -164,7 +166,7 @@ extract_long_unsigned_integer (const voi /* Treat the bytes at BUF as a pointer of type TYPE, and return the address it represents. */ CORE_ADDR -extract_typed_address (const void *buf, struct type *type) +extract_typed_address (const gdb_byte *buf, struct type *type) { if (TYPE_CODE (type) != TYPE_CODE_PTR && TYPE_CODE (type) != TYPE_CODE_REF) @@ -177,11 +179,11 @@ extract_typed_address (const void *buf, void -store_signed_integer (void *addr, int len, LONGEST val) +store_signed_integer (gdb_byte *addr, int len, LONGEST val) { - unsigned char *p; - unsigned char *startaddr = (unsigned char *) addr; - unsigned char *endaddr = startaddr + len; + gdb_byte *p; + gdb_byte *startaddr = addr; + gdb_byte *endaddr = startaddr + len; /* Start at the least significant end of the integer, and work towards the most significant. */ @@ -204,7 +206,7 @@ store_signed_integer (void *addr, int le } void -store_unsigned_integer (void *addr, int len, ULONGEST val) +store_unsigned_integer (gdb_byte *addr, int len, ULONGEST val) { unsigned char *p; unsigned char *startaddr = (unsigned char *) addr; @@ -233,7 +235,7 @@ store_unsigned_integer (void *addr, int /* Store the address ADDR as a pointer of type TYPE at BUF, in target form. */ void -store_typed_address (void *buf, struct type *type, CORE_ADDR addr) +store_typed_address (gdb_byte *buf, struct type *type, CORE_ADDR addr) { if (TYPE_CODE (type) != TYPE_CODE_PTR && TYPE_CODE (type) != TYPE_CODE_REF) Index: valops.c =================================================================== RCS file: /cvs/src/src/gdb/valops.c,v retrieving revision 1.157 diff -p -u -r1.157 valops.c --- valops.c 9 May 2005 21:20:35 -0000 1.157 +++ valops.c 19 May 2005 17:54:12 -0000 @@ -933,54 +933,6 @@ value_ind (struct value *arg1) return 0; /* For lint -- never reached */ } -/* Pushing small parts of stack frames. */ - -/* Push one word (the size of object that a register holds). */ - -CORE_ADDR -push_word (CORE_ADDR sp, ULONGEST word) -{ - int len = DEPRECATED_REGISTER_SIZE; - char buffer[MAX_REGISTER_SIZE]; - - store_unsigned_integer (buffer, len, word); - if (INNER_THAN (1, 2)) - { - /* stack grows downward */ - sp -= len; - write_memory (sp, buffer, len); - } - else - { - /* stack grows upward */ - write_memory (sp, buffer, len); - sp += len; - } - - return sp; -} - -/* Push LEN bytes with data at BUFFER. */ - -CORE_ADDR -push_bytes (CORE_ADDR sp, char *buffer, int len) -{ - if (INNER_THAN (1, 2)) - { - /* stack grows downward */ - sp -= len; - write_memory (sp, buffer, len); - } - else - { - /* stack grows upward */ - write_memory (sp, buffer, len); - sp += len; - } - - return sp; -} - /* Create a value for an array by allocating space in the inferior, copying the data into that space, and then setting up an array value.
2005-05-19 19:55:53 +02:00
const gdb_byte *p;
const gdb_byte *first_addr;
int len;
len = orig_len;
* defs.h (extract_signed_integer, extract_unsigned_integer, extract_long_unsigned_integer, store_signed_integer, store_unsigned_integer): Add BYTE_ORDER parameter. * findvar.c (extract_signed_integer, extract_unsigned_integer, extract_long_unsigned_integer, store_signed_integer, store_unsigned_integer): Add BYTE_ORDER parameter. Use it instead of current_gdbarch. * gdbcore.h (read_memory_integer, safe_read_memory_integer, read_memory_unsigned_integer, write_memory_signed_integer, write_memory_unsigned_integer): Add BYTE_ORDER parameter. * corefile.c (struct captured_read_memory_integer_arguments): Add BYTE_ORDER member. (safe_read_memory_integer): Add BYTE_ORDER parameter. Store it into struct captured_read_memory_integer_arguments. (do_captured_read_memory_integer): Pass it to read_memory_integer. (read_memory_integer): Add BYTE_ORDER parameter. Pass it to extract_signed_integer. (read_memory_unsigned_integer): Add BYTE_ORDER parameter. Pass it to extract_unsigned_integer. (write_memory_signed_integer): Add BYTE_ORDER parameter. Pass it to store_signed_integer. (write_memory_unsigned_integer): Add BYTE_ORDER parameter. Pass it to store_unsigned_integer. * target.h (get_target_memory_unsigned): Add BYTE_ORDER parameter. * target.c (get_target_memory_unsigned): Add BYTE_ORDER parameter. Pass it to extract_unsigned_integer. Update calls to extract_signed_integer, extract_unsigned_integer, extract_long_unsigned_integer, store_signed_integer, store_unsigned_integer, read_memory_integer, read_memory_unsigned_integer, safe_read_memory_integer, write_memory_signed_integer, write_memory_unsigned_integer, and get_target_memory_unsigned to pass byte order: * ada-lang.c (ada_value_binop): Update. * ada-valprint.c (char_at): Update. * alpha-osf1-tdep.c (alpha_osf1_sigcontext_addr): Update. * alpha-tdep.c (alpha_lds, alpha_sts, alpha_push_dummy_call, alpha_extract_return_value, alpha_read_insn, alpha_get_longjmp_target): Update. * amd64-linux-tdep.c (amd64_linux_sigcontext_addr): Update. * amd64obsd-tdep.c (amd64obsd_supply_uthread, amd64obsd_collect_uthread, amd64obsd_trapframe_cache): Update. * amd64-tdep.c (amd64_push_dummy_call, amd64_analyze_prologue, amd64_frame_cache, amd64_sigtramp_frame_cache, fixup_riprel, amd64_displaced_step_fixup): Update. * arm-linux-tdep.c (arm_linux_sigreturn_init, arm_linux_rt_sigreturn_init, arm_linux_supply_gregset): Update. * arm-tdep.c (thumb_analyze_prologue, arm_skip_prologue, arm_scan_prologue, arm_push_dummy_call, thumb_get_next_pc, arm_get_next_pc, arm_extract_return_value, arm_store_return_value, arm_return_value): Update. * arm-wince-tdep.c (arm_pe_skip_trampoline_code): Update. * auxv.c (default_auxv_parse): Update. * avr-tdep.c (avr_address_to_pointer, avr_pointer_to_address, avr_scan_prologue, avr_extract_return_value, avr_frame_prev_register, avr_push_dummy_call): Update. * bsd-uthread.c (bsd_uthread_check_magic, bsd_uthread_lookup_offset, bsd_uthread_wait, bsd_uthread_thread_alive, bsd_uthread_extra_thread_info): Update. * c-lang.c (c_printstr, print_wchar): Update. * cp-valprint.c (cp_print_class_member): Update. * cris-tdep.c (cris_sigcontext_addr, cris_sigtramp_frame_unwind_cache, cris_push_dummy_call, cris_scan_prologue, cris_store_return_value, cris_extract_return_value, find_step_target, dip_prefix, sixteen_bit_offset_branch_op, none_reg_mode_jump_op, move_mem_to_reg_movem_op, get_data_from_address): Update. * dwarf2expr.c (dwarf2_read_address, execute_stack_op): Update. * dwarf2-frame.c (execute_cfa_program): Update. * dwarf2loc.c (find_location_expression): Update. * dwarf2read.c (dwarf2_const_value): Update. * expprint.c (print_subexp_standard): Update. * findvar.c (unsigned_pointer_to_address, signed_pointer_to_address, unsigned_address_to_pointer, address_to_signed_pointer, read_var_value): Update. * frame.c (frame_unwind_register_signed, frame_unwind_register_unsigned, get_frame_memory_signed, get_frame_memory_unsigned): Update. * frame-unwind.c (frame_unwind_got_constant): Update. * frv-linux-tdep.c (frv_linux_pc_in_sigtramp, frv_linux_sigcontext_reg_addr, frv_linux_sigtramp_frame_cache): Update. * frv-tdep.c (frv_analyze_prologue, frv_skip_main_prologue, frv_extract_return_value, find_func_descr, frv_convert_from_func_ptr_addr, frv_push_dummy_call): Update. * f-valprint.c (f_val_print): Update. * gnu-v3-abi.c (gnuv3_decode_method_ptr, gnuv3_make_method_ptr): Update. * h8300-tdep.c (h8300_is_argument_spill, h8300_analyze_prologue, h8300_push_dummy_call, h8300_extract_return_value, h8300h_extract_return_value, h8300_store_return_value, h8300h_store_return_value): Update. * hppabsd-tdep.c (hppabsd_find_global_pointer): Update. * hppa-hpux-nat.c (hppa_hpux_fetch_register, hppa_hpux_store_register): Update. * hppa-hpux-tdep.c (hppa32_hpux_in_solib_call_trampoline, hppa64_hpux_in_solib_call_trampoline, hppa_hpux_in_solib_return_trampoline, hppa_hpux_skip_trampoline_code, hppa_hpux_sigtramp_frame_unwind_cache, hppa_hpux_sigtramp_unwind_sniffer, hppa32_hpux_find_global_pointer, hppa64_hpux_find_global_pointer, hppa_hpux_search_pattern, hppa32_hpux_search_dummy_call_sequence, hppa64_hpux_search_dummy_call_sequence, hppa_hpux_supply_save_state, hppa_hpux_unwind_adjust_stub): Update. * hppa-linux-tdep.c (insns_match_pattern, hppa_linux_find_global_pointer): Update. * hppa-tdep.c (hppa_in_function_epilogue_p, hppa32_push_dummy_call, hppa64_convert_code_addr_to_fptr, hppa64_push_dummy_call, skip_prologue_hard_way, hppa_frame_cache, hppa_fallback_frame_cache, hppa_pseudo_register_read, hppa_frame_prev_register_helper, hppa_match_insns): Update. * hpux-thread.c (hpux_thread_fetch_registers): Update. * i386-tdep.c (i386bsd_sigcontext_addr): Update. * i386-cygwin-tdep.c (core_process_module_section): Update. * i386-darwin-nat.c (i386_darwin_sstep_at_sigreturn, amd64_darwin_sstep_at_sigreturn): Update. * i386-darwin-tdep.c (i386_darwin_sigcontext_addr, amd64_darwin_sigcontext_addr): Likewise. * i386-linux-nat.c (i386_linux_sigcontext_addr): Update. * i386nbsd-tdep.c (i386nbsd_sigtramp_cache_init): Update. * i386-nto-tdep.c (i386nto_sigcontext_addr): Update. * i386obsd-nat.c (i386obsd_supply_pcb): Update. * i386obsd-tdep.c (i386obsd_supply_uthread, i386obsd_collect_uthread, i386obsd_trapframe_cache): Update. * i386-tdep.c (i386_displaced_step_fixup, i386_follow_jump, i386_analyze_frame_setup, i386_analyze_prologue, i386_skip_main_prologue, i386_frame_cache, i386_sigtramp_frame_cache, i386_get_longjmp_target, i386_push_dummy_call, i386_pe_skip_trampoline_code, i386_svr4_sigcontext_addr, i386_fetch_pointer_argument): Update. * i387-tdep.c (i387_supply_fsave): Update. * ia64-linux-tdep.c (ia64_linux_sigcontext_register_address): Update. * ia64-tdep.c (ia64_pseudo_register_read, ia64_pseudo_register_write, examine_prologue, ia64_frame_cache, ia64_frame_prev_register, ia64_sigtramp_frame_cache, ia64_sigtramp_frame_prev_register, ia64_access_reg, ia64_access_rse_reg, ia64_libunwind_frame_this_id, ia64_libunwind_frame_prev_register, ia64_libunwind_sigtramp_frame_this_id, ia64_libunwind_sigtramp_frame_prev_register, ia64_find_global_pointer, find_extant_func_descr, find_func_descr, ia64_convert_from_func_ptr_addr, ia64_push_dummy_call, ia64_dummy_id, ia64_unwind_pc): Update. * iq2000-tdep.c (iq2000_pointer_to_address, iq2000_address_to_pointer, iq2000_scan_prologue, iq2000_extract_return_value, iq2000_push_dummy_call): Update. * irix5nat.c (fill_gregset): Update. * jv-lang.c (evaluate_subexp_java): Update. * jv-valprint.c (java_value_print): Update. * lm32-tdep.c (lm32_analyze_prologue, lm32_push_dummy_call, lm32_extract_return_value, lm32_store_return_value): Update. * m32c-tdep.c (m32c_push_dummy_call, m32c_return_value, m32c_skip_trampoline_code, m32c_m16c_address_to_pointer, m32c_m16c_pointer_to_address): Update. * m32r-tdep.c (m32r_store_return_value, decode_prologue, m32r_skip_prologue, m32r_push_dummy_call, m32r_extract_return_value): Update. * m68hc11-tdep.c (m68hc11_pseudo_register_read, m68hc11_pseudo_register_write, m68hc11_analyze_instruction, m68hc11_push_dummy_call): Update. * m68linux-tdep.c (m68k_linux_pc_in_sigtramp, m68k_linux_get_sigtramp_info, m68k_linux_sigtramp_frame_cache): Update. * m68k-tdep.c (m68k_push_dummy_call, m68k_analyze_frame_setup, m68k_analyze_register_saves, m68k_analyze_prologue, m68k_frame_cache, m68k_get_longjmp_target): Update. * m88k-tdep.c (m88k_fetch_instruction): Update. * mep-tdep.c (mep_pseudo_cr32_read, mep_pseudo_csr_write, mep_pseudo_cr32_write, mep_get_insn, mep_push_dummy_call): Update. * mi/mi-main.c (mi_cmd_data_write_memory): Update. * mips-linux-tdep.c (mips_linux_get_longjmp_target, supply_32bit_reg, mips64_linux_get_longjmp_target, mips64_fill_gregset, mips64_fill_fpregset, mips_linux_in_dynsym_stub): Update. * mipsnbdsd-tdep.c (mipsnbsd_get_longjmp_target): Update. * mips-tdep.c (mips_fetch_instruction, fetch_mips_16, mips_eabi_push_dummy_call, mips_n32n64_push_dummy_call, mips_o32_push_dummy_call, mips_o64_push_dummy_call, mips_single_step_through_delay, mips_skip_pic_trampoline_code, mips_integer_to_address): Update. * mn10300-tdep.c (mn10300_analyze_prologue, mn10300_push_dummy_call): Update. * monitor.c (monitor_supply_register, monitor_write_memory, monitor_read_memory_single): Update. * moxie-tdep.c (moxie_store_return_value, moxie_extract_return_value, moxie_analyze_prologue): Update. * mt-tdep.c (mt_return_value, mt_skip_prologue, mt_select_coprocessor, mt_pseudo_register_read, mt_pseudo_register_write, mt_registers_info, mt_push_dummy_call): Update. * objc-lang.c (read_objc_method, read_objc_methlist_nmethods, read_objc_methlist_method, read_objc_object, read_objc_super, read_objc_class, find_implementation_from_class): Update. * ppc64-linux-tdep.c (ppc64_desc_entry_point, ppc64_linux_convert_from_func_ptr_addr, ppc_linux_sigtramp_cache): Update. * ppcobsd-tdep.c (ppcobsd_sigtramp_frame_sniffer, ppcobsd_sigtramp_frame_cache): Update. * ppc-sysv-tdep.c (ppc_sysv_abi_push_dummy_call, do_ppc_sysv_return_value, ppc64_sysv_abi_push_dummy_call, ppc64_sysv_abi_return_value): Update. * ppc-linux-nat.c (ppc_linux_auxv_parse): Update. * procfs.c (procfs_auxv_parse): Update. * p-valprint.c (pascal_val_print): Update. * regcache.c (regcache_raw_read_signed, regcache_raw_read_unsigned, regcache_raw_write_signed, regcache_raw_write_unsigned, regcache_cooked_read_signed, regcache_cooked_read_unsigned, regcache_cooked_write_signed, regcache_cooked_write_unsigned): Update. * remote-m32r-sdi.c (m32r_fetch_register): Update. * remote-mips.c (mips_wait, mips_fetch_registers, mips_xfer_memory): Update. * rs6000-aix-tdep.c (rs6000_push_dummy_call, rs6000_return_value, rs6000_convert_from_func_ptr_addr, branch_dest, rs6000_software_single_step): Update. * rs6000-tdep.c (rs6000_in_function_epilogue_p, ppc_displaced_step_fixup, ppc_deal_with_atomic_sequence, bl_to_blrl_insn_p, rs6000_fetch_instruction, skip_prologue, rs6000_skip_main_prologue, rs6000_skip_trampoline_code, rs6000_frame_cache): Update. * s390-tdep.c (s390_pseudo_register_read, s390_pseudo_register_write, s390x_pseudo_register_read, s390x_pseudo_register_write, s390_load, s390_backchain_frame_unwind_cache, s390_sigtramp_frame_unwind_cache, extend_simple_arg, s390_push_dummy_call, s390_return_value): Update. * scm-exp.c (scm_lreadr): Update. * scm-lang.c (scm_get_field, scm_unpack): Update. * scm-valprint.c (scm_val_print): Update. * score-tdep.c (score_breakpoint_from_pc, score_push_dummy_call, score_fetch_inst): Update. * sh64-tdep.c (look_for_args_moves, sh64_skip_prologue_hard_way, sh64_analyze_prologue, sh64_push_dummy_call, sh64_extract_return_value, sh64_pseudo_register_read, sh64_pseudo_register_write, sh64_frame_prev_register): Update: * sh-tdep.c (sh_analyze_prologue, sh_push_dummy_call_fpu, sh_push_dummy_call_nofpu, sh_extract_return_value_nofpu, sh_store_return_value_nofpu, sh_in_function_epilogue_p): Update. * solib-darwin.c (darwin_load_image_infos): Update. * solib-frv.c (fetch_loadmap, lm_base, frv_current_sos, enable_break2, find_canonical_descriptor_in_load_object): Update. * solib-irix.c (extract_mips_address, fetch_lm_info, irix_current_sos, irix_open_symbol_file_object): Update. * solib-som.c (som_solib_create_inferior_hook, link_map_start, som_current_sos, som_open_symbol_file_object): Update. * solib-sunos.c (SOLIB_EXTRACT_ADDRESS, LM_ADDR, LM_NEXT, LM_NAME): Update. * solib-svr4.c (read_program_header, scan_dyntag_auxv, solib_svr4_r_ldsomap): Update. * sparc64-linux-tdep.c (sparc64_linux_step_trap): Update. * sparc64obsd-tdep.c (sparc64obsd_supply_uthread, sparc64obsd_collect_uthread): Update. * sparc64-tdep.c (sparc64_pseudo_register_read, sparc64_pseudo_register_write, sparc64_supply_gregset, sparc64_collect_gregset): Update. * sparc-linux-tdep.c (sparc32_linux_step_trap): Update. * sparcobsd-tdep.c (sparc32obsd_supply_uthread, sparc32obsd_collect_uthread): Update. * sparc-tdep.c (sparc_fetch_wcookie, sparc32_push_dummy_code, sparc32_store_arguments, sparc32_return_value, sparc_supply_rwindow, sparc_collect_rwindow): Update. * spu-linux-nat.c (parse_spufs_run): Update. * spu-tdep.c (spu_pseudo_register_read_spu, spu_pseudo_register_write_spu, spu_pointer_to_address, spu_analyze_prologue, spu_in_function_epilogue_p, spu_frame_unwind_cache, spu_push_dummy_call, spu_software_single_step, spu_get_longjmp_target, spu_get_overlay_table, spu_overlay_update_osect, info_spu_signal_command, info_spu_mailbox_list, info_spu_dma_cmdlist, info_spu_dma_command, info_spu_proxydma_command): Update. * stack.c (print_frame_nameless_args, frame_info): Update. * symfile.c (read_target_long_array, simple_read_overlay_table, simple_read_overlay_region_table): Update. * target.c (debug_print_register): Update. * tramp-frame.c (tramp_frame_start): Update. * v850-tdep.c (v850_analyze_prologue, v850_push_dummy_call, v850_extract_return_value, v850_store_return_value, * valarith.c (value_binop, value_bit_index): Update. * valops.c (value_cast): Update. * valprint.c (val_print_type_code_int, val_print_string, read_string): Update. * value.c (unpack_long, unpack_double, unpack_field_as_long, modify_field, pack_long): Update. * vax-tdep.c (vax_store_arguments, vax_push_dummy_call, vax_skip_prologue): Update. * xstormy16-tdep.c (xstormy16_push_dummy_call, xstormy16_analyze_prologue, xstormy16_in_function_epilogue_p, xstormy16_resolve_jmp_table_entry, xstormy16_find_jmp_table_entry, xstormy16_pointer_to_address, xstormy16_address_to_pointer): Update. * xtensa-tdep.c (extract_call_winsize, xtensa_pseudo_register_read, xtensa_pseudo_register_write, xtensa_frame_cache, xtensa_push_dummy_call, call0_track_op, call0_frame_cache): Update. * dfp.h (decimal_to_string, decimal_from_string, decimal_from_integral, decimal_from_floating, decimal_to_doublest, decimal_is_zero): Add BYTE_ORDER parameter. (decimal_binop): Add BYTE_ORDER_X, BYTE_ORDER_Y, and BYTE_ORDER_RESULT parameters. (decimal_compare): Add BYTE_ORDER_X and BYTE_ORDER_Y parameters. (decimal_convert): Add BYTE_ORDER_FROM and BYTE_ORDER_TO parameters. * dfp.c (match_endianness): Add BYTE_ORDER parameter. Use it instead of current_gdbarch. (decimal_to_string, decimal_from_integral, decimal_from_floating, decimal_to_doublest, decimal_is_zero): Add BYTE_ORDER parameter. Pass it to match_endianness. (decimal_binop): Add BYTE_ORDER_X, BYTE_ORDER_Y, and BYTE_ORDER_RESULT parameters. Pass them to match_endianness. (decimal_compare): Add BYTE_ORDER_X and BYTE_ORDER_Y parameters. Pass them to match_endianness. (decimal_convert): Add BYTE_ORDER_FROM and BYTE_ORDER_TO parameters. Pass them to match_endianness. * valarith.c (value_args_as_decimal): Add BYTE_ORDER_X and BYTE_ORDER_Y output parameters. (value_binop): Update call to value_args_as_decimal. Update calls to decimal_to_string, decimal_from_string, decimal_from_integral, decimal_from_floating, decimal_to_doublest, decimal_is_zero, decimal_binop, decimal_compare and decimal_convert to pass/receive byte order: * c-exp.y (parse_number): Update. * printcmd.c (printf_command): Update. * valarith.c (value_args_as_decimal, value_binop, value_logical_not, value_equal, value_less): Update. * valops.c (value_cast, value_one): Update. * valprint.c (print_decimal_floating): Update. * value.c (unpack_long, unpack_double): Update. * python/python-value.c (valpy_nonzero): Update. * ada-valprint.c (char_at): Add BYTE_ORDER parameter. (printstr): Update calls to char_at. (ada_val_print_array): Likewise. * valprint.c (read_string): Add BYTE_ORDER parameter. (val_print_string): Update call to read_string. * c-lang.c (c_get_string): Likewise. * charset.h (target_wide_charset): Add BYTE_ORDER parameter. * charset.c (target_wide_charset): Add BYTE_ORDER parameter. Use it instead of current_gdbarch. * printcmd.c (printf_command): Update calls to target_wide_charset. * c-lang.c (charset_for_string_type): Add BYTE_ORDER parameter. Pass to target_wide_charset. Use it instead of current_gdbarch. (classify_type): Add BYTE_ORDER parameter. Pass to charset_for_string_type. Allow NULL encoding pointer. (print_wchar): Add BYTE_ORDER parameter. (c_emit_char): Update calls to classify_type and print_wchar. (c_printchar, c_printstr): Likewise. * gdbarch.sh (in_solib_return_trampoline): Convert to type "m". * gdbarch.c, gdbarch.h: Regenerate. * arch-utils.h (generic_in_solib_return_trampoline): Add GDBARCH parameter. * arch-utils.c (generic_in_solib_return_trampoline): Likewise. * hppa-hpux-tdep.c (hppa_hpux_in_solib_return_trampoline): Likewise. * rs6000-tdep.c (rs6000_in_solib_return_trampoline): Likewise. (rs6000_skip_trampoline_code): Update call. * alpha-tdep.h (struct gdbarch_tdep): Add GDBARCH parameter to dynamic_sigtramp_offset and pc_in_sigtramp callbacks. (alpha_read_insn): Add GDBARCH parameter. * alpha-tdep.c (alpha_lds, alpha_sts): Add GDBARCH parameter. (alpha_register_to_value): Pass architecture to alpha_sts. (alpha_extract_return_value): Likewise. (alpha_value_to_register): Pass architecture to alpha_lds. (alpha_store_return_value): Likewise. (alpha_read_insn): Add GDBARCH parameter. (alpha_skip_prologue): Pass architecture to alpha_read_insn. (alpha_heuristic_proc_start): Likewise. (alpha_heuristic_frame_unwind_cache): Likewise. (alpha_next_pc): Likewise. (alpha_sigtramp_frame_this_id): Pass architecture to tdep->dynamic_sigtramp_offset callback. (alpha_sigtramp_frame_sniffer): Pass architecture to tdep->pc_in_sigtramp callback. * alphafbsd-tdep.c (alphafbsd_pc_in_sigtramp): Add GDBARCH parameter. (alphafbsd_sigtramp_offset): Likewise. * alpha-linux-tdep.c (alpha_linux_sigtramp_offset_1): Add GDBARCH parameter. Pass to alpha_read_insn. (alpha_linux_sigtramp_offset): Add GDBARCH parameter. Pass to alpha_linux_sigtramp_offset_1. (alpha_linux_pc_in_sigtramp): Add GDBARCH parameter. Pass to alpha_linux_sigtramp_offset. (alpha_linux_sigcontext_addr): Pass architecture to alpha_read_insn and alpha_linux_sigtramp_offset. * alphanbsd-tdep.c (alphanbsd_sigtramp_offset): Add GDBARCH parameter. (alphanbsd_pc_in_sigtramp): Add GDBARCH parameter. Pass to alphanbsd_sigtramp_offset. * alphaobsd-tdep.c (alphaobsd_sigtramp_offset): Add GDBARCH parameter. (alphaobsd_pc_in_sigtramp): Add GDBARCH parameter. Pass to alpha_read_insn. (alphaobsd_sigcontext_addr): Pass architecture to alphaobsd_sigtramp_offset. * alpha-osf1-tdep.c (alpha_osf1_pc_in_sigtramp): Add GDBARCH parameter. * amd64-tdep.c (amd64_analyze_prologue): Add GDBARCH parameter. (amd64_skip_prologue): Pass architecture to amd64_analyze_prologue. (amd64_frame_cache): Likewise. * arm-tdep.c (SWAP_SHORT, SWAP_INT): Remove. (thumb_analyze_prologue, arm_skip_prologue, arm_scan_prologue, thumb_get_next_pc, arm_get_next_pc): Do not use SWAP_ macros. * arm-wince-tdep.c: Include "frame.h". * avr-tdep.c (EXTRACT_INSN): Remove. (avr_scan_prologue): Add GDBARCH argument, inline EXTRACT_INSN. (avr_skip_prologue): Pass architecture to avr_scan_prologue. (avr_frame_unwind_cache): Likewise. * cris-tdep.c (struct instruction_environment): Add BYTE_ORDER member. (find_step_target): Initialize it. (get_data_from_address): Add BYTE_ORDER parameter. (bdap_prefix): Pass byte order to get_data_from_address. (handle_prefix_assign_mode_for_aritm_op): Likewise. (three_operand_add_sub_cmp_and_or_op): Likewise. (handle_inc_and_index_mode_for_aritm_op): Likewise. * frv-linux-tdep.c (frv_linux_pc_in_sigtramp): Add GDBARCH parameter. (frv_linux_sigcontext_reg_addr): Pass architecture to frv_linux_pc_in_sigtramp. (frv_linux_sigtramp_frame_sniffer): Likewise. * h8300-tdep.c (h8300_is_argument_spill): Add GDBARCH parameter. (h8300_analyze_prologue): Add GDBARCH parameter. Pass to h8300_is_argument_spill. (h8300_frame_cache, h8300_skip_prologue): Pass architecture to h8300_analyze_prologue. * hppa-tdep.h (struct gdbarch_tdep): Add GDBARCH parameter to in_solib_call_trampoline callback. (hppa_in_solib_call_trampoline): Add GDBARCH parameter. * hppa-tdep.c (hppa64_convert_code_addr_to_fptr): Add GDBARCH parameter. (hppa64_push_dummy_call): Pass architecture to hppa64_convert_code_addr_to_fptr. (hppa_match_insns): Add GDBARCH parameter. (hppa_match_insns_relaxed): Add GDBARCH parameter. Pass to hppa_match_insns. (hppa_skip_trampoline_code): Pass architecture to hppa_match_insns. (hppa_in_solib_call_trampoline): Add GDBARCH parameter. Pass to hppa_match_insns_relaxed. (hppa_stub_unwind_sniffer): Pass architecture to tdep->in_solib_call_trampoline callback. * hppa-hpux-tdep.c (hppa_hpux_search_pattern): Add GDBARCH parameter. (hppa32_hpux_search_dummy_call_sequence): Pass architecture to hppa_hpux_search_pattern. * hppa-linux-tdep.c (insns_match_pattern): Add GDBARCH parameter. (hppa_linux_sigtramp_find_sigcontext): Add GDBARCH parameter. Pass to insns_match_pattern. (hppa_linux_sigtramp_frame_unwind_cache): Pass architecture to hppa_linux_sigtramp_find_sigcontext. (hppa_linux_sigtramp_frame_sniffer): Likewise. (hppa32_hpux_in_solib_call_trampoline): Add GDBARCH parameter. (hppa64_hpux_in_solib_call_trampoline): Likewise. * i386-tdep.c (i386_follow_jump): Add GDBARCH parameter. (i386_analyze_frame_setup): Add GDBARCH parameter. (i386_analyze_prologue): Add GDBARCH parameter. Pass to i386_follow_jump and i386_analyze_frame_setup. (i386_skip_prologue): Pass architecture to i386_analyze_prologue and i386_follow_jump. (i386_frame_cache): Pass architecture to i386_analyze_prologue. (i386_pe_skip_trampoline_code): Add FRAME parameter. * i386-tdep.h (i386_pe_skip_trampoline_code): Add FRAME parameter. * i386-cygwin-tdep.c (i386_cygwin_skip_trampoline_code): Pass frame to i386_pe_skip_trampoline_code. * ia64-tdep.h (struct gdbarch_tdep): Add GDBARCH parameter to sigcontext_register_address callback. * ia64-tdep.c (ia64_find_global_pointer): Add GDBARCH parameter. (ia64_find_unwind_table): Pass architecture to ia64_find_global_pointer. (find_extant_func_descr): Add GDBARCH parameter. (find_func_descr): Pass architecture to find_extant_func_descr and ia64_find_global_pointer. (ia64_sigtramp_frame_init_saved_regs): Pass architecture to tdep->sigcontext_register_address callback. * ia64-linux-tdep.c (ia64_linux_sigcontext_register_address): Add GDBARCH parameter. * iq2000-tdep.c (iq2000_scan_prologue): Add GDBARCH parameter. (iq2000_frame_cache): Pass architecture to iq2000_scan_prologue. * lm32-tdep.c (lm32_analyze_prologue): Add GDBARCH parameter. (lm32_skip_prologue, lm32_frame_cache): Pass architecture to lm32_analyze_prologue. * m32r-tdep.c (decode_prologue): Add GDBARCH parameter. (m32r_skip_prologue): Pass architecture to decode_prologue. * m68hc11-tdep.c (m68hc11_analyze_instruction): Add GDBARCH parameter. (m68hc11_scan_prologue): Pass architecture to m68hc11_analyze_instruction. * m68k-tdep.c (m68k_analyze_frame_setup): Add GDBARCH parameter. (m68k_analyze_prologue): Pass architecture to m68k_analyze_frame_setup. * m88k-tdep.c (m88k_fetch_instruction): Add BYTE_ORDER parameter. (m88k_analyze_prologue): Add GDBARCH parameter. Pass byte order to m88k_fetch_instruction. (m88k_skip_prologue): Pass architecture to m88k_analyze_prologue. (m88k_frame_cache): Likewise. * mep-tdep.c (mep_get_insn): Add GDBARCH parameter. (mep_analyze_prologue): Pass architecture to mep_get_insn. * mips-tdep.c (mips_fetch_instruction): Add GDBARCH parameter. (mips32_next_pc): Pass architecture to mips_fetch_instruction. (deal_with_atomic_sequence): Likewise. (unpack_mips16): Add GDBARCH parameter, pass to mips_fetch_instruction. (mips16_scan_prologue): Likewise. (mips32_scan_prologue): Likewise. (mips16_in_function_epilogue_p): Likewise. (mips32_in_function_epilogue_p): Likewise. (mips_about_to_return): Likewise. (mips_insn16_frame_cache): Pass architecture to mips16_scan_prologue. (mips_insn32_frame_cache): Pass architecture to mips32_scan_prologue. (mips_skip_prologue): Pass architecture to mips16_scan_prologue and mips32_scan_prologue. (mips_in_function_epilogue_p): Pass architecture to mips16_in_function_epilogue_p and mips32_in_function_epilogue_p. (heuristic_proc_start): Pass architecture to mips_fetch_instruction and mips_about_to_return. (mips_skip_mips16_trampoline_code): Pass architecture to mips_fetch_instruction. (fetch_mips_16): Add GDBARCH parameter. (mips16_next_pc): Pass architecture to fetch_mips_16. (extended_mips16_next_pc): Pass architecture to unpack_mips16 and fetch_mips_16. * objc-lang.c (read_objc_method, read_objc_methlist_nmethods, read_objc_methlist_method, read_objc_object, read_objc_super, read_objc_class): Add GDBARCH parameter. (find_implementation_from_class): Add GDBARCH parameter, pass to read_objc_class, read_objc_methlist_nmethods, and read_objc_methlist_method. (find_implementation): Add GDBARCH parameter, pass to read_objc_object and find_implementation_from_class. (resolve_msgsend, resolve_msgsend_stret): Pass architecture to find_implementation. (resolve_msgsend_super, resolve_msgsend_super_stret): Pass architecture to read_objc_super and find_implementation_from_class. * ppc64-linux-tdep.c (ppc64_desc_entry_point): Add GDBARCH parameter. (ppc64_standard_linkage1_target, ppc64_standard_linkage2_target, ppc64_standard_linkage3_target): Pass architecture to ppc64_desc_entry_point. * rs6000-tdep.c (bl_to_blrl_insn_p): Add BYTE_ORDER parameter. (skip_prologue): Pass byte order to bl_to_blrl_insn_p. (rs6000_fetch_instruction): Add GDBARCH parameter. (rs6000_skip_stack_check): Add GDBARCH parameter, pass to rs6000_fetch_instruction. (skip_prologue): Pass architecture to rs6000_fetch_instruction. * remote-mips.c (mips_store_word): Return old_contents as host integer value instead of target bytes. * s390-tdep.c (struct s390_prologue_data): Add BYTE_ORDER member. (s390_analyze_prologue): Initialize it. (extend_simple_arg): Add GDBARCH parameter. (s390_push_dummy_call): Pass architecture to extend_simple_arg. * scm-lang.c (scm_get_field): Add BYTE_ORDER parameter. * scm-lang.h (scm_get_field): Add BYTE_ORDER parameter. (SCM_CAR, SCM_CDR): Pass SCM_BYTE_ORDER to scm_get_field. * scm-valprint.c (scm_scmval_print): Likewise. (scm_scmlist_print, scm_ipruk, scm_scmval_print): Define SCM_BYTE_ORDER. * sh64-tdep.c (look_for_args_moves): Add GDBARCH parameter. (sh64_skip_prologue_hard_way): Add GDBARCH parameter, pass to look_for_args_moves. (sh64_skip_prologue): Pass architecture to sh64_skip_prologue_hard_way. * sh-tdep.c (sh_analyze_prologue): Add GDBARCH parameter. (sh_skip_prologue): Pass architecture to sh_analyze_prologue. (sh_frame_cache): Likewise. * solib-irix.c (extract_mips_address): Add GDBARCH parameter. (fetch_lm_info, irix_current_sos, irix_open_symbol_file_object): Pass architecture to extract_mips_address. * sparc-tdep.h (sparc_fetch_wcookie): Add GDBARCH parameter. * sparc-tdep.c (sparc_fetch_wcookie): Add GDBARCH parameter. (sparc_supply_rwindow, sparc_collect_rwindow): Pass architecture to sparc_fetch_wcookie. (sparc32_frame_prev_register): Likewise. * sparc64-tdep.c (sparc64_frame_prev_register): Likewise. * sparc32nbsd-tdep.c (sparc32nbsd_sigcontext_saved_regs): Likewise. * sparc64nbsd-tdep.c (sparc64nbsd_sigcontext_saved_regs): Likewise. * spu-tdep.c (spu_analyze_prologue): Add GDBARCH parameter. (spu_skip_prologue): Pass architecture to spu_analyze_prologue. (spu_virtual_frame_pointer): Likewise. (spu_frame_unwind_cache): Likewise. (info_spu_mailbox_list): Add BYTE_ORER parameter. (info_spu_mailbox_command): Pass byte order to info_spu_mailbox_list. (info_spu_dma_cmdlist): Add BYTE_ORER parameter. (info_spu_dma_command, info_spu_proxydma_command): Pass byte order to info_spu_dma_cmdlist. * symfile.c (read_target_long_array): Add GDBARCH parameter. (simple_read_overlay_table, simple_read_overlay_region_table, simple_overlay_update_1): Pass architecture to read_target_long_array. * v850-tdep.c (v850_analyze_prologue): Add GDBARCH parameter. (v850_frame_cache): Pass architecture to v850_analyze_prologue. * xstormy16-tdep.c (xstormy16_analyze_prologue): Add GDBARCH parameter. (xstormy16_skip_prologue, xstormy16_frame_cache): Pass architecture to xstormy16_analyze_prologue. (xstormy16_resolve_jmp_table_entry): Add GDBARCH parameter. (xstormy16_find_jmp_table_entry): Likewise. (xstormy16_skip_trampoline_code): Pass architecture to xstormy16_resolve_jmp_table_entry. (xstormy16_pointer_to_address): Likewise. (xstormy16_address_to_pointer): Pass architecture to xstormy16_find_jmp_table_entry. * xtensa-tdep.c (call0_track_op): Add GDBARCH parameter. (call0_analyze_prologue): Add GDBARCH parameter, pass to call0_track_op. (call0_frame_cache): Pass architecture to call0_analyze_prologue. (xtensa_skip_prologue): Likewise.
2009-07-02 19:25:59 +02:00
if (byte_order == BFD_ENDIAN_BIG)
{
2005-05-19 Andrew Cagney <cagney@gnu.org> * defs.h (extract_signed_integer, extract_unsigned_integer) (extract_long_unsigned_integer, extract_typed_address) (store_signed_integer, store_unsigned_integer) (store_typed_address): Use gdb_byte for byte buffer parameters. (push_bytes, push_word): Delete declaration. * valops.c (push_bytes, push_word): Delete function. * findvar.c (extract_signed_integer, extract_unsigned_integer) (extract_typed_address, store_signed_integer) (store_unsigned_integer): Update. Index: defs.h =================================================================== RCS file: /cvs/src/src/gdb/defs.h,v retrieving revision 1.185 diff -p -u -r1.185 defs.h --- defs.h 9 May 2005 17:20:18 -0000 1.185 +++ defs.h 19 May 2005 17:54:12 -0000 @@ -1042,27 +1042,25 @@ enum { MAX_REGISTER_SIZE = 16 }; /* In findvar.c. */ -extern LONGEST extract_signed_integer (const void *, int); +extern LONGEST extract_signed_integer (const gdb_byte *, int); -extern ULONGEST extract_unsigned_integer (const void *, int); +extern ULONGEST extract_unsigned_integer (const gdb_byte *, int); -extern int extract_long_unsigned_integer (const void *, int, LONGEST *); +extern int extract_long_unsigned_integer (const gdb_byte *, int, LONGEST *); -extern CORE_ADDR extract_typed_address (const void *buf, struct type *type); +extern CORE_ADDR extract_typed_address (const gdb_byte *buf, + struct type *type); -extern void store_signed_integer (void *, int, LONGEST); +extern void store_signed_integer (gdb_byte *, int, LONGEST); -extern void store_unsigned_integer (void *, int, ULONGEST); +extern void store_unsigned_integer (gdb_byte *, int, ULONGEST); -extern void store_typed_address (void *buf, struct type *type, CORE_ADDR addr); +extern void store_typed_address (gdb_byte *buf, struct type *type, + CORE_ADDR addr); /* From valops.c */ -extern CORE_ADDR push_bytes (CORE_ADDR, char *, int); - -extern CORE_ADDR push_word (CORE_ADDR, ULONGEST); - extern int watchdog; /* Hooks for alternate command interfaces. */ Index: findvar.c =================================================================== RCS file: /cvs/src/src/gdb/findvar.c,v retrieving revision 1.91 diff -p -u -r1.91 findvar.c --- findvar.c 14 May 2005 06:07:41 -0000 1.91 +++ findvar.c 19 May 2005 17:54:12 -0000 @@ -49,7 +49,7 @@ you lose #endif LONGEST -extract_signed_integer (const void *addr, int len) +extract_signed_integer (const gdb_byte *addr, int len) { LONGEST retval; const unsigned char *p; @@ -83,7 +83,7 @@ That operation is not available on integ } ULONGEST -extract_unsigned_integer (const void *addr, int len) +extract_unsigned_integer (const gdb_byte *addr, int len) { ULONGEST retval; const unsigned char *p; @@ -117,16 +117,18 @@ That operation is not available on integ function returns 1 and sets *PVAL. Otherwise it returns 0. */ int -extract_long_unsigned_integer (const void *addr, int orig_len, LONGEST *pval) +extract_long_unsigned_integer (const gdb_byte *addr, int orig_len, + LONGEST *pval) { - char *p, *first_addr; + const gdb_byte *p; + const gdb_byte *first_addr; int len; len = orig_len; if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG) { - for (p = (char *) addr; - len > (int) sizeof (LONGEST) && p < (char *) addr + orig_len; + for (p = addr; + len > (int) sizeof (LONGEST) && p < addr + orig_len; p++) { if (*p == 0) @@ -138,9 +140,9 @@ extract_long_unsigned_integer (const voi } else { - first_addr = (char *) addr; - for (p = (char *) addr + orig_len - 1; - len > (int) sizeof (LONGEST) && p >= (char *) addr; + first_addr = addr; + for (p = addr + orig_len - 1; + len > (int) sizeof (LONGEST) && p >= addr; p--) { if (*p == 0) @@ -164,7 +166,7 @@ extract_long_unsigned_integer (const voi /* Treat the bytes at BUF as a pointer of type TYPE, and return the address it represents. */ CORE_ADDR -extract_typed_address (const void *buf, struct type *type) +extract_typed_address (const gdb_byte *buf, struct type *type) { if (TYPE_CODE (type) != TYPE_CODE_PTR && TYPE_CODE (type) != TYPE_CODE_REF) @@ -177,11 +179,11 @@ extract_typed_address (const void *buf, void -store_signed_integer (void *addr, int len, LONGEST val) +store_signed_integer (gdb_byte *addr, int len, LONGEST val) { - unsigned char *p; - unsigned char *startaddr = (unsigned char *) addr; - unsigned char *endaddr = startaddr + len; + gdb_byte *p; + gdb_byte *startaddr = addr; + gdb_byte *endaddr = startaddr + len; /* Start at the least significant end of the integer, and work towards the most significant. */ @@ -204,7 +206,7 @@ store_signed_integer (void *addr, int le } void -store_unsigned_integer (void *addr, int len, ULONGEST val) +store_unsigned_integer (gdb_byte *addr, int len, ULONGEST val) { unsigned char *p; unsigned char *startaddr = (unsigned char *) addr; @@ -233,7 +235,7 @@ store_unsigned_integer (void *addr, int /* Store the address ADDR as a pointer of type TYPE at BUF, in target form. */ void -store_typed_address (void *buf, struct type *type, CORE_ADDR addr) +store_typed_address (gdb_byte *buf, struct type *type, CORE_ADDR addr) { if (TYPE_CODE (type) != TYPE_CODE_PTR && TYPE_CODE (type) != TYPE_CODE_REF) Index: valops.c =================================================================== RCS file: /cvs/src/src/gdb/valops.c,v retrieving revision 1.157 diff -p -u -r1.157 valops.c --- valops.c 9 May 2005 21:20:35 -0000 1.157 +++ valops.c 19 May 2005 17:54:12 -0000 @@ -933,54 +933,6 @@ value_ind (struct value *arg1) return 0; /* For lint -- never reached */ } -/* Pushing small parts of stack frames. */ - -/* Push one word (the size of object that a register holds). */ - -CORE_ADDR -push_word (CORE_ADDR sp, ULONGEST word) -{ - int len = DEPRECATED_REGISTER_SIZE; - char buffer[MAX_REGISTER_SIZE]; - - store_unsigned_integer (buffer, len, word); - if (INNER_THAN (1, 2)) - { - /* stack grows downward */ - sp -= len; - write_memory (sp, buffer, len); - } - else - { - /* stack grows upward */ - write_memory (sp, buffer, len); - sp += len; - } - - return sp; -} - -/* Push LEN bytes with data at BUFFER. */ - -CORE_ADDR -push_bytes (CORE_ADDR sp, char *buffer, int len) -{ - if (INNER_THAN (1, 2)) - { - /* stack grows downward */ - sp -= len; - write_memory (sp, buffer, len); - } - else - { - /* stack grows upward */ - write_memory (sp, buffer, len); - sp += len; - } - - return sp; -} - /* Create a value for an array by allocating space in the inferior, copying the data into that space, and then setting up an array value.
2005-05-19 19:55:53 +02:00
for (p = addr;
len > (int) sizeof (LONGEST) && p < addr + orig_len;
p++)
{
if (*p == 0)
len--;
else
break;
}
first_addr = p;
}
else
{
2005-05-19 Andrew Cagney <cagney@gnu.org> * defs.h (extract_signed_integer, extract_unsigned_integer) (extract_long_unsigned_integer, extract_typed_address) (store_signed_integer, store_unsigned_integer) (store_typed_address): Use gdb_byte for byte buffer parameters. (push_bytes, push_word): Delete declaration. * valops.c (push_bytes, push_word): Delete function. * findvar.c (extract_signed_integer, extract_unsigned_integer) (extract_typed_address, store_signed_integer) (store_unsigned_integer): Update. Index: defs.h =================================================================== RCS file: /cvs/src/src/gdb/defs.h,v retrieving revision 1.185 diff -p -u -r1.185 defs.h --- defs.h 9 May 2005 17:20:18 -0000 1.185 +++ defs.h 19 May 2005 17:54:12 -0000 @@ -1042,27 +1042,25 @@ enum { MAX_REGISTER_SIZE = 16 }; /* In findvar.c. */ -extern LONGEST extract_signed_integer (const void *, int); +extern LONGEST extract_signed_integer (const gdb_byte *, int); -extern ULONGEST extract_unsigned_integer (const void *, int); +extern ULONGEST extract_unsigned_integer (const gdb_byte *, int); -extern int extract_long_unsigned_integer (const void *, int, LONGEST *); +extern int extract_long_unsigned_integer (const gdb_byte *, int, LONGEST *); -extern CORE_ADDR extract_typed_address (const void *buf, struct type *type); +extern CORE_ADDR extract_typed_address (const gdb_byte *buf, + struct type *type); -extern void store_signed_integer (void *, int, LONGEST); +extern void store_signed_integer (gdb_byte *, int, LONGEST); -extern void store_unsigned_integer (void *, int, ULONGEST); +extern void store_unsigned_integer (gdb_byte *, int, ULONGEST); -extern void store_typed_address (void *buf, struct type *type, CORE_ADDR addr); +extern void store_typed_address (gdb_byte *buf, struct type *type, + CORE_ADDR addr); /* From valops.c */ -extern CORE_ADDR push_bytes (CORE_ADDR, char *, int); - -extern CORE_ADDR push_word (CORE_ADDR, ULONGEST); - extern int watchdog; /* Hooks for alternate command interfaces. */ Index: findvar.c =================================================================== RCS file: /cvs/src/src/gdb/findvar.c,v retrieving revision 1.91 diff -p -u -r1.91 findvar.c --- findvar.c 14 May 2005 06:07:41 -0000 1.91 +++ findvar.c 19 May 2005 17:54:12 -0000 @@ -49,7 +49,7 @@ you lose #endif LONGEST -extract_signed_integer (const void *addr, int len) +extract_signed_integer (const gdb_byte *addr, int len) { LONGEST retval; const unsigned char *p; @@ -83,7 +83,7 @@ That operation is not available on integ } ULONGEST -extract_unsigned_integer (const void *addr, int len) +extract_unsigned_integer (const gdb_byte *addr, int len) { ULONGEST retval; const unsigned char *p; @@ -117,16 +117,18 @@ That operation is not available on integ function returns 1 and sets *PVAL. Otherwise it returns 0. */ int -extract_long_unsigned_integer (const void *addr, int orig_len, LONGEST *pval) +extract_long_unsigned_integer (const gdb_byte *addr, int orig_len, + LONGEST *pval) { - char *p, *first_addr; + const gdb_byte *p; + const gdb_byte *first_addr; int len; len = orig_len; if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG) { - for (p = (char *) addr; - len > (int) sizeof (LONGEST) && p < (char *) addr + orig_len; + for (p = addr; + len > (int) sizeof (LONGEST) && p < addr + orig_len; p++) { if (*p == 0) @@ -138,9 +140,9 @@ extract_long_unsigned_integer (const voi } else { - first_addr = (char *) addr; - for (p = (char *) addr + orig_len - 1; - len > (int) sizeof (LONGEST) && p >= (char *) addr; + first_addr = addr; + for (p = addr + orig_len - 1; + len > (int) sizeof (LONGEST) && p >= addr; p--) { if (*p == 0) @@ -164,7 +166,7 @@ extract_long_unsigned_integer (const voi /* Treat the bytes at BUF as a pointer of type TYPE, and return the address it represents. */ CORE_ADDR -extract_typed_address (const void *buf, struct type *type) +extract_typed_address (const gdb_byte *buf, struct type *type) { if (TYPE_CODE (type) != TYPE_CODE_PTR && TYPE_CODE (type) != TYPE_CODE_REF) @@ -177,11 +179,11 @@ extract_typed_address (const void *buf, void -store_signed_integer (void *addr, int len, LONGEST val) +store_signed_integer (gdb_byte *addr, int len, LONGEST val) { - unsigned char *p; - unsigned char *startaddr = (unsigned char *) addr; - unsigned char *endaddr = startaddr + len; + gdb_byte *p; + gdb_byte *startaddr = addr; + gdb_byte *endaddr = startaddr + len; /* Start at the least significant end of the integer, and work towards the most significant. */ @@ -204,7 +206,7 @@ store_signed_integer (void *addr, int le } void -store_unsigned_integer (void *addr, int len, ULONGEST val) +store_unsigned_integer (gdb_byte *addr, int len, ULONGEST val) { unsigned char *p; unsigned char *startaddr = (unsigned char *) addr; @@ -233,7 +235,7 @@ store_unsigned_integer (void *addr, int /* Store the address ADDR as a pointer of type TYPE at BUF, in target form. */ void -store_typed_address (void *buf, struct type *type, CORE_ADDR addr) +store_typed_address (gdb_byte *buf, struct type *type, CORE_ADDR addr) { if (TYPE_CODE (type) != TYPE_CODE_PTR && TYPE_CODE (type) != TYPE_CODE_REF) Index: valops.c =================================================================== RCS file: /cvs/src/src/gdb/valops.c,v retrieving revision 1.157 diff -p -u -r1.157 valops.c --- valops.c 9 May 2005 21:20:35 -0000 1.157 +++ valops.c 19 May 2005 17:54:12 -0000 @@ -933,54 +933,6 @@ value_ind (struct value *arg1) return 0; /* For lint -- never reached */ } -/* Pushing small parts of stack frames. */ - -/* Push one word (the size of object that a register holds). */ - -CORE_ADDR -push_word (CORE_ADDR sp, ULONGEST word) -{ - int len = DEPRECATED_REGISTER_SIZE; - char buffer[MAX_REGISTER_SIZE]; - - store_unsigned_integer (buffer, len, word); - if (INNER_THAN (1, 2)) - { - /* stack grows downward */ - sp -= len; - write_memory (sp, buffer, len); - } - else - { - /* stack grows upward */ - write_memory (sp, buffer, len); - sp += len; - } - - return sp; -} - -/* Push LEN bytes with data at BUFFER. */ - -CORE_ADDR -push_bytes (CORE_ADDR sp, char *buffer, int len) -{ - if (INNER_THAN (1, 2)) - { - /* stack grows downward */ - sp -= len; - write_memory (sp, buffer, len); - } - else - { - /* stack grows upward */ - write_memory (sp, buffer, len); - sp += len; - } - - return sp; -} - /* Create a value for an array by allocating space in the inferior, copying the data into that space, and then setting up an array value.
2005-05-19 19:55:53 +02:00
first_addr = addr;
for (p = addr + orig_len - 1;
len > (int) sizeof (LONGEST) && p >= addr;
p--)
{
if (*p == 0)
len--;
else
break;
}
}
if (len <= (int) sizeof (LONGEST))
{
*pval = (LONGEST) extract_unsigned_integer (first_addr,
* defs.h (extract_signed_integer, extract_unsigned_integer, extract_long_unsigned_integer, store_signed_integer, store_unsigned_integer): Add BYTE_ORDER parameter. * findvar.c (extract_signed_integer, extract_unsigned_integer, extract_long_unsigned_integer, store_signed_integer, store_unsigned_integer): Add BYTE_ORDER parameter. Use it instead of current_gdbarch. * gdbcore.h (read_memory_integer, safe_read_memory_integer, read_memory_unsigned_integer, write_memory_signed_integer, write_memory_unsigned_integer): Add BYTE_ORDER parameter. * corefile.c (struct captured_read_memory_integer_arguments): Add BYTE_ORDER member. (safe_read_memory_integer): Add BYTE_ORDER parameter. Store it into struct captured_read_memory_integer_arguments. (do_captured_read_memory_integer): Pass it to read_memory_integer. (read_memory_integer): Add BYTE_ORDER parameter. Pass it to extract_signed_integer. (read_memory_unsigned_integer): Add BYTE_ORDER parameter. Pass it to extract_unsigned_integer. (write_memory_signed_integer): Add BYTE_ORDER parameter. Pass it to store_signed_integer. (write_memory_unsigned_integer): Add BYTE_ORDER parameter. Pass it to store_unsigned_integer. * target.h (get_target_memory_unsigned): Add BYTE_ORDER parameter. * target.c (get_target_memory_unsigned): Add BYTE_ORDER parameter. Pass it to extract_unsigned_integer. Update calls to extract_signed_integer, extract_unsigned_integer, extract_long_unsigned_integer, store_signed_integer, store_unsigned_integer, read_memory_integer, read_memory_unsigned_integer, safe_read_memory_integer, write_memory_signed_integer, write_memory_unsigned_integer, and get_target_memory_unsigned to pass byte order: * ada-lang.c (ada_value_binop): Update. * ada-valprint.c (char_at): Update. * alpha-osf1-tdep.c (alpha_osf1_sigcontext_addr): Update. * alpha-tdep.c (alpha_lds, alpha_sts, alpha_push_dummy_call, alpha_extract_return_value, alpha_read_insn, alpha_get_longjmp_target): Update. * amd64-linux-tdep.c (amd64_linux_sigcontext_addr): Update. * amd64obsd-tdep.c (amd64obsd_supply_uthread, amd64obsd_collect_uthread, amd64obsd_trapframe_cache): Update. * amd64-tdep.c (amd64_push_dummy_call, amd64_analyze_prologue, amd64_frame_cache, amd64_sigtramp_frame_cache, fixup_riprel, amd64_displaced_step_fixup): Update. * arm-linux-tdep.c (arm_linux_sigreturn_init, arm_linux_rt_sigreturn_init, arm_linux_supply_gregset): Update. * arm-tdep.c (thumb_analyze_prologue, arm_skip_prologue, arm_scan_prologue, arm_push_dummy_call, thumb_get_next_pc, arm_get_next_pc, arm_extract_return_value, arm_store_return_value, arm_return_value): Update. * arm-wince-tdep.c (arm_pe_skip_trampoline_code): Update. * auxv.c (default_auxv_parse): Update. * avr-tdep.c (avr_address_to_pointer, avr_pointer_to_address, avr_scan_prologue, avr_extract_return_value, avr_frame_prev_register, avr_push_dummy_call): Update. * bsd-uthread.c (bsd_uthread_check_magic, bsd_uthread_lookup_offset, bsd_uthread_wait, bsd_uthread_thread_alive, bsd_uthread_extra_thread_info): Update. * c-lang.c (c_printstr, print_wchar): Update. * cp-valprint.c (cp_print_class_member): Update. * cris-tdep.c (cris_sigcontext_addr, cris_sigtramp_frame_unwind_cache, cris_push_dummy_call, cris_scan_prologue, cris_store_return_value, cris_extract_return_value, find_step_target, dip_prefix, sixteen_bit_offset_branch_op, none_reg_mode_jump_op, move_mem_to_reg_movem_op, get_data_from_address): Update. * dwarf2expr.c (dwarf2_read_address, execute_stack_op): Update. * dwarf2-frame.c (execute_cfa_program): Update. * dwarf2loc.c (find_location_expression): Update. * dwarf2read.c (dwarf2_const_value): Update. * expprint.c (print_subexp_standard): Update. * findvar.c (unsigned_pointer_to_address, signed_pointer_to_address, unsigned_address_to_pointer, address_to_signed_pointer, read_var_value): Update. * frame.c (frame_unwind_register_signed, frame_unwind_register_unsigned, get_frame_memory_signed, get_frame_memory_unsigned): Update. * frame-unwind.c (frame_unwind_got_constant): Update. * frv-linux-tdep.c (frv_linux_pc_in_sigtramp, frv_linux_sigcontext_reg_addr, frv_linux_sigtramp_frame_cache): Update. * frv-tdep.c (frv_analyze_prologue, frv_skip_main_prologue, frv_extract_return_value, find_func_descr, frv_convert_from_func_ptr_addr, frv_push_dummy_call): Update. * f-valprint.c (f_val_print): Update. * gnu-v3-abi.c (gnuv3_decode_method_ptr, gnuv3_make_method_ptr): Update. * h8300-tdep.c (h8300_is_argument_spill, h8300_analyze_prologue, h8300_push_dummy_call, h8300_extract_return_value, h8300h_extract_return_value, h8300_store_return_value, h8300h_store_return_value): Update. * hppabsd-tdep.c (hppabsd_find_global_pointer): Update. * hppa-hpux-nat.c (hppa_hpux_fetch_register, hppa_hpux_store_register): Update. * hppa-hpux-tdep.c (hppa32_hpux_in_solib_call_trampoline, hppa64_hpux_in_solib_call_trampoline, hppa_hpux_in_solib_return_trampoline, hppa_hpux_skip_trampoline_code, hppa_hpux_sigtramp_frame_unwind_cache, hppa_hpux_sigtramp_unwind_sniffer, hppa32_hpux_find_global_pointer, hppa64_hpux_find_global_pointer, hppa_hpux_search_pattern, hppa32_hpux_search_dummy_call_sequence, hppa64_hpux_search_dummy_call_sequence, hppa_hpux_supply_save_state, hppa_hpux_unwind_adjust_stub): Update. * hppa-linux-tdep.c (insns_match_pattern, hppa_linux_find_global_pointer): Update. * hppa-tdep.c (hppa_in_function_epilogue_p, hppa32_push_dummy_call, hppa64_convert_code_addr_to_fptr, hppa64_push_dummy_call, skip_prologue_hard_way, hppa_frame_cache, hppa_fallback_frame_cache, hppa_pseudo_register_read, hppa_frame_prev_register_helper, hppa_match_insns): Update. * hpux-thread.c (hpux_thread_fetch_registers): Update. * i386-tdep.c (i386bsd_sigcontext_addr): Update. * i386-cygwin-tdep.c (core_process_module_section): Update. * i386-darwin-nat.c (i386_darwin_sstep_at_sigreturn, amd64_darwin_sstep_at_sigreturn): Update. * i386-darwin-tdep.c (i386_darwin_sigcontext_addr, amd64_darwin_sigcontext_addr): Likewise. * i386-linux-nat.c (i386_linux_sigcontext_addr): Update. * i386nbsd-tdep.c (i386nbsd_sigtramp_cache_init): Update. * i386-nto-tdep.c (i386nto_sigcontext_addr): Update. * i386obsd-nat.c (i386obsd_supply_pcb): Update. * i386obsd-tdep.c (i386obsd_supply_uthread, i386obsd_collect_uthread, i386obsd_trapframe_cache): Update. * i386-tdep.c (i386_displaced_step_fixup, i386_follow_jump, i386_analyze_frame_setup, i386_analyze_prologue, i386_skip_main_prologue, i386_frame_cache, i386_sigtramp_frame_cache, i386_get_longjmp_target, i386_push_dummy_call, i386_pe_skip_trampoline_code, i386_svr4_sigcontext_addr, i386_fetch_pointer_argument): Update. * i387-tdep.c (i387_supply_fsave): Update. * ia64-linux-tdep.c (ia64_linux_sigcontext_register_address): Update. * ia64-tdep.c (ia64_pseudo_register_read, ia64_pseudo_register_write, examine_prologue, ia64_frame_cache, ia64_frame_prev_register, ia64_sigtramp_frame_cache, ia64_sigtramp_frame_prev_register, ia64_access_reg, ia64_access_rse_reg, ia64_libunwind_frame_this_id, ia64_libunwind_frame_prev_register, ia64_libunwind_sigtramp_frame_this_id, ia64_libunwind_sigtramp_frame_prev_register, ia64_find_global_pointer, find_extant_func_descr, find_func_descr, ia64_convert_from_func_ptr_addr, ia64_push_dummy_call, ia64_dummy_id, ia64_unwind_pc): Update. * iq2000-tdep.c (iq2000_pointer_to_address, iq2000_address_to_pointer, iq2000_scan_prologue, iq2000_extract_return_value, iq2000_push_dummy_call): Update. * irix5nat.c (fill_gregset): Update. * jv-lang.c (evaluate_subexp_java): Update. * jv-valprint.c (java_value_print): Update. * lm32-tdep.c (lm32_analyze_prologue, lm32_push_dummy_call, lm32_extract_return_value, lm32_store_return_value): Update. * m32c-tdep.c (m32c_push_dummy_call, m32c_return_value, m32c_skip_trampoline_code, m32c_m16c_address_to_pointer, m32c_m16c_pointer_to_address): Update. * m32r-tdep.c (m32r_store_return_value, decode_prologue, m32r_skip_prologue, m32r_push_dummy_call, m32r_extract_return_value): Update. * m68hc11-tdep.c (m68hc11_pseudo_register_read, m68hc11_pseudo_register_write, m68hc11_analyze_instruction, m68hc11_push_dummy_call): Update. * m68linux-tdep.c (m68k_linux_pc_in_sigtramp, m68k_linux_get_sigtramp_info, m68k_linux_sigtramp_frame_cache): Update. * m68k-tdep.c (m68k_push_dummy_call, m68k_analyze_frame_setup, m68k_analyze_register_saves, m68k_analyze_prologue, m68k_frame_cache, m68k_get_longjmp_target): Update. * m88k-tdep.c (m88k_fetch_instruction): Update. * mep-tdep.c (mep_pseudo_cr32_read, mep_pseudo_csr_write, mep_pseudo_cr32_write, mep_get_insn, mep_push_dummy_call): Update. * mi/mi-main.c (mi_cmd_data_write_memory): Update. * mips-linux-tdep.c (mips_linux_get_longjmp_target, supply_32bit_reg, mips64_linux_get_longjmp_target, mips64_fill_gregset, mips64_fill_fpregset, mips_linux_in_dynsym_stub): Update. * mipsnbdsd-tdep.c (mipsnbsd_get_longjmp_target): Update. * mips-tdep.c (mips_fetch_instruction, fetch_mips_16, mips_eabi_push_dummy_call, mips_n32n64_push_dummy_call, mips_o32_push_dummy_call, mips_o64_push_dummy_call, mips_single_step_through_delay, mips_skip_pic_trampoline_code, mips_integer_to_address): Update. * mn10300-tdep.c (mn10300_analyze_prologue, mn10300_push_dummy_call): Update. * monitor.c (monitor_supply_register, monitor_write_memory, monitor_read_memory_single): Update. * moxie-tdep.c (moxie_store_return_value, moxie_extract_return_value, moxie_analyze_prologue): Update. * mt-tdep.c (mt_return_value, mt_skip_prologue, mt_select_coprocessor, mt_pseudo_register_read, mt_pseudo_register_write, mt_registers_info, mt_push_dummy_call): Update. * objc-lang.c (read_objc_method, read_objc_methlist_nmethods, read_objc_methlist_method, read_objc_object, read_objc_super, read_objc_class, find_implementation_from_class): Update. * ppc64-linux-tdep.c (ppc64_desc_entry_point, ppc64_linux_convert_from_func_ptr_addr, ppc_linux_sigtramp_cache): Update. * ppcobsd-tdep.c (ppcobsd_sigtramp_frame_sniffer, ppcobsd_sigtramp_frame_cache): Update. * ppc-sysv-tdep.c (ppc_sysv_abi_push_dummy_call, do_ppc_sysv_return_value, ppc64_sysv_abi_push_dummy_call, ppc64_sysv_abi_return_value): Update. * ppc-linux-nat.c (ppc_linux_auxv_parse): Update. * procfs.c (procfs_auxv_parse): Update. * p-valprint.c (pascal_val_print): Update. * regcache.c (regcache_raw_read_signed, regcache_raw_read_unsigned, regcache_raw_write_signed, regcache_raw_write_unsigned, regcache_cooked_read_signed, regcache_cooked_read_unsigned, regcache_cooked_write_signed, regcache_cooked_write_unsigned): Update. * remote-m32r-sdi.c (m32r_fetch_register): Update. * remote-mips.c (mips_wait, mips_fetch_registers, mips_xfer_memory): Update. * rs6000-aix-tdep.c (rs6000_push_dummy_call, rs6000_return_value, rs6000_convert_from_func_ptr_addr, branch_dest, rs6000_software_single_step): Update. * rs6000-tdep.c (rs6000_in_function_epilogue_p, ppc_displaced_step_fixup, ppc_deal_with_atomic_sequence, bl_to_blrl_insn_p, rs6000_fetch_instruction, skip_prologue, rs6000_skip_main_prologue, rs6000_skip_trampoline_code, rs6000_frame_cache): Update. * s390-tdep.c (s390_pseudo_register_read, s390_pseudo_register_write, s390x_pseudo_register_read, s390x_pseudo_register_write, s390_load, s390_backchain_frame_unwind_cache, s390_sigtramp_frame_unwind_cache, extend_simple_arg, s390_push_dummy_call, s390_return_value): Update. * scm-exp.c (scm_lreadr): Update. * scm-lang.c (scm_get_field, scm_unpack): Update. * scm-valprint.c (scm_val_print): Update. * score-tdep.c (score_breakpoint_from_pc, score_push_dummy_call, score_fetch_inst): Update. * sh64-tdep.c (look_for_args_moves, sh64_skip_prologue_hard_way, sh64_analyze_prologue, sh64_push_dummy_call, sh64_extract_return_value, sh64_pseudo_register_read, sh64_pseudo_register_write, sh64_frame_prev_register): Update: * sh-tdep.c (sh_analyze_prologue, sh_push_dummy_call_fpu, sh_push_dummy_call_nofpu, sh_extract_return_value_nofpu, sh_store_return_value_nofpu, sh_in_function_epilogue_p): Update. * solib-darwin.c (darwin_load_image_infos): Update. * solib-frv.c (fetch_loadmap, lm_base, frv_current_sos, enable_break2, find_canonical_descriptor_in_load_object): Update. * solib-irix.c (extract_mips_address, fetch_lm_info, irix_current_sos, irix_open_symbol_file_object): Update. * solib-som.c (som_solib_create_inferior_hook, link_map_start, som_current_sos, som_open_symbol_file_object): Update. * solib-sunos.c (SOLIB_EXTRACT_ADDRESS, LM_ADDR, LM_NEXT, LM_NAME): Update. * solib-svr4.c (read_program_header, scan_dyntag_auxv, solib_svr4_r_ldsomap): Update. * sparc64-linux-tdep.c (sparc64_linux_step_trap): Update. * sparc64obsd-tdep.c (sparc64obsd_supply_uthread, sparc64obsd_collect_uthread): Update. * sparc64-tdep.c (sparc64_pseudo_register_read, sparc64_pseudo_register_write, sparc64_supply_gregset, sparc64_collect_gregset): Update. * sparc-linux-tdep.c (sparc32_linux_step_trap): Update. * sparcobsd-tdep.c (sparc32obsd_supply_uthread, sparc32obsd_collect_uthread): Update. * sparc-tdep.c (sparc_fetch_wcookie, sparc32_push_dummy_code, sparc32_store_arguments, sparc32_return_value, sparc_supply_rwindow, sparc_collect_rwindow): Update. * spu-linux-nat.c (parse_spufs_run): Update. * spu-tdep.c (spu_pseudo_register_read_spu, spu_pseudo_register_write_spu, spu_pointer_to_address, spu_analyze_prologue, spu_in_function_epilogue_p, spu_frame_unwind_cache, spu_push_dummy_call, spu_software_single_step, spu_get_longjmp_target, spu_get_overlay_table, spu_overlay_update_osect, info_spu_signal_command, info_spu_mailbox_list, info_spu_dma_cmdlist, info_spu_dma_command, info_spu_proxydma_command): Update. * stack.c (print_frame_nameless_args, frame_info): Update. * symfile.c (read_target_long_array, simple_read_overlay_table, simple_read_overlay_region_table): Update. * target.c (debug_print_register): Update. * tramp-frame.c (tramp_frame_start): Update. * v850-tdep.c (v850_analyze_prologue, v850_push_dummy_call, v850_extract_return_value, v850_store_return_value, * valarith.c (value_binop, value_bit_index): Update. * valops.c (value_cast): Update. * valprint.c (val_print_type_code_int, val_print_string, read_string): Update. * value.c (unpack_long, unpack_double, unpack_field_as_long, modify_field, pack_long): Update. * vax-tdep.c (vax_store_arguments, vax_push_dummy_call, vax_skip_prologue): Update. * xstormy16-tdep.c (xstormy16_push_dummy_call, xstormy16_analyze_prologue, xstormy16_in_function_epilogue_p, xstormy16_resolve_jmp_table_entry, xstormy16_find_jmp_table_entry, xstormy16_pointer_to_address, xstormy16_address_to_pointer): Update. * xtensa-tdep.c (extract_call_winsize, xtensa_pseudo_register_read, xtensa_pseudo_register_write, xtensa_frame_cache, xtensa_push_dummy_call, call0_track_op, call0_frame_cache): Update. * dfp.h (decimal_to_string, decimal_from_string, decimal_from_integral, decimal_from_floating, decimal_to_doublest, decimal_is_zero): Add BYTE_ORDER parameter. (decimal_binop): Add BYTE_ORDER_X, BYTE_ORDER_Y, and BYTE_ORDER_RESULT parameters. (decimal_compare): Add BYTE_ORDER_X and BYTE_ORDER_Y parameters. (decimal_convert): Add BYTE_ORDER_FROM and BYTE_ORDER_TO parameters. * dfp.c (match_endianness): Add BYTE_ORDER parameter. Use it instead of current_gdbarch. (decimal_to_string, decimal_from_integral, decimal_from_floating, decimal_to_doublest, decimal_is_zero): Add BYTE_ORDER parameter. Pass it to match_endianness. (decimal_binop): Add BYTE_ORDER_X, BYTE_ORDER_Y, and BYTE_ORDER_RESULT parameters. Pass them to match_endianness. (decimal_compare): Add BYTE_ORDER_X and BYTE_ORDER_Y parameters. Pass them to match_endianness. (decimal_convert): Add BYTE_ORDER_FROM and BYTE_ORDER_TO parameters. Pass them to match_endianness. * valarith.c (value_args_as_decimal): Add BYTE_ORDER_X and BYTE_ORDER_Y output parameters. (value_binop): Update call to value_args_as_decimal. Update calls to decimal_to_string, decimal_from_string, decimal_from_integral, decimal_from_floating, decimal_to_doublest, decimal_is_zero, decimal_binop, decimal_compare and decimal_convert to pass/receive byte order: * c-exp.y (parse_number): Update. * printcmd.c (printf_command): Update. * valarith.c (value_args_as_decimal, value_binop, value_logical_not, value_equal, value_less): Update. * valops.c (value_cast, value_one): Update. * valprint.c (print_decimal_floating): Update. * value.c (unpack_long, unpack_double): Update. * python/python-value.c (valpy_nonzero): Update. * ada-valprint.c (char_at): Add BYTE_ORDER parameter. (printstr): Update calls to char_at. (ada_val_print_array): Likewise. * valprint.c (read_string): Add BYTE_ORDER parameter. (val_print_string): Update call to read_string. * c-lang.c (c_get_string): Likewise. * charset.h (target_wide_charset): Add BYTE_ORDER parameter. * charset.c (target_wide_charset): Add BYTE_ORDER parameter. Use it instead of current_gdbarch. * printcmd.c (printf_command): Update calls to target_wide_charset. * c-lang.c (charset_for_string_type): Add BYTE_ORDER parameter. Pass to target_wide_charset. Use it instead of current_gdbarch. (classify_type): Add BYTE_ORDER parameter. Pass to charset_for_string_type. Allow NULL encoding pointer. (print_wchar): Add BYTE_ORDER parameter. (c_emit_char): Update calls to classify_type and print_wchar. (c_printchar, c_printstr): Likewise. * gdbarch.sh (in_solib_return_trampoline): Convert to type "m". * gdbarch.c, gdbarch.h: Regenerate. * arch-utils.h (generic_in_solib_return_trampoline): Add GDBARCH parameter. * arch-utils.c (generic_in_solib_return_trampoline): Likewise. * hppa-hpux-tdep.c (hppa_hpux_in_solib_return_trampoline): Likewise. * rs6000-tdep.c (rs6000_in_solib_return_trampoline): Likewise. (rs6000_skip_trampoline_code): Update call. * alpha-tdep.h (struct gdbarch_tdep): Add GDBARCH parameter to dynamic_sigtramp_offset and pc_in_sigtramp callbacks. (alpha_read_insn): Add GDBARCH parameter. * alpha-tdep.c (alpha_lds, alpha_sts): Add GDBARCH parameter. (alpha_register_to_value): Pass architecture to alpha_sts. (alpha_extract_return_value): Likewise. (alpha_value_to_register): Pass architecture to alpha_lds. (alpha_store_return_value): Likewise. (alpha_read_insn): Add GDBARCH parameter. (alpha_skip_prologue): Pass architecture to alpha_read_insn. (alpha_heuristic_proc_start): Likewise. (alpha_heuristic_frame_unwind_cache): Likewise. (alpha_next_pc): Likewise. (alpha_sigtramp_frame_this_id): Pass architecture to tdep->dynamic_sigtramp_offset callback. (alpha_sigtramp_frame_sniffer): Pass architecture to tdep->pc_in_sigtramp callback. * alphafbsd-tdep.c (alphafbsd_pc_in_sigtramp): Add GDBARCH parameter. (alphafbsd_sigtramp_offset): Likewise. * alpha-linux-tdep.c (alpha_linux_sigtramp_offset_1): Add GDBARCH parameter. Pass to alpha_read_insn. (alpha_linux_sigtramp_offset): Add GDBARCH parameter. Pass to alpha_linux_sigtramp_offset_1. (alpha_linux_pc_in_sigtramp): Add GDBARCH parameter. Pass to alpha_linux_sigtramp_offset. (alpha_linux_sigcontext_addr): Pass architecture to alpha_read_insn and alpha_linux_sigtramp_offset. * alphanbsd-tdep.c (alphanbsd_sigtramp_offset): Add GDBARCH parameter. (alphanbsd_pc_in_sigtramp): Add GDBARCH parameter. Pass to alphanbsd_sigtramp_offset. * alphaobsd-tdep.c (alphaobsd_sigtramp_offset): Add GDBARCH parameter. (alphaobsd_pc_in_sigtramp): Add GDBARCH parameter. Pass to alpha_read_insn. (alphaobsd_sigcontext_addr): Pass architecture to alphaobsd_sigtramp_offset. * alpha-osf1-tdep.c (alpha_osf1_pc_in_sigtramp): Add GDBARCH parameter. * amd64-tdep.c (amd64_analyze_prologue): Add GDBARCH parameter. (amd64_skip_prologue): Pass architecture to amd64_analyze_prologue. (amd64_frame_cache): Likewise. * arm-tdep.c (SWAP_SHORT, SWAP_INT): Remove. (thumb_analyze_prologue, arm_skip_prologue, arm_scan_prologue, thumb_get_next_pc, arm_get_next_pc): Do not use SWAP_ macros. * arm-wince-tdep.c: Include "frame.h". * avr-tdep.c (EXTRACT_INSN): Remove. (avr_scan_prologue): Add GDBARCH argument, inline EXTRACT_INSN. (avr_skip_prologue): Pass architecture to avr_scan_prologue. (avr_frame_unwind_cache): Likewise. * cris-tdep.c (struct instruction_environment): Add BYTE_ORDER member. (find_step_target): Initialize it. (get_data_from_address): Add BYTE_ORDER parameter. (bdap_prefix): Pass byte order to get_data_from_address. (handle_prefix_assign_mode_for_aritm_op): Likewise. (three_operand_add_sub_cmp_and_or_op): Likewise. (handle_inc_and_index_mode_for_aritm_op): Likewise. * frv-linux-tdep.c (frv_linux_pc_in_sigtramp): Add GDBARCH parameter. (frv_linux_sigcontext_reg_addr): Pass architecture to frv_linux_pc_in_sigtramp. (frv_linux_sigtramp_frame_sniffer): Likewise. * h8300-tdep.c (h8300_is_argument_spill): Add GDBARCH parameter. (h8300_analyze_prologue): Add GDBARCH parameter. Pass to h8300_is_argument_spill. (h8300_frame_cache, h8300_skip_prologue): Pass architecture to h8300_analyze_prologue. * hppa-tdep.h (struct gdbarch_tdep): Add GDBARCH parameter to in_solib_call_trampoline callback. (hppa_in_solib_call_trampoline): Add GDBARCH parameter. * hppa-tdep.c (hppa64_convert_code_addr_to_fptr): Add GDBARCH parameter. (hppa64_push_dummy_call): Pass architecture to hppa64_convert_code_addr_to_fptr. (hppa_match_insns): Add GDBARCH parameter. (hppa_match_insns_relaxed): Add GDBARCH parameter. Pass to hppa_match_insns. (hppa_skip_trampoline_code): Pass architecture to hppa_match_insns. (hppa_in_solib_call_trampoline): Add GDBARCH parameter. Pass to hppa_match_insns_relaxed. (hppa_stub_unwind_sniffer): Pass architecture to tdep->in_solib_call_trampoline callback. * hppa-hpux-tdep.c (hppa_hpux_search_pattern): Add GDBARCH parameter. (hppa32_hpux_search_dummy_call_sequence): Pass architecture to hppa_hpux_search_pattern. * hppa-linux-tdep.c (insns_match_pattern): Add GDBARCH parameter. (hppa_linux_sigtramp_find_sigcontext): Add GDBARCH parameter. Pass to insns_match_pattern. (hppa_linux_sigtramp_frame_unwind_cache): Pass architecture to hppa_linux_sigtramp_find_sigcontext. (hppa_linux_sigtramp_frame_sniffer): Likewise. (hppa32_hpux_in_solib_call_trampoline): Add GDBARCH parameter. (hppa64_hpux_in_solib_call_trampoline): Likewise. * i386-tdep.c (i386_follow_jump): Add GDBARCH parameter. (i386_analyze_frame_setup): Add GDBARCH parameter. (i386_analyze_prologue): Add GDBARCH parameter. Pass to i386_follow_jump and i386_analyze_frame_setup. (i386_skip_prologue): Pass architecture to i386_analyze_prologue and i386_follow_jump. (i386_frame_cache): Pass architecture to i386_analyze_prologue. (i386_pe_skip_trampoline_code): Add FRAME parameter. * i386-tdep.h (i386_pe_skip_trampoline_code): Add FRAME parameter. * i386-cygwin-tdep.c (i386_cygwin_skip_trampoline_code): Pass frame to i386_pe_skip_trampoline_code. * ia64-tdep.h (struct gdbarch_tdep): Add GDBARCH parameter to sigcontext_register_address callback. * ia64-tdep.c (ia64_find_global_pointer): Add GDBARCH parameter. (ia64_find_unwind_table): Pass architecture to ia64_find_global_pointer. (find_extant_func_descr): Add GDBARCH parameter. (find_func_descr): Pass architecture to find_extant_func_descr and ia64_find_global_pointer. (ia64_sigtramp_frame_init_saved_regs): Pass architecture to tdep->sigcontext_register_address callback. * ia64-linux-tdep.c (ia64_linux_sigcontext_register_address): Add GDBARCH parameter. * iq2000-tdep.c (iq2000_scan_prologue): Add GDBARCH parameter. (iq2000_frame_cache): Pass architecture to iq2000_scan_prologue. * lm32-tdep.c (lm32_analyze_prologue): Add GDBARCH parameter. (lm32_skip_prologue, lm32_frame_cache): Pass architecture to lm32_analyze_prologue. * m32r-tdep.c (decode_prologue): Add GDBARCH parameter. (m32r_skip_prologue): Pass architecture to decode_prologue. * m68hc11-tdep.c (m68hc11_analyze_instruction): Add GDBARCH parameter. (m68hc11_scan_prologue): Pass architecture to m68hc11_analyze_instruction. * m68k-tdep.c (m68k_analyze_frame_setup): Add GDBARCH parameter. (m68k_analyze_prologue): Pass architecture to m68k_analyze_frame_setup. * m88k-tdep.c (m88k_fetch_instruction): Add BYTE_ORDER parameter. (m88k_analyze_prologue): Add GDBARCH parameter. Pass byte order to m88k_fetch_instruction. (m88k_skip_prologue): Pass architecture to m88k_analyze_prologue. (m88k_frame_cache): Likewise. * mep-tdep.c (mep_get_insn): Add GDBARCH parameter. (mep_analyze_prologue): Pass architecture to mep_get_insn. * mips-tdep.c (mips_fetch_instruction): Add GDBARCH parameter. (mips32_next_pc): Pass architecture to mips_fetch_instruction. (deal_with_atomic_sequence): Likewise. (unpack_mips16): Add GDBARCH parameter, pass to mips_fetch_instruction. (mips16_scan_prologue): Likewise. (mips32_scan_prologue): Likewise. (mips16_in_function_epilogue_p): Likewise. (mips32_in_function_epilogue_p): Likewise. (mips_about_to_return): Likewise. (mips_insn16_frame_cache): Pass architecture to mips16_scan_prologue. (mips_insn32_frame_cache): Pass architecture to mips32_scan_prologue. (mips_skip_prologue): Pass architecture to mips16_scan_prologue and mips32_scan_prologue. (mips_in_function_epilogue_p): Pass architecture to mips16_in_function_epilogue_p and mips32_in_function_epilogue_p. (heuristic_proc_start): Pass architecture to mips_fetch_instruction and mips_about_to_return. (mips_skip_mips16_trampoline_code): Pass architecture to mips_fetch_instruction. (fetch_mips_16): Add GDBARCH parameter. (mips16_next_pc): Pass architecture to fetch_mips_16. (extended_mips16_next_pc): Pass architecture to unpack_mips16 and fetch_mips_16. * objc-lang.c (read_objc_method, read_objc_methlist_nmethods, read_objc_methlist_method, read_objc_object, read_objc_super, read_objc_class): Add GDBARCH parameter. (find_implementation_from_class): Add GDBARCH parameter, pass to read_objc_class, read_objc_methlist_nmethods, and read_objc_methlist_method. (find_implementation): Add GDBARCH parameter, pass to read_objc_object and find_implementation_from_class. (resolve_msgsend, resolve_msgsend_stret): Pass architecture to find_implementation. (resolve_msgsend_super, resolve_msgsend_super_stret): Pass architecture to read_objc_super and find_implementation_from_class. * ppc64-linux-tdep.c (ppc64_desc_entry_point): Add GDBARCH parameter. (ppc64_standard_linkage1_target, ppc64_standard_linkage2_target, ppc64_standard_linkage3_target): Pass architecture to ppc64_desc_entry_point. * rs6000-tdep.c (bl_to_blrl_insn_p): Add BYTE_ORDER parameter. (skip_prologue): Pass byte order to bl_to_blrl_insn_p. (rs6000_fetch_instruction): Add GDBARCH parameter. (rs6000_skip_stack_check): Add GDBARCH parameter, pass to rs6000_fetch_instruction. (skip_prologue): Pass architecture to rs6000_fetch_instruction. * remote-mips.c (mips_store_word): Return old_contents as host integer value instead of target bytes. * s390-tdep.c (struct s390_prologue_data): Add BYTE_ORDER member. (s390_analyze_prologue): Initialize it. (extend_simple_arg): Add GDBARCH parameter. (s390_push_dummy_call): Pass architecture to extend_simple_arg. * scm-lang.c (scm_get_field): Add BYTE_ORDER parameter. * scm-lang.h (scm_get_field): Add BYTE_ORDER parameter. (SCM_CAR, SCM_CDR): Pass SCM_BYTE_ORDER to scm_get_field. * scm-valprint.c (scm_scmval_print): Likewise. (scm_scmlist_print, scm_ipruk, scm_scmval_print): Define SCM_BYTE_ORDER. * sh64-tdep.c (look_for_args_moves): Add GDBARCH parameter. (sh64_skip_prologue_hard_way): Add GDBARCH parameter, pass to look_for_args_moves. (sh64_skip_prologue): Pass architecture to sh64_skip_prologue_hard_way. * sh-tdep.c (sh_analyze_prologue): Add GDBARCH parameter. (sh_skip_prologue): Pass architecture to sh_analyze_prologue. (sh_frame_cache): Likewise. * solib-irix.c (extract_mips_address): Add GDBARCH parameter. (fetch_lm_info, irix_current_sos, irix_open_symbol_file_object): Pass architecture to extract_mips_address. * sparc-tdep.h (sparc_fetch_wcookie): Add GDBARCH parameter. * sparc-tdep.c (sparc_fetch_wcookie): Add GDBARCH parameter. (sparc_supply_rwindow, sparc_collect_rwindow): Pass architecture to sparc_fetch_wcookie. (sparc32_frame_prev_register): Likewise. * sparc64-tdep.c (sparc64_frame_prev_register): Likewise. * sparc32nbsd-tdep.c (sparc32nbsd_sigcontext_saved_regs): Likewise. * sparc64nbsd-tdep.c (sparc64nbsd_sigcontext_saved_regs): Likewise. * spu-tdep.c (spu_analyze_prologue): Add GDBARCH parameter. (spu_skip_prologue): Pass architecture to spu_analyze_prologue. (spu_virtual_frame_pointer): Likewise. (spu_frame_unwind_cache): Likewise. (info_spu_mailbox_list): Add BYTE_ORER parameter. (info_spu_mailbox_command): Pass byte order to info_spu_mailbox_list. (info_spu_dma_cmdlist): Add BYTE_ORER parameter. (info_spu_dma_command, info_spu_proxydma_command): Pass byte order to info_spu_dma_cmdlist. * symfile.c (read_target_long_array): Add GDBARCH parameter. (simple_read_overlay_table, simple_read_overlay_region_table, simple_overlay_update_1): Pass architecture to read_target_long_array. * v850-tdep.c (v850_analyze_prologue): Add GDBARCH parameter. (v850_frame_cache): Pass architecture to v850_analyze_prologue. * xstormy16-tdep.c (xstormy16_analyze_prologue): Add GDBARCH parameter. (xstormy16_skip_prologue, xstormy16_frame_cache): Pass architecture to xstormy16_analyze_prologue. (xstormy16_resolve_jmp_table_entry): Add GDBARCH parameter. (xstormy16_find_jmp_table_entry): Likewise. (xstormy16_skip_trampoline_code): Pass architecture to xstormy16_resolve_jmp_table_entry. (xstormy16_pointer_to_address): Likewise. (xstormy16_address_to_pointer): Pass architecture to xstormy16_find_jmp_table_entry. * xtensa-tdep.c (call0_track_op): Add GDBARCH parameter. (call0_analyze_prologue): Add GDBARCH parameter, pass to call0_track_op. (call0_frame_cache): Pass architecture to call0_analyze_prologue. (xtensa_skip_prologue): Likewise.
2009-07-02 19:25:59 +02:00
sizeof (LONGEST),
byte_order);
return 1;
}
return 0;
}
* gdbarch.sh (POINTER_TO_ADDRESS, ADDRESS_TO_POINTER): Two new functions which architectures can redefine, defaulting to generic_pointer_to_address and generic_address_to_pointer. * findvar.c (extract_typed_address, store_typed_address, generic_pointer_to_address, generic_address_to_pointer): New functions. (POINTER_TO_ADDRESS, ADDRESS_TO_POINTER): Provide default definitions. (extract_address, store_address): Doc fixes. * values.c (value_as_pointer): Doc fix. (value_from_pointer): New function. * defs.h (extract_typed_address, store_typed_address): New declarations. * inferior.h (generic_address_to_pointer, generic_pointer_to_address): New declarations. * value.h (value_from_pointer): New declaration. * ax-gdb.c (const_var_ref): Use value_from_pointer, not value_from_longest. * blockframe.c (generic_push_dummy_frame): Use read_pc and read_sp, not read_register. * c-valprint.c (c_val_print): Use extract_typed_address instead of extract_address to extract vtable entries and references. * cp-valprint.c (cp_print_value_fields): Use value_from_pointer instead of value_from_longest to extract the vtable's address. * eval.c (evaluate_subexp_standard): Use value_from_pointer instead of value_from_longest to compute `this', and for doing pointer-to-member dereferencing. * findvar.c (read_register): Use extract_unsigned_integer, not extract_address. (read_var_value): Use store_typed_address instead of store_address for building label values. (locate_var_value): Use value_from_pointer instead of value_from_longest. * hppa-tdep.c (find_stub_with_shl_get): Use value_from_pointer, instead of value_from_longest, to build arguments to __d_shl_get. * printcmd.c (set_next_address): Use value_from_pointer, not value_from_longest. (x_command): Use value_from_pointer, not value_from_longest. * tracepoint.c (set_traceframe_context): Use value_from_pointer, not value_from_longest. * valarith.c (value_add, value_sub): Use value_from_pointer, not value_from_longest. * valops.c (find_function_in_inferior, value_coerce_array, value_coerce_function, value_addr, hand_function_call): Same. * value.h (COERCE_REF): Use unpack_pointer, not unpack_long. * values.c (unpack_long): Use extract_typed_address to produce addresses from pointers and references, not extract_address. (value_from_longest): Use store_typed_address instead of store_address to produce pointer and reference values.
2000-04-14 20:43:41 +02:00
/* Treat the bytes at BUF as a pointer of type TYPE, and return the
address it represents. */
CORE_ADDR
2005-05-19 Andrew Cagney <cagney@gnu.org> * defs.h (extract_signed_integer, extract_unsigned_integer) (extract_long_unsigned_integer, extract_typed_address) (store_signed_integer, store_unsigned_integer) (store_typed_address): Use gdb_byte for byte buffer parameters. (push_bytes, push_word): Delete declaration. * valops.c (push_bytes, push_word): Delete function. * findvar.c (extract_signed_integer, extract_unsigned_integer) (extract_typed_address, store_signed_integer) (store_unsigned_integer): Update. Index: defs.h =================================================================== RCS file: /cvs/src/src/gdb/defs.h,v retrieving revision 1.185 diff -p -u -r1.185 defs.h --- defs.h 9 May 2005 17:20:18 -0000 1.185 +++ defs.h 19 May 2005 17:54:12 -0000 @@ -1042,27 +1042,25 @@ enum { MAX_REGISTER_SIZE = 16 }; /* In findvar.c. */ -extern LONGEST extract_signed_integer (const void *, int); +extern LONGEST extract_signed_integer (const gdb_byte *, int); -extern ULONGEST extract_unsigned_integer (const void *, int); +extern ULONGEST extract_unsigned_integer (const gdb_byte *, int); -extern int extract_long_unsigned_integer (const void *, int, LONGEST *); +extern int extract_long_unsigned_integer (const gdb_byte *, int, LONGEST *); -extern CORE_ADDR extract_typed_address (const void *buf, struct type *type); +extern CORE_ADDR extract_typed_address (const gdb_byte *buf, + struct type *type); -extern void store_signed_integer (void *, int, LONGEST); +extern void store_signed_integer (gdb_byte *, int, LONGEST); -extern void store_unsigned_integer (void *, int, ULONGEST); +extern void store_unsigned_integer (gdb_byte *, int, ULONGEST); -extern void store_typed_address (void *buf, struct type *type, CORE_ADDR addr); +extern void store_typed_address (gdb_byte *buf, struct type *type, + CORE_ADDR addr); /* From valops.c */ -extern CORE_ADDR push_bytes (CORE_ADDR, char *, int); - -extern CORE_ADDR push_word (CORE_ADDR, ULONGEST); - extern int watchdog; /* Hooks for alternate command interfaces. */ Index: findvar.c =================================================================== RCS file: /cvs/src/src/gdb/findvar.c,v retrieving revision 1.91 diff -p -u -r1.91 findvar.c --- findvar.c 14 May 2005 06:07:41 -0000 1.91 +++ findvar.c 19 May 2005 17:54:12 -0000 @@ -49,7 +49,7 @@ you lose #endif LONGEST -extract_signed_integer (const void *addr, int len) +extract_signed_integer (const gdb_byte *addr, int len) { LONGEST retval; const unsigned char *p; @@ -83,7 +83,7 @@ That operation is not available on integ } ULONGEST -extract_unsigned_integer (const void *addr, int len) +extract_unsigned_integer (const gdb_byte *addr, int len) { ULONGEST retval; const unsigned char *p; @@ -117,16 +117,18 @@ That operation is not available on integ function returns 1 and sets *PVAL. Otherwise it returns 0. */ int -extract_long_unsigned_integer (const void *addr, int orig_len, LONGEST *pval) +extract_long_unsigned_integer (const gdb_byte *addr, int orig_len, + LONGEST *pval) { - char *p, *first_addr; + const gdb_byte *p; + const gdb_byte *first_addr; int len; len = orig_len; if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG) { - for (p = (char *) addr; - len > (int) sizeof (LONGEST) && p < (char *) addr + orig_len; + for (p = addr; + len > (int) sizeof (LONGEST) && p < addr + orig_len; p++) { if (*p == 0) @@ -138,9 +140,9 @@ extract_long_unsigned_integer (const voi } else { - first_addr = (char *) addr; - for (p = (char *) addr + orig_len - 1; - len > (int) sizeof (LONGEST) && p >= (char *) addr; + first_addr = addr; + for (p = addr + orig_len - 1; + len > (int) sizeof (LONGEST) && p >= addr; p--) { if (*p == 0) @@ -164,7 +166,7 @@ extract_long_unsigned_integer (const voi /* Treat the bytes at BUF as a pointer of type TYPE, and return the address it represents. */ CORE_ADDR -extract_typed_address (const void *buf, struct type *type) +extract_typed_address (const gdb_byte *buf, struct type *type) { if (TYPE_CODE (type) != TYPE_CODE_PTR && TYPE_CODE (type) != TYPE_CODE_REF) @@ -177,11 +179,11 @@ extract_typed_address (const void *buf, void -store_signed_integer (void *addr, int len, LONGEST val) +store_signed_integer (gdb_byte *addr, int len, LONGEST val) { - unsigned char *p; - unsigned char *startaddr = (unsigned char *) addr; - unsigned char *endaddr = startaddr + len; + gdb_byte *p; + gdb_byte *startaddr = addr; + gdb_byte *endaddr = startaddr + len; /* Start at the least significant end of the integer, and work towards the most significant. */ @@ -204,7 +206,7 @@ store_signed_integer (void *addr, int le } void -store_unsigned_integer (void *addr, int len, ULONGEST val) +store_unsigned_integer (gdb_byte *addr, int len, ULONGEST val) { unsigned char *p; unsigned char *startaddr = (unsigned char *) addr; @@ -233,7 +235,7 @@ store_unsigned_integer (void *addr, int /* Store the address ADDR as a pointer of type TYPE at BUF, in target form. */ void -store_typed_address (void *buf, struct type *type, CORE_ADDR addr) +store_typed_address (gdb_byte *buf, struct type *type, CORE_ADDR addr) { if (TYPE_CODE (type) != TYPE_CODE_PTR && TYPE_CODE (type) != TYPE_CODE_REF) Index: valops.c =================================================================== RCS file: /cvs/src/src/gdb/valops.c,v retrieving revision 1.157 diff -p -u -r1.157 valops.c --- valops.c 9 May 2005 21:20:35 -0000 1.157 +++ valops.c 19 May 2005 17:54:12 -0000 @@ -933,54 +933,6 @@ value_ind (struct value *arg1) return 0; /* For lint -- never reached */ } -/* Pushing small parts of stack frames. */ - -/* Push one word (the size of object that a register holds). */ - -CORE_ADDR -push_word (CORE_ADDR sp, ULONGEST word) -{ - int len = DEPRECATED_REGISTER_SIZE; - char buffer[MAX_REGISTER_SIZE]; - - store_unsigned_integer (buffer, len, word); - if (INNER_THAN (1, 2)) - { - /* stack grows downward */ - sp -= len; - write_memory (sp, buffer, len); - } - else - { - /* stack grows upward */ - write_memory (sp, buffer, len); - sp += len; - } - - return sp; -} - -/* Push LEN bytes with data at BUFFER. */ - -CORE_ADDR -push_bytes (CORE_ADDR sp, char *buffer, int len) -{ - if (INNER_THAN (1, 2)) - { - /* stack grows downward */ - sp -= len; - write_memory (sp, buffer, len); - } - else - { - /* stack grows upward */ - write_memory (sp, buffer, len); - sp += len; - } - - return sp; -} - /* Create a value for an array by allocating space in the inferior, copying the data into that space, and then setting up an array value.
2005-05-19 19:55:53 +02:00
extract_typed_address (const gdb_byte *buf, struct type *type)
* gdbarch.sh (POINTER_TO_ADDRESS, ADDRESS_TO_POINTER): Two new functions which architectures can redefine, defaulting to generic_pointer_to_address and generic_address_to_pointer. * findvar.c (extract_typed_address, store_typed_address, generic_pointer_to_address, generic_address_to_pointer): New functions. (POINTER_TO_ADDRESS, ADDRESS_TO_POINTER): Provide default definitions. (extract_address, store_address): Doc fixes. * values.c (value_as_pointer): Doc fix. (value_from_pointer): New function. * defs.h (extract_typed_address, store_typed_address): New declarations. * inferior.h (generic_address_to_pointer, generic_pointer_to_address): New declarations. * value.h (value_from_pointer): New declaration. * ax-gdb.c (const_var_ref): Use value_from_pointer, not value_from_longest. * blockframe.c (generic_push_dummy_frame): Use read_pc and read_sp, not read_register. * c-valprint.c (c_val_print): Use extract_typed_address instead of extract_address to extract vtable entries and references. * cp-valprint.c (cp_print_value_fields): Use value_from_pointer instead of value_from_longest to extract the vtable's address. * eval.c (evaluate_subexp_standard): Use value_from_pointer instead of value_from_longest to compute `this', and for doing pointer-to-member dereferencing. * findvar.c (read_register): Use extract_unsigned_integer, not extract_address. (read_var_value): Use store_typed_address instead of store_address for building label values. (locate_var_value): Use value_from_pointer instead of value_from_longest. * hppa-tdep.c (find_stub_with_shl_get): Use value_from_pointer, instead of value_from_longest, to build arguments to __d_shl_get. * printcmd.c (set_next_address): Use value_from_pointer, not value_from_longest. (x_command): Use value_from_pointer, not value_from_longest. * tracepoint.c (set_traceframe_context): Use value_from_pointer, not value_from_longest. * valarith.c (value_add, value_sub): Use value_from_pointer, not value_from_longest. * valops.c (find_function_in_inferior, value_coerce_array, value_coerce_function, value_addr, hand_function_call): Same. * value.h (COERCE_REF): Use unpack_pointer, not unpack_long. * values.c (unpack_long): Use extract_typed_address to produce addresses from pointers and references, not extract_address. (value_from_longest): Use store_typed_address instead of store_address to produce pointer and reference values.
2000-04-14 20:43:41 +02:00
{
if (type->code () != TYPE_CODE_PTR && !TYPE_IS_REFERENCE (type))
internal_error (__FILE__, __LINE__,
2005-02-11 Andrew Cagney <cagney@gnu.org> Mark up error_no_arg, query, perror_with_name, complaint, and internal_error. * breakpoint.c, cp-abi.c, cp-namespace.c, cp-support.c: Update. * cris-tdep.c, dbxread.c, dictionary.c, dsrec.c: Update. * dummy-frame.c, dve3900-rom.c, dwarf2-frame.c, dwarf2expr.c: Update. * dwarf2read.c, dwarfread.c, elfread.c, event-loop.c: Update. * exceptions.c, exec.c, f-lang.c, findvar.c, fork-child.c: Update. * frame-unwind.c, frame.c, frv-linux-tdep.c, frv-tdep.c: Update. * gdb_assert.h, gdbarch.c, gdbtypes.c, gnu-nat.c: Update. * go32-nat.c, hppa-tdep.c, hppabsd-nat.c, hpread.c: Update. * i386-linux-nat.c, i386-nat.c, i386-tdep.c, i386bsd-nat.c: Update. * i386fbsd-nat.c, inf-ptrace.c, inf-ttrace.c, infcall.c: Update. * infcmd.c, inflow.c, infptrace.c, infrun.c, inftarg.c: Update. * interps.c, language.c, linespec.c, linux-nat.c: Update. * m32r-linux-nat.c, m68k-tdep.c, m68kbsd-nat.c: Update. * m68klinux-nat.c, m88kbsd-nat.c, macroexp.c, macroscope.c: Update. * macrotab.c, maint.c, mdebugread.c, memattr.c: Update. * mips-linux-tdep.c, mips-tdep.c, mips64obsd-nat.c: Update. * mipsnbsd-nat.c, mn10300-tdep.c, monitor.c, nto-procfs.c: Update. * objc-lang.c, objfiles.c, objfiles.h, ocd.c, osabi.c: Update. * parse.c, ppc-bdm.c, ppc-linux-nat.c, ppc-sysv-tdep.c: Update. * ppcnbsd-nat.c, ppcobsd-nat.c, printcmd.c, procfs.c: Update. * regcache.c, reggroups.c, remote-e7000.c, remote-mips.c: Update. * remote-rdp.c, remote-sds.c, remote-sim.c, remote-st.c: Update. * remote-utils.c, remote.c, rs6000-nat.c, rs6000-tdep.c: Update. * s390-nat.c, s390-tdep.c, sentinel-frame.c, serial.c: Update. * sh-tdep.c, sh3-rom.c, sh64-tdep.c, shnbsd-nat.c: Update. * solib-aix5.c, solib-svr4.c, solib.c, source.c: Update. * sparc-nat.c, stabsread.c, stack.c, symfile.c, symtab.c: Update. * symtab.h, target.c, tracepoint.c, ui-file.c, ui-out.c: Update. * utils.c, valops.c, valprint.c, vax-nat.c, vaxbsd-nat.c: Update. * win32-nat.c, xcoffread.c, xstormy16-tdep.c: Update. * cli/cli-cmds.c, cli/cli-logging.c, cli/cli-script.c: Update. * cli/cli-setshow.c, mi/mi-cmd-break.c, mi/mi-cmds.c: Update. * mi/mi-console.c, mi/mi-getopt.c, mi/mi-out.c: Update. * tui/tui-file.c, tui/tui-interp.c: Update.
2005-02-11 19:13:55 +01:00
_("extract_typed_address: "
"type is not a pointer or reference"));
* gdbarch.sh (POINTER_TO_ADDRESS, ADDRESS_TO_POINTER): Two new functions which architectures can redefine, defaulting to generic_pointer_to_address and generic_address_to_pointer. * findvar.c (extract_typed_address, store_typed_address, generic_pointer_to_address, generic_address_to_pointer): New functions. (POINTER_TO_ADDRESS, ADDRESS_TO_POINTER): Provide default definitions. (extract_address, store_address): Doc fixes. * values.c (value_as_pointer): Doc fix. (value_from_pointer): New function. * defs.h (extract_typed_address, store_typed_address): New declarations. * inferior.h (generic_address_to_pointer, generic_pointer_to_address): New declarations. * value.h (value_from_pointer): New declaration. * ax-gdb.c (const_var_ref): Use value_from_pointer, not value_from_longest. * blockframe.c (generic_push_dummy_frame): Use read_pc and read_sp, not read_register. * c-valprint.c (c_val_print): Use extract_typed_address instead of extract_address to extract vtable entries and references. * cp-valprint.c (cp_print_value_fields): Use value_from_pointer instead of value_from_longest to extract the vtable's address. * eval.c (evaluate_subexp_standard): Use value_from_pointer instead of value_from_longest to compute `this', and for doing pointer-to-member dereferencing. * findvar.c (read_register): Use extract_unsigned_integer, not extract_address. (read_var_value): Use store_typed_address instead of store_address for building label values. (locate_var_value): Use value_from_pointer instead of value_from_longest. * hppa-tdep.c (find_stub_with_shl_get): Use value_from_pointer, instead of value_from_longest, to build arguments to __d_shl_get. * printcmd.c (set_next_address): Use value_from_pointer, not value_from_longest. (x_command): Use value_from_pointer, not value_from_longest. * tracepoint.c (set_traceframe_context): Use value_from_pointer, not value_from_longest. * valarith.c (value_add, value_sub): Use value_from_pointer, not value_from_longest. * valops.c (find_function_in_inferior, value_coerce_array, value_coerce_function, value_addr, hand_function_call): Same. * value.h (COERCE_REF): Use unpack_pointer, not unpack_long. * values.c (unpack_long): Use extract_typed_address to produce addresses from pointers and references, not extract_address. (value_from_longest): Use store_typed_address instead of store_address to produce pointer and reference values.
2000-04-14 20:43:41 +02:00
* gdbtypes.c (make_pointer_type, make_reference_type, smash_to_memberptr_type, lookup_array_range_type, check_stub_method): Use type architecture instead of current_gdbarch. * gdbtypes.h (address_space_name_to_int, address_space_int_to_name): Add GDBARCH paramter. * gdbtypes.c (address_space_name_to_int, address_space_int_to_name): Add GDBARCH parameter. Use it instead of current_gdbarch. * c-typeprint.c (c_type_print_modifier): Update call. * parse.c (push_type_address_space): Likewise. * findvar.c (extract_typed_address, store_typed_address): Use type architecture instead of current_gdbarch. * value.c (value_as_address, unpack_field_as_long): Use type architecture instead of current_gdbarch. * doublest.c (floatformat_from_length): Add GDBARCH argument. Use it instead of current_gdbarch. (floatformat_from_type): Pass type architecture. * infcall.c (find_function_addr): Use type architecture instead of current_gdbarch. * valarith.c (value_bitstring_subscript, value_x_binop, value_neg, value_bit_index): Use type architecture instead of current_gdbarch. * valops.c (value_cast, value_slice): Likewise. * value.h (modify_field): Add TYPE argument. * value.c (modify_field): Add TYPE argument. Use type architecture instead of current_gdbarch. (set_internalvar_component): Likewise. * eval.c (evaluate_struct_tuple): Update call. * valops.c (value_assign): Likewise. * ada-lang.c (modify_general_field): Likewise. Add TYPE argument. (make_array_descriptor): Update calls. (move_bits): Add BITS_BIG_ENDIAN_P argument. Use it instead of current_gdbarch. (ada_value_assign, value_assign_to_component): Update calls. (decode_packed_array, ada_value_primitive_packed_val, ada_value_assign, value_assign_to_component): Use type arch instead of current_gdbarch. * printcmd.c (float_type_from_length): Remove GDBARCH argument, use type architecture instead. (print_scalar_formatted, printf_command): Update calls. Use type architecture instead of current_gdbarch. * valprint.c (val_print_type_code_int): Use type architecture instead of current_gdbarch. * varobj.c (value_get_print_value): Likewise. * python/python-prettyprint.c (print_string_repr): Add GDBARCH argument. Use it instead of current_gdbarch. (apply_val_pretty_printer): Update call. * ada-valprint.c (ada_val_print_1): Use type architecture instead of current_gdbarch. * c-valprint.c (print_function_pointer_address): Add GDBARCH argument. Use it instead of current_gdbarch. (c_val_print): Update calls passing type architecture. * f-valprint.c (f_val_print): Use type architecture instead of current_gdbarch. * jv-valprint (java_value_print): Likewise. * m2-valprint.c (print_function_pointer_address): Add GDBARCH argument. Use it instead of current_gdbarch. (print_unpacked_pointer): Update calls passing type architecture. * scm-valprint.c (scm_scmval_print): Use type architecture instead of current_gdbarch. * gnu-v3-abi.c (get_class_arch): Remove. (gnuv3_rtti_type): Use get_type_arch instead of get_class_arch. Remove special-case check for Java classes. (gnuv3_virtual_fn_field, gnuv3_baseclass_offset, gnuv3_print_method_ptr, gnuv3_method_ptr_size, gnuv3_make_method_ptr, gnuv3_method_ptr_to_value): Use get_type_arch instead of get_class_arch.
2009-07-02 14:57:14 +02:00
return gdbarch_pointer_to_address (get_type_arch (type), type, buf);
* gdbarch.sh (POINTER_TO_ADDRESS, ADDRESS_TO_POINTER): Two new functions which architectures can redefine, defaulting to generic_pointer_to_address and generic_address_to_pointer. * findvar.c (extract_typed_address, store_typed_address, generic_pointer_to_address, generic_address_to_pointer): New functions. (POINTER_TO_ADDRESS, ADDRESS_TO_POINTER): Provide default definitions. (extract_address, store_address): Doc fixes. * values.c (value_as_pointer): Doc fix. (value_from_pointer): New function. * defs.h (extract_typed_address, store_typed_address): New declarations. * inferior.h (generic_address_to_pointer, generic_pointer_to_address): New declarations. * value.h (value_from_pointer): New declaration. * ax-gdb.c (const_var_ref): Use value_from_pointer, not value_from_longest. * blockframe.c (generic_push_dummy_frame): Use read_pc and read_sp, not read_register. * c-valprint.c (c_val_print): Use extract_typed_address instead of extract_address to extract vtable entries and references. * cp-valprint.c (cp_print_value_fields): Use value_from_pointer instead of value_from_longest to extract the vtable's address. * eval.c (evaluate_subexp_standard): Use value_from_pointer instead of value_from_longest to compute `this', and for doing pointer-to-member dereferencing. * findvar.c (read_register): Use extract_unsigned_integer, not extract_address. (read_var_value): Use store_typed_address instead of store_address for building label values. (locate_var_value): Use value_from_pointer instead of value_from_longest. * hppa-tdep.c (find_stub_with_shl_get): Use value_from_pointer, instead of value_from_longest, to build arguments to __d_shl_get. * printcmd.c (set_next_address): Use value_from_pointer, not value_from_longest. (x_command): Use value_from_pointer, not value_from_longest. * tracepoint.c (set_traceframe_context): Use value_from_pointer, not value_from_longest. * valarith.c (value_add, value_sub): Use value_from_pointer, not value_from_longest. * valops.c (find_function_in_inferior, value_coerce_array, value_coerce_function, value_addr, hand_function_call): Same. * value.h (COERCE_REF): Use unpack_pointer, not unpack_long. * values.c (unpack_long): Use extract_typed_address to produce addresses from pointers and references, not extract_address. (value_from_longest): Use store_typed_address instead of store_address to produce pointer and reference values.
2000-04-14 20:43:41 +02:00
}
/* All 'store' functions accept a host-format integer and store a
target-format integer at ADDR which is LEN bytes long. */
extract/store integer function template This patch converts functions extract_{unsigned,signed}_integer to a function template extract_integer, which has two instantiations. It also does the similar changes to store__{unsigned,signed}_integer, regcache::raw_read_{unsigned,signed}, regcache::raw_write_{unsigned,signed}, regcache::cooked_read_{unsigned,signed}, regcache::cooked_write_{unsigned,signed}. This patch was posted here https://sourceware.org/ml/gdb-patches/2017-05/msg00492.html but the problem was fixed in a different way. However, I think the patch is still useful to shorten the code. gdb: 2017-06-16 Alan Hayward <alan.hayward@arm.com> Pedro Alves <palves@redhat.com> Yao Qi <yao.qi@linaro.org> * defs.h (RequireLongest): New. (extract_integer): Declare function template. (extract_signed_integer): Remove the declaration, but define it static inline. (extract_unsigned_integer): Likewise. (store_integer): Declare function template. (store_signed_integer): Remove the declaration, but define it static inline. (store_unsigned_integer): Likewise. * findvar.c (extract_integer): New function template. (extract_signed_integer): Remove. (extract_unsigned_integer): Remove. (extract_integer<LONGEST>, extract_integer<ULONGEST>): Explicit instantiations. (store_integer): New function template. (store_signed_integer): Remove. (store_unsigned_integer): Remove. (store_integer): Explicit instantiations. * regcache.c (regcache_raw_read_signed): Update. (regcache::raw_read): New function. (regcache::raw_read_signed): Remove. (regcache::raw_read_unsigned): Remove. (regcache_raw_read_unsigned): Update. (regcache_raw_write_unsigned): Update. (regcache::raw_write_signed): Remove. (regcache::raw_write): New function. (regcache_cooked_read_signed): Update. (regcache::raw_write_unsigned): Remove. (regcache::cooked_read_signed): Remove. (regcache_cooked_read_unsigned): Update. (regcache::cooked_read_unsigned): Remove. (regcache_cooked_write_signed): Update. (regcache_cooked_write_unsigned): Update. * regcache.h (regcache) <raw_read_signed>: Remove. <raw_write_signed, raw_read_unsigned, raw_write_unsigned>: Remove. <raw_read, raw_write>: New. <cooked_read_signed, cooked_write_signed>: Remove. <cooked_write_unsigned, cooked_read_unsigned>: Remove. <cooked_read, cooked_write>: New. * sh64-tdep.c (sh64_pseudo_register_read): Update. (sh64_pseudo_register_write): Update.
2017-06-16 16:38:42 +02:00
template<typename T, typename>
void
extract/store integer function template This patch converts functions extract_{unsigned,signed}_integer to a function template extract_integer, which has two instantiations. It also does the similar changes to store__{unsigned,signed}_integer, regcache::raw_read_{unsigned,signed}, regcache::raw_write_{unsigned,signed}, regcache::cooked_read_{unsigned,signed}, regcache::cooked_write_{unsigned,signed}. This patch was posted here https://sourceware.org/ml/gdb-patches/2017-05/msg00492.html but the problem was fixed in a different way. However, I think the patch is still useful to shorten the code. gdb: 2017-06-16 Alan Hayward <alan.hayward@arm.com> Pedro Alves <palves@redhat.com> Yao Qi <yao.qi@linaro.org> * defs.h (RequireLongest): New. (extract_integer): Declare function template. (extract_signed_integer): Remove the declaration, but define it static inline. (extract_unsigned_integer): Likewise. (store_integer): Declare function template. (store_signed_integer): Remove the declaration, but define it static inline. (store_unsigned_integer): Likewise. * findvar.c (extract_integer): New function template. (extract_signed_integer): Remove. (extract_unsigned_integer): Remove. (extract_integer<LONGEST>, extract_integer<ULONGEST>): Explicit instantiations. (store_integer): New function template. (store_signed_integer): Remove. (store_unsigned_integer): Remove. (store_integer): Explicit instantiations. * regcache.c (regcache_raw_read_signed): Update. (regcache::raw_read): New function. (regcache::raw_read_signed): Remove. (regcache::raw_read_unsigned): Remove. (regcache_raw_read_unsigned): Update. (regcache_raw_write_unsigned): Update. (regcache::raw_write_signed): Remove. (regcache::raw_write): New function. (regcache_cooked_read_signed): Update. (regcache::raw_write_unsigned): Remove. (regcache::cooked_read_signed): Remove. (regcache_cooked_read_unsigned): Update. (regcache::cooked_read_unsigned): Remove. (regcache_cooked_write_signed): Update. (regcache_cooked_write_unsigned): Update. * regcache.h (regcache) <raw_read_signed>: Remove. <raw_write_signed, raw_read_unsigned, raw_write_unsigned>: Remove. <raw_read, raw_write>: New. <cooked_read_signed, cooked_write_signed>: Remove. <cooked_write_unsigned, cooked_read_unsigned>: Remove. <cooked_read, cooked_write>: New. * sh64-tdep.c (sh64_pseudo_register_read): Update. (sh64_pseudo_register_write): Update.
2017-06-16 16:38:42 +02:00
store_integer (gdb_byte *addr, int len, enum bfd_endian byte_order,
T val)
{
2005-05-19 Andrew Cagney <cagney@gnu.org> * defs.h (extract_signed_integer, extract_unsigned_integer) (extract_long_unsigned_integer, extract_typed_address) (store_signed_integer, store_unsigned_integer) (store_typed_address): Use gdb_byte for byte buffer parameters. (push_bytes, push_word): Delete declaration. * valops.c (push_bytes, push_word): Delete function. * findvar.c (extract_signed_integer, extract_unsigned_integer) (extract_typed_address, store_signed_integer) (store_unsigned_integer): Update. Index: defs.h =================================================================== RCS file: /cvs/src/src/gdb/defs.h,v retrieving revision 1.185 diff -p -u -r1.185 defs.h --- defs.h 9 May 2005 17:20:18 -0000 1.185 +++ defs.h 19 May 2005 17:54:12 -0000 @@ -1042,27 +1042,25 @@ enum { MAX_REGISTER_SIZE = 16 }; /* In findvar.c. */ -extern LONGEST extract_signed_integer (const void *, int); +extern LONGEST extract_signed_integer (const gdb_byte *, int); -extern ULONGEST extract_unsigned_integer (const void *, int); +extern ULONGEST extract_unsigned_integer (const gdb_byte *, int); -extern int extract_long_unsigned_integer (const void *, int, LONGEST *); +extern int extract_long_unsigned_integer (const gdb_byte *, int, LONGEST *); -extern CORE_ADDR extract_typed_address (const void *buf, struct type *type); +extern CORE_ADDR extract_typed_address (const gdb_byte *buf, + struct type *type); -extern void store_signed_integer (void *, int, LONGEST); +extern void store_signed_integer (gdb_byte *, int, LONGEST); -extern void store_unsigned_integer (void *, int, ULONGEST); +extern void store_unsigned_integer (gdb_byte *, int, ULONGEST); -extern void store_typed_address (void *buf, struct type *type, CORE_ADDR addr); +extern void store_typed_address (gdb_byte *buf, struct type *type, + CORE_ADDR addr); /* From valops.c */ -extern CORE_ADDR push_bytes (CORE_ADDR, char *, int); - -extern CORE_ADDR push_word (CORE_ADDR, ULONGEST); - extern int watchdog; /* Hooks for alternate command interfaces. */ Index: findvar.c =================================================================== RCS file: /cvs/src/src/gdb/findvar.c,v retrieving revision 1.91 diff -p -u -r1.91 findvar.c --- findvar.c 14 May 2005 06:07:41 -0000 1.91 +++ findvar.c 19 May 2005 17:54:12 -0000 @@ -49,7 +49,7 @@ you lose #endif LONGEST -extract_signed_integer (const void *addr, int len) +extract_signed_integer (const gdb_byte *addr, int len) { LONGEST retval; const unsigned char *p; @@ -83,7 +83,7 @@ That operation is not available on integ } ULONGEST -extract_unsigned_integer (const void *addr, int len) +extract_unsigned_integer (const gdb_byte *addr, int len) { ULONGEST retval; const unsigned char *p; @@ -117,16 +117,18 @@ That operation is not available on integ function returns 1 and sets *PVAL. Otherwise it returns 0. */ int -extract_long_unsigned_integer (const void *addr, int orig_len, LONGEST *pval) +extract_long_unsigned_integer (const gdb_byte *addr, int orig_len, + LONGEST *pval) { - char *p, *first_addr; + const gdb_byte *p; + const gdb_byte *first_addr; int len; len = orig_len; if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG) { - for (p = (char *) addr; - len > (int) sizeof (LONGEST) && p < (char *) addr + orig_len; + for (p = addr; + len > (int) sizeof (LONGEST) && p < addr + orig_len; p++) { if (*p == 0) @@ -138,9 +140,9 @@ extract_long_unsigned_integer (const voi } else { - first_addr = (char *) addr; - for (p = (char *) addr + orig_len - 1; - len > (int) sizeof (LONGEST) && p >= (char *) addr; + first_addr = addr; + for (p = addr + orig_len - 1; + len > (int) sizeof (LONGEST) && p >= addr; p--) { if (*p == 0) @@ -164,7 +166,7 @@ extract_long_unsigned_integer (const voi /* Treat the bytes at BUF as a pointer of type TYPE, and return the address it represents. */ CORE_ADDR -extract_typed_address (const void *buf, struct type *type) +extract_typed_address (const gdb_byte *buf, struct type *type) { if (TYPE_CODE (type) != TYPE_CODE_PTR && TYPE_CODE (type) != TYPE_CODE_REF) @@ -177,11 +179,11 @@ extract_typed_address (const void *buf, void -store_signed_integer (void *addr, int len, LONGEST val) +store_signed_integer (gdb_byte *addr, int len, LONGEST val) { - unsigned char *p; - unsigned char *startaddr = (unsigned char *) addr; - unsigned char *endaddr = startaddr + len; + gdb_byte *p; + gdb_byte *startaddr = addr; + gdb_byte *endaddr = startaddr + len; /* Start at the least significant end of the integer, and work towards the most significant. */ @@ -204,7 +206,7 @@ store_signed_integer (void *addr, int le } void -store_unsigned_integer (void *addr, int len, ULONGEST val) +store_unsigned_integer (gdb_byte *addr, int len, ULONGEST val) { unsigned char *p; unsigned char *startaddr = (unsigned char *) addr; @@ -233,7 +235,7 @@ store_unsigned_integer (void *addr, int /* Store the address ADDR as a pointer of type TYPE at BUF, in target form. */ void -store_typed_address (void *buf, struct type *type, CORE_ADDR addr) +store_typed_address (gdb_byte *buf, struct type *type, CORE_ADDR addr) { if (TYPE_CODE (type) != TYPE_CODE_PTR && TYPE_CODE (type) != TYPE_CODE_REF) Index: valops.c =================================================================== RCS file: /cvs/src/src/gdb/valops.c,v retrieving revision 1.157 diff -p -u -r1.157 valops.c --- valops.c 9 May 2005 21:20:35 -0000 1.157 +++ valops.c 19 May 2005 17:54:12 -0000 @@ -933,54 +933,6 @@ value_ind (struct value *arg1) return 0; /* For lint -- never reached */ } -/* Pushing small parts of stack frames. */ - -/* Push one word (the size of object that a register holds). */ - -CORE_ADDR -push_word (CORE_ADDR sp, ULONGEST word) -{ - int len = DEPRECATED_REGISTER_SIZE; - char buffer[MAX_REGISTER_SIZE]; - - store_unsigned_integer (buffer, len, word); - if (INNER_THAN (1, 2)) - { - /* stack grows downward */ - sp -= len; - write_memory (sp, buffer, len); - } - else - { - /* stack grows upward */ - write_memory (sp, buffer, len); - sp += len; - } - - return sp; -} - -/* Push LEN bytes with data at BUFFER. */ - -CORE_ADDR -push_bytes (CORE_ADDR sp, char *buffer, int len) -{ - if (INNER_THAN (1, 2)) - { - /* stack grows downward */ - sp -= len; - write_memory (sp, buffer, len); - } - else - { - /* stack grows upward */ - write_memory (sp, buffer, len); - sp += len; - } - - return sp; -} - /* Create a value for an array by allocating space in the inferior, copying the data into that space, and then setting up an array value.
2005-05-19 19:55:53 +02:00
gdb_byte *p;
gdb_byte *startaddr = addr;
gdb_byte *endaddr = startaddr + len;
/* Start at the least significant end of the integer, and work towards
the most significant. */
* defs.h (extract_signed_integer, extract_unsigned_integer, extract_long_unsigned_integer, store_signed_integer, store_unsigned_integer): Add BYTE_ORDER parameter. * findvar.c (extract_signed_integer, extract_unsigned_integer, extract_long_unsigned_integer, store_signed_integer, store_unsigned_integer): Add BYTE_ORDER parameter. Use it instead of current_gdbarch. * gdbcore.h (read_memory_integer, safe_read_memory_integer, read_memory_unsigned_integer, write_memory_signed_integer, write_memory_unsigned_integer): Add BYTE_ORDER parameter. * corefile.c (struct captured_read_memory_integer_arguments): Add BYTE_ORDER member. (safe_read_memory_integer): Add BYTE_ORDER parameter. Store it into struct captured_read_memory_integer_arguments. (do_captured_read_memory_integer): Pass it to read_memory_integer. (read_memory_integer): Add BYTE_ORDER parameter. Pass it to extract_signed_integer. (read_memory_unsigned_integer): Add BYTE_ORDER parameter. Pass it to extract_unsigned_integer. (write_memory_signed_integer): Add BYTE_ORDER parameter. Pass it to store_signed_integer. (write_memory_unsigned_integer): Add BYTE_ORDER parameter. Pass it to store_unsigned_integer. * target.h (get_target_memory_unsigned): Add BYTE_ORDER parameter. * target.c (get_target_memory_unsigned): Add BYTE_ORDER parameter. Pass it to extract_unsigned_integer. Update calls to extract_signed_integer, extract_unsigned_integer, extract_long_unsigned_integer, store_signed_integer, store_unsigned_integer, read_memory_integer, read_memory_unsigned_integer, safe_read_memory_integer, write_memory_signed_integer, write_memory_unsigned_integer, and get_target_memory_unsigned to pass byte order: * ada-lang.c (ada_value_binop): Update. * ada-valprint.c (char_at): Update. * alpha-osf1-tdep.c (alpha_osf1_sigcontext_addr): Update. * alpha-tdep.c (alpha_lds, alpha_sts, alpha_push_dummy_call, alpha_extract_return_value, alpha_read_insn, alpha_get_longjmp_target): Update. * amd64-linux-tdep.c (amd64_linux_sigcontext_addr): Update. * amd64obsd-tdep.c (amd64obsd_supply_uthread, amd64obsd_collect_uthread, amd64obsd_trapframe_cache): Update. * amd64-tdep.c (amd64_push_dummy_call, amd64_analyze_prologue, amd64_frame_cache, amd64_sigtramp_frame_cache, fixup_riprel, amd64_displaced_step_fixup): Update. * arm-linux-tdep.c (arm_linux_sigreturn_init, arm_linux_rt_sigreturn_init, arm_linux_supply_gregset): Update. * arm-tdep.c (thumb_analyze_prologue, arm_skip_prologue, arm_scan_prologue, arm_push_dummy_call, thumb_get_next_pc, arm_get_next_pc, arm_extract_return_value, arm_store_return_value, arm_return_value): Update. * arm-wince-tdep.c (arm_pe_skip_trampoline_code): Update. * auxv.c (default_auxv_parse): Update. * avr-tdep.c (avr_address_to_pointer, avr_pointer_to_address, avr_scan_prologue, avr_extract_return_value, avr_frame_prev_register, avr_push_dummy_call): Update. * bsd-uthread.c (bsd_uthread_check_magic, bsd_uthread_lookup_offset, bsd_uthread_wait, bsd_uthread_thread_alive, bsd_uthread_extra_thread_info): Update. * c-lang.c (c_printstr, print_wchar): Update. * cp-valprint.c (cp_print_class_member): Update. * cris-tdep.c (cris_sigcontext_addr, cris_sigtramp_frame_unwind_cache, cris_push_dummy_call, cris_scan_prologue, cris_store_return_value, cris_extract_return_value, find_step_target, dip_prefix, sixteen_bit_offset_branch_op, none_reg_mode_jump_op, move_mem_to_reg_movem_op, get_data_from_address): Update. * dwarf2expr.c (dwarf2_read_address, execute_stack_op): Update. * dwarf2-frame.c (execute_cfa_program): Update. * dwarf2loc.c (find_location_expression): Update. * dwarf2read.c (dwarf2_const_value): Update. * expprint.c (print_subexp_standard): Update. * findvar.c (unsigned_pointer_to_address, signed_pointer_to_address, unsigned_address_to_pointer, address_to_signed_pointer, read_var_value): Update. * frame.c (frame_unwind_register_signed, frame_unwind_register_unsigned, get_frame_memory_signed, get_frame_memory_unsigned): Update. * frame-unwind.c (frame_unwind_got_constant): Update. * frv-linux-tdep.c (frv_linux_pc_in_sigtramp, frv_linux_sigcontext_reg_addr, frv_linux_sigtramp_frame_cache): Update. * frv-tdep.c (frv_analyze_prologue, frv_skip_main_prologue, frv_extract_return_value, find_func_descr, frv_convert_from_func_ptr_addr, frv_push_dummy_call): Update. * f-valprint.c (f_val_print): Update. * gnu-v3-abi.c (gnuv3_decode_method_ptr, gnuv3_make_method_ptr): Update. * h8300-tdep.c (h8300_is_argument_spill, h8300_analyze_prologue, h8300_push_dummy_call, h8300_extract_return_value, h8300h_extract_return_value, h8300_store_return_value, h8300h_store_return_value): Update. * hppabsd-tdep.c (hppabsd_find_global_pointer): Update. * hppa-hpux-nat.c (hppa_hpux_fetch_register, hppa_hpux_store_register): Update. * hppa-hpux-tdep.c (hppa32_hpux_in_solib_call_trampoline, hppa64_hpux_in_solib_call_trampoline, hppa_hpux_in_solib_return_trampoline, hppa_hpux_skip_trampoline_code, hppa_hpux_sigtramp_frame_unwind_cache, hppa_hpux_sigtramp_unwind_sniffer, hppa32_hpux_find_global_pointer, hppa64_hpux_find_global_pointer, hppa_hpux_search_pattern, hppa32_hpux_search_dummy_call_sequence, hppa64_hpux_search_dummy_call_sequence, hppa_hpux_supply_save_state, hppa_hpux_unwind_adjust_stub): Update. * hppa-linux-tdep.c (insns_match_pattern, hppa_linux_find_global_pointer): Update. * hppa-tdep.c (hppa_in_function_epilogue_p, hppa32_push_dummy_call, hppa64_convert_code_addr_to_fptr, hppa64_push_dummy_call, skip_prologue_hard_way, hppa_frame_cache, hppa_fallback_frame_cache, hppa_pseudo_register_read, hppa_frame_prev_register_helper, hppa_match_insns): Update. * hpux-thread.c (hpux_thread_fetch_registers): Update. * i386-tdep.c (i386bsd_sigcontext_addr): Update. * i386-cygwin-tdep.c (core_process_module_section): Update. * i386-darwin-nat.c (i386_darwin_sstep_at_sigreturn, amd64_darwin_sstep_at_sigreturn): Update. * i386-darwin-tdep.c (i386_darwin_sigcontext_addr, amd64_darwin_sigcontext_addr): Likewise. * i386-linux-nat.c (i386_linux_sigcontext_addr): Update. * i386nbsd-tdep.c (i386nbsd_sigtramp_cache_init): Update. * i386-nto-tdep.c (i386nto_sigcontext_addr): Update. * i386obsd-nat.c (i386obsd_supply_pcb): Update. * i386obsd-tdep.c (i386obsd_supply_uthread, i386obsd_collect_uthread, i386obsd_trapframe_cache): Update. * i386-tdep.c (i386_displaced_step_fixup, i386_follow_jump, i386_analyze_frame_setup, i386_analyze_prologue, i386_skip_main_prologue, i386_frame_cache, i386_sigtramp_frame_cache, i386_get_longjmp_target, i386_push_dummy_call, i386_pe_skip_trampoline_code, i386_svr4_sigcontext_addr, i386_fetch_pointer_argument): Update. * i387-tdep.c (i387_supply_fsave): Update. * ia64-linux-tdep.c (ia64_linux_sigcontext_register_address): Update. * ia64-tdep.c (ia64_pseudo_register_read, ia64_pseudo_register_write, examine_prologue, ia64_frame_cache, ia64_frame_prev_register, ia64_sigtramp_frame_cache, ia64_sigtramp_frame_prev_register, ia64_access_reg, ia64_access_rse_reg, ia64_libunwind_frame_this_id, ia64_libunwind_frame_prev_register, ia64_libunwind_sigtramp_frame_this_id, ia64_libunwind_sigtramp_frame_prev_register, ia64_find_global_pointer, find_extant_func_descr, find_func_descr, ia64_convert_from_func_ptr_addr, ia64_push_dummy_call, ia64_dummy_id, ia64_unwind_pc): Update. * iq2000-tdep.c (iq2000_pointer_to_address, iq2000_address_to_pointer, iq2000_scan_prologue, iq2000_extract_return_value, iq2000_push_dummy_call): Update. * irix5nat.c (fill_gregset): Update. * jv-lang.c (evaluate_subexp_java): Update. * jv-valprint.c (java_value_print): Update. * lm32-tdep.c (lm32_analyze_prologue, lm32_push_dummy_call, lm32_extract_return_value, lm32_store_return_value): Update. * m32c-tdep.c (m32c_push_dummy_call, m32c_return_value, m32c_skip_trampoline_code, m32c_m16c_address_to_pointer, m32c_m16c_pointer_to_address): Update. * m32r-tdep.c (m32r_store_return_value, decode_prologue, m32r_skip_prologue, m32r_push_dummy_call, m32r_extract_return_value): Update. * m68hc11-tdep.c (m68hc11_pseudo_register_read, m68hc11_pseudo_register_write, m68hc11_analyze_instruction, m68hc11_push_dummy_call): Update. * m68linux-tdep.c (m68k_linux_pc_in_sigtramp, m68k_linux_get_sigtramp_info, m68k_linux_sigtramp_frame_cache): Update. * m68k-tdep.c (m68k_push_dummy_call, m68k_analyze_frame_setup, m68k_analyze_register_saves, m68k_analyze_prologue, m68k_frame_cache, m68k_get_longjmp_target): Update. * m88k-tdep.c (m88k_fetch_instruction): Update. * mep-tdep.c (mep_pseudo_cr32_read, mep_pseudo_csr_write, mep_pseudo_cr32_write, mep_get_insn, mep_push_dummy_call): Update. * mi/mi-main.c (mi_cmd_data_write_memory): Update. * mips-linux-tdep.c (mips_linux_get_longjmp_target, supply_32bit_reg, mips64_linux_get_longjmp_target, mips64_fill_gregset, mips64_fill_fpregset, mips_linux_in_dynsym_stub): Update. * mipsnbdsd-tdep.c (mipsnbsd_get_longjmp_target): Update. * mips-tdep.c (mips_fetch_instruction, fetch_mips_16, mips_eabi_push_dummy_call, mips_n32n64_push_dummy_call, mips_o32_push_dummy_call, mips_o64_push_dummy_call, mips_single_step_through_delay, mips_skip_pic_trampoline_code, mips_integer_to_address): Update. * mn10300-tdep.c (mn10300_analyze_prologue, mn10300_push_dummy_call): Update. * monitor.c (monitor_supply_register, monitor_write_memory, monitor_read_memory_single): Update. * moxie-tdep.c (moxie_store_return_value, moxie_extract_return_value, moxie_analyze_prologue): Update. * mt-tdep.c (mt_return_value, mt_skip_prologue, mt_select_coprocessor, mt_pseudo_register_read, mt_pseudo_register_write, mt_registers_info, mt_push_dummy_call): Update. * objc-lang.c (read_objc_method, read_objc_methlist_nmethods, read_objc_methlist_method, read_objc_object, read_objc_super, read_objc_class, find_implementation_from_class): Update. * ppc64-linux-tdep.c (ppc64_desc_entry_point, ppc64_linux_convert_from_func_ptr_addr, ppc_linux_sigtramp_cache): Update. * ppcobsd-tdep.c (ppcobsd_sigtramp_frame_sniffer, ppcobsd_sigtramp_frame_cache): Update. * ppc-sysv-tdep.c (ppc_sysv_abi_push_dummy_call, do_ppc_sysv_return_value, ppc64_sysv_abi_push_dummy_call, ppc64_sysv_abi_return_value): Update. * ppc-linux-nat.c (ppc_linux_auxv_parse): Update. * procfs.c (procfs_auxv_parse): Update. * p-valprint.c (pascal_val_print): Update. * regcache.c (regcache_raw_read_signed, regcache_raw_read_unsigned, regcache_raw_write_signed, regcache_raw_write_unsigned, regcache_cooked_read_signed, regcache_cooked_read_unsigned, regcache_cooked_write_signed, regcache_cooked_write_unsigned): Update. * remote-m32r-sdi.c (m32r_fetch_register): Update. * remote-mips.c (mips_wait, mips_fetch_registers, mips_xfer_memory): Update. * rs6000-aix-tdep.c (rs6000_push_dummy_call, rs6000_return_value, rs6000_convert_from_func_ptr_addr, branch_dest, rs6000_software_single_step): Update. * rs6000-tdep.c (rs6000_in_function_epilogue_p, ppc_displaced_step_fixup, ppc_deal_with_atomic_sequence, bl_to_blrl_insn_p, rs6000_fetch_instruction, skip_prologue, rs6000_skip_main_prologue, rs6000_skip_trampoline_code, rs6000_frame_cache): Update. * s390-tdep.c (s390_pseudo_register_read, s390_pseudo_register_write, s390x_pseudo_register_read, s390x_pseudo_register_write, s390_load, s390_backchain_frame_unwind_cache, s390_sigtramp_frame_unwind_cache, extend_simple_arg, s390_push_dummy_call, s390_return_value): Update. * scm-exp.c (scm_lreadr): Update. * scm-lang.c (scm_get_field, scm_unpack): Update. * scm-valprint.c (scm_val_print): Update. * score-tdep.c (score_breakpoint_from_pc, score_push_dummy_call, score_fetch_inst): Update. * sh64-tdep.c (look_for_args_moves, sh64_skip_prologue_hard_way, sh64_analyze_prologue, sh64_push_dummy_call, sh64_extract_return_value, sh64_pseudo_register_read, sh64_pseudo_register_write, sh64_frame_prev_register): Update: * sh-tdep.c (sh_analyze_prologue, sh_push_dummy_call_fpu, sh_push_dummy_call_nofpu, sh_extract_return_value_nofpu, sh_store_return_value_nofpu, sh_in_function_epilogue_p): Update. * solib-darwin.c (darwin_load_image_infos): Update. * solib-frv.c (fetch_loadmap, lm_base, frv_current_sos, enable_break2, find_canonical_descriptor_in_load_object): Update. * solib-irix.c (extract_mips_address, fetch_lm_info, irix_current_sos, irix_open_symbol_file_object): Update. * solib-som.c (som_solib_create_inferior_hook, link_map_start, som_current_sos, som_open_symbol_file_object): Update. * solib-sunos.c (SOLIB_EXTRACT_ADDRESS, LM_ADDR, LM_NEXT, LM_NAME): Update. * solib-svr4.c (read_program_header, scan_dyntag_auxv, solib_svr4_r_ldsomap): Update. * sparc64-linux-tdep.c (sparc64_linux_step_trap): Update. * sparc64obsd-tdep.c (sparc64obsd_supply_uthread, sparc64obsd_collect_uthread): Update. * sparc64-tdep.c (sparc64_pseudo_register_read, sparc64_pseudo_register_write, sparc64_supply_gregset, sparc64_collect_gregset): Update. * sparc-linux-tdep.c (sparc32_linux_step_trap): Update. * sparcobsd-tdep.c (sparc32obsd_supply_uthread, sparc32obsd_collect_uthread): Update. * sparc-tdep.c (sparc_fetch_wcookie, sparc32_push_dummy_code, sparc32_store_arguments, sparc32_return_value, sparc_supply_rwindow, sparc_collect_rwindow): Update. * spu-linux-nat.c (parse_spufs_run): Update. * spu-tdep.c (spu_pseudo_register_read_spu, spu_pseudo_register_write_spu, spu_pointer_to_address, spu_analyze_prologue, spu_in_function_epilogue_p, spu_frame_unwind_cache, spu_push_dummy_call, spu_software_single_step, spu_get_longjmp_target, spu_get_overlay_table, spu_overlay_update_osect, info_spu_signal_command, info_spu_mailbox_list, info_spu_dma_cmdlist, info_spu_dma_command, info_spu_proxydma_command): Update. * stack.c (print_frame_nameless_args, frame_info): Update. * symfile.c (read_target_long_array, simple_read_overlay_table, simple_read_overlay_region_table): Update. * target.c (debug_print_register): Update. * tramp-frame.c (tramp_frame_start): Update. * v850-tdep.c (v850_analyze_prologue, v850_push_dummy_call, v850_extract_return_value, v850_store_return_value, * valarith.c (value_binop, value_bit_index): Update. * valops.c (value_cast): Update. * valprint.c (val_print_type_code_int, val_print_string, read_string): Update. * value.c (unpack_long, unpack_double, unpack_field_as_long, modify_field, pack_long): Update. * vax-tdep.c (vax_store_arguments, vax_push_dummy_call, vax_skip_prologue): Update. * xstormy16-tdep.c (xstormy16_push_dummy_call, xstormy16_analyze_prologue, xstormy16_in_function_epilogue_p, xstormy16_resolve_jmp_table_entry, xstormy16_find_jmp_table_entry, xstormy16_pointer_to_address, xstormy16_address_to_pointer): Update. * xtensa-tdep.c (extract_call_winsize, xtensa_pseudo_register_read, xtensa_pseudo_register_write, xtensa_frame_cache, xtensa_push_dummy_call, call0_track_op, call0_frame_cache): Update. * dfp.h (decimal_to_string, decimal_from_string, decimal_from_integral, decimal_from_floating, decimal_to_doublest, decimal_is_zero): Add BYTE_ORDER parameter. (decimal_binop): Add BYTE_ORDER_X, BYTE_ORDER_Y, and BYTE_ORDER_RESULT parameters. (decimal_compare): Add BYTE_ORDER_X and BYTE_ORDER_Y parameters. (decimal_convert): Add BYTE_ORDER_FROM and BYTE_ORDER_TO parameters. * dfp.c (match_endianness): Add BYTE_ORDER parameter. Use it instead of current_gdbarch. (decimal_to_string, decimal_from_integral, decimal_from_floating, decimal_to_doublest, decimal_is_zero): Add BYTE_ORDER parameter. Pass it to match_endianness. (decimal_binop): Add BYTE_ORDER_X, BYTE_ORDER_Y, and BYTE_ORDER_RESULT parameters. Pass them to match_endianness. (decimal_compare): Add BYTE_ORDER_X and BYTE_ORDER_Y parameters. Pass them to match_endianness. (decimal_convert): Add BYTE_ORDER_FROM and BYTE_ORDER_TO parameters. Pass them to match_endianness. * valarith.c (value_args_as_decimal): Add BYTE_ORDER_X and BYTE_ORDER_Y output parameters. (value_binop): Update call to value_args_as_decimal. Update calls to decimal_to_string, decimal_from_string, decimal_from_integral, decimal_from_floating, decimal_to_doublest, decimal_is_zero, decimal_binop, decimal_compare and decimal_convert to pass/receive byte order: * c-exp.y (parse_number): Update. * printcmd.c (printf_command): Update. * valarith.c (value_args_as_decimal, value_binop, value_logical_not, value_equal, value_less): Update. * valops.c (value_cast, value_one): Update. * valprint.c (print_decimal_floating): Update. * value.c (unpack_long, unpack_double): Update. * python/python-value.c (valpy_nonzero): Update. * ada-valprint.c (char_at): Add BYTE_ORDER parameter. (printstr): Update calls to char_at. (ada_val_print_array): Likewise. * valprint.c (read_string): Add BYTE_ORDER parameter. (val_print_string): Update call to read_string. * c-lang.c (c_get_string): Likewise. * charset.h (target_wide_charset): Add BYTE_ORDER parameter. * charset.c (target_wide_charset): Add BYTE_ORDER parameter. Use it instead of current_gdbarch. * printcmd.c (printf_command): Update calls to target_wide_charset. * c-lang.c (charset_for_string_type): Add BYTE_ORDER parameter. Pass to target_wide_charset. Use it instead of current_gdbarch. (classify_type): Add BYTE_ORDER parameter. Pass to charset_for_string_type. Allow NULL encoding pointer. (print_wchar): Add BYTE_ORDER parameter. (c_emit_char): Update calls to classify_type and print_wchar. (c_printchar, c_printstr): Likewise. * gdbarch.sh (in_solib_return_trampoline): Convert to type "m". * gdbarch.c, gdbarch.h: Regenerate. * arch-utils.h (generic_in_solib_return_trampoline): Add GDBARCH parameter. * arch-utils.c (generic_in_solib_return_trampoline): Likewise. * hppa-hpux-tdep.c (hppa_hpux_in_solib_return_trampoline): Likewise. * rs6000-tdep.c (rs6000_in_solib_return_trampoline): Likewise. (rs6000_skip_trampoline_code): Update call. * alpha-tdep.h (struct gdbarch_tdep): Add GDBARCH parameter to dynamic_sigtramp_offset and pc_in_sigtramp callbacks. (alpha_read_insn): Add GDBARCH parameter. * alpha-tdep.c (alpha_lds, alpha_sts): Add GDBARCH parameter. (alpha_register_to_value): Pass architecture to alpha_sts. (alpha_extract_return_value): Likewise. (alpha_value_to_register): Pass architecture to alpha_lds. (alpha_store_return_value): Likewise. (alpha_read_insn): Add GDBARCH parameter. (alpha_skip_prologue): Pass architecture to alpha_read_insn. (alpha_heuristic_proc_start): Likewise. (alpha_heuristic_frame_unwind_cache): Likewise. (alpha_next_pc): Likewise. (alpha_sigtramp_frame_this_id): Pass architecture to tdep->dynamic_sigtramp_offset callback. (alpha_sigtramp_frame_sniffer): Pass architecture to tdep->pc_in_sigtramp callback. * alphafbsd-tdep.c (alphafbsd_pc_in_sigtramp): Add GDBARCH parameter. (alphafbsd_sigtramp_offset): Likewise. * alpha-linux-tdep.c (alpha_linux_sigtramp_offset_1): Add GDBARCH parameter. Pass to alpha_read_insn. (alpha_linux_sigtramp_offset): Add GDBARCH parameter. Pass to alpha_linux_sigtramp_offset_1. (alpha_linux_pc_in_sigtramp): Add GDBARCH parameter. Pass to alpha_linux_sigtramp_offset. (alpha_linux_sigcontext_addr): Pass architecture to alpha_read_insn and alpha_linux_sigtramp_offset. * alphanbsd-tdep.c (alphanbsd_sigtramp_offset): Add GDBARCH parameter. (alphanbsd_pc_in_sigtramp): Add GDBARCH parameter. Pass to alphanbsd_sigtramp_offset. * alphaobsd-tdep.c (alphaobsd_sigtramp_offset): Add GDBARCH parameter. (alphaobsd_pc_in_sigtramp): Add GDBARCH parameter. Pass to alpha_read_insn. (alphaobsd_sigcontext_addr): Pass architecture to alphaobsd_sigtramp_offset. * alpha-osf1-tdep.c (alpha_osf1_pc_in_sigtramp): Add GDBARCH parameter. * amd64-tdep.c (amd64_analyze_prologue): Add GDBARCH parameter. (amd64_skip_prologue): Pass architecture to amd64_analyze_prologue. (amd64_frame_cache): Likewise. * arm-tdep.c (SWAP_SHORT, SWAP_INT): Remove. (thumb_analyze_prologue, arm_skip_prologue, arm_scan_prologue, thumb_get_next_pc, arm_get_next_pc): Do not use SWAP_ macros. * arm-wince-tdep.c: Include "frame.h". * avr-tdep.c (EXTRACT_INSN): Remove. (avr_scan_prologue): Add GDBARCH argument, inline EXTRACT_INSN. (avr_skip_prologue): Pass architecture to avr_scan_prologue. (avr_frame_unwind_cache): Likewise. * cris-tdep.c (struct instruction_environment): Add BYTE_ORDER member. (find_step_target): Initialize it. (get_data_from_address): Add BYTE_ORDER parameter. (bdap_prefix): Pass byte order to get_data_from_address. (handle_prefix_assign_mode_for_aritm_op): Likewise. (three_operand_add_sub_cmp_and_or_op): Likewise. (handle_inc_and_index_mode_for_aritm_op): Likewise. * frv-linux-tdep.c (frv_linux_pc_in_sigtramp): Add GDBARCH parameter. (frv_linux_sigcontext_reg_addr): Pass architecture to frv_linux_pc_in_sigtramp. (frv_linux_sigtramp_frame_sniffer): Likewise. * h8300-tdep.c (h8300_is_argument_spill): Add GDBARCH parameter. (h8300_analyze_prologue): Add GDBARCH parameter. Pass to h8300_is_argument_spill. (h8300_frame_cache, h8300_skip_prologue): Pass architecture to h8300_analyze_prologue. * hppa-tdep.h (struct gdbarch_tdep): Add GDBARCH parameter to in_solib_call_trampoline callback. (hppa_in_solib_call_trampoline): Add GDBARCH parameter. * hppa-tdep.c (hppa64_convert_code_addr_to_fptr): Add GDBARCH parameter. (hppa64_push_dummy_call): Pass architecture to hppa64_convert_code_addr_to_fptr. (hppa_match_insns): Add GDBARCH parameter. (hppa_match_insns_relaxed): Add GDBARCH parameter. Pass to hppa_match_insns. (hppa_skip_trampoline_code): Pass architecture to hppa_match_insns. (hppa_in_solib_call_trampoline): Add GDBARCH parameter. Pass to hppa_match_insns_relaxed. (hppa_stub_unwind_sniffer): Pass architecture to tdep->in_solib_call_trampoline callback. * hppa-hpux-tdep.c (hppa_hpux_search_pattern): Add GDBARCH parameter. (hppa32_hpux_search_dummy_call_sequence): Pass architecture to hppa_hpux_search_pattern. * hppa-linux-tdep.c (insns_match_pattern): Add GDBARCH parameter. (hppa_linux_sigtramp_find_sigcontext): Add GDBARCH parameter. Pass to insns_match_pattern. (hppa_linux_sigtramp_frame_unwind_cache): Pass architecture to hppa_linux_sigtramp_find_sigcontext. (hppa_linux_sigtramp_frame_sniffer): Likewise. (hppa32_hpux_in_solib_call_trampoline): Add GDBARCH parameter. (hppa64_hpux_in_solib_call_trampoline): Likewise. * i386-tdep.c (i386_follow_jump): Add GDBARCH parameter. (i386_analyze_frame_setup): Add GDBARCH parameter. (i386_analyze_prologue): Add GDBARCH parameter. Pass to i386_follow_jump and i386_analyze_frame_setup. (i386_skip_prologue): Pass architecture to i386_analyze_prologue and i386_follow_jump. (i386_frame_cache): Pass architecture to i386_analyze_prologue. (i386_pe_skip_trampoline_code): Add FRAME parameter. * i386-tdep.h (i386_pe_skip_trampoline_code): Add FRAME parameter. * i386-cygwin-tdep.c (i386_cygwin_skip_trampoline_code): Pass frame to i386_pe_skip_trampoline_code. * ia64-tdep.h (struct gdbarch_tdep): Add GDBARCH parameter to sigcontext_register_address callback. * ia64-tdep.c (ia64_find_global_pointer): Add GDBARCH parameter. (ia64_find_unwind_table): Pass architecture to ia64_find_global_pointer. (find_extant_func_descr): Add GDBARCH parameter. (find_func_descr): Pass architecture to find_extant_func_descr and ia64_find_global_pointer. (ia64_sigtramp_frame_init_saved_regs): Pass architecture to tdep->sigcontext_register_address callback. * ia64-linux-tdep.c (ia64_linux_sigcontext_register_address): Add GDBARCH parameter. * iq2000-tdep.c (iq2000_scan_prologue): Add GDBARCH parameter. (iq2000_frame_cache): Pass architecture to iq2000_scan_prologue. * lm32-tdep.c (lm32_analyze_prologue): Add GDBARCH parameter. (lm32_skip_prologue, lm32_frame_cache): Pass architecture to lm32_analyze_prologue. * m32r-tdep.c (decode_prologue): Add GDBARCH parameter. (m32r_skip_prologue): Pass architecture to decode_prologue. * m68hc11-tdep.c (m68hc11_analyze_instruction): Add GDBARCH parameter. (m68hc11_scan_prologue): Pass architecture to m68hc11_analyze_instruction. * m68k-tdep.c (m68k_analyze_frame_setup): Add GDBARCH parameter. (m68k_analyze_prologue): Pass architecture to m68k_analyze_frame_setup. * m88k-tdep.c (m88k_fetch_instruction): Add BYTE_ORDER parameter. (m88k_analyze_prologue): Add GDBARCH parameter. Pass byte order to m88k_fetch_instruction. (m88k_skip_prologue): Pass architecture to m88k_analyze_prologue. (m88k_frame_cache): Likewise. * mep-tdep.c (mep_get_insn): Add GDBARCH parameter. (mep_analyze_prologue): Pass architecture to mep_get_insn. * mips-tdep.c (mips_fetch_instruction): Add GDBARCH parameter. (mips32_next_pc): Pass architecture to mips_fetch_instruction. (deal_with_atomic_sequence): Likewise. (unpack_mips16): Add GDBARCH parameter, pass to mips_fetch_instruction. (mips16_scan_prologue): Likewise. (mips32_scan_prologue): Likewise. (mips16_in_function_epilogue_p): Likewise. (mips32_in_function_epilogue_p): Likewise. (mips_about_to_return): Likewise. (mips_insn16_frame_cache): Pass architecture to mips16_scan_prologue. (mips_insn32_frame_cache): Pass architecture to mips32_scan_prologue. (mips_skip_prologue): Pass architecture to mips16_scan_prologue and mips32_scan_prologue. (mips_in_function_epilogue_p): Pass architecture to mips16_in_function_epilogue_p and mips32_in_function_epilogue_p. (heuristic_proc_start): Pass architecture to mips_fetch_instruction and mips_about_to_return. (mips_skip_mips16_trampoline_code): Pass architecture to mips_fetch_instruction. (fetch_mips_16): Add GDBARCH parameter. (mips16_next_pc): Pass architecture to fetch_mips_16. (extended_mips16_next_pc): Pass architecture to unpack_mips16 and fetch_mips_16. * objc-lang.c (read_objc_method, read_objc_methlist_nmethods, read_objc_methlist_method, read_objc_object, read_objc_super, read_objc_class): Add GDBARCH parameter. (find_implementation_from_class): Add GDBARCH parameter, pass to read_objc_class, read_objc_methlist_nmethods, and read_objc_methlist_method. (find_implementation): Add GDBARCH parameter, pass to read_objc_object and find_implementation_from_class. (resolve_msgsend, resolve_msgsend_stret): Pass architecture to find_implementation. (resolve_msgsend_super, resolve_msgsend_super_stret): Pass architecture to read_objc_super and find_implementation_from_class. * ppc64-linux-tdep.c (ppc64_desc_entry_point): Add GDBARCH parameter. (ppc64_standard_linkage1_target, ppc64_standard_linkage2_target, ppc64_standard_linkage3_target): Pass architecture to ppc64_desc_entry_point. * rs6000-tdep.c (bl_to_blrl_insn_p): Add BYTE_ORDER parameter. (skip_prologue): Pass byte order to bl_to_blrl_insn_p. (rs6000_fetch_instruction): Add GDBARCH parameter. (rs6000_skip_stack_check): Add GDBARCH parameter, pass to rs6000_fetch_instruction. (skip_prologue): Pass architecture to rs6000_fetch_instruction. * remote-mips.c (mips_store_word): Return old_contents as host integer value instead of target bytes. * s390-tdep.c (struct s390_prologue_data): Add BYTE_ORDER member. (s390_analyze_prologue): Initialize it. (extend_simple_arg): Add GDBARCH parameter. (s390_push_dummy_call): Pass architecture to extend_simple_arg. * scm-lang.c (scm_get_field): Add BYTE_ORDER parameter. * scm-lang.h (scm_get_field): Add BYTE_ORDER parameter. (SCM_CAR, SCM_CDR): Pass SCM_BYTE_ORDER to scm_get_field. * scm-valprint.c (scm_scmval_print): Likewise. (scm_scmlist_print, scm_ipruk, scm_scmval_print): Define SCM_BYTE_ORDER. * sh64-tdep.c (look_for_args_moves): Add GDBARCH parameter. (sh64_skip_prologue_hard_way): Add GDBARCH parameter, pass to look_for_args_moves. (sh64_skip_prologue): Pass architecture to sh64_skip_prologue_hard_way. * sh-tdep.c (sh_analyze_prologue): Add GDBARCH parameter. (sh_skip_prologue): Pass architecture to sh_analyze_prologue. (sh_frame_cache): Likewise. * solib-irix.c (extract_mips_address): Add GDBARCH parameter. (fetch_lm_info, irix_current_sos, irix_open_symbol_file_object): Pass architecture to extract_mips_address. * sparc-tdep.h (sparc_fetch_wcookie): Add GDBARCH parameter. * sparc-tdep.c (sparc_fetch_wcookie): Add GDBARCH parameter. (sparc_supply_rwindow, sparc_collect_rwindow): Pass architecture to sparc_fetch_wcookie. (sparc32_frame_prev_register): Likewise. * sparc64-tdep.c (sparc64_frame_prev_register): Likewise. * sparc32nbsd-tdep.c (sparc32nbsd_sigcontext_saved_regs): Likewise. * sparc64nbsd-tdep.c (sparc64nbsd_sigcontext_saved_regs): Likewise. * spu-tdep.c (spu_analyze_prologue): Add GDBARCH parameter. (spu_skip_prologue): Pass architecture to spu_analyze_prologue. (spu_virtual_frame_pointer): Likewise. (spu_frame_unwind_cache): Likewise. (info_spu_mailbox_list): Add BYTE_ORER parameter. (info_spu_mailbox_command): Pass byte order to info_spu_mailbox_list. (info_spu_dma_cmdlist): Add BYTE_ORER parameter. (info_spu_dma_command, info_spu_proxydma_command): Pass byte order to info_spu_dma_cmdlist. * symfile.c (read_target_long_array): Add GDBARCH parameter. (simple_read_overlay_table, simple_read_overlay_region_table, simple_overlay_update_1): Pass architecture to read_target_long_array. * v850-tdep.c (v850_analyze_prologue): Add GDBARCH parameter. (v850_frame_cache): Pass architecture to v850_analyze_prologue. * xstormy16-tdep.c (xstormy16_analyze_prologue): Add GDBARCH parameter. (xstormy16_skip_prologue, xstormy16_frame_cache): Pass architecture to xstormy16_analyze_prologue. (xstormy16_resolve_jmp_table_entry): Add GDBARCH parameter. (xstormy16_find_jmp_table_entry): Likewise. (xstormy16_skip_trampoline_code): Pass architecture to xstormy16_resolve_jmp_table_entry. (xstormy16_pointer_to_address): Likewise. (xstormy16_address_to_pointer): Pass architecture to xstormy16_find_jmp_table_entry. * xtensa-tdep.c (call0_track_op): Add GDBARCH parameter. (call0_analyze_prologue): Add GDBARCH parameter, pass to call0_track_op. (call0_frame_cache): Pass architecture to call0_analyze_prologue. (xtensa_skip_prologue): Likewise.
2009-07-02 19:25:59 +02:00
if (byte_order == BFD_ENDIAN_BIG)
{
for (p = endaddr - 1; p >= startaddr; --p)
{
*p = val & 0xff;
val >>= 8;
}
}
else
{
for (p = startaddr; p < endaddr; ++p)
{
*p = val & 0xff;
val >>= 8;
}
}
}
extract/store integer function template This patch converts functions extract_{unsigned,signed}_integer to a function template extract_integer, which has two instantiations. It also does the similar changes to store__{unsigned,signed}_integer, regcache::raw_read_{unsigned,signed}, regcache::raw_write_{unsigned,signed}, regcache::cooked_read_{unsigned,signed}, regcache::cooked_write_{unsigned,signed}. This patch was posted here https://sourceware.org/ml/gdb-patches/2017-05/msg00492.html but the problem was fixed in a different way. However, I think the patch is still useful to shorten the code. gdb: 2017-06-16 Alan Hayward <alan.hayward@arm.com> Pedro Alves <palves@redhat.com> Yao Qi <yao.qi@linaro.org> * defs.h (RequireLongest): New. (extract_integer): Declare function template. (extract_signed_integer): Remove the declaration, but define it static inline. (extract_unsigned_integer): Likewise. (store_integer): Declare function template. (store_signed_integer): Remove the declaration, but define it static inline. (store_unsigned_integer): Likewise. * findvar.c (extract_integer): New function template. (extract_signed_integer): Remove. (extract_unsigned_integer): Remove. (extract_integer<LONGEST>, extract_integer<ULONGEST>): Explicit instantiations. (store_integer): New function template. (store_signed_integer): Remove. (store_unsigned_integer): Remove. (store_integer): Explicit instantiations. * regcache.c (regcache_raw_read_signed): Update. (regcache::raw_read): New function. (regcache::raw_read_signed): Remove. (regcache::raw_read_unsigned): Remove. (regcache_raw_read_unsigned): Update. (regcache_raw_write_unsigned): Update. (regcache::raw_write_signed): Remove. (regcache::raw_write): New function. (regcache_cooked_read_signed): Update. (regcache::raw_write_unsigned): Remove. (regcache::cooked_read_signed): Remove. (regcache_cooked_read_unsigned): Update. (regcache::cooked_read_unsigned): Remove. (regcache_cooked_write_signed): Update. (regcache_cooked_write_unsigned): Update. * regcache.h (regcache) <raw_read_signed>: Remove. <raw_write_signed, raw_read_unsigned, raw_write_unsigned>: Remove. <raw_read, raw_write>: New. <cooked_read_signed, cooked_write_signed>: Remove. <cooked_write_unsigned, cooked_read_unsigned>: Remove. <cooked_read, cooked_write>: New. * sh64-tdep.c (sh64_pseudo_register_read): Update. (sh64_pseudo_register_write): Update.
2017-06-16 16:38:42 +02:00
/* Explicit instantiations. */
template void store_integer (gdb_byte *addr, int len,
enum bfd_endian byte_order,
LONGEST val);
extract/store integer function template This patch converts functions extract_{unsigned,signed}_integer to a function template extract_integer, which has two instantiations. It also does the similar changes to store__{unsigned,signed}_integer, regcache::raw_read_{unsigned,signed}, regcache::raw_write_{unsigned,signed}, regcache::cooked_read_{unsigned,signed}, regcache::cooked_write_{unsigned,signed}. This patch was posted here https://sourceware.org/ml/gdb-patches/2017-05/msg00492.html but the problem was fixed in a different way. However, I think the patch is still useful to shorten the code. gdb: 2017-06-16 Alan Hayward <alan.hayward@arm.com> Pedro Alves <palves@redhat.com> Yao Qi <yao.qi@linaro.org> * defs.h (RequireLongest): New. (extract_integer): Declare function template. (extract_signed_integer): Remove the declaration, but define it static inline. (extract_unsigned_integer): Likewise. (store_integer): Declare function template. (store_signed_integer): Remove the declaration, but define it static inline. (store_unsigned_integer): Likewise. * findvar.c (extract_integer): New function template. (extract_signed_integer): Remove. (extract_unsigned_integer): Remove. (extract_integer<LONGEST>, extract_integer<ULONGEST>): Explicit instantiations. (store_integer): New function template. (store_signed_integer): Remove. (store_unsigned_integer): Remove. (store_integer): Explicit instantiations. * regcache.c (regcache_raw_read_signed): Update. (regcache::raw_read): New function. (regcache::raw_read_signed): Remove. (regcache::raw_read_unsigned): Remove. (regcache_raw_read_unsigned): Update. (regcache_raw_write_unsigned): Update. (regcache::raw_write_signed): Remove. (regcache::raw_write): New function. (regcache_cooked_read_signed): Update. (regcache::raw_write_unsigned): Remove. (regcache::cooked_read_signed): Remove. (regcache_cooked_read_unsigned): Update. (regcache::cooked_read_unsigned): Remove. (regcache_cooked_write_signed): Update. (regcache_cooked_write_unsigned): Update. * regcache.h (regcache) <raw_read_signed>: Remove. <raw_write_signed, raw_read_unsigned, raw_write_unsigned>: Remove. <raw_read, raw_write>: New. <cooked_read_signed, cooked_write_signed>: Remove. <cooked_write_unsigned, cooked_read_unsigned>: Remove. <cooked_read, cooked_write>: New. * sh64-tdep.c (sh64_pseudo_register_read): Update. (sh64_pseudo_register_write): Update.
2017-06-16 16:38:42 +02:00
template void store_integer (gdb_byte *addr, int len,
enum bfd_endian byte_order,
ULONGEST val);
* gdbarch.sh (POINTER_TO_ADDRESS, ADDRESS_TO_POINTER): Two new functions which architectures can redefine, defaulting to generic_pointer_to_address and generic_address_to_pointer. * findvar.c (extract_typed_address, store_typed_address, generic_pointer_to_address, generic_address_to_pointer): New functions. (POINTER_TO_ADDRESS, ADDRESS_TO_POINTER): Provide default definitions. (extract_address, store_address): Doc fixes. * values.c (value_as_pointer): Doc fix. (value_from_pointer): New function. * defs.h (extract_typed_address, store_typed_address): New declarations. * inferior.h (generic_address_to_pointer, generic_pointer_to_address): New declarations. * value.h (value_from_pointer): New declaration. * ax-gdb.c (const_var_ref): Use value_from_pointer, not value_from_longest. * blockframe.c (generic_push_dummy_frame): Use read_pc and read_sp, not read_register. * c-valprint.c (c_val_print): Use extract_typed_address instead of extract_address to extract vtable entries and references. * cp-valprint.c (cp_print_value_fields): Use value_from_pointer instead of value_from_longest to extract the vtable's address. * eval.c (evaluate_subexp_standard): Use value_from_pointer instead of value_from_longest to compute `this', and for doing pointer-to-member dereferencing. * findvar.c (read_register): Use extract_unsigned_integer, not extract_address. (read_var_value): Use store_typed_address instead of store_address for building label values. (locate_var_value): Use value_from_pointer instead of value_from_longest. * hppa-tdep.c (find_stub_with_shl_get): Use value_from_pointer, instead of value_from_longest, to build arguments to __d_shl_get. * printcmd.c (set_next_address): Use value_from_pointer, not value_from_longest. (x_command): Use value_from_pointer, not value_from_longest. * tracepoint.c (set_traceframe_context): Use value_from_pointer, not value_from_longest. * valarith.c (value_add, value_sub): Use value_from_pointer, not value_from_longest. * valops.c (find_function_in_inferior, value_coerce_array, value_coerce_function, value_addr, hand_function_call): Same. * value.h (COERCE_REF): Use unpack_pointer, not unpack_long. * values.c (unpack_long): Use extract_typed_address to produce addresses from pointers and references, not extract_address. (value_from_longest): Use store_typed_address instead of store_address to produce pointer and reference values.
2000-04-14 20:43:41 +02:00
/* Store the address ADDR as a pointer of type TYPE at BUF, in target
form. */
void
2005-05-19 Andrew Cagney <cagney@gnu.org> * defs.h (extract_signed_integer, extract_unsigned_integer) (extract_long_unsigned_integer, extract_typed_address) (store_signed_integer, store_unsigned_integer) (store_typed_address): Use gdb_byte for byte buffer parameters. (push_bytes, push_word): Delete declaration. * valops.c (push_bytes, push_word): Delete function. * findvar.c (extract_signed_integer, extract_unsigned_integer) (extract_typed_address, store_signed_integer) (store_unsigned_integer): Update. Index: defs.h =================================================================== RCS file: /cvs/src/src/gdb/defs.h,v retrieving revision 1.185 diff -p -u -r1.185 defs.h --- defs.h 9 May 2005 17:20:18 -0000 1.185 +++ defs.h 19 May 2005 17:54:12 -0000 @@ -1042,27 +1042,25 @@ enum { MAX_REGISTER_SIZE = 16 }; /* In findvar.c. */ -extern LONGEST extract_signed_integer (const void *, int); +extern LONGEST extract_signed_integer (const gdb_byte *, int); -extern ULONGEST extract_unsigned_integer (const void *, int); +extern ULONGEST extract_unsigned_integer (const gdb_byte *, int); -extern int extract_long_unsigned_integer (const void *, int, LONGEST *); +extern int extract_long_unsigned_integer (const gdb_byte *, int, LONGEST *); -extern CORE_ADDR extract_typed_address (const void *buf, struct type *type); +extern CORE_ADDR extract_typed_address (const gdb_byte *buf, + struct type *type); -extern void store_signed_integer (void *, int, LONGEST); +extern void store_signed_integer (gdb_byte *, int, LONGEST); -extern void store_unsigned_integer (void *, int, ULONGEST); +extern void store_unsigned_integer (gdb_byte *, int, ULONGEST); -extern void store_typed_address (void *buf, struct type *type, CORE_ADDR addr); +extern void store_typed_address (gdb_byte *buf, struct type *type, + CORE_ADDR addr); /* From valops.c */ -extern CORE_ADDR push_bytes (CORE_ADDR, char *, int); - -extern CORE_ADDR push_word (CORE_ADDR, ULONGEST); - extern int watchdog; /* Hooks for alternate command interfaces. */ Index: findvar.c =================================================================== RCS file: /cvs/src/src/gdb/findvar.c,v retrieving revision 1.91 diff -p -u -r1.91 findvar.c --- findvar.c 14 May 2005 06:07:41 -0000 1.91 +++ findvar.c 19 May 2005 17:54:12 -0000 @@ -49,7 +49,7 @@ you lose #endif LONGEST -extract_signed_integer (const void *addr, int len) +extract_signed_integer (const gdb_byte *addr, int len) { LONGEST retval; const unsigned char *p; @@ -83,7 +83,7 @@ That operation is not available on integ } ULONGEST -extract_unsigned_integer (const void *addr, int len) +extract_unsigned_integer (const gdb_byte *addr, int len) { ULONGEST retval; const unsigned char *p; @@ -117,16 +117,18 @@ That operation is not available on integ function returns 1 and sets *PVAL. Otherwise it returns 0. */ int -extract_long_unsigned_integer (const void *addr, int orig_len, LONGEST *pval) +extract_long_unsigned_integer (const gdb_byte *addr, int orig_len, + LONGEST *pval) { - char *p, *first_addr; + const gdb_byte *p; + const gdb_byte *first_addr; int len; len = orig_len; if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG) { - for (p = (char *) addr; - len > (int) sizeof (LONGEST) && p < (char *) addr + orig_len; + for (p = addr; + len > (int) sizeof (LONGEST) && p < addr + orig_len; p++) { if (*p == 0) @@ -138,9 +140,9 @@ extract_long_unsigned_integer (const voi } else { - first_addr = (char *) addr; - for (p = (char *) addr + orig_len - 1; - len > (int) sizeof (LONGEST) && p >= (char *) addr; + first_addr = addr; + for (p = addr + orig_len - 1; + len > (int) sizeof (LONGEST) && p >= addr; p--) { if (*p == 0) @@ -164,7 +166,7 @@ extract_long_unsigned_integer (const voi /* Treat the bytes at BUF as a pointer of type TYPE, and return the address it represents. */ CORE_ADDR -extract_typed_address (const void *buf, struct type *type) +extract_typed_address (const gdb_byte *buf, struct type *type) { if (TYPE_CODE (type) != TYPE_CODE_PTR && TYPE_CODE (type) != TYPE_CODE_REF) @@ -177,11 +179,11 @@ extract_typed_address (const void *buf, void -store_signed_integer (void *addr, int len, LONGEST val) +store_signed_integer (gdb_byte *addr, int len, LONGEST val) { - unsigned char *p; - unsigned char *startaddr = (unsigned char *) addr; - unsigned char *endaddr = startaddr + len; + gdb_byte *p; + gdb_byte *startaddr = addr; + gdb_byte *endaddr = startaddr + len; /* Start at the least significant end of the integer, and work towards the most significant. */ @@ -204,7 +206,7 @@ store_signed_integer (void *addr, int le } void -store_unsigned_integer (void *addr, int len, ULONGEST val) +store_unsigned_integer (gdb_byte *addr, int len, ULONGEST val) { unsigned char *p; unsigned char *startaddr = (unsigned char *) addr; @@ -233,7 +235,7 @@ store_unsigned_integer (void *addr, int /* Store the address ADDR as a pointer of type TYPE at BUF, in target form. */ void -store_typed_address (void *buf, struct type *type, CORE_ADDR addr) +store_typed_address (gdb_byte *buf, struct type *type, CORE_ADDR addr) { if (TYPE_CODE (type) != TYPE_CODE_PTR && TYPE_CODE (type) != TYPE_CODE_REF) Index: valops.c =================================================================== RCS file: /cvs/src/src/gdb/valops.c,v retrieving revision 1.157 diff -p -u -r1.157 valops.c --- valops.c 9 May 2005 21:20:35 -0000 1.157 +++ valops.c 19 May 2005 17:54:12 -0000 @@ -933,54 +933,6 @@ value_ind (struct value *arg1) return 0; /* For lint -- never reached */ } -/* Pushing small parts of stack frames. */ - -/* Push one word (the size of object that a register holds). */ - -CORE_ADDR -push_word (CORE_ADDR sp, ULONGEST word) -{ - int len = DEPRECATED_REGISTER_SIZE; - char buffer[MAX_REGISTER_SIZE]; - - store_unsigned_integer (buffer, len, word); - if (INNER_THAN (1, 2)) - { - /* stack grows downward */ - sp -= len; - write_memory (sp, buffer, len); - } - else - { - /* stack grows upward */ - write_memory (sp, buffer, len); - sp += len; - } - - return sp; -} - -/* Push LEN bytes with data at BUFFER. */ - -CORE_ADDR -push_bytes (CORE_ADDR sp, char *buffer, int len) -{ - if (INNER_THAN (1, 2)) - { - /* stack grows downward */ - sp -= len; - write_memory (sp, buffer, len); - } - else - { - /* stack grows upward */ - write_memory (sp, buffer, len); - sp += len; - } - - return sp; -} - /* Create a value for an array by allocating space in the inferior, copying the data into that space, and then setting up an array value.
2005-05-19 19:55:53 +02:00
store_typed_address (gdb_byte *buf, struct type *type, CORE_ADDR addr)
* gdbarch.sh (POINTER_TO_ADDRESS, ADDRESS_TO_POINTER): Two new functions which architectures can redefine, defaulting to generic_pointer_to_address and generic_address_to_pointer. * findvar.c (extract_typed_address, store_typed_address, generic_pointer_to_address, generic_address_to_pointer): New functions. (POINTER_TO_ADDRESS, ADDRESS_TO_POINTER): Provide default definitions. (extract_address, store_address): Doc fixes. * values.c (value_as_pointer): Doc fix. (value_from_pointer): New function. * defs.h (extract_typed_address, store_typed_address): New declarations. * inferior.h (generic_address_to_pointer, generic_pointer_to_address): New declarations. * value.h (value_from_pointer): New declaration. * ax-gdb.c (const_var_ref): Use value_from_pointer, not value_from_longest. * blockframe.c (generic_push_dummy_frame): Use read_pc and read_sp, not read_register. * c-valprint.c (c_val_print): Use extract_typed_address instead of extract_address to extract vtable entries and references. * cp-valprint.c (cp_print_value_fields): Use value_from_pointer instead of value_from_longest to extract the vtable's address. * eval.c (evaluate_subexp_standard): Use value_from_pointer instead of value_from_longest to compute `this', and for doing pointer-to-member dereferencing. * findvar.c (read_register): Use extract_unsigned_integer, not extract_address. (read_var_value): Use store_typed_address instead of store_address for building label values. (locate_var_value): Use value_from_pointer instead of value_from_longest. * hppa-tdep.c (find_stub_with_shl_get): Use value_from_pointer, instead of value_from_longest, to build arguments to __d_shl_get. * printcmd.c (set_next_address): Use value_from_pointer, not value_from_longest. (x_command): Use value_from_pointer, not value_from_longest. * tracepoint.c (set_traceframe_context): Use value_from_pointer, not value_from_longest. * valarith.c (value_add, value_sub): Use value_from_pointer, not value_from_longest. * valops.c (find_function_in_inferior, value_coerce_array, value_coerce_function, value_addr, hand_function_call): Same. * value.h (COERCE_REF): Use unpack_pointer, not unpack_long. * values.c (unpack_long): Use extract_typed_address to produce addresses from pointers and references, not extract_address. (value_from_longest): Use store_typed_address instead of store_address to produce pointer and reference values.
2000-04-14 20:43:41 +02:00
{
if (type->code () != TYPE_CODE_PTR && !TYPE_IS_REFERENCE (type))
internal_error (__FILE__, __LINE__,
2005-02-11 Andrew Cagney <cagney@gnu.org> Mark up error_no_arg, query, perror_with_name, complaint, and internal_error. * breakpoint.c, cp-abi.c, cp-namespace.c, cp-support.c: Update. * cris-tdep.c, dbxread.c, dictionary.c, dsrec.c: Update. * dummy-frame.c, dve3900-rom.c, dwarf2-frame.c, dwarf2expr.c: Update. * dwarf2read.c, dwarfread.c, elfread.c, event-loop.c: Update. * exceptions.c, exec.c, f-lang.c, findvar.c, fork-child.c: Update. * frame-unwind.c, frame.c, frv-linux-tdep.c, frv-tdep.c: Update. * gdb_assert.h, gdbarch.c, gdbtypes.c, gnu-nat.c: Update. * go32-nat.c, hppa-tdep.c, hppabsd-nat.c, hpread.c: Update. * i386-linux-nat.c, i386-nat.c, i386-tdep.c, i386bsd-nat.c: Update. * i386fbsd-nat.c, inf-ptrace.c, inf-ttrace.c, infcall.c: Update. * infcmd.c, inflow.c, infptrace.c, infrun.c, inftarg.c: Update. * interps.c, language.c, linespec.c, linux-nat.c: Update. * m32r-linux-nat.c, m68k-tdep.c, m68kbsd-nat.c: Update. * m68klinux-nat.c, m88kbsd-nat.c, macroexp.c, macroscope.c: Update. * macrotab.c, maint.c, mdebugread.c, memattr.c: Update. * mips-linux-tdep.c, mips-tdep.c, mips64obsd-nat.c: Update. * mipsnbsd-nat.c, mn10300-tdep.c, monitor.c, nto-procfs.c: Update. * objc-lang.c, objfiles.c, objfiles.h, ocd.c, osabi.c: Update. * parse.c, ppc-bdm.c, ppc-linux-nat.c, ppc-sysv-tdep.c: Update. * ppcnbsd-nat.c, ppcobsd-nat.c, printcmd.c, procfs.c: Update. * regcache.c, reggroups.c, remote-e7000.c, remote-mips.c: Update. * remote-rdp.c, remote-sds.c, remote-sim.c, remote-st.c: Update. * remote-utils.c, remote.c, rs6000-nat.c, rs6000-tdep.c: Update. * s390-nat.c, s390-tdep.c, sentinel-frame.c, serial.c: Update. * sh-tdep.c, sh3-rom.c, sh64-tdep.c, shnbsd-nat.c: Update. * solib-aix5.c, solib-svr4.c, solib.c, source.c: Update. * sparc-nat.c, stabsread.c, stack.c, symfile.c, symtab.c: Update. * symtab.h, target.c, tracepoint.c, ui-file.c, ui-out.c: Update. * utils.c, valops.c, valprint.c, vax-nat.c, vaxbsd-nat.c: Update. * win32-nat.c, xcoffread.c, xstormy16-tdep.c: Update. * cli/cli-cmds.c, cli/cli-logging.c, cli/cli-script.c: Update. * cli/cli-setshow.c, mi/mi-cmd-break.c, mi/mi-cmds.c: Update. * mi/mi-console.c, mi/mi-getopt.c, mi/mi-out.c: Update. * tui/tui-file.c, tui/tui-interp.c: Update.
2005-02-11 19:13:55 +01:00
_("store_typed_address: "
"type is not a pointer or reference"));
* gdbarch.sh (POINTER_TO_ADDRESS, ADDRESS_TO_POINTER): Two new functions which architectures can redefine, defaulting to generic_pointer_to_address and generic_address_to_pointer. * findvar.c (extract_typed_address, store_typed_address, generic_pointer_to_address, generic_address_to_pointer): New functions. (POINTER_TO_ADDRESS, ADDRESS_TO_POINTER): Provide default definitions. (extract_address, store_address): Doc fixes. * values.c (value_as_pointer): Doc fix. (value_from_pointer): New function. * defs.h (extract_typed_address, store_typed_address): New declarations. * inferior.h (generic_address_to_pointer, generic_pointer_to_address): New declarations. * value.h (value_from_pointer): New declaration. * ax-gdb.c (const_var_ref): Use value_from_pointer, not value_from_longest. * blockframe.c (generic_push_dummy_frame): Use read_pc and read_sp, not read_register. * c-valprint.c (c_val_print): Use extract_typed_address instead of extract_address to extract vtable entries and references. * cp-valprint.c (cp_print_value_fields): Use value_from_pointer instead of value_from_longest to extract the vtable's address. * eval.c (evaluate_subexp_standard): Use value_from_pointer instead of value_from_longest to compute `this', and for doing pointer-to-member dereferencing. * findvar.c (read_register): Use extract_unsigned_integer, not extract_address. (read_var_value): Use store_typed_address instead of store_address for building label values. (locate_var_value): Use value_from_pointer instead of value_from_longest. * hppa-tdep.c (find_stub_with_shl_get): Use value_from_pointer, instead of value_from_longest, to build arguments to __d_shl_get. * printcmd.c (set_next_address): Use value_from_pointer, not value_from_longest. (x_command): Use value_from_pointer, not value_from_longest. * tracepoint.c (set_traceframe_context): Use value_from_pointer, not value_from_longest. * valarith.c (value_add, value_sub): Use value_from_pointer, not value_from_longest. * valops.c (find_function_in_inferior, value_coerce_array, value_coerce_function, value_addr, hand_function_call): Same. * value.h (COERCE_REF): Use unpack_pointer, not unpack_long. * values.c (unpack_long): Use extract_typed_address to produce addresses from pointers and references, not extract_address. (value_from_longest): Use store_typed_address instead of store_address to produce pointer and reference values.
2000-04-14 20:43:41 +02:00
* gdbtypes.c (make_pointer_type, make_reference_type, smash_to_memberptr_type, lookup_array_range_type, check_stub_method): Use type architecture instead of current_gdbarch. * gdbtypes.h (address_space_name_to_int, address_space_int_to_name): Add GDBARCH paramter. * gdbtypes.c (address_space_name_to_int, address_space_int_to_name): Add GDBARCH parameter. Use it instead of current_gdbarch. * c-typeprint.c (c_type_print_modifier): Update call. * parse.c (push_type_address_space): Likewise. * findvar.c (extract_typed_address, store_typed_address): Use type architecture instead of current_gdbarch. * value.c (value_as_address, unpack_field_as_long): Use type architecture instead of current_gdbarch. * doublest.c (floatformat_from_length): Add GDBARCH argument. Use it instead of current_gdbarch. (floatformat_from_type): Pass type architecture. * infcall.c (find_function_addr): Use type architecture instead of current_gdbarch. * valarith.c (value_bitstring_subscript, value_x_binop, value_neg, value_bit_index): Use type architecture instead of current_gdbarch. * valops.c (value_cast, value_slice): Likewise. * value.h (modify_field): Add TYPE argument. * value.c (modify_field): Add TYPE argument. Use type architecture instead of current_gdbarch. (set_internalvar_component): Likewise. * eval.c (evaluate_struct_tuple): Update call. * valops.c (value_assign): Likewise. * ada-lang.c (modify_general_field): Likewise. Add TYPE argument. (make_array_descriptor): Update calls. (move_bits): Add BITS_BIG_ENDIAN_P argument. Use it instead of current_gdbarch. (ada_value_assign, value_assign_to_component): Update calls. (decode_packed_array, ada_value_primitive_packed_val, ada_value_assign, value_assign_to_component): Use type arch instead of current_gdbarch. * printcmd.c (float_type_from_length): Remove GDBARCH argument, use type architecture instead. (print_scalar_formatted, printf_command): Update calls. Use type architecture instead of current_gdbarch. * valprint.c (val_print_type_code_int): Use type architecture instead of current_gdbarch. * varobj.c (value_get_print_value): Likewise. * python/python-prettyprint.c (print_string_repr): Add GDBARCH argument. Use it instead of current_gdbarch. (apply_val_pretty_printer): Update call. * ada-valprint.c (ada_val_print_1): Use type architecture instead of current_gdbarch. * c-valprint.c (print_function_pointer_address): Add GDBARCH argument. Use it instead of current_gdbarch. (c_val_print): Update calls passing type architecture. * f-valprint.c (f_val_print): Use type architecture instead of current_gdbarch. * jv-valprint (java_value_print): Likewise. * m2-valprint.c (print_function_pointer_address): Add GDBARCH argument. Use it instead of current_gdbarch. (print_unpacked_pointer): Update calls passing type architecture. * scm-valprint.c (scm_scmval_print): Use type architecture instead of current_gdbarch. * gnu-v3-abi.c (get_class_arch): Remove. (gnuv3_rtti_type): Use get_type_arch instead of get_class_arch. Remove special-case check for Java classes. (gnuv3_virtual_fn_field, gnuv3_baseclass_offset, gnuv3_print_method_ptr, gnuv3_method_ptr_size, gnuv3_make_method_ptr, gnuv3_method_ptr_to_value): Use get_type_arch instead of get_class_arch.
2009-07-02 14:57:14 +02:00
gdbarch_address_to_pointer (get_type_arch (type), type, buf, addr);
* gdbarch.sh (POINTER_TO_ADDRESS, ADDRESS_TO_POINTER): Two new functions which architectures can redefine, defaulting to generic_pointer_to_address and generic_address_to_pointer. * findvar.c (extract_typed_address, store_typed_address, generic_pointer_to_address, generic_address_to_pointer): New functions. (POINTER_TO_ADDRESS, ADDRESS_TO_POINTER): Provide default definitions. (extract_address, store_address): Doc fixes. * values.c (value_as_pointer): Doc fix. (value_from_pointer): New function. * defs.h (extract_typed_address, store_typed_address): New declarations. * inferior.h (generic_address_to_pointer, generic_pointer_to_address): New declarations. * value.h (value_from_pointer): New declaration. * ax-gdb.c (const_var_ref): Use value_from_pointer, not value_from_longest. * blockframe.c (generic_push_dummy_frame): Use read_pc and read_sp, not read_register. * c-valprint.c (c_val_print): Use extract_typed_address instead of extract_address to extract vtable entries and references. * cp-valprint.c (cp_print_value_fields): Use value_from_pointer instead of value_from_longest to extract the vtable's address. * eval.c (evaluate_subexp_standard): Use value_from_pointer instead of value_from_longest to compute `this', and for doing pointer-to-member dereferencing. * findvar.c (read_register): Use extract_unsigned_integer, not extract_address. (read_var_value): Use store_typed_address instead of store_address for building label values. (locate_var_value): Use value_from_pointer instead of value_from_longest. * hppa-tdep.c (find_stub_with_shl_get): Use value_from_pointer, instead of value_from_longest, to build arguments to __d_shl_get. * printcmd.c (set_next_address): Use value_from_pointer, not value_from_longest. (x_command): Use value_from_pointer, not value_from_longest. * tracepoint.c (set_traceframe_context): Use value_from_pointer, not value_from_longest. * valarith.c (value_add, value_sub): Use value_from_pointer, not value_from_longest. * valops.c (find_function_in_inferior, value_coerce_array, value_coerce_function, value_addr, hand_function_call): Same. * value.h (COERCE_REF): Use unpack_pointer, not unpack_long. * values.c (unpack_long): Use extract_typed_address to produce addresses from pointers and references, not extract_address. (value_from_longest): Use store_typed_address instead of store_address to produce pointer and reference values.
2000-04-14 20:43:41 +02:00
}
/* Copy a value from SOURCE of size SOURCE_SIZE bytes to DEST of size DEST_SIZE
bytes. If SOURCE_SIZE is greater than DEST_SIZE, then truncate the most
significant bytes. If SOURCE_SIZE is less than DEST_SIZE then either sign
or zero extended according to IS_SIGNED. Values are stored in memory with
endianness BYTE_ORDER. */
* gdbarch.sh (POINTER_TO_ADDRESS, ADDRESS_TO_POINTER): Two new functions which architectures can redefine, defaulting to generic_pointer_to_address and generic_address_to_pointer. * findvar.c (extract_typed_address, store_typed_address, generic_pointer_to_address, generic_address_to_pointer): New functions. (POINTER_TO_ADDRESS, ADDRESS_TO_POINTER): Provide default definitions. (extract_address, store_address): Doc fixes. * values.c (value_as_pointer): Doc fix. (value_from_pointer): New function. * defs.h (extract_typed_address, store_typed_address): New declarations. * inferior.h (generic_address_to_pointer, generic_pointer_to_address): New declarations. * value.h (value_from_pointer): New declaration. * ax-gdb.c (const_var_ref): Use value_from_pointer, not value_from_longest. * blockframe.c (generic_push_dummy_frame): Use read_pc and read_sp, not read_register. * c-valprint.c (c_val_print): Use extract_typed_address instead of extract_address to extract vtable entries and references. * cp-valprint.c (cp_print_value_fields): Use value_from_pointer instead of value_from_longest to extract the vtable's address. * eval.c (evaluate_subexp_standard): Use value_from_pointer instead of value_from_longest to compute `this', and for doing pointer-to-member dereferencing. * findvar.c (read_register): Use extract_unsigned_integer, not extract_address. (read_var_value): Use store_typed_address instead of store_address for building label values. (locate_var_value): Use value_from_pointer instead of value_from_longest. * hppa-tdep.c (find_stub_with_shl_get): Use value_from_pointer, instead of value_from_longest, to build arguments to __d_shl_get. * printcmd.c (set_next_address): Use value_from_pointer, not value_from_longest. (x_command): Use value_from_pointer, not value_from_longest. * tracepoint.c (set_traceframe_context): Use value_from_pointer, not value_from_longest. * valarith.c (value_add, value_sub): Use value_from_pointer, not value_from_longest. * valops.c (find_function_in_inferior, value_coerce_array, value_coerce_function, value_addr, hand_function_call): Same. * value.h (COERCE_REF): Use unpack_pointer, not unpack_long. * values.c (unpack_long): Use extract_typed_address to produce addresses from pointers and references, not extract_address. (value_from_longest): Use store_typed_address instead of store_address to produce pointer and reference values.
2000-04-14 20:43:41 +02:00
void
copy_integer_to_size (gdb_byte *dest, int dest_size, const gdb_byte *source,
int source_size, bool is_signed,
enum bfd_endian byte_order)
{
signed int size_diff = dest_size - source_size;
/* Copy across everything from SOURCE that can fit into DEST. */
if (byte_order == BFD_ENDIAN_BIG && size_diff > 0)
memcpy (dest + size_diff, source, source_size);
else if (byte_order == BFD_ENDIAN_BIG && size_diff < 0)
memcpy (dest, source - size_diff, dest_size);
else
memcpy (dest, source, std::min (source_size, dest_size));
/* Fill the remaining space in DEST by either zero extending or sign
extending. */
if (size_diff > 0)
{
gdb_byte extension = 0;
if (is_signed
&& ((byte_order != BFD_ENDIAN_BIG && source[source_size - 1] & 0x80)
|| (byte_order == BFD_ENDIAN_BIG && source[0] & 0x80)))
extension = 0xff;
/* Extend into MSBs of SOURCE. */
if (byte_order == BFD_ENDIAN_BIG)
memset (dest, extension, size_diff);
else
memset (dest + source_size, extension, size_diff);
}
}
* gdbarch.sh (POINTER_TO_ADDRESS, ADDRESS_TO_POINTER): Two new functions which architectures can redefine, defaulting to generic_pointer_to_address and generic_address_to_pointer. * findvar.c (extract_typed_address, store_typed_address, generic_pointer_to_address, generic_address_to_pointer): New functions. (POINTER_TO_ADDRESS, ADDRESS_TO_POINTER): Provide default definitions. (extract_address, store_address): Doc fixes. * values.c (value_as_pointer): Doc fix. (value_from_pointer): New function. * defs.h (extract_typed_address, store_typed_address): New declarations. * inferior.h (generic_address_to_pointer, generic_pointer_to_address): New declarations. * value.h (value_from_pointer): New declaration. * ax-gdb.c (const_var_ref): Use value_from_pointer, not value_from_longest. * blockframe.c (generic_push_dummy_frame): Use read_pc and read_sp, not read_register. * c-valprint.c (c_val_print): Use extract_typed_address instead of extract_address to extract vtable entries and references. * cp-valprint.c (cp_print_value_fields): Use value_from_pointer instead of value_from_longest to extract the vtable's address. * eval.c (evaluate_subexp_standard): Use value_from_pointer instead of value_from_longest to compute `this', and for doing pointer-to-member dereferencing. * findvar.c (read_register): Use extract_unsigned_integer, not extract_address. (read_var_value): Use store_typed_address instead of store_address for building label values. (locate_var_value): Use value_from_pointer instead of value_from_longest. * hppa-tdep.c (find_stub_with_shl_get): Use value_from_pointer, instead of value_from_longest, to build arguments to __d_shl_get. * printcmd.c (set_next_address): Use value_from_pointer, not value_from_longest. (x_command): Use value_from_pointer, not value_from_longest. * tracepoint.c (set_traceframe_context): Use value_from_pointer, not value_from_longest. * valarith.c (value_add, value_sub): Use value_from_pointer, not value_from_longest. * valops.c (find_function_in_inferior, value_coerce_array, value_coerce_function, value_addr, hand_function_call): Same. * value.h (COERCE_REF): Use unpack_pointer, not unpack_long. * values.c (unpack_long): Use extract_typed_address to produce addresses from pointers and references, not extract_address. (value_from_longest): Use store_typed_address instead of store_address to produce pointer and reference values.
2000-04-14 20:43:41 +02:00
/* Return a `value' with the contents of (virtual or cooked) register
REGNUM as found in the specified FRAME. The register's type is
determined by register_type (). */
2001-11-10 22:34:56 +01:00
struct value *
value_of_register (int regnum, struct frame_info *frame)
{
struct gdbarch *gdbarch = get_frame_arch (frame);
2001-11-10 22:34:56 +01:00
struct value *reg_val;
/* User registers lie completely outside of the range of normal
registers. Catch them early so that the target never sees them. */
Introduce gdbarch_num_cooked_regs The expression gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch) is used quite often to find the number of cooked registers (raw + pseudo registers). This patch introduces gdbarch_num_cooked_regs, which does the equivalent. It substantially reduces required wrapping in some places, so should improve readability. There is a for loop in m68hc11_frame_unwind_cache that had iterated until (the equivalent of) gdbarch_num_cooked_regs (gdbarch) - 1. During review, we concluded that this is most likely an off-by-one mistake, so I replaced it with gdbarch_num_cooked_regs (gdbarch). gdb/ChangeLog: * gdbarch.sh (gdbarch_num_cooked_regs): New. * gdbarch.h: Re-generate. * ax-gdb.c (gen_expr): Use gdbarch_num_cooked_regs. * dwarf2-frame.c (dwarf2_frame_cache): Likewise. * eval.c (evaluate_subexp_standard): Likewise. * findvar.c (value_of_register): Likewise. (value_of_register_lazy): Likewise. (address_from_register): Likewise. * frame.c (get_frame_register_bytes): Likewise. * gdbarch-selftests.c (register_to_value_test): Likewise. * h8300-tdep.c (h8300_register_type): Likewise. * i386-tdep.c (i386_dbx_reg_to_regnum): Likewise. (i386_svr4_reg_to_regnum): Likewise. * infcmd.c (default_print_registers_info): Likewise. (registers_info): Likewise. (print_vector_info): Likewise. (default_print_float_info): Likewise. * m68hc11-tdep.c (m68hc11_frame_unwind_cache): Likewise. * mdebugread.c (mdebug_reg_to_regnum): Likewise. * mi/mi-main.c (mi_cmd_data_list_register_names): Likewise. (mi_cmd_data_list_changed_registers): Likewise. (mi_cmd_data_list_register_values): Likewise. (mi_cmd_data_write_register_values): Likewise. (mi_cmd_trace_frame_collected): Likewise. * mips-tdep.c (print_gp_register_row): Likewise. (mips_print_registers_info): Likewise. * nds32-tdep.c (nds32_gdbarch_init): Likewise. * regcache.c (init_regcache_descr): Likewise. (register_size): Likewise. (register_dump::dump): Likewise. (cooked_read_test): Likewise. (cooked_write_test): Likewise. * rs6000-tdep.c (rs6000_register_sim_regno): Likewise. (rs6000_gdbarch_init): Likewise. * stabsread.c (stab_reg_to_regnum): Likewise. * stack.c (info_frame_command): Likewise. * target-descriptions.c (tdesc_register_name): Likewise. * trad-frame.c (trad_frame_alloc_saved_regs): Likewise. * tui/tui-regs.c (tui_show_register_group): Likewise. * user-regs.c (user_reg_map_name_to_regnum): Likewise. (user_reg_map_regnum_to_name): Likewise. (value_of_user_reg): Likewise. (maintenance_print_user_registers): Likewise. * xtensa-tdep.c (xtensa_find_register_by_name): Likewise. (xtensa_register_name): Likewise. (xtensa_register_type): Likewise. (xtensa_reg_to_regnum): Likewise. (xtensa_pseudo_register_read): Likewise. (xtensa_pseudo_register_write): Likewise.
2018-10-22 04:29:21 +02:00
if (regnum >= gdbarch_num_cooked_regs (gdbarch))
return value_of_user_reg (regnum, frame);
Rework value_of_register in terms of value_of_register_lazy. I noticed that value_of_register (used for getting values _of_ registers ($pc, $rax, etc.), rather than variables _in_ registers), kind of builds a franken-value, by propagating the lval and address of the frame register value, but not the entire location, like necessary for lval_computed (if some unwinder ever returns that, the resulting value will misbehave). This gets in the way of printing optimized out (not saved) lval_registers differently from other optimized out values, as it doesn't make sure the resulting value is lval_register. I started out by just doing something like: - VALUE_LVAL (reg_val) = lval; - set_value_address (reg_val, addr); + VALUE_LVAL (reg_val) = lval_register; ... just like value_of_register_lazy below. That's sufficient to fix the issue. Then I noticed this is using frame_register, which we should avoid nowadays, for it returns elements of a value, but not all that's sometimes necessary (unavailable-ness is all or nothing with it, for instance), and considered using get_frame_register_value instead (which returns a struct value), and value_contents_copy, just like value_fetch_lazy's handling of lval_register. But at that point, I realized we might as well just defer all that work to value_of_register_lazy/value_fetch_lazy... Doing it this way adds a frame_find_by_id lookup (from within value_fetch_lazy), while we already have a frame pointer handy in value_of_register. I considered factoring out the lazy register fetching out of value_fetch_lazy, into a function that takes a frame pointer and call that instead, avoiding the lookup, but then it looked like too much complication for an early optimization, and went back to keeping it simple. Tested on x86_64 Fedora 17. gdb/ 2013-09-05 Pedro Alves <palves@redhat.com> * findvar.c (value_of_register): Rework in terms of value_of_register_lazy.
2013-09-05 16:02:16 +02:00
reg_val = value_of_register_lazy (frame, regnum);
value_fetch_lazy (reg_val);
return reg_val;
}
* gdbarch.sh (POINTER_TO_ADDRESS, ADDRESS_TO_POINTER): Two new functions which architectures can redefine, defaulting to generic_pointer_to_address and generic_address_to_pointer. * findvar.c (extract_typed_address, store_typed_address, generic_pointer_to_address, generic_address_to_pointer): New functions. (POINTER_TO_ADDRESS, ADDRESS_TO_POINTER): Provide default definitions. (extract_address, store_address): Doc fixes. * values.c (value_as_pointer): Doc fix. (value_from_pointer): New function. * defs.h (extract_typed_address, store_typed_address): New declarations. * inferior.h (generic_address_to_pointer, generic_pointer_to_address): New declarations. * value.h (value_from_pointer): New declaration. * ax-gdb.c (const_var_ref): Use value_from_pointer, not value_from_longest. * blockframe.c (generic_push_dummy_frame): Use read_pc and read_sp, not read_register. * c-valprint.c (c_val_print): Use extract_typed_address instead of extract_address to extract vtable entries and references. * cp-valprint.c (cp_print_value_fields): Use value_from_pointer instead of value_from_longest to extract the vtable's address. * eval.c (evaluate_subexp_standard): Use value_from_pointer instead of value_from_longest to compute `this', and for doing pointer-to-member dereferencing. * findvar.c (read_register): Use extract_unsigned_integer, not extract_address. (read_var_value): Use store_typed_address instead of store_address for building label values. (locate_var_value): Use value_from_pointer instead of value_from_longest. * hppa-tdep.c (find_stub_with_shl_get): Use value_from_pointer, instead of value_from_longest, to build arguments to __d_shl_get. * printcmd.c (set_next_address): Use value_from_pointer, not value_from_longest. (x_command): Use value_from_pointer, not value_from_longest. * tracepoint.c (set_traceframe_context): Use value_from_pointer, not value_from_longest. * valarith.c (value_add, value_sub): Use value_from_pointer, not value_from_longest. * valops.c (find_function_in_inferior, value_coerce_array, value_coerce_function, value_addr, hand_function_call): Same. * value.h (COERCE_REF): Use unpack_pointer, not unpack_long. * values.c (unpack_long): Use extract_typed_address to produce addresses from pointers and references, not extract_address. (value_from_longest): Use store_typed_address instead of store_address to produce pointer and reference values.
2000-04-14 20:43:41 +02:00
/* Return a `value' with the contents of (virtual or cooked) register
REGNUM as found in the specified FRAME. The register's type is
determined by register_type (). The value is not fetched. */
struct value *
value_of_register_lazy (struct frame_info *frame, int regnum)
{
struct gdbarch *gdbarch = get_frame_arch (frame);
struct value *reg_val;
Change meaning of VALUE_FRAME_ID; rename to VALUE_NEXT_FRAME_ID The VALUE_FRAME_ID macro provides access to a member in struct value that's used to hold the frame id that's used when determining a register's value or when assigning to a register. The underlying member has a long and obscure name. I won't refer to it here, but will simply refer to VALUE_FRAME_ID as if it's the struct value member instead of being a convenient macro. At the moment, without this patch in place, VALUE_FRAME_ID is set in value_of_register_lazy() and several other locations to hold the frame id of the frame passed to those functions. VALUE_FRAME_ID is used in the lval_register case of value_fetch_lazy(). To fetch the register's value, it calls get_frame_register_value() which, in turn, calls frame_unwind_register_value() with frame->next. A python based unwinder may wish to determine the value of a register or evaluate an expression containing a register. When it does this, value_fetch_lazy() will be called under some circumstances. It will attempt to determine the frame id associated with the frame passed to it. In so doing, it will end up back in the frame sniffer of the very same python unwinder that's attempting to learn the value of a register as part of the sniffing operation. This recursion is not desirable. As noted above, when value_fetch_lazy() wants to fetch a register's value, it does so (indirectly) by unwinding from frame->next. With this in mind, a solution suggests itself: Change VALUE_FRAME_ID to hold the frame id associated with the next frame. Then, when it comes time to obtain the value associated with the register, we can simply unwind from the frame corresponding to the frame id stored in VALUE_FRAME_ID. This neatly avoids the python unwinder recursion problem by changing when the "next" operation occurs. Instead of the "next" operation occuring when the register value is fetched, it occurs earlier on when assigning a frame id to VALUE_FRAME_ID. (Thanks to Pedro for this suggestion.) This patch implements this idea. It builds on the patch "Distinguish sentinel frame from null frame". Without that work in place, it's necessary to check for null_id at several places and then obtain the sentinel frame. It also renames most occurences of VALUE_FRAME_ID to VALUE_NEXT_FRAME_ID to reflect the new meaning of this field. There are several uses of VALUE_FRAME_ID which were not changed. In each case, the original meaning of VALUE_FRAME_ID is required to get correct results. In all but one of these uses, either put_frame_register_bytes() or get_frame_register_bytes() is being called with the frame value obtained from VALUE_FRAME_ID. Both of these functions perform some unwinding by performing a "->next" operation on the frame passed to it. If we were to use the new VALUE_NEXT_FRAME_ID macro, this would effectively do two "->next" operations, which is not what we want. The VALUE_FRAME_ID macro has been redefined in terms of VALUE_NEXT_FRAME_ID. It simply fetches the previous frame's id, providing this id as the value of the macro. gdb/ChangeLog: * value.h (VALUE_FRAME_ID): Rename to VALUE_NEXT_FRAME_ID. Update comment. Create new VALUE_FRAME_ID which is defined in terms of VALUE_NEXT_FRAME_ID. (deprecated_value_frame_id_hack): Rename to deprecated_value_next_frame_id_hack. * dwarf2loc.c, findvar.c, frame-unwind.c, sentinel-frame.c, valarith.c, valops.c, value.c: Adjust nearly all occurences of VALUE_FRAME_ID to VALUE_NEXT_FRAME_ID. Add comments for those which did not change. * value.c (struct value): Rename frame_id field to next_frame_id. Update comment. (deprecated_value_frame_id_hack): Rename to deprecated_value_next_frame_id_hack. (value_fetch_lazy): Call frame_unwind_register_value() instead of get_frame_register_value(). * frame.c (get_prev_frame_id_by_id): New function. * frame.h (get_prev_frame_id_by_id): Declare. * dwarf2loc.c (dwarf2_evaluate_loc_desc_full): Make VALUE_NEXT_FRAME_ID refer to the next frame. * findvar.c (value_of_register_lazy): Likewise. (default_value_from_register): Likewise. (value_from_register): Likewise. * frame_unwind.c (frame_unwind_got_optimized): Likewise. * sentinel-frame.c (sentinel_frame_prev_register): Likewise. * value.h (VALUE_FRAME_ID): Update comment describing this macro.
2016-09-28 06:18:44 +02:00
struct frame_info *next_frame;
Introduce gdbarch_num_cooked_regs The expression gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch) is used quite often to find the number of cooked registers (raw + pseudo registers). This patch introduces gdbarch_num_cooked_regs, which does the equivalent. It substantially reduces required wrapping in some places, so should improve readability. There is a for loop in m68hc11_frame_unwind_cache that had iterated until (the equivalent of) gdbarch_num_cooked_regs (gdbarch) - 1. During review, we concluded that this is most likely an off-by-one mistake, so I replaced it with gdbarch_num_cooked_regs (gdbarch). gdb/ChangeLog: * gdbarch.sh (gdbarch_num_cooked_regs): New. * gdbarch.h: Re-generate. * ax-gdb.c (gen_expr): Use gdbarch_num_cooked_regs. * dwarf2-frame.c (dwarf2_frame_cache): Likewise. * eval.c (evaluate_subexp_standard): Likewise. * findvar.c (value_of_register): Likewise. (value_of_register_lazy): Likewise. (address_from_register): Likewise. * frame.c (get_frame_register_bytes): Likewise. * gdbarch-selftests.c (register_to_value_test): Likewise. * h8300-tdep.c (h8300_register_type): Likewise. * i386-tdep.c (i386_dbx_reg_to_regnum): Likewise. (i386_svr4_reg_to_regnum): Likewise. * infcmd.c (default_print_registers_info): Likewise. (registers_info): Likewise. (print_vector_info): Likewise. (default_print_float_info): Likewise. * m68hc11-tdep.c (m68hc11_frame_unwind_cache): Likewise. * mdebugread.c (mdebug_reg_to_regnum): Likewise. * mi/mi-main.c (mi_cmd_data_list_register_names): Likewise. (mi_cmd_data_list_changed_registers): Likewise. (mi_cmd_data_list_register_values): Likewise. (mi_cmd_data_write_register_values): Likewise. (mi_cmd_trace_frame_collected): Likewise. * mips-tdep.c (print_gp_register_row): Likewise. (mips_print_registers_info): Likewise. * nds32-tdep.c (nds32_gdbarch_init): Likewise. * regcache.c (init_regcache_descr): Likewise. (register_size): Likewise. (register_dump::dump): Likewise. (cooked_read_test): Likewise. (cooked_write_test): Likewise. * rs6000-tdep.c (rs6000_register_sim_regno): Likewise. (rs6000_gdbarch_init): Likewise. * stabsread.c (stab_reg_to_regnum): Likewise. * stack.c (info_frame_command): Likewise. * target-descriptions.c (tdesc_register_name): Likewise. * trad-frame.c (trad_frame_alloc_saved_regs): Likewise. * tui/tui-regs.c (tui_show_register_group): Likewise. * user-regs.c (user_reg_map_name_to_regnum): Likewise. (user_reg_map_regnum_to_name): Likewise. (value_of_user_reg): Likewise. (maintenance_print_user_registers): Likewise. * xtensa-tdep.c (xtensa_find_register_by_name): Likewise. (xtensa_register_name): Likewise. (xtensa_register_type): Likewise. (xtensa_reg_to_regnum): Likewise. (xtensa_pseudo_register_read): Likewise. (xtensa_pseudo_register_write): Likewise.
2018-10-22 04:29:21 +02:00
gdb_assert (regnum < gdbarch_num_cooked_regs (gdbarch));
Change meaning of VALUE_FRAME_ID; rename to VALUE_NEXT_FRAME_ID The VALUE_FRAME_ID macro provides access to a member in struct value that's used to hold the frame id that's used when determining a register's value or when assigning to a register. The underlying member has a long and obscure name. I won't refer to it here, but will simply refer to VALUE_FRAME_ID as if it's the struct value member instead of being a convenient macro. At the moment, without this patch in place, VALUE_FRAME_ID is set in value_of_register_lazy() and several other locations to hold the frame id of the frame passed to those functions. VALUE_FRAME_ID is used in the lval_register case of value_fetch_lazy(). To fetch the register's value, it calls get_frame_register_value() which, in turn, calls frame_unwind_register_value() with frame->next. A python based unwinder may wish to determine the value of a register or evaluate an expression containing a register. When it does this, value_fetch_lazy() will be called under some circumstances. It will attempt to determine the frame id associated with the frame passed to it. In so doing, it will end up back in the frame sniffer of the very same python unwinder that's attempting to learn the value of a register as part of the sniffing operation. This recursion is not desirable. As noted above, when value_fetch_lazy() wants to fetch a register's value, it does so (indirectly) by unwinding from frame->next. With this in mind, a solution suggests itself: Change VALUE_FRAME_ID to hold the frame id associated with the next frame. Then, when it comes time to obtain the value associated with the register, we can simply unwind from the frame corresponding to the frame id stored in VALUE_FRAME_ID. This neatly avoids the python unwinder recursion problem by changing when the "next" operation occurs. Instead of the "next" operation occuring when the register value is fetched, it occurs earlier on when assigning a frame id to VALUE_FRAME_ID. (Thanks to Pedro for this suggestion.) This patch implements this idea. It builds on the patch "Distinguish sentinel frame from null frame". Without that work in place, it's necessary to check for null_id at several places and then obtain the sentinel frame. It also renames most occurences of VALUE_FRAME_ID to VALUE_NEXT_FRAME_ID to reflect the new meaning of this field. There are several uses of VALUE_FRAME_ID which were not changed. In each case, the original meaning of VALUE_FRAME_ID is required to get correct results. In all but one of these uses, either put_frame_register_bytes() or get_frame_register_bytes() is being called with the frame value obtained from VALUE_FRAME_ID. Both of these functions perform some unwinding by performing a "->next" operation on the frame passed to it. If we were to use the new VALUE_NEXT_FRAME_ID macro, this would effectively do two "->next" operations, which is not what we want. The VALUE_FRAME_ID macro has been redefined in terms of VALUE_NEXT_FRAME_ID. It simply fetches the previous frame's id, providing this id as the value of the macro. gdb/ChangeLog: * value.h (VALUE_FRAME_ID): Rename to VALUE_NEXT_FRAME_ID. Update comment. Create new VALUE_FRAME_ID which is defined in terms of VALUE_NEXT_FRAME_ID. (deprecated_value_frame_id_hack): Rename to deprecated_value_next_frame_id_hack. * dwarf2loc.c, findvar.c, frame-unwind.c, sentinel-frame.c, valarith.c, valops.c, value.c: Adjust nearly all occurences of VALUE_FRAME_ID to VALUE_NEXT_FRAME_ID. Add comments for those which did not change. * value.c (struct value): Rename frame_id field to next_frame_id. Update comment. (deprecated_value_frame_id_hack): Rename to deprecated_value_next_frame_id_hack. (value_fetch_lazy): Call frame_unwind_register_value() instead of get_frame_register_value(). * frame.c (get_prev_frame_id_by_id): New function. * frame.h (get_prev_frame_id_by_id): Declare. * dwarf2loc.c (dwarf2_evaluate_loc_desc_full): Make VALUE_NEXT_FRAME_ID refer to the next frame. * findvar.c (value_of_register_lazy): Likewise. (default_value_from_register): Likewise. (value_from_register): Likewise. * frame_unwind.c (frame_unwind_got_optimized): Likewise. * sentinel-frame.c (sentinel_frame_prev_register): Likewise. * value.h (VALUE_FRAME_ID): Update comment describing this macro.
2016-09-28 06:18:44 +02:00
gdb_assert (frame != NULL);
next_frame = get_next_frame_sentinel_okay (frame);
/* We should have a valid next frame. */
gdb_assert (frame_id_p (get_frame_id (next_frame)));
reg_val = allocate_value_lazy (register_type (gdbarch, regnum));
VALUE_LVAL (reg_val) = lval_register;
VALUE_REGNUM (reg_val) = regnum;
Change meaning of VALUE_FRAME_ID; rename to VALUE_NEXT_FRAME_ID The VALUE_FRAME_ID macro provides access to a member in struct value that's used to hold the frame id that's used when determining a register's value or when assigning to a register. The underlying member has a long and obscure name. I won't refer to it here, but will simply refer to VALUE_FRAME_ID as if it's the struct value member instead of being a convenient macro. At the moment, without this patch in place, VALUE_FRAME_ID is set in value_of_register_lazy() and several other locations to hold the frame id of the frame passed to those functions. VALUE_FRAME_ID is used in the lval_register case of value_fetch_lazy(). To fetch the register's value, it calls get_frame_register_value() which, in turn, calls frame_unwind_register_value() with frame->next. A python based unwinder may wish to determine the value of a register or evaluate an expression containing a register. When it does this, value_fetch_lazy() will be called under some circumstances. It will attempt to determine the frame id associated with the frame passed to it. In so doing, it will end up back in the frame sniffer of the very same python unwinder that's attempting to learn the value of a register as part of the sniffing operation. This recursion is not desirable. As noted above, when value_fetch_lazy() wants to fetch a register's value, it does so (indirectly) by unwinding from frame->next. With this in mind, a solution suggests itself: Change VALUE_FRAME_ID to hold the frame id associated with the next frame. Then, when it comes time to obtain the value associated with the register, we can simply unwind from the frame corresponding to the frame id stored in VALUE_FRAME_ID. This neatly avoids the python unwinder recursion problem by changing when the "next" operation occurs. Instead of the "next" operation occuring when the register value is fetched, it occurs earlier on when assigning a frame id to VALUE_FRAME_ID. (Thanks to Pedro for this suggestion.) This patch implements this idea. It builds on the patch "Distinguish sentinel frame from null frame". Without that work in place, it's necessary to check for null_id at several places and then obtain the sentinel frame. It also renames most occurences of VALUE_FRAME_ID to VALUE_NEXT_FRAME_ID to reflect the new meaning of this field. There are several uses of VALUE_FRAME_ID which were not changed. In each case, the original meaning of VALUE_FRAME_ID is required to get correct results. In all but one of these uses, either put_frame_register_bytes() or get_frame_register_bytes() is being called with the frame value obtained from VALUE_FRAME_ID. Both of these functions perform some unwinding by performing a "->next" operation on the frame passed to it. If we were to use the new VALUE_NEXT_FRAME_ID macro, this would effectively do two "->next" operations, which is not what we want. The VALUE_FRAME_ID macro has been redefined in terms of VALUE_NEXT_FRAME_ID. It simply fetches the previous frame's id, providing this id as the value of the macro. gdb/ChangeLog: * value.h (VALUE_FRAME_ID): Rename to VALUE_NEXT_FRAME_ID. Update comment. Create new VALUE_FRAME_ID which is defined in terms of VALUE_NEXT_FRAME_ID. (deprecated_value_frame_id_hack): Rename to deprecated_value_next_frame_id_hack. * dwarf2loc.c, findvar.c, frame-unwind.c, sentinel-frame.c, valarith.c, valops.c, value.c: Adjust nearly all occurences of VALUE_FRAME_ID to VALUE_NEXT_FRAME_ID. Add comments for those which did not change. * value.c (struct value): Rename frame_id field to next_frame_id. Update comment. (deprecated_value_frame_id_hack): Rename to deprecated_value_next_frame_id_hack. (value_fetch_lazy): Call frame_unwind_register_value() instead of get_frame_register_value(). * frame.c (get_prev_frame_id_by_id): New function. * frame.h (get_prev_frame_id_by_id): Declare. * dwarf2loc.c (dwarf2_evaluate_loc_desc_full): Make VALUE_NEXT_FRAME_ID refer to the next frame. * findvar.c (value_of_register_lazy): Likewise. (default_value_from_register): Likewise. (value_from_register): Likewise. * frame_unwind.c (frame_unwind_got_optimized): Likewise. * sentinel-frame.c (sentinel_frame_prev_register): Likewise. * value.h (VALUE_FRAME_ID): Update comment describing this macro.
2016-09-28 06:18:44 +02:00
VALUE_NEXT_FRAME_ID (reg_val) = get_frame_id (next_frame);
return reg_val;
}
* gdbarch.sh (POINTER_TO_ADDRESS, ADDRESS_TO_POINTER): Two new functions which architectures can redefine, defaulting to generic_pointer_to_address and generic_address_to_pointer. * findvar.c (extract_typed_address, store_typed_address, generic_pointer_to_address, generic_address_to_pointer): New functions. (POINTER_TO_ADDRESS, ADDRESS_TO_POINTER): Provide default definitions. (extract_address, store_address): Doc fixes. * values.c (value_as_pointer): Doc fix. (value_from_pointer): New function. * defs.h (extract_typed_address, store_typed_address): New declarations. * inferior.h (generic_address_to_pointer, generic_pointer_to_address): New declarations. * value.h (value_from_pointer): New declaration. * ax-gdb.c (const_var_ref): Use value_from_pointer, not value_from_longest. * blockframe.c (generic_push_dummy_frame): Use read_pc and read_sp, not read_register. * c-valprint.c (c_val_print): Use extract_typed_address instead of extract_address to extract vtable entries and references. * cp-valprint.c (cp_print_value_fields): Use value_from_pointer instead of value_from_longest to extract the vtable's address. * eval.c (evaluate_subexp_standard): Use value_from_pointer instead of value_from_longest to compute `this', and for doing pointer-to-member dereferencing. * findvar.c (read_register): Use extract_unsigned_integer, not extract_address. (read_var_value): Use store_typed_address instead of store_address for building label values. (locate_var_value): Use value_from_pointer instead of value_from_longest. * hppa-tdep.c (find_stub_with_shl_get): Use value_from_pointer, instead of value_from_longest, to build arguments to __d_shl_get. * printcmd.c (set_next_address): Use value_from_pointer, not value_from_longest. (x_command): Use value_from_pointer, not value_from_longest. * tracepoint.c (set_traceframe_context): Use value_from_pointer, not value_from_longest. * valarith.c (value_add, value_sub): Use value_from_pointer, not value_from_longest. * valops.c (find_function_in_inferior, value_coerce_array, value_coerce_function, value_addr, hand_function_call): Same. * value.h (COERCE_REF): Use unpack_pointer, not unpack_long. * values.c (unpack_long): Use extract_typed_address to produce addresses from pointers and references, not extract_address. (value_from_longest): Use store_typed_address instead of store_address to produce pointer and reference values.
2000-04-14 20:43:41 +02:00
/* Given a pointer of type TYPE in target form in BUF, return the
address it represents. */
CORE_ADDR
unsigned_pointer_to_address (struct gdbarch *gdbarch,
struct type *type, const gdb_byte *buf)
* gdbarch.sh (POINTER_TO_ADDRESS, ADDRESS_TO_POINTER): Two new functions which architectures can redefine, defaulting to generic_pointer_to_address and generic_address_to_pointer. * findvar.c (extract_typed_address, store_typed_address, generic_pointer_to_address, generic_address_to_pointer): New functions. (POINTER_TO_ADDRESS, ADDRESS_TO_POINTER): Provide default definitions. (extract_address, store_address): Doc fixes. * values.c (value_as_pointer): Doc fix. (value_from_pointer): New function. * defs.h (extract_typed_address, store_typed_address): New declarations. * inferior.h (generic_address_to_pointer, generic_pointer_to_address): New declarations. * value.h (value_from_pointer): New declaration. * ax-gdb.c (const_var_ref): Use value_from_pointer, not value_from_longest. * blockframe.c (generic_push_dummy_frame): Use read_pc and read_sp, not read_register. * c-valprint.c (c_val_print): Use extract_typed_address instead of extract_address to extract vtable entries and references. * cp-valprint.c (cp_print_value_fields): Use value_from_pointer instead of value_from_longest to extract the vtable's address. * eval.c (evaluate_subexp_standard): Use value_from_pointer instead of value_from_longest to compute `this', and for doing pointer-to-member dereferencing. * findvar.c (read_register): Use extract_unsigned_integer, not extract_address. (read_var_value): Use store_typed_address instead of store_address for building label values. (locate_var_value): Use value_from_pointer instead of value_from_longest. * hppa-tdep.c (find_stub_with_shl_get): Use value_from_pointer, instead of value_from_longest, to build arguments to __d_shl_get. * printcmd.c (set_next_address): Use value_from_pointer, not value_from_longest. (x_command): Use value_from_pointer, not value_from_longest. * tracepoint.c (set_traceframe_context): Use value_from_pointer, not value_from_longest. * valarith.c (value_add, value_sub): Use value_from_pointer, not value_from_longest. * valops.c (find_function_in_inferior, value_coerce_array, value_coerce_function, value_addr, hand_function_call): Same. * value.h (COERCE_REF): Use unpack_pointer, not unpack_long. * values.c (unpack_long): Use extract_typed_address to produce addresses from pointers and references, not extract_address. (value_from_longest): Use store_typed_address instead of store_address to produce pointer and reference values.
2000-04-14 20:43:41 +02:00
{
Adjust byte order variable display/change if DW_AT_endianity is present. - 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
2017-10-06 22:13:04 +02:00
enum bfd_endian byte_order = type_byte_order (type);
* defs.h (extract_signed_integer, extract_unsigned_integer, extract_long_unsigned_integer, store_signed_integer, store_unsigned_integer): Add BYTE_ORDER parameter. * findvar.c (extract_signed_integer, extract_unsigned_integer, extract_long_unsigned_integer, store_signed_integer, store_unsigned_integer): Add BYTE_ORDER parameter. Use it instead of current_gdbarch. * gdbcore.h (read_memory_integer, safe_read_memory_integer, read_memory_unsigned_integer, write_memory_signed_integer, write_memory_unsigned_integer): Add BYTE_ORDER parameter. * corefile.c (struct captured_read_memory_integer_arguments): Add BYTE_ORDER member. (safe_read_memory_integer): Add BYTE_ORDER parameter. Store it into struct captured_read_memory_integer_arguments. (do_captured_read_memory_integer): Pass it to read_memory_integer. (read_memory_integer): Add BYTE_ORDER parameter. Pass it to extract_signed_integer. (read_memory_unsigned_integer): Add BYTE_ORDER parameter. Pass it to extract_unsigned_integer. (write_memory_signed_integer): Add BYTE_ORDER parameter. Pass it to store_signed_integer. (write_memory_unsigned_integer): Add BYTE_ORDER parameter. Pass it to store_unsigned_integer. * target.h (get_target_memory_unsigned): Add BYTE_ORDER parameter. * target.c (get_target_memory_unsigned): Add BYTE_ORDER parameter. Pass it to extract_unsigned_integer. Update calls to extract_signed_integer, extract_unsigned_integer, extract_long_unsigned_integer, store_signed_integer, store_unsigned_integer, read_memory_integer, read_memory_unsigned_integer, safe_read_memory_integer, write_memory_signed_integer, write_memory_unsigned_integer, and get_target_memory_unsigned to pass byte order: * ada-lang.c (ada_value_binop): Update. * ada-valprint.c (char_at): Update. * alpha-osf1-tdep.c (alpha_osf1_sigcontext_addr): Update. * alpha-tdep.c (alpha_lds, alpha_sts, alpha_push_dummy_call, alpha_extract_return_value, alpha_read_insn, alpha_get_longjmp_target): Update. * amd64-linux-tdep.c (amd64_linux_sigcontext_addr): Update. * amd64obsd-tdep.c (amd64obsd_supply_uthread, amd64obsd_collect_uthread, amd64obsd_trapframe_cache): Update. * amd64-tdep.c (amd64_push_dummy_call, amd64_analyze_prologue, amd64_frame_cache, amd64_sigtramp_frame_cache, fixup_riprel, amd64_displaced_step_fixup): Update. * arm-linux-tdep.c (arm_linux_sigreturn_init, arm_linux_rt_sigreturn_init, arm_linux_supply_gregset): Update. * arm-tdep.c (thumb_analyze_prologue, arm_skip_prologue, arm_scan_prologue, arm_push_dummy_call, thumb_get_next_pc, arm_get_next_pc, arm_extract_return_value, arm_store_return_value, arm_return_value): Update. * arm-wince-tdep.c (arm_pe_skip_trampoline_code): Update. * auxv.c (default_auxv_parse): Update. * avr-tdep.c (avr_address_to_pointer, avr_pointer_to_address, avr_scan_prologue, avr_extract_return_value, avr_frame_prev_register, avr_push_dummy_call): Update. * bsd-uthread.c (bsd_uthread_check_magic, bsd_uthread_lookup_offset, bsd_uthread_wait, bsd_uthread_thread_alive, bsd_uthread_extra_thread_info): Update. * c-lang.c (c_printstr, print_wchar): Update. * cp-valprint.c (cp_print_class_member): Update. * cris-tdep.c (cris_sigcontext_addr, cris_sigtramp_frame_unwind_cache, cris_push_dummy_call, cris_scan_prologue, cris_store_return_value, cris_extract_return_value, find_step_target, dip_prefix, sixteen_bit_offset_branch_op, none_reg_mode_jump_op, move_mem_to_reg_movem_op, get_data_from_address): Update. * dwarf2expr.c (dwarf2_read_address, execute_stack_op): Update. * dwarf2-frame.c (execute_cfa_program): Update. * dwarf2loc.c (find_location_expression): Update. * dwarf2read.c (dwarf2_const_value): Update. * expprint.c (print_subexp_standard): Update. * findvar.c (unsigned_pointer_to_address, signed_pointer_to_address, unsigned_address_to_pointer, address_to_signed_pointer, read_var_value): Update. * frame.c (frame_unwind_register_signed, frame_unwind_register_unsigned, get_frame_memory_signed, get_frame_memory_unsigned): Update. * frame-unwind.c (frame_unwind_got_constant): Update. * frv-linux-tdep.c (frv_linux_pc_in_sigtramp, frv_linux_sigcontext_reg_addr, frv_linux_sigtramp_frame_cache): Update. * frv-tdep.c (frv_analyze_prologue, frv_skip_main_prologue, frv_extract_return_value, find_func_descr, frv_convert_from_func_ptr_addr, frv_push_dummy_call): Update. * f-valprint.c (f_val_print): Update. * gnu-v3-abi.c (gnuv3_decode_method_ptr, gnuv3_make_method_ptr): Update. * h8300-tdep.c (h8300_is_argument_spill, h8300_analyze_prologue, h8300_push_dummy_call, h8300_extract_return_value, h8300h_extract_return_value, h8300_store_return_value, h8300h_store_return_value): Update. * hppabsd-tdep.c (hppabsd_find_global_pointer): Update. * hppa-hpux-nat.c (hppa_hpux_fetch_register, hppa_hpux_store_register): Update. * hppa-hpux-tdep.c (hppa32_hpux_in_solib_call_trampoline, hppa64_hpux_in_solib_call_trampoline, hppa_hpux_in_solib_return_trampoline, hppa_hpux_skip_trampoline_code, hppa_hpux_sigtramp_frame_unwind_cache, hppa_hpux_sigtramp_unwind_sniffer, hppa32_hpux_find_global_pointer, hppa64_hpux_find_global_pointer, hppa_hpux_search_pattern, hppa32_hpux_search_dummy_call_sequence, hppa64_hpux_search_dummy_call_sequence, hppa_hpux_supply_save_state, hppa_hpux_unwind_adjust_stub): Update. * hppa-linux-tdep.c (insns_match_pattern, hppa_linux_find_global_pointer): Update. * hppa-tdep.c (hppa_in_function_epilogue_p, hppa32_push_dummy_call, hppa64_convert_code_addr_to_fptr, hppa64_push_dummy_call, skip_prologue_hard_way, hppa_frame_cache, hppa_fallback_frame_cache, hppa_pseudo_register_read, hppa_frame_prev_register_helper, hppa_match_insns): Update. * hpux-thread.c (hpux_thread_fetch_registers): Update. * i386-tdep.c (i386bsd_sigcontext_addr): Update. * i386-cygwin-tdep.c (core_process_module_section): Update. * i386-darwin-nat.c (i386_darwin_sstep_at_sigreturn, amd64_darwin_sstep_at_sigreturn): Update. * i386-darwin-tdep.c (i386_darwin_sigcontext_addr, amd64_darwin_sigcontext_addr): Likewise. * i386-linux-nat.c (i386_linux_sigcontext_addr): Update. * i386nbsd-tdep.c (i386nbsd_sigtramp_cache_init): Update. * i386-nto-tdep.c (i386nto_sigcontext_addr): Update. * i386obsd-nat.c (i386obsd_supply_pcb): Update. * i386obsd-tdep.c (i386obsd_supply_uthread, i386obsd_collect_uthread, i386obsd_trapframe_cache): Update. * i386-tdep.c (i386_displaced_step_fixup, i386_follow_jump, i386_analyze_frame_setup, i386_analyze_prologue, i386_skip_main_prologue, i386_frame_cache, i386_sigtramp_frame_cache, i386_get_longjmp_target, i386_push_dummy_call, i386_pe_skip_trampoline_code, i386_svr4_sigcontext_addr, i386_fetch_pointer_argument): Update. * i387-tdep.c (i387_supply_fsave): Update. * ia64-linux-tdep.c (ia64_linux_sigcontext_register_address): Update. * ia64-tdep.c (ia64_pseudo_register_read, ia64_pseudo_register_write, examine_prologue, ia64_frame_cache, ia64_frame_prev_register, ia64_sigtramp_frame_cache, ia64_sigtramp_frame_prev_register, ia64_access_reg, ia64_access_rse_reg, ia64_libunwind_frame_this_id, ia64_libunwind_frame_prev_register, ia64_libunwind_sigtramp_frame_this_id, ia64_libunwind_sigtramp_frame_prev_register, ia64_find_global_pointer, find_extant_func_descr, find_func_descr, ia64_convert_from_func_ptr_addr, ia64_push_dummy_call, ia64_dummy_id, ia64_unwind_pc): Update. * iq2000-tdep.c (iq2000_pointer_to_address, iq2000_address_to_pointer, iq2000_scan_prologue, iq2000_extract_return_value, iq2000_push_dummy_call): Update. * irix5nat.c (fill_gregset): Update. * jv-lang.c (evaluate_subexp_java): Update. * jv-valprint.c (java_value_print): Update. * lm32-tdep.c (lm32_analyze_prologue, lm32_push_dummy_call, lm32_extract_return_value, lm32_store_return_value): Update. * m32c-tdep.c (m32c_push_dummy_call, m32c_return_value, m32c_skip_trampoline_code, m32c_m16c_address_to_pointer, m32c_m16c_pointer_to_address): Update. * m32r-tdep.c (m32r_store_return_value, decode_prologue, m32r_skip_prologue, m32r_push_dummy_call, m32r_extract_return_value): Update. * m68hc11-tdep.c (m68hc11_pseudo_register_read, m68hc11_pseudo_register_write, m68hc11_analyze_instruction, m68hc11_push_dummy_call): Update. * m68linux-tdep.c (m68k_linux_pc_in_sigtramp, m68k_linux_get_sigtramp_info, m68k_linux_sigtramp_frame_cache): Update. * m68k-tdep.c (m68k_push_dummy_call, m68k_analyze_frame_setup, m68k_analyze_register_saves, m68k_analyze_prologue, m68k_frame_cache, m68k_get_longjmp_target): Update. * m88k-tdep.c (m88k_fetch_instruction): Update. * mep-tdep.c (mep_pseudo_cr32_read, mep_pseudo_csr_write, mep_pseudo_cr32_write, mep_get_insn, mep_push_dummy_call): Update. * mi/mi-main.c (mi_cmd_data_write_memory): Update. * mips-linux-tdep.c (mips_linux_get_longjmp_target, supply_32bit_reg, mips64_linux_get_longjmp_target, mips64_fill_gregset, mips64_fill_fpregset, mips_linux_in_dynsym_stub): Update. * mipsnbdsd-tdep.c (mipsnbsd_get_longjmp_target): Update. * mips-tdep.c (mips_fetch_instruction, fetch_mips_16, mips_eabi_push_dummy_call, mips_n32n64_push_dummy_call, mips_o32_push_dummy_call, mips_o64_push_dummy_call, mips_single_step_through_delay, mips_skip_pic_trampoline_code, mips_integer_to_address): Update. * mn10300-tdep.c (mn10300_analyze_prologue, mn10300_push_dummy_call): Update. * monitor.c (monitor_supply_register, monitor_write_memory, monitor_read_memory_single): Update. * moxie-tdep.c (moxie_store_return_value, moxie_extract_return_value, moxie_analyze_prologue): Update. * mt-tdep.c (mt_return_value, mt_skip_prologue, mt_select_coprocessor, mt_pseudo_register_read, mt_pseudo_register_write, mt_registers_info, mt_push_dummy_call): Update. * objc-lang.c (read_objc_method, read_objc_methlist_nmethods, read_objc_methlist_method, read_objc_object, read_objc_super, read_objc_class, find_implementation_from_class): Update. * ppc64-linux-tdep.c (ppc64_desc_entry_point, ppc64_linux_convert_from_func_ptr_addr, ppc_linux_sigtramp_cache): Update. * ppcobsd-tdep.c (ppcobsd_sigtramp_frame_sniffer, ppcobsd_sigtramp_frame_cache): Update. * ppc-sysv-tdep.c (ppc_sysv_abi_push_dummy_call, do_ppc_sysv_return_value, ppc64_sysv_abi_push_dummy_call, ppc64_sysv_abi_return_value): Update. * ppc-linux-nat.c (ppc_linux_auxv_parse): Update. * procfs.c (procfs_auxv_parse): Update. * p-valprint.c (pascal_val_print): Update. * regcache.c (regcache_raw_read_signed, regcache_raw_read_unsigned, regcache_raw_write_signed, regcache_raw_write_unsigned, regcache_cooked_read_signed, regcache_cooked_read_unsigned, regcache_cooked_write_signed, regcache_cooked_write_unsigned): Update. * remote-m32r-sdi.c (m32r_fetch_register): Update. * remote-mips.c (mips_wait, mips_fetch_registers, mips_xfer_memory): Update. * rs6000-aix-tdep.c (rs6000_push_dummy_call, rs6000_return_value, rs6000_convert_from_func_ptr_addr, branch_dest, rs6000_software_single_step): Update. * rs6000-tdep.c (rs6000_in_function_epilogue_p, ppc_displaced_step_fixup, ppc_deal_with_atomic_sequence, bl_to_blrl_insn_p, rs6000_fetch_instruction, skip_prologue, rs6000_skip_main_prologue, rs6000_skip_trampoline_code, rs6000_frame_cache): Update. * s390-tdep.c (s390_pseudo_register_read, s390_pseudo_register_write, s390x_pseudo_register_read, s390x_pseudo_register_write, s390_load, s390_backchain_frame_unwind_cache, s390_sigtramp_frame_unwind_cache, extend_simple_arg, s390_push_dummy_call, s390_return_value): Update. * scm-exp.c (scm_lreadr): Update. * scm-lang.c (scm_get_field, scm_unpack): Update. * scm-valprint.c (scm_val_print): Update. * score-tdep.c (score_breakpoint_from_pc, score_push_dummy_call, score_fetch_inst): Update. * sh64-tdep.c (look_for_args_moves, sh64_skip_prologue_hard_way, sh64_analyze_prologue, sh64_push_dummy_call, sh64_extract_return_value, sh64_pseudo_register_read, sh64_pseudo_register_write, sh64_frame_prev_register): Update: * sh-tdep.c (sh_analyze_prologue, sh_push_dummy_call_fpu, sh_push_dummy_call_nofpu, sh_extract_return_value_nofpu, sh_store_return_value_nofpu, sh_in_function_epilogue_p): Update. * solib-darwin.c (darwin_load_image_infos): Update. * solib-frv.c (fetch_loadmap, lm_base, frv_current_sos, enable_break2, find_canonical_descriptor_in_load_object): Update. * solib-irix.c (extract_mips_address, fetch_lm_info, irix_current_sos, irix_open_symbol_file_object): Update. * solib-som.c (som_solib_create_inferior_hook, link_map_start, som_current_sos, som_open_symbol_file_object): Update. * solib-sunos.c (SOLIB_EXTRACT_ADDRESS, LM_ADDR, LM_NEXT, LM_NAME): Update. * solib-svr4.c (read_program_header, scan_dyntag_auxv, solib_svr4_r_ldsomap): Update. * sparc64-linux-tdep.c (sparc64_linux_step_trap): Update. * sparc64obsd-tdep.c (sparc64obsd_supply_uthread, sparc64obsd_collect_uthread): Update. * sparc64-tdep.c (sparc64_pseudo_register_read, sparc64_pseudo_register_write, sparc64_supply_gregset, sparc64_collect_gregset): Update. * sparc-linux-tdep.c (sparc32_linux_step_trap): Update. * sparcobsd-tdep.c (sparc32obsd_supply_uthread, sparc32obsd_collect_uthread): Update. * sparc-tdep.c (sparc_fetch_wcookie, sparc32_push_dummy_code, sparc32_store_arguments, sparc32_return_value, sparc_supply_rwindow, sparc_collect_rwindow): Update. * spu-linux-nat.c (parse_spufs_run): Update. * spu-tdep.c (spu_pseudo_register_read_spu, spu_pseudo_register_write_spu, spu_pointer_to_address, spu_analyze_prologue, spu_in_function_epilogue_p, spu_frame_unwind_cache, spu_push_dummy_call, spu_software_single_step, spu_get_longjmp_target, spu_get_overlay_table, spu_overlay_update_osect, info_spu_signal_command, info_spu_mailbox_list, info_spu_dma_cmdlist, info_spu_dma_command, info_spu_proxydma_command): Update. * stack.c (print_frame_nameless_args, frame_info): Update. * symfile.c (read_target_long_array, simple_read_overlay_table, simple_read_overlay_region_table): Update. * target.c (debug_print_register): Update. * tramp-frame.c (tramp_frame_start): Update. * v850-tdep.c (v850_analyze_prologue, v850_push_dummy_call, v850_extract_return_value, v850_store_return_value, * valarith.c (value_binop, value_bit_index): Update. * valops.c (value_cast): Update. * valprint.c (val_print_type_code_int, val_print_string, read_string): Update. * value.c (unpack_long, unpack_double, unpack_field_as_long, modify_field, pack_long): Update. * vax-tdep.c (vax_store_arguments, vax_push_dummy_call, vax_skip_prologue): Update. * xstormy16-tdep.c (xstormy16_push_dummy_call, xstormy16_analyze_prologue, xstormy16_in_function_epilogue_p, xstormy16_resolve_jmp_table_entry, xstormy16_find_jmp_table_entry, xstormy16_pointer_to_address, xstormy16_address_to_pointer): Update. * xtensa-tdep.c (extract_call_winsize, xtensa_pseudo_register_read, xtensa_pseudo_register_write, xtensa_frame_cache, xtensa_push_dummy_call, call0_track_op, call0_frame_cache): Update. * dfp.h (decimal_to_string, decimal_from_string, decimal_from_integral, decimal_from_floating, decimal_to_doublest, decimal_is_zero): Add BYTE_ORDER parameter. (decimal_binop): Add BYTE_ORDER_X, BYTE_ORDER_Y, and BYTE_ORDER_RESULT parameters. (decimal_compare): Add BYTE_ORDER_X and BYTE_ORDER_Y parameters. (decimal_convert): Add BYTE_ORDER_FROM and BYTE_ORDER_TO parameters. * dfp.c (match_endianness): Add BYTE_ORDER parameter. Use it instead of current_gdbarch. (decimal_to_string, decimal_from_integral, decimal_from_floating, decimal_to_doublest, decimal_is_zero): Add BYTE_ORDER parameter. Pass it to match_endianness. (decimal_binop): Add BYTE_ORDER_X, BYTE_ORDER_Y, and BYTE_ORDER_RESULT parameters. Pass them to match_endianness. (decimal_compare): Add BYTE_ORDER_X and BYTE_ORDER_Y parameters. Pass them to match_endianness. (decimal_convert): Add BYTE_ORDER_FROM and BYTE_ORDER_TO parameters. Pass them to match_endianness. * valarith.c (value_args_as_decimal): Add BYTE_ORDER_X and BYTE_ORDER_Y output parameters. (value_binop): Update call to value_args_as_decimal. Update calls to decimal_to_string, decimal_from_string, decimal_from_integral, decimal_from_floating, decimal_to_doublest, decimal_is_zero, decimal_binop, decimal_compare and decimal_convert to pass/receive byte order: * c-exp.y (parse_number): Update. * printcmd.c (printf_command): Update. * valarith.c (value_args_as_decimal, value_binop, value_logical_not, value_equal, value_less): Update. * valops.c (value_cast, value_one): Update. * valprint.c (print_decimal_floating): Update. * value.c (unpack_long, unpack_double): Update. * python/python-value.c (valpy_nonzero): Update. * ada-valprint.c (char_at): Add BYTE_ORDER parameter. (printstr): Update calls to char_at. (ada_val_print_array): Likewise. * valprint.c (read_string): Add BYTE_ORDER parameter. (val_print_string): Update call to read_string. * c-lang.c (c_get_string): Likewise. * charset.h (target_wide_charset): Add BYTE_ORDER parameter. * charset.c (target_wide_charset): Add BYTE_ORDER parameter. Use it instead of current_gdbarch. * printcmd.c (printf_command): Update calls to target_wide_charset. * c-lang.c (charset_for_string_type): Add BYTE_ORDER parameter. Pass to target_wide_charset. Use it instead of current_gdbarch. (classify_type): Add BYTE_ORDER parameter. Pass to charset_for_string_type. Allow NULL encoding pointer. (print_wchar): Add BYTE_ORDER parameter. (c_emit_char): Update calls to classify_type and print_wchar. (c_printchar, c_printstr): Likewise. * gdbarch.sh (in_solib_return_trampoline): Convert to type "m". * gdbarch.c, gdbarch.h: Regenerate. * arch-utils.h (generic_in_solib_return_trampoline): Add GDBARCH parameter. * arch-utils.c (generic_in_solib_return_trampoline): Likewise. * hppa-hpux-tdep.c (hppa_hpux_in_solib_return_trampoline): Likewise. * rs6000-tdep.c (rs6000_in_solib_return_trampoline): Likewise. (rs6000_skip_trampoline_code): Update call. * alpha-tdep.h (struct gdbarch_tdep): Add GDBARCH parameter to dynamic_sigtramp_offset and pc_in_sigtramp callbacks. (alpha_read_insn): Add GDBARCH parameter. * alpha-tdep.c (alpha_lds, alpha_sts): Add GDBARCH parameter. (alpha_register_to_value): Pass architecture to alpha_sts. (alpha_extract_return_value): Likewise. (alpha_value_to_register): Pass architecture to alpha_lds. (alpha_store_return_value): Likewise. (alpha_read_insn): Add GDBARCH parameter. (alpha_skip_prologue): Pass architecture to alpha_read_insn. (alpha_heuristic_proc_start): Likewise. (alpha_heuristic_frame_unwind_cache): Likewise. (alpha_next_pc): Likewise. (alpha_sigtramp_frame_this_id): Pass architecture to tdep->dynamic_sigtramp_offset callback. (alpha_sigtramp_frame_sniffer): Pass architecture to tdep->pc_in_sigtramp callback. * alphafbsd-tdep.c (alphafbsd_pc_in_sigtramp): Add GDBARCH parameter. (alphafbsd_sigtramp_offset): Likewise. * alpha-linux-tdep.c (alpha_linux_sigtramp_offset_1): Add GDBARCH parameter. Pass to alpha_read_insn. (alpha_linux_sigtramp_offset): Add GDBARCH parameter. Pass to alpha_linux_sigtramp_offset_1. (alpha_linux_pc_in_sigtramp): Add GDBARCH parameter. Pass to alpha_linux_sigtramp_offset. (alpha_linux_sigcontext_addr): Pass architecture to alpha_read_insn and alpha_linux_sigtramp_offset. * alphanbsd-tdep.c (alphanbsd_sigtramp_offset): Add GDBARCH parameter. (alphanbsd_pc_in_sigtramp): Add GDBARCH parameter. Pass to alphanbsd_sigtramp_offset. * alphaobsd-tdep.c (alphaobsd_sigtramp_offset): Add GDBARCH parameter. (alphaobsd_pc_in_sigtramp): Add GDBARCH parameter. Pass to alpha_read_insn. (alphaobsd_sigcontext_addr): Pass architecture to alphaobsd_sigtramp_offset. * alpha-osf1-tdep.c (alpha_osf1_pc_in_sigtramp): Add GDBARCH parameter. * amd64-tdep.c (amd64_analyze_prologue): Add GDBARCH parameter. (amd64_skip_prologue): Pass architecture to amd64_analyze_prologue. (amd64_frame_cache): Likewise. * arm-tdep.c (SWAP_SHORT, SWAP_INT): Remove. (thumb_analyze_prologue, arm_skip_prologue, arm_scan_prologue, thumb_get_next_pc, arm_get_next_pc): Do not use SWAP_ macros. * arm-wince-tdep.c: Include "frame.h". * avr-tdep.c (EXTRACT_INSN): Remove. (avr_scan_prologue): Add GDBARCH argument, inline EXTRACT_INSN. (avr_skip_prologue): Pass architecture to avr_scan_prologue. (avr_frame_unwind_cache): Likewise. * cris-tdep.c (struct instruction_environment): Add BYTE_ORDER member. (find_step_target): Initialize it. (get_data_from_address): Add BYTE_ORDER parameter. (bdap_prefix): Pass byte order to get_data_from_address. (handle_prefix_assign_mode_for_aritm_op): Likewise. (three_operand_add_sub_cmp_and_or_op): Likewise. (handle_inc_and_index_mode_for_aritm_op): Likewise. * frv-linux-tdep.c (frv_linux_pc_in_sigtramp): Add GDBARCH parameter. (frv_linux_sigcontext_reg_addr): Pass architecture to frv_linux_pc_in_sigtramp. (frv_linux_sigtramp_frame_sniffer): Likewise. * h8300-tdep.c (h8300_is_argument_spill): Add GDBARCH parameter. (h8300_analyze_prologue): Add GDBARCH parameter. Pass to h8300_is_argument_spill. (h8300_frame_cache, h8300_skip_prologue): Pass architecture to h8300_analyze_prologue. * hppa-tdep.h (struct gdbarch_tdep): Add GDBARCH parameter to in_solib_call_trampoline callback. (hppa_in_solib_call_trampoline): Add GDBARCH parameter. * hppa-tdep.c (hppa64_convert_code_addr_to_fptr): Add GDBARCH parameter. (hppa64_push_dummy_call): Pass architecture to hppa64_convert_code_addr_to_fptr. (hppa_match_insns): Add GDBARCH parameter. (hppa_match_insns_relaxed): Add GDBARCH parameter. Pass to hppa_match_insns. (hppa_skip_trampoline_code): Pass architecture to hppa_match_insns. (hppa_in_solib_call_trampoline): Add GDBARCH parameter. Pass to hppa_match_insns_relaxed. (hppa_stub_unwind_sniffer): Pass architecture to tdep->in_solib_call_trampoline callback. * hppa-hpux-tdep.c (hppa_hpux_search_pattern): Add GDBARCH parameter. (hppa32_hpux_search_dummy_call_sequence): Pass architecture to hppa_hpux_search_pattern. * hppa-linux-tdep.c (insns_match_pattern): Add GDBARCH parameter. (hppa_linux_sigtramp_find_sigcontext): Add GDBARCH parameter. Pass to insns_match_pattern. (hppa_linux_sigtramp_frame_unwind_cache): Pass architecture to hppa_linux_sigtramp_find_sigcontext. (hppa_linux_sigtramp_frame_sniffer): Likewise. (hppa32_hpux_in_solib_call_trampoline): Add GDBARCH parameter. (hppa64_hpux_in_solib_call_trampoline): Likewise. * i386-tdep.c (i386_follow_jump): Add GDBARCH parameter. (i386_analyze_frame_setup): Add GDBARCH parameter. (i386_analyze_prologue): Add GDBARCH parameter. Pass to i386_follow_jump and i386_analyze_frame_setup. (i386_skip_prologue): Pass architecture to i386_analyze_prologue and i386_follow_jump. (i386_frame_cache): Pass architecture to i386_analyze_prologue. (i386_pe_skip_trampoline_code): Add FRAME parameter. * i386-tdep.h (i386_pe_skip_trampoline_code): Add FRAME parameter. * i386-cygwin-tdep.c (i386_cygwin_skip_trampoline_code): Pass frame to i386_pe_skip_trampoline_code. * ia64-tdep.h (struct gdbarch_tdep): Add GDBARCH parameter to sigcontext_register_address callback. * ia64-tdep.c (ia64_find_global_pointer): Add GDBARCH parameter. (ia64_find_unwind_table): Pass architecture to ia64_find_global_pointer. (find_extant_func_descr): Add GDBARCH parameter. (find_func_descr): Pass architecture to find_extant_func_descr and ia64_find_global_pointer. (ia64_sigtramp_frame_init_saved_regs): Pass architecture to tdep->sigcontext_register_address callback. * ia64-linux-tdep.c (ia64_linux_sigcontext_register_address): Add GDBARCH parameter. * iq2000-tdep.c (iq2000_scan_prologue): Add GDBARCH parameter. (iq2000_frame_cache): Pass architecture to iq2000_scan_prologue. * lm32-tdep.c (lm32_analyze_prologue): Add GDBARCH parameter. (lm32_skip_prologue, lm32_frame_cache): Pass architecture to lm32_analyze_prologue. * m32r-tdep.c (decode_prologue): Add GDBARCH parameter. (m32r_skip_prologue): Pass architecture to decode_prologue. * m68hc11-tdep.c (m68hc11_analyze_instruction): Add GDBARCH parameter. (m68hc11_scan_prologue): Pass architecture to m68hc11_analyze_instruction. * m68k-tdep.c (m68k_analyze_frame_setup): Add GDBARCH parameter. (m68k_analyze_prologue): Pass architecture to m68k_analyze_frame_setup. * m88k-tdep.c (m88k_fetch_instruction): Add BYTE_ORDER parameter. (m88k_analyze_prologue): Add GDBARCH parameter. Pass byte order to m88k_fetch_instruction. (m88k_skip_prologue): Pass architecture to m88k_analyze_prologue. (m88k_frame_cache): Likewise. * mep-tdep.c (mep_get_insn): Add GDBARCH parameter. (mep_analyze_prologue): Pass architecture to mep_get_insn. * mips-tdep.c (mips_fetch_instruction): Add GDBARCH parameter. (mips32_next_pc): Pass architecture to mips_fetch_instruction. (deal_with_atomic_sequence): Likewise. (unpack_mips16): Add GDBARCH parameter, pass to mips_fetch_instruction. (mips16_scan_prologue): Likewise. (mips32_scan_prologue): Likewise. (mips16_in_function_epilogue_p): Likewise. (mips32_in_function_epilogue_p): Likewise. (mips_about_to_return): Likewise. (mips_insn16_frame_cache): Pass architecture to mips16_scan_prologue. (mips_insn32_frame_cache): Pass architecture to mips32_scan_prologue. (mips_skip_prologue): Pass architecture to mips16_scan_prologue and mips32_scan_prologue. (mips_in_function_epilogue_p): Pass architecture to mips16_in_function_epilogue_p and mips32_in_function_epilogue_p. (heuristic_proc_start): Pass architecture to mips_fetch_instruction and mips_about_to_return. (mips_skip_mips16_trampoline_code): Pass architecture to mips_fetch_instruction. (fetch_mips_16): Add GDBARCH parameter. (mips16_next_pc): Pass architecture to fetch_mips_16. (extended_mips16_next_pc): Pass architecture to unpack_mips16 and fetch_mips_16. * objc-lang.c (read_objc_method, read_objc_methlist_nmethods, read_objc_methlist_method, read_objc_object, read_objc_super, read_objc_class): Add GDBARCH parameter. (find_implementation_from_class): Add GDBARCH parameter, pass to read_objc_class, read_objc_methlist_nmethods, and read_objc_methlist_method. (find_implementation): Add GDBARCH parameter, pass to read_objc_object and find_implementation_from_class. (resolve_msgsend, resolve_msgsend_stret): Pass architecture to find_implementation. (resolve_msgsend_super, resolve_msgsend_super_stret): Pass architecture to read_objc_super and find_implementation_from_class. * ppc64-linux-tdep.c (ppc64_desc_entry_point): Add GDBARCH parameter. (ppc64_standard_linkage1_target, ppc64_standard_linkage2_target, ppc64_standard_linkage3_target): Pass architecture to ppc64_desc_entry_point. * rs6000-tdep.c (bl_to_blrl_insn_p): Add BYTE_ORDER parameter. (skip_prologue): Pass byte order to bl_to_blrl_insn_p. (rs6000_fetch_instruction): Add GDBARCH parameter. (rs6000_skip_stack_check): Add GDBARCH parameter, pass to rs6000_fetch_instruction. (skip_prologue): Pass architecture to rs6000_fetch_instruction. * remote-mips.c (mips_store_word): Return old_contents as host integer value instead of target bytes. * s390-tdep.c (struct s390_prologue_data): Add BYTE_ORDER member. (s390_analyze_prologue): Initialize it. (extend_simple_arg): Add GDBARCH parameter. (s390_push_dummy_call): Pass architecture to extend_simple_arg. * scm-lang.c (scm_get_field): Add BYTE_ORDER parameter. * scm-lang.h (scm_get_field): Add BYTE_ORDER parameter. (SCM_CAR, SCM_CDR): Pass SCM_BYTE_ORDER to scm_get_field. * scm-valprint.c (scm_scmval_print): Likewise. (scm_scmlist_print, scm_ipruk, scm_scmval_print): Define SCM_BYTE_ORDER. * sh64-tdep.c (look_for_args_moves): Add GDBARCH parameter. (sh64_skip_prologue_hard_way): Add GDBARCH parameter, pass to look_for_args_moves. (sh64_skip_prologue): Pass architecture to sh64_skip_prologue_hard_way. * sh-tdep.c (sh_analyze_prologue): Add GDBARCH parameter. (sh_skip_prologue): Pass architecture to sh_analyze_prologue. (sh_frame_cache): Likewise. * solib-irix.c (extract_mips_address): Add GDBARCH parameter. (fetch_lm_info, irix_current_sos, irix_open_symbol_file_object): Pass architecture to extract_mips_address. * sparc-tdep.h (sparc_fetch_wcookie): Add GDBARCH parameter. * sparc-tdep.c (sparc_fetch_wcookie): Add GDBARCH parameter. (sparc_supply_rwindow, sparc_collect_rwindow): Pass architecture to sparc_fetch_wcookie. (sparc32_frame_prev_register): Likewise. * sparc64-tdep.c (sparc64_frame_prev_register): Likewise. * sparc32nbsd-tdep.c (sparc32nbsd_sigcontext_saved_regs): Likewise. * sparc64nbsd-tdep.c (sparc64nbsd_sigcontext_saved_regs): Likewise. * spu-tdep.c (spu_analyze_prologue): Add GDBARCH parameter. (spu_skip_prologue): Pass architecture to spu_analyze_prologue. (spu_virtual_frame_pointer): Likewise. (spu_frame_unwind_cache): Likewise. (info_spu_mailbox_list): Add BYTE_ORER parameter. (info_spu_mailbox_command): Pass byte order to info_spu_mailbox_list. (info_spu_dma_cmdlist): Add BYTE_ORER parameter. (info_spu_dma_command, info_spu_proxydma_command): Pass byte order to info_spu_dma_cmdlist. * symfile.c (read_target_long_array): Add GDBARCH parameter. (simple_read_overlay_table, simple_read_overlay_region_table, simple_overlay_update_1): Pass architecture to read_target_long_array. * v850-tdep.c (v850_analyze_prologue): Add GDBARCH parameter. (v850_frame_cache): Pass architecture to v850_analyze_prologue. * xstormy16-tdep.c (xstormy16_analyze_prologue): Add GDBARCH parameter. (xstormy16_skip_prologue, xstormy16_frame_cache): Pass architecture to xstormy16_analyze_prologue. (xstormy16_resolve_jmp_table_entry): Add GDBARCH parameter. (xstormy16_find_jmp_table_entry): Likewise. (xstormy16_skip_trampoline_code): Pass architecture to xstormy16_resolve_jmp_table_entry. (xstormy16_pointer_to_address): Likewise. (xstormy16_address_to_pointer): Pass architecture to xstormy16_find_jmp_table_entry. * xtensa-tdep.c (call0_track_op): Add GDBARCH parameter. (call0_analyze_prologue): Add GDBARCH parameter, pass to call0_track_op. (call0_frame_cache): Pass architecture to call0_analyze_prologue. (xtensa_skip_prologue): Likewise.
2009-07-02 19:25:59 +02:00
return extract_unsigned_integer (buf, TYPE_LENGTH (type), byte_order);
* gdbarch.sh (POINTER_TO_ADDRESS, ADDRESS_TO_POINTER): Two new functions which architectures can redefine, defaulting to generic_pointer_to_address and generic_address_to_pointer. * findvar.c (extract_typed_address, store_typed_address, generic_pointer_to_address, generic_address_to_pointer): New functions. (POINTER_TO_ADDRESS, ADDRESS_TO_POINTER): Provide default definitions. (extract_address, store_address): Doc fixes. * values.c (value_as_pointer): Doc fix. (value_from_pointer): New function. * defs.h (extract_typed_address, store_typed_address): New declarations. * inferior.h (generic_address_to_pointer, generic_pointer_to_address): New declarations. * value.h (value_from_pointer): New declaration. * ax-gdb.c (const_var_ref): Use value_from_pointer, not value_from_longest. * blockframe.c (generic_push_dummy_frame): Use read_pc and read_sp, not read_register. * c-valprint.c (c_val_print): Use extract_typed_address instead of extract_address to extract vtable entries and references. * cp-valprint.c (cp_print_value_fields): Use value_from_pointer instead of value_from_longest to extract the vtable's address. * eval.c (evaluate_subexp_standard): Use value_from_pointer instead of value_from_longest to compute `this', and for doing pointer-to-member dereferencing. * findvar.c (read_register): Use extract_unsigned_integer, not extract_address. (read_var_value): Use store_typed_address instead of store_address for building label values. (locate_var_value): Use value_from_pointer instead of value_from_longest. * hppa-tdep.c (find_stub_with_shl_get): Use value_from_pointer, instead of value_from_longest, to build arguments to __d_shl_get. * printcmd.c (set_next_address): Use value_from_pointer, not value_from_longest. (x_command): Use value_from_pointer, not value_from_longest. * tracepoint.c (set_traceframe_context): Use value_from_pointer, not value_from_longest. * valarith.c (value_add, value_sub): Use value_from_pointer, not value_from_longest. * valops.c (find_function_in_inferior, value_coerce_array, value_coerce_function, value_addr, hand_function_call): Same. * value.h (COERCE_REF): Use unpack_pointer, not unpack_long. * values.c (unpack_long): Use extract_typed_address to produce addresses from pointers and references, not extract_address. (value_from_longest): Use store_typed_address instead of store_address to produce pointer and reference values.
2000-04-14 20:43:41 +02:00
}
CORE_ADDR
signed_pointer_to_address (struct gdbarch *gdbarch,
struct type *type, const gdb_byte *buf)
{
Adjust byte order variable display/change if DW_AT_endianity is present. - 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
2017-10-06 22:13:04 +02:00
enum bfd_endian byte_order = type_byte_order (type);
* defs.h (extract_signed_integer, extract_unsigned_integer, extract_long_unsigned_integer, store_signed_integer, store_unsigned_integer): Add BYTE_ORDER parameter. * findvar.c (extract_signed_integer, extract_unsigned_integer, extract_long_unsigned_integer, store_signed_integer, store_unsigned_integer): Add BYTE_ORDER parameter. Use it instead of current_gdbarch. * gdbcore.h (read_memory_integer, safe_read_memory_integer, read_memory_unsigned_integer, write_memory_signed_integer, write_memory_unsigned_integer): Add BYTE_ORDER parameter. * corefile.c (struct captured_read_memory_integer_arguments): Add BYTE_ORDER member. (safe_read_memory_integer): Add BYTE_ORDER parameter. Store it into struct captured_read_memory_integer_arguments. (do_captured_read_memory_integer): Pass it to read_memory_integer. (read_memory_integer): Add BYTE_ORDER parameter. Pass it to extract_signed_integer. (read_memory_unsigned_integer): Add BYTE_ORDER parameter. Pass it to extract_unsigned_integer. (write_memory_signed_integer): Add BYTE_ORDER parameter. Pass it to store_signed_integer. (write_memory_unsigned_integer): Add BYTE_ORDER parameter. Pass it to store_unsigned_integer. * target.h (get_target_memory_unsigned): Add BYTE_ORDER parameter. * target.c (get_target_memory_unsigned): Add BYTE_ORDER parameter. Pass it to extract_unsigned_integer. Update calls to extract_signed_integer, extract_unsigned_integer, extract_long_unsigned_integer, store_signed_integer, store_unsigned_integer, read_memory_integer, read_memory_unsigned_integer, safe_read_memory_integer, write_memory_signed_integer, write_memory_unsigned_integer, and get_target_memory_unsigned to pass byte order: * ada-lang.c (ada_value_binop): Update. * ada-valprint.c (char_at): Update. * alpha-osf1-tdep.c (alpha_osf1_sigcontext_addr): Update. * alpha-tdep.c (alpha_lds, alpha_sts, alpha_push_dummy_call, alpha_extract_return_value, alpha_read_insn, alpha_get_longjmp_target): Update. * amd64-linux-tdep.c (amd64_linux_sigcontext_addr): Update. * amd64obsd-tdep.c (amd64obsd_supply_uthread, amd64obsd_collect_uthread, amd64obsd_trapframe_cache): Update. * amd64-tdep.c (amd64_push_dummy_call, amd64_analyze_prologue, amd64_frame_cache, amd64_sigtramp_frame_cache, fixup_riprel, amd64_displaced_step_fixup): Update. * arm-linux-tdep.c (arm_linux_sigreturn_init, arm_linux_rt_sigreturn_init, arm_linux_supply_gregset): Update. * arm-tdep.c (thumb_analyze_prologue, arm_skip_prologue, arm_scan_prologue, arm_push_dummy_call, thumb_get_next_pc, arm_get_next_pc, arm_extract_return_value, arm_store_return_value, arm_return_value): Update. * arm-wince-tdep.c (arm_pe_skip_trampoline_code): Update. * auxv.c (default_auxv_parse): Update. * avr-tdep.c (avr_address_to_pointer, avr_pointer_to_address, avr_scan_prologue, avr_extract_return_value, avr_frame_prev_register, avr_push_dummy_call): Update. * bsd-uthread.c (bsd_uthread_check_magic, bsd_uthread_lookup_offset, bsd_uthread_wait, bsd_uthread_thread_alive, bsd_uthread_extra_thread_info): Update. * c-lang.c (c_printstr, print_wchar): Update. * cp-valprint.c (cp_print_class_member): Update. * cris-tdep.c (cris_sigcontext_addr, cris_sigtramp_frame_unwind_cache, cris_push_dummy_call, cris_scan_prologue, cris_store_return_value, cris_extract_return_value, find_step_target, dip_prefix, sixteen_bit_offset_branch_op, none_reg_mode_jump_op, move_mem_to_reg_movem_op, get_data_from_address): Update. * dwarf2expr.c (dwarf2_read_address, execute_stack_op): Update. * dwarf2-frame.c (execute_cfa_program): Update. * dwarf2loc.c (find_location_expression): Update. * dwarf2read.c (dwarf2_const_value): Update. * expprint.c (print_subexp_standard): Update. * findvar.c (unsigned_pointer_to_address, signed_pointer_to_address, unsigned_address_to_pointer, address_to_signed_pointer, read_var_value): Update. * frame.c (frame_unwind_register_signed, frame_unwind_register_unsigned, get_frame_memory_signed, get_frame_memory_unsigned): Update. * frame-unwind.c (frame_unwind_got_constant): Update. * frv-linux-tdep.c (frv_linux_pc_in_sigtramp, frv_linux_sigcontext_reg_addr, frv_linux_sigtramp_frame_cache): Update. * frv-tdep.c (frv_analyze_prologue, frv_skip_main_prologue, frv_extract_return_value, find_func_descr, frv_convert_from_func_ptr_addr, frv_push_dummy_call): Update. * f-valprint.c (f_val_print): Update. * gnu-v3-abi.c (gnuv3_decode_method_ptr, gnuv3_make_method_ptr): Update. * h8300-tdep.c (h8300_is_argument_spill, h8300_analyze_prologue, h8300_push_dummy_call, h8300_extract_return_value, h8300h_extract_return_value, h8300_store_return_value, h8300h_store_return_value): Update. * hppabsd-tdep.c (hppabsd_find_global_pointer): Update. * hppa-hpux-nat.c (hppa_hpux_fetch_register, hppa_hpux_store_register): Update. * hppa-hpux-tdep.c (hppa32_hpux_in_solib_call_trampoline, hppa64_hpux_in_solib_call_trampoline, hppa_hpux_in_solib_return_trampoline, hppa_hpux_skip_trampoline_code, hppa_hpux_sigtramp_frame_unwind_cache, hppa_hpux_sigtramp_unwind_sniffer, hppa32_hpux_find_global_pointer, hppa64_hpux_find_global_pointer, hppa_hpux_search_pattern, hppa32_hpux_search_dummy_call_sequence, hppa64_hpux_search_dummy_call_sequence, hppa_hpux_supply_save_state, hppa_hpux_unwind_adjust_stub): Update. * hppa-linux-tdep.c (insns_match_pattern, hppa_linux_find_global_pointer): Update. * hppa-tdep.c (hppa_in_function_epilogue_p, hppa32_push_dummy_call, hppa64_convert_code_addr_to_fptr, hppa64_push_dummy_call, skip_prologue_hard_way, hppa_frame_cache, hppa_fallback_frame_cache, hppa_pseudo_register_read, hppa_frame_prev_register_helper, hppa_match_insns): Update. * hpux-thread.c (hpux_thread_fetch_registers): Update. * i386-tdep.c (i386bsd_sigcontext_addr): Update. * i386-cygwin-tdep.c (core_process_module_section): Update. * i386-darwin-nat.c (i386_darwin_sstep_at_sigreturn, amd64_darwin_sstep_at_sigreturn): Update. * i386-darwin-tdep.c (i386_darwin_sigcontext_addr, amd64_darwin_sigcontext_addr): Likewise. * i386-linux-nat.c (i386_linux_sigcontext_addr): Update. * i386nbsd-tdep.c (i386nbsd_sigtramp_cache_init): Update. * i386-nto-tdep.c (i386nto_sigcontext_addr): Update. * i386obsd-nat.c (i386obsd_supply_pcb): Update. * i386obsd-tdep.c (i386obsd_supply_uthread, i386obsd_collect_uthread, i386obsd_trapframe_cache): Update. * i386-tdep.c (i386_displaced_step_fixup, i386_follow_jump, i386_analyze_frame_setup, i386_analyze_prologue, i386_skip_main_prologue, i386_frame_cache, i386_sigtramp_frame_cache, i386_get_longjmp_target, i386_push_dummy_call, i386_pe_skip_trampoline_code, i386_svr4_sigcontext_addr, i386_fetch_pointer_argument): Update. * i387-tdep.c (i387_supply_fsave): Update. * ia64-linux-tdep.c (ia64_linux_sigcontext_register_address): Update. * ia64-tdep.c (ia64_pseudo_register_read, ia64_pseudo_register_write, examine_prologue, ia64_frame_cache, ia64_frame_prev_register, ia64_sigtramp_frame_cache, ia64_sigtramp_frame_prev_register, ia64_access_reg, ia64_access_rse_reg, ia64_libunwind_frame_this_id, ia64_libunwind_frame_prev_register, ia64_libunwind_sigtramp_frame_this_id, ia64_libunwind_sigtramp_frame_prev_register, ia64_find_global_pointer, find_extant_func_descr, find_func_descr, ia64_convert_from_func_ptr_addr, ia64_push_dummy_call, ia64_dummy_id, ia64_unwind_pc): Update. * iq2000-tdep.c (iq2000_pointer_to_address, iq2000_address_to_pointer, iq2000_scan_prologue, iq2000_extract_return_value, iq2000_push_dummy_call): Update. * irix5nat.c (fill_gregset): Update. * jv-lang.c (evaluate_subexp_java): Update. * jv-valprint.c (java_value_print): Update. * lm32-tdep.c (lm32_analyze_prologue, lm32_push_dummy_call, lm32_extract_return_value, lm32_store_return_value): Update. * m32c-tdep.c (m32c_push_dummy_call, m32c_return_value, m32c_skip_trampoline_code, m32c_m16c_address_to_pointer, m32c_m16c_pointer_to_address): Update. * m32r-tdep.c (m32r_store_return_value, decode_prologue, m32r_skip_prologue, m32r_push_dummy_call, m32r_extract_return_value): Update. * m68hc11-tdep.c (m68hc11_pseudo_register_read, m68hc11_pseudo_register_write, m68hc11_analyze_instruction, m68hc11_push_dummy_call): Update. * m68linux-tdep.c (m68k_linux_pc_in_sigtramp, m68k_linux_get_sigtramp_info, m68k_linux_sigtramp_frame_cache): Update. * m68k-tdep.c (m68k_push_dummy_call, m68k_analyze_frame_setup, m68k_analyze_register_saves, m68k_analyze_prologue, m68k_frame_cache, m68k_get_longjmp_target): Update. * m88k-tdep.c (m88k_fetch_instruction): Update. * mep-tdep.c (mep_pseudo_cr32_read, mep_pseudo_csr_write, mep_pseudo_cr32_write, mep_get_insn, mep_push_dummy_call): Update. * mi/mi-main.c (mi_cmd_data_write_memory): Update. * mips-linux-tdep.c (mips_linux_get_longjmp_target, supply_32bit_reg, mips64_linux_get_longjmp_target, mips64_fill_gregset, mips64_fill_fpregset, mips_linux_in_dynsym_stub): Update. * mipsnbdsd-tdep.c (mipsnbsd_get_longjmp_target): Update. * mips-tdep.c (mips_fetch_instruction, fetch_mips_16, mips_eabi_push_dummy_call, mips_n32n64_push_dummy_call, mips_o32_push_dummy_call, mips_o64_push_dummy_call, mips_single_step_through_delay, mips_skip_pic_trampoline_code, mips_integer_to_address): Update. * mn10300-tdep.c (mn10300_analyze_prologue, mn10300_push_dummy_call): Update. * monitor.c (monitor_supply_register, monitor_write_memory, monitor_read_memory_single): Update. * moxie-tdep.c (moxie_store_return_value, moxie_extract_return_value, moxie_analyze_prologue): Update. * mt-tdep.c (mt_return_value, mt_skip_prologue, mt_select_coprocessor, mt_pseudo_register_read, mt_pseudo_register_write, mt_registers_info, mt_push_dummy_call): Update. * objc-lang.c (read_objc_method, read_objc_methlist_nmethods, read_objc_methlist_method, read_objc_object, read_objc_super, read_objc_class, find_implementation_from_class): Update. * ppc64-linux-tdep.c (ppc64_desc_entry_point, ppc64_linux_convert_from_func_ptr_addr, ppc_linux_sigtramp_cache): Update. * ppcobsd-tdep.c (ppcobsd_sigtramp_frame_sniffer, ppcobsd_sigtramp_frame_cache): Update. * ppc-sysv-tdep.c (ppc_sysv_abi_push_dummy_call, do_ppc_sysv_return_value, ppc64_sysv_abi_push_dummy_call, ppc64_sysv_abi_return_value): Update. * ppc-linux-nat.c (ppc_linux_auxv_parse): Update. * procfs.c (procfs_auxv_parse): Update. * p-valprint.c (pascal_val_print): Update. * regcache.c (regcache_raw_read_signed, regcache_raw_read_unsigned, regcache_raw_write_signed, regcache_raw_write_unsigned, regcache_cooked_read_signed, regcache_cooked_read_unsigned, regcache_cooked_write_signed, regcache_cooked_write_unsigned): Update. * remote-m32r-sdi.c (m32r_fetch_register): Update. * remote-mips.c (mips_wait, mips_fetch_registers, mips_xfer_memory): Update. * rs6000-aix-tdep.c (rs6000_push_dummy_call, rs6000_return_value, rs6000_convert_from_func_ptr_addr, branch_dest, rs6000_software_single_step): Update. * rs6000-tdep.c (rs6000_in_function_epilogue_p, ppc_displaced_step_fixup, ppc_deal_with_atomic_sequence, bl_to_blrl_insn_p, rs6000_fetch_instruction, skip_prologue, rs6000_skip_main_prologue, rs6000_skip_trampoline_code, rs6000_frame_cache): Update. * s390-tdep.c (s390_pseudo_register_read, s390_pseudo_register_write, s390x_pseudo_register_read, s390x_pseudo_register_write, s390_load, s390_backchain_frame_unwind_cache, s390_sigtramp_frame_unwind_cache, extend_simple_arg, s390_push_dummy_call, s390_return_value): Update. * scm-exp.c (scm_lreadr): Update. * scm-lang.c (scm_get_field, scm_unpack): Update. * scm-valprint.c (scm_val_print): Update. * score-tdep.c (score_breakpoint_from_pc, score_push_dummy_call, score_fetch_inst): Update. * sh64-tdep.c (look_for_args_moves, sh64_skip_prologue_hard_way, sh64_analyze_prologue, sh64_push_dummy_call, sh64_extract_return_value, sh64_pseudo_register_read, sh64_pseudo_register_write, sh64_frame_prev_register): Update: * sh-tdep.c (sh_analyze_prologue, sh_push_dummy_call_fpu, sh_push_dummy_call_nofpu, sh_extract_return_value_nofpu, sh_store_return_value_nofpu, sh_in_function_epilogue_p): Update. * solib-darwin.c (darwin_load_image_infos): Update. * solib-frv.c (fetch_loadmap, lm_base, frv_current_sos, enable_break2, find_canonical_descriptor_in_load_object): Update. * solib-irix.c (extract_mips_address, fetch_lm_info, irix_current_sos, irix_open_symbol_file_object): Update. * solib-som.c (som_solib_create_inferior_hook, link_map_start, som_current_sos, som_open_symbol_file_object): Update. * solib-sunos.c (SOLIB_EXTRACT_ADDRESS, LM_ADDR, LM_NEXT, LM_NAME): Update. * solib-svr4.c (read_program_header, scan_dyntag_auxv, solib_svr4_r_ldsomap): Update. * sparc64-linux-tdep.c (sparc64_linux_step_trap): Update. * sparc64obsd-tdep.c (sparc64obsd_supply_uthread, sparc64obsd_collect_uthread): Update. * sparc64-tdep.c (sparc64_pseudo_register_read, sparc64_pseudo_register_write, sparc64_supply_gregset, sparc64_collect_gregset): Update. * sparc-linux-tdep.c (sparc32_linux_step_trap): Update. * sparcobsd-tdep.c (sparc32obsd_supply_uthread, sparc32obsd_collect_uthread): Update. * sparc-tdep.c (sparc_fetch_wcookie, sparc32_push_dummy_code, sparc32_store_arguments, sparc32_return_value, sparc_supply_rwindow, sparc_collect_rwindow): Update. * spu-linux-nat.c (parse_spufs_run): Update. * spu-tdep.c (spu_pseudo_register_read_spu, spu_pseudo_register_write_spu, spu_pointer_to_address, spu_analyze_prologue, spu_in_function_epilogue_p, spu_frame_unwind_cache, spu_push_dummy_call, spu_software_single_step, spu_get_longjmp_target, spu_get_overlay_table, spu_overlay_update_osect, info_spu_signal_command, info_spu_mailbox_list, info_spu_dma_cmdlist, info_spu_dma_command, info_spu_proxydma_command): Update. * stack.c (print_frame_nameless_args, frame_info): Update. * symfile.c (read_target_long_array, simple_read_overlay_table, simple_read_overlay_region_table): Update. * target.c (debug_print_register): Update. * tramp-frame.c (tramp_frame_start): Update. * v850-tdep.c (v850_analyze_prologue, v850_push_dummy_call, v850_extract_return_value, v850_store_return_value, * valarith.c (value_binop, value_bit_index): Update. * valops.c (value_cast): Update. * valprint.c (val_print_type_code_int, val_print_string, read_string): Update. * value.c (unpack_long, unpack_double, unpack_field_as_long, modify_field, pack_long): Update. * vax-tdep.c (vax_store_arguments, vax_push_dummy_call, vax_skip_prologue): Update. * xstormy16-tdep.c (xstormy16_push_dummy_call, xstormy16_analyze_prologue, xstormy16_in_function_epilogue_p, xstormy16_resolve_jmp_table_entry, xstormy16_find_jmp_table_entry, xstormy16_pointer_to_address, xstormy16_address_to_pointer): Update. * xtensa-tdep.c (extract_call_winsize, xtensa_pseudo_register_read, xtensa_pseudo_register_write, xtensa_frame_cache, xtensa_push_dummy_call, call0_track_op, call0_frame_cache): Update. * dfp.h (decimal_to_string, decimal_from_string, decimal_from_integral, decimal_from_floating, decimal_to_doublest, decimal_is_zero): Add BYTE_ORDER parameter. (decimal_binop): Add BYTE_ORDER_X, BYTE_ORDER_Y, and BYTE_ORDER_RESULT parameters. (decimal_compare): Add BYTE_ORDER_X and BYTE_ORDER_Y parameters. (decimal_convert): Add BYTE_ORDER_FROM and BYTE_ORDER_TO parameters. * dfp.c (match_endianness): Add BYTE_ORDER parameter. Use it instead of current_gdbarch. (decimal_to_string, decimal_from_integral, decimal_from_floating, decimal_to_doublest, decimal_is_zero): Add BYTE_ORDER parameter. Pass it to match_endianness. (decimal_binop): Add BYTE_ORDER_X, BYTE_ORDER_Y, and BYTE_ORDER_RESULT parameters. Pass them to match_endianness. (decimal_compare): Add BYTE_ORDER_X and BYTE_ORDER_Y parameters. Pass them to match_endianness. (decimal_convert): Add BYTE_ORDER_FROM and BYTE_ORDER_TO parameters. Pass them to match_endianness. * valarith.c (value_args_as_decimal): Add BYTE_ORDER_X and BYTE_ORDER_Y output parameters. (value_binop): Update call to value_args_as_decimal. Update calls to decimal_to_string, decimal_from_string, decimal_from_integral, decimal_from_floating, decimal_to_doublest, decimal_is_zero, decimal_binop, decimal_compare and decimal_convert to pass/receive byte order: * c-exp.y (parse_number): Update. * printcmd.c (printf_command): Update. * valarith.c (value_args_as_decimal, value_binop, value_logical_not, value_equal, value_less): Update. * valops.c (value_cast, value_one): Update. * valprint.c (print_decimal_floating): Update. * value.c (unpack_long, unpack_double): Update. * python/python-value.c (valpy_nonzero): Update. * ada-valprint.c (char_at): Add BYTE_ORDER parameter. (printstr): Update calls to char_at. (ada_val_print_array): Likewise. * valprint.c (read_string): Add BYTE_ORDER parameter. (val_print_string): Update call to read_string. * c-lang.c (c_get_string): Likewise. * charset.h (target_wide_charset): Add BYTE_ORDER parameter. * charset.c (target_wide_charset): Add BYTE_ORDER parameter. Use it instead of current_gdbarch. * printcmd.c (printf_command): Update calls to target_wide_charset. * c-lang.c (charset_for_string_type): Add BYTE_ORDER parameter. Pass to target_wide_charset. Use it instead of current_gdbarch. (classify_type): Add BYTE_ORDER parameter. Pass to charset_for_string_type. Allow NULL encoding pointer. (print_wchar): Add BYTE_ORDER parameter. (c_emit_char): Update calls to classify_type and print_wchar. (c_printchar, c_printstr): Likewise. * gdbarch.sh (in_solib_return_trampoline): Convert to type "m". * gdbarch.c, gdbarch.h: Regenerate. * arch-utils.h (generic_in_solib_return_trampoline): Add GDBARCH parameter. * arch-utils.c (generic_in_solib_return_trampoline): Likewise. * hppa-hpux-tdep.c (hppa_hpux_in_solib_return_trampoline): Likewise. * rs6000-tdep.c (rs6000_in_solib_return_trampoline): Likewise. (rs6000_skip_trampoline_code): Update call. * alpha-tdep.h (struct gdbarch_tdep): Add GDBARCH parameter to dynamic_sigtramp_offset and pc_in_sigtramp callbacks. (alpha_read_insn): Add GDBARCH parameter. * alpha-tdep.c (alpha_lds, alpha_sts): Add GDBARCH parameter. (alpha_register_to_value): Pass architecture to alpha_sts. (alpha_extract_return_value): Likewise. (alpha_value_to_register): Pass architecture to alpha_lds. (alpha_store_return_value): Likewise. (alpha_read_insn): Add GDBARCH parameter. (alpha_skip_prologue): Pass architecture to alpha_read_insn. (alpha_heuristic_proc_start): Likewise. (alpha_heuristic_frame_unwind_cache): Likewise. (alpha_next_pc): Likewise. (alpha_sigtramp_frame_this_id): Pass architecture to tdep->dynamic_sigtramp_offset callback. (alpha_sigtramp_frame_sniffer): Pass architecture to tdep->pc_in_sigtramp callback. * alphafbsd-tdep.c (alphafbsd_pc_in_sigtramp): Add GDBARCH parameter. (alphafbsd_sigtramp_offset): Likewise. * alpha-linux-tdep.c (alpha_linux_sigtramp_offset_1): Add GDBARCH parameter. Pass to alpha_read_insn. (alpha_linux_sigtramp_offset): Add GDBARCH parameter. Pass to alpha_linux_sigtramp_offset_1. (alpha_linux_pc_in_sigtramp): Add GDBARCH parameter. Pass to alpha_linux_sigtramp_offset. (alpha_linux_sigcontext_addr): Pass architecture to alpha_read_insn and alpha_linux_sigtramp_offset. * alphanbsd-tdep.c (alphanbsd_sigtramp_offset): Add GDBARCH parameter. (alphanbsd_pc_in_sigtramp): Add GDBARCH parameter. Pass to alphanbsd_sigtramp_offset. * alphaobsd-tdep.c (alphaobsd_sigtramp_offset): Add GDBARCH parameter. (alphaobsd_pc_in_sigtramp): Add GDBARCH parameter. Pass to alpha_read_insn. (alphaobsd_sigcontext_addr): Pass architecture to alphaobsd_sigtramp_offset. * alpha-osf1-tdep.c (alpha_osf1_pc_in_sigtramp): Add GDBARCH parameter. * amd64-tdep.c (amd64_analyze_prologue): Add GDBARCH parameter. (amd64_skip_prologue): Pass architecture to amd64_analyze_prologue. (amd64_frame_cache): Likewise. * arm-tdep.c (SWAP_SHORT, SWAP_INT): Remove. (thumb_analyze_prologue, arm_skip_prologue, arm_scan_prologue, thumb_get_next_pc, arm_get_next_pc): Do not use SWAP_ macros. * arm-wince-tdep.c: Include "frame.h". * avr-tdep.c (EXTRACT_INSN): Remove. (avr_scan_prologue): Add GDBARCH argument, inline EXTRACT_INSN. (avr_skip_prologue): Pass architecture to avr_scan_prologue. (avr_frame_unwind_cache): Likewise. * cris-tdep.c (struct instruction_environment): Add BYTE_ORDER member. (find_step_target): Initialize it. (get_data_from_address): Add BYTE_ORDER parameter. (bdap_prefix): Pass byte order to get_data_from_address. (handle_prefix_assign_mode_for_aritm_op): Likewise. (three_operand_add_sub_cmp_and_or_op): Likewise. (handle_inc_and_index_mode_for_aritm_op): Likewise. * frv-linux-tdep.c (frv_linux_pc_in_sigtramp): Add GDBARCH parameter. (frv_linux_sigcontext_reg_addr): Pass architecture to frv_linux_pc_in_sigtramp. (frv_linux_sigtramp_frame_sniffer): Likewise. * h8300-tdep.c (h8300_is_argument_spill): Add GDBARCH parameter. (h8300_analyze_prologue): Add GDBARCH parameter. Pass to h8300_is_argument_spill. (h8300_frame_cache, h8300_skip_prologue): Pass architecture to h8300_analyze_prologue. * hppa-tdep.h (struct gdbarch_tdep): Add GDBARCH parameter to in_solib_call_trampoline callback. (hppa_in_solib_call_trampoline): Add GDBARCH parameter. * hppa-tdep.c (hppa64_convert_code_addr_to_fptr): Add GDBARCH parameter. (hppa64_push_dummy_call): Pass architecture to hppa64_convert_code_addr_to_fptr. (hppa_match_insns): Add GDBARCH parameter. (hppa_match_insns_relaxed): Add GDBARCH parameter. Pass to hppa_match_insns. (hppa_skip_trampoline_code): Pass architecture to hppa_match_insns. (hppa_in_solib_call_trampoline): Add GDBARCH parameter. Pass to hppa_match_insns_relaxed. (hppa_stub_unwind_sniffer): Pass architecture to tdep->in_solib_call_trampoline callback. * hppa-hpux-tdep.c (hppa_hpux_search_pattern): Add GDBARCH parameter. (hppa32_hpux_search_dummy_call_sequence): Pass architecture to hppa_hpux_search_pattern. * hppa-linux-tdep.c (insns_match_pattern): Add GDBARCH parameter. (hppa_linux_sigtramp_find_sigcontext): Add GDBARCH parameter. Pass to insns_match_pattern. (hppa_linux_sigtramp_frame_unwind_cache): Pass architecture to hppa_linux_sigtramp_find_sigcontext. (hppa_linux_sigtramp_frame_sniffer): Likewise. (hppa32_hpux_in_solib_call_trampoline): Add GDBARCH parameter. (hppa64_hpux_in_solib_call_trampoline): Likewise. * i386-tdep.c (i386_follow_jump): Add GDBARCH parameter. (i386_analyze_frame_setup): Add GDBARCH parameter. (i386_analyze_prologue): Add GDBARCH parameter. Pass to i386_follow_jump and i386_analyze_frame_setup. (i386_skip_prologue): Pass architecture to i386_analyze_prologue and i386_follow_jump. (i386_frame_cache): Pass architecture to i386_analyze_prologue. (i386_pe_skip_trampoline_code): Add FRAME parameter. * i386-tdep.h (i386_pe_skip_trampoline_code): Add FRAME parameter. * i386-cygwin-tdep.c (i386_cygwin_skip_trampoline_code): Pass frame to i386_pe_skip_trampoline_code. * ia64-tdep.h (struct gdbarch_tdep): Add GDBARCH parameter to sigcontext_register_address callback. * ia64-tdep.c (ia64_find_global_pointer): Add GDBARCH parameter. (ia64_find_unwind_table): Pass architecture to ia64_find_global_pointer. (find_extant_func_descr): Add GDBARCH parameter. (find_func_descr): Pass architecture to find_extant_func_descr and ia64_find_global_pointer. (ia64_sigtramp_frame_init_saved_regs): Pass architecture to tdep->sigcontext_register_address callback. * ia64-linux-tdep.c (ia64_linux_sigcontext_register_address): Add GDBARCH parameter. * iq2000-tdep.c (iq2000_scan_prologue): Add GDBARCH parameter. (iq2000_frame_cache): Pass architecture to iq2000_scan_prologue. * lm32-tdep.c (lm32_analyze_prologue): Add GDBARCH parameter. (lm32_skip_prologue, lm32_frame_cache): Pass architecture to lm32_analyze_prologue. * m32r-tdep.c (decode_prologue): Add GDBARCH parameter. (m32r_skip_prologue): Pass architecture to decode_prologue. * m68hc11-tdep.c (m68hc11_analyze_instruction): Add GDBARCH parameter. (m68hc11_scan_prologue): Pass architecture to m68hc11_analyze_instruction. * m68k-tdep.c (m68k_analyze_frame_setup): Add GDBARCH parameter. (m68k_analyze_prologue): Pass architecture to m68k_analyze_frame_setup. * m88k-tdep.c (m88k_fetch_instruction): Add BYTE_ORDER parameter. (m88k_analyze_prologue): Add GDBARCH parameter. Pass byte order to m88k_fetch_instruction. (m88k_skip_prologue): Pass architecture to m88k_analyze_prologue. (m88k_frame_cache): Likewise. * mep-tdep.c (mep_get_insn): Add GDBARCH parameter. (mep_analyze_prologue): Pass architecture to mep_get_insn. * mips-tdep.c (mips_fetch_instruction): Add GDBARCH parameter. (mips32_next_pc): Pass architecture to mips_fetch_instruction. (deal_with_atomic_sequence): Likewise. (unpack_mips16): Add GDBARCH parameter, pass to mips_fetch_instruction. (mips16_scan_prologue): Likewise. (mips32_scan_prologue): Likewise. (mips16_in_function_epilogue_p): Likewise. (mips32_in_function_epilogue_p): Likewise. (mips_about_to_return): Likewise. (mips_insn16_frame_cache): Pass architecture to mips16_scan_prologue. (mips_insn32_frame_cache): Pass architecture to mips32_scan_prologue. (mips_skip_prologue): Pass architecture to mips16_scan_prologue and mips32_scan_prologue. (mips_in_function_epilogue_p): Pass architecture to mips16_in_function_epilogue_p and mips32_in_function_epilogue_p. (heuristic_proc_start): Pass architecture to mips_fetch_instruction and mips_about_to_return. (mips_skip_mips16_trampoline_code): Pass architecture to mips_fetch_instruction. (fetch_mips_16): Add GDBARCH parameter. (mips16_next_pc): Pass architecture to fetch_mips_16. (extended_mips16_next_pc): Pass architecture to unpack_mips16 and fetch_mips_16. * objc-lang.c (read_objc_method, read_objc_methlist_nmethods, read_objc_methlist_method, read_objc_object, read_objc_super, read_objc_class): Add GDBARCH parameter. (find_implementation_from_class): Add GDBARCH parameter, pass to read_objc_class, read_objc_methlist_nmethods, and read_objc_methlist_method. (find_implementation): Add GDBARCH parameter, pass to read_objc_object and find_implementation_from_class. (resolve_msgsend, resolve_msgsend_stret): Pass architecture to find_implementation. (resolve_msgsend_super, resolve_msgsend_super_stret): Pass architecture to read_objc_super and find_implementation_from_class. * ppc64-linux-tdep.c (ppc64_desc_entry_point): Add GDBARCH parameter. (ppc64_standard_linkage1_target, ppc64_standard_linkage2_target, ppc64_standard_linkage3_target): Pass architecture to ppc64_desc_entry_point. * rs6000-tdep.c (bl_to_blrl_insn_p): Add BYTE_ORDER parameter. (skip_prologue): Pass byte order to bl_to_blrl_insn_p. (rs6000_fetch_instruction): Add GDBARCH parameter. (rs6000_skip_stack_check): Add GDBARCH parameter, pass to rs6000_fetch_instruction. (skip_prologue): Pass architecture to rs6000_fetch_instruction. * remote-mips.c (mips_store_word): Return old_contents as host integer value instead of target bytes. * s390-tdep.c (struct s390_prologue_data): Add BYTE_ORDER member. (s390_analyze_prologue): Initialize it. (extend_simple_arg): Add GDBARCH parameter. (s390_push_dummy_call): Pass architecture to extend_simple_arg. * scm-lang.c (scm_get_field): Add BYTE_ORDER parameter. * scm-lang.h (scm_get_field): Add BYTE_ORDER parameter. (SCM_CAR, SCM_CDR): Pass SCM_BYTE_ORDER to scm_get_field. * scm-valprint.c (scm_scmval_print): Likewise. (scm_scmlist_print, scm_ipruk, scm_scmval_print): Define SCM_BYTE_ORDER. * sh64-tdep.c (look_for_args_moves): Add GDBARCH parameter. (sh64_skip_prologue_hard_way): Add GDBARCH parameter, pass to look_for_args_moves. (sh64_skip_prologue): Pass architecture to sh64_skip_prologue_hard_way. * sh-tdep.c (sh_analyze_prologue): Add GDBARCH parameter. (sh_skip_prologue): Pass architecture to sh_analyze_prologue. (sh_frame_cache): Likewise. * solib-irix.c (extract_mips_address): Add GDBARCH parameter. (fetch_lm_info, irix_current_sos, irix_open_symbol_file_object): Pass architecture to extract_mips_address. * sparc-tdep.h (sparc_fetch_wcookie): Add GDBARCH parameter. * sparc-tdep.c (sparc_fetch_wcookie): Add GDBARCH parameter. (sparc_supply_rwindow, sparc_collect_rwindow): Pass architecture to sparc_fetch_wcookie. (sparc32_frame_prev_register): Likewise. * sparc64-tdep.c (sparc64_frame_prev_register): Likewise. * sparc32nbsd-tdep.c (sparc32nbsd_sigcontext_saved_regs): Likewise. * sparc64nbsd-tdep.c (sparc64nbsd_sigcontext_saved_regs): Likewise. * spu-tdep.c (spu_analyze_prologue): Add GDBARCH parameter. (spu_skip_prologue): Pass architecture to spu_analyze_prologue. (spu_virtual_frame_pointer): Likewise. (spu_frame_unwind_cache): Likewise. (info_spu_mailbox_list): Add BYTE_ORER parameter. (info_spu_mailbox_command): Pass byte order to info_spu_mailbox_list. (info_spu_dma_cmdlist): Add BYTE_ORER parameter. (info_spu_dma_command, info_spu_proxydma_command): Pass byte order to info_spu_dma_cmdlist. * symfile.c (read_target_long_array): Add GDBARCH parameter. (simple_read_overlay_table, simple_read_overlay_region_table, simple_overlay_update_1): Pass architecture to read_target_long_array. * v850-tdep.c (v850_analyze_prologue): Add GDBARCH parameter. (v850_frame_cache): Pass architecture to v850_analyze_prologue. * xstormy16-tdep.c (xstormy16_analyze_prologue): Add GDBARCH parameter. (xstormy16_skip_prologue, xstormy16_frame_cache): Pass architecture to xstormy16_analyze_prologue. (xstormy16_resolve_jmp_table_entry): Add GDBARCH parameter. (xstormy16_find_jmp_table_entry): Likewise. (xstormy16_skip_trampoline_code): Pass architecture to xstormy16_resolve_jmp_table_entry. (xstormy16_pointer_to_address): Likewise. (xstormy16_address_to_pointer): Pass architecture to xstormy16_find_jmp_table_entry. * xtensa-tdep.c (call0_track_op): Add GDBARCH parameter. (call0_analyze_prologue): Add GDBARCH parameter, pass to call0_track_op. (call0_frame_cache): Pass architecture to call0_analyze_prologue. (xtensa_skip_prologue): Likewise.
2009-07-02 19:25:59 +02:00
return extract_signed_integer (buf, TYPE_LENGTH (type), byte_order);
}
* gdbarch.sh (POINTER_TO_ADDRESS, ADDRESS_TO_POINTER): Two new functions which architectures can redefine, defaulting to generic_pointer_to_address and generic_address_to_pointer. * findvar.c (extract_typed_address, store_typed_address, generic_pointer_to_address, generic_address_to_pointer): New functions. (POINTER_TO_ADDRESS, ADDRESS_TO_POINTER): Provide default definitions. (extract_address, store_address): Doc fixes. * values.c (value_as_pointer): Doc fix. (value_from_pointer): New function. * defs.h (extract_typed_address, store_typed_address): New declarations. * inferior.h (generic_address_to_pointer, generic_pointer_to_address): New declarations. * value.h (value_from_pointer): New declaration. * ax-gdb.c (const_var_ref): Use value_from_pointer, not value_from_longest. * blockframe.c (generic_push_dummy_frame): Use read_pc and read_sp, not read_register. * c-valprint.c (c_val_print): Use extract_typed_address instead of extract_address to extract vtable entries and references. * cp-valprint.c (cp_print_value_fields): Use value_from_pointer instead of value_from_longest to extract the vtable's address. * eval.c (evaluate_subexp_standard): Use value_from_pointer instead of value_from_longest to compute `this', and for doing pointer-to-member dereferencing. * findvar.c (read_register): Use extract_unsigned_integer, not extract_address. (read_var_value): Use store_typed_address instead of store_address for building label values. (locate_var_value): Use value_from_pointer instead of value_from_longest. * hppa-tdep.c (find_stub_with_shl_get): Use value_from_pointer, instead of value_from_longest, to build arguments to __d_shl_get. * printcmd.c (set_next_address): Use value_from_pointer, not value_from_longest. (x_command): Use value_from_pointer, not value_from_longest. * tracepoint.c (set_traceframe_context): Use value_from_pointer, not value_from_longest. * valarith.c (value_add, value_sub): Use value_from_pointer, not value_from_longest. * valops.c (find_function_in_inferior, value_coerce_array, value_coerce_function, value_addr, hand_function_call): Same. * value.h (COERCE_REF): Use unpack_pointer, not unpack_long. * values.c (unpack_long): Use extract_typed_address to produce addresses from pointers and references, not extract_address. (value_from_longest): Use store_typed_address instead of store_address to produce pointer and reference values.
2000-04-14 20:43:41 +02:00
/* Given an address, store it as a pointer of type TYPE in target
format in BUF. */
void
unsigned_address_to_pointer (struct gdbarch *gdbarch, struct type *type,
gdb_byte *buf, CORE_ADDR addr)
* gdbarch.sh (POINTER_TO_ADDRESS, ADDRESS_TO_POINTER): Two new functions which architectures can redefine, defaulting to generic_pointer_to_address and generic_address_to_pointer. * findvar.c (extract_typed_address, store_typed_address, generic_pointer_to_address, generic_address_to_pointer): New functions. (POINTER_TO_ADDRESS, ADDRESS_TO_POINTER): Provide default definitions. (extract_address, store_address): Doc fixes. * values.c (value_as_pointer): Doc fix. (value_from_pointer): New function. * defs.h (extract_typed_address, store_typed_address): New declarations. * inferior.h (generic_address_to_pointer, generic_pointer_to_address): New declarations. * value.h (value_from_pointer): New declaration. * ax-gdb.c (const_var_ref): Use value_from_pointer, not value_from_longest. * blockframe.c (generic_push_dummy_frame): Use read_pc and read_sp, not read_register. * c-valprint.c (c_val_print): Use extract_typed_address instead of extract_address to extract vtable entries and references. * cp-valprint.c (cp_print_value_fields): Use value_from_pointer instead of value_from_longest to extract the vtable's address. * eval.c (evaluate_subexp_standard): Use value_from_pointer instead of value_from_longest to compute `this', and for doing pointer-to-member dereferencing. * findvar.c (read_register): Use extract_unsigned_integer, not extract_address. (read_var_value): Use store_typed_address instead of store_address for building label values. (locate_var_value): Use value_from_pointer instead of value_from_longest. * hppa-tdep.c (find_stub_with_shl_get): Use value_from_pointer, instead of value_from_longest, to build arguments to __d_shl_get. * printcmd.c (set_next_address): Use value_from_pointer, not value_from_longest. (x_command): Use value_from_pointer, not value_from_longest. * tracepoint.c (set_traceframe_context): Use value_from_pointer, not value_from_longest. * valarith.c (value_add, value_sub): Use value_from_pointer, not value_from_longest. * valops.c (find_function_in_inferior, value_coerce_array, value_coerce_function, value_addr, hand_function_call): Same. * value.h (COERCE_REF): Use unpack_pointer, not unpack_long. * values.c (unpack_long): Use extract_typed_address to produce addresses from pointers and references, not extract_address. (value_from_longest): Use store_typed_address instead of store_address to produce pointer and reference values.
2000-04-14 20:43:41 +02:00
{
Adjust byte order variable display/change if DW_AT_endianity is present. - 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
2017-10-06 22:13:04 +02:00
enum bfd_endian byte_order = type_byte_order (type);
* defs.h (extract_signed_integer, extract_unsigned_integer, extract_long_unsigned_integer, store_signed_integer, store_unsigned_integer): Add BYTE_ORDER parameter. * findvar.c (extract_signed_integer, extract_unsigned_integer, extract_long_unsigned_integer, store_signed_integer, store_unsigned_integer): Add BYTE_ORDER parameter. Use it instead of current_gdbarch. * gdbcore.h (read_memory_integer, safe_read_memory_integer, read_memory_unsigned_integer, write_memory_signed_integer, write_memory_unsigned_integer): Add BYTE_ORDER parameter. * corefile.c (struct captured_read_memory_integer_arguments): Add BYTE_ORDER member. (safe_read_memory_integer): Add BYTE_ORDER parameter. Store it into struct captured_read_memory_integer_arguments. (do_captured_read_memory_integer): Pass it to read_memory_integer. (read_memory_integer): Add BYTE_ORDER parameter. Pass it to extract_signed_integer. (read_memory_unsigned_integer): Add BYTE_ORDER parameter. Pass it to extract_unsigned_integer. (write_memory_signed_integer): Add BYTE_ORDER parameter. Pass it to store_signed_integer. (write_memory_unsigned_integer): Add BYTE_ORDER parameter. Pass it to store_unsigned_integer. * target.h (get_target_memory_unsigned): Add BYTE_ORDER parameter. * target.c (get_target_memory_unsigned): Add BYTE_ORDER parameter. Pass it to extract_unsigned_integer. Update calls to extract_signed_integer, extract_unsigned_integer, extract_long_unsigned_integer, store_signed_integer, store_unsigned_integer, read_memory_integer, read_memory_unsigned_integer, safe_read_memory_integer, write_memory_signed_integer, write_memory_unsigned_integer, and get_target_memory_unsigned to pass byte order: * ada-lang.c (ada_value_binop): Update. * ada-valprint.c (char_at): Update. * alpha-osf1-tdep.c (alpha_osf1_sigcontext_addr): Update. * alpha-tdep.c (alpha_lds, alpha_sts, alpha_push_dummy_call, alpha_extract_return_value, alpha_read_insn, alpha_get_longjmp_target): Update. * amd64-linux-tdep.c (amd64_linux_sigcontext_addr): Update. * amd64obsd-tdep.c (amd64obsd_supply_uthread, amd64obsd_collect_uthread, amd64obsd_trapframe_cache): Update. * amd64-tdep.c (amd64_push_dummy_call, amd64_analyze_prologue, amd64_frame_cache, amd64_sigtramp_frame_cache, fixup_riprel, amd64_displaced_step_fixup): Update. * arm-linux-tdep.c (arm_linux_sigreturn_init, arm_linux_rt_sigreturn_init, arm_linux_supply_gregset): Update. * arm-tdep.c (thumb_analyze_prologue, arm_skip_prologue, arm_scan_prologue, arm_push_dummy_call, thumb_get_next_pc, arm_get_next_pc, arm_extract_return_value, arm_store_return_value, arm_return_value): Update. * arm-wince-tdep.c (arm_pe_skip_trampoline_code): Update. * auxv.c (default_auxv_parse): Update. * avr-tdep.c (avr_address_to_pointer, avr_pointer_to_address, avr_scan_prologue, avr_extract_return_value, avr_frame_prev_register, avr_push_dummy_call): Update. * bsd-uthread.c (bsd_uthread_check_magic, bsd_uthread_lookup_offset, bsd_uthread_wait, bsd_uthread_thread_alive, bsd_uthread_extra_thread_info): Update. * c-lang.c (c_printstr, print_wchar): Update. * cp-valprint.c (cp_print_class_member): Update. * cris-tdep.c (cris_sigcontext_addr, cris_sigtramp_frame_unwind_cache, cris_push_dummy_call, cris_scan_prologue, cris_store_return_value, cris_extract_return_value, find_step_target, dip_prefix, sixteen_bit_offset_branch_op, none_reg_mode_jump_op, move_mem_to_reg_movem_op, get_data_from_address): Update. * dwarf2expr.c (dwarf2_read_address, execute_stack_op): Update. * dwarf2-frame.c (execute_cfa_program): Update. * dwarf2loc.c (find_location_expression): Update. * dwarf2read.c (dwarf2_const_value): Update. * expprint.c (print_subexp_standard): Update. * findvar.c (unsigned_pointer_to_address, signed_pointer_to_address, unsigned_address_to_pointer, address_to_signed_pointer, read_var_value): Update. * frame.c (frame_unwind_register_signed, frame_unwind_register_unsigned, get_frame_memory_signed, get_frame_memory_unsigned): Update. * frame-unwind.c (frame_unwind_got_constant): Update. * frv-linux-tdep.c (frv_linux_pc_in_sigtramp, frv_linux_sigcontext_reg_addr, frv_linux_sigtramp_frame_cache): Update. * frv-tdep.c (frv_analyze_prologue, frv_skip_main_prologue, frv_extract_return_value, find_func_descr, frv_convert_from_func_ptr_addr, frv_push_dummy_call): Update. * f-valprint.c (f_val_print): Update. * gnu-v3-abi.c (gnuv3_decode_method_ptr, gnuv3_make_method_ptr): Update. * h8300-tdep.c (h8300_is_argument_spill, h8300_analyze_prologue, h8300_push_dummy_call, h8300_extract_return_value, h8300h_extract_return_value, h8300_store_return_value, h8300h_store_return_value): Update. * hppabsd-tdep.c (hppabsd_find_global_pointer): Update. * hppa-hpux-nat.c (hppa_hpux_fetch_register, hppa_hpux_store_register): Update. * hppa-hpux-tdep.c (hppa32_hpux_in_solib_call_trampoline, hppa64_hpux_in_solib_call_trampoline, hppa_hpux_in_solib_return_trampoline, hppa_hpux_skip_trampoline_code, hppa_hpux_sigtramp_frame_unwind_cache, hppa_hpux_sigtramp_unwind_sniffer, hppa32_hpux_find_global_pointer, hppa64_hpux_find_global_pointer, hppa_hpux_search_pattern, hppa32_hpux_search_dummy_call_sequence, hppa64_hpux_search_dummy_call_sequence, hppa_hpux_supply_save_state, hppa_hpux_unwind_adjust_stub): Update. * hppa-linux-tdep.c (insns_match_pattern, hppa_linux_find_global_pointer): Update. * hppa-tdep.c (hppa_in_function_epilogue_p, hppa32_push_dummy_call, hppa64_convert_code_addr_to_fptr, hppa64_push_dummy_call, skip_prologue_hard_way, hppa_frame_cache, hppa_fallback_frame_cache, hppa_pseudo_register_read, hppa_frame_prev_register_helper, hppa_match_insns): Update. * hpux-thread.c (hpux_thread_fetch_registers): Update. * i386-tdep.c (i386bsd_sigcontext_addr): Update. * i386-cygwin-tdep.c (core_process_module_section): Update. * i386-darwin-nat.c (i386_darwin_sstep_at_sigreturn, amd64_darwin_sstep_at_sigreturn): Update. * i386-darwin-tdep.c (i386_darwin_sigcontext_addr, amd64_darwin_sigcontext_addr): Likewise. * i386-linux-nat.c (i386_linux_sigcontext_addr): Update. * i386nbsd-tdep.c (i386nbsd_sigtramp_cache_init): Update. * i386-nto-tdep.c (i386nto_sigcontext_addr): Update. * i386obsd-nat.c (i386obsd_supply_pcb): Update. * i386obsd-tdep.c (i386obsd_supply_uthread, i386obsd_collect_uthread, i386obsd_trapframe_cache): Update. * i386-tdep.c (i386_displaced_step_fixup, i386_follow_jump, i386_analyze_frame_setup, i386_analyze_prologue, i386_skip_main_prologue, i386_frame_cache, i386_sigtramp_frame_cache, i386_get_longjmp_target, i386_push_dummy_call, i386_pe_skip_trampoline_code, i386_svr4_sigcontext_addr, i386_fetch_pointer_argument): Update. * i387-tdep.c (i387_supply_fsave): Update. * ia64-linux-tdep.c (ia64_linux_sigcontext_register_address): Update. * ia64-tdep.c (ia64_pseudo_register_read, ia64_pseudo_register_write, examine_prologue, ia64_frame_cache, ia64_frame_prev_register, ia64_sigtramp_frame_cache, ia64_sigtramp_frame_prev_register, ia64_access_reg, ia64_access_rse_reg, ia64_libunwind_frame_this_id, ia64_libunwind_frame_prev_register, ia64_libunwind_sigtramp_frame_this_id, ia64_libunwind_sigtramp_frame_prev_register, ia64_find_global_pointer, find_extant_func_descr, find_func_descr, ia64_convert_from_func_ptr_addr, ia64_push_dummy_call, ia64_dummy_id, ia64_unwind_pc): Update. * iq2000-tdep.c (iq2000_pointer_to_address, iq2000_address_to_pointer, iq2000_scan_prologue, iq2000_extract_return_value, iq2000_push_dummy_call): Update. * irix5nat.c (fill_gregset): Update. * jv-lang.c (evaluate_subexp_java): Update. * jv-valprint.c (java_value_print): Update. * lm32-tdep.c (lm32_analyze_prologue, lm32_push_dummy_call, lm32_extract_return_value, lm32_store_return_value): Update. * m32c-tdep.c (m32c_push_dummy_call, m32c_return_value, m32c_skip_trampoline_code, m32c_m16c_address_to_pointer, m32c_m16c_pointer_to_address): Update. * m32r-tdep.c (m32r_store_return_value, decode_prologue, m32r_skip_prologue, m32r_push_dummy_call, m32r_extract_return_value): Update. * m68hc11-tdep.c (m68hc11_pseudo_register_read, m68hc11_pseudo_register_write, m68hc11_analyze_instruction, m68hc11_push_dummy_call): Update. * m68linux-tdep.c (m68k_linux_pc_in_sigtramp, m68k_linux_get_sigtramp_info, m68k_linux_sigtramp_frame_cache): Update. * m68k-tdep.c (m68k_push_dummy_call, m68k_analyze_frame_setup, m68k_analyze_register_saves, m68k_analyze_prologue, m68k_frame_cache, m68k_get_longjmp_target): Update. * m88k-tdep.c (m88k_fetch_instruction): Update. * mep-tdep.c (mep_pseudo_cr32_read, mep_pseudo_csr_write, mep_pseudo_cr32_write, mep_get_insn, mep_push_dummy_call): Update. * mi/mi-main.c (mi_cmd_data_write_memory): Update. * mips-linux-tdep.c (mips_linux_get_longjmp_target, supply_32bit_reg, mips64_linux_get_longjmp_target, mips64_fill_gregset, mips64_fill_fpregset, mips_linux_in_dynsym_stub): Update. * mipsnbdsd-tdep.c (mipsnbsd_get_longjmp_target): Update. * mips-tdep.c (mips_fetch_instruction, fetch_mips_16, mips_eabi_push_dummy_call, mips_n32n64_push_dummy_call, mips_o32_push_dummy_call, mips_o64_push_dummy_call, mips_single_step_through_delay, mips_skip_pic_trampoline_code, mips_integer_to_address): Update. * mn10300-tdep.c (mn10300_analyze_prologue, mn10300_push_dummy_call): Update. * monitor.c (monitor_supply_register, monitor_write_memory, monitor_read_memory_single): Update. * moxie-tdep.c (moxie_store_return_value, moxie_extract_return_value, moxie_analyze_prologue): Update. * mt-tdep.c (mt_return_value, mt_skip_prologue, mt_select_coprocessor, mt_pseudo_register_read, mt_pseudo_register_write, mt_registers_info, mt_push_dummy_call): Update. * objc-lang.c (read_objc_method, read_objc_methlist_nmethods, read_objc_methlist_method, read_objc_object, read_objc_super, read_objc_class, find_implementation_from_class): Update. * ppc64-linux-tdep.c (ppc64_desc_entry_point, ppc64_linux_convert_from_func_ptr_addr, ppc_linux_sigtramp_cache): Update. * ppcobsd-tdep.c (ppcobsd_sigtramp_frame_sniffer, ppcobsd_sigtramp_frame_cache): Update. * ppc-sysv-tdep.c (ppc_sysv_abi_push_dummy_call, do_ppc_sysv_return_value, ppc64_sysv_abi_push_dummy_call, ppc64_sysv_abi_return_value): Update. * ppc-linux-nat.c (ppc_linux_auxv_parse): Update. * procfs.c (procfs_auxv_parse): Update. * p-valprint.c (pascal_val_print): Update. * regcache.c (regcache_raw_read_signed, regcache_raw_read_unsigned, regcache_raw_write_signed, regcache_raw_write_unsigned, regcache_cooked_read_signed, regcache_cooked_read_unsigned, regcache_cooked_write_signed, regcache_cooked_write_unsigned): Update. * remote-m32r-sdi.c (m32r_fetch_register): Update. * remote-mips.c (mips_wait, mips_fetch_registers, mips_xfer_memory): Update. * rs6000-aix-tdep.c (rs6000_push_dummy_call, rs6000_return_value, rs6000_convert_from_func_ptr_addr, branch_dest, rs6000_software_single_step): Update. * rs6000-tdep.c (rs6000_in_function_epilogue_p, ppc_displaced_step_fixup, ppc_deal_with_atomic_sequence, bl_to_blrl_insn_p, rs6000_fetch_instruction, skip_prologue, rs6000_skip_main_prologue, rs6000_skip_trampoline_code, rs6000_frame_cache): Update. * s390-tdep.c (s390_pseudo_register_read, s390_pseudo_register_write, s390x_pseudo_register_read, s390x_pseudo_register_write, s390_load, s390_backchain_frame_unwind_cache, s390_sigtramp_frame_unwind_cache, extend_simple_arg, s390_push_dummy_call, s390_return_value): Update. * scm-exp.c (scm_lreadr): Update. * scm-lang.c (scm_get_field, scm_unpack): Update. * scm-valprint.c (scm_val_print): Update. * score-tdep.c (score_breakpoint_from_pc, score_push_dummy_call, score_fetch_inst): Update. * sh64-tdep.c (look_for_args_moves, sh64_skip_prologue_hard_way, sh64_analyze_prologue, sh64_push_dummy_call, sh64_extract_return_value, sh64_pseudo_register_read, sh64_pseudo_register_write, sh64_frame_prev_register): Update: * sh-tdep.c (sh_analyze_prologue, sh_push_dummy_call_fpu, sh_push_dummy_call_nofpu, sh_extract_return_value_nofpu, sh_store_return_value_nofpu, sh_in_function_epilogue_p): Update. * solib-darwin.c (darwin_load_image_infos): Update. * solib-frv.c (fetch_loadmap, lm_base, frv_current_sos, enable_break2, find_canonical_descriptor_in_load_object): Update. * solib-irix.c (extract_mips_address, fetch_lm_info, irix_current_sos, irix_open_symbol_file_object): Update. * solib-som.c (som_solib_create_inferior_hook, link_map_start, som_current_sos, som_open_symbol_file_object): Update. * solib-sunos.c (SOLIB_EXTRACT_ADDRESS, LM_ADDR, LM_NEXT, LM_NAME): Update. * solib-svr4.c (read_program_header, scan_dyntag_auxv, solib_svr4_r_ldsomap): Update. * sparc64-linux-tdep.c (sparc64_linux_step_trap): Update. * sparc64obsd-tdep.c (sparc64obsd_supply_uthread, sparc64obsd_collect_uthread): Update. * sparc64-tdep.c (sparc64_pseudo_register_read, sparc64_pseudo_register_write, sparc64_supply_gregset, sparc64_collect_gregset): Update. * sparc-linux-tdep.c (sparc32_linux_step_trap): Update. * sparcobsd-tdep.c (sparc32obsd_supply_uthread, sparc32obsd_collect_uthread): Update. * sparc-tdep.c (sparc_fetch_wcookie, sparc32_push_dummy_code, sparc32_store_arguments, sparc32_return_value, sparc_supply_rwindow, sparc_collect_rwindow): Update. * spu-linux-nat.c (parse_spufs_run): Update. * spu-tdep.c (spu_pseudo_register_read_spu, spu_pseudo_register_write_spu, spu_pointer_to_address, spu_analyze_prologue, spu_in_function_epilogue_p, spu_frame_unwind_cache, spu_push_dummy_call, spu_software_single_step, spu_get_longjmp_target, spu_get_overlay_table, spu_overlay_update_osect, info_spu_signal_command, info_spu_mailbox_list, info_spu_dma_cmdlist, info_spu_dma_command, info_spu_proxydma_command): Update. * stack.c (print_frame_nameless_args, frame_info): Update. * symfile.c (read_target_long_array, simple_read_overlay_table, simple_read_overlay_region_table): Update. * target.c (debug_print_register): Update. * tramp-frame.c (tramp_frame_start): Update. * v850-tdep.c (v850_analyze_prologue, v850_push_dummy_call, v850_extract_return_value, v850_store_return_value, * valarith.c (value_binop, value_bit_index): Update. * valops.c (value_cast): Update. * valprint.c (val_print_type_code_int, val_print_string, read_string): Update. * value.c (unpack_long, unpack_double, unpack_field_as_long, modify_field, pack_long): Update. * vax-tdep.c (vax_store_arguments, vax_push_dummy_call, vax_skip_prologue): Update. * xstormy16-tdep.c (xstormy16_push_dummy_call, xstormy16_analyze_prologue, xstormy16_in_function_epilogue_p, xstormy16_resolve_jmp_table_entry, xstormy16_find_jmp_table_entry, xstormy16_pointer_to_address, xstormy16_address_to_pointer): Update. * xtensa-tdep.c (extract_call_winsize, xtensa_pseudo_register_read, xtensa_pseudo_register_write, xtensa_frame_cache, xtensa_push_dummy_call, call0_track_op, call0_frame_cache): Update. * dfp.h (decimal_to_string, decimal_from_string, decimal_from_integral, decimal_from_floating, decimal_to_doublest, decimal_is_zero): Add BYTE_ORDER parameter. (decimal_binop): Add BYTE_ORDER_X, BYTE_ORDER_Y, and BYTE_ORDER_RESULT parameters. (decimal_compare): Add BYTE_ORDER_X and BYTE_ORDER_Y parameters. (decimal_convert): Add BYTE_ORDER_FROM and BYTE_ORDER_TO parameters. * dfp.c (match_endianness): Add BYTE_ORDER parameter. Use it instead of current_gdbarch. (decimal_to_string, decimal_from_integral, decimal_from_floating, decimal_to_doublest, decimal_is_zero): Add BYTE_ORDER parameter. Pass it to match_endianness. (decimal_binop): Add BYTE_ORDER_X, BYTE_ORDER_Y, and BYTE_ORDER_RESULT parameters. Pass them to match_endianness. (decimal_compare): Add BYTE_ORDER_X and BYTE_ORDER_Y parameters. Pass them to match_endianness. (decimal_convert): Add BYTE_ORDER_FROM and BYTE_ORDER_TO parameters. Pass them to match_endianness. * valarith.c (value_args_as_decimal): Add BYTE_ORDER_X and BYTE_ORDER_Y output parameters. (value_binop): Update call to value_args_as_decimal. Update calls to decimal_to_string, decimal_from_string, decimal_from_integral, decimal_from_floating, decimal_to_doublest, decimal_is_zero, decimal_binop, decimal_compare and decimal_convert to pass/receive byte order: * c-exp.y (parse_number): Update. * printcmd.c (printf_command): Update. * valarith.c (value_args_as_decimal, value_binop, value_logical_not, value_equal, value_less): Update. * valops.c (value_cast, value_one): Update. * valprint.c (print_decimal_floating): Update. * value.c (unpack_long, unpack_double): Update. * python/python-value.c (valpy_nonzero): Update. * ada-valprint.c (char_at): Add BYTE_ORDER parameter. (printstr): Update calls to char_at. (ada_val_print_array): Likewise. * valprint.c (read_string): Add BYTE_ORDER parameter. (val_print_string): Update call to read_string. * c-lang.c (c_get_string): Likewise. * charset.h (target_wide_charset): Add BYTE_ORDER parameter. * charset.c (target_wide_charset): Add BYTE_ORDER parameter. Use it instead of current_gdbarch. * printcmd.c (printf_command): Update calls to target_wide_charset. * c-lang.c (charset_for_string_type): Add BYTE_ORDER parameter. Pass to target_wide_charset. Use it instead of current_gdbarch. (classify_type): Add BYTE_ORDER parameter. Pass to charset_for_string_type. Allow NULL encoding pointer. (print_wchar): Add BYTE_ORDER parameter. (c_emit_char): Update calls to classify_type and print_wchar. (c_printchar, c_printstr): Likewise. * gdbarch.sh (in_solib_return_trampoline): Convert to type "m". * gdbarch.c, gdbarch.h: Regenerate. * arch-utils.h (generic_in_solib_return_trampoline): Add GDBARCH parameter. * arch-utils.c (generic_in_solib_return_trampoline): Likewise. * hppa-hpux-tdep.c (hppa_hpux_in_solib_return_trampoline): Likewise. * rs6000-tdep.c (rs6000_in_solib_return_trampoline): Likewise. (rs6000_skip_trampoline_code): Update call. * alpha-tdep.h (struct gdbarch_tdep): Add GDBARCH parameter to dynamic_sigtramp_offset and pc_in_sigtramp callbacks. (alpha_read_insn): Add GDBARCH parameter. * alpha-tdep.c (alpha_lds, alpha_sts): Add GDBARCH parameter. (alpha_register_to_value): Pass architecture to alpha_sts. (alpha_extract_return_value): Likewise. (alpha_value_to_register): Pass architecture to alpha_lds. (alpha_store_return_value): Likewise. (alpha_read_insn): Add GDBARCH parameter. (alpha_skip_prologue): Pass architecture to alpha_read_insn. (alpha_heuristic_proc_start): Likewise. (alpha_heuristic_frame_unwind_cache): Likewise. (alpha_next_pc): Likewise. (alpha_sigtramp_frame_this_id): Pass architecture to tdep->dynamic_sigtramp_offset callback. (alpha_sigtramp_frame_sniffer): Pass architecture to tdep->pc_in_sigtramp callback. * alphafbsd-tdep.c (alphafbsd_pc_in_sigtramp): Add GDBARCH parameter. (alphafbsd_sigtramp_offset): Likewise. * alpha-linux-tdep.c (alpha_linux_sigtramp_offset_1): Add GDBARCH parameter. Pass to alpha_read_insn. (alpha_linux_sigtramp_offset): Add GDBARCH parameter. Pass to alpha_linux_sigtramp_offset_1. (alpha_linux_pc_in_sigtramp): Add GDBARCH parameter. Pass to alpha_linux_sigtramp_offset. (alpha_linux_sigcontext_addr): Pass architecture to alpha_read_insn and alpha_linux_sigtramp_offset. * alphanbsd-tdep.c (alphanbsd_sigtramp_offset): Add GDBARCH parameter. (alphanbsd_pc_in_sigtramp): Add GDBARCH parameter. Pass to alphanbsd_sigtramp_offset. * alphaobsd-tdep.c (alphaobsd_sigtramp_offset): Add GDBARCH parameter. (alphaobsd_pc_in_sigtramp): Add GDBARCH parameter. Pass to alpha_read_insn. (alphaobsd_sigcontext_addr): Pass architecture to alphaobsd_sigtramp_offset. * alpha-osf1-tdep.c (alpha_osf1_pc_in_sigtramp): Add GDBARCH parameter. * amd64-tdep.c (amd64_analyze_prologue): Add GDBARCH parameter. (amd64_skip_prologue): Pass architecture to amd64_analyze_prologue. (amd64_frame_cache): Likewise. * arm-tdep.c (SWAP_SHORT, SWAP_INT): Remove. (thumb_analyze_prologue, arm_skip_prologue, arm_scan_prologue, thumb_get_next_pc, arm_get_next_pc): Do not use SWAP_ macros. * arm-wince-tdep.c: Include "frame.h". * avr-tdep.c (EXTRACT_INSN): Remove. (avr_scan_prologue): Add GDBARCH argument, inline EXTRACT_INSN. (avr_skip_prologue): Pass architecture to avr_scan_prologue. (avr_frame_unwind_cache): Likewise. * cris-tdep.c (struct instruction_environment): Add BYTE_ORDER member. (find_step_target): Initialize it. (get_data_from_address): Add BYTE_ORDER parameter. (bdap_prefix): Pass byte order to get_data_from_address. (handle_prefix_assign_mode_for_aritm_op): Likewise. (three_operand_add_sub_cmp_and_or_op): Likewise. (handle_inc_and_index_mode_for_aritm_op): Likewise. * frv-linux-tdep.c (frv_linux_pc_in_sigtramp): Add GDBARCH parameter. (frv_linux_sigcontext_reg_addr): Pass architecture to frv_linux_pc_in_sigtramp. (frv_linux_sigtramp_frame_sniffer): Likewise. * h8300-tdep.c (h8300_is_argument_spill): Add GDBARCH parameter. (h8300_analyze_prologue): Add GDBARCH parameter. Pass to h8300_is_argument_spill. (h8300_frame_cache, h8300_skip_prologue): Pass architecture to h8300_analyze_prologue. * hppa-tdep.h (struct gdbarch_tdep): Add GDBARCH parameter to in_solib_call_trampoline callback. (hppa_in_solib_call_trampoline): Add GDBARCH parameter. * hppa-tdep.c (hppa64_convert_code_addr_to_fptr): Add GDBARCH parameter. (hppa64_push_dummy_call): Pass architecture to hppa64_convert_code_addr_to_fptr. (hppa_match_insns): Add GDBARCH parameter. (hppa_match_insns_relaxed): Add GDBARCH parameter. Pass to hppa_match_insns. (hppa_skip_trampoline_code): Pass architecture to hppa_match_insns. (hppa_in_solib_call_trampoline): Add GDBARCH parameter. Pass to hppa_match_insns_relaxed. (hppa_stub_unwind_sniffer): Pass architecture to tdep->in_solib_call_trampoline callback. * hppa-hpux-tdep.c (hppa_hpux_search_pattern): Add GDBARCH parameter. (hppa32_hpux_search_dummy_call_sequence): Pass architecture to hppa_hpux_search_pattern. * hppa-linux-tdep.c (insns_match_pattern): Add GDBARCH parameter. (hppa_linux_sigtramp_find_sigcontext): Add GDBARCH parameter. Pass to insns_match_pattern. (hppa_linux_sigtramp_frame_unwind_cache): Pass architecture to hppa_linux_sigtramp_find_sigcontext. (hppa_linux_sigtramp_frame_sniffer): Likewise. (hppa32_hpux_in_solib_call_trampoline): Add GDBARCH parameter. (hppa64_hpux_in_solib_call_trampoline): Likewise. * i386-tdep.c (i386_follow_jump): Add GDBARCH parameter. (i386_analyze_frame_setup): Add GDBARCH parameter. (i386_analyze_prologue): Add GDBARCH parameter. Pass to i386_follow_jump and i386_analyze_frame_setup. (i386_skip_prologue): Pass architecture to i386_analyze_prologue and i386_follow_jump. (i386_frame_cache): Pass architecture to i386_analyze_prologue. (i386_pe_skip_trampoline_code): Add FRAME parameter. * i386-tdep.h (i386_pe_skip_trampoline_code): Add FRAME parameter. * i386-cygwin-tdep.c (i386_cygwin_skip_trampoline_code): Pass frame to i386_pe_skip_trampoline_code. * ia64-tdep.h (struct gdbarch_tdep): Add GDBARCH parameter to sigcontext_register_address callback. * ia64-tdep.c (ia64_find_global_pointer): Add GDBARCH parameter. (ia64_find_unwind_table): Pass architecture to ia64_find_global_pointer. (find_extant_func_descr): Add GDBARCH parameter. (find_func_descr): Pass architecture to find_extant_func_descr and ia64_find_global_pointer. (ia64_sigtramp_frame_init_saved_regs): Pass architecture to tdep->sigcontext_register_address callback. * ia64-linux-tdep.c (ia64_linux_sigcontext_register_address): Add GDBARCH parameter. * iq2000-tdep.c (iq2000_scan_prologue): Add GDBARCH parameter. (iq2000_frame_cache): Pass architecture to iq2000_scan_prologue. * lm32-tdep.c (lm32_analyze_prologue): Add GDBARCH parameter. (lm32_skip_prologue, lm32_frame_cache): Pass architecture to lm32_analyze_prologue. * m32r-tdep.c (decode_prologue): Add GDBARCH parameter. (m32r_skip_prologue): Pass architecture to decode_prologue. * m68hc11-tdep.c (m68hc11_analyze_instruction): Add GDBARCH parameter. (m68hc11_scan_prologue): Pass architecture to m68hc11_analyze_instruction. * m68k-tdep.c (m68k_analyze_frame_setup): Add GDBARCH parameter. (m68k_analyze_prologue): Pass architecture to m68k_analyze_frame_setup. * m88k-tdep.c (m88k_fetch_instruction): Add BYTE_ORDER parameter. (m88k_analyze_prologue): Add GDBARCH parameter. Pass byte order to m88k_fetch_instruction. (m88k_skip_prologue): Pass architecture to m88k_analyze_prologue. (m88k_frame_cache): Likewise. * mep-tdep.c (mep_get_insn): Add GDBARCH parameter. (mep_analyze_prologue): Pass architecture to mep_get_insn. * mips-tdep.c (mips_fetch_instruction): Add GDBARCH parameter. (mips32_next_pc): Pass architecture to mips_fetch_instruction. (deal_with_atomic_sequence): Likewise. (unpack_mips16): Add GDBARCH parameter, pass to mips_fetch_instruction. (mips16_scan_prologue): Likewise. (mips32_scan_prologue): Likewise. (mips16_in_function_epilogue_p): Likewise. (mips32_in_function_epilogue_p): Likewise. (mips_about_to_return): Likewise. (mips_insn16_frame_cache): Pass architecture to mips16_scan_prologue. (mips_insn32_frame_cache): Pass architecture to mips32_scan_prologue. (mips_skip_prologue): Pass architecture to mips16_scan_prologue and mips32_scan_prologue. (mips_in_function_epilogue_p): Pass architecture to mips16_in_function_epilogue_p and mips32_in_function_epilogue_p. (heuristic_proc_start): Pass architecture to mips_fetch_instruction and mips_about_to_return. (mips_skip_mips16_trampoline_code): Pass architecture to mips_fetch_instruction. (fetch_mips_16): Add GDBARCH parameter. (mips16_next_pc): Pass architecture to fetch_mips_16. (extended_mips16_next_pc): Pass architecture to unpack_mips16 and fetch_mips_16. * objc-lang.c (read_objc_method, read_objc_methlist_nmethods, read_objc_methlist_method, read_objc_object, read_objc_super, read_objc_class): Add GDBARCH parameter. (find_implementation_from_class): Add GDBARCH parameter, pass to read_objc_class, read_objc_methlist_nmethods, and read_objc_methlist_method. (find_implementation): Add GDBARCH parameter, pass to read_objc_object and find_implementation_from_class. (resolve_msgsend, resolve_msgsend_stret): Pass architecture to find_implementation. (resolve_msgsend_super, resolve_msgsend_super_stret): Pass architecture to read_objc_super and find_implementation_from_class. * ppc64-linux-tdep.c (ppc64_desc_entry_point): Add GDBARCH parameter. (ppc64_standard_linkage1_target, ppc64_standard_linkage2_target, ppc64_standard_linkage3_target): Pass architecture to ppc64_desc_entry_point. * rs6000-tdep.c (bl_to_blrl_insn_p): Add BYTE_ORDER parameter. (skip_prologue): Pass byte order to bl_to_blrl_insn_p. (rs6000_fetch_instruction): Add GDBARCH parameter. (rs6000_skip_stack_check): Add GDBARCH parameter, pass to rs6000_fetch_instruction. (skip_prologue): Pass architecture to rs6000_fetch_instruction. * remote-mips.c (mips_store_word): Return old_contents as host integer value instead of target bytes. * s390-tdep.c (struct s390_prologue_data): Add BYTE_ORDER member. (s390_analyze_prologue): Initialize it. (extend_simple_arg): Add GDBARCH parameter. (s390_push_dummy_call): Pass architecture to extend_simple_arg. * scm-lang.c (scm_get_field): Add BYTE_ORDER parameter. * scm-lang.h (scm_get_field): Add BYTE_ORDER parameter. (SCM_CAR, SCM_CDR): Pass SCM_BYTE_ORDER to scm_get_field. * scm-valprint.c (scm_scmval_print): Likewise. (scm_scmlist_print, scm_ipruk, scm_scmval_print): Define SCM_BYTE_ORDER. * sh64-tdep.c (look_for_args_moves): Add GDBARCH parameter. (sh64_skip_prologue_hard_way): Add GDBARCH parameter, pass to look_for_args_moves. (sh64_skip_prologue): Pass architecture to sh64_skip_prologue_hard_way. * sh-tdep.c (sh_analyze_prologue): Add GDBARCH parameter. (sh_skip_prologue): Pass architecture to sh_analyze_prologue. (sh_frame_cache): Likewise. * solib-irix.c (extract_mips_address): Add GDBARCH parameter. (fetch_lm_info, irix_current_sos, irix_open_symbol_file_object): Pass architecture to extract_mips_address. * sparc-tdep.h (sparc_fetch_wcookie): Add GDBARCH parameter. * sparc-tdep.c (sparc_fetch_wcookie): Add GDBARCH parameter. (sparc_supply_rwindow, sparc_collect_rwindow): Pass architecture to sparc_fetch_wcookie. (sparc32_frame_prev_register): Likewise. * sparc64-tdep.c (sparc64_frame_prev_register): Likewise. * sparc32nbsd-tdep.c (sparc32nbsd_sigcontext_saved_regs): Likewise. * sparc64nbsd-tdep.c (sparc64nbsd_sigcontext_saved_regs): Likewise. * spu-tdep.c (spu_analyze_prologue): Add GDBARCH parameter. (spu_skip_prologue): Pass architecture to spu_analyze_prologue. (spu_virtual_frame_pointer): Likewise. (spu_frame_unwind_cache): Likewise. (info_spu_mailbox_list): Add BYTE_ORER parameter. (info_spu_mailbox_command): Pass byte order to info_spu_mailbox_list. (info_spu_dma_cmdlist): Add BYTE_ORER parameter. (info_spu_dma_command, info_spu_proxydma_command): Pass byte order to info_spu_dma_cmdlist. * symfile.c (read_target_long_array): Add GDBARCH parameter. (simple_read_overlay_table, simple_read_overlay_region_table, simple_overlay_update_1): Pass architecture to read_target_long_array. * v850-tdep.c (v850_analyze_prologue): Add GDBARCH parameter. (v850_frame_cache): Pass architecture to v850_analyze_prologue. * xstormy16-tdep.c (xstormy16_analyze_prologue): Add GDBARCH parameter. (xstormy16_skip_prologue, xstormy16_frame_cache): Pass architecture to xstormy16_analyze_prologue. (xstormy16_resolve_jmp_table_entry): Add GDBARCH parameter. (xstormy16_find_jmp_table_entry): Likewise. (xstormy16_skip_trampoline_code): Pass architecture to xstormy16_resolve_jmp_table_entry. (xstormy16_pointer_to_address): Likewise. (xstormy16_address_to_pointer): Pass architecture to xstormy16_find_jmp_table_entry. * xtensa-tdep.c (call0_track_op): Add GDBARCH parameter. (call0_analyze_prologue): Add GDBARCH parameter, pass to call0_track_op. (call0_frame_cache): Pass architecture to call0_analyze_prologue. (xtensa_skip_prologue): Likewise.
2009-07-02 19:25:59 +02:00
store_unsigned_integer (buf, TYPE_LENGTH (type), byte_order, addr);
* gdbarch.sh (POINTER_TO_ADDRESS, ADDRESS_TO_POINTER): Two new functions which architectures can redefine, defaulting to generic_pointer_to_address and generic_address_to_pointer. * findvar.c (extract_typed_address, store_typed_address, generic_pointer_to_address, generic_address_to_pointer): New functions. (POINTER_TO_ADDRESS, ADDRESS_TO_POINTER): Provide default definitions. (extract_address, store_address): Doc fixes. * values.c (value_as_pointer): Doc fix. (value_from_pointer): New function. * defs.h (extract_typed_address, store_typed_address): New declarations. * inferior.h (generic_address_to_pointer, generic_pointer_to_address): New declarations. * value.h (value_from_pointer): New declaration. * ax-gdb.c (const_var_ref): Use value_from_pointer, not value_from_longest. * blockframe.c (generic_push_dummy_frame): Use read_pc and read_sp, not read_register. * c-valprint.c (c_val_print): Use extract_typed_address instead of extract_address to extract vtable entries and references. * cp-valprint.c (cp_print_value_fields): Use value_from_pointer instead of value_from_longest to extract the vtable's address. * eval.c (evaluate_subexp_standard): Use value_from_pointer instead of value_from_longest to compute `this', and for doing pointer-to-member dereferencing. * findvar.c (read_register): Use extract_unsigned_integer, not extract_address. (read_var_value): Use store_typed_address instead of store_address for building label values. (locate_var_value): Use value_from_pointer instead of value_from_longest. * hppa-tdep.c (find_stub_with_shl_get): Use value_from_pointer, instead of value_from_longest, to build arguments to __d_shl_get. * printcmd.c (set_next_address): Use value_from_pointer, not value_from_longest. (x_command): Use value_from_pointer, not value_from_longest. * tracepoint.c (set_traceframe_context): Use value_from_pointer, not value_from_longest. * valarith.c (value_add, value_sub): Use value_from_pointer, not value_from_longest. * valops.c (find_function_in_inferior, value_coerce_array, value_coerce_function, value_addr, hand_function_call): Same. * value.h (COERCE_REF): Use unpack_pointer, not unpack_long. * values.c (unpack_long): Use extract_typed_address to produce addresses from pointers and references, not extract_address. (value_from_longest): Use store_typed_address instead of store_address to produce pointer and reference values.
2000-04-14 20:43:41 +02:00
}
void
address_to_signed_pointer (struct gdbarch *gdbarch, struct type *type,
gdb_byte *buf, CORE_ADDR addr)
{
Adjust byte order variable display/change if DW_AT_endianity is present. - 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
2017-10-06 22:13:04 +02:00
enum bfd_endian byte_order = type_byte_order (type);
* defs.h (extract_signed_integer, extract_unsigned_integer, extract_long_unsigned_integer, store_signed_integer, store_unsigned_integer): Add BYTE_ORDER parameter. * findvar.c (extract_signed_integer, extract_unsigned_integer, extract_long_unsigned_integer, store_signed_integer, store_unsigned_integer): Add BYTE_ORDER parameter. Use it instead of current_gdbarch. * gdbcore.h (read_memory_integer, safe_read_memory_integer, read_memory_unsigned_integer, write_memory_signed_integer, write_memory_unsigned_integer): Add BYTE_ORDER parameter. * corefile.c (struct captured_read_memory_integer_arguments): Add BYTE_ORDER member. (safe_read_memory_integer): Add BYTE_ORDER parameter. Store it into struct captured_read_memory_integer_arguments. (do_captured_read_memory_integer): Pass it to read_memory_integer. (read_memory_integer): Add BYTE_ORDER parameter. Pass it to extract_signed_integer. (read_memory_unsigned_integer): Add BYTE_ORDER parameter. Pass it to extract_unsigned_integer. (write_memory_signed_integer): Add BYTE_ORDER parameter. Pass it to store_signed_integer. (write_memory_unsigned_integer): Add BYTE_ORDER parameter. Pass it to store_unsigned_integer. * target.h (get_target_memory_unsigned): Add BYTE_ORDER parameter. * target.c (get_target_memory_unsigned): Add BYTE_ORDER parameter. Pass it to extract_unsigned_integer. Update calls to extract_signed_integer, extract_unsigned_integer, extract_long_unsigned_integer, store_signed_integer, store_unsigned_integer, read_memory_integer, read_memory_unsigned_integer, safe_read_memory_integer, write_memory_signed_integer, write_memory_unsigned_integer, and get_target_memory_unsigned to pass byte order: * ada-lang.c (ada_value_binop): Update. * ada-valprint.c (char_at): Update. * alpha-osf1-tdep.c (alpha_osf1_sigcontext_addr): Update. * alpha-tdep.c (alpha_lds, alpha_sts, alpha_push_dummy_call, alpha_extract_return_value, alpha_read_insn, alpha_get_longjmp_target): Update. * amd64-linux-tdep.c (amd64_linux_sigcontext_addr): Update. * amd64obsd-tdep.c (amd64obsd_supply_uthread, amd64obsd_collect_uthread, amd64obsd_trapframe_cache): Update. * amd64-tdep.c (amd64_push_dummy_call, amd64_analyze_prologue, amd64_frame_cache, amd64_sigtramp_frame_cache, fixup_riprel, amd64_displaced_step_fixup): Update. * arm-linux-tdep.c (arm_linux_sigreturn_init, arm_linux_rt_sigreturn_init, arm_linux_supply_gregset): Update. * arm-tdep.c (thumb_analyze_prologue, arm_skip_prologue, arm_scan_prologue, arm_push_dummy_call, thumb_get_next_pc, arm_get_next_pc, arm_extract_return_value, arm_store_return_value, arm_return_value): Update. * arm-wince-tdep.c (arm_pe_skip_trampoline_code): Update. * auxv.c (default_auxv_parse): Update. * avr-tdep.c (avr_address_to_pointer, avr_pointer_to_address, avr_scan_prologue, avr_extract_return_value, avr_frame_prev_register, avr_push_dummy_call): Update. * bsd-uthread.c (bsd_uthread_check_magic, bsd_uthread_lookup_offset, bsd_uthread_wait, bsd_uthread_thread_alive, bsd_uthread_extra_thread_info): Update. * c-lang.c (c_printstr, print_wchar): Update. * cp-valprint.c (cp_print_class_member): Update. * cris-tdep.c (cris_sigcontext_addr, cris_sigtramp_frame_unwind_cache, cris_push_dummy_call, cris_scan_prologue, cris_store_return_value, cris_extract_return_value, find_step_target, dip_prefix, sixteen_bit_offset_branch_op, none_reg_mode_jump_op, move_mem_to_reg_movem_op, get_data_from_address): Update. * dwarf2expr.c (dwarf2_read_address, execute_stack_op): Update. * dwarf2-frame.c (execute_cfa_program): Update. * dwarf2loc.c (find_location_expression): Update. * dwarf2read.c (dwarf2_const_value): Update. * expprint.c (print_subexp_standard): Update. * findvar.c (unsigned_pointer_to_address, signed_pointer_to_address, unsigned_address_to_pointer, address_to_signed_pointer, read_var_value): Update. * frame.c (frame_unwind_register_signed, frame_unwind_register_unsigned, get_frame_memory_signed, get_frame_memory_unsigned): Update. * frame-unwind.c (frame_unwind_got_constant): Update. * frv-linux-tdep.c (frv_linux_pc_in_sigtramp, frv_linux_sigcontext_reg_addr, frv_linux_sigtramp_frame_cache): Update. * frv-tdep.c (frv_analyze_prologue, frv_skip_main_prologue, frv_extract_return_value, find_func_descr, frv_convert_from_func_ptr_addr, frv_push_dummy_call): Update. * f-valprint.c (f_val_print): Update. * gnu-v3-abi.c (gnuv3_decode_method_ptr, gnuv3_make_method_ptr): Update. * h8300-tdep.c (h8300_is_argument_spill, h8300_analyze_prologue, h8300_push_dummy_call, h8300_extract_return_value, h8300h_extract_return_value, h8300_store_return_value, h8300h_store_return_value): Update. * hppabsd-tdep.c (hppabsd_find_global_pointer): Update. * hppa-hpux-nat.c (hppa_hpux_fetch_register, hppa_hpux_store_register): Update. * hppa-hpux-tdep.c (hppa32_hpux_in_solib_call_trampoline, hppa64_hpux_in_solib_call_trampoline, hppa_hpux_in_solib_return_trampoline, hppa_hpux_skip_trampoline_code, hppa_hpux_sigtramp_frame_unwind_cache, hppa_hpux_sigtramp_unwind_sniffer, hppa32_hpux_find_global_pointer, hppa64_hpux_find_global_pointer, hppa_hpux_search_pattern, hppa32_hpux_search_dummy_call_sequence, hppa64_hpux_search_dummy_call_sequence, hppa_hpux_supply_save_state, hppa_hpux_unwind_adjust_stub): Update. * hppa-linux-tdep.c (insns_match_pattern, hppa_linux_find_global_pointer): Update. * hppa-tdep.c (hppa_in_function_epilogue_p, hppa32_push_dummy_call, hppa64_convert_code_addr_to_fptr, hppa64_push_dummy_call, skip_prologue_hard_way, hppa_frame_cache, hppa_fallback_frame_cache, hppa_pseudo_register_read, hppa_frame_prev_register_helper, hppa_match_insns): Update. * hpux-thread.c (hpux_thread_fetch_registers): Update. * i386-tdep.c (i386bsd_sigcontext_addr): Update. * i386-cygwin-tdep.c (core_process_module_section): Update. * i386-darwin-nat.c (i386_darwin_sstep_at_sigreturn, amd64_darwin_sstep_at_sigreturn): Update. * i386-darwin-tdep.c (i386_darwin_sigcontext_addr, amd64_darwin_sigcontext_addr): Likewise. * i386-linux-nat.c (i386_linux_sigcontext_addr): Update. * i386nbsd-tdep.c (i386nbsd_sigtramp_cache_init): Update. * i386-nto-tdep.c (i386nto_sigcontext_addr): Update. * i386obsd-nat.c (i386obsd_supply_pcb): Update. * i386obsd-tdep.c (i386obsd_supply_uthread, i386obsd_collect_uthread, i386obsd_trapframe_cache): Update. * i386-tdep.c (i386_displaced_step_fixup, i386_follow_jump, i386_analyze_frame_setup, i386_analyze_prologue, i386_skip_main_prologue, i386_frame_cache, i386_sigtramp_frame_cache, i386_get_longjmp_target, i386_push_dummy_call, i386_pe_skip_trampoline_code, i386_svr4_sigcontext_addr, i386_fetch_pointer_argument): Update. * i387-tdep.c (i387_supply_fsave): Update. * ia64-linux-tdep.c (ia64_linux_sigcontext_register_address): Update. * ia64-tdep.c (ia64_pseudo_register_read, ia64_pseudo_register_write, examine_prologue, ia64_frame_cache, ia64_frame_prev_register, ia64_sigtramp_frame_cache, ia64_sigtramp_frame_prev_register, ia64_access_reg, ia64_access_rse_reg, ia64_libunwind_frame_this_id, ia64_libunwind_frame_prev_register, ia64_libunwind_sigtramp_frame_this_id, ia64_libunwind_sigtramp_frame_prev_register, ia64_find_global_pointer, find_extant_func_descr, find_func_descr, ia64_convert_from_func_ptr_addr, ia64_push_dummy_call, ia64_dummy_id, ia64_unwind_pc): Update. * iq2000-tdep.c (iq2000_pointer_to_address, iq2000_address_to_pointer, iq2000_scan_prologue, iq2000_extract_return_value, iq2000_push_dummy_call): Update. * irix5nat.c (fill_gregset): Update. * jv-lang.c (evaluate_subexp_java): Update. * jv-valprint.c (java_value_print): Update. * lm32-tdep.c (lm32_analyze_prologue, lm32_push_dummy_call, lm32_extract_return_value, lm32_store_return_value): Update. * m32c-tdep.c (m32c_push_dummy_call, m32c_return_value, m32c_skip_trampoline_code, m32c_m16c_address_to_pointer, m32c_m16c_pointer_to_address): Update. * m32r-tdep.c (m32r_store_return_value, decode_prologue, m32r_skip_prologue, m32r_push_dummy_call, m32r_extract_return_value): Update. * m68hc11-tdep.c (m68hc11_pseudo_register_read, m68hc11_pseudo_register_write, m68hc11_analyze_instruction, m68hc11_push_dummy_call): Update. * m68linux-tdep.c (m68k_linux_pc_in_sigtramp, m68k_linux_get_sigtramp_info, m68k_linux_sigtramp_frame_cache): Update. * m68k-tdep.c (m68k_push_dummy_call, m68k_analyze_frame_setup, m68k_analyze_register_saves, m68k_analyze_prologue, m68k_frame_cache, m68k_get_longjmp_target): Update. * m88k-tdep.c (m88k_fetch_instruction): Update. * mep-tdep.c (mep_pseudo_cr32_read, mep_pseudo_csr_write, mep_pseudo_cr32_write, mep_get_insn, mep_push_dummy_call): Update. * mi/mi-main.c (mi_cmd_data_write_memory): Update. * mips-linux-tdep.c (mips_linux_get_longjmp_target, supply_32bit_reg, mips64_linux_get_longjmp_target, mips64_fill_gregset, mips64_fill_fpregset, mips_linux_in_dynsym_stub): Update. * mipsnbdsd-tdep.c (mipsnbsd_get_longjmp_target): Update. * mips-tdep.c (mips_fetch_instruction, fetch_mips_16, mips_eabi_push_dummy_call, mips_n32n64_push_dummy_call, mips_o32_push_dummy_call, mips_o64_push_dummy_call, mips_single_step_through_delay, mips_skip_pic_trampoline_code, mips_integer_to_address): Update. * mn10300-tdep.c (mn10300_analyze_prologue, mn10300_push_dummy_call): Update. * monitor.c (monitor_supply_register, monitor_write_memory, monitor_read_memory_single): Update. * moxie-tdep.c (moxie_store_return_value, moxie_extract_return_value, moxie_analyze_prologue): Update. * mt-tdep.c (mt_return_value, mt_skip_prologue, mt_select_coprocessor, mt_pseudo_register_read, mt_pseudo_register_write, mt_registers_info, mt_push_dummy_call): Update. * objc-lang.c (read_objc_method, read_objc_methlist_nmethods, read_objc_methlist_method, read_objc_object, read_objc_super, read_objc_class, find_implementation_from_class): Update. * ppc64-linux-tdep.c (ppc64_desc_entry_point, ppc64_linux_convert_from_func_ptr_addr, ppc_linux_sigtramp_cache): Update. * ppcobsd-tdep.c (ppcobsd_sigtramp_frame_sniffer, ppcobsd_sigtramp_frame_cache): Update. * ppc-sysv-tdep.c (ppc_sysv_abi_push_dummy_call, do_ppc_sysv_return_value, ppc64_sysv_abi_push_dummy_call, ppc64_sysv_abi_return_value): Update. * ppc-linux-nat.c (ppc_linux_auxv_parse): Update. * procfs.c (procfs_auxv_parse): Update. * p-valprint.c (pascal_val_print): Update. * regcache.c (regcache_raw_read_signed, regcache_raw_read_unsigned, regcache_raw_write_signed, regcache_raw_write_unsigned, regcache_cooked_read_signed, regcache_cooked_read_unsigned, regcache_cooked_write_signed, regcache_cooked_write_unsigned): Update. * remote-m32r-sdi.c (m32r_fetch_register): Update. * remote-mips.c (mips_wait, mips_fetch_registers, mips_xfer_memory): Update. * rs6000-aix-tdep.c (rs6000_push_dummy_call, rs6000_return_value, rs6000_convert_from_func_ptr_addr, branch_dest, rs6000_software_single_step): Update. * rs6000-tdep.c (rs6000_in_function_epilogue_p, ppc_displaced_step_fixup, ppc_deal_with_atomic_sequence, bl_to_blrl_insn_p, rs6000_fetch_instruction, skip_prologue, rs6000_skip_main_prologue, rs6000_skip_trampoline_code, rs6000_frame_cache): Update. * s390-tdep.c (s390_pseudo_register_read, s390_pseudo_register_write, s390x_pseudo_register_read, s390x_pseudo_register_write, s390_load, s390_backchain_frame_unwind_cache, s390_sigtramp_frame_unwind_cache, extend_simple_arg, s390_push_dummy_call, s390_return_value): Update. * scm-exp.c (scm_lreadr): Update. * scm-lang.c (scm_get_field, scm_unpack): Update. * scm-valprint.c (scm_val_print): Update. * score-tdep.c (score_breakpoint_from_pc, score_push_dummy_call, score_fetch_inst): Update. * sh64-tdep.c (look_for_args_moves, sh64_skip_prologue_hard_way, sh64_analyze_prologue, sh64_push_dummy_call, sh64_extract_return_value, sh64_pseudo_register_read, sh64_pseudo_register_write, sh64_frame_prev_register): Update: * sh-tdep.c (sh_analyze_prologue, sh_push_dummy_call_fpu, sh_push_dummy_call_nofpu, sh_extract_return_value_nofpu, sh_store_return_value_nofpu, sh_in_function_epilogue_p): Update. * solib-darwin.c (darwin_load_image_infos): Update. * solib-frv.c (fetch_loadmap, lm_base, frv_current_sos, enable_break2, find_canonical_descriptor_in_load_object): Update. * solib-irix.c (extract_mips_address, fetch_lm_info, irix_current_sos, irix_open_symbol_file_object): Update. * solib-som.c (som_solib_create_inferior_hook, link_map_start, som_current_sos, som_open_symbol_file_object): Update. * solib-sunos.c (SOLIB_EXTRACT_ADDRESS, LM_ADDR, LM_NEXT, LM_NAME): Update. * solib-svr4.c (read_program_header, scan_dyntag_auxv, solib_svr4_r_ldsomap): Update. * sparc64-linux-tdep.c (sparc64_linux_step_trap): Update. * sparc64obsd-tdep.c (sparc64obsd_supply_uthread, sparc64obsd_collect_uthread): Update. * sparc64-tdep.c (sparc64_pseudo_register_read, sparc64_pseudo_register_write, sparc64_supply_gregset, sparc64_collect_gregset): Update. * sparc-linux-tdep.c (sparc32_linux_step_trap): Update. * sparcobsd-tdep.c (sparc32obsd_supply_uthread, sparc32obsd_collect_uthread): Update. * sparc-tdep.c (sparc_fetch_wcookie, sparc32_push_dummy_code, sparc32_store_arguments, sparc32_return_value, sparc_supply_rwindow, sparc_collect_rwindow): Update. * spu-linux-nat.c (parse_spufs_run): Update. * spu-tdep.c (spu_pseudo_register_read_spu, spu_pseudo_register_write_spu, spu_pointer_to_address, spu_analyze_prologue, spu_in_function_epilogue_p, spu_frame_unwind_cache, spu_push_dummy_call, spu_software_single_step, spu_get_longjmp_target, spu_get_overlay_table, spu_overlay_update_osect, info_spu_signal_command, info_spu_mailbox_list, info_spu_dma_cmdlist, info_spu_dma_command, info_spu_proxydma_command): Update. * stack.c (print_frame_nameless_args, frame_info): Update. * symfile.c (read_target_long_array, simple_read_overlay_table, simple_read_overlay_region_table): Update. * target.c (debug_print_register): Update. * tramp-frame.c (tramp_frame_start): Update. * v850-tdep.c (v850_analyze_prologue, v850_push_dummy_call, v850_extract_return_value, v850_store_return_value, * valarith.c (value_binop, value_bit_index): Update. * valops.c (value_cast): Update. * valprint.c (val_print_type_code_int, val_print_string, read_string): Update. * value.c (unpack_long, unpack_double, unpack_field_as_long, modify_field, pack_long): Update. * vax-tdep.c (vax_store_arguments, vax_push_dummy_call, vax_skip_prologue): Update. * xstormy16-tdep.c (xstormy16_push_dummy_call, xstormy16_analyze_prologue, xstormy16_in_function_epilogue_p, xstormy16_resolve_jmp_table_entry, xstormy16_find_jmp_table_entry, xstormy16_pointer_to_address, xstormy16_address_to_pointer): Update. * xtensa-tdep.c (extract_call_winsize, xtensa_pseudo_register_read, xtensa_pseudo_register_write, xtensa_frame_cache, xtensa_push_dummy_call, call0_track_op, call0_frame_cache): Update. * dfp.h (decimal_to_string, decimal_from_string, decimal_from_integral, decimal_from_floating, decimal_to_doublest, decimal_is_zero): Add BYTE_ORDER parameter. (decimal_binop): Add BYTE_ORDER_X, BYTE_ORDER_Y, and BYTE_ORDER_RESULT parameters. (decimal_compare): Add BYTE_ORDER_X and BYTE_ORDER_Y parameters. (decimal_convert): Add BYTE_ORDER_FROM and BYTE_ORDER_TO parameters. * dfp.c (match_endianness): Add BYTE_ORDER parameter. Use it instead of current_gdbarch. (decimal_to_string, decimal_from_integral, decimal_from_floating, decimal_to_doublest, decimal_is_zero): Add BYTE_ORDER parameter. Pass it to match_endianness. (decimal_binop): Add BYTE_ORDER_X, BYTE_ORDER_Y, and BYTE_ORDER_RESULT parameters. Pass them to match_endianness. (decimal_compare): Add BYTE_ORDER_X and BYTE_ORDER_Y parameters. Pass them to match_endianness. (decimal_convert): Add BYTE_ORDER_FROM and BYTE_ORDER_TO parameters. Pass them to match_endianness. * valarith.c (value_args_as_decimal): Add BYTE_ORDER_X and BYTE_ORDER_Y output parameters. (value_binop): Update call to value_args_as_decimal. Update calls to decimal_to_string, decimal_from_string, decimal_from_integral, decimal_from_floating, decimal_to_doublest, decimal_is_zero, decimal_binop, decimal_compare and decimal_convert to pass/receive byte order: * c-exp.y (parse_number): Update. * printcmd.c (printf_command): Update. * valarith.c (value_args_as_decimal, value_binop, value_logical_not, value_equal, value_less): Update. * valops.c (value_cast, value_one): Update. * valprint.c (print_decimal_floating): Update. * value.c (unpack_long, unpack_double): Update. * python/python-value.c (valpy_nonzero): Update. * ada-valprint.c (char_at): Add BYTE_ORDER parameter. (printstr): Update calls to char_at. (ada_val_print_array): Likewise. * valprint.c (read_string): Add BYTE_ORDER parameter. (val_print_string): Update call to read_string. * c-lang.c (c_get_string): Likewise. * charset.h (target_wide_charset): Add BYTE_ORDER parameter. * charset.c (target_wide_charset): Add BYTE_ORDER parameter. Use it instead of current_gdbarch. * printcmd.c (printf_command): Update calls to target_wide_charset. * c-lang.c (charset_for_string_type): Add BYTE_ORDER parameter. Pass to target_wide_charset. Use it instead of current_gdbarch. (classify_type): Add BYTE_ORDER parameter. Pass to charset_for_string_type. Allow NULL encoding pointer. (print_wchar): Add BYTE_ORDER parameter. (c_emit_char): Update calls to classify_type and print_wchar. (c_printchar, c_printstr): Likewise. * gdbarch.sh (in_solib_return_trampoline): Convert to type "m". * gdbarch.c, gdbarch.h: Regenerate. * arch-utils.h (generic_in_solib_return_trampoline): Add GDBARCH parameter. * arch-utils.c (generic_in_solib_return_trampoline): Likewise. * hppa-hpux-tdep.c (hppa_hpux_in_solib_return_trampoline): Likewise. * rs6000-tdep.c (rs6000_in_solib_return_trampoline): Likewise. (rs6000_skip_trampoline_code): Update call. * alpha-tdep.h (struct gdbarch_tdep): Add GDBARCH parameter to dynamic_sigtramp_offset and pc_in_sigtramp callbacks. (alpha_read_insn): Add GDBARCH parameter. * alpha-tdep.c (alpha_lds, alpha_sts): Add GDBARCH parameter. (alpha_register_to_value): Pass architecture to alpha_sts. (alpha_extract_return_value): Likewise. (alpha_value_to_register): Pass architecture to alpha_lds. (alpha_store_return_value): Likewise. (alpha_read_insn): Add GDBARCH parameter. (alpha_skip_prologue): Pass architecture to alpha_read_insn. (alpha_heuristic_proc_start): Likewise. (alpha_heuristic_frame_unwind_cache): Likewise. (alpha_next_pc): Likewise. (alpha_sigtramp_frame_this_id): Pass architecture to tdep->dynamic_sigtramp_offset callback. (alpha_sigtramp_frame_sniffer): Pass architecture to tdep->pc_in_sigtramp callback. * alphafbsd-tdep.c (alphafbsd_pc_in_sigtramp): Add GDBARCH parameter. (alphafbsd_sigtramp_offset): Likewise. * alpha-linux-tdep.c (alpha_linux_sigtramp_offset_1): Add GDBARCH parameter. Pass to alpha_read_insn. (alpha_linux_sigtramp_offset): Add GDBARCH parameter. Pass to alpha_linux_sigtramp_offset_1. (alpha_linux_pc_in_sigtramp): Add GDBARCH parameter. Pass to alpha_linux_sigtramp_offset. (alpha_linux_sigcontext_addr): Pass architecture to alpha_read_insn and alpha_linux_sigtramp_offset. * alphanbsd-tdep.c (alphanbsd_sigtramp_offset): Add GDBARCH parameter. (alphanbsd_pc_in_sigtramp): Add GDBARCH parameter. Pass to alphanbsd_sigtramp_offset. * alphaobsd-tdep.c (alphaobsd_sigtramp_offset): Add GDBARCH parameter. (alphaobsd_pc_in_sigtramp): Add GDBARCH parameter. Pass to alpha_read_insn. (alphaobsd_sigcontext_addr): Pass architecture to alphaobsd_sigtramp_offset. * alpha-osf1-tdep.c (alpha_osf1_pc_in_sigtramp): Add GDBARCH parameter. * amd64-tdep.c (amd64_analyze_prologue): Add GDBARCH parameter. (amd64_skip_prologue): Pass architecture to amd64_analyze_prologue. (amd64_frame_cache): Likewise. * arm-tdep.c (SWAP_SHORT, SWAP_INT): Remove. (thumb_analyze_prologue, arm_skip_prologue, arm_scan_prologue, thumb_get_next_pc, arm_get_next_pc): Do not use SWAP_ macros. * arm-wince-tdep.c: Include "frame.h". * avr-tdep.c (EXTRACT_INSN): Remove. (avr_scan_prologue): Add GDBARCH argument, inline EXTRACT_INSN. (avr_skip_prologue): Pass architecture to avr_scan_prologue. (avr_frame_unwind_cache): Likewise. * cris-tdep.c (struct instruction_environment): Add BYTE_ORDER member. (find_step_target): Initialize it. (get_data_from_address): Add BYTE_ORDER parameter. (bdap_prefix): Pass byte order to get_data_from_address. (handle_prefix_assign_mode_for_aritm_op): Likewise. (three_operand_add_sub_cmp_and_or_op): Likewise. (handle_inc_and_index_mode_for_aritm_op): Likewise. * frv-linux-tdep.c (frv_linux_pc_in_sigtramp): Add GDBARCH parameter. (frv_linux_sigcontext_reg_addr): Pass architecture to frv_linux_pc_in_sigtramp. (frv_linux_sigtramp_frame_sniffer): Likewise. * h8300-tdep.c (h8300_is_argument_spill): Add GDBARCH parameter. (h8300_analyze_prologue): Add GDBARCH parameter. Pass to h8300_is_argument_spill. (h8300_frame_cache, h8300_skip_prologue): Pass architecture to h8300_analyze_prologue. * hppa-tdep.h (struct gdbarch_tdep): Add GDBARCH parameter to in_solib_call_trampoline callback. (hppa_in_solib_call_trampoline): Add GDBARCH parameter. * hppa-tdep.c (hppa64_convert_code_addr_to_fptr): Add GDBARCH parameter. (hppa64_push_dummy_call): Pass architecture to hppa64_convert_code_addr_to_fptr. (hppa_match_insns): Add GDBARCH parameter. (hppa_match_insns_relaxed): Add GDBARCH parameter. Pass to hppa_match_insns. (hppa_skip_trampoline_code): Pass architecture to hppa_match_insns. (hppa_in_solib_call_trampoline): Add GDBARCH parameter. Pass to hppa_match_insns_relaxed. (hppa_stub_unwind_sniffer): Pass architecture to tdep->in_solib_call_trampoline callback. * hppa-hpux-tdep.c (hppa_hpux_search_pattern): Add GDBARCH parameter. (hppa32_hpux_search_dummy_call_sequence): Pass architecture to hppa_hpux_search_pattern. * hppa-linux-tdep.c (insns_match_pattern): Add GDBARCH parameter. (hppa_linux_sigtramp_find_sigcontext): Add GDBARCH parameter. Pass to insns_match_pattern. (hppa_linux_sigtramp_frame_unwind_cache): Pass architecture to hppa_linux_sigtramp_find_sigcontext. (hppa_linux_sigtramp_frame_sniffer): Likewise. (hppa32_hpux_in_solib_call_trampoline): Add GDBARCH parameter. (hppa64_hpux_in_solib_call_trampoline): Likewise. * i386-tdep.c (i386_follow_jump): Add GDBARCH parameter. (i386_analyze_frame_setup): Add GDBARCH parameter. (i386_analyze_prologue): Add GDBARCH parameter. Pass to i386_follow_jump and i386_analyze_frame_setup. (i386_skip_prologue): Pass architecture to i386_analyze_prologue and i386_follow_jump. (i386_frame_cache): Pass architecture to i386_analyze_prologue. (i386_pe_skip_trampoline_code): Add FRAME parameter. * i386-tdep.h (i386_pe_skip_trampoline_code): Add FRAME parameter. * i386-cygwin-tdep.c (i386_cygwin_skip_trampoline_code): Pass frame to i386_pe_skip_trampoline_code. * ia64-tdep.h (struct gdbarch_tdep): Add GDBARCH parameter to sigcontext_register_address callback. * ia64-tdep.c (ia64_find_global_pointer): Add GDBARCH parameter. (ia64_find_unwind_table): Pass architecture to ia64_find_global_pointer. (find_extant_func_descr): Add GDBARCH parameter. (find_func_descr): Pass architecture to find_extant_func_descr and ia64_find_global_pointer. (ia64_sigtramp_frame_init_saved_regs): Pass architecture to tdep->sigcontext_register_address callback. * ia64-linux-tdep.c (ia64_linux_sigcontext_register_address): Add GDBARCH parameter. * iq2000-tdep.c (iq2000_scan_prologue): Add GDBARCH parameter. (iq2000_frame_cache): Pass architecture to iq2000_scan_prologue. * lm32-tdep.c (lm32_analyze_prologue): Add GDBARCH parameter. (lm32_skip_prologue, lm32_frame_cache): Pass architecture to lm32_analyze_prologue. * m32r-tdep.c (decode_prologue): Add GDBARCH parameter. (m32r_skip_prologue): Pass architecture to decode_prologue. * m68hc11-tdep.c (m68hc11_analyze_instruction): Add GDBARCH parameter. (m68hc11_scan_prologue): Pass architecture to m68hc11_analyze_instruction. * m68k-tdep.c (m68k_analyze_frame_setup): Add GDBARCH parameter. (m68k_analyze_prologue): Pass architecture to m68k_analyze_frame_setup. * m88k-tdep.c (m88k_fetch_instruction): Add BYTE_ORDER parameter. (m88k_analyze_prologue): Add GDBARCH parameter. Pass byte order to m88k_fetch_instruction. (m88k_skip_prologue): Pass architecture to m88k_analyze_prologue. (m88k_frame_cache): Likewise. * mep-tdep.c (mep_get_insn): Add GDBARCH parameter. (mep_analyze_prologue): Pass architecture to mep_get_insn. * mips-tdep.c (mips_fetch_instruction): Add GDBARCH parameter. (mips32_next_pc): Pass architecture to mips_fetch_instruction. (deal_with_atomic_sequence): Likewise. (unpack_mips16): Add GDBARCH parameter, pass to mips_fetch_instruction. (mips16_scan_prologue): Likewise. (mips32_scan_prologue): Likewise. (mips16_in_function_epilogue_p): Likewise. (mips32_in_function_epilogue_p): Likewise. (mips_about_to_return): Likewise. (mips_insn16_frame_cache): Pass architecture to mips16_scan_prologue. (mips_insn32_frame_cache): Pass architecture to mips32_scan_prologue. (mips_skip_prologue): Pass architecture to mips16_scan_prologue and mips32_scan_prologue. (mips_in_function_epilogue_p): Pass architecture to mips16_in_function_epilogue_p and mips32_in_function_epilogue_p. (heuristic_proc_start): Pass architecture to mips_fetch_instruction and mips_about_to_return. (mips_skip_mips16_trampoline_code): Pass architecture to mips_fetch_instruction. (fetch_mips_16): Add GDBARCH parameter. (mips16_next_pc): Pass architecture to fetch_mips_16. (extended_mips16_next_pc): Pass architecture to unpack_mips16 and fetch_mips_16. * objc-lang.c (read_objc_method, read_objc_methlist_nmethods, read_objc_methlist_method, read_objc_object, read_objc_super, read_objc_class): Add GDBARCH parameter. (find_implementation_from_class): Add GDBARCH parameter, pass to read_objc_class, read_objc_methlist_nmethods, and read_objc_methlist_method. (find_implementation): Add GDBARCH parameter, pass to read_objc_object and find_implementation_from_class. (resolve_msgsend, resolve_msgsend_stret): Pass architecture to find_implementation. (resolve_msgsend_super, resolve_msgsend_super_stret): Pass architecture to read_objc_super and find_implementation_from_class. * ppc64-linux-tdep.c (ppc64_desc_entry_point): Add GDBARCH parameter. (ppc64_standard_linkage1_target, ppc64_standard_linkage2_target, ppc64_standard_linkage3_target): Pass architecture to ppc64_desc_entry_point. * rs6000-tdep.c (bl_to_blrl_insn_p): Add BYTE_ORDER parameter. (skip_prologue): Pass byte order to bl_to_blrl_insn_p. (rs6000_fetch_instruction): Add GDBARCH parameter. (rs6000_skip_stack_check): Add GDBARCH parameter, pass to rs6000_fetch_instruction. (skip_prologue): Pass architecture to rs6000_fetch_instruction. * remote-mips.c (mips_store_word): Return old_contents as host integer value instead of target bytes. * s390-tdep.c (struct s390_prologue_data): Add BYTE_ORDER member. (s390_analyze_prologue): Initialize it. (extend_simple_arg): Add GDBARCH parameter. (s390_push_dummy_call): Pass architecture to extend_simple_arg. * scm-lang.c (scm_get_field): Add BYTE_ORDER parameter. * scm-lang.h (scm_get_field): Add BYTE_ORDER parameter. (SCM_CAR, SCM_CDR): Pass SCM_BYTE_ORDER to scm_get_field. * scm-valprint.c (scm_scmval_print): Likewise. (scm_scmlist_print, scm_ipruk, scm_scmval_print): Define SCM_BYTE_ORDER. * sh64-tdep.c (look_for_args_moves): Add GDBARCH parameter. (sh64_skip_prologue_hard_way): Add GDBARCH parameter, pass to look_for_args_moves. (sh64_skip_prologue): Pass architecture to sh64_skip_prologue_hard_way. * sh-tdep.c (sh_analyze_prologue): Add GDBARCH parameter. (sh_skip_prologue): Pass architecture to sh_analyze_prologue. (sh_frame_cache): Likewise. * solib-irix.c (extract_mips_address): Add GDBARCH parameter. (fetch_lm_info, irix_current_sos, irix_open_symbol_file_object): Pass architecture to extract_mips_address. * sparc-tdep.h (sparc_fetch_wcookie): Add GDBARCH parameter. * sparc-tdep.c (sparc_fetch_wcookie): Add GDBARCH parameter. (sparc_supply_rwindow, sparc_collect_rwindow): Pass architecture to sparc_fetch_wcookie. (sparc32_frame_prev_register): Likewise. * sparc64-tdep.c (sparc64_frame_prev_register): Likewise. * sparc32nbsd-tdep.c (sparc32nbsd_sigcontext_saved_regs): Likewise. * sparc64nbsd-tdep.c (sparc64nbsd_sigcontext_saved_regs): Likewise. * spu-tdep.c (spu_analyze_prologue): Add GDBARCH parameter. (spu_skip_prologue): Pass architecture to spu_analyze_prologue. (spu_virtual_frame_pointer): Likewise. (spu_frame_unwind_cache): Likewise. (info_spu_mailbox_list): Add BYTE_ORER parameter. (info_spu_mailbox_command): Pass byte order to info_spu_mailbox_list. (info_spu_dma_cmdlist): Add BYTE_ORER parameter. (info_spu_dma_command, info_spu_proxydma_command): Pass byte order to info_spu_dma_cmdlist. * symfile.c (read_target_long_array): Add GDBARCH parameter. (simple_read_overlay_table, simple_read_overlay_region_table, simple_overlay_update_1): Pass architecture to read_target_long_array. * v850-tdep.c (v850_analyze_prologue): Add GDBARCH parameter. (v850_frame_cache): Pass architecture to v850_analyze_prologue. * xstormy16-tdep.c (xstormy16_analyze_prologue): Add GDBARCH parameter. (xstormy16_skip_prologue, xstormy16_frame_cache): Pass architecture to xstormy16_analyze_prologue. (xstormy16_resolve_jmp_table_entry): Add GDBARCH parameter. (xstormy16_find_jmp_table_entry): Likewise. (xstormy16_skip_trampoline_code): Pass architecture to xstormy16_resolve_jmp_table_entry. (xstormy16_pointer_to_address): Likewise. (xstormy16_address_to_pointer): Pass architecture to xstormy16_find_jmp_table_entry. * xtensa-tdep.c (call0_track_op): Add GDBARCH parameter. (call0_analyze_prologue): Add GDBARCH parameter, pass to call0_track_op. (call0_frame_cache): Pass architecture to call0_analyze_prologue. (xtensa_skip_prologue): Likewise.
2009-07-02 19:25:59 +02:00
store_signed_integer (buf, TYPE_LENGTH (type), byte_order, addr);
}
PR python/20190 - compute TLS symbol without a frame PR python/20190 arose from an exception I noticed when trying to use the Python unwinder for Spider Monkey in Firefox. The problem is that the unwinder wants to examine the value of a thread-local variable. However, sympy_value rejects this because symbol_read_needs_frame returns true for a TLS variable. This problem arose once before, though in a different context: https://sourceware.org/bugzilla/show_bug.cgi?id=11803 At the time Pedro and Daniel pointed out a simpler way to fix that bug (see links in 20190 if you are interested); but for this new bug I couldn't think of a similar fix and ended up implementing Daniel's other suggestion: https://sourceware.org/ml/gdb-patches/2010-07/msg00393.html That is, this patch makes it possible to detect whether a symbol needs a specific frame, or whether it just needs the inferior to have registers. Built and regtested on x86-64 Fedora 24. 2016-07-26 Tom Tromey <tom@tromey.com> * symtab.c (register_symbol_computed_impl): Update. PR python/20190: * value.h (symbol_read_needs): Declare. (symbol_read_needs_frame): Add comment. * symtab.h (struct symbol_computed_ops) <read_variable>: Update comment. <get_symbol_read_needs>: Rename. Change return type. * findvar.c (symbol_read_needs): New function. (symbol_read_needs_frame): Rewrite. (default_read_var_value): Use symbol_read_needs. * dwarf2loc.c (struct symbol_needs_baton): Rename. <needs>: Renamed from needs_frame. Changed type. (needs_frame_read_addr_from_reg, symbol_needs_get_reg_value) (symbol_needs_read_mem, symbol_needs_frame_base) (symbol_needs_frame_cfa, symbol_needs_tls_address) (symbol_needs_dwarf_call): Rename. (needs_dwarf_reg_entry_value): Update. (symbol_needs_ctx_funcs, dwarf2_loc_desc_get_symbol_read_needs): Rename and update. (locexpr_get_symbol_read_needs, loclist_symbol_needs): Likewise. (dwarf2_locexpr_funcs, dwarf2_loclist_funcs): Update. * defs.h (enum symbol_needs_kind): New. 2016-07-26 Tom Tromey <tom@tromey.com> PR python/20190: * gdb.threads/tls.exp (check_thread_local): Add python symbol test.
2016-06-03 22:11:08 +02:00
/* See value.h. */
enum symbol_needs_kind
symbol_read_needs (struct symbol *sym)
{
if (SYMBOL_COMPUTED_OPS (sym) != NULL)
PR python/20190 - compute TLS symbol without a frame PR python/20190 arose from an exception I noticed when trying to use the Python unwinder for Spider Monkey in Firefox. The problem is that the unwinder wants to examine the value of a thread-local variable. However, sympy_value rejects this because symbol_read_needs_frame returns true for a TLS variable. This problem arose once before, though in a different context: https://sourceware.org/bugzilla/show_bug.cgi?id=11803 At the time Pedro and Daniel pointed out a simpler way to fix that bug (see links in 20190 if you are interested); but for this new bug I couldn't think of a similar fix and ended up implementing Daniel's other suggestion: https://sourceware.org/ml/gdb-patches/2010-07/msg00393.html That is, this patch makes it possible to detect whether a symbol needs a specific frame, or whether it just needs the inferior to have registers. Built and regtested on x86-64 Fedora 24. 2016-07-26 Tom Tromey <tom@tromey.com> * symtab.c (register_symbol_computed_impl): Update. PR python/20190: * value.h (symbol_read_needs): Declare. (symbol_read_needs_frame): Add comment. * symtab.h (struct symbol_computed_ops) <read_variable>: Update comment. <get_symbol_read_needs>: Rename. Change return type. * findvar.c (symbol_read_needs): New function. (symbol_read_needs_frame): Rewrite. (default_read_var_value): Use symbol_read_needs. * dwarf2loc.c (struct symbol_needs_baton): Rename. <needs>: Renamed from needs_frame. Changed type. (needs_frame_read_addr_from_reg, symbol_needs_get_reg_value) (symbol_needs_read_mem, symbol_needs_frame_base) (symbol_needs_frame_cfa, symbol_needs_tls_address) (symbol_needs_dwarf_call): Rename. (needs_dwarf_reg_entry_value): Update. (symbol_needs_ctx_funcs, dwarf2_loc_desc_get_symbol_read_needs): Rename and update. (locexpr_get_symbol_read_needs, loclist_symbol_needs): Likewise. (dwarf2_locexpr_funcs, dwarf2_loclist_funcs): Update. * defs.h (enum symbol_needs_kind): New. 2016-07-26 Tom Tromey <tom@tromey.com> PR python/20190: * gdb.threads/tls.exp (check_thread_local): Add python symbol test.
2016-06-03 22:11:08 +02:00
return SYMBOL_COMPUTED_OPS (sym)->get_symbol_read_needs (sym);
switch (SYMBOL_CLASS (sym))
{
/* All cases listed explicitly so that gcc -Wall will detect it if
1999-07-07 22:19:36 +02:00
we failed to consider one. */
case LOC_COMPUTED:
gdb_assert_not_reached (_("LOC_COMPUTED variable missing a method"));
case LOC_REGISTER:
case LOC_ARG:
case LOC_REF_ARG:
case LOC_REGPARM_ADDR:
case LOC_LOCAL:
PR python/20190 - compute TLS symbol without a frame PR python/20190 arose from an exception I noticed when trying to use the Python unwinder for Spider Monkey in Firefox. The problem is that the unwinder wants to examine the value of a thread-local variable. However, sympy_value rejects this because symbol_read_needs_frame returns true for a TLS variable. This problem arose once before, though in a different context: https://sourceware.org/bugzilla/show_bug.cgi?id=11803 At the time Pedro and Daniel pointed out a simpler way to fix that bug (see links in 20190 if you are interested); but for this new bug I couldn't think of a similar fix and ended up implementing Daniel's other suggestion: https://sourceware.org/ml/gdb-patches/2010-07/msg00393.html That is, this patch makes it possible to detect whether a symbol needs a specific frame, or whether it just needs the inferior to have registers. Built and regtested on x86-64 Fedora 24. 2016-07-26 Tom Tromey <tom@tromey.com> * symtab.c (register_symbol_computed_impl): Update. PR python/20190: * value.h (symbol_read_needs): Declare. (symbol_read_needs_frame): Add comment. * symtab.h (struct symbol_computed_ops) <read_variable>: Update comment. <get_symbol_read_needs>: Rename. Change return type. * findvar.c (symbol_read_needs): New function. (symbol_read_needs_frame): Rewrite. (default_read_var_value): Use symbol_read_needs. * dwarf2loc.c (struct symbol_needs_baton): Rename. <needs>: Renamed from needs_frame. Changed type. (needs_frame_read_addr_from_reg, symbol_needs_get_reg_value) (symbol_needs_read_mem, symbol_needs_frame_base) (symbol_needs_frame_cfa, symbol_needs_tls_address) (symbol_needs_dwarf_call): Rename. (needs_dwarf_reg_entry_value): Update. (symbol_needs_ctx_funcs, dwarf2_loc_desc_get_symbol_read_needs): Rename and update. (locexpr_get_symbol_read_needs, loclist_symbol_needs): Likewise. (dwarf2_locexpr_funcs, dwarf2_loclist_funcs): Update. * defs.h (enum symbol_needs_kind): New. 2016-07-26 Tom Tromey <tom@tromey.com> PR python/20190: * gdb.threads/tls.exp (check_thread_local): Add python symbol test.
2016-06-03 22:11:08 +02:00
return SYMBOL_NEEDS_FRAME;
case LOC_UNDEF:
case LOC_CONST:
case LOC_STATIC:
case LOC_TYPEDEF:
case LOC_LABEL:
/* Getting the address of a label can be done independently of the block,
1999-07-07 22:19:36 +02:00
even if some *uses* of that address wouldn't work so well without
the right frame. */
case LOC_BLOCK:
case LOC_CONST_BYTES:
case LOC_UNRESOLVED:
case LOC_OPTIMIZED_OUT:
PR python/20190 - compute TLS symbol without a frame PR python/20190 arose from an exception I noticed when trying to use the Python unwinder for Spider Monkey in Firefox. The problem is that the unwinder wants to examine the value of a thread-local variable. However, sympy_value rejects this because symbol_read_needs_frame returns true for a TLS variable. This problem arose once before, though in a different context: https://sourceware.org/bugzilla/show_bug.cgi?id=11803 At the time Pedro and Daniel pointed out a simpler way to fix that bug (see links in 20190 if you are interested); but for this new bug I couldn't think of a similar fix and ended up implementing Daniel's other suggestion: https://sourceware.org/ml/gdb-patches/2010-07/msg00393.html That is, this patch makes it possible to detect whether a symbol needs a specific frame, or whether it just needs the inferior to have registers. Built and regtested on x86-64 Fedora 24. 2016-07-26 Tom Tromey <tom@tromey.com> * symtab.c (register_symbol_computed_impl): Update. PR python/20190: * value.h (symbol_read_needs): Declare. (symbol_read_needs_frame): Add comment. * symtab.h (struct symbol_computed_ops) <read_variable>: Update comment. <get_symbol_read_needs>: Rename. Change return type. * findvar.c (symbol_read_needs): New function. (symbol_read_needs_frame): Rewrite. (default_read_var_value): Use symbol_read_needs. * dwarf2loc.c (struct symbol_needs_baton): Rename. <needs>: Renamed from needs_frame. Changed type. (needs_frame_read_addr_from_reg, symbol_needs_get_reg_value) (symbol_needs_read_mem, symbol_needs_frame_base) (symbol_needs_frame_cfa, symbol_needs_tls_address) (symbol_needs_dwarf_call): Rename. (needs_dwarf_reg_entry_value): Update. (symbol_needs_ctx_funcs, dwarf2_loc_desc_get_symbol_read_needs): Rename and update. (locexpr_get_symbol_read_needs, loclist_symbol_needs): Likewise. (dwarf2_locexpr_funcs, dwarf2_loclist_funcs): Update. * defs.h (enum symbol_needs_kind): New. 2016-07-26 Tom Tromey <tom@tromey.com> PR python/20190: * gdb.threads/tls.exp (check_thread_local): Add python symbol test.
2016-06-03 22:11:08 +02:00
return SYMBOL_NEEDS_NONE;
}
PR python/20190 - compute TLS symbol without a frame PR python/20190 arose from an exception I noticed when trying to use the Python unwinder for Spider Monkey in Firefox. The problem is that the unwinder wants to examine the value of a thread-local variable. However, sympy_value rejects this because symbol_read_needs_frame returns true for a TLS variable. This problem arose once before, though in a different context: https://sourceware.org/bugzilla/show_bug.cgi?id=11803 At the time Pedro and Daniel pointed out a simpler way to fix that bug (see links in 20190 if you are interested); but for this new bug I couldn't think of a similar fix and ended up implementing Daniel's other suggestion: https://sourceware.org/ml/gdb-patches/2010-07/msg00393.html That is, this patch makes it possible to detect whether a symbol needs a specific frame, or whether it just needs the inferior to have registers. Built and regtested on x86-64 Fedora 24. 2016-07-26 Tom Tromey <tom@tromey.com> * symtab.c (register_symbol_computed_impl): Update. PR python/20190: * value.h (symbol_read_needs): Declare. (symbol_read_needs_frame): Add comment. * symtab.h (struct symbol_computed_ops) <read_variable>: Update comment. <get_symbol_read_needs>: Rename. Change return type. * findvar.c (symbol_read_needs): New function. (symbol_read_needs_frame): Rewrite. (default_read_var_value): Use symbol_read_needs. * dwarf2loc.c (struct symbol_needs_baton): Rename. <needs>: Renamed from needs_frame. Changed type. (needs_frame_read_addr_from_reg, symbol_needs_get_reg_value) (symbol_needs_read_mem, symbol_needs_frame_base) (symbol_needs_frame_cfa, symbol_needs_tls_address) (symbol_needs_dwarf_call): Rename. (needs_dwarf_reg_entry_value): Update. (symbol_needs_ctx_funcs, dwarf2_loc_desc_get_symbol_read_needs): Rename and update. (locexpr_get_symbol_read_needs, loclist_symbol_needs): Likewise. (dwarf2_locexpr_funcs, dwarf2_loclist_funcs): Update. * defs.h (enum symbol_needs_kind): New. 2016-07-26 Tom Tromey <tom@tromey.com> PR python/20190: * gdb.threads/tls.exp (check_thread_local): Add python symbol test.
2016-06-03 22:11:08 +02:00
return SYMBOL_NEEDS_FRAME;
}
/* See value.h. */
int
symbol_read_needs_frame (struct symbol *sym)
{
return symbol_read_needs (sym) == SYMBOL_NEEDS_FRAME;
}
New "iterate_over_objfiles_in_search_order" gdbarch method. This patch introduces the "iterate_over_objfiles_in_search_order" gdbarch method, as well as its default implementation, and converts the areas where it will matter to using this gdbarch method. The default method implementation is the only one installed, and the changes should have no functional impact in terms of behavior. This only paves the way for the architectures that will need their own version. gdb/ChangeLog: * gdbarch.sh: Add generation of "iterate_over_objfiles_in_search_order_cb_ftype" typedef in gdbarch.h. Add include of "objfiles.h" in gdbarch.c. (iterate_over_objfiles_in_search_order): New gdbarch method. * gdbarch.h, gdbarch.c: Regenerate. * objfiles.h (default_iterate_over_objfiles_in_search_order): Add declaration. * objfiles.c (default_iterate_over_objfiles_in_search_order): New function. * symtab.c (lookup_symbol_aux_objfile): New function, extracted out of lookup_symbol_aux_symtabs. (lookup_symbol_aux_symtabs): Replace extracted-out code by call to lookup_symbol_aux_objfile. (struct global_sym_lookup_data): New type. (lookup_symbol_global_iterator_cb): New function. (lookup_symbol_global): Search for symbol using gdbarch_iterate_over_objfiles_in_search_order and lookup_symbol_global_iterator_cb. * findvar.c (struct minsym_lookup_data): New type. (minsym_lookup_iterator_cb): New function. (default_read_var_value) [case LOC_UNRESOLVED]: Resolve the symbol's address via gdbarch_iterate_over_objfiles_in_search_order and minsym_lookup_iterator_cb.
2012-06-05 15:50:50 +02:00
/* Private data to be used with minsym_lookup_iterator_cb. */
struct minsym_lookup_data
{
/* The name of the minimal symbol we are searching for. */
const char *name;
/* The field where the callback should store the minimal symbol
if found. It should be initialized to NULL before the search
is started. */
use bound_minsym as result for lookup_minimal_symbol et al This patch changes a few minimal symbol lookup functions to return a bound_minimal_symbol rather than a pointer to the minsym. This change helps prepare gdb for computing a minimal symbol's address at the point of use. Note that this changes even those functions that ostensibly search a single objfile. That was necessary because, in fact, those functions can search an objfile and its separate debug objfiles; and it is important for the caller to know in which objfile the minimal symbol was actually found. The bulk of this patch is mechanical. 2014-02-26 Tom Tromey <tromey@redhat.com> * ada-lang.c (ada_update_initial_language): Update. (ada_main_name, ada_has_this_exception_support): Update. * ada-tasks.c (ada_tasks_inferior_data_sniffer): Update. * aix-thread.c (pdc_symbol_addrs, pd_enable): Update. * arm-tdep.c (arm_skip_stub): Update. * auxv.c (ld_so_xfer_auxv): Update. * avr-tdep.c (avr_scan_prologue): Update. * ax-gdb.c (gen_var_ref): Update. * breakpoint.c (struct breakpoint_objfile_data) <overlay_msym, longjmp_msym, terminate_msym, exception_msym>: Change type to bound_minimal_symbol. (create_overlay_event_breakpoint) (create_longjmp_master_breakpoint) (create_std_terminate_master_breakpoint) (create_exception_master_breakpoint): Update. * bsd-uthread.c (bsd_uthread_lookup_address): Update. * c-exp.y (classify_name): Update. * coffread.c (coff_symfile_read): Update. * common/agent.c (agent_look_up_symbols): Update. * d-lang.c (d_main_name): Update. * dbxread.c (find_stab_function_addr, end_psymtab): Update. * dec-thread.c (enable_dec_thread): Update. * dwarf2loc.c (call_site_to_target_addr): Update. * elfread.c (elf_gnu_ifunc_resolve_by_got): Update. * eval.c (evaluate_subexp_standard): Update. * findvar.c (struct minsym_lookup_data) <result>: Change type to bound_minimal_symbol. <objfile>: Remove. (minsym_lookup_iterator_cb, default_read_var_value): Update. * frame.c (inside_main_func): Update. * frv-tdep.c (frv_frame_this_id): Update. * gcore.c (call_target_sbrk): Update. * glibc-tdep.c (glibc_skip_solib_resolver): Update. * gnu-v3-abi.c (gnuv3_get_typeid, gnuv3_skip_trampoline): Update. * go-lang.c (go_main_name): Update. * hppa-hpux-tdep.c (hppa_hpux_skip_trampoline_code) (hppa_hpux_find_import_stub_for_addr): Update. * hppa-tdep.c (hppa_extract_17, hppa_lookup_stub_minimal_symbol): Update. Change return type. * hppa-tdep.h (hppa_lookup_stub_minimal_symbol): Change return type. * jit.c (jit_breakpoint_re_set_internal): Update. * linux-fork.c (inferior_call_waitpid, checkpoint_command): Update. * linux-nat.c (get_signo): Update. * linux-thread-db.c (inferior_has_bug): Update * m32c-tdep.c (m32c_return_value) (m32c_m16c_address_to_pointer): Update. * m32r-tdep.c (m32r_frame_this_id): Update. * m68hc11-tdep.c (m68hc11_get_register_info): Update. * machoread.c (macho_resolve_oso_sym_with_minsym): Update. * minsyms.c (lookup_minimal_symbol_internal): Rename to lookup_minimal_symbol. Change return type. (lookup_minimal_symbol): Remove. (lookup_bound_minimal_symbol): Update. (lookup_minimal_symbol_text): Change return type. (lookup_minimal_symbol_solib_trampoline): Change return type. * minsyms.h (lookup_minimal_symbol, lookup_minimal_symbol_text) (lookup_minimal_symbol_solib_trampoline): Change return type. * mips-linux-tdep.c (mips_linux_skip_resolver): Update. * objc-lang.c (lookup_objc_class, lookup_child_selector) (value_nsstring, find_imps): Update. * obsd-tdep.c (obsd_skip_solib_resolver): Update. * p-lang.c (pascal_main_name): Update. * ppc-linux-tdep.c (ppc_linux_spe_context_lookup): Update. * ppc-sysv-tdep.c (convert_code_addr_to_desc_addr): Update. * proc-service.c (ps_pglobal_lookup): Update. * ravenscar-thread.c (get_running_thread_msymbol): Change return type. (has_ravenscar_runtime, get_running_thread_id): Update. * remote.c (remote_check_symbols): Update. * sol-thread.c (ps_pglobal_lookup): Update. * sol2-tdep.c (sol2_skip_solib_resolver): Update. * solib-dsbt.c (lm_base): Update. * solib-frv.c (lm_base, frv_relocate_section_addresses): Update. * solib-irix.c (locate_base): Update. * solib-som.c (som_solib_create_inferior_hook) (som_solib_desire_dynamic_linker_symbols, link_map_start): Update. * solib-spu.c (spu_enable_break): Update. * solib-svr4.c (elf_locate_base, enable_break): Update. * spu-tdep.c (spu_get_overlay_table, spu_catch_start) (flush_ea_cache): Update. * stabsread.c (define_symbol): Update. * symfile.c (simple_read_overlay_table): Update. * symtab.c (find_pc_sect_line): Update. * tracepoint.c (scope_info): Update. * tui-disasm.c (tui_get_begin_asm_address): Update. * value.c (value_static_field): Update.
2013-10-15 03:53:29 +02:00
struct bound_minimal_symbol result;
New "iterate_over_objfiles_in_search_order" gdbarch method. This patch introduces the "iterate_over_objfiles_in_search_order" gdbarch method, as well as its default implementation, and converts the areas where it will matter to using this gdbarch method. The default method implementation is the only one installed, and the changes should have no functional impact in terms of behavior. This only paves the way for the architectures that will need their own version. gdb/ChangeLog: * gdbarch.sh: Add generation of "iterate_over_objfiles_in_search_order_cb_ftype" typedef in gdbarch.h. Add include of "objfiles.h" in gdbarch.c. (iterate_over_objfiles_in_search_order): New gdbarch method. * gdbarch.h, gdbarch.c: Regenerate. * objfiles.h (default_iterate_over_objfiles_in_search_order): Add declaration. * objfiles.c (default_iterate_over_objfiles_in_search_order): New function. * symtab.c (lookup_symbol_aux_objfile): New function, extracted out of lookup_symbol_aux_symtabs. (lookup_symbol_aux_symtabs): Replace extracted-out code by call to lookup_symbol_aux_objfile. (struct global_sym_lookup_data): New type. (lookup_symbol_global_iterator_cb): New function. (lookup_symbol_global): Search for symbol using gdbarch_iterate_over_objfiles_in_search_order and lookup_symbol_global_iterator_cb. * findvar.c (struct minsym_lookup_data): New type. (minsym_lookup_iterator_cb): New function. (default_read_var_value) [case LOC_UNRESOLVED]: Resolve the symbol's address via gdbarch_iterate_over_objfiles_in_search_order and minsym_lookup_iterator_cb.
2012-06-05 15:50:50 +02:00
};
/* A callback function for gdbarch_iterate_over_objfiles_in_search_order.
It searches by name for a minimal symbol within the given OBJFILE.
The arguments are passed via CB_DATA, which in reality is a pointer
to struct minsym_lookup_data. */
static int
minsym_lookup_iterator_cb (struct objfile *objfile, void *cb_data)
{
struct minsym_lookup_data *data = (struct minsym_lookup_data *) cb_data;
use bound_minsym as result for lookup_minimal_symbol et al This patch changes a few minimal symbol lookup functions to return a bound_minimal_symbol rather than a pointer to the minsym. This change helps prepare gdb for computing a minimal symbol's address at the point of use. Note that this changes even those functions that ostensibly search a single objfile. That was necessary because, in fact, those functions can search an objfile and its separate debug objfiles; and it is important for the caller to know in which objfile the minimal symbol was actually found. The bulk of this patch is mechanical. 2014-02-26 Tom Tromey <tromey@redhat.com> * ada-lang.c (ada_update_initial_language): Update. (ada_main_name, ada_has_this_exception_support): Update. * ada-tasks.c (ada_tasks_inferior_data_sniffer): Update. * aix-thread.c (pdc_symbol_addrs, pd_enable): Update. * arm-tdep.c (arm_skip_stub): Update. * auxv.c (ld_so_xfer_auxv): Update. * avr-tdep.c (avr_scan_prologue): Update. * ax-gdb.c (gen_var_ref): Update. * breakpoint.c (struct breakpoint_objfile_data) <overlay_msym, longjmp_msym, terminate_msym, exception_msym>: Change type to bound_minimal_symbol. (create_overlay_event_breakpoint) (create_longjmp_master_breakpoint) (create_std_terminate_master_breakpoint) (create_exception_master_breakpoint): Update. * bsd-uthread.c (bsd_uthread_lookup_address): Update. * c-exp.y (classify_name): Update. * coffread.c (coff_symfile_read): Update. * common/agent.c (agent_look_up_symbols): Update. * d-lang.c (d_main_name): Update. * dbxread.c (find_stab_function_addr, end_psymtab): Update. * dec-thread.c (enable_dec_thread): Update. * dwarf2loc.c (call_site_to_target_addr): Update. * elfread.c (elf_gnu_ifunc_resolve_by_got): Update. * eval.c (evaluate_subexp_standard): Update. * findvar.c (struct minsym_lookup_data) <result>: Change type to bound_minimal_symbol. <objfile>: Remove. (minsym_lookup_iterator_cb, default_read_var_value): Update. * frame.c (inside_main_func): Update. * frv-tdep.c (frv_frame_this_id): Update. * gcore.c (call_target_sbrk): Update. * glibc-tdep.c (glibc_skip_solib_resolver): Update. * gnu-v3-abi.c (gnuv3_get_typeid, gnuv3_skip_trampoline): Update. * go-lang.c (go_main_name): Update. * hppa-hpux-tdep.c (hppa_hpux_skip_trampoline_code) (hppa_hpux_find_import_stub_for_addr): Update. * hppa-tdep.c (hppa_extract_17, hppa_lookup_stub_minimal_symbol): Update. Change return type. * hppa-tdep.h (hppa_lookup_stub_minimal_symbol): Change return type. * jit.c (jit_breakpoint_re_set_internal): Update. * linux-fork.c (inferior_call_waitpid, checkpoint_command): Update. * linux-nat.c (get_signo): Update. * linux-thread-db.c (inferior_has_bug): Update * m32c-tdep.c (m32c_return_value) (m32c_m16c_address_to_pointer): Update. * m32r-tdep.c (m32r_frame_this_id): Update. * m68hc11-tdep.c (m68hc11_get_register_info): Update. * machoread.c (macho_resolve_oso_sym_with_minsym): Update. * minsyms.c (lookup_minimal_symbol_internal): Rename to lookup_minimal_symbol. Change return type. (lookup_minimal_symbol): Remove. (lookup_bound_minimal_symbol): Update. (lookup_minimal_symbol_text): Change return type. (lookup_minimal_symbol_solib_trampoline): Change return type. * minsyms.h (lookup_minimal_symbol, lookup_minimal_symbol_text) (lookup_minimal_symbol_solib_trampoline): Change return type. * mips-linux-tdep.c (mips_linux_skip_resolver): Update. * objc-lang.c (lookup_objc_class, lookup_child_selector) (value_nsstring, find_imps): Update. * obsd-tdep.c (obsd_skip_solib_resolver): Update. * p-lang.c (pascal_main_name): Update. * ppc-linux-tdep.c (ppc_linux_spe_context_lookup): Update. * ppc-sysv-tdep.c (convert_code_addr_to_desc_addr): Update. * proc-service.c (ps_pglobal_lookup): Update. * ravenscar-thread.c (get_running_thread_msymbol): Change return type. (has_ravenscar_runtime, get_running_thread_id): Update. * remote.c (remote_check_symbols): Update. * sol-thread.c (ps_pglobal_lookup): Update. * sol2-tdep.c (sol2_skip_solib_resolver): Update. * solib-dsbt.c (lm_base): Update. * solib-frv.c (lm_base, frv_relocate_section_addresses): Update. * solib-irix.c (locate_base): Update. * solib-som.c (som_solib_create_inferior_hook) (som_solib_desire_dynamic_linker_symbols, link_map_start): Update. * solib-spu.c (spu_enable_break): Update. * solib-svr4.c (elf_locate_base, enable_break): Update. * spu-tdep.c (spu_get_overlay_table, spu_catch_start) (flush_ea_cache): Update. * stabsread.c (define_symbol): Update. * symfile.c (simple_read_overlay_table): Update. * symtab.c (find_pc_sect_line): Update. * tracepoint.c (scope_info): Update. * tui-disasm.c (tui_get_begin_asm_address): Update. * value.c (value_static_field): Update.
2013-10-15 03:53:29 +02:00
gdb_assert (data->result.minsym == NULL);
New "iterate_over_objfiles_in_search_order" gdbarch method. This patch introduces the "iterate_over_objfiles_in_search_order" gdbarch method, as well as its default implementation, and converts the areas where it will matter to using this gdbarch method. The default method implementation is the only one installed, and the changes should have no functional impact in terms of behavior. This only paves the way for the architectures that will need their own version. gdb/ChangeLog: * gdbarch.sh: Add generation of "iterate_over_objfiles_in_search_order_cb_ftype" typedef in gdbarch.h. Add include of "objfiles.h" in gdbarch.c. (iterate_over_objfiles_in_search_order): New gdbarch method. * gdbarch.h, gdbarch.c: Regenerate. * objfiles.h (default_iterate_over_objfiles_in_search_order): Add declaration. * objfiles.c (default_iterate_over_objfiles_in_search_order): New function. * symtab.c (lookup_symbol_aux_objfile): New function, extracted out of lookup_symbol_aux_symtabs. (lookup_symbol_aux_symtabs): Replace extracted-out code by call to lookup_symbol_aux_objfile. (struct global_sym_lookup_data): New type. (lookup_symbol_global_iterator_cb): New function. (lookup_symbol_global): Search for symbol using gdbarch_iterate_over_objfiles_in_search_order and lookup_symbol_global_iterator_cb. * findvar.c (struct minsym_lookup_data): New type. (minsym_lookup_iterator_cb): New function. (default_read_var_value) [case LOC_UNRESOLVED]: Resolve the symbol's address via gdbarch_iterate_over_objfiles_in_search_order and minsym_lookup_iterator_cb.
2012-06-05 15:50:50 +02:00
data->result = lookup_minimal_symbol (data->name, NULL, objfile);
/* The iterator should stop iff a match was found. */
use bound_minsym as result for lookup_minimal_symbol et al This patch changes a few minimal symbol lookup functions to return a bound_minimal_symbol rather than a pointer to the minsym. This change helps prepare gdb for computing a minimal symbol's address at the point of use. Note that this changes even those functions that ostensibly search a single objfile. That was necessary because, in fact, those functions can search an objfile and its separate debug objfiles; and it is important for the caller to know in which objfile the minimal symbol was actually found. The bulk of this patch is mechanical. 2014-02-26 Tom Tromey <tromey@redhat.com> * ada-lang.c (ada_update_initial_language): Update. (ada_main_name, ada_has_this_exception_support): Update. * ada-tasks.c (ada_tasks_inferior_data_sniffer): Update. * aix-thread.c (pdc_symbol_addrs, pd_enable): Update. * arm-tdep.c (arm_skip_stub): Update. * auxv.c (ld_so_xfer_auxv): Update. * avr-tdep.c (avr_scan_prologue): Update. * ax-gdb.c (gen_var_ref): Update. * breakpoint.c (struct breakpoint_objfile_data) <overlay_msym, longjmp_msym, terminate_msym, exception_msym>: Change type to bound_minimal_symbol. (create_overlay_event_breakpoint) (create_longjmp_master_breakpoint) (create_std_terminate_master_breakpoint) (create_exception_master_breakpoint): Update. * bsd-uthread.c (bsd_uthread_lookup_address): Update. * c-exp.y (classify_name): Update. * coffread.c (coff_symfile_read): Update. * common/agent.c (agent_look_up_symbols): Update. * d-lang.c (d_main_name): Update. * dbxread.c (find_stab_function_addr, end_psymtab): Update. * dec-thread.c (enable_dec_thread): Update. * dwarf2loc.c (call_site_to_target_addr): Update. * elfread.c (elf_gnu_ifunc_resolve_by_got): Update. * eval.c (evaluate_subexp_standard): Update. * findvar.c (struct minsym_lookup_data) <result>: Change type to bound_minimal_symbol. <objfile>: Remove. (minsym_lookup_iterator_cb, default_read_var_value): Update. * frame.c (inside_main_func): Update. * frv-tdep.c (frv_frame_this_id): Update. * gcore.c (call_target_sbrk): Update. * glibc-tdep.c (glibc_skip_solib_resolver): Update. * gnu-v3-abi.c (gnuv3_get_typeid, gnuv3_skip_trampoline): Update. * go-lang.c (go_main_name): Update. * hppa-hpux-tdep.c (hppa_hpux_skip_trampoline_code) (hppa_hpux_find_import_stub_for_addr): Update. * hppa-tdep.c (hppa_extract_17, hppa_lookup_stub_minimal_symbol): Update. Change return type. * hppa-tdep.h (hppa_lookup_stub_minimal_symbol): Change return type. * jit.c (jit_breakpoint_re_set_internal): Update. * linux-fork.c (inferior_call_waitpid, checkpoint_command): Update. * linux-nat.c (get_signo): Update. * linux-thread-db.c (inferior_has_bug): Update * m32c-tdep.c (m32c_return_value) (m32c_m16c_address_to_pointer): Update. * m32r-tdep.c (m32r_frame_this_id): Update. * m68hc11-tdep.c (m68hc11_get_register_info): Update. * machoread.c (macho_resolve_oso_sym_with_minsym): Update. * minsyms.c (lookup_minimal_symbol_internal): Rename to lookup_minimal_symbol. Change return type. (lookup_minimal_symbol): Remove. (lookup_bound_minimal_symbol): Update. (lookup_minimal_symbol_text): Change return type. (lookup_minimal_symbol_solib_trampoline): Change return type. * minsyms.h (lookup_minimal_symbol, lookup_minimal_symbol_text) (lookup_minimal_symbol_solib_trampoline): Change return type. * mips-linux-tdep.c (mips_linux_skip_resolver): Update. * objc-lang.c (lookup_objc_class, lookup_child_selector) (value_nsstring, find_imps): Update. * obsd-tdep.c (obsd_skip_solib_resolver): Update. * p-lang.c (pascal_main_name): Update. * ppc-linux-tdep.c (ppc_linux_spe_context_lookup): Update. * ppc-sysv-tdep.c (convert_code_addr_to_desc_addr): Update. * proc-service.c (ps_pglobal_lookup): Update. * ravenscar-thread.c (get_running_thread_msymbol): Change return type. (has_ravenscar_runtime, get_running_thread_id): Update. * remote.c (remote_check_symbols): Update. * sol-thread.c (ps_pglobal_lookup): Update. * sol2-tdep.c (sol2_skip_solib_resolver): Update. * solib-dsbt.c (lm_base): Update. * solib-frv.c (lm_base, frv_relocate_section_addresses): Update. * solib-irix.c (locate_base): Update. * solib-som.c (som_solib_create_inferior_hook) (som_solib_desire_dynamic_linker_symbols, link_map_start): Update. * solib-spu.c (spu_enable_break): Update. * solib-svr4.c (elf_locate_base, enable_break): Update. * spu-tdep.c (spu_get_overlay_table, spu_catch_start) (flush_ea_cache): Update. * stabsread.c (define_symbol): Update. * symfile.c (simple_read_overlay_table): Update. * symtab.c (find_pc_sect_line): Update. * tracepoint.c (scope_info): Update. * tui-disasm.c (tui_get_begin_asm_address): Update. * value.c (value_static_field): Update.
2013-10-15 03:53:29 +02:00
return (data->result.minsym != NULL);
New "iterate_over_objfiles_in_search_order" gdbarch method. This patch introduces the "iterate_over_objfiles_in_search_order" gdbarch method, as well as its default implementation, and converts the areas where it will matter to using this gdbarch method. The default method implementation is the only one installed, and the changes should have no functional impact in terms of behavior. This only paves the way for the architectures that will need their own version. gdb/ChangeLog: * gdbarch.sh: Add generation of "iterate_over_objfiles_in_search_order_cb_ftype" typedef in gdbarch.h. Add include of "objfiles.h" in gdbarch.c. (iterate_over_objfiles_in_search_order): New gdbarch method. * gdbarch.h, gdbarch.c: Regenerate. * objfiles.h (default_iterate_over_objfiles_in_search_order): Add declaration. * objfiles.c (default_iterate_over_objfiles_in_search_order): New function. * symtab.c (lookup_symbol_aux_objfile): New function, extracted out of lookup_symbol_aux_symtabs. (lookup_symbol_aux_symtabs): Replace extracted-out code by call to lookup_symbol_aux_objfile. (struct global_sym_lookup_data): New type. (lookup_symbol_global_iterator_cb): New function. (lookup_symbol_global): Search for symbol using gdbarch_iterate_over_objfiles_in_search_order and lookup_symbol_global_iterator_cb. * findvar.c (struct minsym_lookup_data): New type. (minsym_lookup_iterator_cb): New function. (default_read_var_value) [case LOC_UNRESOLVED]: Resolve the symbol's address via gdbarch_iterate_over_objfiles_in_search_order and minsym_lookup_iterator_cb.
2012-06-05 15:50:50 +02:00
}
DWARF: handle non-local references in nested functions GDB's current behavior when dealing with non-local references in the context of nested fuctions is approximative: - code using valops.c:value_of_variable read the first available stack frame that holds the corresponding variable (whereas there can be multiple candidates for this); - code directly relying on read_var_value will instead read non-local variables in frames where they are not even defined. This change adds the necessary context to symbol reads (to get the block they belong to) and to blocks (the static link property, if any) so that GDB can make the proper decisions when dealing with non-local varibale references. gdb/ChangeLog: * ada-lang.c (ada_read_var_value): Add a var_block argument and pass it to default_read_var_value. * block.c (block_static_link): New accessor. * block.h (block_static_link): Declare it. * buildsym.c (finish_block_internal): Add a static_link argument. If there is a static link, associate it to the new block. (finish_block): Add a static link argument and pass it to finish_block_internal. (end_symtab_get_static_block): Update calls to finish_block and to finish_block_internal. (end_symtab_with_blockvector): Update call to finish_block_internal. * buildsym.h: Forward-declare struct dynamic_prop. (struct context_stack): Add a static_link field. (finish_block): Add a static link argument. * c-exp.y: Remove an obsolete comment (evaluation of variables already start from the selected frame, and now they climb *up* the call stack) and propagate the block information to the produced expression. * d-exp.y: Likewise. * f-exp.y: Likewise. * go-exp.y: Likewise. * jv-exp.y: Likewise. * m2-exp.y: Likewise. * p-exp.y: Likewise. * coffread.c (coff_symtab_read): Update calls to finish_block. * dbxread.c (process_one_symbol): Likewise. * xcoffread.c (read_xcoff_symtab): Likewise. * compile/compile-c-symbols.c (convert_one_symbol): Promote the "sym" parameter to struct block_symbol, update its uses and pass its block to calls to read_var_value. (convert_symbol_sym): Update the calls to convert_one_symbol. * compile/compile-loc2c.c (do_compile_dwarf_expr_to_c): Update call to read_var_value. * dwarf2loc.c (block_op_get_frame_base): New. (dwarf2_block_frame_base_locexpr_funcs): Implement the get_frame_base method. (dwarf2_block_frame_base_loclist_funcs): Likewise. (dwarf2locexpr_baton_eval): Add a frame argument and use it instead of the selected frame in order to evaluate the expression. (dwarf2_evaluate_property): Add a frame argument. Update call to dwarf2_locexpr_baton_eval to provide a frame in available and to handle the absence of address stack. * dwarf2loc.h (dwarf2_evaluate_property): Add a frame argument. * dwarf2read.c (attr_to_dynamic_prop): Add a forward declaration. (read_func_scope): Record any available static link description. Update call to finish_block. (read_lexical_block_scope): Update call to finish_block. * findvar.c (follow_static_link): New. (get_hosting_frame): New. (default_read_var_value): Add a var_block argument. Use get_hosting_frame to handle non-local references. (read_var_value): Add a var_block argument and pass it to the LA_READ_VAR_VALUE method. * gdbtypes.c (resolve_dynamic_range): Update calls to dwarf2_evaluate_property. (resolve_dynamic_type_internal): Likewise. * guile/scm-frame.c (gdbscm_frame_read_var): Update call to read_var_value, passing it the block coming from symbol lookup. * guile/scm-symbol.c (gdbscm_symbol_value): Update call to read_var_value (TODO). * infcmd.c (finish_command_continuation): Update call to read_var_value, passing it the block coming from symbol lookup. * infrun.c (insert_exception_resume_breakpoint): Likewise. * language.h (struct language_defn): Add a var_block argument to the LA_READ_VAR_VALUE method. * objfiles.c (struct static_link_htab_entry): New. (static_link_htab_entry_hash): New. (static_link_htab_entry_eq): New. (objfile_register_static_link): New. (objfile_lookup_static_link): New. (free_objfile): Free the STATIC_LINKS hashed map if needed. * objfiles.h: Include hashtab.h. (struct objfile): Add a static_links field. (objfile_register_static_link): New. (objfile_lookup_static_link): New. * printcmd.c (print_variable_and_value): Update call to read_var_value. * python/py-finishbreakpoint.c (bpfinishpy_init): Likewise. * python/py-frame.c (frapy_read_var): Update call to read_var_value, passing it the block coming from symbol lookup. * python/py-framefilter.c (extract_sym): Add a sym_block parameter and set the pointed value to NULL (TODO). (enumerate_args): Update call to extract_sym. (enumerate_locals): Update calls to extract_sym and to read_var_value. * python/py-symbol.c (sympy_value): Update call to read_var_value (TODO). * stack.c (read_frame_local): Update call to read_var_value. (read_frame_arg): Likewise. (return_command): Likewise. * symtab.h (struct symbol_block_ops): Add a get_frame_base method. (struct symbol): Add a block field. (SYMBOL_BLOCK): New accessor. * valops.c (value_of_variable): Remove frame/block handling and pass the block argument to read_var_value, which does this job now. (value_struct_elt_for_reference): Update calls to read_var_value. (value_of_this): Pass the block found to read_var_value. * value.h (read_var_value): Add a var_block argument. (default_read_var_value): Likewise. gdb/testsuite/ChangeLog: * gdb.base/nested-subp1.exp: New file. * gdb.base/nested-subp1.c: New file. * gdb.base/nested-subp2.exp: New file. * gdb.base/nested-subp2.c: New file. * gdb.base/nested-subp3.exp: New file. * gdb.base/nested-subp3.c: New file.
2015-02-05 17:00:06 +01:00
/* Given static link expression and the frame it lives in, look for the frame
the static links points to and return it. Return NULL if we could not find
such a frame. */
static struct frame_info *
follow_static_link (struct frame_info *frame,
const struct dynamic_prop *static_link)
{
CORE_ADDR upper_frame_base;
if (!dwarf2_evaluate_property (static_link, frame, NULL, &upper_frame_base))
return NULL;
/* Now climb up the stack frame until we reach the frame we are interested
in. */
for (; frame != NULL; frame = get_prev_frame (frame))
{
struct symbol *framefunc = get_frame_function (frame);
/* Stacks can be quite deep: give the user a chance to stop this. */
QUIT;
/* If we don't know how to compute FRAME's base address, don't give up:
[gdb] Fix more typos in comments 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-10-18 02:48:08 +02:00
maybe the frame we are looking for is upper in the stack frame. */
DWARF: handle non-local references in nested functions GDB's current behavior when dealing with non-local references in the context of nested fuctions is approximative: - code using valops.c:value_of_variable read the first available stack frame that holds the corresponding variable (whereas there can be multiple candidates for this); - code directly relying on read_var_value will instead read non-local variables in frames where they are not even defined. This change adds the necessary context to symbol reads (to get the block they belong to) and to blocks (the static link property, if any) so that GDB can make the proper decisions when dealing with non-local varibale references. gdb/ChangeLog: * ada-lang.c (ada_read_var_value): Add a var_block argument and pass it to default_read_var_value. * block.c (block_static_link): New accessor. * block.h (block_static_link): Declare it. * buildsym.c (finish_block_internal): Add a static_link argument. If there is a static link, associate it to the new block. (finish_block): Add a static link argument and pass it to finish_block_internal. (end_symtab_get_static_block): Update calls to finish_block and to finish_block_internal. (end_symtab_with_blockvector): Update call to finish_block_internal. * buildsym.h: Forward-declare struct dynamic_prop. (struct context_stack): Add a static_link field. (finish_block): Add a static link argument. * c-exp.y: Remove an obsolete comment (evaluation of variables already start from the selected frame, and now they climb *up* the call stack) and propagate the block information to the produced expression. * d-exp.y: Likewise. * f-exp.y: Likewise. * go-exp.y: Likewise. * jv-exp.y: Likewise. * m2-exp.y: Likewise. * p-exp.y: Likewise. * coffread.c (coff_symtab_read): Update calls to finish_block. * dbxread.c (process_one_symbol): Likewise. * xcoffread.c (read_xcoff_symtab): Likewise. * compile/compile-c-symbols.c (convert_one_symbol): Promote the "sym" parameter to struct block_symbol, update its uses and pass its block to calls to read_var_value. (convert_symbol_sym): Update the calls to convert_one_symbol. * compile/compile-loc2c.c (do_compile_dwarf_expr_to_c): Update call to read_var_value. * dwarf2loc.c (block_op_get_frame_base): New. (dwarf2_block_frame_base_locexpr_funcs): Implement the get_frame_base method. (dwarf2_block_frame_base_loclist_funcs): Likewise. (dwarf2locexpr_baton_eval): Add a frame argument and use it instead of the selected frame in order to evaluate the expression. (dwarf2_evaluate_property): Add a frame argument. Update call to dwarf2_locexpr_baton_eval to provide a frame in available and to handle the absence of address stack. * dwarf2loc.h (dwarf2_evaluate_property): Add a frame argument. * dwarf2read.c (attr_to_dynamic_prop): Add a forward declaration. (read_func_scope): Record any available static link description. Update call to finish_block. (read_lexical_block_scope): Update call to finish_block. * findvar.c (follow_static_link): New. (get_hosting_frame): New. (default_read_var_value): Add a var_block argument. Use get_hosting_frame to handle non-local references. (read_var_value): Add a var_block argument and pass it to the LA_READ_VAR_VALUE method. * gdbtypes.c (resolve_dynamic_range): Update calls to dwarf2_evaluate_property. (resolve_dynamic_type_internal): Likewise. * guile/scm-frame.c (gdbscm_frame_read_var): Update call to read_var_value, passing it the block coming from symbol lookup. * guile/scm-symbol.c (gdbscm_symbol_value): Update call to read_var_value (TODO). * infcmd.c (finish_command_continuation): Update call to read_var_value, passing it the block coming from symbol lookup. * infrun.c (insert_exception_resume_breakpoint): Likewise. * language.h (struct language_defn): Add a var_block argument to the LA_READ_VAR_VALUE method. * objfiles.c (struct static_link_htab_entry): New. (static_link_htab_entry_hash): New. (static_link_htab_entry_eq): New. (objfile_register_static_link): New. (objfile_lookup_static_link): New. (free_objfile): Free the STATIC_LINKS hashed map if needed. * objfiles.h: Include hashtab.h. (struct objfile): Add a static_links field. (objfile_register_static_link): New. (objfile_lookup_static_link): New. * printcmd.c (print_variable_and_value): Update call to read_var_value. * python/py-finishbreakpoint.c (bpfinishpy_init): Likewise. * python/py-frame.c (frapy_read_var): Update call to read_var_value, passing it the block coming from symbol lookup. * python/py-framefilter.c (extract_sym): Add a sym_block parameter and set the pointed value to NULL (TODO). (enumerate_args): Update call to extract_sym. (enumerate_locals): Update calls to extract_sym and to read_var_value. * python/py-symbol.c (sympy_value): Update call to read_var_value (TODO). * stack.c (read_frame_local): Update call to read_var_value. (read_frame_arg): Likewise. (return_command): Likewise. * symtab.h (struct symbol_block_ops): Add a get_frame_base method. (struct symbol): Add a block field. (SYMBOL_BLOCK): New accessor. * valops.c (value_of_variable): Remove frame/block handling and pass the block argument to read_var_value, which does this job now. (value_struct_elt_for_reference): Update calls to read_var_value. (value_of_this): Pass the block found to read_var_value. * value.h (read_var_value): Add a var_block argument. (default_read_var_value): Likewise. gdb/testsuite/ChangeLog: * gdb.base/nested-subp1.exp: New file. * gdb.base/nested-subp1.c: New file. * gdb.base/nested-subp2.exp: New file. * gdb.base/nested-subp2.c: New file. * gdb.base/nested-subp3.exp: New file. * gdb.base/nested-subp3.c: New file.
2015-02-05 17:00:06 +01:00
if (framefunc != NULL
&& SYMBOL_BLOCK_OPS (framefunc) != NULL
DWARF: handle non-local references in nested functions GDB's current behavior when dealing with non-local references in the context of nested fuctions is approximative: - code using valops.c:value_of_variable read the first available stack frame that holds the corresponding variable (whereas there can be multiple candidates for this); - code directly relying on read_var_value will instead read non-local variables in frames where they are not even defined. This change adds the necessary context to symbol reads (to get the block they belong to) and to blocks (the static link property, if any) so that GDB can make the proper decisions when dealing with non-local varibale references. gdb/ChangeLog: * ada-lang.c (ada_read_var_value): Add a var_block argument and pass it to default_read_var_value. * block.c (block_static_link): New accessor. * block.h (block_static_link): Declare it. * buildsym.c (finish_block_internal): Add a static_link argument. If there is a static link, associate it to the new block. (finish_block): Add a static link argument and pass it to finish_block_internal. (end_symtab_get_static_block): Update calls to finish_block and to finish_block_internal. (end_symtab_with_blockvector): Update call to finish_block_internal. * buildsym.h: Forward-declare struct dynamic_prop. (struct context_stack): Add a static_link field. (finish_block): Add a static link argument. * c-exp.y: Remove an obsolete comment (evaluation of variables already start from the selected frame, and now they climb *up* the call stack) and propagate the block information to the produced expression. * d-exp.y: Likewise. * f-exp.y: Likewise. * go-exp.y: Likewise. * jv-exp.y: Likewise. * m2-exp.y: Likewise. * p-exp.y: Likewise. * coffread.c (coff_symtab_read): Update calls to finish_block. * dbxread.c (process_one_symbol): Likewise. * xcoffread.c (read_xcoff_symtab): Likewise. * compile/compile-c-symbols.c (convert_one_symbol): Promote the "sym" parameter to struct block_symbol, update its uses and pass its block to calls to read_var_value. (convert_symbol_sym): Update the calls to convert_one_symbol. * compile/compile-loc2c.c (do_compile_dwarf_expr_to_c): Update call to read_var_value. * dwarf2loc.c (block_op_get_frame_base): New. (dwarf2_block_frame_base_locexpr_funcs): Implement the get_frame_base method. (dwarf2_block_frame_base_loclist_funcs): Likewise. (dwarf2locexpr_baton_eval): Add a frame argument and use it instead of the selected frame in order to evaluate the expression. (dwarf2_evaluate_property): Add a frame argument. Update call to dwarf2_locexpr_baton_eval to provide a frame in available and to handle the absence of address stack. * dwarf2loc.h (dwarf2_evaluate_property): Add a frame argument. * dwarf2read.c (attr_to_dynamic_prop): Add a forward declaration. (read_func_scope): Record any available static link description. Update call to finish_block. (read_lexical_block_scope): Update call to finish_block. * findvar.c (follow_static_link): New. (get_hosting_frame): New. (default_read_var_value): Add a var_block argument. Use get_hosting_frame to handle non-local references. (read_var_value): Add a var_block argument and pass it to the LA_READ_VAR_VALUE method. * gdbtypes.c (resolve_dynamic_range): Update calls to dwarf2_evaluate_property. (resolve_dynamic_type_internal): Likewise. * guile/scm-frame.c (gdbscm_frame_read_var): Update call to read_var_value, passing it the block coming from symbol lookup. * guile/scm-symbol.c (gdbscm_symbol_value): Update call to read_var_value (TODO). * infcmd.c (finish_command_continuation): Update call to read_var_value, passing it the block coming from symbol lookup. * infrun.c (insert_exception_resume_breakpoint): Likewise. * language.h (struct language_defn): Add a var_block argument to the LA_READ_VAR_VALUE method. * objfiles.c (struct static_link_htab_entry): New. (static_link_htab_entry_hash): New. (static_link_htab_entry_eq): New. (objfile_register_static_link): New. (objfile_lookup_static_link): New. (free_objfile): Free the STATIC_LINKS hashed map if needed. * objfiles.h: Include hashtab.h. (struct objfile): Add a static_links field. (objfile_register_static_link): New. (objfile_lookup_static_link): New. * printcmd.c (print_variable_and_value): Update call to read_var_value. * python/py-finishbreakpoint.c (bpfinishpy_init): Likewise. * python/py-frame.c (frapy_read_var): Update call to read_var_value, passing it the block coming from symbol lookup. * python/py-framefilter.c (extract_sym): Add a sym_block parameter and set the pointed value to NULL (TODO). (enumerate_args): Update call to extract_sym. (enumerate_locals): Update calls to extract_sym and to read_var_value. * python/py-symbol.c (sympy_value): Update call to read_var_value (TODO). * stack.c (read_frame_local): Update call to read_var_value. (read_frame_arg): Likewise. (return_command): Likewise. * symtab.h (struct symbol_block_ops): Add a get_frame_base method. (struct symbol): Add a block field. (SYMBOL_BLOCK): New accessor. * valops.c (value_of_variable): Remove frame/block handling and pass the block argument to read_var_value, which does this job now. (value_struct_elt_for_reference): Update calls to read_var_value. (value_of_this): Pass the block found to read_var_value. * value.h (read_var_value): Add a var_block argument. (default_read_var_value): Likewise. gdb/testsuite/ChangeLog: * gdb.base/nested-subp1.exp: New file. * gdb.base/nested-subp1.c: New file. * gdb.base/nested-subp2.exp: New file. * gdb.base/nested-subp2.c: New file. * gdb.base/nested-subp3.exp: New file. * gdb.base/nested-subp3.c: New file.
2015-02-05 17:00:06 +01:00
&& SYMBOL_BLOCK_OPS (framefunc)->get_frame_base != NULL
&& (SYMBOL_BLOCK_OPS (framefunc)->get_frame_base (framefunc, frame)
== upper_frame_base))
break;
}
return frame;
}
/* Assuming VAR is a symbol that can be reached from FRAME thanks to lexical
rules, look for the frame that is actually hosting VAR and return it. If,
for some reason, we found no such frame, return NULL.
This kind of computation is necessary to correctly handle lexically nested
functions.
Note that in some cases, we know what scope VAR comes from but we cannot
reach the specific frame that hosts the instance of VAR we are looking for.
For backward compatibility purposes (with old compilers), we then look for
the first frame that can host it. */
static struct frame_info *
get_hosting_frame (struct symbol *var, const struct block *var_block,
struct frame_info *frame)
{
const struct block *frame_block = NULL;
if (!symbol_read_needs_frame (var))
return NULL;
/* Some symbols for local variables have no block: this happens when they are
not produced by a debug information reader, for instance when GDB creates
synthetic symbols. Without block information, we must assume they are
local to FRAME. In this case, there is nothing to do. */
else if (var_block == NULL)
return frame;
/* We currently assume that all symbols with a location list need a frame.
This is true in practice because selecting the location description
requires to compute the CFA, hence requires a frame. However we have
tests that embed global/static symbols with null location lists.
We want to get <optimized out> instead of <frame required> when evaluating
them so return a frame instead of raising an error. */
else if (var_block == block_global_block (var_block)
|| var_block == block_static_block (var_block))
return frame;
/* We have to handle the "my_func::my_local_var" notation. This requires us
to look for upper frames when we find no block for the current frame: here
and below, handle when frame_block == NULL. */
if (frame != NULL)
frame_block = get_frame_block (frame, NULL);
/* Climb up the call stack until reaching the frame we are looking for. */
while (frame != NULL && frame_block != var_block)
{
/* Stacks can be quite deep: give the user a chance to stop this. */
QUIT;
if (frame_block == NULL)
{
frame = get_prev_frame (frame);
if (frame == NULL)
break;
frame_block = get_frame_block (frame, NULL);
}
/* If we failed to find the proper frame, fallback to the heuristic
method below. */
else if (frame_block == block_global_block (frame_block))
{
frame = NULL;
break;
}
/* Assuming we have a block for this frame: if we are at the function
level, the immediate upper lexical block is in an outer function:
follow the static link. */
else if (BLOCK_FUNCTION (frame_block))
{
const struct dynamic_prop *static_link
= block_static_link (frame_block);
int could_climb_up = 0;
if (static_link != NULL)
{
frame = follow_static_link (frame, static_link);
if (frame != NULL)
{
frame_block = get_frame_block (frame, NULL);
could_climb_up = frame_block != NULL;
}
}
if (!could_climb_up)
{
frame = NULL;
break;
}
}
else
/* We must be in some function nested lexical block. Just get the
outer block: both must share the same frame. */
frame_block = BLOCK_SUPERBLOCK (frame_block);
}
/* Old compilers may not provide a static link, or they may provide an
invalid one. For such cases, fallback on the old way to evaluate
non-local references: just climb up the call stack and pick the first
frame that contains the variable we are looking for. */
if (frame == NULL)
{
frame = block_innermost_frame (var_block);
if (frame == NULL)
{
if (BLOCK_FUNCTION (var_block)
&& !block_inlined_p (var_block)
Replace SYMBOL_*_NAME accessors with member functions Similar to the MSYMBOL version of this patch, improves readability and will eventually allow making name private. gdb/ChangeLog: 2019-11-22 Christian Biesinger <cbiesinger@google.com> * ada-exp.y: Update. * ada-lang.c (sort_choices): Update. (ada_print_symbol_signature): Update. (resolve_subexp): Update. (ada_parse_renaming): Update. (ada_read_renaming_var_value): Update. (lesseq_defined_than): Update. (remove_extra_symbols): Update. (remove_irrelevant_renamings): Update. (ada_add_block_symbols): Update. (ada_collect_symbol_completion_matches): Update. (ada_is_renaming_symbol): Update. (aggregate_assign_from_choices): Update. (ada_evaluate_subexp): Update. (ada_has_this_exception_support): Update. (ada_is_non_standard_exception_sym): Update. (ada_add_exceptions_from_frame): Update. (ada_add_global_exceptions): Update. (ada_print_subexp): Update. * ax-gdb.c (gen_var_ref): Update. (gen_maybe_namespace_elt): Update. (gen_expr_for_cast): Update. (gen_expr): Update. * block.h: Update. * blockframe.c (find_pc_partial_function): Update. * breakpoint.c (print_breakpoint_location): Update. (update_static_tracepoint): Update. * btrace.c (ftrace_print_function_name): Update. (ftrace_function_switched): Update. * buildsym.c (find_symbol_in_list): Update. * c-exp.y: Update. * c-typeprint.c (c_print_typedef): Update. (c_type_print_template_args): Update. * cli/cli-cmds.c (edit_command): Update. (list_command): Update. (print_sal_location): Update. * coffread.c (patch_opaque_types): Update. (process_coff_symbol): Update. (coff_read_enum_type): Update. * compile/compile-c-symbols.c (c_symbol_substitution_name): Update. (convert_one_symbol): Update. (hash_symname): Update. (eq_symname): Update. * compile/compile-cplus-symbols.c (convert_one_symbol): Update. * compile/compile-cplus-types.c (debug_print_scope): Update. * compile/compile-loc2c.c (do_compile_dwarf_expr_to_c): Update. * compile/compile-object-load.c (get_out_value_type): Update. * cp-namespace.c (cp_scan_for_anonymous_namespaces): Update. (search_symbol_list): Update. (cp_lookup_symbol_imports_or_template): Update. * cp-support.c (overload_list_add_symbol): Update. * ctfread.c (psymtab_to_symtab): Update. * dbxread.c (cp_set_block_scope): Update. * dictionary.c (iter_match_first_hashed): Update. (iter_match_next_hashed): Update. (insert_symbol_hashed): Update. (iter_match_next_linear): Update. * dictionary.h: Update. * dwarf2loc.c (func_get_frame_base_dwarf_block): Update. (locexpr_describe_location_piece): Update. (locexpr_describe_location_1): Update. (locexpr_generate_c_location): Update. (loclist_describe_location): Update. (loclist_generate_c_location): Update. * dwarf2read.c (dw2_debug_names_lookup_symbol): Update. (read_func_scope): Update. (process_enumeration_scope): Update. (new_symbol): Update. (dwarf2_const_value): Update. (dwarf2_symbol_mark_computed): Update. * eval.c (evaluate_funcall): Update. (evaluate_subexp_standard): Update. * expprint.c (print_subexp_standard): Update. (dump_subexp_body_standard): Update. * f-valprint.c (info_common_command_for_block): Update. * findvar.c (get_hosting_frame): Update. (default_read_var_value): Update. * go-lang.c (go_symbol_package_name): Update. * guile/scm-block.c (bkscm_print_block_smob): Update. * guile/scm-symbol.c (syscm_print_symbol_smob): Update. (gdbscm_symbol_name): Update. (gdbscm_symbol_linkage_name): Update. (gdbscm_symbol_print_name): Update. * infcall.c (get_function_name): Update. * infcmd.c (jump_command): Update. (finish_command): Update. * infrun.c (insert_exception_resume_breakpoint): Update. * linespec.c (canonicalize_linespec): Update. (create_sals_line_offset): Update. (convert_linespec_to_sals): Update. (complete_label): Update. (find_label_symbols_in_block): Update. * m2-typeprint.c (m2_print_typedef): Update. * mdebugread.c (mdebug_reg_to_regnum): Update. (parse_symbol): Update. (mylookup_symbol): Update. * mi/mi-cmd-stack.c (list_arg_or_local): Update. (list_args_or_locals): Update. * objc-lang.c (compare_selectors): Update. (info_selectors_command): Update. (compare_classes): Update. (info_classes_command): Update. (find_imps): Update. * p-typeprint.c (pascal_print_typedef): Update. * printcmd.c (build_address_symbolic): Update. (info_address_command): Update. (print_variable_and_value): Update. * python/py-framefilter.c (extract_sym): Update. (py_print_single_arg): Update. * python/py-symbol.c (sympy_str): Update. (sympy_get_name): Update. (sympy_get_linkage_name): Update. * python/python.c (gdbpy_rbreak): Update. * record-btrace.c (btrace_get_bfun_name): Update. (btrace_call_history): Update. * rust-lang.c (rust_print_typedef): Update. * solib-frv.c (frv_fdpic_find_canonical_descriptor): Update. * stabsread.c (stab_reg_to_regnum): Update. (define_symbol): Update. (read_enum_type): Update. (common_block_end): Update. (cleanup_undefined_types_1): Update. (scan_file_globals): Update. * stack.c (print_frame_arg): Update. (print_frame_args): Update. (find_frame_funname): Update. (info_frame_command_core): Update. (iterate_over_block_locals): Update. (print_block_frame_labels): Update. (do_print_variable_and_value): Update. (iterate_over_block_arg_vars): Update. (return_command): Update. * symmisc.c (dump_symtab_1): Update. (print_symbol): Update. * symtab.c (eq_symbol_entry): Update. (symbol_cache_dump): Update. (lookup_language_this): Update. (find_pc_sect_line): Update. (skip_prologue_sal): Update. (symbol_search::compare_search_syms): Update. (treg_matches_sym_type_name): Update. (search_symbols): Update. (print_symbol_info): Update. (rbreak_command): Update. (completion_list_add_symbol): Update. (find_gnu_ifunc): Update. (get_symbol_address): Update. (search_module_symbols): Update. (info_module_subcommand): Update. * symtab.h (SYMBOL_NATURAL_NAME): Remove. (SYMBOL_LINKAGE_NAME): Remove. (SYMBOL_DEMANGLED_NAME): Remove. (SYMBOL_PRINT_NAME): Remove. (SYMBOL_SEARCH_NAME): Remove. * tracepoint.c (set_traceframe_context): Update. (validate_actionline): Update. (collection_list::collect_symbol): Update. (encode_actions_1): Update. (info_scope_command): Update. (print_one_static_tracepoint_marker): Update. * typeprint.c (typedef_hash_table::add_template_parameters): Update. * valops.c (address_of_variable): Update. (find_overload_match): Update. (find_oload_champ): Update. Change-Id: I76bdc8b44eea6876bf03af9d351f8e90cc0154b2
2019-11-22 19:05:14 +01:00
&& BLOCK_FUNCTION (var_block)->print_name ())
DWARF: handle non-local references in nested functions GDB's current behavior when dealing with non-local references in the context of nested fuctions is approximative: - code using valops.c:value_of_variable read the first available stack frame that holds the corresponding variable (whereas there can be multiple candidates for this); - code directly relying on read_var_value will instead read non-local variables in frames where they are not even defined. This change adds the necessary context to symbol reads (to get the block they belong to) and to blocks (the static link property, if any) so that GDB can make the proper decisions when dealing with non-local varibale references. gdb/ChangeLog: * ada-lang.c (ada_read_var_value): Add a var_block argument and pass it to default_read_var_value. * block.c (block_static_link): New accessor. * block.h (block_static_link): Declare it. * buildsym.c (finish_block_internal): Add a static_link argument. If there is a static link, associate it to the new block. (finish_block): Add a static link argument and pass it to finish_block_internal. (end_symtab_get_static_block): Update calls to finish_block and to finish_block_internal. (end_symtab_with_blockvector): Update call to finish_block_internal. * buildsym.h: Forward-declare struct dynamic_prop. (struct context_stack): Add a static_link field. (finish_block): Add a static link argument. * c-exp.y: Remove an obsolete comment (evaluation of variables already start from the selected frame, and now they climb *up* the call stack) and propagate the block information to the produced expression. * d-exp.y: Likewise. * f-exp.y: Likewise. * go-exp.y: Likewise. * jv-exp.y: Likewise. * m2-exp.y: Likewise. * p-exp.y: Likewise. * coffread.c (coff_symtab_read): Update calls to finish_block. * dbxread.c (process_one_symbol): Likewise. * xcoffread.c (read_xcoff_symtab): Likewise. * compile/compile-c-symbols.c (convert_one_symbol): Promote the "sym" parameter to struct block_symbol, update its uses and pass its block to calls to read_var_value. (convert_symbol_sym): Update the calls to convert_one_symbol. * compile/compile-loc2c.c (do_compile_dwarf_expr_to_c): Update call to read_var_value. * dwarf2loc.c (block_op_get_frame_base): New. (dwarf2_block_frame_base_locexpr_funcs): Implement the get_frame_base method. (dwarf2_block_frame_base_loclist_funcs): Likewise. (dwarf2locexpr_baton_eval): Add a frame argument and use it instead of the selected frame in order to evaluate the expression. (dwarf2_evaluate_property): Add a frame argument. Update call to dwarf2_locexpr_baton_eval to provide a frame in available and to handle the absence of address stack. * dwarf2loc.h (dwarf2_evaluate_property): Add a frame argument. * dwarf2read.c (attr_to_dynamic_prop): Add a forward declaration. (read_func_scope): Record any available static link description. Update call to finish_block. (read_lexical_block_scope): Update call to finish_block. * findvar.c (follow_static_link): New. (get_hosting_frame): New. (default_read_var_value): Add a var_block argument. Use get_hosting_frame to handle non-local references. (read_var_value): Add a var_block argument and pass it to the LA_READ_VAR_VALUE method. * gdbtypes.c (resolve_dynamic_range): Update calls to dwarf2_evaluate_property. (resolve_dynamic_type_internal): Likewise. * guile/scm-frame.c (gdbscm_frame_read_var): Update call to read_var_value, passing it the block coming from symbol lookup. * guile/scm-symbol.c (gdbscm_symbol_value): Update call to read_var_value (TODO). * infcmd.c (finish_command_continuation): Update call to read_var_value, passing it the block coming from symbol lookup. * infrun.c (insert_exception_resume_breakpoint): Likewise. * language.h (struct language_defn): Add a var_block argument to the LA_READ_VAR_VALUE method. * objfiles.c (struct static_link_htab_entry): New. (static_link_htab_entry_hash): New. (static_link_htab_entry_eq): New. (objfile_register_static_link): New. (objfile_lookup_static_link): New. (free_objfile): Free the STATIC_LINKS hashed map if needed. * objfiles.h: Include hashtab.h. (struct objfile): Add a static_links field. (objfile_register_static_link): New. (objfile_lookup_static_link): New. * printcmd.c (print_variable_and_value): Update call to read_var_value. * python/py-finishbreakpoint.c (bpfinishpy_init): Likewise. * python/py-frame.c (frapy_read_var): Update call to read_var_value, passing it the block coming from symbol lookup. * python/py-framefilter.c (extract_sym): Add a sym_block parameter and set the pointed value to NULL (TODO). (enumerate_args): Update call to extract_sym. (enumerate_locals): Update calls to extract_sym and to read_var_value. * python/py-symbol.c (sympy_value): Update call to read_var_value (TODO). * stack.c (read_frame_local): Update call to read_var_value. (read_frame_arg): Likewise. (return_command): Likewise. * symtab.h (struct symbol_block_ops): Add a get_frame_base method. (struct symbol): Add a block field. (SYMBOL_BLOCK): New accessor. * valops.c (value_of_variable): Remove frame/block handling and pass the block argument to read_var_value, which does this job now. (value_struct_elt_for_reference): Update calls to read_var_value. (value_of_this): Pass the block found to read_var_value. * value.h (read_var_value): Add a var_block argument. (default_read_var_value): Likewise. gdb/testsuite/ChangeLog: * gdb.base/nested-subp1.exp: New file. * gdb.base/nested-subp1.c: New file. * gdb.base/nested-subp2.exp: New file. * gdb.base/nested-subp2.c: New file. * gdb.base/nested-subp3.exp: New file. * gdb.base/nested-subp3.c: New file.
2015-02-05 17:00:06 +01:00
error (_("No frame is currently executing in block %s."),
Replace SYMBOL_*_NAME accessors with member functions Similar to the MSYMBOL version of this patch, improves readability and will eventually allow making name private. gdb/ChangeLog: 2019-11-22 Christian Biesinger <cbiesinger@google.com> * ada-exp.y: Update. * ada-lang.c (sort_choices): Update. (ada_print_symbol_signature): Update. (resolve_subexp): Update. (ada_parse_renaming): Update. (ada_read_renaming_var_value): Update. (lesseq_defined_than): Update. (remove_extra_symbols): Update. (remove_irrelevant_renamings): Update. (ada_add_block_symbols): Update. (ada_collect_symbol_completion_matches): Update. (ada_is_renaming_symbol): Update. (aggregate_assign_from_choices): Update. (ada_evaluate_subexp): Update. (ada_has_this_exception_support): Update. (ada_is_non_standard_exception_sym): Update. (ada_add_exceptions_from_frame): Update. (ada_add_global_exceptions): Update. (ada_print_subexp): Update. * ax-gdb.c (gen_var_ref): Update. (gen_maybe_namespace_elt): Update. (gen_expr_for_cast): Update. (gen_expr): Update. * block.h: Update. * blockframe.c (find_pc_partial_function): Update. * breakpoint.c (print_breakpoint_location): Update. (update_static_tracepoint): Update. * btrace.c (ftrace_print_function_name): Update. (ftrace_function_switched): Update. * buildsym.c (find_symbol_in_list): Update. * c-exp.y: Update. * c-typeprint.c (c_print_typedef): Update. (c_type_print_template_args): Update. * cli/cli-cmds.c (edit_command): Update. (list_command): Update. (print_sal_location): Update. * coffread.c (patch_opaque_types): Update. (process_coff_symbol): Update. (coff_read_enum_type): Update. * compile/compile-c-symbols.c (c_symbol_substitution_name): Update. (convert_one_symbol): Update. (hash_symname): Update. (eq_symname): Update. * compile/compile-cplus-symbols.c (convert_one_symbol): Update. * compile/compile-cplus-types.c (debug_print_scope): Update. * compile/compile-loc2c.c (do_compile_dwarf_expr_to_c): Update. * compile/compile-object-load.c (get_out_value_type): Update. * cp-namespace.c (cp_scan_for_anonymous_namespaces): Update. (search_symbol_list): Update. (cp_lookup_symbol_imports_or_template): Update. * cp-support.c (overload_list_add_symbol): Update. * ctfread.c (psymtab_to_symtab): Update. * dbxread.c (cp_set_block_scope): Update. * dictionary.c (iter_match_first_hashed): Update. (iter_match_next_hashed): Update. (insert_symbol_hashed): Update. (iter_match_next_linear): Update. * dictionary.h: Update. * dwarf2loc.c (func_get_frame_base_dwarf_block): Update. (locexpr_describe_location_piece): Update. (locexpr_describe_location_1): Update. (locexpr_generate_c_location): Update. (loclist_describe_location): Update. (loclist_generate_c_location): Update. * dwarf2read.c (dw2_debug_names_lookup_symbol): Update. (read_func_scope): Update. (process_enumeration_scope): Update. (new_symbol): Update. (dwarf2_const_value): Update. (dwarf2_symbol_mark_computed): Update. * eval.c (evaluate_funcall): Update. (evaluate_subexp_standard): Update. * expprint.c (print_subexp_standard): Update. (dump_subexp_body_standard): Update. * f-valprint.c (info_common_command_for_block): Update. * findvar.c (get_hosting_frame): Update. (default_read_var_value): Update. * go-lang.c (go_symbol_package_name): Update. * guile/scm-block.c (bkscm_print_block_smob): Update. * guile/scm-symbol.c (syscm_print_symbol_smob): Update. (gdbscm_symbol_name): Update. (gdbscm_symbol_linkage_name): Update. (gdbscm_symbol_print_name): Update. * infcall.c (get_function_name): Update. * infcmd.c (jump_command): Update. (finish_command): Update. * infrun.c (insert_exception_resume_breakpoint): Update. * linespec.c (canonicalize_linespec): Update. (create_sals_line_offset): Update. (convert_linespec_to_sals): Update. (complete_label): Update. (find_label_symbols_in_block): Update. * m2-typeprint.c (m2_print_typedef): Update. * mdebugread.c (mdebug_reg_to_regnum): Update. (parse_symbol): Update. (mylookup_symbol): Update. * mi/mi-cmd-stack.c (list_arg_or_local): Update. (list_args_or_locals): Update. * objc-lang.c (compare_selectors): Update. (info_selectors_command): Update. (compare_classes): Update. (info_classes_command): Update. (find_imps): Update. * p-typeprint.c (pascal_print_typedef): Update. * printcmd.c (build_address_symbolic): Update. (info_address_command): Update. (print_variable_and_value): Update. * python/py-framefilter.c (extract_sym): Update. (py_print_single_arg): Update. * python/py-symbol.c (sympy_str): Update. (sympy_get_name): Update. (sympy_get_linkage_name): Update. * python/python.c (gdbpy_rbreak): Update. * record-btrace.c (btrace_get_bfun_name): Update. (btrace_call_history): Update. * rust-lang.c (rust_print_typedef): Update. * solib-frv.c (frv_fdpic_find_canonical_descriptor): Update. * stabsread.c (stab_reg_to_regnum): Update. (define_symbol): Update. (read_enum_type): Update. (common_block_end): Update. (cleanup_undefined_types_1): Update. (scan_file_globals): Update. * stack.c (print_frame_arg): Update. (print_frame_args): Update. (find_frame_funname): Update. (info_frame_command_core): Update. (iterate_over_block_locals): Update. (print_block_frame_labels): Update. (do_print_variable_and_value): Update. (iterate_over_block_arg_vars): Update. (return_command): Update. * symmisc.c (dump_symtab_1): Update. (print_symbol): Update. * symtab.c (eq_symbol_entry): Update. (symbol_cache_dump): Update. (lookup_language_this): Update. (find_pc_sect_line): Update. (skip_prologue_sal): Update. (symbol_search::compare_search_syms): Update. (treg_matches_sym_type_name): Update. (search_symbols): Update. (print_symbol_info): Update. (rbreak_command): Update. (completion_list_add_symbol): Update. (find_gnu_ifunc): Update. (get_symbol_address): Update. (search_module_symbols): Update. (info_module_subcommand): Update. * symtab.h (SYMBOL_NATURAL_NAME): Remove. (SYMBOL_LINKAGE_NAME): Remove. (SYMBOL_DEMANGLED_NAME): Remove. (SYMBOL_PRINT_NAME): Remove. (SYMBOL_SEARCH_NAME): Remove. * tracepoint.c (set_traceframe_context): Update. (validate_actionline): Update. (collection_list::collect_symbol): Update. (encode_actions_1): Update. (info_scope_command): Update. (print_one_static_tracepoint_marker): Update. * typeprint.c (typedef_hash_table::add_template_parameters): Update. * valops.c (address_of_variable): Update. (find_overload_match): Update. (find_oload_champ): Update. Change-Id: I76bdc8b44eea6876bf03af9d351f8e90cc0154b2
2019-11-22 19:05:14 +01:00
BLOCK_FUNCTION (var_block)->print_name ());
DWARF: handle non-local references in nested functions GDB's current behavior when dealing with non-local references in the context of nested fuctions is approximative: - code using valops.c:value_of_variable read the first available stack frame that holds the corresponding variable (whereas there can be multiple candidates for this); - code directly relying on read_var_value will instead read non-local variables in frames where they are not even defined. This change adds the necessary context to symbol reads (to get the block they belong to) and to blocks (the static link property, if any) so that GDB can make the proper decisions when dealing with non-local varibale references. gdb/ChangeLog: * ada-lang.c (ada_read_var_value): Add a var_block argument and pass it to default_read_var_value. * block.c (block_static_link): New accessor. * block.h (block_static_link): Declare it. * buildsym.c (finish_block_internal): Add a static_link argument. If there is a static link, associate it to the new block. (finish_block): Add a static link argument and pass it to finish_block_internal. (end_symtab_get_static_block): Update calls to finish_block and to finish_block_internal. (end_symtab_with_blockvector): Update call to finish_block_internal. * buildsym.h: Forward-declare struct dynamic_prop. (struct context_stack): Add a static_link field. (finish_block): Add a static link argument. * c-exp.y: Remove an obsolete comment (evaluation of variables already start from the selected frame, and now they climb *up* the call stack) and propagate the block information to the produced expression. * d-exp.y: Likewise. * f-exp.y: Likewise. * go-exp.y: Likewise. * jv-exp.y: Likewise. * m2-exp.y: Likewise. * p-exp.y: Likewise. * coffread.c (coff_symtab_read): Update calls to finish_block. * dbxread.c (process_one_symbol): Likewise. * xcoffread.c (read_xcoff_symtab): Likewise. * compile/compile-c-symbols.c (convert_one_symbol): Promote the "sym" parameter to struct block_symbol, update its uses and pass its block to calls to read_var_value. (convert_symbol_sym): Update the calls to convert_one_symbol. * compile/compile-loc2c.c (do_compile_dwarf_expr_to_c): Update call to read_var_value. * dwarf2loc.c (block_op_get_frame_base): New. (dwarf2_block_frame_base_locexpr_funcs): Implement the get_frame_base method. (dwarf2_block_frame_base_loclist_funcs): Likewise. (dwarf2locexpr_baton_eval): Add a frame argument and use it instead of the selected frame in order to evaluate the expression. (dwarf2_evaluate_property): Add a frame argument. Update call to dwarf2_locexpr_baton_eval to provide a frame in available and to handle the absence of address stack. * dwarf2loc.h (dwarf2_evaluate_property): Add a frame argument. * dwarf2read.c (attr_to_dynamic_prop): Add a forward declaration. (read_func_scope): Record any available static link description. Update call to finish_block. (read_lexical_block_scope): Update call to finish_block. * findvar.c (follow_static_link): New. (get_hosting_frame): New. (default_read_var_value): Add a var_block argument. Use get_hosting_frame to handle non-local references. (read_var_value): Add a var_block argument and pass it to the LA_READ_VAR_VALUE method. * gdbtypes.c (resolve_dynamic_range): Update calls to dwarf2_evaluate_property. (resolve_dynamic_type_internal): Likewise. * guile/scm-frame.c (gdbscm_frame_read_var): Update call to read_var_value, passing it the block coming from symbol lookup. * guile/scm-symbol.c (gdbscm_symbol_value): Update call to read_var_value (TODO). * infcmd.c (finish_command_continuation): Update call to read_var_value, passing it the block coming from symbol lookup. * infrun.c (insert_exception_resume_breakpoint): Likewise. * language.h (struct language_defn): Add a var_block argument to the LA_READ_VAR_VALUE method. * objfiles.c (struct static_link_htab_entry): New. (static_link_htab_entry_hash): New. (static_link_htab_entry_eq): New. (objfile_register_static_link): New. (objfile_lookup_static_link): New. (free_objfile): Free the STATIC_LINKS hashed map if needed. * objfiles.h: Include hashtab.h. (struct objfile): Add a static_links field. (objfile_register_static_link): New. (objfile_lookup_static_link): New. * printcmd.c (print_variable_and_value): Update call to read_var_value. * python/py-finishbreakpoint.c (bpfinishpy_init): Likewise. * python/py-frame.c (frapy_read_var): Update call to read_var_value, passing it the block coming from symbol lookup. * python/py-framefilter.c (extract_sym): Add a sym_block parameter and set the pointed value to NULL (TODO). (enumerate_args): Update call to extract_sym. (enumerate_locals): Update calls to extract_sym and to read_var_value. * python/py-symbol.c (sympy_value): Update call to read_var_value (TODO). * stack.c (read_frame_local): Update call to read_var_value. (read_frame_arg): Likewise. (return_command): Likewise. * symtab.h (struct symbol_block_ops): Add a get_frame_base method. (struct symbol): Add a block field. (SYMBOL_BLOCK): New accessor. * valops.c (value_of_variable): Remove frame/block handling and pass the block argument to read_var_value, which does this job now. (value_struct_elt_for_reference): Update calls to read_var_value. (value_of_this): Pass the block found to read_var_value. * value.h (read_var_value): Add a var_block argument. (default_read_var_value): Likewise. gdb/testsuite/ChangeLog: * gdb.base/nested-subp1.exp: New file. * gdb.base/nested-subp1.c: New file. * gdb.base/nested-subp2.exp: New file. * gdb.base/nested-subp2.c: New file. * gdb.base/nested-subp3.exp: New file. * gdb.base/nested-subp3.c: New file.
2015-02-05 17:00:06 +01:00
else
error (_("No frame is currently executing in specified"
" block"));
}
}
return frame;
}
gdb: Convert language la_read_var_value field to a method This commit changes the language_data::la_read_var_value function pointer member variable into a member function of language_defn. An interesting aspect of this change is that the implementation of language_defn::read_var_value is actually in findvar.c. This is partly historical, the new language_defn::read_var_value is a rename of default_read_var_value, which was already in that file, but also, that is the file that contains the helper functions needed by the read_var_value method, so it makes sens that the method implementation should continue to live there (I think). There should be no user visible changes after this commit. gdb/ChangeLog: * ada-lang.c (ada_read_var_value): Delete function, move implementation to... (ada_language::read_var_value): ...here. (ada_language_data): Delete la_read_var_value initializer. * c-lang.c (c_language_data): Likewise. (cplus_language_data): Likewise. (minimal_language_data): Likewise. * d-lang.c (d_language_data): Likewise. * f-lang.c (f_language_data): Likewise. * findvar.c (default_read_var_value): Rename to... (language_defn::read_var_value): ...this. * findvar.c (read_var_value): Update header comment, and change to call member function instead of function pointer. * go-lang.c (go_language_data): Likewise. * language.c (unknown_language_data): Delete la_read_var_value initializer. (auto_language_data): Likewise. * language.h (struct language_data): Delete la_read_var_value field. (language_defn::read_var_value): New member function. (default_read_var_value): Delete declaration. * m2-lang.c (m2_language_data): Delete la_read_var_value initializer. * objc-lang.c (objc_language_data): Likewise. * opencl-lang.c (opencl_language_data): Likewise. * p-lang.c (pascal_language_data): Likewise. * rust-lang.c (rust_language_data): Likewise. * value.h (default_read_var_value): Delete declaration.
2020-05-01 18:33:22 +02:00
/* See language.h. */
2001-11-10 22:34:56 +01:00
struct value *
gdb: Convert language la_read_var_value field to a method This commit changes the language_data::la_read_var_value function pointer member variable into a member function of language_defn. An interesting aspect of this change is that the implementation of language_defn::read_var_value is actually in findvar.c. This is partly historical, the new language_defn::read_var_value is a rename of default_read_var_value, which was already in that file, but also, that is the file that contains the helper functions needed by the read_var_value method, so it makes sens that the method implementation should continue to live there (I think). There should be no user visible changes after this commit. gdb/ChangeLog: * ada-lang.c (ada_read_var_value): Delete function, move implementation to... (ada_language::read_var_value): ...here. (ada_language_data): Delete la_read_var_value initializer. * c-lang.c (c_language_data): Likewise. (cplus_language_data): Likewise. (minimal_language_data): Likewise. * d-lang.c (d_language_data): Likewise. * f-lang.c (f_language_data): Likewise. * findvar.c (default_read_var_value): Rename to... (language_defn::read_var_value): ...this. * findvar.c (read_var_value): Update header comment, and change to call member function instead of function pointer. * go-lang.c (go_language_data): Likewise. * language.c (unknown_language_data): Delete la_read_var_value initializer. (auto_language_data): Likewise. * language.h (struct language_data): Delete la_read_var_value field. (language_defn::read_var_value): New member function. (default_read_var_value): Delete declaration. * m2-lang.c (m2_language_data): Delete la_read_var_value initializer. * objc-lang.c (objc_language_data): Likewise. * opencl-lang.c (opencl_language_data): Likewise. * p-lang.c (pascal_language_data): Likewise. * rust-lang.c (rust_language_data): Likewise. * value.h (default_read_var_value): Delete declaration.
2020-05-01 18:33:22 +02:00
language_defn::read_var_value (struct symbol *var,
const struct block *var_block,
struct frame_info *frame) const
{
struct value *v;
struct type *type = SYMBOL_TYPE (var);
CORE_ADDR addr;
PR python/20190 - compute TLS symbol without a frame PR python/20190 arose from an exception I noticed when trying to use the Python unwinder for Spider Monkey in Firefox. The problem is that the unwinder wants to examine the value of a thread-local variable. However, sympy_value rejects this because symbol_read_needs_frame returns true for a TLS variable. This problem arose once before, though in a different context: https://sourceware.org/bugzilla/show_bug.cgi?id=11803 At the time Pedro and Daniel pointed out a simpler way to fix that bug (see links in 20190 if you are interested); but for this new bug I couldn't think of a similar fix and ended up implementing Daniel's other suggestion: https://sourceware.org/ml/gdb-patches/2010-07/msg00393.html That is, this patch makes it possible to detect whether a symbol needs a specific frame, or whether it just needs the inferior to have registers. Built and regtested on x86-64 Fedora 24. 2016-07-26 Tom Tromey <tom@tromey.com> * symtab.c (register_symbol_computed_impl): Update. PR python/20190: * value.h (symbol_read_needs): Declare. (symbol_read_needs_frame): Add comment. * symtab.h (struct symbol_computed_ops) <read_variable>: Update comment. <get_symbol_read_needs>: Rename. Change return type. * findvar.c (symbol_read_needs): New function. (symbol_read_needs_frame): Rewrite. (default_read_var_value): Use symbol_read_needs. * dwarf2loc.c (struct symbol_needs_baton): Rename. <needs>: Renamed from needs_frame. Changed type. (needs_frame_read_addr_from_reg, symbol_needs_get_reg_value) (symbol_needs_read_mem, symbol_needs_frame_base) (symbol_needs_frame_cfa, symbol_needs_tls_address) (symbol_needs_dwarf_call): Rename. (needs_dwarf_reg_entry_value): Update. (symbol_needs_ctx_funcs, dwarf2_loc_desc_get_symbol_read_needs): Rename and update. (locexpr_get_symbol_read_needs, loclist_symbol_needs): Likewise. (dwarf2_locexpr_funcs, dwarf2_loclist_funcs): Update. * defs.h (enum symbol_needs_kind): New. 2016-07-26 Tom Tromey <tom@tromey.com> PR python/20190: * gdb.threads/tls.exp (check_thread_local): Add python symbol test.
2016-06-03 22:11:08 +02:00
enum symbol_needs_kind sym_need;
/* Call check_typedef on our type to make sure that, if TYPE is
a TYPE_CODE_TYPEDEF, its length is set to the length of the target type
instead of zero. However, we do not replace the typedef type by the
target type, because we want to keep the typedef in order to be able to
set the returned value type description correctly. */
check_typedef (type);
PR python/20190 - compute TLS symbol without a frame PR python/20190 arose from an exception I noticed when trying to use the Python unwinder for Spider Monkey in Firefox. The problem is that the unwinder wants to examine the value of a thread-local variable. However, sympy_value rejects this because symbol_read_needs_frame returns true for a TLS variable. This problem arose once before, though in a different context: https://sourceware.org/bugzilla/show_bug.cgi?id=11803 At the time Pedro and Daniel pointed out a simpler way to fix that bug (see links in 20190 if you are interested); but for this new bug I couldn't think of a similar fix and ended up implementing Daniel's other suggestion: https://sourceware.org/ml/gdb-patches/2010-07/msg00393.html That is, this patch makes it possible to detect whether a symbol needs a specific frame, or whether it just needs the inferior to have registers. Built and regtested on x86-64 Fedora 24. 2016-07-26 Tom Tromey <tom@tromey.com> * symtab.c (register_symbol_computed_impl): Update. PR python/20190: * value.h (symbol_read_needs): Declare. (symbol_read_needs_frame): Add comment. * symtab.h (struct symbol_computed_ops) <read_variable>: Update comment. <get_symbol_read_needs>: Rename. Change return type. * findvar.c (symbol_read_needs): New function. (symbol_read_needs_frame): Rewrite. (default_read_var_value): Use symbol_read_needs. * dwarf2loc.c (struct symbol_needs_baton): Rename. <needs>: Renamed from needs_frame. Changed type. (needs_frame_read_addr_from_reg, symbol_needs_get_reg_value) (symbol_needs_read_mem, symbol_needs_frame_base) (symbol_needs_frame_cfa, symbol_needs_tls_address) (symbol_needs_dwarf_call): Rename. (needs_dwarf_reg_entry_value): Update. (symbol_needs_ctx_funcs, dwarf2_loc_desc_get_symbol_read_needs): Rename and update. (locexpr_get_symbol_read_needs, loclist_symbol_needs): Likewise. (dwarf2_locexpr_funcs, dwarf2_loclist_funcs): Update. * defs.h (enum symbol_needs_kind): New. 2016-07-26 Tom Tromey <tom@tromey.com> PR python/20190: * gdb.threads/tls.exp (check_thread_local): Add python symbol test.
2016-06-03 22:11:08 +02:00
sym_need = symbol_read_needs (var);
if (sym_need == SYMBOL_NEEDS_FRAME)
DWARF: handle non-local references in nested functions GDB's current behavior when dealing with non-local references in the context of nested fuctions is approximative: - code using valops.c:value_of_variable read the first available stack frame that holds the corresponding variable (whereas there can be multiple candidates for this); - code directly relying on read_var_value will instead read non-local variables in frames where they are not even defined. This change adds the necessary context to symbol reads (to get the block they belong to) and to blocks (the static link property, if any) so that GDB can make the proper decisions when dealing with non-local varibale references. gdb/ChangeLog: * ada-lang.c (ada_read_var_value): Add a var_block argument and pass it to default_read_var_value. * block.c (block_static_link): New accessor. * block.h (block_static_link): Declare it. * buildsym.c (finish_block_internal): Add a static_link argument. If there is a static link, associate it to the new block. (finish_block): Add a static link argument and pass it to finish_block_internal. (end_symtab_get_static_block): Update calls to finish_block and to finish_block_internal. (end_symtab_with_blockvector): Update call to finish_block_internal. * buildsym.h: Forward-declare struct dynamic_prop. (struct context_stack): Add a static_link field. (finish_block): Add a static link argument. * c-exp.y: Remove an obsolete comment (evaluation of variables already start from the selected frame, and now they climb *up* the call stack) and propagate the block information to the produced expression. * d-exp.y: Likewise. * f-exp.y: Likewise. * go-exp.y: Likewise. * jv-exp.y: Likewise. * m2-exp.y: Likewise. * p-exp.y: Likewise. * coffread.c (coff_symtab_read): Update calls to finish_block. * dbxread.c (process_one_symbol): Likewise. * xcoffread.c (read_xcoff_symtab): Likewise. * compile/compile-c-symbols.c (convert_one_symbol): Promote the "sym" parameter to struct block_symbol, update its uses and pass its block to calls to read_var_value. (convert_symbol_sym): Update the calls to convert_one_symbol. * compile/compile-loc2c.c (do_compile_dwarf_expr_to_c): Update call to read_var_value. * dwarf2loc.c (block_op_get_frame_base): New. (dwarf2_block_frame_base_locexpr_funcs): Implement the get_frame_base method. (dwarf2_block_frame_base_loclist_funcs): Likewise. (dwarf2locexpr_baton_eval): Add a frame argument and use it instead of the selected frame in order to evaluate the expression. (dwarf2_evaluate_property): Add a frame argument. Update call to dwarf2_locexpr_baton_eval to provide a frame in available and to handle the absence of address stack. * dwarf2loc.h (dwarf2_evaluate_property): Add a frame argument. * dwarf2read.c (attr_to_dynamic_prop): Add a forward declaration. (read_func_scope): Record any available static link description. Update call to finish_block. (read_lexical_block_scope): Update call to finish_block. * findvar.c (follow_static_link): New. (get_hosting_frame): New. (default_read_var_value): Add a var_block argument. Use get_hosting_frame to handle non-local references. (read_var_value): Add a var_block argument and pass it to the LA_READ_VAR_VALUE method. * gdbtypes.c (resolve_dynamic_range): Update calls to dwarf2_evaluate_property. (resolve_dynamic_type_internal): Likewise. * guile/scm-frame.c (gdbscm_frame_read_var): Update call to read_var_value, passing it the block coming from symbol lookup. * guile/scm-symbol.c (gdbscm_symbol_value): Update call to read_var_value (TODO). * infcmd.c (finish_command_continuation): Update call to read_var_value, passing it the block coming from symbol lookup. * infrun.c (insert_exception_resume_breakpoint): Likewise. * language.h (struct language_defn): Add a var_block argument to the LA_READ_VAR_VALUE method. * objfiles.c (struct static_link_htab_entry): New. (static_link_htab_entry_hash): New. (static_link_htab_entry_eq): New. (objfile_register_static_link): New. (objfile_lookup_static_link): New. (free_objfile): Free the STATIC_LINKS hashed map if needed. * objfiles.h: Include hashtab.h. (struct objfile): Add a static_links field. (objfile_register_static_link): New. (objfile_lookup_static_link): New. * printcmd.c (print_variable_and_value): Update call to read_var_value. * python/py-finishbreakpoint.c (bpfinishpy_init): Likewise. * python/py-frame.c (frapy_read_var): Update call to read_var_value, passing it the block coming from symbol lookup. * python/py-framefilter.c (extract_sym): Add a sym_block parameter and set the pointed value to NULL (TODO). (enumerate_args): Update call to extract_sym. (enumerate_locals): Update calls to extract_sym and to read_var_value. * python/py-symbol.c (sympy_value): Update call to read_var_value (TODO). * stack.c (read_frame_local): Update call to read_var_value. (read_frame_arg): Likewise. (return_command): Likewise. * symtab.h (struct symbol_block_ops): Add a get_frame_base method. (struct symbol): Add a block field. (SYMBOL_BLOCK): New accessor. * valops.c (value_of_variable): Remove frame/block handling and pass the block argument to read_var_value, which does this job now. (value_struct_elt_for_reference): Update calls to read_var_value. (value_of_this): Pass the block found to read_var_value. * value.h (read_var_value): Add a var_block argument. (default_read_var_value): Likewise. gdb/testsuite/ChangeLog: * gdb.base/nested-subp1.exp: New file. * gdb.base/nested-subp1.c: New file. * gdb.base/nested-subp2.exp: New file. * gdb.base/nested-subp2.c: New file. * gdb.base/nested-subp3.exp: New file. * gdb.base/nested-subp3.c: New file.
2015-02-05 17:00:06 +01:00
gdb_assert (frame != NULL);
PR python/20190 - compute TLS symbol without a frame PR python/20190 arose from an exception I noticed when trying to use the Python unwinder for Spider Monkey in Firefox. The problem is that the unwinder wants to examine the value of a thread-local variable. However, sympy_value rejects this because symbol_read_needs_frame returns true for a TLS variable. This problem arose once before, though in a different context: https://sourceware.org/bugzilla/show_bug.cgi?id=11803 At the time Pedro and Daniel pointed out a simpler way to fix that bug (see links in 20190 if you are interested); but for this new bug I couldn't think of a similar fix and ended up implementing Daniel's other suggestion: https://sourceware.org/ml/gdb-patches/2010-07/msg00393.html That is, this patch makes it possible to detect whether a symbol needs a specific frame, or whether it just needs the inferior to have registers. Built and regtested on x86-64 Fedora 24. 2016-07-26 Tom Tromey <tom@tromey.com> * symtab.c (register_symbol_computed_impl): Update. PR python/20190: * value.h (symbol_read_needs): Declare. (symbol_read_needs_frame): Add comment. * symtab.h (struct symbol_computed_ops) <read_variable>: Update comment. <get_symbol_read_needs>: Rename. Change return type. * findvar.c (symbol_read_needs): New function. (symbol_read_needs_frame): Rewrite. (default_read_var_value): Use symbol_read_needs. * dwarf2loc.c (struct symbol_needs_baton): Rename. <needs>: Renamed from needs_frame. Changed type. (needs_frame_read_addr_from_reg, symbol_needs_get_reg_value) (symbol_needs_read_mem, symbol_needs_frame_base) (symbol_needs_frame_cfa, symbol_needs_tls_address) (symbol_needs_dwarf_call): Rename. (needs_dwarf_reg_entry_value): Update. (symbol_needs_ctx_funcs, dwarf2_loc_desc_get_symbol_read_needs): Rename and update. (locexpr_get_symbol_read_needs, loclist_symbol_needs): Likewise. (dwarf2_locexpr_funcs, dwarf2_loclist_funcs): Update. * defs.h (enum symbol_needs_kind): New. 2016-07-26 Tom Tromey <tom@tromey.com> PR python/20190: * gdb.threads/tls.exp (check_thread_local): Add python symbol test.
2016-06-03 22:11:08 +02:00
else if (sym_need == SYMBOL_NEEDS_REGISTERS && !target_has_registers)
Replace SYMBOL_*_NAME accessors with member functions Similar to the MSYMBOL version of this patch, improves readability and will eventually allow making name private. gdb/ChangeLog: 2019-11-22 Christian Biesinger <cbiesinger@google.com> * ada-exp.y: Update. * ada-lang.c (sort_choices): Update. (ada_print_symbol_signature): Update. (resolve_subexp): Update. (ada_parse_renaming): Update. (ada_read_renaming_var_value): Update. (lesseq_defined_than): Update. (remove_extra_symbols): Update. (remove_irrelevant_renamings): Update. (ada_add_block_symbols): Update. (ada_collect_symbol_completion_matches): Update. (ada_is_renaming_symbol): Update. (aggregate_assign_from_choices): Update. (ada_evaluate_subexp): Update. (ada_has_this_exception_support): Update. (ada_is_non_standard_exception_sym): Update. (ada_add_exceptions_from_frame): Update. (ada_add_global_exceptions): Update. (ada_print_subexp): Update. * ax-gdb.c (gen_var_ref): Update. (gen_maybe_namespace_elt): Update. (gen_expr_for_cast): Update. (gen_expr): Update. * block.h: Update. * blockframe.c (find_pc_partial_function): Update. * breakpoint.c (print_breakpoint_location): Update. (update_static_tracepoint): Update. * btrace.c (ftrace_print_function_name): Update. (ftrace_function_switched): Update. * buildsym.c (find_symbol_in_list): Update. * c-exp.y: Update. * c-typeprint.c (c_print_typedef): Update. (c_type_print_template_args): Update. * cli/cli-cmds.c (edit_command): Update. (list_command): Update. (print_sal_location): Update. * coffread.c (patch_opaque_types): Update. (process_coff_symbol): Update. (coff_read_enum_type): Update. * compile/compile-c-symbols.c (c_symbol_substitution_name): Update. (convert_one_symbol): Update. (hash_symname): Update. (eq_symname): Update. * compile/compile-cplus-symbols.c (convert_one_symbol): Update. * compile/compile-cplus-types.c (debug_print_scope): Update. * compile/compile-loc2c.c (do_compile_dwarf_expr_to_c): Update. * compile/compile-object-load.c (get_out_value_type): Update. * cp-namespace.c (cp_scan_for_anonymous_namespaces): Update. (search_symbol_list): Update. (cp_lookup_symbol_imports_or_template): Update. * cp-support.c (overload_list_add_symbol): Update. * ctfread.c (psymtab_to_symtab): Update. * dbxread.c (cp_set_block_scope): Update. * dictionary.c (iter_match_first_hashed): Update. (iter_match_next_hashed): Update. (insert_symbol_hashed): Update. (iter_match_next_linear): Update. * dictionary.h: Update. * dwarf2loc.c (func_get_frame_base_dwarf_block): Update. (locexpr_describe_location_piece): Update. (locexpr_describe_location_1): Update. (locexpr_generate_c_location): Update. (loclist_describe_location): Update. (loclist_generate_c_location): Update. * dwarf2read.c (dw2_debug_names_lookup_symbol): Update. (read_func_scope): Update. (process_enumeration_scope): Update. (new_symbol): Update. (dwarf2_const_value): Update. (dwarf2_symbol_mark_computed): Update. * eval.c (evaluate_funcall): Update. (evaluate_subexp_standard): Update. * expprint.c (print_subexp_standard): Update. (dump_subexp_body_standard): Update. * f-valprint.c (info_common_command_for_block): Update. * findvar.c (get_hosting_frame): Update. (default_read_var_value): Update. * go-lang.c (go_symbol_package_name): Update. * guile/scm-block.c (bkscm_print_block_smob): Update. * guile/scm-symbol.c (syscm_print_symbol_smob): Update. (gdbscm_symbol_name): Update. (gdbscm_symbol_linkage_name): Update. (gdbscm_symbol_print_name): Update. * infcall.c (get_function_name): Update. * infcmd.c (jump_command): Update. (finish_command): Update. * infrun.c (insert_exception_resume_breakpoint): Update. * linespec.c (canonicalize_linespec): Update. (create_sals_line_offset): Update. (convert_linespec_to_sals): Update. (complete_label): Update. (find_label_symbols_in_block): Update. * m2-typeprint.c (m2_print_typedef): Update. * mdebugread.c (mdebug_reg_to_regnum): Update. (parse_symbol): Update. (mylookup_symbol): Update. * mi/mi-cmd-stack.c (list_arg_or_local): Update. (list_args_or_locals): Update. * objc-lang.c (compare_selectors): Update. (info_selectors_command): Update. (compare_classes): Update. (info_classes_command): Update. (find_imps): Update. * p-typeprint.c (pascal_print_typedef): Update. * printcmd.c (build_address_symbolic): Update. (info_address_command): Update. (print_variable_and_value): Update. * python/py-framefilter.c (extract_sym): Update. (py_print_single_arg): Update. * python/py-symbol.c (sympy_str): Update. (sympy_get_name): Update. (sympy_get_linkage_name): Update. * python/python.c (gdbpy_rbreak): Update. * record-btrace.c (btrace_get_bfun_name): Update. (btrace_call_history): Update. * rust-lang.c (rust_print_typedef): Update. * solib-frv.c (frv_fdpic_find_canonical_descriptor): Update. * stabsread.c (stab_reg_to_regnum): Update. (define_symbol): Update. (read_enum_type): Update. (common_block_end): Update. (cleanup_undefined_types_1): Update. (scan_file_globals): Update. * stack.c (print_frame_arg): Update. (print_frame_args): Update. (find_frame_funname): Update. (info_frame_command_core): Update. (iterate_over_block_locals): Update. (print_block_frame_labels): Update. (do_print_variable_and_value): Update. (iterate_over_block_arg_vars): Update. (return_command): Update. * symmisc.c (dump_symtab_1): Update. (print_symbol): Update. * symtab.c (eq_symbol_entry): Update. (symbol_cache_dump): Update. (lookup_language_this): Update. (find_pc_sect_line): Update. (skip_prologue_sal): Update. (symbol_search::compare_search_syms): Update. (treg_matches_sym_type_name): Update. (search_symbols): Update. (print_symbol_info): Update. (rbreak_command): Update. (completion_list_add_symbol): Update. (find_gnu_ifunc): Update. (get_symbol_address): Update. (search_module_symbols): Update. (info_module_subcommand): Update. * symtab.h (SYMBOL_NATURAL_NAME): Remove. (SYMBOL_LINKAGE_NAME): Remove. (SYMBOL_DEMANGLED_NAME): Remove. (SYMBOL_PRINT_NAME): Remove. (SYMBOL_SEARCH_NAME): Remove. * tracepoint.c (set_traceframe_context): Update. (validate_actionline): Update. (collection_list::collect_symbol): Update. (encode_actions_1): Update. (info_scope_command): Update. (print_one_static_tracepoint_marker): Update. * typeprint.c (typedef_hash_table::add_template_parameters): Update. * valops.c (address_of_variable): Update. (find_overload_match): Update. (find_oload_champ): Update. Change-Id: I76bdc8b44eea6876bf03af9d351f8e90cc0154b2
2019-11-22 19:05:14 +01:00
error (_("Cannot read `%s' without registers"), var->print_name ());
DWARF: handle non-local references in nested functions GDB's current behavior when dealing with non-local references in the context of nested fuctions is approximative: - code using valops.c:value_of_variable read the first available stack frame that holds the corresponding variable (whereas there can be multiple candidates for this); - code directly relying on read_var_value will instead read non-local variables in frames where they are not even defined. This change adds the necessary context to symbol reads (to get the block they belong to) and to blocks (the static link property, if any) so that GDB can make the proper decisions when dealing with non-local varibale references. gdb/ChangeLog: * ada-lang.c (ada_read_var_value): Add a var_block argument and pass it to default_read_var_value. * block.c (block_static_link): New accessor. * block.h (block_static_link): Declare it. * buildsym.c (finish_block_internal): Add a static_link argument. If there is a static link, associate it to the new block. (finish_block): Add a static link argument and pass it to finish_block_internal. (end_symtab_get_static_block): Update calls to finish_block and to finish_block_internal. (end_symtab_with_blockvector): Update call to finish_block_internal. * buildsym.h: Forward-declare struct dynamic_prop. (struct context_stack): Add a static_link field. (finish_block): Add a static link argument. * c-exp.y: Remove an obsolete comment (evaluation of variables already start from the selected frame, and now they climb *up* the call stack) and propagate the block information to the produced expression. * d-exp.y: Likewise. * f-exp.y: Likewise. * go-exp.y: Likewise. * jv-exp.y: Likewise. * m2-exp.y: Likewise. * p-exp.y: Likewise. * coffread.c (coff_symtab_read): Update calls to finish_block. * dbxread.c (process_one_symbol): Likewise. * xcoffread.c (read_xcoff_symtab): Likewise. * compile/compile-c-symbols.c (convert_one_symbol): Promote the "sym" parameter to struct block_symbol, update its uses and pass its block to calls to read_var_value. (convert_symbol_sym): Update the calls to convert_one_symbol. * compile/compile-loc2c.c (do_compile_dwarf_expr_to_c): Update call to read_var_value. * dwarf2loc.c (block_op_get_frame_base): New. (dwarf2_block_frame_base_locexpr_funcs): Implement the get_frame_base method. (dwarf2_block_frame_base_loclist_funcs): Likewise. (dwarf2locexpr_baton_eval): Add a frame argument and use it instead of the selected frame in order to evaluate the expression. (dwarf2_evaluate_property): Add a frame argument. Update call to dwarf2_locexpr_baton_eval to provide a frame in available and to handle the absence of address stack. * dwarf2loc.h (dwarf2_evaluate_property): Add a frame argument. * dwarf2read.c (attr_to_dynamic_prop): Add a forward declaration. (read_func_scope): Record any available static link description. Update call to finish_block. (read_lexical_block_scope): Update call to finish_block. * findvar.c (follow_static_link): New. (get_hosting_frame): New. (default_read_var_value): Add a var_block argument. Use get_hosting_frame to handle non-local references. (read_var_value): Add a var_block argument and pass it to the LA_READ_VAR_VALUE method. * gdbtypes.c (resolve_dynamic_range): Update calls to dwarf2_evaluate_property. (resolve_dynamic_type_internal): Likewise. * guile/scm-frame.c (gdbscm_frame_read_var): Update call to read_var_value, passing it the block coming from symbol lookup. * guile/scm-symbol.c (gdbscm_symbol_value): Update call to read_var_value (TODO). * infcmd.c (finish_command_continuation): Update call to read_var_value, passing it the block coming from symbol lookup. * infrun.c (insert_exception_resume_breakpoint): Likewise. * language.h (struct language_defn): Add a var_block argument to the LA_READ_VAR_VALUE method. * objfiles.c (struct static_link_htab_entry): New. (static_link_htab_entry_hash): New. (static_link_htab_entry_eq): New. (objfile_register_static_link): New. (objfile_lookup_static_link): New. (free_objfile): Free the STATIC_LINKS hashed map if needed. * objfiles.h: Include hashtab.h. (struct objfile): Add a static_links field. (objfile_register_static_link): New. (objfile_lookup_static_link): New. * printcmd.c (print_variable_and_value): Update call to read_var_value. * python/py-finishbreakpoint.c (bpfinishpy_init): Likewise. * python/py-frame.c (frapy_read_var): Update call to read_var_value, passing it the block coming from symbol lookup. * python/py-framefilter.c (extract_sym): Add a sym_block parameter and set the pointed value to NULL (TODO). (enumerate_args): Update call to extract_sym. (enumerate_locals): Update calls to extract_sym and to read_var_value. * python/py-symbol.c (sympy_value): Update call to read_var_value (TODO). * stack.c (read_frame_local): Update call to read_var_value. (read_frame_arg): Likewise. (return_command): Likewise. * symtab.h (struct symbol_block_ops): Add a get_frame_base method. (struct symbol): Add a block field. (SYMBOL_BLOCK): New accessor. * valops.c (value_of_variable): Remove frame/block handling and pass the block argument to read_var_value, which does this job now. (value_struct_elt_for_reference): Update calls to read_var_value. (value_of_this): Pass the block found to read_var_value. * value.h (read_var_value): Add a var_block argument. (default_read_var_value): Likewise. gdb/testsuite/ChangeLog: * gdb.base/nested-subp1.exp: New file. * gdb.base/nested-subp1.c: New file. * gdb.base/nested-subp2.exp: New file. * gdb.base/nested-subp2.c: New file. * gdb.base/nested-subp3.exp: New file. * gdb.base/nested-subp3.c: New file.
2015-02-05 17:00:06 +01:00
if (frame != NULL)
frame = get_hosting_frame (var, var_block, frame);
if (SYMBOL_COMPUTED_OPS (var) != NULL)
return SYMBOL_COMPUTED_OPS (var)->read_variable (var, frame);
switch (SYMBOL_CLASS (var))
{
case LOC_CONST:
if (is_dynamic_type (type))
{
/* Value is a constant byte-sequence and needs no memory access. */
Prefer existing data when evaluating DWARF expression When evaluating a DWARF expression, the dynamic type resolution code will pass in a buffer of bytes via the property_addr_info. However, the DWARF expression evaluator will then proceed to read memory from the inferior, even when the request could be filled from this buffer. This, in turn, is a problem in some cases; and specifically when trying to handle the Ada scenario of extracting a variable-length value from a packed array. Here, the ordinary DWARF expression cannot be directly evaluated, because the data may appear at some arbitrary bit offset. So, it is unpacked into a staging area and then the expression is evaluated -- using an address of 0. This patch fixes the problem by arranging for the DWARF evaluator, in this case, to prefer passed-in memory when possible. The type of the buffer in the property_addr_info is changed to an array_view so that bounds checking can be done. gdb/ChangeLog 2020-04-24 Tom Tromey <tromey@adacore.com> * ada-lang.c (ada_discrete_type_high_bound, ada_discrete_type_low) (ada_value_primitive_packed_val): Update. * ada-valprint.c (ada_value_print_1): Update. * dwarf2/loc.c (evaluate_for_locexpr_baton): New struct. (dwarf2_locexpr_baton_eval): Take a property_addr_info rather than just an address. Use evaluate_for_locexpr_baton. (dwarf2_evaluate_property): Update. * dwarf2/loc.h (struct property_addr_info) <valaddr>: Now an array_view. * findvar.c (default_read_var_value): Update. * gdbtypes.c (compute_variant_fields_inner) (resolve_dynamic_type_internal): Update. (resolve_dynamic_type): Change type of valaddr parameter. * gdbtypes.h (resolve_dynamic_type): Update. * valarith.c (value_subscripted_rvalue): Update. * value.c (value_from_contents_and_address): Update.
2020-04-24 21:40:31 +02:00
type = resolve_dynamic_type (type, {}, /* Unused address. */ 0);
}
/* Put the constant back in target format. */
v = allocate_value (type);
store_signed_integer (value_contents_raw (v), TYPE_LENGTH (type),
Adjust byte order variable display/change if DW_AT_endianity is present. - 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
2017-10-06 22:13:04 +02:00
type_byte_order (type),
(LONGEST) SYMBOL_VALUE (var));
VALUE_LVAL (v) = not_lval;
return v;
case LOC_LABEL:
/* Put the constant back in target format. */
v = allocate_value (type);
if (overlay_debugging)
* gdbarch.sh (POINTER_TO_ADDRESS, ADDRESS_TO_POINTER): Two new functions which architectures can redefine, defaulting to generic_pointer_to_address and generic_address_to_pointer. * findvar.c (extract_typed_address, store_typed_address, generic_pointer_to_address, generic_address_to_pointer): New functions. (POINTER_TO_ADDRESS, ADDRESS_TO_POINTER): Provide default definitions. (extract_address, store_address): Doc fixes. * values.c (value_as_pointer): Doc fix. (value_from_pointer): New function. * defs.h (extract_typed_address, store_typed_address): New declarations. * inferior.h (generic_address_to_pointer, generic_pointer_to_address): New declarations. * value.h (value_from_pointer): New declaration. * ax-gdb.c (const_var_ref): Use value_from_pointer, not value_from_longest. * blockframe.c (generic_push_dummy_frame): Use read_pc and read_sp, not read_register. * c-valprint.c (c_val_print): Use extract_typed_address instead of extract_address to extract vtable entries and references. * cp-valprint.c (cp_print_value_fields): Use value_from_pointer instead of value_from_longest to extract the vtable's address. * eval.c (evaluate_subexp_standard): Use value_from_pointer instead of value_from_longest to compute `this', and for doing pointer-to-member dereferencing. * findvar.c (read_register): Use extract_unsigned_integer, not extract_address. (read_var_value): Use store_typed_address instead of store_address for building label values. (locate_var_value): Use value_from_pointer instead of value_from_longest. * hppa-tdep.c (find_stub_with_shl_get): Use value_from_pointer, instead of value_from_longest, to build arguments to __d_shl_get. * printcmd.c (set_next_address): Use value_from_pointer, not value_from_longest. (x_command): Use value_from_pointer, not value_from_longest. * tracepoint.c (set_traceframe_context): Use value_from_pointer, not value_from_longest. * valarith.c (value_add, value_sub): Use value_from_pointer, not value_from_longest. * valops.c (find_function_in_inferior, value_coerce_array, value_coerce_function, value_addr, hand_function_call): Same. * value.h (COERCE_REF): Use unpack_pointer, not unpack_long. * values.c (unpack_long): Use extract_typed_address to produce addresses from pointers and references, not extract_address. (value_from_longest): Use store_typed_address instead of store_address to produce pointer and reference values.
2000-04-14 20:43:41 +02:00
{
Simple -Wshadow=local fixes 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-04-22 00:16:27 +02:00
addr
* gdbarch.sh (POINTER_TO_ADDRESS, ADDRESS_TO_POINTER): Two new functions which architectures can redefine, defaulting to generic_pointer_to_address and generic_address_to_pointer. * findvar.c (extract_typed_address, store_typed_address, generic_pointer_to_address, generic_address_to_pointer): New functions. (POINTER_TO_ADDRESS, ADDRESS_TO_POINTER): Provide default definitions. (extract_address, store_address): Doc fixes. * values.c (value_as_pointer): Doc fix. (value_from_pointer): New function. * defs.h (extract_typed_address, store_typed_address): New declarations. * inferior.h (generic_address_to_pointer, generic_pointer_to_address): New declarations. * value.h (value_from_pointer): New declaration. * ax-gdb.c (const_var_ref): Use value_from_pointer, not value_from_longest. * blockframe.c (generic_push_dummy_frame): Use read_pc and read_sp, not read_register. * c-valprint.c (c_val_print): Use extract_typed_address instead of extract_address to extract vtable entries and references. * cp-valprint.c (cp_print_value_fields): Use value_from_pointer instead of value_from_longest to extract the vtable's address. * eval.c (evaluate_subexp_standard): Use value_from_pointer instead of value_from_longest to compute `this', and for doing pointer-to-member dereferencing. * findvar.c (read_register): Use extract_unsigned_integer, not extract_address. (read_var_value): Use store_typed_address instead of store_address for building label values. (locate_var_value): Use value_from_pointer instead of value_from_longest. * hppa-tdep.c (find_stub_with_shl_get): Use value_from_pointer, instead of value_from_longest, to build arguments to __d_shl_get. * printcmd.c (set_next_address): Use value_from_pointer, not value_from_longest. (x_command): Use value_from_pointer, not value_from_longest. * tracepoint.c (set_traceframe_context): Use value_from_pointer, not value_from_longest. * valarith.c (value_add, value_sub): Use value_from_pointer, not value_from_longest. * valops.c (find_function_in_inferior, value_coerce_array, value_coerce_function, value_addr, hand_function_call): Same. * value.h (COERCE_REF): Use unpack_pointer, not unpack_long. * values.c (unpack_long): Use extract_typed_address to produce addresses from pointers and references, not extract_address. (value_from_longest): Use store_typed_address instead of store_address to produce pointer and reference values.
2000-04-14 20:43:41 +02:00
= symbol_overlayed_address (SYMBOL_VALUE_ADDRESS (var),
SYMBOL_OBJ_SECTION (symbol_objfile (var),
PR symtab/8424: * blockframe.c (find_pc_partial_function_gnu_ifunc): Check SYMBOL_SECTION, not SYMBOL_OBJ_SECTION. * breakpoint.c (resolve_sal_pc): Update. * elfread.c (elf_gnu_ifunc_record_cache): Update. * findvar.c (struct minsym_lookup_data) <objfile>: New field. (minsym_lookup_iterator_cb): Use it. (default_read_var_value): Update. * hppa-hpux-tdep.c (hppa64_hpux_in_solib_call_trampoline): Update. * infcmd.c (jump_command): Update. * linespec.c (minsym_found): Update. * maint.c (maintenance_translate_address): Update. * minsyms.c (lookup_minimal_symbol_by_pc_section_1): Update. (prim_record_minimal_symbol_full): Don't set SYMBOL_OBJ_SECTION. * parse.c (write_exp_msymbol): Update. * printcmd.c (address_info): Update. * psymtab.c (find_pc_sect_psymbol): Update. (fixup_psymbol_section): Check SYMBOL_SECTION, not SYMBOL_OBJ_SECTION. (add_psymbol_to_bcache): Correctly initialize SYMBOL_SECTION. Don't initialize SYMBOL_OBJ_SECTION. * spu-tdep.c (spu_catch_start): Update. * stabsread.c (define_symbol): Don't set SYMBOL_SECTION. * symmisc.c (dump_msymbols, print_symbol): Update. * symtab.c (fixup_section): Don't set 'obj_section'. Change how fallback section is computed. (fixup_symbol_section): Update. (find_pc_sect_symtab, find_function_start_sal, skip_prologue_sal): Update. (allocate_symbol, initialize_symbol, allocate_template_symbol): Initialize SYMBOL_SECTION. * symtab.h (struct general_symbol_info) <section>: Update comment. <obj_section>: Remove. (SYMBOL_OBJ_SECTION): Add 'objfile' argument. Rewrite. (SYMBOL_OBJFILE): New macro.
2013-04-08 22:18:11 +02:00
var));
store_typed_address (value_contents_raw (v), type, addr);
* gdbarch.sh (POINTER_TO_ADDRESS, ADDRESS_TO_POINTER): Two new functions which architectures can redefine, defaulting to generic_pointer_to_address and generic_address_to_pointer. * findvar.c (extract_typed_address, store_typed_address, generic_pointer_to_address, generic_address_to_pointer): New functions. (POINTER_TO_ADDRESS, ADDRESS_TO_POINTER): Provide default definitions. (extract_address, store_address): Doc fixes. * values.c (value_as_pointer): Doc fix. (value_from_pointer): New function. * defs.h (extract_typed_address, store_typed_address): New declarations. * inferior.h (generic_address_to_pointer, generic_pointer_to_address): New declarations. * value.h (value_from_pointer): New declaration. * ax-gdb.c (const_var_ref): Use value_from_pointer, not value_from_longest. * blockframe.c (generic_push_dummy_frame): Use read_pc and read_sp, not read_register. * c-valprint.c (c_val_print): Use extract_typed_address instead of extract_address to extract vtable entries and references. * cp-valprint.c (cp_print_value_fields): Use value_from_pointer instead of value_from_longest to extract the vtable's address. * eval.c (evaluate_subexp_standard): Use value_from_pointer instead of value_from_longest to compute `this', and for doing pointer-to-member dereferencing. * findvar.c (read_register): Use extract_unsigned_integer, not extract_address. (read_var_value): Use store_typed_address instead of store_address for building label values. (locate_var_value): Use value_from_pointer instead of value_from_longest. * hppa-tdep.c (find_stub_with_shl_get): Use value_from_pointer, instead of value_from_longest, to build arguments to __d_shl_get. * printcmd.c (set_next_address): Use value_from_pointer, not value_from_longest. (x_command): Use value_from_pointer, not value_from_longest. * tracepoint.c (set_traceframe_context): Use value_from_pointer, not value_from_longest. * valarith.c (value_add, value_sub): Use value_from_pointer, not value_from_longest. * valops.c (find_function_in_inferior, value_coerce_array, value_coerce_function, value_addr, hand_function_call): Same. * value.h (COERCE_REF): Use unpack_pointer, not unpack_long. * values.c (unpack_long): Use extract_typed_address to produce addresses from pointers and references, not extract_address. (value_from_longest): Use store_typed_address instead of store_address to produce pointer and reference values.
2000-04-14 20:43:41 +02:00
}
else
store_typed_address (value_contents_raw (v), type,
* gdbarch.sh (POINTER_TO_ADDRESS, ADDRESS_TO_POINTER): Two new functions which architectures can redefine, defaulting to generic_pointer_to_address and generic_address_to_pointer. * findvar.c (extract_typed_address, store_typed_address, generic_pointer_to_address, generic_address_to_pointer): New functions. (POINTER_TO_ADDRESS, ADDRESS_TO_POINTER): Provide default definitions. (extract_address, store_address): Doc fixes. * values.c (value_as_pointer): Doc fix. (value_from_pointer): New function. * defs.h (extract_typed_address, store_typed_address): New declarations. * inferior.h (generic_address_to_pointer, generic_pointer_to_address): New declarations. * value.h (value_from_pointer): New declaration. * ax-gdb.c (const_var_ref): Use value_from_pointer, not value_from_longest. * blockframe.c (generic_push_dummy_frame): Use read_pc and read_sp, not read_register. * c-valprint.c (c_val_print): Use extract_typed_address instead of extract_address to extract vtable entries and references. * cp-valprint.c (cp_print_value_fields): Use value_from_pointer instead of value_from_longest to extract the vtable's address. * eval.c (evaluate_subexp_standard): Use value_from_pointer instead of value_from_longest to compute `this', and for doing pointer-to-member dereferencing. * findvar.c (read_register): Use extract_unsigned_integer, not extract_address. (read_var_value): Use store_typed_address instead of store_address for building label values. (locate_var_value): Use value_from_pointer instead of value_from_longest. * hppa-tdep.c (find_stub_with_shl_get): Use value_from_pointer, instead of value_from_longest, to build arguments to __d_shl_get. * printcmd.c (set_next_address): Use value_from_pointer, not value_from_longest. (x_command): Use value_from_pointer, not value_from_longest. * tracepoint.c (set_traceframe_context): Use value_from_pointer, not value_from_longest. * valarith.c (value_add, value_sub): Use value_from_pointer, not value_from_longest. * valops.c (find_function_in_inferior, value_coerce_array, value_coerce_function, value_addr, hand_function_call): Same. * value.h (COERCE_REF): Use unpack_pointer, not unpack_long. * values.c (unpack_long): Use extract_typed_address to produce addresses from pointers and references, not extract_address. (value_from_longest): Use store_typed_address instead of store_address to produce pointer and reference values.
2000-04-14 20:43:41 +02:00
SYMBOL_VALUE_ADDRESS (var));
VALUE_LVAL (v) = not_lval;
return v;
case LOC_CONST_BYTES:
if (is_dynamic_type (type))
{
/* Value is a constant byte-sequence and needs no memory access. */
Prefer existing data when evaluating DWARF expression When evaluating a DWARF expression, the dynamic type resolution code will pass in a buffer of bytes via the property_addr_info. However, the DWARF expression evaluator will then proceed to read memory from the inferior, even when the request could be filled from this buffer. This, in turn, is a problem in some cases; and specifically when trying to handle the Ada scenario of extracting a variable-length value from a packed array. Here, the ordinary DWARF expression cannot be directly evaluated, because the data may appear at some arbitrary bit offset. So, it is unpacked into a staging area and then the expression is evaluated -- using an address of 0. This patch fixes the problem by arranging for the DWARF evaluator, in this case, to prefer passed-in memory when possible. The type of the buffer in the property_addr_info is changed to an array_view so that bounds checking can be done. gdb/ChangeLog 2020-04-24 Tom Tromey <tromey@adacore.com> * ada-lang.c (ada_discrete_type_high_bound, ada_discrete_type_low) (ada_value_primitive_packed_val): Update. * ada-valprint.c (ada_value_print_1): Update. * dwarf2/loc.c (evaluate_for_locexpr_baton): New struct. (dwarf2_locexpr_baton_eval): Take a property_addr_info rather than just an address. Use evaluate_for_locexpr_baton. (dwarf2_evaluate_property): Update. * dwarf2/loc.h (struct property_addr_info) <valaddr>: Now an array_view. * findvar.c (default_read_var_value): Update. * gdbtypes.c (compute_variant_fields_inner) (resolve_dynamic_type_internal): Update. (resolve_dynamic_type): Change type of valaddr parameter. * gdbtypes.h (resolve_dynamic_type): Update. * valarith.c (value_subscripted_rvalue): Update. * value.c (value_from_contents_and_address): Update.
2020-04-24 21:40:31 +02:00
type = resolve_dynamic_type (type, {}, /* Unused address. */ 0);
}
v = allocate_value (type);
memcpy (value_contents_raw (v), SYMBOL_VALUE_BYTES (var),
TYPE_LENGTH (type));
VALUE_LVAL (v) = not_lval;
return v;
case LOC_STATIC:
if (overlay_debugging)
addr = symbol_overlayed_address (SYMBOL_VALUE_ADDRESS (var),
SYMBOL_OBJ_SECTION (symbol_objfile (var),
PR symtab/8424: * blockframe.c (find_pc_partial_function_gnu_ifunc): Check SYMBOL_SECTION, not SYMBOL_OBJ_SECTION. * breakpoint.c (resolve_sal_pc): Update. * elfread.c (elf_gnu_ifunc_record_cache): Update. * findvar.c (struct minsym_lookup_data) <objfile>: New field. (minsym_lookup_iterator_cb): Use it. (default_read_var_value): Update. * hppa-hpux-tdep.c (hppa64_hpux_in_solib_call_trampoline): Update. * infcmd.c (jump_command): Update. * linespec.c (minsym_found): Update. * maint.c (maintenance_translate_address): Update. * minsyms.c (lookup_minimal_symbol_by_pc_section_1): Update. (prim_record_minimal_symbol_full): Don't set SYMBOL_OBJ_SECTION. * parse.c (write_exp_msymbol): Update. * printcmd.c (address_info): Update. * psymtab.c (find_pc_sect_psymbol): Update. (fixup_psymbol_section): Check SYMBOL_SECTION, not SYMBOL_OBJ_SECTION. (add_psymbol_to_bcache): Correctly initialize SYMBOL_SECTION. Don't initialize SYMBOL_OBJ_SECTION. * spu-tdep.c (spu_catch_start): Update. * stabsread.c (define_symbol): Don't set SYMBOL_SECTION. * symmisc.c (dump_msymbols, print_symbol): Update. * symtab.c (fixup_section): Don't set 'obj_section'. Change how fallback section is computed. (fixup_symbol_section): Update. (find_pc_sect_symtab, find_function_start_sal, skip_prologue_sal): Update. (allocate_symbol, initialize_symbol, allocate_template_symbol): Initialize SYMBOL_SECTION. * symtab.h (struct general_symbol_info) <section>: Update comment. <obj_section>: Remove. (SYMBOL_OBJ_SECTION): Add 'objfile' argument. Rewrite. (SYMBOL_OBJFILE): New macro.
2013-04-08 22:18:11 +02:00
var));
else
addr = SYMBOL_VALUE_ADDRESS (var);
break;
case LOC_ARG:
addr = get_frame_args_address (frame);
if (!addr)
error (_("Unknown argument list address for `%s'."),
Replace SYMBOL_*_NAME accessors with member functions Similar to the MSYMBOL version of this patch, improves readability and will eventually allow making name private. gdb/ChangeLog: 2019-11-22 Christian Biesinger <cbiesinger@google.com> * ada-exp.y: Update. * ada-lang.c (sort_choices): Update. (ada_print_symbol_signature): Update. (resolve_subexp): Update. (ada_parse_renaming): Update. (ada_read_renaming_var_value): Update. (lesseq_defined_than): Update. (remove_extra_symbols): Update. (remove_irrelevant_renamings): Update. (ada_add_block_symbols): Update. (ada_collect_symbol_completion_matches): Update. (ada_is_renaming_symbol): Update. (aggregate_assign_from_choices): Update. (ada_evaluate_subexp): Update. (ada_has_this_exception_support): Update. (ada_is_non_standard_exception_sym): Update. (ada_add_exceptions_from_frame): Update. (ada_add_global_exceptions): Update. (ada_print_subexp): Update. * ax-gdb.c (gen_var_ref): Update. (gen_maybe_namespace_elt): Update. (gen_expr_for_cast): Update. (gen_expr): Update. * block.h: Update. * blockframe.c (find_pc_partial_function): Update. * breakpoint.c (print_breakpoint_location): Update. (update_static_tracepoint): Update. * btrace.c (ftrace_print_function_name): Update. (ftrace_function_switched): Update. * buildsym.c (find_symbol_in_list): Update. * c-exp.y: Update. * c-typeprint.c (c_print_typedef): Update. (c_type_print_template_args): Update. * cli/cli-cmds.c (edit_command): Update. (list_command): Update. (print_sal_location): Update. * coffread.c (patch_opaque_types): Update. (process_coff_symbol): Update. (coff_read_enum_type): Update. * compile/compile-c-symbols.c (c_symbol_substitution_name): Update. (convert_one_symbol): Update. (hash_symname): Update. (eq_symname): Update. * compile/compile-cplus-symbols.c (convert_one_symbol): Update. * compile/compile-cplus-types.c (debug_print_scope): Update. * compile/compile-loc2c.c (do_compile_dwarf_expr_to_c): Update. * compile/compile-object-load.c (get_out_value_type): Update. * cp-namespace.c (cp_scan_for_anonymous_namespaces): Update. (search_symbol_list): Update. (cp_lookup_symbol_imports_or_template): Update. * cp-support.c (overload_list_add_symbol): Update. * ctfread.c (psymtab_to_symtab): Update. * dbxread.c (cp_set_block_scope): Update. * dictionary.c (iter_match_first_hashed): Update. (iter_match_next_hashed): Update. (insert_symbol_hashed): Update. (iter_match_next_linear): Update. * dictionary.h: Update. * dwarf2loc.c (func_get_frame_base_dwarf_block): Update. (locexpr_describe_location_piece): Update. (locexpr_describe_location_1): Update. (locexpr_generate_c_location): Update. (loclist_describe_location): Update. (loclist_generate_c_location): Update. * dwarf2read.c (dw2_debug_names_lookup_symbol): Update. (read_func_scope): Update. (process_enumeration_scope): Update. (new_symbol): Update. (dwarf2_const_value): Update. (dwarf2_symbol_mark_computed): Update. * eval.c (evaluate_funcall): Update. (evaluate_subexp_standard): Update. * expprint.c (print_subexp_standard): Update. (dump_subexp_body_standard): Update. * f-valprint.c (info_common_command_for_block): Update. * findvar.c (get_hosting_frame): Update. (default_read_var_value): Update. * go-lang.c (go_symbol_package_name): Update. * guile/scm-block.c (bkscm_print_block_smob): Update. * guile/scm-symbol.c (syscm_print_symbol_smob): Update. (gdbscm_symbol_name): Update. (gdbscm_symbol_linkage_name): Update. (gdbscm_symbol_print_name): Update. * infcall.c (get_function_name): Update. * infcmd.c (jump_command): Update. (finish_command): Update. * infrun.c (insert_exception_resume_breakpoint): Update. * linespec.c (canonicalize_linespec): Update. (create_sals_line_offset): Update. (convert_linespec_to_sals): Update. (complete_label): Update. (find_label_symbols_in_block): Update. * m2-typeprint.c (m2_print_typedef): Update. * mdebugread.c (mdebug_reg_to_regnum): Update. (parse_symbol): Update. (mylookup_symbol): Update. * mi/mi-cmd-stack.c (list_arg_or_local): Update. (list_args_or_locals): Update. * objc-lang.c (compare_selectors): Update. (info_selectors_command): Update. (compare_classes): Update. (info_classes_command): Update. (find_imps): Update. * p-typeprint.c (pascal_print_typedef): Update. * printcmd.c (build_address_symbolic): Update. (info_address_command): Update. (print_variable_and_value): Update. * python/py-framefilter.c (extract_sym): Update. (py_print_single_arg): Update. * python/py-symbol.c (sympy_str): Update. (sympy_get_name): Update. (sympy_get_linkage_name): Update. * python/python.c (gdbpy_rbreak): Update. * record-btrace.c (btrace_get_bfun_name): Update. (btrace_call_history): Update. * rust-lang.c (rust_print_typedef): Update. * solib-frv.c (frv_fdpic_find_canonical_descriptor): Update. * stabsread.c (stab_reg_to_regnum): Update. (define_symbol): Update. (read_enum_type): Update. (common_block_end): Update. (cleanup_undefined_types_1): Update. (scan_file_globals): Update. * stack.c (print_frame_arg): Update. (print_frame_args): Update. (find_frame_funname): Update. (info_frame_command_core): Update. (iterate_over_block_locals): Update. (print_block_frame_labels): Update. (do_print_variable_and_value): Update. (iterate_over_block_arg_vars): Update. (return_command): Update. * symmisc.c (dump_symtab_1): Update. (print_symbol): Update. * symtab.c (eq_symbol_entry): Update. (symbol_cache_dump): Update. (lookup_language_this): Update. (find_pc_sect_line): Update. (skip_prologue_sal): Update. (symbol_search::compare_search_syms): Update. (treg_matches_sym_type_name): Update. (search_symbols): Update. (print_symbol_info): Update. (rbreak_command): Update. (completion_list_add_symbol): Update. (find_gnu_ifunc): Update. (get_symbol_address): Update. (search_module_symbols): Update. (info_module_subcommand): Update. * symtab.h (SYMBOL_NATURAL_NAME): Remove. (SYMBOL_LINKAGE_NAME): Remove. (SYMBOL_DEMANGLED_NAME): Remove. (SYMBOL_PRINT_NAME): Remove. (SYMBOL_SEARCH_NAME): Remove. * tracepoint.c (set_traceframe_context): Update. (validate_actionline): Update. (collection_list::collect_symbol): Update. (encode_actions_1): Update. (info_scope_command): Update. (print_one_static_tracepoint_marker): Update. * typeprint.c (typedef_hash_table::add_template_parameters): Update. * valops.c (address_of_variable): Update. (find_overload_match): Update. (find_oload_champ): Update. Change-Id: I76bdc8b44eea6876bf03af9d351f8e90cc0154b2
2019-11-22 19:05:14 +01:00
var->print_name ());
addr += SYMBOL_VALUE (var);
break;
case LOC_REF_ARG:
{
struct value *ref;
CORE_ADDR argref;
argref = get_frame_args_address (frame);
if (!argref)
error (_("Unknown argument list address for `%s'."),
Replace SYMBOL_*_NAME accessors with member functions Similar to the MSYMBOL version of this patch, improves readability and will eventually allow making name private. gdb/ChangeLog: 2019-11-22 Christian Biesinger <cbiesinger@google.com> * ada-exp.y: Update. * ada-lang.c (sort_choices): Update. (ada_print_symbol_signature): Update. (resolve_subexp): Update. (ada_parse_renaming): Update. (ada_read_renaming_var_value): Update. (lesseq_defined_than): Update. (remove_extra_symbols): Update. (remove_irrelevant_renamings): Update. (ada_add_block_symbols): Update. (ada_collect_symbol_completion_matches): Update. (ada_is_renaming_symbol): Update. (aggregate_assign_from_choices): Update. (ada_evaluate_subexp): Update. (ada_has_this_exception_support): Update. (ada_is_non_standard_exception_sym): Update. (ada_add_exceptions_from_frame): Update. (ada_add_global_exceptions): Update. (ada_print_subexp): Update. * ax-gdb.c (gen_var_ref): Update. (gen_maybe_namespace_elt): Update. (gen_expr_for_cast): Update. (gen_expr): Update. * block.h: Update. * blockframe.c (find_pc_partial_function): Update. * breakpoint.c (print_breakpoint_location): Update. (update_static_tracepoint): Update. * btrace.c (ftrace_print_function_name): Update. (ftrace_function_switched): Update. * buildsym.c (find_symbol_in_list): Update. * c-exp.y: Update. * c-typeprint.c (c_print_typedef): Update. (c_type_print_template_args): Update. * cli/cli-cmds.c (edit_command): Update. (list_command): Update. (print_sal_location): Update. * coffread.c (patch_opaque_types): Update. (process_coff_symbol): Update. (coff_read_enum_type): Update. * compile/compile-c-symbols.c (c_symbol_substitution_name): Update. (convert_one_symbol): Update. (hash_symname): Update. (eq_symname): Update. * compile/compile-cplus-symbols.c (convert_one_symbol): Update. * compile/compile-cplus-types.c (debug_print_scope): Update. * compile/compile-loc2c.c (do_compile_dwarf_expr_to_c): Update. * compile/compile-object-load.c (get_out_value_type): Update. * cp-namespace.c (cp_scan_for_anonymous_namespaces): Update. (search_symbol_list): Update. (cp_lookup_symbol_imports_or_template): Update. * cp-support.c (overload_list_add_symbol): Update. * ctfread.c (psymtab_to_symtab): Update. * dbxread.c (cp_set_block_scope): Update. * dictionary.c (iter_match_first_hashed): Update. (iter_match_next_hashed): Update. (insert_symbol_hashed): Update. (iter_match_next_linear): Update. * dictionary.h: Update. * dwarf2loc.c (func_get_frame_base_dwarf_block): Update. (locexpr_describe_location_piece): Update. (locexpr_describe_location_1): Update. (locexpr_generate_c_location): Update. (loclist_describe_location): Update. (loclist_generate_c_location): Update. * dwarf2read.c (dw2_debug_names_lookup_symbol): Update. (read_func_scope): Update. (process_enumeration_scope): Update. (new_symbol): Update. (dwarf2_const_value): Update. (dwarf2_symbol_mark_computed): Update. * eval.c (evaluate_funcall): Update. (evaluate_subexp_standard): Update. * expprint.c (print_subexp_standard): Update. (dump_subexp_body_standard): Update. * f-valprint.c (info_common_command_for_block): Update. * findvar.c (get_hosting_frame): Update. (default_read_var_value): Update. * go-lang.c (go_symbol_package_name): Update. * guile/scm-block.c (bkscm_print_block_smob): Update. * guile/scm-symbol.c (syscm_print_symbol_smob): Update. (gdbscm_symbol_name): Update. (gdbscm_symbol_linkage_name): Update. (gdbscm_symbol_print_name): Update. * infcall.c (get_function_name): Update. * infcmd.c (jump_command): Update. (finish_command): Update. * infrun.c (insert_exception_resume_breakpoint): Update. * linespec.c (canonicalize_linespec): Update. (create_sals_line_offset): Update. (convert_linespec_to_sals): Update. (complete_label): Update. (find_label_symbols_in_block): Update. * m2-typeprint.c (m2_print_typedef): Update. * mdebugread.c (mdebug_reg_to_regnum): Update. (parse_symbol): Update. (mylookup_symbol): Update. * mi/mi-cmd-stack.c (list_arg_or_local): Update. (list_args_or_locals): Update. * objc-lang.c (compare_selectors): Update. (info_selectors_command): Update. (compare_classes): Update. (info_classes_command): Update. (find_imps): Update. * p-typeprint.c (pascal_print_typedef): Update. * printcmd.c (build_address_symbolic): Update. (info_address_command): Update. (print_variable_and_value): Update. * python/py-framefilter.c (extract_sym): Update. (py_print_single_arg): Update. * python/py-symbol.c (sympy_str): Update. (sympy_get_name): Update. (sympy_get_linkage_name): Update. * python/python.c (gdbpy_rbreak): Update. * record-btrace.c (btrace_get_bfun_name): Update. (btrace_call_history): Update. * rust-lang.c (rust_print_typedef): Update. * solib-frv.c (frv_fdpic_find_canonical_descriptor): Update. * stabsread.c (stab_reg_to_regnum): Update. (define_symbol): Update. (read_enum_type): Update. (common_block_end): Update. (cleanup_undefined_types_1): Update. (scan_file_globals): Update. * stack.c (print_frame_arg): Update. (print_frame_args): Update. (find_frame_funname): Update. (info_frame_command_core): Update. (iterate_over_block_locals): Update. (print_block_frame_labels): Update. (do_print_variable_and_value): Update. (iterate_over_block_arg_vars): Update. (return_command): Update. * symmisc.c (dump_symtab_1): Update. (print_symbol): Update. * symtab.c (eq_symbol_entry): Update. (symbol_cache_dump): Update. (lookup_language_this): Update. (find_pc_sect_line): Update. (skip_prologue_sal): Update. (symbol_search::compare_search_syms): Update. (treg_matches_sym_type_name): Update. (search_symbols): Update. (print_symbol_info): Update. (rbreak_command): Update. (completion_list_add_symbol): Update. (find_gnu_ifunc): Update. (get_symbol_address): Update. (search_module_symbols): Update. (info_module_subcommand): Update. * symtab.h (SYMBOL_NATURAL_NAME): Remove. (SYMBOL_LINKAGE_NAME): Remove. (SYMBOL_DEMANGLED_NAME): Remove. (SYMBOL_PRINT_NAME): Remove. (SYMBOL_SEARCH_NAME): Remove. * tracepoint.c (set_traceframe_context): Update. (validate_actionline): Update. (collection_list::collect_symbol): Update. (encode_actions_1): Update. (info_scope_command): Update. (print_one_static_tracepoint_marker): Update. * typeprint.c (typedef_hash_table::add_template_parameters): Update. * valops.c (address_of_variable): Update. (find_overload_match): Update. (find_oload_champ): Update. Change-Id: I76bdc8b44eea6876bf03af9d351f8e90cc0154b2
2019-11-22 19:05:14 +01:00
var->print_name ());
argref += SYMBOL_VALUE (var);
ref = value_at (lookup_pointer_type (type), argref);
addr = value_as_address (ref);
break;
}
case LOC_LOCAL:
addr = get_frame_locals_address (frame);
addr += SYMBOL_VALUE (var);
break;
case LOC_TYPEDEF:
error (_("Cannot look up value of a typedef `%s'."),
Replace SYMBOL_*_NAME accessors with member functions Similar to the MSYMBOL version of this patch, improves readability and will eventually allow making name private. gdb/ChangeLog: 2019-11-22 Christian Biesinger <cbiesinger@google.com> * ada-exp.y: Update. * ada-lang.c (sort_choices): Update. (ada_print_symbol_signature): Update. (resolve_subexp): Update. (ada_parse_renaming): Update. (ada_read_renaming_var_value): Update. (lesseq_defined_than): Update. (remove_extra_symbols): Update. (remove_irrelevant_renamings): Update. (ada_add_block_symbols): Update. (ada_collect_symbol_completion_matches): Update. (ada_is_renaming_symbol): Update. (aggregate_assign_from_choices): Update. (ada_evaluate_subexp): Update. (ada_has_this_exception_support): Update. (ada_is_non_standard_exception_sym): Update. (ada_add_exceptions_from_frame): Update. (ada_add_global_exceptions): Update. (ada_print_subexp): Update. * ax-gdb.c (gen_var_ref): Update. (gen_maybe_namespace_elt): Update. (gen_expr_for_cast): Update. (gen_expr): Update. * block.h: Update. * blockframe.c (find_pc_partial_function): Update. * breakpoint.c (print_breakpoint_location): Update. (update_static_tracepoint): Update. * btrace.c (ftrace_print_function_name): Update. (ftrace_function_switched): Update. * buildsym.c (find_symbol_in_list): Update. * c-exp.y: Update. * c-typeprint.c (c_print_typedef): Update. (c_type_print_template_args): Update. * cli/cli-cmds.c (edit_command): Update. (list_command): Update. (print_sal_location): Update. * coffread.c (patch_opaque_types): Update. (process_coff_symbol): Update. (coff_read_enum_type): Update. * compile/compile-c-symbols.c (c_symbol_substitution_name): Update. (convert_one_symbol): Update. (hash_symname): Update. (eq_symname): Update. * compile/compile-cplus-symbols.c (convert_one_symbol): Update. * compile/compile-cplus-types.c (debug_print_scope): Update. * compile/compile-loc2c.c (do_compile_dwarf_expr_to_c): Update. * compile/compile-object-load.c (get_out_value_type): Update. * cp-namespace.c (cp_scan_for_anonymous_namespaces): Update. (search_symbol_list): Update. (cp_lookup_symbol_imports_or_template): Update. * cp-support.c (overload_list_add_symbol): Update. * ctfread.c (psymtab_to_symtab): Update. * dbxread.c (cp_set_block_scope): Update. * dictionary.c (iter_match_first_hashed): Update. (iter_match_next_hashed): Update. (insert_symbol_hashed): Update. (iter_match_next_linear): Update. * dictionary.h: Update. * dwarf2loc.c (func_get_frame_base_dwarf_block): Update. (locexpr_describe_location_piece): Update. (locexpr_describe_location_1): Update. (locexpr_generate_c_location): Update. (loclist_describe_location): Update. (loclist_generate_c_location): Update. * dwarf2read.c (dw2_debug_names_lookup_symbol): Update. (read_func_scope): Update. (process_enumeration_scope): Update. (new_symbol): Update. (dwarf2_const_value): Update. (dwarf2_symbol_mark_computed): Update. * eval.c (evaluate_funcall): Update. (evaluate_subexp_standard): Update. * expprint.c (print_subexp_standard): Update. (dump_subexp_body_standard): Update. * f-valprint.c (info_common_command_for_block): Update. * findvar.c (get_hosting_frame): Update. (default_read_var_value): Update. * go-lang.c (go_symbol_package_name): Update. * guile/scm-block.c (bkscm_print_block_smob): Update. * guile/scm-symbol.c (syscm_print_symbol_smob): Update. (gdbscm_symbol_name): Update. (gdbscm_symbol_linkage_name): Update. (gdbscm_symbol_print_name): Update. * infcall.c (get_function_name): Update. * infcmd.c (jump_command): Update. (finish_command): Update. * infrun.c (insert_exception_resume_breakpoint): Update. * linespec.c (canonicalize_linespec): Update. (create_sals_line_offset): Update. (convert_linespec_to_sals): Update. (complete_label): Update. (find_label_symbols_in_block): Update. * m2-typeprint.c (m2_print_typedef): Update. * mdebugread.c (mdebug_reg_to_regnum): Update. (parse_symbol): Update. (mylookup_symbol): Update. * mi/mi-cmd-stack.c (list_arg_or_local): Update. (list_args_or_locals): Update. * objc-lang.c (compare_selectors): Update. (info_selectors_command): Update. (compare_classes): Update. (info_classes_command): Update. (find_imps): Update. * p-typeprint.c (pascal_print_typedef): Update. * printcmd.c (build_address_symbolic): Update. (info_address_command): Update. (print_variable_and_value): Update. * python/py-framefilter.c (extract_sym): Update. (py_print_single_arg): Update. * python/py-symbol.c (sympy_str): Update. (sympy_get_name): Update. (sympy_get_linkage_name): Update. * python/python.c (gdbpy_rbreak): Update. * record-btrace.c (btrace_get_bfun_name): Update. (btrace_call_history): Update. * rust-lang.c (rust_print_typedef): Update. * solib-frv.c (frv_fdpic_find_canonical_descriptor): Update. * stabsread.c (stab_reg_to_regnum): Update. (define_symbol): Update. (read_enum_type): Update. (common_block_end): Update. (cleanup_undefined_types_1): Update. (scan_file_globals): Update. * stack.c (print_frame_arg): Update. (print_frame_args): Update. (find_frame_funname): Update. (info_frame_command_core): Update. (iterate_over_block_locals): Update. (print_block_frame_labels): Update. (do_print_variable_and_value): Update. (iterate_over_block_arg_vars): Update. (return_command): Update. * symmisc.c (dump_symtab_1): Update. (print_symbol): Update. * symtab.c (eq_symbol_entry): Update. (symbol_cache_dump): Update. (lookup_language_this): Update. (find_pc_sect_line): Update. (skip_prologue_sal): Update. (symbol_search::compare_search_syms): Update. (treg_matches_sym_type_name): Update. (search_symbols): Update. (print_symbol_info): Update. (rbreak_command): Update. (completion_list_add_symbol): Update. (find_gnu_ifunc): Update. (get_symbol_address): Update. (search_module_symbols): Update. (info_module_subcommand): Update. * symtab.h (SYMBOL_NATURAL_NAME): Remove. (SYMBOL_LINKAGE_NAME): Remove. (SYMBOL_DEMANGLED_NAME): Remove. (SYMBOL_PRINT_NAME): Remove. (SYMBOL_SEARCH_NAME): Remove. * tracepoint.c (set_traceframe_context): Update. (validate_actionline): Update. (collection_list::collect_symbol): Update. (encode_actions_1): Update. (info_scope_command): Update. (print_one_static_tracepoint_marker): Update. * typeprint.c (typedef_hash_table::add_template_parameters): Update. * valops.c (address_of_variable): Update. (find_overload_match): Update. (find_oload_champ): Update. Change-Id: I76bdc8b44eea6876bf03af9d351f8e90cc0154b2
2019-11-22 19:05:14 +01:00
var->print_name ());
break;
case LOC_BLOCK:
if (overlay_debugging)
addr = symbol_overlayed_address
Use BLOCK_ENTRY_PC in place of most uses of BLOCK_START This change/patch substitues BLOCK_ENTRY_PC for BLOCK_START in places where BLOCK_START is used to obtain the address at which execution should enter the block. Since blocks can now contain non-contiguous ranges, the BLOCK_START - which is still be the very lowest address in the block - might not be the same as BLOCK_ENTRY_PC. There is a change to infrun.c which is less obvious and less mechanical. I'm posting it as a separate patch. gdb/ChangeLog: * ax-gdb.c (gen_var_ref): Use BLOCK_ENTRY_PC in place of BLOCK_START. * blockframe.c (get_pc_function_start): Likewise. * compile/compile-c-symbols.c (convert_one_symbol): Likewise. (gcc_symbol_address): Likewise. * compile/compile-object-run.c (compile_object_run): Likewise. * compile/compile.c (get_expr_block_and_pc): Likewise. * dwarf2loc.c (dwarf2_find_location_expression): Likewise. (func_addr_to_tail_call_list): Likewise. * findvar.c (default_read_var_value): Likewise. * inline-frame.c (inline_frame_this_id): Likewise. (skip-inline_frames): Likewise. * infcmd.c (until_next_command): Likewise. * linespec.c (convert_linespec_to_sals): Likewise. * parse.c (parse_exp_in_context_1): Likewise. * printcmd.c (build_address_symbolic): likewise. (info_address_command): Likewise. symtab.c (find_function_start_sal): Likewise. (skip_prologue_sal): Likewise. (find_function_alias_target): Likewise. (find_gnu_ifunc): Likewise. * stack.c (find_frame_funname): Likewise. * symtab.c (fixup_symbol_section): Likewise. (find_function_start_sal): Likewise. (skip_prologue_sal): Likewsie. (find_function_alias_target): Likewise. (find_gnu_ifunc): Likewise. * tracepoint.c (info_scope_command): Likewise. * value.c (value_fn_field): Likewise.
2018-08-24 01:00:49 +02:00
(BLOCK_ENTRY_PC (SYMBOL_BLOCK_VALUE (var)),
SYMBOL_OBJ_SECTION (symbol_objfile (var), var));
else
Use BLOCK_ENTRY_PC in place of most uses of BLOCK_START This change/patch substitues BLOCK_ENTRY_PC for BLOCK_START in places where BLOCK_START is used to obtain the address at which execution should enter the block. Since blocks can now contain non-contiguous ranges, the BLOCK_START - which is still be the very lowest address in the block - might not be the same as BLOCK_ENTRY_PC. There is a change to infrun.c which is less obvious and less mechanical. I'm posting it as a separate patch. gdb/ChangeLog: * ax-gdb.c (gen_var_ref): Use BLOCK_ENTRY_PC in place of BLOCK_START. * blockframe.c (get_pc_function_start): Likewise. * compile/compile-c-symbols.c (convert_one_symbol): Likewise. (gcc_symbol_address): Likewise. * compile/compile-object-run.c (compile_object_run): Likewise. * compile/compile.c (get_expr_block_and_pc): Likewise. * dwarf2loc.c (dwarf2_find_location_expression): Likewise. (func_addr_to_tail_call_list): Likewise. * findvar.c (default_read_var_value): Likewise. * inline-frame.c (inline_frame_this_id): Likewise. (skip-inline_frames): Likewise. * infcmd.c (until_next_command): Likewise. * linespec.c (convert_linespec_to_sals): Likewise. * parse.c (parse_exp_in_context_1): Likewise. * printcmd.c (build_address_symbolic): likewise. (info_address_command): Likewise. symtab.c (find_function_start_sal): Likewise. (skip_prologue_sal): Likewise. (find_function_alias_target): Likewise. (find_gnu_ifunc): Likewise. * stack.c (find_frame_funname): Likewise. * symtab.c (fixup_symbol_section): Likewise. (find_function_start_sal): Likewise. (skip_prologue_sal): Likewsie. (find_function_alias_target): Likewise. (find_gnu_ifunc): Likewise. * tracepoint.c (info_scope_command): Likewise. * value.c (value_fn_field): Likewise.
2018-08-24 01:00:49 +02:00
addr = BLOCK_ENTRY_PC (SYMBOL_BLOCK_VALUE (var));
break;
case LOC_REGISTER:
case LOC_REGPARM_ADDR:
{
* symtab.h: Rename SYMBOL_OPS to SYMBOL_COMPUTED_OPS. * ax-gdb.c (gen_var_ref): Likewise. * findvar.c (read_var_value, symbol_read_needs_frame): Likewise. * printcmd.c (address_info): Likewise. * dwarf2loc.c (dwarf_expr_frame_base): Likewise. * dwarf2read.c (dwarf2_symbol_mark_computed): Likewise. * symtab.h: Rename struct symbol_ops to struct symbol_computed_ops. * dwarf2loc.h: Likewise. * dwarf2loc.c (dwarf2_locexpr_funcs, dwarf2_loclist_funcs): Likewise. * symtab.h: (struct symbol_register_ops): New struct definition. (struct symbol): Make "ops" member a union of symbol_computed_ops and symbol_register_ops callback pointers. (SYMBOL_REGISTER_OPS): New macro. * tracepoint.c: Include "objfiles.h". (scope_info, collect_symbol): Use SYMBOL_REGISTER_OPS register_number callback to retrieve register numbers. * ax-gdb.c (gen_var_ref): Likewise. * findvar.c (read_var_value): Likewise. * printcmd.c (address_info): Likewise. * coffread.c (coff_reg_to_regnum): New function. (coff_register_funcs): New static variable. (process_coff_symbol): Do not call gdbarch_sdb_reg_to_regnum. Install SYMBOL_REGISTER_OPS callbacks. * mdebugread.c (mdebug_reg_to_regnum): New function. (mdebug_register_funcs): New static variable. (parse_symbol): Do not call gdbarch_ecoff_reg_to_regnum. Install SYMBOL_REGISTER_OPS callbacks. * stabsread.c (stab_reg_to_regnum): New function. (stab_register_funcs): New static variable. (define_symbol): Do not call gdbarch_stab_reg_to_regnum. Install SYMBOL_REGISTER_OPS callbacks.
2009-06-04 14:28:39 +02:00
int regno = SYMBOL_REGISTER_OPS (var)
->register_number (var, get_frame_arch (frame));
2001-11-10 22:34:56 +01:00
struct value *regval;
if (SYMBOL_CLASS (var) == LOC_REGPARM_ADDR)
{
regval = value_from_register (lookup_pointer_type (type),
1999-07-07 22:19:36 +02:00
regno,
frame);
if (regval == NULL)
error (_("Value of register variable not available for `%s'."),
Replace SYMBOL_*_NAME accessors with member functions Similar to the MSYMBOL version of this patch, improves readability and will eventually allow making name private. gdb/ChangeLog: 2019-11-22 Christian Biesinger <cbiesinger@google.com> * ada-exp.y: Update. * ada-lang.c (sort_choices): Update. (ada_print_symbol_signature): Update. (resolve_subexp): Update. (ada_parse_renaming): Update. (ada_read_renaming_var_value): Update. (lesseq_defined_than): Update. (remove_extra_symbols): Update. (remove_irrelevant_renamings): Update. (ada_add_block_symbols): Update. (ada_collect_symbol_completion_matches): Update. (ada_is_renaming_symbol): Update. (aggregate_assign_from_choices): Update. (ada_evaluate_subexp): Update. (ada_has_this_exception_support): Update. (ada_is_non_standard_exception_sym): Update. (ada_add_exceptions_from_frame): Update. (ada_add_global_exceptions): Update. (ada_print_subexp): Update. * ax-gdb.c (gen_var_ref): Update. (gen_maybe_namespace_elt): Update. (gen_expr_for_cast): Update. (gen_expr): Update. * block.h: Update. * blockframe.c (find_pc_partial_function): Update. * breakpoint.c (print_breakpoint_location): Update. (update_static_tracepoint): Update. * btrace.c (ftrace_print_function_name): Update. (ftrace_function_switched): Update. * buildsym.c (find_symbol_in_list): Update. * c-exp.y: Update. * c-typeprint.c (c_print_typedef): Update. (c_type_print_template_args): Update. * cli/cli-cmds.c (edit_command): Update. (list_command): Update. (print_sal_location): Update. * coffread.c (patch_opaque_types): Update. (process_coff_symbol): Update. (coff_read_enum_type): Update. * compile/compile-c-symbols.c (c_symbol_substitution_name): Update. (convert_one_symbol): Update. (hash_symname): Update. (eq_symname): Update. * compile/compile-cplus-symbols.c (convert_one_symbol): Update. * compile/compile-cplus-types.c (debug_print_scope): Update. * compile/compile-loc2c.c (do_compile_dwarf_expr_to_c): Update. * compile/compile-object-load.c (get_out_value_type): Update. * cp-namespace.c (cp_scan_for_anonymous_namespaces): Update. (search_symbol_list): Update. (cp_lookup_symbol_imports_or_template): Update. * cp-support.c (overload_list_add_symbol): Update. * ctfread.c (psymtab_to_symtab): Update. * dbxread.c (cp_set_block_scope): Update. * dictionary.c (iter_match_first_hashed): Update. (iter_match_next_hashed): Update. (insert_symbol_hashed): Update. (iter_match_next_linear): Update. * dictionary.h: Update. * dwarf2loc.c (func_get_frame_base_dwarf_block): Update. (locexpr_describe_location_piece): Update. (locexpr_describe_location_1): Update. (locexpr_generate_c_location): Update. (loclist_describe_location): Update. (loclist_generate_c_location): Update. * dwarf2read.c (dw2_debug_names_lookup_symbol): Update. (read_func_scope): Update. (process_enumeration_scope): Update. (new_symbol): Update. (dwarf2_const_value): Update. (dwarf2_symbol_mark_computed): Update. * eval.c (evaluate_funcall): Update. (evaluate_subexp_standard): Update. * expprint.c (print_subexp_standard): Update. (dump_subexp_body_standard): Update. * f-valprint.c (info_common_command_for_block): Update. * findvar.c (get_hosting_frame): Update. (default_read_var_value): Update. * go-lang.c (go_symbol_package_name): Update. * guile/scm-block.c (bkscm_print_block_smob): Update. * guile/scm-symbol.c (syscm_print_symbol_smob): Update. (gdbscm_symbol_name): Update. (gdbscm_symbol_linkage_name): Update. (gdbscm_symbol_print_name): Update. * infcall.c (get_function_name): Update. * infcmd.c (jump_command): Update. (finish_command): Update. * infrun.c (insert_exception_resume_breakpoint): Update. * linespec.c (canonicalize_linespec): Update. (create_sals_line_offset): Update. (convert_linespec_to_sals): Update. (complete_label): Update. (find_label_symbols_in_block): Update. * m2-typeprint.c (m2_print_typedef): Update. * mdebugread.c (mdebug_reg_to_regnum): Update. (parse_symbol): Update. (mylookup_symbol): Update. * mi/mi-cmd-stack.c (list_arg_or_local): Update. (list_args_or_locals): Update. * objc-lang.c (compare_selectors): Update. (info_selectors_command): Update. (compare_classes): Update. (info_classes_command): Update. (find_imps): Update. * p-typeprint.c (pascal_print_typedef): Update. * printcmd.c (build_address_symbolic): Update. (info_address_command): Update. (print_variable_and_value): Update. * python/py-framefilter.c (extract_sym): Update. (py_print_single_arg): Update. * python/py-symbol.c (sympy_str): Update. (sympy_get_name): Update. (sympy_get_linkage_name): Update. * python/python.c (gdbpy_rbreak): Update. * record-btrace.c (btrace_get_bfun_name): Update. (btrace_call_history): Update. * rust-lang.c (rust_print_typedef): Update. * solib-frv.c (frv_fdpic_find_canonical_descriptor): Update. * stabsread.c (stab_reg_to_regnum): Update. (define_symbol): Update. (read_enum_type): Update. (common_block_end): Update. (cleanup_undefined_types_1): Update. (scan_file_globals): Update. * stack.c (print_frame_arg): Update. (print_frame_args): Update. (find_frame_funname): Update. (info_frame_command_core): Update. (iterate_over_block_locals): Update. (print_block_frame_labels): Update. (do_print_variable_and_value): Update. (iterate_over_block_arg_vars): Update. (return_command): Update. * symmisc.c (dump_symtab_1): Update. (print_symbol): Update. * symtab.c (eq_symbol_entry): Update. (symbol_cache_dump): Update. (lookup_language_this): Update. (find_pc_sect_line): Update. (skip_prologue_sal): Update. (symbol_search::compare_search_syms): Update. (treg_matches_sym_type_name): Update. (search_symbols): Update. (print_symbol_info): Update. (rbreak_command): Update. (completion_list_add_symbol): Update. (find_gnu_ifunc): Update. (get_symbol_address): Update. (search_module_symbols): Update. (info_module_subcommand): Update. * symtab.h (SYMBOL_NATURAL_NAME): Remove. (SYMBOL_LINKAGE_NAME): Remove. (SYMBOL_DEMANGLED_NAME): Remove. (SYMBOL_PRINT_NAME): Remove. (SYMBOL_SEARCH_NAME): Remove. * tracepoint.c (set_traceframe_context): Update. (validate_actionline): Update. (collection_list::collect_symbol): Update. (encode_actions_1): Update. (info_scope_command): Update. (print_one_static_tracepoint_marker): Update. * typeprint.c (typedef_hash_table::add_template_parameters): Update. * valops.c (address_of_variable): Update. (find_overload_match): Update. (find_oload_champ): Update. Change-Id: I76bdc8b44eea6876bf03af9d351f8e90cc0154b2
2019-11-22 19:05:14 +01:00
var->print_name ());
addr = value_as_address (regval);
}
else
{
regval = value_from_register (type, regno, frame);
if (regval == NULL)
error (_("Value of register variable not available for `%s'."),
Replace SYMBOL_*_NAME accessors with member functions Similar to the MSYMBOL version of this patch, improves readability and will eventually allow making name private. gdb/ChangeLog: 2019-11-22 Christian Biesinger <cbiesinger@google.com> * ada-exp.y: Update. * ada-lang.c (sort_choices): Update. (ada_print_symbol_signature): Update. (resolve_subexp): Update. (ada_parse_renaming): Update. (ada_read_renaming_var_value): Update. (lesseq_defined_than): Update. (remove_extra_symbols): Update. (remove_irrelevant_renamings): Update. (ada_add_block_symbols): Update. (ada_collect_symbol_completion_matches): Update. (ada_is_renaming_symbol): Update. (aggregate_assign_from_choices): Update. (ada_evaluate_subexp): Update. (ada_has_this_exception_support): Update. (ada_is_non_standard_exception_sym): Update. (ada_add_exceptions_from_frame): Update. (ada_add_global_exceptions): Update. (ada_print_subexp): Update. * ax-gdb.c (gen_var_ref): Update. (gen_maybe_namespace_elt): Update. (gen_expr_for_cast): Update. (gen_expr): Update. * block.h: Update. * blockframe.c (find_pc_partial_function): Update. * breakpoint.c (print_breakpoint_location): Update. (update_static_tracepoint): Update. * btrace.c (ftrace_print_function_name): Update. (ftrace_function_switched): Update. * buildsym.c (find_symbol_in_list): Update. * c-exp.y: Update. * c-typeprint.c (c_print_typedef): Update. (c_type_print_template_args): Update. * cli/cli-cmds.c (edit_command): Update. (list_command): Update. (print_sal_location): Update. * coffread.c (patch_opaque_types): Update. (process_coff_symbol): Update. (coff_read_enum_type): Update. * compile/compile-c-symbols.c (c_symbol_substitution_name): Update. (convert_one_symbol): Update. (hash_symname): Update. (eq_symname): Update. * compile/compile-cplus-symbols.c (convert_one_symbol): Update. * compile/compile-cplus-types.c (debug_print_scope): Update. * compile/compile-loc2c.c (do_compile_dwarf_expr_to_c): Update. * compile/compile-object-load.c (get_out_value_type): Update. * cp-namespace.c (cp_scan_for_anonymous_namespaces): Update. (search_symbol_list): Update. (cp_lookup_symbol_imports_or_template): Update. * cp-support.c (overload_list_add_symbol): Update. * ctfread.c (psymtab_to_symtab): Update. * dbxread.c (cp_set_block_scope): Update. * dictionary.c (iter_match_first_hashed): Update. (iter_match_next_hashed): Update. (insert_symbol_hashed): Update. (iter_match_next_linear): Update. * dictionary.h: Update. * dwarf2loc.c (func_get_frame_base_dwarf_block): Update. (locexpr_describe_location_piece): Update. (locexpr_describe_location_1): Update. (locexpr_generate_c_location): Update. (loclist_describe_location): Update. (loclist_generate_c_location): Update. * dwarf2read.c (dw2_debug_names_lookup_symbol): Update. (read_func_scope): Update. (process_enumeration_scope): Update. (new_symbol): Update. (dwarf2_const_value): Update. (dwarf2_symbol_mark_computed): Update. * eval.c (evaluate_funcall): Update. (evaluate_subexp_standard): Update. * expprint.c (print_subexp_standard): Update. (dump_subexp_body_standard): Update. * f-valprint.c (info_common_command_for_block): Update. * findvar.c (get_hosting_frame): Update. (default_read_var_value): Update. * go-lang.c (go_symbol_package_name): Update. * guile/scm-block.c (bkscm_print_block_smob): Update. * guile/scm-symbol.c (syscm_print_symbol_smob): Update. (gdbscm_symbol_name): Update. (gdbscm_symbol_linkage_name): Update. (gdbscm_symbol_print_name): Update. * infcall.c (get_function_name): Update. * infcmd.c (jump_command): Update. (finish_command): Update. * infrun.c (insert_exception_resume_breakpoint): Update. * linespec.c (canonicalize_linespec): Update. (create_sals_line_offset): Update. (convert_linespec_to_sals): Update. (complete_label): Update. (find_label_symbols_in_block): Update. * m2-typeprint.c (m2_print_typedef): Update. * mdebugread.c (mdebug_reg_to_regnum): Update. (parse_symbol): Update. (mylookup_symbol): Update. * mi/mi-cmd-stack.c (list_arg_or_local): Update. (list_args_or_locals): Update. * objc-lang.c (compare_selectors): Update. (info_selectors_command): Update. (compare_classes): Update. (info_classes_command): Update. (find_imps): Update. * p-typeprint.c (pascal_print_typedef): Update. * printcmd.c (build_address_symbolic): Update. (info_address_command): Update. (print_variable_and_value): Update. * python/py-framefilter.c (extract_sym): Update. (py_print_single_arg): Update. * python/py-symbol.c (sympy_str): Update. (sympy_get_name): Update. (sympy_get_linkage_name): Update. * python/python.c (gdbpy_rbreak): Update. * record-btrace.c (btrace_get_bfun_name): Update. (btrace_call_history): Update. * rust-lang.c (rust_print_typedef): Update. * solib-frv.c (frv_fdpic_find_canonical_descriptor): Update. * stabsread.c (stab_reg_to_regnum): Update. (define_symbol): Update. (read_enum_type): Update. (common_block_end): Update. (cleanup_undefined_types_1): Update. (scan_file_globals): Update. * stack.c (print_frame_arg): Update. (print_frame_args): Update. (find_frame_funname): Update. (info_frame_command_core): Update. (iterate_over_block_locals): Update. (print_block_frame_labels): Update. (do_print_variable_and_value): Update. (iterate_over_block_arg_vars): Update. (return_command): Update. * symmisc.c (dump_symtab_1): Update. (print_symbol): Update. * symtab.c (eq_symbol_entry): Update. (symbol_cache_dump): Update. (lookup_language_this): Update. (find_pc_sect_line): Update. (skip_prologue_sal): Update. (symbol_search::compare_search_syms): Update. (treg_matches_sym_type_name): Update. (search_symbols): Update. (print_symbol_info): Update. (rbreak_command): Update. (completion_list_add_symbol): Update. (find_gnu_ifunc): Update. (get_symbol_address): Update. (search_module_symbols): Update. (info_module_subcommand): Update. * symtab.h (SYMBOL_NATURAL_NAME): Remove. (SYMBOL_LINKAGE_NAME): Remove. (SYMBOL_DEMANGLED_NAME): Remove. (SYMBOL_PRINT_NAME): Remove. (SYMBOL_SEARCH_NAME): Remove. * tracepoint.c (set_traceframe_context): Update. (validate_actionline): Update. (collection_list::collect_symbol): Update. (encode_actions_1): Update. (info_scope_command): Update. (print_one_static_tracepoint_marker): Update. * typeprint.c (typedef_hash_table::add_template_parameters): Update. * valops.c (address_of_variable): Update. (find_overload_match): Update. (find_oload_champ): Update. Change-Id: I76bdc8b44eea6876bf03af9d351f8e90cc0154b2
2019-11-22 19:05:14 +01:00
var->print_name ());
return regval;
}
}
break;
case LOC_COMPUTED:
gdb_assert_not_reached (_("LOC_COMPUTED variable missing a method"));
case LOC_UNRESOLVED:
{
New "iterate_over_objfiles_in_search_order" gdbarch method. This patch introduces the "iterate_over_objfiles_in_search_order" gdbarch method, as well as its default implementation, and converts the areas where it will matter to using this gdbarch method. The default method implementation is the only one installed, and the changes should have no functional impact in terms of behavior. This only paves the way for the architectures that will need their own version. gdb/ChangeLog: * gdbarch.sh: Add generation of "iterate_over_objfiles_in_search_order_cb_ftype" typedef in gdbarch.h. Add include of "objfiles.h" in gdbarch.c. (iterate_over_objfiles_in_search_order): New gdbarch method. * gdbarch.h, gdbarch.c: Regenerate. * objfiles.h (default_iterate_over_objfiles_in_search_order): Add declaration. * objfiles.c (default_iterate_over_objfiles_in_search_order): New function. * symtab.c (lookup_symbol_aux_objfile): New function, extracted out of lookup_symbol_aux_symtabs. (lookup_symbol_aux_symtabs): Replace extracted-out code by call to lookup_symbol_aux_objfile. (struct global_sym_lookup_data): New type. (lookup_symbol_global_iterator_cb): New function. (lookup_symbol_global): Search for symbol using gdbarch_iterate_over_objfiles_in_search_order and lookup_symbol_global_iterator_cb. * findvar.c (struct minsym_lookup_data): New type. (minsym_lookup_iterator_cb): New function. (default_read_var_value) [case LOC_UNRESOLVED]: Resolve the symbol's address via gdbarch_iterate_over_objfiles_in_search_order and minsym_lookup_iterator_cb.
2012-06-05 15:50:50 +02:00
struct minsym_lookup_data lookup_data;
struct minimal_symbol *msym;
struct obj_section *obj_section;
New "iterate_over_objfiles_in_search_order" gdbarch method. This patch introduces the "iterate_over_objfiles_in_search_order" gdbarch method, as well as its default implementation, and converts the areas where it will matter to using this gdbarch method. The default method implementation is the only one installed, and the changes should have no functional impact in terms of behavior. This only paves the way for the architectures that will need their own version. gdb/ChangeLog: * gdbarch.sh: Add generation of "iterate_over_objfiles_in_search_order_cb_ftype" typedef in gdbarch.h. Add include of "objfiles.h" in gdbarch.c. (iterate_over_objfiles_in_search_order): New gdbarch method. * gdbarch.h, gdbarch.c: Regenerate. * objfiles.h (default_iterate_over_objfiles_in_search_order): Add declaration. * objfiles.c (default_iterate_over_objfiles_in_search_order): New function. * symtab.c (lookup_symbol_aux_objfile): New function, extracted out of lookup_symbol_aux_symtabs. (lookup_symbol_aux_symtabs): Replace extracted-out code by call to lookup_symbol_aux_objfile. (struct global_sym_lookup_data): New type. (lookup_symbol_global_iterator_cb): New function. (lookup_symbol_global): Search for symbol using gdbarch_iterate_over_objfiles_in_search_order and lookup_symbol_global_iterator_cb. * findvar.c (struct minsym_lookup_data): New type. (minsym_lookup_iterator_cb): New function. (default_read_var_value) [case LOC_UNRESOLVED]: Resolve the symbol's address via gdbarch_iterate_over_objfiles_in_search_order and minsym_lookup_iterator_cb.
2012-06-05 15:50:50 +02:00
memset (&lookup_data, 0, sizeof (lookup_data));
Replace SYMBOL_*_NAME accessors with member functions Similar to the MSYMBOL version of this patch, improves readability and will eventually allow making name private. gdb/ChangeLog: 2019-11-22 Christian Biesinger <cbiesinger@google.com> * ada-exp.y: Update. * ada-lang.c (sort_choices): Update. (ada_print_symbol_signature): Update. (resolve_subexp): Update. (ada_parse_renaming): Update. (ada_read_renaming_var_value): Update. (lesseq_defined_than): Update. (remove_extra_symbols): Update. (remove_irrelevant_renamings): Update. (ada_add_block_symbols): Update. (ada_collect_symbol_completion_matches): Update. (ada_is_renaming_symbol): Update. (aggregate_assign_from_choices): Update. (ada_evaluate_subexp): Update. (ada_has_this_exception_support): Update. (ada_is_non_standard_exception_sym): Update. (ada_add_exceptions_from_frame): Update. (ada_add_global_exceptions): Update. (ada_print_subexp): Update. * ax-gdb.c (gen_var_ref): Update. (gen_maybe_namespace_elt): Update. (gen_expr_for_cast): Update. (gen_expr): Update. * block.h: Update. * blockframe.c (find_pc_partial_function): Update. * breakpoint.c (print_breakpoint_location): Update. (update_static_tracepoint): Update. * btrace.c (ftrace_print_function_name): Update. (ftrace_function_switched): Update. * buildsym.c (find_symbol_in_list): Update. * c-exp.y: Update. * c-typeprint.c (c_print_typedef): Update. (c_type_print_template_args): Update. * cli/cli-cmds.c (edit_command): Update. (list_command): Update. (print_sal_location): Update. * coffread.c (patch_opaque_types): Update. (process_coff_symbol): Update. (coff_read_enum_type): Update. * compile/compile-c-symbols.c (c_symbol_substitution_name): Update. (convert_one_symbol): Update. (hash_symname): Update. (eq_symname): Update. * compile/compile-cplus-symbols.c (convert_one_symbol): Update. * compile/compile-cplus-types.c (debug_print_scope): Update. * compile/compile-loc2c.c (do_compile_dwarf_expr_to_c): Update. * compile/compile-object-load.c (get_out_value_type): Update. * cp-namespace.c (cp_scan_for_anonymous_namespaces): Update. (search_symbol_list): Update. (cp_lookup_symbol_imports_or_template): Update. * cp-support.c (overload_list_add_symbol): Update. * ctfread.c (psymtab_to_symtab): Update. * dbxread.c (cp_set_block_scope): Update. * dictionary.c (iter_match_first_hashed): Update. (iter_match_next_hashed): Update. (insert_symbol_hashed): Update. (iter_match_next_linear): Update. * dictionary.h: Update. * dwarf2loc.c (func_get_frame_base_dwarf_block): Update. (locexpr_describe_location_piece): Update. (locexpr_describe_location_1): Update. (locexpr_generate_c_location): Update. (loclist_describe_location): Update. (loclist_generate_c_location): Update. * dwarf2read.c (dw2_debug_names_lookup_symbol): Update. (read_func_scope): Update. (process_enumeration_scope): Update. (new_symbol): Update. (dwarf2_const_value): Update. (dwarf2_symbol_mark_computed): Update. * eval.c (evaluate_funcall): Update. (evaluate_subexp_standard): Update. * expprint.c (print_subexp_standard): Update. (dump_subexp_body_standard): Update. * f-valprint.c (info_common_command_for_block): Update. * findvar.c (get_hosting_frame): Update. (default_read_var_value): Update. * go-lang.c (go_symbol_package_name): Update. * guile/scm-block.c (bkscm_print_block_smob): Update. * guile/scm-symbol.c (syscm_print_symbol_smob): Update. (gdbscm_symbol_name): Update. (gdbscm_symbol_linkage_name): Update. (gdbscm_symbol_print_name): Update. * infcall.c (get_function_name): Update. * infcmd.c (jump_command): Update. (finish_command): Update. * infrun.c (insert_exception_resume_breakpoint): Update. * linespec.c (canonicalize_linespec): Update. (create_sals_line_offset): Update. (convert_linespec_to_sals): Update. (complete_label): Update. (find_label_symbols_in_block): Update. * m2-typeprint.c (m2_print_typedef): Update. * mdebugread.c (mdebug_reg_to_regnum): Update. (parse_symbol): Update. (mylookup_symbol): Update. * mi/mi-cmd-stack.c (list_arg_or_local): Update. (list_args_or_locals): Update. * objc-lang.c (compare_selectors): Update. (info_selectors_command): Update. (compare_classes): Update. (info_classes_command): Update. (find_imps): Update. * p-typeprint.c (pascal_print_typedef): Update. * printcmd.c (build_address_symbolic): Update. (info_address_command): Update. (print_variable_and_value): Update. * python/py-framefilter.c (extract_sym): Update. (py_print_single_arg): Update. * python/py-symbol.c (sympy_str): Update. (sympy_get_name): Update. (sympy_get_linkage_name): Update. * python/python.c (gdbpy_rbreak): Update. * record-btrace.c (btrace_get_bfun_name): Update. (btrace_call_history): Update. * rust-lang.c (rust_print_typedef): Update. * solib-frv.c (frv_fdpic_find_canonical_descriptor): Update. * stabsread.c (stab_reg_to_regnum): Update. (define_symbol): Update. (read_enum_type): Update. (common_block_end): Update. (cleanup_undefined_types_1): Update. (scan_file_globals): Update. * stack.c (print_frame_arg): Update. (print_frame_args): Update. (find_frame_funname): Update. (info_frame_command_core): Update. (iterate_over_block_locals): Update. (print_block_frame_labels): Update. (do_print_variable_and_value): Update. (iterate_over_block_arg_vars): Update. (return_command): Update. * symmisc.c (dump_symtab_1): Update. (print_symbol): Update. * symtab.c (eq_symbol_entry): Update. (symbol_cache_dump): Update. (lookup_language_this): Update. (find_pc_sect_line): Update. (skip_prologue_sal): Update. (symbol_search::compare_search_syms): Update. (treg_matches_sym_type_name): Update. (search_symbols): Update. (print_symbol_info): Update. (rbreak_command): Update. (completion_list_add_symbol): Update. (find_gnu_ifunc): Update. (get_symbol_address): Update. (search_module_symbols): Update. (info_module_subcommand): Update. * symtab.h (SYMBOL_NATURAL_NAME): Remove. (SYMBOL_LINKAGE_NAME): Remove. (SYMBOL_DEMANGLED_NAME): Remove. (SYMBOL_PRINT_NAME): Remove. (SYMBOL_SEARCH_NAME): Remove. * tracepoint.c (set_traceframe_context): Update. (validate_actionline): Update. (collection_list::collect_symbol): Update. (encode_actions_1): Update. (info_scope_command): Update. (print_one_static_tracepoint_marker): Update. * typeprint.c (typedef_hash_table::add_template_parameters): Update. * valops.c (address_of_variable): Update. (find_overload_match): Update. (find_oload_champ): Update. Change-Id: I76bdc8b44eea6876bf03af9d351f8e90cc0154b2
2019-11-22 19:05:14 +01:00
lookup_data.name = var->linkage_name ();
New "iterate_over_objfiles_in_search_order" gdbarch method. This patch introduces the "iterate_over_objfiles_in_search_order" gdbarch method, as well as its default implementation, and converts the areas where it will matter to using this gdbarch method. The default method implementation is the only one installed, and the changes should have no functional impact in terms of behavior. This only paves the way for the architectures that will need their own version. gdb/ChangeLog: * gdbarch.sh: Add generation of "iterate_over_objfiles_in_search_order_cb_ftype" typedef in gdbarch.h. Add include of "objfiles.h" in gdbarch.c. (iterate_over_objfiles_in_search_order): New gdbarch method. * gdbarch.h, gdbarch.c: Regenerate. * objfiles.h (default_iterate_over_objfiles_in_search_order): Add declaration. * objfiles.c (default_iterate_over_objfiles_in_search_order): New function. * symtab.c (lookup_symbol_aux_objfile): New function, extracted out of lookup_symbol_aux_symtabs. (lookup_symbol_aux_symtabs): Replace extracted-out code by call to lookup_symbol_aux_objfile. (struct global_sym_lookup_data): New type. (lookup_symbol_global_iterator_cb): New function. (lookup_symbol_global): Search for symbol using gdbarch_iterate_over_objfiles_in_search_order and lookup_symbol_global_iterator_cb. * findvar.c (struct minsym_lookup_data): New type. (minsym_lookup_iterator_cb): New function. (default_read_var_value) [case LOC_UNRESOLVED]: Resolve the symbol's address via gdbarch_iterate_over_objfiles_in_search_order and minsym_lookup_iterator_cb.
2012-06-05 15:50:50 +02:00
gdbarch_iterate_over_objfiles_in_search_order
(symbol_arch (var),
New "iterate_over_objfiles_in_search_order" gdbarch method. This patch introduces the "iterate_over_objfiles_in_search_order" gdbarch method, as well as its default implementation, and converts the areas where it will matter to using this gdbarch method. The default method implementation is the only one installed, and the changes should have no functional impact in terms of behavior. This only paves the way for the architectures that will need their own version. gdb/ChangeLog: * gdbarch.sh: Add generation of "iterate_over_objfiles_in_search_order_cb_ftype" typedef in gdbarch.h. Add include of "objfiles.h" in gdbarch.c. (iterate_over_objfiles_in_search_order): New gdbarch method. * gdbarch.h, gdbarch.c: Regenerate. * objfiles.h (default_iterate_over_objfiles_in_search_order): Add declaration. * objfiles.c (default_iterate_over_objfiles_in_search_order): New function. * symtab.c (lookup_symbol_aux_objfile): New function, extracted out of lookup_symbol_aux_symtabs. (lookup_symbol_aux_symtabs): Replace extracted-out code by call to lookup_symbol_aux_objfile. (struct global_sym_lookup_data): New type. (lookup_symbol_global_iterator_cb): New function. (lookup_symbol_global): Search for symbol using gdbarch_iterate_over_objfiles_in_search_order and lookup_symbol_global_iterator_cb. * findvar.c (struct minsym_lookup_data): New type. (minsym_lookup_iterator_cb): New function. (default_read_var_value) [case LOC_UNRESOLVED]: Resolve the symbol's address via gdbarch_iterate_over_objfiles_in_search_order and minsym_lookup_iterator_cb.
2012-06-05 15:50:50 +02:00
minsym_lookup_iterator_cb, &lookup_data,
symbol_objfile (var));
use bound_minsym as result for lookup_minimal_symbol et al This patch changes a few minimal symbol lookup functions to return a bound_minimal_symbol rather than a pointer to the minsym. This change helps prepare gdb for computing a minimal symbol's address at the point of use. Note that this changes even those functions that ostensibly search a single objfile. That was necessary because, in fact, those functions can search an objfile and its separate debug objfiles; and it is important for the caller to know in which objfile the minimal symbol was actually found. The bulk of this patch is mechanical. 2014-02-26 Tom Tromey <tromey@redhat.com> * ada-lang.c (ada_update_initial_language): Update. (ada_main_name, ada_has_this_exception_support): Update. * ada-tasks.c (ada_tasks_inferior_data_sniffer): Update. * aix-thread.c (pdc_symbol_addrs, pd_enable): Update. * arm-tdep.c (arm_skip_stub): Update. * auxv.c (ld_so_xfer_auxv): Update. * avr-tdep.c (avr_scan_prologue): Update. * ax-gdb.c (gen_var_ref): Update. * breakpoint.c (struct breakpoint_objfile_data) <overlay_msym, longjmp_msym, terminate_msym, exception_msym>: Change type to bound_minimal_symbol. (create_overlay_event_breakpoint) (create_longjmp_master_breakpoint) (create_std_terminate_master_breakpoint) (create_exception_master_breakpoint): Update. * bsd-uthread.c (bsd_uthread_lookup_address): Update. * c-exp.y (classify_name): Update. * coffread.c (coff_symfile_read): Update. * common/agent.c (agent_look_up_symbols): Update. * d-lang.c (d_main_name): Update. * dbxread.c (find_stab_function_addr, end_psymtab): Update. * dec-thread.c (enable_dec_thread): Update. * dwarf2loc.c (call_site_to_target_addr): Update. * elfread.c (elf_gnu_ifunc_resolve_by_got): Update. * eval.c (evaluate_subexp_standard): Update. * findvar.c (struct minsym_lookup_data) <result>: Change type to bound_minimal_symbol. <objfile>: Remove. (minsym_lookup_iterator_cb, default_read_var_value): Update. * frame.c (inside_main_func): Update. * frv-tdep.c (frv_frame_this_id): Update. * gcore.c (call_target_sbrk): Update. * glibc-tdep.c (glibc_skip_solib_resolver): Update. * gnu-v3-abi.c (gnuv3_get_typeid, gnuv3_skip_trampoline): Update. * go-lang.c (go_main_name): Update. * hppa-hpux-tdep.c (hppa_hpux_skip_trampoline_code) (hppa_hpux_find_import_stub_for_addr): Update. * hppa-tdep.c (hppa_extract_17, hppa_lookup_stub_minimal_symbol): Update. Change return type. * hppa-tdep.h (hppa_lookup_stub_minimal_symbol): Change return type. * jit.c (jit_breakpoint_re_set_internal): Update. * linux-fork.c (inferior_call_waitpid, checkpoint_command): Update. * linux-nat.c (get_signo): Update. * linux-thread-db.c (inferior_has_bug): Update * m32c-tdep.c (m32c_return_value) (m32c_m16c_address_to_pointer): Update. * m32r-tdep.c (m32r_frame_this_id): Update. * m68hc11-tdep.c (m68hc11_get_register_info): Update. * machoread.c (macho_resolve_oso_sym_with_minsym): Update. * minsyms.c (lookup_minimal_symbol_internal): Rename to lookup_minimal_symbol. Change return type. (lookup_minimal_symbol): Remove. (lookup_bound_minimal_symbol): Update. (lookup_minimal_symbol_text): Change return type. (lookup_minimal_symbol_solib_trampoline): Change return type. * minsyms.h (lookup_minimal_symbol, lookup_minimal_symbol_text) (lookup_minimal_symbol_solib_trampoline): Change return type. * mips-linux-tdep.c (mips_linux_skip_resolver): Update. * objc-lang.c (lookup_objc_class, lookup_child_selector) (value_nsstring, find_imps): Update. * obsd-tdep.c (obsd_skip_solib_resolver): Update. * p-lang.c (pascal_main_name): Update. * ppc-linux-tdep.c (ppc_linux_spe_context_lookup): Update. * ppc-sysv-tdep.c (convert_code_addr_to_desc_addr): Update. * proc-service.c (ps_pglobal_lookup): Update. * ravenscar-thread.c (get_running_thread_msymbol): Change return type. (has_ravenscar_runtime, get_running_thread_id): Update. * remote.c (remote_check_symbols): Update. * sol-thread.c (ps_pglobal_lookup): Update. * sol2-tdep.c (sol2_skip_solib_resolver): Update. * solib-dsbt.c (lm_base): Update. * solib-frv.c (lm_base, frv_relocate_section_addresses): Update. * solib-irix.c (locate_base): Update. * solib-som.c (som_solib_create_inferior_hook) (som_solib_desire_dynamic_linker_symbols, link_map_start): Update. * solib-spu.c (spu_enable_break): Update. * solib-svr4.c (elf_locate_base, enable_break): Update. * spu-tdep.c (spu_get_overlay_table, spu_catch_start) (flush_ea_cache): Update. * stabsread.c (define_symbol): Update. * symfile.c (simple_read_overlay_table): Update. * symtab.c (find_pc_sect_line): Update. * tracepoint.c (scope_info): Update. * tui-disasm.c (tui_get_begin_asm_address): Update. * value.c (value_static_field): Update.
2013-10-15 03:53:29 +02:00
msym = lookup_data.result.minsym;
New "iterate_over_objfiles_in_search_order" gdbarch method. This patch introduces the "iterate_over_objfiles_in_search_order" gdbarch method, as well as its default implementation, and converts the areas where it will matter to using this gdbarch method. The default method implementation is the only one installed, and the changes should have no functional impact in terms of behavior. This only paves the way for the architectures that will need their own version. gdb/ChangeLog: * gdbarch.sh: Add generation of "iterate_over_objfiles_in_search_order_cb_ftype" typedef in gdbarch.h. Add include of "objfiles.h" in gdbarch.c. (iterate_over_objfiles_in_search_order): New gdbarch method. * gdbarch.h, gdbarch.c: Regenerate. * objfiles.h (default_iterate_over_objfiles_in_search_order): Add declaration. * objfiles.c (default_iterate_over_objfiles_in_search_order): New function. * symtab.c (lookup_symbol_aux_objfile): New function, extracted out of lookup_symbol_aux_symtabs. (lookup_symbol_aux_symtabs): Replace extracted-out code by call to lookup_symbol_aux_objfile. (struct global_sym_lookup_data): New type. (lookup_symbol_global_iterator_cb): New function. (lookup_symbol_global): Search for symbol using gdbarch_iterate_over_objfiles_in_search_order and lookup_symbol_global_iterator_cb. * findvar.c (struct minsym_lookup_data): New type. (minsym_lookup_iterator_cb): New function. (default_read_var_value) [case LOC_UNRESOLVED]: Resolve the symbol's address via gdbarch_iterate_over_objfiles_in_search_order and minsym_lookup_iterator_cb.
2012-06-05 15:50:50 +02:00
/* If we can't find the minsym there's a problem in the symbol info.
The symbol exists in the debug info, but it's missing in the minsym
table. */
if (msym == NULL)
{
const char *flavour_name
= objfile_flavour_name (symbol_objfile (var));
/* We can't get here unless we've opened the file, so flavour_name
can't be NULL. */
gdb_assert (flavour_name != NULL);
error (_("Missing %s symbol \"%s\"."),
Replace SYMBOL_*_NAME accessors with member functions Similar to the MSYMBOL version of this patch, improves readability and will eventually allow making name private. gdb/ChangeLog: 2019-11-22 Christian Biesinger <cbiesinger@google.com> * ada-exp.y: Update. * ada-lang.c (sort_choices): Update. (ada_print_symbol_signature): Update. (resolve_subexp): Update. (ada_parse_renaming): Update. (ada_read_renaming_var_value): Update. (lesseq_defined_than): Update. (remove_extra_symbols): Update. (remove_irrelevant_renamings): Update. (ada_add_block_symbols): Update. (ada_collect_symbol_completion_matches): Update. (ada_is_renaming_symbol): Update. (aggregate_assign_from_choices): Update. (ada_evaluate_subexp): Update. (ada_has_this_exception_support): Update. (ada_is_non_standard_exception_sym): Update. (ada_add_exceptions_from_frame): Update. (ada_add_global_exceptions): Update. (ada_print_subexp): Update. * ax-gdb.c (gen_var_ref): Update. (gen_maybe_namespace_elt): Update. (gen_expr_for_cast): Update. (gen_expr): Update. * block.h: Update. * blockframe.c (find_pc_partial_function): Update. * breakpoint.c (print_breakpoint_location): Update. (update_static_tracepoint): Update. * btrace.c (ftrace_print_function_name): Update. (ftrace_function_switched): Update. * buildsym.c (find_symbol_in_list): Update. * c-exp.y: Update. * c-typeprint.c (c_print_typedef): Update. (c_type_print_template_args): Update. * cli/cli-cmds.c (edit_command): Update. (list_command): Update. (print_sal_location): Update. * coffread.c (patch_opaque_types): Update. (process_coff_symbol): Update. (coff_read_enum_type): Update. * compile/compile-c-symbols.c (c_symbol_substitution_name): Update. (convert_one_symbol): Update. (hash_symname): Update. (eq_symname): Update. * compile/compile-cplus-symbols.c (convert_one_symbol): Update. * compile/compile-cplus-types.c (debug_print_scope): Update. * compile/compile-loc2c.c (do_compile_dwarf_expr_to_c): Update. * compile/compile-object-load.c (get_out_value_type): Update. * cp-namespace.c (cp_scan_for_anonymous_namespaces): Update. (search_symbol_list): Update. (cp_lookup_symbol_imports_or_template): Update. * cp-support.c (overload_list_add_symbol): Update. * ctfread.c (psymtab_to_symtab): Update. * dbxread.c (cp_set_block_scope): Update. * dictionary.c (iter_match_first_hashed): Update. (iter_match_next_hashed): Update. (insert_symbol_hashed): Update. (iter_match_next_linear): Update. * dictionary.h: Update. * dwarf2loc.c (func_get_frame_base_dwarf_block): Update. (locexpr_describe_location_piece): Update. (locexpr_describe_location_1): Update. (locexpr_generate_c_location): Update. (loclist_describe_location): Update. (loclist_generate_c_location): Update. * dwarf2read.c (dw2_debug_names_lookup_symbol): Update. (read_func_scope): Update. (process_enumeration_scope): Update. (new_symbol): Update. (dwarf2_const_value): Update. (dwarf2_symbol_mark_computed): Update. * eval.c (evaluate_funcall): Update. (evaluate_subexp_standard): Update. * expprint.c (print_subexp_standard): Update. (dump_subexp_body_standard): Update. * f-valprint.c (info_common_command_for_block): Update. * findvar.c (get_hosting_frame): Update. (default_read_var_value): Update. * go-lang.c (go_symbol_package_name): Update. * guile/scm-block.c (bkscm_print_block_smob): Update. * guile/scm-symbol.c (syscm_print_symbol_smob): Update. (gdbscm_symbol_name): Update. (gdbscm_symbol_linkage_name): Update. (gdbscm_symbol_print_name): Update. * infcall.c (get_function_name): Update. * infcmd.c (jump_command): Update. (finish_command): Update. * infrun.c (insert_exception_resume_breakpoint): Update. * linespec.c (canonicalize_linespec): Update. (create_sals_line_offset): Update. (convert_linespec_to_sals): Update. (complete_label): Update. (find_label_symbols_in_block): Update. * m2-typeprint.c (m2_print_typedef): Update. * mdebugread.c (mdebug_reg_to_regnum): Update. (parse_symbol): Update. (mylookup_symbol): Update. * mi/mi-cmd-stack.c (list_arg_or_local): Update. (list_args_or_locals): Update. * objc-lang.c (compare_selectors): Update. (info_selectors_command): Update. (compare_classes): Update. (info_classes_command): Update. (find_imps): Update. * p-typeprint.c (pascal_print_typedef): Update. * printcmd.c (build_address_symbolic): Update. (info_address_command): Update. (print_variable_and_value): Update. * python/py-framefilter.c (extract_sym): Update. (py_print_single_arg): Update. * python/py-symbol.c (sympy_str): Update. (sympy_get_name): Update. (sympy_get_linkage_name): Update. * python/python.c (gdbpy_rbreak): Update. * record-btrace.c (btrace_get_bfun_name): Update. (btrace_call_history): Update. * rust-lang.c (rust_print_typedef): Update. * solib-frv.c (frv_fdpic_find_canonical_descriptor): Update. * stabsread.c (stab_reg_to_regnum): Update. (define_symbol): Update. (read_enum_type): Update. (common_block_end): Update. (cleanup_undefined_types_1): Update. (scan_file_globals): Update. * stack.c (print_frame_arg): Update. (print_frame_args): Update. (find_frame_funname): Update. (info_frame_command_core): Update. (iterate_over_block_locals): Update. (print_block_frame_labels): Update. (do_print_variable_and_value): Update. (iterate_over_block_arg_vars): Update. (return_command): Update. * symmisc.c (dump_symtab_1): Update. (print_symbol): Update. * symtab.c (eq_symbol_entry): Update. (symbol_cache_dump): Update. (lookup_language_this): Update. (find_pc_sect_line): Update. (skip_prologue_sal): Update. (symbol_search::compare_search_syms): Update. (treg_matches_sym_type_name): Update. (search_symbols): Update. (print_symbol_info): Update. (rbreak_command): Update. (completion_list_add_symbol): Update. (find_gnu_ifunc): Update. (get_symbol_address): Update. (search_module_symbols): Update. (info_module_subcommand): Update. * symtab.h (SYMBOL_NATURAL_NAME): Remove. (SYMBOL_LINKAGE_NAME): Remove. (SYMBOL_DEMANGLED_NAME): Remove. (SYMBOL_PRINT_NAME): Remove. (SYMBOL_SEARCH_NAME): Remove. * tracepoint.c (set_traceframe_context): Update. (validate_actionline): Update. (collection_list::collect_symbol): Update. (encode_actions_1): Update. (info_scope_command): Update. (print_one_static_tracepoint_marker): Update. * typeprint.c (typedef_hash_table::add_template_parameters): Update. * valops.c (address_of_variable): Update. (find_overload_match): Update. (find_oload_champ): Update. Change-Id: I76bdc8b44eea6876bf03af9d351f8e90cc0154b2
2019-11-22 19:05:14 +01:00
flavour_name, var->linkage_name ());
}
use bound_minsym as result for lookup_minimal_symbol et al This patch changes a few minimal symbol lookup functions to return a bound_minimal_symbol rather than a pointer to the minsym. This change helps prepare gdb for computing a minimal symbol's address at the point of use. Note that this changes even those functions that ostensibly search a single objfile. That was necessary because, in fact, those functions can search an objfile and its separate debug objfiles; and it is important for the caller to know in which objfile the minimal symbol was actually found. The bulk of this patch is mechanical. 2014-02-26 Tom Tromey <tromey@redhat.com> * ada-lang.c (ada_update_initial_language): Update. (ada_main_name, ada_has_this_exception_support): Update. * ada-tasks.c (ada_tasks_inferior_data_sniffer): Update. * aix-thread.c (pdc_symbol_addrs, pd_enable): Update. * arm-tdep.c (arm_skip_stub): Update. * auxv.c (ld_so_xfer_auxv): Update. * avr-tdep.c (avr_scan_prologue): Update. * ax-gdb.c (gen_var_ref): Update. * breakpoint.c (struct breakpoint_objfile_data) <overlay_msym, longjmp_msym, terminate_msym, exception_msym>: Change type to bound_minimal_symbol. (create_overlay_event_breakpoint) (create_longjmp_master_breakpoint) (create_std_terminate_master_breakpoint) (create_exception_master_breakpoint): Update. * bsd-uthread.c (bsd_uthread_lookup_address): Update. * c-exp.y (classify_name): Update. * coffread.c (coff_symfile_read): Update. * common/agent.c (agent_look_up_symbols): Update. * d-lang.c (d_main_name): Update. * dbxread.c (find_stab_function_addr, end_psymtab): Update. * dec-thread.c (enable_dec_thread): Update. * dwarf2loc.c (call_site_to_target_addr): Update. * elfread.c (elf_gnu_ifunc_resolve_by_got): Update. * eval.c (evaluate_subexp_standard): Update. * findvar.c (struct minsym_lookup_data) <result>: Change type to bound_minimal_symbol. <objfile>: Remove. (minsym_lookup_iterator_cb, default_read_var_value): Update. * frame.c (inside_main_func): Update. * frv-tdep.c (frv_frame_this_id): Update. * gcore.c (call_target_sbrk): Update. * glibc-tdep.c (glibc_skip_solib_resolver): Update. * gnu-v3-abi.c (gnuv3_get_typeid, gnuv3_skip_trampoline): Update. * go-lang.c (go_main_name): Update. * hppa-hpux-tdep.c (hppa_hpux_skip_trampoline_code) (hppa_hpux_find_import_stub_for_addr): Update. * hppa-tdep.c (hppa_extract_17, hppa_lookup_stub_minimal_symbol): Update. Change return type. * hppa-tdep.h (hppa_lookup_stub_minimal_symbol): Change return type. * jit.c (jit_breakpoint_re_set_internal): Update. * linux-fork.c (inferior_call_waitpid, checkpoint_command): Update. * linux-nat.c (get_signo): Update. * linux-thread-db.c (inferior_has_bug): Update * m32c-tdep.c (m32c_return_value) (m32c_m16c_address_to_pointer): Update. * m32r-tdep.c (m32r_frame_this_id): Update. * m68hc11-tdep.c (m68hc11_get_register_info): Update. * machoread.c (macho_resolve_oso_sym_with_minsym): Update. * minsyms.c (lookup_minimal_symbol_internal): Rename to lookup_minimal_symbol. Change return type. (lookup_minimal_symbol): Remove. (lookup_bound_minimal_symbol): Update. (lookup_minimal_symbol_text): Change return type. (lookup_minimal_symbol_solib_trampoline): Change return type. * minsyms.h (lookup_minimal_symbol, lookup_minimal_symbol_text) (lookup_minimal_symbol_solib_trampoline): Change return type. * mips-linux-tdep.c (mips_linux_skip_resolver): Update. * objc-lang.c (lookup_objc_class, lookup_child_selector) (value_nsstring, find_imps): Update. * obsd-tdep.c (obsd_skip_solib_resolver): Update. * p-lang.c (pascal_main_name): Update. * ppc-linux-tdep.c (ppc_linux_spe_context_lookup): Update. * ppc-sysv-tdep.c (convert_code_addr_to_desc_addr): Update. * proc-service.c (ps_pglobal_lookup): Update. * ravenscar-thread.c (get_running_thread_msymbol): Change return type. (has_ravenscar_runtime, get_running_thread_id): Update. * remote.c (remote_check_symbols): Update. * sol-thread.c (ps_pglobal_lookup): Update. * sol2-tdep.c (sol2_skip_solib_resolver): Update. * solib-dsbt.c (lm_base): Update. * solib-frv.c (lm_base, frv_relocate_section_addresses): Update. * solib-irix.c (locate_base): Update. * solib-som.c (som_solib_create_inferior_hook) (som_solib_desire_dynamic_linker_symbols, link_map_start): Update. * solib-spu.c (spu_enable_break): Update. * solib-svr4.c (elf_locate_base, enable_break): Update. * spu-tdep.c (spu_get_overlay_table, spu_catch_start) (flush_ea_cache): Update. * stabsread.c (define_symbol): Update. * symfile.c (simple_read_overlay_table): Update. * symtab.c (find_pc_sect_line): Update. * tracepoint.c (scope_info): Update. * tui-disasm.c (tui_get_begin_asm_address): Update. * value.c (value_static_field): Update.
2013-10-15 03:53:29 +02:00
obj_section = MSYMBOL_OBJ_SECTION (lookup_data.result.objfile, msym);
/* Relocate address, unless there is no section or the variable is
a TLS variable. */
if (obj_section == NULL
|| (obj_section->the_bfd_section->flags & SEC_THREAD_LOCAL) != 0)
addr = MSYMBOL_VALUE_RAW_ADDRESS (msym);
else
addr = BMSYMBOL_VALUE_ADDRESS (lookup_data.result);
if (overlay_debugging)
addr = symbol_overlayed_address (addr, obj_section);
/* Determine address of TLS variable. */
if (obj_section
&& (obj_section->the_bfd_section->flags & SEC_THREAD_LOCAL) != 0)
addr = target_translate_tls_address (obj_section->objfile, addr);
}
break;
case LOC_OPTIMIZED_OUT:
if (is_dynamic_type (type))
Prefer existing data when evaluating DWARF expression When evaluating a DWARF expression, the dynamic type resolution code will pass in a buffer of bytes via the property_addr_info. However, the DWARF expression evaluator will then proceed to read memory from the inferior, even when the request could be filled from this buffer. This, in turn, is a problem in some cases; and specifically when trying to handle the Ada scenario of extracting a variable-length value from a packed array. Here, the ordinary DWARF expression cannot be directly evaluated, because the data may appear at some arbitrary bit offset. So, it is unpacked into a staging area and then the expression is evaluated -- using an address of 0. This patch fixes the problem by arranging for the DWARF evaluator, in this case, to prefer passed-in memory when possible. The type of the buffer in the property_addr_info is changed to an array_view so that bounds checking can be done. gdb/ChangeLog 2020-04-24 Tom Tromey <tromey@adacore.com> * ada-lang.c (ada_discrete_type_high_bound, ada_discrete_type_low) (ada_value_primitive_packed_val): Update. * ada-valprint.c (ada_value_print_1): Update. * dwarf2/loc.c (evaluate_for_locexpr_baton): New struct. (dwarf2_locexpr_baton_eval): Take a property_addr_info rather than just an address. Use evaluate_for_locexpr_baton. (dwarf2_evaluate_property): Update. * dwarf2/loc.h (struct property_addr_info) <valaddr>: Now an array_view. * findvar.c (default_read_var_value): Update. * gdbtypes.c (compute_variant_fields_inner) (resolve_dynamic_type_internal): Update. (resolve_dynamic_type): Change type of valaddr parameter. * gdbtypes.h (resolve_dynamic_type): Update. * valarith.c (value_subscripted_rvalue): Update. * value.c (value_from_contents_and_address): Update.
2020-04-24 21:40:31 +02:00
type = resolve_dynamic_type (type, {}, /* Unused address. */ 0);
return allocate_optimized_out_value (type);
default:
error (_("Cannot look up value of a botched symbol `%s'."),
Replace SYMBOL_*_NAME accessors with member functions Similar to the MSYMBOL version of this patch, improves readability and will eventually allow making name private. gdb/ChangeLog: 2019-11-22 Christian Biesinger <cbiesinger@google.com> * ada-exp.y: Update. * ada-lang.c (sort_choices): Update. (ada_print_symbol_signature): Update. (resolve_subexp): Update. (ada_parse_renaming): Update. (ada_read_renaming_var_value): Update. (lesseq_defined_than): Update. (remove_extra_symbols): Update. (remove_irrelevant_renamings): Update. (ada_add_block_symbols): Update. (ada_collect_symbol_completion_matches): Update. (ada_is_renaming_symbol): Update. (aggregate_assign_from_choices): Update. (ada_evaluate_subexp): Update. (ada_has_this_exception_support): Update. (ada_is_non_standard_exception_sym): Update. (ada_add_exceptions_from_frame): Update. (ada_add_global_exceptions): Update. (ada_print_subexp): Update. * ax-gdb.c (gen_var_ref): Update. (gen_maybe_namespace_elt): Update. (gen_expr_for_cast): Update. (gen_expr): Update. * block.h: Update. * blockframe.c (find_pc_partial_function): Update. * breakpoint.c (print_breakpoint_location): Update. (update_static_tracepoint): Update. * btrace.c (ftrace_print_function_name): Update. (ftrace_function_switched): Update. * buildsym.c (find_symbol_in_list): Update. * c-exp.y: Update. * c-typeprint.c (c_print_typedef): Update. (c_type_print_template_args): Update. * cli/cli-cmds.c (edit_command): Update. (list_command): Update. (print_sal_location): Update. * coffread.c (patch_opaque_types): Update. (process_coff_symbol): Update. (coff_read_enum_type): Update. * compile/compile-c-symbols.c (c_symbol_substitution_name): Update. (convert_one_symbol): Update. (hash_symname): Update. (eq_symname): Update. * compile/compile-cplus-symbols.c (convert_one_symbol): Update. * compile/compile-cplus-types.c (debug_print_scope): Update. * compile/compile-loc2c.c (do_compile_dwarf_expr_to_c): Update. * compile/compile-object-load.c (get_out_value_type): Update. * cp-namespace.c (cp_scan_for_anonymous_namespaces): Update. (search_symbol_list): Update. (cp_lookup_symbol_imports_or_template): Update. * cp-support.c (overload_list_add_symbol): Update. * ctfread.c (psymtab_to_symtab): Update. * dbxread.c (cp_set_block_scope): Update. * dictionary.c (iter_match_first_hashed): Update. (iter_match_next_hashed): Update. (insert_symbol_hashed): Update. (iter_match_next_linear): Update. * dictionary.h: Update. * dwarf2loc.c (func_get_frame_base_dwarf_block): Update. (locexpr_describe_location_piece): Update. (locexpr_describe_location_1): Update. (locexpr_generate_c_location): Update. (loclist_describe_location): Update. (loclist_generate_c_location): Update. * dwarf2read.c (dw2_debug_names_lookup_symbol): Update. (read_func_scope): Update. (process_enumeration_scope): Update. (new_symbol): Update. (dwarf2_const_value): Update. (dwarf2_symbol_mark_computed): Update. * eval.c (evaluate_funcall): Update. (evaluate_subexp_standard): Update. * expprint.c (print_subexp_standard): Update. (dump_subexp_body_standard): Update. * f-valprint.c (info_common_command_for_block): Update. * findvar.c (get_hosting_frame): Update. (default_read_var_value): Update. * go-lang.c (go_symbol_package_name): Update. * guile/scm-block.c (bkscm_print_block_smob): Update. * guile/scm-symbol.c (syscm_print_symbol_smob): Update. (gdbscm_symbol_name): Update. (gdbscm_symbol_linkage_name): Update. (gdbscm_symbol_print_name): Update. * infcall.c (get_function_name): Update. * infcmd.c (jump_command): Update. (finish_command): Update. * infrun.c (insert_exception_resume_breakpoint): Update. * linespec.c (canonicalize_linespec): Update. (create_sals_line_offset): Update. (convert_linespec_to_sals): Update. (complete_label): Update. (find_label_symbols_in_block): Update. * m2-typeprint.c (m2_print_typedef): Update. * mdebugread.c (mdebug_reg_to_regnum): Update. (parse_symbol): Update. (mylookup_symbol): Update. * mi/mi-cmd-stack.c (list_arg_or_local): Update. (list_args_or_locals): Update. * objc-lang.c (compare_selectors): Update. (info_selectors_command): Update. (compare_classes): Update. (info_classes_command): Update. (find_imps): Update. * p-typeprint.c (pascal_print_typedef): Update. * printcmd.c (build_address_symbolic): Update. (info_address_command): Update. (print_variable_and_value): Update. * python/py-framefilter.c (extract_sym): Update. (py_print_single_arg): Update. * python/py-symbol.c (sympy_str): Update. (sympy_get_name): Update. (sympy_get_linkage_name): Update. * python/python.c (gdbpy_rbreak): Update. * record-btrace.c (btrace_get_bfun_name): Update. (btrace_call_history): Update. * rust-lang.c (rust_print_typedef): Update. * solib-frv.c (frv_fdpic_find_canonical_descriptor): Update. * stabsread.c (stab_reg_to_regnum): Update. (define_symbol): Update. (read_enum_type): Update. (common_block_end): Update. (cleanup_undefined_types_1): Update. (scan_file_globals): Update. * stack.c (print_frame_arg): Update. (print_frame_args): Update. (find_frame_funname): Update. (info_frame_command_core): Update. (iterate_over_block_locals): Update. (print_block_frame_labels): Update. (do_print_variable_and_value): Update. (iterate_over_block_arg_vars): Update. (return_command): Update. * symmisc.c (dump_symtab_1): Update. (print_symbol): Update. * symtab.c (eq_symbol_entry): Update. (symbol_cache_dump): Update. (lookup_language_this): Update. (find_pc_sect_line): Update. (skip_prologue_sal): Update. (symbol_search::compare_search_syms): Update. (treg_matches_sym_type_name): Update. (search_symbols): Update. (print_symbol_info): Update. (rbreak_command): Update. (completion_list_add_symbol): Update. (find_gnu_ifunc): Update. (get_symbol_address): Update. (search_module_symbols): Update. (info_module_subcommand): Update. * symtab.h (SYMBOL_NATURAL_NAME): Remove. (SYMBOL_LINKAGE_NAME): Remove. (SYMBOL_DEMANGLED_NAME): Remove. (SYMBOL_PRINT_NAME): Remove. (SYMBOL_SEARCH_NAME): Remove. * tracepoint.c (set_traceframe_context): Update. (validate_actionline): Update. (collection_list::collect_symbol): Update. (encode_actions_1): Update. (info_scope_command): Update. (print_one_static_tracepoint_marker): Update. * typeprint.c (typedef_hash_table::add_template_parameters): Update. * valops.c (address_of_variable): Update. (find_overload_match): Update. (find_oload_champ): Update. Change-Id: I76bdc8b44eea6876bf03af9d351f8e90cc0154b2
2019-11-22 19:05:14 +01:00
var->print_name ());
break;
}
v = value_at_lazy (type, addr);
return v;
}
gdb: Convert language la_read_var_value field to a method This commit changes the language_data::la_read_var_value function pointer member variable into a member function of language_defn. An interesting aspect of this change is that the implementation of language_defn::read_var_value is actually in findvar.c. This is partly historical, the new language_defn::read_var_value is a rename of default_read_var_value, which was already in that file, but also, that is the file that contains the helper functions needed by the read_var_value method, so it makes sens that the method implementation should continue to live there (I think). There should be no user visible changes after this commit. gdb/ChangeLog: * ada-lang.c (ada_read_var_value): Delete function, move implementation to... (ada_language::read_var_value): ...here. (ada_language_data): Delete la_read_var_value initializer. * c-lang.c (c_language_data): Likewise. (cplus_language_data): Likewise. (minimal_language_data): Likewise. * d-lang.c (d_language_data): Likewise. * f-lang.c (f_language_data): Likewise. * findvar.c (default_read_var_value): Rename to... (language_defn::read_var_value): ...this. * findvar.c (read_var_value): Update header comment, and change to call member function instead of function pointer. * go-lang.c (go_language_data): Likewise. * language.c (unknown_language_data): Delete la_read_var_value initializer. (auto_language_data): Likewise. * language.h (struct language_data): Delete la_read_var_value field. (language_defn::read_var_value): New member function. (default_read_var_value): Delete declaration. * m2-lang.c (m2_language_data): Delete la_read_var_value initializer. * objc-lang.c (objc_language_data): Likewise. * opencl-lang.c (opencl_language_data): Likewise. * p-lang.c (pascal_language_data): Likewise. * rust-lang.c (rust_language_data): Likewise. * value.h (default_read_var_value): Delete declaration.
2020-05-01 18:33:22 +02:00
/* Calls VAR's language read_var_value hook with the given arguments. */
language-specific read_var_value for Ada renamings The purpose of this patch is to better support renamings in the "info locals" command. Consider ... procedure Foo is GV : Integer renames Pck.Global_Variable; begin Increment (GV); -- STOP end Foo; ... Pck.Global_Variable is just an integer. After having stopped at the "STOP" line, "info locals" yields: (gdb) info locals gv = <error reading variable gv (Cannot access memory at address 0xffffffffffffffff)> In reality, two things are happening: (1) Variable "GV" does not exist, which is normal, since there is "GV" the renaming of another variable; (2) But to allow the user access to that renaming the same way the code has, the compiler produces an artificial variable whose name encodes the renaming: gv___XR_pck__global_variable___XE For practical reasons, the artificial variable itself is given irrelevant types and addresses. But the "info locals" command does not act as if it was a short-cut of "foreach VAR in locals, print VAR". Instead it gets the value of each VAR directly, which does not work in this case, since the variable is artificial and needs to be decoded first. This patch makes the "read_var_value" routine language-specific. The old implementation of "read_var_value" gets renamed to "default_read_var_value" and all languages now use it (unchanged behavior), except for Ada. In Ada, the new function ada_read_var_value checks if we have a renaming, and if so, evaluates its value, or else defers to default_read_var_value. gdb/ChangeLog: * language.h (struct language_defn): New "method" la_read_var_value. * findvar.c: #include "language.h". (default_read_var_value): Renames read_var_value. Rewrite function description. (read_var_value): New function. * value.h (default_read_var_value): Add prototype. * ada-lang.c (ada_read_renaming_var_value, ada_read_var_value): New functions. (ada_language_defn): Add entry for la_read_var_value. * c-lang.c, d-lang.c, f-lang.c, jv-lang.c, language.c, * m2-lang.c, objc-lang.c, opencl-lang.c, p-lang.c: Update language_defn structures to add entry for new la_read_var_value field.
2012-03-02 20:29:01 +01:00
struct value *
DWARF: handle non-local references in nested functions GDB's current behavior when dealing with non-local references in the context of nested fuctions is approximative: - code using valops.c:value_of_variable read the first available stack frame that holds the corresponding variable (whereas there can be multiple candidates for this); - code directly relying on read_var_value will instead read non-local variables in frames where they are not even defined. This change adds the necessary context to symbol reads (to get the block they belong to) and to blocks (the static link property, if any) so that GDB can make the proper decisions when dealing with non-local varibale references. gdb/ChangeLog: * ada-lang.c (ada_read_var_value): Add a var_block argument and pass it to default_read_var_value. * block.c (block_static_link): New accessor. * block.h (block_static_link): Declare it. * buildsym.c (finish_block_internal): Add a static_link argument. If there is a static link, associate it to the new block. (finish_block): Add a static link argument and pass it to finish_block_internal. (end_symtab_get_static_block): Update calls to finish_block and to finish_block_internal. (end_symtab_with_blockvector): Update call to finish_block_internal. * buildsym.h: Forward-declare struct dynamic_prop. (struct context_stack): Add a static_link field. (finish_block): Add a static link argument. * c-exp.y: Remove an obsolete comment (evaluation of variables already start from the selected frame, and now they climb *up* the call stack) and propagate the block information to the produced expression. * d-exp.y: Likewise. * f-exp.y: Likewise. * go-exp.y: Likewise. * jv-exp.y: Likewise. * m2-exp.y: Likewise. * p-exp.y: Likewise. * coffread.c (coff_symtab_read): Update calls to finish_block. * dbxread.c (process_one_symbol): Likewise. * xcoffread.c (read_xcoff_symtab): Likewise. * compile/compile-c-symbols.c (convert_one_symbol): Promote the "sym" parameter to struct block_symbol, update its uses and pass its block to calls to read_var_value. (convert_symbol_sym): Update the calls to convert_one_symbol. * compile/compile-loc2c.c (do_compile_dwarf_expr_to_c): Update call to read_var_value. * dwarf2loc.c (block_op_get_frame_base): New. (dwarf2_block_frame_base_locexpr_funcs): Implement the get_frame_base method. (dwarf2_block_frame_base_loclist_funcs): Likewise. (dwarf2locexpr_baton_eval): Add a frame argument and use it instead of the selected frame in order to evaluate the expression. (dwarf2_evaluate_property): Add a frame argument. Update call to dwarf2_locexpr_baton_eval to provide a frame in available and to handle the absence of address stack. * dwarf2loc.h (dwarf2_evaluate_property): Add a frame argument. * dwarf2read.c (attr_to_dynamic_prop): Add a forward declaration. (read_func_scope): Record any available static link description. Update call to finish_block. (read_lexical_block_scope): Update call to finish_block. * findvar.c (follow_static_link): New. (get_hosting_frame): New. (default_read_var_value): Add a var_block argument. Use get_hosting_frame to handle non-local references. (read_var_value): Add a var_block argument and pass it to the LA_READ_VAR_VALUE method. * gdbtypes.c (resolve_dynamic_range): Update calls to dwarf2_evaluate_property. (resolve_dynamic_type_internal): Likewise. * guile/scm-frame.c (gdbscm_frame_read_var): Update call to read_var_value, passing it the block coming from symbol lookup. * guile/scm-symbol.c (gdbscm_symbol_value): Update call to read_var_value (TODO). * infcmd.c (finish_command_continuation): Update call to read_var_value, passing it the block coming from symbol lookup. * infrun.c (insert_exception_resume_breakpoint): Likewise. * language.h (struct language_defn): Add a var_block argument to the LA_READ_VAR_VALUE method. * objfiles.c (struct static_link_htab_entry): New. (static_link_htab_entry_hash): New. (static_link_htab_entry_eq): New. (objfile_register_static_link): New. (objfile_lookup_static_link): New. (free_objfile): Free the STATIC_LINKS hashed map if needed. * objfiles.h: Include hashtab.h. (struct objfile): Add a static_links field. (objfile_register_static_link): New. (objfile_lookup_static_link): New. * printcmd.c (print_variable_and_value): Update call to read_var_value. * python/py-finishbreakpoint.c (bpfinishpy_init): Likewise. * python/py-frame.c (frapy_read_var): Update call to read_var_value, passing it the block coming from symbol lookup. * python/py-framefilter.c (extract_sym): Add a sym_block parameter and set the pointed value to NULL (TODO). (enumerate_args): Update call to extract_sym. (enumerate_locals): Update calls to extract_sym and to read_var_value. * python/py-symbol.c (sympy_value): Update call to read_var_value (TODO). * stack.c (read_frame_local): Update call to read_var_value. (read_frame_arg): Likewise. (return_command): Likewise. * symtab.h (struct symbol_block_ops): Add a get_frame_base method. (struct symbol): Add a block field. (SYMBOL_BLOCK): New accessor. * valops.c (value_of_variable): Remove frame/block handling and pass the block argument to read_var_value, which does this job now. (value_struct_elt_for_reference): Update calls to read_var_value. (value_of_this): Pass the block found to read_var_value. * value.h (read_var_value): Add a var_block argument. (default_read_var_value): Likewise. gdb/testsuite/ChangeLog: * gdb.base/nested-subp1.exp: New file. * gdb.base/nested-subp1.c: New file. * gdb.base/nested-subp2.exp: New file. * gdb.base/nested-subp2.c: New file. * gdb.base/nested-subp3.exp: New file. * gdb.base/nested-subp3.c: New file.
2015-02-05 17:00:06 +01:00
read_var_value (struct symbol *var, const struct block *var_block,
struct frame_info *frame)
language-specific read_var_value for Ada renamings The purpose of this patch is to better support renamings in the "info locals" command. Consider ... procedure Foo is GV : Integer renames Pck.Global_Variable; begin Increment (GV); -- STOP end Foo; ... Pck.Global_Variable is just an integer. After having stopped at the "STOP" line, "info locals" yields: (gdb) info locals gv = <error reading variable gv (Cannot access memory at address 0xffffffffffffffff)> In reality, two things are happening: (1) Variable "GV" does not exist, which is normal, since there is "GV" the renaming of another variable; (2) But to allow the user access to that renaming the same way the code has, the compiler produces an artificial variable whose name encodes the renaming: gv___XR_pck__global_variable___XE For practical reasons, the artificial variable itself is given irrelevant types and addresses. But the "info locals" command does not act as if it was a short-cut of "foreach VAR in locals, print VAR". Instead it gets the value of each VAR directly, which does not work in this case, since the variable is artificial and needs to be decoded first. This patch makes the "read_var_value" routine language-specific. The old implementation of "read_var_value" gets renamed to "default_read_var_value" and all languages now use it (unchanged behavior), except for Ada. In Ada, the new function ada_read_var_value checks if we have a renaming, and if so, evaluates its value, or else defers to default_read_var_value. gdb/ChangeLog: * language.h (struct language_defn): New "method" la_read_var_value. * findvar.c: #include "language.h". (default_read_var_value): Renames read_var_value. Rewrite function description. (read_var_value): New function. * value.h (default_read_var_value): Add prototype. * ada-lang.c (ada_read_renaming_var_value, ada_read_var_value): New functions. (ada_language_defn): Add entry for la_read_var_value. * c-lang.c, d-lang.c, f-lang.c, jv-lang.c, language.c, * m2-lang.c, objc-lang.c, opencl-lang.c, p-lang.c: Update language_defn structures to add entry for new la_read_var_value field.
2012-03-02 20:29:01 +01:00
{
Use an accessor function for general_symbol_info::language Also renames the member variable to m_language to make code easier to read when more functions become member functions. I was originally hoping to eventually make m_language private (after a few more patches), but unfortunately then it no longer counts as a POD type, which means gdbsupport/poison.h won't let us use memset to initialize this type, which psymtabs rely on to clear padding bytes so that bcache can work properly. gdb/ChangeLog: 2019-12-15 Christian Biesinger <cbiesinger@google.com> * ada-lang.c (ada_add_block_symbols): Update. (ada_collect_symbol_completion_matches): Update. * ax-gdb.c (gen_expr): Update. * block.c (block_lookup_symbol): Update. (block_lookup_symbol_primary): Update. (block_find_symbol): Update. * cp-namespace.c (cp_lookup_symbol_imports_or_template): Update. * dbxread.c (process_one_symbol): Update. * dictionary.c (insert_symbol_hashed): Update. (collate_pending_symbols_by_language): Update. (mdict_add_symbol): Update. * dwarf-index-write.c (write_psymbols): Update. * dwarf2read.c (fixup_go_packaging): Update. * findvar.c (read_var_value): Update. * ft32-tdep.c (ft32_skip_prologue): Update. * go-lang.c (go_symbol_package_name): Update. * language.h (scoped_switch_to_sym_language_if_auto:: scoped_switch_to_sym_language_if_auto): Update. * linespec.c (find_method): Update. (find_label_symbols_in_block): Update. * mdebugread.c (parse_symbol): Update. * mi/mi-cmd-stack.c (list_arg_or_local): Update. * minsyms.c (add_minsym_to_demangled_hash_table): Update. (minimal_symbol_reader::install): Update. * moxie-tdep.c (moxie_skip_prologue): Update. * parse.c (parse_exp_in_context): Update. * psymtab.c (psymbol_name_matches): Update. (match_partial_symbol): Update. (lookup_partial_symbol): Update. (psymbol_hash): Update. (psymbol_compare): Update. * python/py-framefilter.c (extract_sym): Update. (py_print_single_arg): Update. * stabsread.c (define_symbol): Update. * stack.c (print_frame_arg): Update. (find_frame_funname): Update. (info_frame_command_core): Update. * symfile.c (set_initial_language): Update. * symtab.c (symbol_set_demangled_name): Update. (symbol_get_demangled_name): Update. (symbol_set_language): Update. (symbol_find_demangled_name): Update. (symbol_set_names): Update. (general_symbol_info::natural_name): Update. (general_symbol_info::demangled_name): Update. (general_symbol_info::search_name): Update. (symbol_matches_search_name): Update. (eq_symbol_entry): Update. (iterate_over_symbols): Update. (completion_list_add_symbol): Update. (completion_list_add_msymbol): Update. (completion_list_add_fields): Update. * symtab.h (struct general_symbol_info) <language>: New function. <language>: Rename to... <m_language>: ...this. (SYMBOL_LANGUAGE): Remove. (MSYMBOL_LANGUAGE): Remove. (struct symbol) <ctor>: Update. * xstormy16-tdep.c (xstormy16_skip_prologue): Update. Change-Id: I6464d477457e61639c63ddf8b145e407a35c235a
2019-12-04 00:10:32 +01:00
const struct language_defn *lang = language_def (var->language ());
language-specific read_var_value for Ada renamings The purpose of this patch is to better support renamings in the "info locals" command. Consider ... procedure Foo is GV : Integer renames Pck.Global_Variable; begin Increment (GV); -- STOP end Foo; ... Pck.Global_Variable is just an integer. After having stopped at the "STOP" line, "info locals" yields: (gdb) info locals gv = <error reading variable gv (Cannot access memory at address 0xffffffffffffffff)> In reality, two things are happening: (1) Variable "GV" does not exist, which is normal, since there is "GV" the renaming of another variable; (2) But to allow the user access to that renaming the same way the code has, the compiler produces an artificial variable whose name encodes the renaming: gv___XR_pck__global_variable___XE For practical reasons, the artificial variable itself is given irrelevant types and addresses. But the "info locals" command does not act as if it was a short-cut of "foreach VAR in locals, print VAR". Instead it gets the value of each VAR directly, which does not work in this case, since the variable is artificial and needs to be decoded first. This patch makes the "read_var_value" routine language-specific. The old implementation of "read_var_value" gets renamed to "default_read_var_value" and all languages now use it (unchanged behavior), except for Ada. In Ada, the new function ada_read_var_value checks if we have a renaming, and if so, evaluates its value, or else defers to default_read_var_value. gdb/ChangeLog: * language.h (struct language_defn): New "method" la_read_var_value. * findvar.c: #include "language.h". (default_read_var_value): Renames read_var_value. Rewrite function description. (read_var_value): New function. * value.h (default_read_var_value): Add prototype. * ada-lang.c (ada_read_renaming_var_value, ada_read_var_value): New functions. (ada_language_defn): Add entry for la_read_var_value. * c-lang.c, d-lang.c, f-lang.c, jv-lang.c, language.c, * m2-lang.c, objc-lang.c, opencl-lang.c, p-lang.c: Update language_defn structures to add entry for new la_read_var_value field.
2012-03-02 20:29:01 +01:00
gdb_assert (lang != NULL);
gdb: Convert language la_read_var_value field to a method This commit changes the language_data::la_read_var_value function pointer member variable into a member function of language_defn. An interesting aspect of this change is that the implementation of language_defn::read_var_value is actually in findvar.c. This is partly historical, the new language_defn::read_var_value is a rename of default_read_var_value, which was already in that file, but also, that is the file that contains the helper functions needed by the read_var_value method, so it makes sens that the method implementation should continue to live there (I think). There should be no user visible changes after this commit. gdb/ChangeLog: * ada-lang.c (ada_read_var_value): Delete function, move implementation to... (ada_language::read_var_value): ...here. (ada_language_data): Delete la_read_var_value initializer. * c-lang.c (c_language_data): Likewise. (cplus_language_data): Likewise. (minimal_language_data): Likewise. * d-lang.c (d_language_data): Likewise. * f-lang.c (f_language_data): Likewise. * findvar.c (default_read_var_value): Rename to... (language_defn::read_var_value): ...this. * findvar.c (read_var_value): Update header comment, and change to call member function instead of function pointer. * go-lang.c (go_language_data): Likewise. * language.c (unknown_language_data): Delete la_read_var_value initializer. (auto_language_data): Likewise. * language.h (struct language_data): Delete la_read_var_value field. (language_defn::read_var_value): New member function. (default_read_var_value): Delete declaration. * m2-lang.c (m2_language_data): Delete la_read_var_value initializer. * objc-lang.c (objc_language_data): Likewise. * opencl-lang.c (opencl_language_data): Likewise. * p-lang.c (pascal_language_data): Likewise. * rust-lang.c (rust_language_data): Likewise. * value.h (default_read_var_value): Delete declaration.
2020-05-01 18:33:22 +02:00
return lang->read_var_value (var, var_block, frame);
language-specific read_var_value for Ada renamings The purpose of this patch is to better support renamings in the "info locals" command. Consider ... procedure Foo is GV : Integer renames Pck.Global_Variable; begin Increment (GV); -- STOP end Foo; ... Pck.Global_Variable is just an integer. After having stopped at the "STOP" line, "info locals" yields: (gdb) info locals gv = <error reading variable gv (Cannot access memory at address 0xffffffffffffffff)> In reality, two things are happening: (1) Variable "GV" does not exist, which is normal, since there is "GV" the renaming of another variable; (2) But to allow the user access to that renaming the same way the code has, the compiler produces an artificial variable whose name encodes the renaming: gv___XR_pck__global_variable___XE For practical reasons, the artificial variable itself is given irrelevant types and addresses. But the "info locals" command does not act as if it was a short-cut of "foreach VAR in locals, print VAR". Instead it gets the value of each VAR directly, which does not work in this case, since the variable is artificial and needs to be decoded first. This patch makes the "read_var_value" routine language-specific. The old implementation of "read_var_value" gets renamed to "default_read_var_value" and all languages now use it (unchanged behavior), except for Ada. In Ada, the new function ada_read_var_value checks if we have a renaming, and if so, evaluates its value, or else defers to default_read_var_value. gdb/ChangeLog: * language.h (struct language_defn): New "method" la_read_var_value. * findvar.c: #include "language.h". (default_read_var_value): Renames read_var_value. Rewrite function description. (read_var_value): New function. * value.h (default_read_var_value): Add prototype. * ada-lang.c (ada_read_renaming_var_value, ada_read_var_value): New functions. (ada_language_defn): Add entry for la_read_var_value. * c-lang.c, d-lang.c, f-lang.c, jv-lang.c, language.c, * m2-lang.c, objc-lang.c, opencl-lang.c, p-lang.c: Update language_defn structures to add entry for new la_read_var_value field.
2012-03-02 20:29:01 +01:00
}
/* Install default attributes for register values. */
struct value *
Use address_from_register in dwarf2-frame.c:read_addr_from_reg This patch fixes a problem that prevented use of the Dwarf unwinders on SPU, because dwarf2-frame.c common code did not support the situation where the stack and/or frame pointer is maintained in a *vector* register. This is because read_addr_from_reg is hard-coded to assume that such pointers can be read from registers via a simple get_frame_register / unpack_pointer operation. Now, there *is* a routine address_from_register that calls into the appropriate tdep routines to handle pointer values in "weird" registers like on SPU, but it turns out I cannot simply change dwarf2-frame.c to use address_from_register. This is because address_from_register uses value_from_register to create a (temporary) value, and that routine at some point calls get_frame_id in order to set up that value's VALUE_FRAME_ID entry. However, the dwarf2-frame.c read_addr_from_reg routine will be called during early unwinding (to unwind the frame's CFA), at which point the frame's ID is not actually known yet! This would cause an assert. On the other hand, we may notice that VALUE_FRAME_ID is only needed in the value returned by value_from_register if that value is later used as an lvalue. But this is obviously never done to the temporary value used in address_from_register. So, if we could change address_from_register to not call value_from_register but instead accept constructing a value that doesn't have VALUE_FRAME_ID set, things should be fine. To do that, we can change the value_from_register callback to accept a FRAME_ID instead of a FRAME; the only existing uses of the FRAME argument were either to extract its frame ID, or its gdbarch. (To keep a way of getting at the latter, we also change the callback's type from "f" to "m".) Together with the required follow-on changes in the existing value_from_register implementations (including the default one), this seems to fix the problem. As another minor interface cleanup, I've removed the explicit TYPE argument from address_from_register. This routine really always uses a default pointer type, and in the new implementation it -to some extent- relies on that fact, in that it will now no longer handle types that require gdbarch_convert_register_p handling. gdb: 2014-04-17 Ulrich Weigand  <uweigand@de.ibm.com> * gdbarch.sh (value_from_register): Make class "m" instead of "f". Replace FRAME argument with FRAME_ID. * gdbarch.c, gdbarch.h: Regenerate. * findvar.c (default_value_from_register): Add GDBARCH argument; replace FRAME by FRAME_ID. No longer call get_frame_id. (value_from_register): Update call to gdbarch_value_from_register. * value.h (default_value_from_register): Update prototype. * s390-linux-tdep.c (s390_value_from_register): Update interface and call to default_value_from_register. * spu-tdep.c (spu_value_from_register): Likewise. * findvar.c (address_from_register): Remove TYPE argument. Do not call value_from_register; use gdbarch_value_from_register with null_frame_id instead. * value.h (address_from_register): Update prototype. * dwarf2-frame.c (read_addr_from_reg): Use address_from_register. * dwarf2loc.c (dwarf_expr_read_addr_from_reg): Update for address_from_register interface change.
2014-04-17 14:01:39 +02:00
default_value_from_register (struct gdbarch *gdbarch, struct type *type,
int regnum, struct frame_id frame_id)
{
int len = TYPE_LENGTH (type);
struct value *value = allocate_value (type);
Change meaning of VALUE_FRAME_ID; rename to VALUE_NEXT_FRAME_ID The VALUE_FRAME_ID macro provides access to a member in struct value that's used to hold the frame id that's used when determining a register's value or when assigning to a register. The underlying member has a long and obscure name. I won't refer to it here, but will simply refer to VALUE_FRAME_ID as if it's the struct value member instead of being a convenient macro. At the moment, without this patch in place, VALUE_FRAME_ID is set in value_of_register_lazy() and several other locations to hold the frame id of the frame passed to those functions. VALUE_FRAME_ID is used in the lval_register case of value_fetch_lazy(). To fetch the register's value, it calls get_frame_register_value() which, in turn, calls frame_unwind_register_value() with frame->next. A python based unwinder may wish to determine the value of a register or evaluate an expression containing a register. When it does this, value_fetch_lazy() will be called under some circumstances. It will attempt to determine the frame id associated with the frame passed to it. In so doing, it will end up back in the frame sniffer of the very same python unwinder that's attempting to learn the value of a register as part of the sniffing operation. This recursion is not desirable. As noted above, when value_fetch_lazy() wants to fetch a register's value, it does so (indirectly) by unwinding from frame->next. With this in mind, a solution suggests itself: Change VALUE_FRAME_ID to hold the frame id associated with the next frame. Then, when it comes time to obtain the value associated with the register, we can simply unwind from the frame corresponding to the frame id stored in VALUE_FRAME_ID. This neatly avoids the python unwinder recursion problem by changing when the "next" operation occurs. Instead of the "next" operation occuring when the register value is fetched, it occurs earlier on when assigning a frame id to VALUE_FRAME_ID. (Thanks to Pedro for this suggestion.) This patch implements this idea. It builds on the patch "Distinguish sentinel frame from null frame". Without that work in place, it's necessary to check for null_id at several places and then obtain the sentinel frame. It also renames most occurences of VALUE_FRAME_ID to VALUE_NEXT_FRAME_ID to reflect the new meaning of this field. There are several uses of VALUE_FRAME_ID which were not changed. In each case, the original meaning of VALUE_FRAME_ID is required to get correct results. In all but one of these uses, either put_frame_register_bytes() or get_frame_register_bytes() is being called with the frame value obtained from VALUE_FRAME_ID. Both of these functions perform some unwinding by performing a "->next" operation on the frame passed to it. If we were to use the new VALUE_NEXT_FRAME_ID macro, this would effectively do two "->next" operations, which is not what we want. The VALUE_FRAME_ID macro has been redefined in terms of VALUE_NEXT_FRAME_ID. It simply fetches the previous frame's id, providing this id as the value of the macro. gdb/ChangeLog: * value.h (VALUE_FRAME_ID): Rename to VALUE_NEXT_FRAME_ID. Update comment. Create new VALUE_FRAME_ID which is defined in terms of VALUE_NEXT_FRAME_ID. (deprecated_value_frame_id_hack): Rename to deprecated_value_next_frame_id_hack. * dwarf2loc.c, findvar.c, frame-unwind.c, sentinel-frame.c, valarith.c, valops.c, value.c: Adjust nearly all occurences of VALUE_FRAME_ID to VALUE_NEXT_FRAME_ID. Add comments for those which did not change. * value.c (struct value): Rename frame_id field to next_frame_id. Update comment. (deprecated_value_frame_id_hack): Rename to deprecated_value_next_frame_id_hack. (value_fetch_lazy): Call frame_unwind_register_value() instead of get_frame_register_value(). * frame.c (get_prev_frame_id_by_id): New function. * frame.h (get_prev_frame_id_by_id): Declare. * dwarf2loc.c (dwarf2_evaluate_loc_desc_full): Make VALUE_NEXT_FRAME_ID refer to the next frame. * findvar.c (value_of_register_lazy): Likewise. (default_value_from_register): Likewise. (value_from_register): Likewise. * frame_unwind.c (frame_unwind_got_optimized): Likewise. * sentinel-frame.c (sentinel_frame_prev_register): Likewise. * value.h (VALUE_FRAME_ID): Update comment describing this macro.
2016-09-28 06:18:44 +02:00
struct frame_info *frame;
VALUE_LVAL (value) = lval_register;
Change meaning of VALUE_FRAME_ID; rename to VALUE_NEXT_FRAME_ID The VALUE_FRAME_ID macro provides access to a member in struct value that's used to hold the frame id that's used when determining a register's value or when assigning to a register. The underlying member has a long and obscure name. I won't refer to it here, but will simply refer to VALUE_FRAME_ID as if it's the struct value member instead of being a convenient macro. At the moment, without this patch in place, VALUE_FRAME_ID is set in value_of_register_lazy() and several other locations to hold the frame id of the frame passed to those functions. VALUE_FRAME_ID is used in the lval_register case of value_fetch_lazy(). To fetch the register's value, it calls get_frame_register_value() which, in turn, calls frame_unwind_register_value() with frame->next. A python based unwinder may wish to determine the value of a register or evaluate an expression containing a register. When it does this, value_fetch_lazy() will be called under some circumstances. It will attempt to determine the frame id associated with the frame passed to it. In so doing, it will end up back in the frame sniffer of the very same python unwinder that's attempting to learn the value of a register as part of the sniffing operation. This recursion is not desirable. As noted above, when value_fetch_lazy() wants to fetch a register's value, it does so (indirectly) by unwinding from frame->next. With this in mind, a solution suggests itself: Change VALUE_FRAME_ID to hold the frame id associated with the next frame. Then, when it comes time to obtain the value associated with the register, we can simply unwind from the frame corresponding to the frame id stored in VALUE_FRAME_ID. This neatly avoids the python unwinder recursion problem by changing when the "next" operation occurs. Instead of the "next" operation occuring when the register value is fetched, it occurs earlier on when assigning a frame id to VALUE_FRAME_ID. (Thanks to Pedro for this suggestion.) This patch implements this idea. It builds on the patch "Distinguish sentinel frame from null frame". Without that work in place, it's necessary to check for null_id at several places and then obtain the sentinel frame. It also renames most occurences of VALUE_FRAME_ID to VALUE_NEXT_FRAME_ID to reflect the new meaning of this field. There are several uses of VALUE_FRAME_ID which were not changed. In each case, the original meaning of VALUE_FRAME_ID is required to get correct results. In all but one of these uses, either put_frame_register_bytes() or get_frame_register_bytes() is being called with the frame value obtained from VALUE_FRAME_ID. Both of these functions perform some unwinding by performing a "->next" operation on the frame passed to it. If we were to use the new VALUE_NEXT_FRAME_ID macro, this would effectively do two "->next" operations, which is not what we want. The VALUE_FRAME_ID macro has been redefined in terms of VALUE_NEXT_FRAME_ID. It simply fetches the previous frame's id, providing this id as the value of the macro. gdb/ChangeLog: * value.h (VALUE_FRAME_ID): Rename to VALUE_NEXT_FRAME_ID. Update comment. Create new VALUE_FRAME_ID which is defined in terms of VALUE_NEXT_FRAME_ID. (deprecated_value_frame_id_hack): Rename to deprecated_value_next_frame_id_hack. * dwarf2loc.c, findvar.c, frame-unwind.c, sentinel-frame.c, valarith.c, valops.c, value.c: Adjust nearly all occurences of VALUE_FRAME_ID to VALUE_NEXT_FRAME_ID. Add comments for those which did not change. * value.c (struct value): Rename frame_id field to next_frame_id. Update comment. (deprecated_value_frame_id_hack): Rename to deprecated_value_next_frame_id_hack. (value_fetch_lazy): Call frame_unwind_register_value() instead of get_frame_register_value(). * frame.c (get_prev_frame_id_by_id): New function. * frame.h (get_prev_frame_id_by_id): Declare. * dwarf2loc.c (dwarf2_evaluate_loc_desc_full): Make VALUE_NEXT_FRAME_ID refer to the next frame. * findvar.c (value_of_register_lazy): Likewise. (default_value_from_register): Likewise. (value_from_register): Likewise. * frame_unwind.c (frame_unwind_got_optimized): Likewise. * sentinel-frame.c (sentinel_frame_prev_register): Likewise. * value.h (VALUE_FRAME_ID): Update comment describing this macro.
2016-09-28 06:18:44 +02:00
frame = frame_find_by_id (frame_id);
if (frame == NULL)
frame_id = null_frame_id;
else
frame_id = get_frame_id (get_next_frame_sentinel_okay (frame));
VALUE_NEXT_FRAME_ID (value) = frame_id;
VALUE_REGNUM (value) = regnum;
/* Any structure stored in more than one register will always be
an integral number of registers. Otherwise, you need to do
some fiddling with the last register copied here for little
endian machines. */
Adjust byte order variable display/change if DW_AT_endianity is present. - 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
2017-10-06 22:13:04 +02:00
if (type_byte_order (type) == BFD_ENDIAN_BIG
&& len < register_size (gdbarch, regnum))
/* Big-endian, and we want less than full size. */
set_value_offset (value, register_size (gdbarch, regnum) - len);
else
set_value_offset (value, 0);
return value;
}
/* VALUE must be an lval_register value. If regnum is the value's
associated register number, and len the length of the values type,
read one or more registers in FRAME, starting with register REGNUM,
until we've read LEN bytes.
If any of the registers we try to read are optimized out, then mark the
complete resulting value as optimized out. */
void
read_frame_register_value (struct value *value, struct frame_info *frame)
{
struct gdbarch *gdbarch = get_frame_arch (frame);
LONGEST offset = 0;
LONGEST reg_offset = value_offset (value);
int regnum = VALUE_REGNUM (value);
Consider addressable memory unit size in various value functions This patch updates various value handling functions to make them consider the addressable memory unit size of the current architecture. This allows to correctly extract and print values on architectures whose addressable memory unit is not 8 bits. The patch doesn't cover all the code that would ideally need to be adjusted, only the code paths that we happen to use, plus a few obvious ones. Specifically, those areas are not covered by this patch: - Management of unavailable bits - Bitfields - C++ stuff Regression-tested on x86-64 Ubuntu 14.04. I saw no related test result change. gdb/ChangeLog: * c-valprint.c (c_val_print_array): Consider addressable memory unit size. (c_val_print_ptr): Likewise. (c_val_print_int): Likewise. * findvar.c (read_frame_register_value): Likewise. * valarith.c (find_size_for_pointer_math): Likewise. (value_ptrdiff): Likewise. (value_subscripted_rvalue): Likewise. * valops.c (read_value_memory): Likewise (and rename variables). (value_assign): Likewise. (value_repeat): Likewise. (value_array): Likewise. (value_slice): Likewise. * valprint.c (generic_val_print_ptr): Likewise. (generic_val_print_enum): Likewise. (generic_val_print_bool): Likewise. (generic_val_print_int): Likewise. (generic_val_print_char): Likewise. (generic_val_print_float): Likewise. (generic_val_print_decfloat): Likewise. (generic_val_print_complex): Likewise. (val_print_scalar_formatted): Likewise. (val_print_array_elements): Likewise. * value.c (set_value_parent): Likewise. (value_contents_copy_raw): Likewise. (set_internalvar_component): Likewise. (value_primitive_field): Likewise. (value_fetch_lazy): Likewise. * value.h (read_value_memory): Update comment.
2015-07-28 17:01:50 +02:00
int len = type_length_units (check_typedef (value_type (value)));
gdb_assert (VALUE_LVAL (value) == lval_register);
/* Skip registers wholly inside of REG_OFFSET. */
while (reg_offset >= register_size (gdbarch, regnum))
{
reg_offset -= register_size (gdbarch, regnum);
regnum++;
}
/* Copy the data. */
while (len > 0)
{
struct value *regval = get_frame_register_value (frame, regnum);
Consider addressable memory unit size in various value functions This patch updates various value handling functions to make them consider the addressable memory unit size of the current architecture. This allows to correctly extract and print values on architectures whose addressable memory unit is not 8 bits. The patch doesn't cover all the code that would ideally need to be adjusted, only the code paths that we happen to use, plus a few obvious ones. Specifically, those areas are not covered by this patch: - Management of unavailable bits - Bitfields - C++ stuff Regression-tested on x86-64 Ubuntu 14.04. I saw no related test result change. gdb/ChangeLog: * c-valprint.c (c_val_print_array): Consider addressable memory unit size. (c_val_print_ptr): Likewise. (c_val_print_int): Likewise. * findvar.c (read_frame_register_value): Likewise. * valarith.c (find_size_for_pointer_math): Likewise. (value_ptrdiff): Likewise. (value_subscripted_rvalue): Likewise. * valops.c (read_value_memory): Likewise (and rename variables). (value_assign): Likewise. (value_repeat): Likewise. (value_array): Likewise. (value_slice): Likewise. * valprint.c (generic_val_print_ptr): Likewise. (generic_val_print_enum): Likewise. (generic_val_print_bool): Likewise. (generic_val_print_int): Likewise. (generic_val_print_char): Likewise. (generic_val_print_float): Likewise. (generic_val_print_decfloat): Likewise. (generic_val_print_complex): Likewise. (val_print_scalar_formatted): Likewise. (val_print_array_elements): Likewise. * value.c (set_value_parent): Likewise. (value_contents_copy_raw): Likewise. (set_internalvar_component): Likewise. (value_primitive_field): Likewise. (value_fetch_lazy): Likewise. * value.h (read_value_memory): Update comment.
2015-07-28 17:01:50 +02:00
int reg_len = type_length_units (value_type (regval)) - reg_offset;
/* If the register length is larger than the number of bytes
remaining to copy, then only copy the appropriate bytes. */
if (reg_len > len)
reg_len = len;
value_contents_copy (value, offset, regval, reg_offset, reg_len);
offset += reg_len;
len -= reg_len;
reg_offset = 0;
regnum++;
}
}
/* Return a value of type TYPE, stored in register REGNUM, in frame FRAME. */
2001-11-10 22:34:56 +01:00
struct value *
2000-07-30 03:48:28 +02:00
value_from_register (struct type *type, int regnum, struct frame_info *frame)
{
2003-06-14 Andrew Cagney <cagney@redhat.com> Mark Kettenis <kettenis@gnu.org> * gdbarch.sh (CONVERT_REGISTER_P): Add "type" parameter. (REGISTER_TO_VALUE, VALUE_TO_REGISTER): Replace raw buffer parameter with "frame". * gdbarch.h, gdbarch.c: Re-generate. * frame.h (put_frame_register): Declare. * frame.c (put_frame_register): New function. * arch-utils.c (legacy_convert_register_p): Add "type" parameter. (legacy_register_to_value): Rewrite, use "frame" to get the register value. (legacy_value_to_register): Rewrite, use "frame" to find the register's location before storing. * arch-utils.h (legacy_convert_register_p): Update. (legacy_register_to_value, legacy_value_to_register): Update. * findvar.c (value_from_register): Rewrite, eliminate use of REGISTER_CONVERT_TO_TYPE, pass "type" to CONVERT_REGISTER_P, pass "frame" to REGISTER_TO_VALUE. * valops.c (value_assign): Move the CONVERT_REGISTER code to the lval_reg_frame_relative + lval_register branch of the switch. Do not use REGISTER_CONVERT_FROM_TYPE. Use put_frame_register. * i386-tdep.c (I386_EBX_REGNUM, I386_ECX_REGNUM, I386_ESI_REGNUM, I386_EDI_REGNUM): New defines. (i386_next_regnum, i386_convert_register_p, i386_register_to_value, i386_value_to_register): New functions. (i386_register_convertible, i386_register_convert_to_virtual, i386_convert_to_raw): Remove functions. (i386_gdbarch_init): Set convert_register_p, register_to_value and value_to_register instead of register_convertible, register_convert_to_virtual and register_convert_to_raw. * mips-tdep.c (mips_convert_register_p): New function. (mips_value_to_register): Replace mips_register_convert_from_type. (mips_register_to_value): Replace mips_register_convert_to_type. (mips_gdbarch_init): Set conver_register_p, value_to_register and register_to_value. * alpha-tdep.c (alpha_convert_register_p): Update. (alpha_value_to_register): Update, store the register. (alpha_register_to_value): Update, fetch the register.
2003-06-15 00:35:25 +02:00
struct gdbarch *gdbarch = get_frame_arch (frame);
struct type *type1 = check_typedef (type);
struct value *v;
if (gdbarch_convert_register_p (gdbarch, regnum, type1))
2003-06-14 Andrew Cagney <cagney@redhat.com> Mark Kettenis <kettenis@gnu.org> * gdbarch.sh (CONVERT_REGISTER_P): Add "type" parameter. (REGISTER_TO_VALUE, VALUE_TO_REGISTER): Replace raw buffer parameter with "frame". * gdbarch.h, gdbarch.c: Re-generate. * frame.h (put_frame_register): Declare. * frame.c (put_frame_register): New function. * arch-utils.c (legacy_convert_register_p): Add "type" parameter. (legacy_register_to_value): Rewrite, use "frame" to get the register value. (legacy_value_to_register): Rewrite, use "frame" to find the register's location before storing. * arch-utils.h (legacy_convert_register_p): Update. (legacy_register_to_value, legacy_value_to_register): Update. * findvar.c (value_from_register): Rewrite, eliminate use of REGISTER_CONVERT_TO_TYPE, pass "type" to CONVERT_REGISTER_P, pass "frame" to REGISTER_TO_VALUE. * valops.c (value_assign): Move the CONVERT_REGISTER code to the lval_reg_frame_relative + lval_register branch of the switch. Do not use REGISTER_CONVERT_FROM_TYPE. Use put_frame_register. * i386-tdep.c (I386_EBX_REGNUM, I386_ECX_REGNUM, I386_ESI_REGNUM, I386_EDI_REGNUM): New defines. (i386_next_regnum, i386_convert_register_p, i386_register_to_value, i386_value_to_register): New functions. (i386_register_convertible, i386_register_convert_to_virtual, i386_convert_to_raw): Remove functions. (i386_gdbarch_init): Set convert_register_p, register_to_value and value_to_register instead of register_convertible, register_convert_to_virtual and register_convert_to_raw. * mips-tdep.c (mips_convert_register_p): New function. (mips_value_to_register): Replace mips_register_convert_from_type. (mips_register_to_value): Replace mips_register_convert_to_type. (mips_gdbarch_init): Set conver_register_p, value_to_register and register_to_value. * alpha-tdep.c (alpha_convert_register_p): Update. (alpha_value_to_register): Update, store the register. (alpha_register_to_value): Update, fetch the register.
2003-06-15 00:35:25 +02:00
{
int optim, unavail, ok;
2003-06-14 Andrew Cagney <cagney@redhat.com> Mark Kettenis <kettenis@gnu.org> * gdbarch.sh (CONVERT_REGISTER_P): Add "type" parameter. (REGISTER_TO_VALUE, VALUE_TO_REGISTER): Replace raw buffer parameter with "frame". * gdbarch.h, gdbarch.c: Re-generate. * frame.h (put_frame_register): Declare. * frame.c (put_frame_register): New function. * arch-utils.c (legacy_convert_register_p): Add "type" parameter. (legacy_register_to_value): Rewrite, use "frame" to get the register value. (legacy_value_to_register): Rewrite, use "frame" to find the register's location before storing. * arch-utils.h (legacy_convert_register_p): Update. (legacy_register_to_value, legacy_value_to_register): Update. * findvar.c (value_from_register): Rewrite, eliminate use of REGISTER_CONVERT_TO_TYPE, pass "type" to CONVERT_REGISTER_P, pass "frame" to REGISTER_TO_VALUE. * valops.c (value_assign): Move the CONVERT_REGISTER code to the lval_reg_frame_relative + lval_register branch of the switch. Do not use REGISTER_CONVERT_FROM_TYPE. Use put_frame_register. * i386-tdep.c (I386_EBX_REGNUM, I386_ECX_REGNUM, I386_ESI_REGNUM, I386_EDI_REGNUM): New defines. (i386_next_regnum, i386_convert_register_p, i386_register_to_value, i386_value_to_register): New functions. (i386_register_convertible, i386_register_convert_to_virtual, i386_convert_to_raw): Remove functions. (i386_gdbarch_init): Set convert_register_p, register_to_value and value_to_register instead of register_convertible, register_convert_to_virtual and register_convert_to_raw. * mips-tdep.c (mips_convert_register_p): New function. (mips_value_to_register): Replace mips_register_convert_from_type. (mips_register_to_value): Replace mips_register_convert_to_type. (mips_gdbarch_init): Set conver_register_p, value_to_register and register_to_value. * alpha-tdep.c (alpha_convert_register_p): Update. (alpha_value_to_register): Update, store the register. (alpha_register_to_value): Update, fetch the register.
2003-06-15 00:35:25 +02:00
/* The ISA/ABI need to something weird when obtaining the
specified value from this register. It might need to
re-order non-adjacent, starting with REGNUM (see MIPS and
i386). It might need to convert the [float] register into
the corresponding [integer] type (see Alpha). The assumption
is that gdbarch_register_to_value populates the entire value
2003-06-14 Andrew Cagney <cagney@redhat.com> Mark Kettenis <kettenis@gnu.org> * gdbarch.sh (CONVERT_REGISTER_P): Add "type" parameter. (REGISTER_TO_VALUE, VALUE_TO_REGISTER): Replace raw buffer parameter with "frame". * gdbarch.h, gdbarch.c: Re-generate. * frame.h (put_frame_register): Declare. * frame.c (put_frame_register): New function. * arch-utils.c (legacy_convert_register_p): Add "type" parameter. (legacy_register_to_value): Rewrite, use "frame" to get the register value. (legacy_value_to_register): Rewrite, use "frame" to find the register's location before storing. * arch-utils.h (legacy_convert_register_p): Update. (legacy_register_to_value, legacy_value_to_register): Update. * findvar.c (value_from_register): Rewrite, eliminate use of REGISTER_CONVERT_TO_TYPE, pass "type" to CONVERT_REGISTER_P, pass "frame" to REGISTER_TO_VALUE. * valops.c (value_assign): Move the CONVERT_REGISTER code to the lval_reg_frame_relative + lval_register branch of the switch. Do not use REGISTER_CONVERT_FROM_TYPE. Use put_frame_register. * i386-tdep.c (I386_EBX_REGNUM, I386_ECX_REGNUM, I386_ESI_REGNUM, I386_EDI_REGNUM): New defines. (i386_next_regnum, i386_convert_register_p, i386_register_to_value, i386_value_to_register): New functions. (i386_register_convertible, i386_register_convert_to_virtual, i386_convert_to_raw): Remove functions. (i386_gdbarch_init): Set convert_register_p, register_to_value and value_to_register instead of register_convertible, register_convert_to_virtual and register_convert_to_raw. * mips-tdep.c (mips_convert_register_p): New function. (mips_value_to_register): Replace mips_register_convert_from_type. (mips_register_to_value): Replace mips_register_convert_to_type. (mips_gdbarch_init): Set conver_register_p, value_to_register and register_to_value. * alpha-tdep.c (alpha_convert_register_p): Update. (alpha_value_to_register): Update, store the register. (alpha_register_to_value): Update, fetch the register.
2003-06-15 00:35:25 +02:00
including the location. */
v = allocate_value (type);
VALUE_LVAL (v) = lval_register;
Change meaning of VALUE_FRAME_ID; rename to VALUE_NEXT_FRAME_ID The VALUE_FRAME_ID macro provides access to a member in struct value that's used to hold the frame id that's used when determining a register's value or when assigning to a register. The underlying member has a long and obscure name. I won't refer to it here, but will simply refer to VALUE_FRAME_ID as if it's the struct value member instead of being a convenient macro. At the moment, without this patch in place, VALUE_FRAME_ID is set in value_of_register_lazy() and several other locations to hold the frame id of the frame passed to those functions. VALUE_FRAME_ID is used in the lval_register case of value_fetch_lazy(). To fetch the register's value, it calls get_frame_register_value() which, in turn, calls frame_unwind_register_value() with frame->next. A python based unwinder may wish to determine the value of a register or evaluate an expression containing a register. When it does this, value_fetch_lazy() will be called under some circumstances. It will attempt to determine the frame id associated with the frame passed to it. In so doing, it will end up back in the frame sniffer of the very same python unwinder that's attempting to learn the value of a register as part of the sniffing operation. This recursion is not desirable. As noted above, when value_fetch_lazy() wants to fetch a register's value, it does so (indirectly) by unwinding from frame->next. With this in mind, a solution suggests itself: Change VALUE_FRAME_ID to hold the frame id associated with the next frame. Then, when it comes time to obtain the value associated with the register, we can simply unwind from the frame corresponding to the frame id stored in VALUE_FRAME_ID. This neatly avoids the python unwinder recursion problem by changing when the "next" operation occurs. Instead of the "next" operation occuring when the register value is fetched, it occurs earlier on when assigning a frame id to VALUE_FRAME_ID. (Thanks to Pedro for this suggestion.) This patch implements this idea. It builds on the patch "Distinguish sentinel frame from null frame". Without that work in place, it's necessary to check for null_id at several places and then obtain the sentinel frame. It also renames most occurences of VALUE_FRAME_ID to VALUE_NEXT_FRAME_ID to reflect the new meaning of this field. There are several uses of VALUE_FRAME_ID which were not changed. In each case, the original meaning of VALUE_FRAME_ID is required to get correct results. In all but one of these uses, either put_frame_register_bytes() or get_frame_register_bytes() is being called with the frame value obtained from VALUE_FRAME_ID. Both of these functions perform some unwinding by performing a "->next" operation on the frame passed to it. If we were to use the new VALUE_NEXT_FRAME_ID macro, this would effectively do two "->next" operations, which is not what we want. The VALUE_FRAME_ID macro has been redefined in terms of VALUE_NEXT_FRAME_ID. It simply fetches the previous frame's id, providing this id as the value of the macro. gdb/ChangeLog: * value.h (VALUE_FRAME_ID): Rename to VALUE_NEXT_FRAME_ID. Update comment. Create new VALUE_FRAME_ID which is defined in terms of VALUE_NEXT_FRAME_ID. (deprecated_value_frame_id_hack): Rename to deprecated_value_next_frame_id_hack. * dwarf2loc.c, findvar.c, frame-unwind.c, sentinel-frame.c, valarith.c, valops.c, value.c: Adjust nearly all occurences of VALUE_FRAME_ID to VALUE_NEXT_FRAME_ID. Add comments for those which did not change. * value.c (struct value): Rename frame_id field to next_frame_id. Update comment. (deprecated_value_frame_id_hack): Rename to deprecated_value_next_frame_id_hack. (value_fetch_lazy): Call frame_unwind_register_value() instead of get_frame_register_value(). * frame.c (get_prev_frame_id_by_id): New function. * frame.h (get_prev_frame_id_by_id): Declare. * dwarf2loc.c (dwarf2_evaluate_loc_desc_full): Make VALUE_NEXT_FRAME_ID refer to the next frame. * findvar.c (value_of_register_lazy): Likewise. (default_value_from_register): Likewise. (value_from_register): Likewise. * frame_unwind.c (frame_unwind_got_optimized): Likewise. * sentinel-frame.c (sentinel_frame_prev_register): Likewise. * value.h (VALUE_FRAME_ID): Update comment describing this macro.
2016-09-28 06:18:44 +02:00
VALUE_NEXT_FRAME_ID (v) = get_frame_id (get_next_frame_sentinel_okay (frame));
VALUE_REGNUM (v) = regnum;
gdb/ * dwarf2loc.c (read_pieced_value): Handle get_frame_register_bytes returning that the register piece is unavailable/optimized out. (write_pieced_value): Handle get_frame_register_bytes returning that the register piece is unavailable/optimized out when doing a read-modify write of a bitfield. * findvar.c (value_from_register): Handle get_frame_register_bytes returning that the register piece is unavailable/optimized out. * frame.c (get_frame_register_bytes): New parameters `optimizedp' and `unavailablep'. Throw error on bad debug info. Use frame_register instead of frame_register_read, to fill in the new arguments. * frame.h (get_frame_register_bytes): New parameters `optimizedp' and `unavailablep'. * valops.c: (value_assign): Adjust, and handle get_frame_register_bytes failing. * spu-tdep.c: Include exceptions.h. (spu_software_single_step): Adjust, and handle get_frame_register_bytes failing. (spu_get_longjmp_target): Ditto. * gdbarch.sh (register_to_value): Change to return int. New parameters `optimizedp' and `unavailablep'. * gdbarch.h, gdbarch.c: Regenerate. * i386-tdep.c (i386_register_to_value): Adjust to new gdbarch_register_to_value interface. * i387-tdep.c (i387_register_to_value): Ditto. * i387-tdep.h (i387_register_to_value): Ditto. * alpha-tdep.c (alpha_register_to_value): Ditto. * ia64-tdep.c (ia64_register_to_value): Ditto. * m68k-tdep.c (m68k_register_to_value): Ditto. * mips-tdep.c (mips_register_to_value): Ditto. * rs6000-tdep.c (rs6000_register_to_value): Ditto.
2011-03-18 19:42:41 +01:00
ok = gdbarch_register_to_value (gdbarch, frame, regnum, type1,
value_contents_raw (v), &optim,
&unavail);
if (!ok)
{
if (optim)
Handle partially optimized out values similarly to unavailable values This fixes PR symtab/14604, PR symtab/14605, and Jan's test at https://sourceware.org/ml/gdb-patches/2014-07/msg00158.html, in a tree with bddbbed reverted: 2014-07-22 Pedro Alves <palves@redhat.com> * value.c (allocate_optimized_out_value): Don't mark value as non-lazy. The PRs are about variables described by the DWARF as being split over multiple registers using DWARF piece information, but some of those registers being marked as optimised out (not saved) by a later frame. GDB currently incorrectly mishandles these partially-optimized-out values. Even though we can usually tell from the debug info whether a local or global is optimized out, handling the case of a local living in a register that was not saved in a frame requires fetching the variable. GDB also needs to fetch a value to tell whether parts of it are "<unavailable>". Given this, it's not worth it to try to avoid fetching lazy optimized-out values based on debug info alone. So this patch makes GDB track which chunks of a value's contents are optimized out like it tracks <unavailable> contents. That is, it makes value->optimized_out be a bit range vector instead of a boolean, and removes the struct lval_funcs check_validity and check_any_valid hooks. Unlike Andrew's series which this is based on (at https://sourceware.org/ml/gdb-patches/2013-08/msg00300.html, note some pieces have gone in since), this doesn't merge optimized out and unavailable contents validity/availability behind a single interface, nor does it merge the bit range vectors themselves (at least yet). While it may be desirable to have a single entry point that returns existence of contents irrespective of what may make them invalid/unavailable, several places want to treat optimized out / unavailable / etc. differently, so each spot that potentially could use it will need to be careful considered on case-by-case basis, and best done as a separate change. This fixes Jan's test, because value_available_contents_eq wasn't considering optimized out value contents. It does now, and because of that it's been renamed to value_contents_eq. A new intro comment is added to value.h describing "<optimized out>", "<not saved>" and "<unavailable>" values. gdb/ PR symtab/14604 PR symtab/14605 * ada-lang.c (coerce_unspec_val_to_type): Use value_contents_copy_raw. * ada-valprint.c (val_print_packed_array_elements): Adjust. * c-valprint.c (c_val_print): Use value_bits_any_optimized_out. * cp-valprint.c (cp_print_value_fields): Let the common printing code handle optimized out values. (cp_print_value_fields_rtti): Use value_bits_any_optimized_out. * d-valprint.c (dynamic_array_type): Use value_bits_any_optimized_out. * dwarf2loc.c (entry_data_value_funcs): Remove check_validity and check_any_valid fields. (check_pieced_value_bits): Delete and inline ... (check_pieced_synthetic_pointer): ... here. (check_pieced_value_validity): Delete. (check_pieced_value_invalid): Delete. (pieced_value_funcs): Remove check_validity and check_any_valid fields. (read_pieced_value): Use mark_value_bits_optimized_out. (write_pieced_value): Switch to use mark_value_bytes_optimized_out. (dwarf2_evaluate_loc_desc_full): Copy the value contents instead of assuming the whole value is optimized out. * findvar.c (read_frame_register_value): Remove special handling of optimized out registers. (value_from_register): Use mark_value_bytes_optimized_out. * frame-unwind.c (frame_unwind_got_optimized): Use mark_value_bytes_optimized_out. * jv-valprint.c (java_value_print): Adjust. (java_print_value_fields): Let the common printing code handle optimized out values. * mips-tdep.c (mips_print_register): Remove special handling of optimized out registers. * opencl-lang.c (lval_func_check_validity): Delete. (lval_func_check_any_valid): Delete. (opencl_value_funcs): Remove check_validity and check_any_valid fields. * p-valprint.c (pascal_object_print_value_fields): Let the common printing code handle optimized out values. * stack.c (read_frame_arg): Remove special handling of optimized out values. Fetch both VAL and ENTRYVAL before comparing contents. Adjust to value_available_contents_eq rename. * valprint.c (valprint_check_validity) (val_print_scalar_formatted): Use value_bits_any_optimized_out. (val_print_array_elements): Adjust. * value.c (struct value) <optimized_out>: Now a VEC(range_s). (value_bits_any_optimized_out): New function. (value_entirely_covered_by_range_vector): New function, factored out from value_entirely_unavailable. (value_entirely_unavailable): Reimplement. (value_entirely_optimized_out): New function. (insert_into_bit_range_vector): New function, factored out from mark_value_bits_unavailable. (mark_value_bits_unavailable): Reimplement. (struct ranges_and_idx): New struct. (find_first_range_overlap_and_match): New function, factored out from value_available_contents_bits_eq. (value_available_contents_bits_eq): Rename to ... (value_contents_bits_eq): ... this. Check both unavailable contents and optimized out contents. (value_available_contents_eq): Rename to ... (value_contents_eq): ... this. (allocate_value_lazy): Remove reference to the old optimized_out boolean. (allocate_optimized_out_value): Use mark_value_bytes_optimized_out. (require_not_optimized_out): Adjust to check whether the optimized_out vec is empty. (ranges_copy_adjusted): New function, factored out from value_contents_copy_raw. (value_contents_copy_raw): Also copy the optimized out ranges. Assert the destination ranges aren't optimized out. (value_contents_copy): Update comment, remove call to require_not_optimized_out. (value_contents_equal): Adjust to check whether the optimized_out vec is empty. (set_value_optimized_out, value_optimized_out_const): Delete. (mark_value_bytes_optimized_out, mark_value_bits_optimized_out): New functions. (value_entirely_optimized_out, value_bits_valid): Delete. (value_copy): Take a VEC copy of the 'optimized_out' field. (value_primitive_field): Remove special handling of optimized out. (value_fetch_lazy): Assert that lazy values have no unavailable regions. Use value_bits_any_optimized_out. Remove some special handling for optimized out values. * value.h: Add intro comment about <optimized out> and <unavailable>. (struct lval_funcs): Remove check_validity and check_any_valid fields. (set_value_optimized_out, value_optimized_out_const): Remove. (mark_value_bytes_optimized_out, mark_value_bits_optimized_out): New declarations. (value_bits_any_optimized_out): New declaration. (value_bits_valid): Delete declaration. (value_available_contents_eq): Rename to ... (value_contents_eq): ... this, and extend comments. gdb/testsuite/ PR symtab/14604 PR symtab/14605 * gdb.dwarf2/dw2-op-out-param.exp: Remove kfail branches and use gdb_test.
2014-08-20 01:07:40 +02:00
mark_value_bytes_optimized_out (v, 0, TYPE_LENGTH (type));
if (unavail)
mark_value_bytes_unavailable (v, 0, TYPE_LENGTH (type));
}
2003-06-14 Andrew Cagney <cagney@redhat.com> Mark Kettenis <kettenis@gnu.org> * gdbarch.sh (CONVERT_REGISTER_P): Add "type" parameter. (REGISTER_TO_VALUE, VALUE_TO_REGISTER): Replace raw buffer parameter with "frame". * gdbarch.h, gdbarch.c: Re-generate. * frame.h (put_frame_register): Declare. * frame.c (put_frame_register): New function. * arch-utils.c (legacy_convert_register_p): Add "type" parameter. (legacy_register_to_value): Rewrite, use "frame" to get the register value. (legacy_value_to_register): Rewrite, use "frame" to find the register's location before storing. * arch-utils.h (legacy_convert_register_p): Update. (legacy_register_to_value, legacy_value_to_register): Update. * findvar.c (value_from_register): Rewrite, eliminate use of REGISTER_CONVERT_TO_TYPE, pass "type" to CONVERT_REGISTER_P, pass "frame" to REGISTER_TO_VALUE. * valops.c (value_assign): Move the CONVERT_REGISTER code to the lval_reg_frame_relative + lval_register branch of the switch. Do not use REGISTER_CONVERT_FROM_TYPE. Use put_frame_register. * i386-tdep.c (I386_EBX_REGNUM, I386_ECX_REGNUM, I386_ESI_REGNUM, I386_EDI_REGNUM): New defines. (i386_next_regnum, i386_convert_register_p, i386_register_to_value, i386_value_to_register): New functions. (i386_register_convertible, i386_register_convert_to_virtual, i386_convert_to_raw): Remove functions. (i386_gdbarch_init): Set convert_register_p, register_to_value and value_to_register instead of register_convertible, register_convert_to_virtual and register_convert_to_raw. * mips-tdep.c (mips_convert_register_p): New function. (mips_value_to_register): Replace mips_register_convert_from_type. (mips_register_to_value): Replace mips_register_convert_to_type. (mips_gdbarch_init): Set conver_register_p, value_to_register and register_to_value. * alpha-tdep.c (alpha_convert_register_p): Update. (alpha_value_to_register): Update, store the register. (alpha_register_to_value): Update, fetch the register.
2003-06-15 00:35:25 +02:00
}
else
{
/* Construct the value. */
Use address_from_register in dwarf2-frame.c:read_addr_from_reg This patch fixes a problem that prevented use of the Dwarf unwinders on SPU, because dwarf2-frame.c common code did not support the situation where the stack and/or frame pointer is maintained in a *vector* register. This is because read_addr_from_reg is hard-coded to assume that such pointers can be read from registers via a simple get_frame_register / unpack_pointer operation. Now, there *is* a routine address_from_register that calls into the appropriate tdep routines to handle pointer values in "weird" registers like on SPU, but it turns out I cannot simply change dwarf2-frame.c to use address_from_register. This is because address_from_register uses value_from_register to create a (temporary) value, and that routine at some point calls get_frame_id in order to set up that value's VALUE_FRAME_ID entry. However, the dwarf2-frame.c read_addr_from_reg routine will be called during early unwinding (to unwind the frame's CFA), at which point the frame's ID is not actually known yet! This would cause an assert. On the other hand, we may notice that VALUE_FRAME_ID is only needed in the value returned by value_from_register if that value is later used as an lvalue. But this is obviously never done to the temporary value used in address_from_register. So, if we could change address_from_register to not call value_from_register but instead accept constructing a value that doesn't have VALUE_FRAME_ID set, things should be fine. To do that, we can change the value_from_register callback to accept a FRAME_ID instead of a FRAME; the only existing uses of the FRAME argument were either to extract its frame ID, or its gdbarch. (To keep a way of getting at the latter, we also change the callback's type from "f" to "m".) Together with the required follow-on changes in the existing value_from_register implementations (including the default one), this seems to fix the problem. As another minor interface cleanup, I've removed the explicit TYPE argument from address_from_register. This routine really always uses a default pointer type, and in the new implementation it -to some extent- relies on that fact, in that it will now no longer handle types that require gdbarch_convert_register_p handling. gdb: 2014-04-17 Ulrich Weigand  <uweigand@de.ibm.com> * gdbarch.sh (value_from_register): Make class "m" instead of "f". Replace FRAME argument with FRAME_ID. * gdbarch.c, gdbarch.h: Regenerate. * findvar.c (default_value_from_register): Add GDBARCH argument; replace FRAME by FRAME_ID. No longer call get_frame_id. (value_from_register): Update call to gdbarch_value_from_register. * value.h (default_value_from_register): Update prototype. * s390-linux-tdep.c (s390_value_from_register): Update interface and call to default_value_from_register. * spu-tdep.c (spu_value_from_register): Likewise. * findvar.c (address_from_register): Remove TYPE argument. Do not call value_from_register; use gdbarch_value_from_register with null_frame_id instead. * value.h (address_from_register): Update prototype. * dwarf2-frame.c (read_addr_from_reg): Use address_from_register. * dwarf2loc.c (dwarf_expr_read_addr_from_reg): Update for address_from_register interface change.
2014-04-17 14:01:39 +02:00
v = gdbarch_value_from_register (gdbarch, type,
regnum, get_frame_id (frame));
/* Get the data. */
read_frame_register_value (v, frame);
}
gdb/ * dwarf2loc.c (read_pieced_value): Handle get_frame_register_bytes returning that the register piece is unavailable/optimized out. (write_pieced_value): Handle get_frame_register_bytes returning that the register piece is unavailable/optimized out when doing a read-modify write of a bitfield. * findvar.c (value_from_register): Handle get_frame_register_bytes returning that the register piece is unavailable/optimized out. * frame.c (get_frame_register_bytes): New parameters `optimizedp' and `unavailablep'. Throw error on bad debug info. Use frame_register instead of frame_register_read, to fill in the new arguments. * frame.h (get_frame_register_bytes): New parameters `optimizedp' and `unavailablep'. * valops.c: (value_assign): Adjust, and handle get_frame_register_bytes failing. * spu-tdep.c: Include exceptions.h. (spu_software_single_step): Adjust, and handle get_frame_register_bytes failing. (spu_get_longjmp_target): Ditto. * gdbarch.sh (register_to_value): Change to return int. New parameters `optimizedp' and `unavailablep'. * gdbarch.h, gdbarch.c: Regenerate. * i386-tdep.c (i386_register_to_value): Adjust to new gdbarch_register_to_value interface. * i387-tdep.c (i387_register_to_value): Ditto. * i387-tdep.h (i387_register_to_value): Ditto. * alpha-tdep.c (alpha_register_to_value): Ditto. * ia64-tdep.c (ia64_register_to_value): Ditto. * m68k-tdep.c (m68k_register_to_value): Ditto. * mips-tdep.c (mips_register_to_value): Ditto. * rs6000-tdep.c (rs6000_register_to_value): Ditto.
2011-03-18 19:42:41 +01:00
return v;
}
2003-06-14 Andrew Cagney <cagney@redhat.com> Mark Kettenis <kettenis@gnu.org> * gdbarch.sh (CONVERT_REGISTER_P): Add "type" parameter. (REGISTER_TO_VALUE, VALUE_TO_REGISTER): Replace raw buffer parameter with "frame". * gdbarch.h, gdbarch.c: Re-generate. * frame.h (put_frame_register): Declare. * frame.c (put_frame_register): New function. * arch-utils.c (legacy_convert_register_p): Add "type" parameter. (legacy_register_to_value): Rewrite, use "frame" to get the register value. (legacy_value_to_register): Rewrite, use "frame" to find the register's location before storing. * arch-utils.h (legacy_convert_register_p): Update. (legacy_register_to_value, legacy_value_to_register): Update. * findvar.c (value_from_register): Rewrite, eliminate use of REGISTER_CONVERT_TO_TYPE, pass "type" to CONVERT_REGISTER_P, pass "frame" to REGISTER_TO_VALUE. * valops.c (value_assign): Move the CONVERT_REGISTER code to the lval_reg_frame_relative + lval_register branch of the switch. Do not use REGISTER_CONVERT_FROM_TYPE. Use put_frame_register. * i386-tdep.c (I386_EBX_REGNUM, I386_ECX_REGNUM, I386_ESI_REGNUM, I386_EDI_REGNUM): New defines. (i386_next_regnum, i386_convert_register_p, i386_register_to_value, i386_value_to_register): New functions. (i386_register_convertible, i386_register_convert_to_virtual, i386_convert_to_raw): Remove functions. (i386_gdbarch_init): Set convert_register_p, register_to_value and value_to_register instead of register_convertible, register_convert_to_virtual and register_convert_to_raw. * mips-tdep.c (mips_convert_register_p): New function. (mips_value_to_register): Replace mips_register_convert_from_type. (mips_register_to_value): Replace mips_register_convert_to_type. (mips_gdbarch_init): Set conver_register_p, value_to_register and register_to_value. * alpha-tdep.c (alpha_convert_register_p): Update. (alpha_value_to_register): Update, store the register. (alpha_register_to_value): Update, fetch the register.
2003-06-15 00:35:25 +02:00
Use address_from_register in dwarf2-frame.c:read_addr_from_reg This patch fixes a problem that prevented use of the Dwarf unwinders on SPU, because dwarf2-frame.c common code did not support the situation where the stack and/or frame pointer is maintained in a *vector* register. This is because read_addr_from_reg is hard-coded to assume that such pointers can be read from registers via a simple get_frame_register / unpack_pointer operation. Now, there *is* a routine address_from_register that calls into the appropriate tdep routines to handle pointer values in "weird" registers like on SPU, but it turns out I cannot simply change dwarf2-frame.c to use address_from_register. This is because address_from_register uses value_from_register to create a (temporary) value, and that routine at some point calls get_frame_id in order to set up that value's VALUE_FRAME_ID entry. However, the dwarf2-frame.c read_addr_from_reg routine will be called during early unwinding (to unwind the frame's CFA), at which point the frame's ID is not actually known yet! This would cause an assert. On the other hand, we may notice that VALUE_FRAME_ID is only needed in the value returned by value_from_register if that value is later used as an lvalue. But this is obviously never done to the temporary value used in address_from_register. So, if we could change address_from_register to not call value_from_register but instead accept constructing a value that doesn't have VALUE_FRAME_ID set, things should be fine. To do that, we can change the value_from_register callback to accept a FRAME_ID instead of a FRAME; the only existing uses of the FRAME argument were either to extract its frame ID, or its gdbarch. (To keep a way of getting at the latter, we also change the callback's type from "f" to "m".) Together with the required follow-on changes in the existing value_from_register implementations (including the default one), this seems to fix the problem. As another minor interface cleanup, I've removed the explicit TYPE argument from address_from_register. This routine really always uses a default pointer type, and in the new implementation it -to some extent- relies on that fact, in that it will now no longer handle types that require gdbarch_convert_register_p handling. gdb: 2014-04-17 Ulrich Weigand  <uweigand@de.ibm.com> * gdbarch.sh (value_from_register): Make class "m" instead of "f". Replace FRAME argument with FRAME_ID. * gdbarch.c, gdbarch.h: Regenerate. * findvar.c (default_value_from_register): Add GDBARCH argument; replace FRAME by FRAME_ID. No longer call get_frame_id. (value_from_register): Update call to gdbarch_value_from_register. * value.h (default_value_from_register): Update prototype. * s390-linux-tdep.c (s390_value_from_register): Update interface and call to default_value_from_register. * spu-tdep.c (spu_value_from_register): Likewise. * findvar.c (address_from_register): Remove TYPE argument. Do not call value_from_register; use gdbarch_value_from_register with null_frame_id instead. * value.h (address_from_register): Update prototype. * dwarf2-frame.c (read_addr_from_reg): Use address_from_register. * dwarf2loc.c (dwarf_expr_read_addr_from_reg): Update for address_from_register interface change.
2014-04-17 14:01:39 +02:00
/* Return contents of register REGNUM in frame FRAME as address.
Will abort if register value is not available. */
CORE_ADDR
Use address_from_register in dwarf2-frame.c:read_addr_from_reg This patch fixes a problem that prevented use of the Dwarf unwinders on SPU, because dwarf2-frame.c common code did not support the situation where the stack and/or frame pointer is maintained in a *vector* register. This is because read_addr_from_reg is hard-coded to assume that such pointers can be read from registers via a simple get_frame_register / unpack_pointer operation. Now, there *is* a routine address_from_register that calls into the appropriate tdep routines to handle pointer values in "weird" registers like on SPU, but it turns out I cannot simply change dwarf2-frame.c to use address_from_register. This is because address_from_register uses value_from_register to create a (temporary) value, and that routine at some point calls get_frame_id in order to set up that value's VALUE_FRAME_ID entry. However, the dwarf2-frame.c read_addr_from_reg routine will be called during early unwinding (to unwind the frame's CFA), at which point the frame's ID is not actually known yet! This would cause an assert. On the other hand, we may notice that VALUE_FRAME_ID is only needed in the value returned by value_from_register if that value is later used as an lvalue. But this is obviously never done to the temporary value used in address_from_register. So, if we could change address_from_register to not call value_from_register but instead accept constructing a value that doesn't have VALUE_FRAME_ID set, things should be fine. To do that, we can change the value_from_register callback to accept a FRAME_ID instead of a FRAME; the only existing uses of the FRAME argument were either to extract its frame ID, or its gdbarch. (To keep a way of getting at the latter, we also change the callback's type from "f" to "m".) Together with the required follow-on changes in the existing value_from_register implementations (including the default one), this seems to fix the problem. As another minor interface cleanup, I've removed the explicit TYPE argument from address_from_register. This routine really always uses a default pointer type, and in the new implementation it -to some extent- relies on that fact, in that it will now no longer handle types that require gdbarch_convert_register_p handling. gdb: 2014-04-17 Ulrich Weigand  <uweigand@de.ibm.com> * gdbarch.sh (value_from_register): Make class "m" instead of "f". Replace FRAME argument with FRAME_ID. * gdbarch.c, gdbarch.h: Regenerate. * findvar.c (default_value_from_register): Add GDBARCH argument; replace FRAME by FRAME_ID. No longer call get_frame_id. (value_from_register): Update call to gdbarch_value_from_register. * value.h (default_value_from_register): Update prototype. * s390-linux-tdep.c (s390_value_from_register): Update interface and call to default_value_from_register. * spu-tdep.c (spu_value_from_register): Likewise. * findvar.c (address_from_register): Remove TYPE argument. Do not call value_from_register; use gdbarch_value_from_register with null_frame_id instead. * value.h (address_from_register): Update prototype. * dwarf2-frame.c (read_addr_from_reg): Use address_from_register. * dwarf2loc.c (dwarf_expr_read_addr_from_reg): Update for address_from_register interface change.
2014-04-17 14:01:39 +02:00
address_from_register (int regnum, struct frame_info *frame)
{
Use address_from_register in dwarf2-frame.c:read_addr_from_reg This patch fixes a problem that prevented use of the Dwarf unwinders on SPU, because dwarf2-frame.c common code did not support the situation where the stack and/or frame pointer is maintained in a *vector* register. This is because read_addr_from_reg is hard-coded to assume that such pointers can be read from registers via a simple get_frame_register / unpack_pointer operation. Now, there *is* a routine address_from_register that calls into the appropriate tdep routines to handle pointer values in "weird" registers like on SPU, but it turns out I cannot simply change dwarf2-frame.c to use address_from_register. This is because address_from_register uses value_from_register to create a (temporary) value, and that routine at some point calls get_frame_id in order to set up that value's VALUE_FRAME_ID entry. However, the dwarf2-frame.c read_addr_from_reg routine will be called during early unwinding (to unwind the frame's CFA), at which point the frame's ID is not actually known yet! This would cause an assert. On the other hand, we may notice that VALUE_FRAME_ID is only needed in the value returned by value_from_register if that value is later used as an lvalue. But this is obviously never done to the temporary value used in address_from_register. So, if we could change address_from_register to not call value_from_register but instead accept constructing a value that doesn't have VALUE_FRAME_ID set, things should be fine. To do that, we can change the value_from_register callback to accept a FRAME_ID instead of a FRAME; the only existing uses of the FRAME argument were either to extract its frame ID, or its gdbarch. (To keep a way of getting at the latter, we also change the callback's type from "f" to "m".) Together with the required follow-on changes in the existing value_from_register implementations (including the default one), this seems to fix the problem. As another minor interface cleanup, I've removed the explicit TYPE argument from address_from_register. This routine really always uses a default pointer type, and in the new implementation it -to some extent- relies on that fact, in that it will now no longer handle types that require gdbarch_convert_register_p handling. gdb: 2014-04-17 Ulrich Weigand  <uweigand@de.ibm.com> * gdbarch.sh (value_from_register): Make class "m" instead of "f". Replace FRAME argument with FRAME_ID. * gdbarch.c, gdbarch.h: Regenerate. * findvar.c (default_value_from_register): Add GDBARCH argument; replace FRAME by FRAME_ID. No longer call get_frame_id. (value_from_register): Update call to gdbarch_value_from_register. * value.h (default_value_from_register): Update prototype. * s390-linux-tdep.c (s390_value_from_register): Update interface and call to default_value_from_register. * spu-tdep.c (spu_value_from_register): Likewise. * findvar.c (address_from_register): Remove TYPE argument. Do not call value_from_register; use gdbarch_value_from_register with null_frame_id instead. * value.h (address_from_register): Update prototype. * dwarf2-frame.c (read_addr_from_reg): Use address_from_register. * dwarf2loc.c (dwarf_expr_read_addr_from_reg): Update for address_from_register interface change.
2014-04-17 14:01:39 +02:00
struct gdbarch *gdbarch = get_frame_arch (frame);
struct type *type = builtin_type (gdbarch)->builtin_data_ptr;
struct value *value;
CORE_ADDR result;
Introduce gdbarch_num_cooked_regs The expression gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch) is used quite often to find the number of cooked registers (raw + pseudo registers). This patch introduces gdbarch_num_cooked_regs, which does the equivalent. It substantially reduces required wrapping in some places, so should improve readability. There is a for loop in m68hc11_frame_unwind_cache that had iterated until (the equivalent of) gdbarch_num_cooked_regs (gdbarch) - 1. During review, we concluded that this is most likely an off-by-one mistake, so I replaced it with gdbarch_num_cooked_regs (gdbarch). gdb/ChangeLog: * gdbarch.sh (gdbarch_num_cooked_regs): New. * gdbarch.h: Re-generate. * ax-gdb.c (gen_expr): Use gdbarch_num_cooked_regs. * dwarf2-frame.c (dwarf2_frame_cache): Likewise. * eval.c (evaluate_subexp_standard): Likewise. * findvar.c (value_of_register): Likewise. (value_of_register_lazy): Likewise. (address_from_register): Likewise. * frame.c (get_frame_register_bytes): Likewise. * gdbarch-selftests.c (register_to_value_test): Likewise. * h8300-tdep.c (h8300_register_type): Likewise. * i386-tdep.c (i386_dbx_reg_to_regnum): Likewise. (i386_svr4_reg_to_regnum): Likewise. * infcmd.c (default_print_registers_info): Likewise. (registers_info): Likewise. (print_vector_info): Likewise. (default_print_float_info): Likewise. * m68hc11-tdep.c (m68hc11_frame_unwind_cache): Likewise. * mdebugread.c (mdebug_reg_to_regnum): Likewise. * mi/mi-main.c (mi_cmd_data_list_register_names): Likewise. (mi_cmd_data_list_changed_registers): Likewise. (mi_cmd_data_list_register_values): Likewise. (mi_cmd_data_write_register_values): Likewise. (mi_cmd_trace_frame_collected): Likewise. * mips-tdep.c (print_gp_register_row): Likewise. (mips_print_registers_info): Likewise. * nds32-tdep.c (nds32_gdbarch_init): Likewise. * regcache.c (init_regcache_descr): Likewise. (register_size): Likewise. (register_dump::dump): Likewise. (cooked_read_test): Likewise. (cooked_write_test): Likewise. * rs6000-tdep.c (rs6000_register_sim_regno): Likewise. (rs6000_gdbarch_init): Likewise. * stabsread.c (stab_reg_to_regnum): Likewise. * stack.c (info_frame_command): Likewise. * target-descriptions.c (tdesc_register_name): Likewise. * trad-frame.c (trad_frame_alloc_saved_regs): Likewise. * tui/tui-regs.c (tui_show_register_group): Likewise. * user-regs.c (user_reg_map_name_to_regnum): Likewise. (user_reg_map_regnum_to_name): Likewise. (value_of_user_reg): Likewise. (maintenance_print_user_registers): Likewise. * xtensa-tdep.c (xtensa_find_register_by_name): Likewise. (xtensa_register_name): Likewise. (xtensa_register_type): Likewise. (xtensa_reg_to_regnum): Likewise. (xtensa_pseudo_register_read): Likewise. (xtensa_pseudo_register_write): Likewise.
2018-10-22 04:29:21 +02:00
int regnum_max_excl = gdbarch_num_cooked_regs (gdbarch);
Fix internal error on DW_OP_bregx(-1) https://bugzilla.redhat.com/show_bug.cgi?id=1270564#c15 https://bugzilla.redhat.com/attachment.cgi?id=1081772 clang-3.5.0-9.fc22.x86_64 <3><22b2>: Abbrev Number: 69 (DW_TAG_variable) <22b3> DW_AT_location : 7 byte block: 92 ff ff ff ff f 0 (DW_OP_bregx: 4294967295 (r-1) 0) <22bb> DW_AT_name : (indirect string, offset: 0x2a36): texture_data <22c1> DW_AT_type : <0x1d3> (gdb) p variable warning: Unmapped DWARF Register #-1 encountered. regcache.c:177: internal-error: register_size: Assertion `regnum >= 0 && regnum < (gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch))' failed. [...] Quit this debugging session? (y or n) FAIL: gdb.dwarf2/dw2-regno-invalid.exp: p variable (GDB internal error) -> (x86_64) (gdb) p variable warning: Unmapped DWARF Register #-1 encountered. Invalid register #-1, expecting 0 <= # < 220 (gdb) PASS: gdb.dwarf2/dw2-regno-invalid.exp: p variable -> (i386) (gdb) p variable Invalid register #104, expecting 0 <= # < 104 (gdb) PASS: gdb.dwarf2/dw2-regno-invalid.exp: p variable GDB calls gdbarch_dwarf2_reg_to_regnum() first which returns -1 in the x86_64 case if (regnum == -1) warning (_("Unmapped DWARF Register #%d encountered."), reg); but in i386 case it does: /* This will hopefully provoke a warning. */ return gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch); and the default implementation is a nop, leaving whatever register number the DWARF specified. gdb/ChangeLog 2015-10-20 Jan Kratochvil <jan.kratochvil@redhat.com> * findvar.c (address_from_register): Check REGNUM validity. gdb/testsuite/ChangeLog 2015-10-20 Jan Kratochvil <jan.kratochvil@redhat.com> Pedro Alves <palves@redhat.com> * gdb.dwarf2/dw2-regno-invalid.exp: New file. * lib/dwarf.exp (Dwarf): Add DW_OP_bregx.
2015-10-20 20:40:38 +02:00
if (regnum < 0 || regnum >= regnum_max_excl)
error (_("Invalid register #%d, expecting 0 <= # < %d"), regnum,
regnum_max_excl);
Use address_from_register in dwarf2-frame.c:read_addr_from_reg This patch fixes a problem that prevented use of the Dwarf unwinders on SPU, because dwarf2-frame.c common code did not support the situation where the stack and/or frame pointer is maintained in a *vector* register. This is because read_addr_from_reg is hard-coded to assume that such pointers can be read from registers via a simple get_frame_register / unpack_pointer operation. Now, there *is* a routine address_from_register that calls into the appropriate tdep routines to handle pointer values in "weird" registers like on SPU, but it turns out I cannot simply change dwarf2-frame.c to use address_from_register. This is because address_from_register uses value_from_register to create a (temporary) value, and that routine at some point calls get_frame_id in order to set up that value's VALUE_FRAME_ID entry. However, the dwarf2-frame.c read_addr_from_reg routine will be called during early unwinding (to unwind the frame's CFA), at which point the frame's ID is not actually known yet! This would cause an assert. On the other hand, we may notice that VALUE_FRAME_ID is only needed in the value returned by value_from_register if that value is later used as an lvalue. But this is obviously never done to the temporary value used in address_from_register. So, if we could change address_from_register to not call value_from_register but instead accept constructing a value that doesn't have VALUE_FRAME_ID set, things should be fine. To do that, we can change the value_from_register callback to accept a FRAME_ID instead of a FRAME; the only existing uses of the FRAME argument were either to extract its frame ID, or its gdbarch. (To keep a way of getting at the latter, we also change the callback's type from "f" to "m".) Together with the required follow-on changes in the existing value_from_register implementations (including the default one), this seems to fix the problem. As another minor interface cleanup, I've removed the explicit TYPE argument from address_from_register. This routine really always uses a default pointer type, and in the new implementation it -to some extent- relies on that fact, in that it will now no longer handle types that require gdbarch_convert_register_p handling. gdb: 2014-04-17 Ulrich Weigand  <uweigand@de.ibm.com> * gdbarch.sh (value_from_register): Make class "m" instead of "f". Replace FRAME argument with FRAME_ID. * gdbarch.c, gdbarch.h: Regenerate. * findvar.c (default_value_from_register): Add GDBARCH argument; replace FRAME by FRAME_ID. No longer call get_frame_id. (value_from_register): Update call to gdbarch_value_from_register. * value.h (default_value_from_register): Update prototype. * s390-linux-tdep.c (s390_value_from_register): Update interface and call to default_value_from_register. * spu-tdep.c (spu_value_from_register): Likewise. * findvar.c (address_from_register): Remove TYPE argument. Do not call value_from_register; use gdbarch_value_from_register with null_frame_id instead. * value.h (address_from_register): Update prototype. * dwarf2-frame.c (read_addr_from_reg): Use address_from_register. * dwarf2loc.c (dwarf_expr_read_addr_from_reg): Update for address_from_register interface change.
2014-04-17 14:01:39 +02:00
/* This routine may be called during early unwinding, at a time
where the ID of FRAME is not yet known. Calling value_from_register
would therefore abort in get_frame_id. However, since we only need
a temporary value that is never used as lvalue, we actually do not
Change meaning of VALUE_FRAME_ID; rename to VALUE_NEXT_FRAME_ID The VALUE_FRAME_ID macro provides access to a member in struct value that's used to hold the frame id that's used when determining a register's value or when assigning to a register. The underlying member has a long and obscure name. I won't refer to it here, but will simply refer to VALUE_FRAME_ID as if it's the struct value member instead of being a convenient macro. At the moment, without this patch in place, VALUE_FRAME_ID is set in value_of_register_lazy() and several other locations to hold the frame id of the frame passed to those functions. VALUE_FRAME_ID is used in the lval_register case of value_fetch_lazy(). To fetch the register's value, it calls get_frame_register_value() which, in turn, calls frame_unwind_register_value() with frame->next. A python based unwinder may wish to determine the value of a register or evaluate an expression containing a register. When it does this, value_fetch_lazy() will be called under some circumstances. It will attempt to determine the frame id associated with the frame passed to it. In so doing, it will end up back in the frame sniffer of the very same python unwinder that's attempting to learn the value of a register as part of the sniffing operation. This recursion is not desirable. As noted above, when value_fetch_lazy() wants to fetch a register's value, it does so (indirectly) by unwinding from frame->next. With this in mind, a solution suggests itself: Change VALUE_FRAME_ID to hold the frame id associated with the next frame. Then, when it comes time to obtain the value associated with the register, we can simply unwind from the frame corresponding to the frame id stored in VALUE_FRAME_ID. This neatly avoids the python unwinder recursion problem by changing when the "next" operation occurs. Instead of the "next" operation occuring when the register value is fetched, it occurs earlier on when assigning a frame id to VALUE_FRAME_ID. (Thanks to Pedro for this suggestion.) This patch implements this idea. It builds on the patch "Distinguish sentinel frame from null frame". Without that work in place, it's necessary to check for null_id at several places and then obtain the sentinel frame. It also renames most occurences of VALUE_FRAME_ID to VALUE_NEXT_FRAME_ID to reflect the new meaning of this field. There are several uses of VALUE_FRAME_ID which were not changed. In each case, the original meaning of VALUE_FRAME_ID is required to get correct results. In all but one of these uses, either put_frame_register_bytes() or get_frame_register_bytes() is being called with the frame value obtained from VALUE_FRAME_ID. Both of these functions perform some unwinding by performing a "->next" operation on the frame passed to it. If we were to use the new VALUE_NEXT_FRAME_ID macro, this would effectively do two "->next" operations, which is not what we want. The VALUE_FRAME_ID macro has been redefined in terms of VALUE_NEXT_FRAME_ID. It simply fetches the previous frame's id, providing this id as the value of the macro. gdb/ChangeLog: * value.h (VALUE_FRAME_ID): Rename to VALUE_NEXT_FRAME_ID. Update comment. Create new VALUE_FRAME_ID which is defined in terms of VALUE_NEXT_FRAME_ID. (deprecated_value_frame_id_hack): Rename to deprecated_value_next_frame_id_hack. * dwarf2loc.c, findvar.c, frame-unwind.c, sentinel-frame.c, valarith.c, valops.c, value.c: Adjust nearly all occurences of VALUE_FRAME_ID to VALUE_NEXT_FRAME_ID. Add comments for those which did not change. * value.c (struct value): Rename frame_id field to next_frame_id. Update comment. (deprecated_value_frame_id_hack): Rename to deprecated_value_next_frame_id_hack. (value_fetch_lazy): Call frame_unwind_register_value() instead of get_frame_register_value(). * frame.c (get_prev_frame_id_by_id): New function. * frame.h (get_prev_frame_id_by_id): Declare. * dwarf2loc.c (dwarf2_evaluate_loc_desc_full): Make VALUE_NEXT_FRAME_ID refer to the next frame. * findvar.c (value_of_register_lazy): Likewise. (default_value_from_register): Likewise. (value_from_register): Likewise. * frame_unwind.c (frame_unwind_got_optimized): Likewise. * sentinel-frame.c (sentinel_frame_prev_register): Likewise. * value.h (VALUE_FRAME_ID): Update comment describing this macro.
2016-09-28 06:18:44 +02:00
really need to set its VALUE_NEXT_FRAME_ID. Therefore, we re-implement
the core of value_from_register, but use the null_frame_id. */
Use address_from_register in dwarf2-frame.c:read_addr_from_reg This patch fixes a problem that prevented use of the Dwarf unwinders on SPU, because dwarf2-frame.c common code did not support the situation where the stack and/or frame pointer is maintained in a *vector* register. This is because read_addr_from_reg is hard-coded to assume that such pointers can be read from registers via a simple get_frame_register / unpack_pointer operation. Now, there *is* a routine address_from_register that calls into the appropriate tdep routines to handle pointer values in "weird" registers like on SPU, but it turns out I cannot simply change dwarf2-frame.c to use address_from_register. This is because address_from_register uses value_from_register to create a (temporary) value, and that routine at some point calls get_frame_id in order to set up that value's VALUE_FRAME_ID entry. However, the dwarf2-frame.c read_addr_from_reg routine will be called during early unwinding (to unwind the frame's CFA), at which point the frame's ID is not actually known yet! This would cause an assert. On the other hand, we may notice that VALUE_FRAME_ID is only needed in the value returned by value_from_register if that value is later used as an lvalue. But this is obviously never done to the temporary value used in address_from_register. So, if we could change address_from_register to not call value_from_register but instead accept constructing a value that doesn't have VALUE_FRAME_ID set, things should be fine. To do that, we can change the value_from_register callback to accept a FRAME_ID instead of a FRAME; the only existing uses of the FRAME argument were either to extract its frame ID, or its gdbarch. (To keep a way of getting at the latter, we also change the callback's type from "f" to "m".) Together with the required follow-on changes in the existing value_from_register implementations (including the default one), this seems to fix the problem. As another minor interface cleanup, I've removed the explicit TYPE argument from address_from_register. This routine really always uses a default pointer type, and in the new implementation it -to some extent- relies on that fact, in that it will now no longer handle types that require gdbarch_convert_register_p handling. gdb: 2014-04-17 Ulrich Weigand  <uweigand@de.ibm.com> * gdbarch.sh (value_from_register): Make class "m" instead of "f". Replace FRAME argument with FRAME_ID. * gdbarch.c, gdbarch.h: Regenerate. * findvar.c (default_value_from_register): Add GDBARCH argument; replace FRAME by FRAME_ID. No longer call get_frame_id. (value_from_register): Update call to gdbarch_value_from_register. * value.h (default_value_from_register): Update prototype. * s390-linux-tdep.c (s390_value_from_register): Update interface and call to default_value_from_register. * spu-tdep.c (spu_value_from_register): Likewise. * findvar.c (address_from_register): Remove TYPE argument. Do not call value_from_register; use gdbarch_value_from_register with null_frame_id instead. * value.h (address_from_register): Update prototype. * dwarf2-frame.c (read_addr_from_reg): Use address_from_register. * dwarf2loc.c (dwarf_expr_read_addr_from_reg): Update for address_from_register interface change.
2014-04-17 14:01:39 +02:00
/* Some targets require a special conversion routine even for plain
pointer types. Avoid constructing a value object in those cases. */
if (gdbarch_convert_register_p (gdbarch, regnum, type))
{
Add casts to memory allocation related calls Most allocation functions (if not all) return a void* pointing to the allocated memory. In C++, we need to add an explicit cast when assigning the result to a pointer to another type (which is the case more often than not). The content of this patch is taken from Pedro's branch, from commit "(mostly) auto-generated patch to insert casts needed for C++". I validated that the changes make sense and manually reflowed the code to make it respect the coding style. I also found multiple places where I could use XNEW/XNEWVEC/XRESIZEVEC/etc. Thanks a lot to whoever did that automated script to insert casts, doing it completely by hand would have taken a ridiculous amount of time. Only files built on x86 with --enable-targets=all are modified. This means that all other -nat.c files are untouched and will have to be dealt with later by using appropiate compilers. Or maybe we can try to build them with a regular g++ just to know where to add casts, I don't know. I built-tested this with --enable-targets=all and reg-tested. Here's the changelog entry, which was not too bad to make despite the size, thanks to David Malcom's script. I fixed some bits by hand, but there might be some wrong parts left (hopefully not). gdb/ChangeLog: * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Add cast to allocation result assignment. * ada-exp.y (write_object_renaming): Likewise. (write_ambiguous_var): Likewise. (ada_nget_field_index): Likewise. (write_var_or_type): Likewise. * ada-lang.c (ada_decode_symbol): Likewise. (ada_value_assign): Likewise. (value_pointer): Likewise. (cache_symbol): Likewise. (add_nonlocal_symbols): Likewise. (ada_name_for_lookup): Likewise. (symbol_completion_add): Likewise. (ada_to_fixed_type_1): Likewise. (ada_get_next_arg): Likewise. (defns_collected): Likewise. * ada-lex.l (processId): Likewise. (processString): Likewise. * ada-tasks.c (read_known_tasks_array): Likewise. (read_known_tasks_list): Likewise. * ada-typeprint.c (decoded_type_name): Likewise. * addrmap.c (addrmap_mutable_create_fixed): Likewise. * amd64-tdep.c (amd64_push_arguments): Likewise. (amd64_displaced_step_copy_insn): Likewise. (amd64_classify_insn_at): Likewise. (amd64_relocate_instruction): Likewise. * amd64obsd-tdep.c (amd64obsd_sigtramp_p): Likewise. * arch-utils.c (simple_displaced_step_copy_insn): Likewise. (initialize_current_architecture): Likewise. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * arm-symbian-tdep.c (arm_symbian_osabi_sniffer): Likewise. * arm-tdep.c (arm_exidx_new_objfile): Likewise. (arm_push_dummy_call): Likewise. (extend_buffer_earlier): Likewise. (arm_adjust_breakpoint_address): Likewise. (arm_skip_stub): Likewise. * auto-load.c (filename_is_in_pattern): Likewise. (maybe_add_script_file): Likewise. (maybe_add_script_text): Likewise. (auto_load_objfile_script_1): Likewise. * auxv.c (ld_so_xfer_auxv): Likewise. * ax-general.c (new_agent_expr): Likewise. (grow_expr): Likewise. (ax_reg_mask): Likewise. * bcache.c (bcache_full): Likewise. * breakpoint.c (program_breakpoint_here_p): Likewise. * btrace.c (parse_xml_raw): Likewise. * build-id.c (build_id_to_debug_bfd): Likewise. * buildsym.c (end_symtab_with_blockvector): Likewise. * c-exp.y (string_exp): Likewise. (qualified_name): Likewise. (write_destructor_name): Likewise. (operator_stoken): Likewise. (parse_number): Likewise. (scan_macro_expansion): Likewise. (yylex): Likewise. (c_print_token): Likewise. * c-lang.c (c_get_string): Likewise. (emit_numeric_character): Likewise. * charset.c (wchar_iterate): Likewise. * cli/cli-cmds.c (complete_command): Likewise. (make_command): Likewise. * cli/cli-dump.c (restore_section_callback): Likewise. (restore_binary_file): Likewise. * cli/cli-interp.c (cli_interpreter_exec): Likewise. * cli/cli-script.c (execute_control_command): Likewise. * cli/cli-setshow.c (do_set_command): Likewise. * coff-pe-read.c (add_pe_forwarded_sym): Likewise. (read_pe_exported_syms): Likewise. * coffread.c (coff_read_struct_type): Likewise. (coff_read_enum_type): Likewise. * common/btrace-common.c (btrace_data_append): Likewise. * common/buffer.c (buffer_grow): Likewise. * common/filestuff.c (gdb_fopen_cloexec): Likewise. * common/format.c (parse_format_string): Likewise. * common/gdb_vecs.c (delim_string_to_char_ptr_vec_append): Likewise. * common/xml-utils.c (xml_escape_text): Likewise. * compile/compile-object-load.c (copy_sections): Likewise. (compile_object_load): Likewise. * compile/compile-object-run.c (compile_object_run): Likewise. * completer.c (filename_completer): Likewise. * corefile.c (read_memory_typed_address): Likewise. (write_memory_unsigned_integer): Likewise. (write_memory_signed_integer): Likewise. (complete_set_gnutarget): Likewise. * corelow.c (get_core_register_section): Likewise. * cp-name-parser.y (d_grab): Likewise. (allocate_info): Likewise. (cp_new_demangle_parse_info): Likewise. * cp-namespace.c (cp_scan_for_anonymous_namespaces): Likewise. (cp_lookup_symbol_in_namespace): Likewise. (lookup_namespace_scope): Likewise. (find_symbol_in_baseclass): Likewise. (cp_lookup_nested_symbol): Likewise. (cp_lookup_transparent_type_loop): Likewise. * cp-support.c (copy_string_to_obstack): Likewise. (make_symbol_overload_list): Likewise. (make_symbol_overload_list_namespace): Likewise. (make_symbol_overload_list_adl_namespace): Likewise. (first_component_command): Likewise. * cp-valprint.c (cp_print_value): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * d-exp.y (StringExp): Likewise. * d-namespace.c (d_lookup_symbol_in_module): Likewise. (lookup_module_scope): Likewise. (find_symbol_in_baseclass): Likewise. (d_lookup_nested_symbol): Likewise. * dbxread.c (find_stab_function_addr): Likewise. (read_dbx_symtab): Likewise. (dbx_end_psymtab): Likewise. (cp_set_block_scope): Likewise. * dcache.c (dcache_alloc): Likewise. * demangle.c (_initialize_demangler): Likewise. * dicos-tdep.c (dicos_load_module_p): Likewise. * dictionary.c (dict_create_hashed_expandable): Likewise. (dict_create_linear_expandable): Likewise. (expand_hashtable): Likewise. (add_symbol_linear_expandable): Likewise. * dwarf2-frame.c (add_cie): Likewise. (add_fde): Likewise. (dwarf2_build_frame_info): Likewise. * dwarf2expr.c (dwarf_expr_grow_stack): Likewise. (dwarf_expr_fetch_address): Likewise. (add_piece): Likewise. (execute_stack_op): Likewise. * dwarf2loc.c (chain_candidate): Likewise. (dwarf_entry_parameter_to_value): Likewise. (read_pieced_value): Likewise. (write_pieced_value): Likewise. * dwarf2read.c (dwarf2_read_section): Likewise. (add_type_unit): Likewise. (read_comp_units_from_section): Likewise. (fixup_go_packaging): Likewise. (dwarf2_compute_name): Likewise. (dwarf2_physname): Likewise. (create_dwo_unit_in_dwp_v1): Likewise. (create_dwo_unit_in_dwp_v2): Likewise. (read_func_scope): Likewise. (read_call_site_scope): Likewise. (dwarf2_attach_fields_to_type): Likewise. (process_structure_scope): Likewise. (mark_common_block_symbol_computed): Likewise. (read_common_block): Likewise. (abbrev_table_read_table): Likewise. (guess_partial_die_structure_name): Likewise. (fixup_partial_die): Likewise. (add_file_name): Likewise. (dwarf2_const_value_data): Likewise. (dwarf2_const_value_attr): Likewise. (build_error_marker_type): Likewise. (guess_full_die_structure_name): Likewise. (anonymous_struct_prefix): Likewise. (typename_concat): Likewise. (dwarf2_canonicalize_name): Likewise. (dwarf2_name): Likewise. (write_constant_as_bytes): Likewise. (dwarf2_fetch_constant_bytes): Likewise. (copy_string): Likewise. (parse_macro_definition): Likewise. * elfread.c (elf_symfile_segments): Likewise. (elf_rel_plt_read): Likewise. (elf_gnu_ifunc_resolve_by_cache): Likewise. (elf_gnu_ifunc_resolve_by_got): Likewise. (elf_read_minimal_symbols): Likewise. (elf_gnu_ifunc_record_cache): Likewise. * event-top.c (top_level_prompt): Likewise. (command_line_handler): Likewise. * exec.c (resize_section_table): Likewise. * expprint.c (print_subexp_standard): Likewise. * fbsd-tdep.c (fbsd_collect_regset_section_cb): Likewise. * findcmd.c (parse_find_args): Likewise. * findvar.c (address_from_register): Likewise. * frame.c (get_prev_frame_always): Likewise. * gdb_bfd.c (gdb_bfd_ref): Likewise. (get_section_descriptor): Likewise. * gdb_obstack.c (obconcat): Likewise. (obstack_strdup): Likewise. * gdbtypes.c (lookup_function_type_with_arguments): Likewise. (create_set_type): Likewise. (lookup_unsigned_typename): Likewise. (lookup_signed_typename): Likewise. (resolve_dynamic_union): Likewise. (resolve_dynamic_struct): Likewise. (add_dyn_prop): Likewise. (copy_dynamic_prop_list): Likewise. (arch_flags_type): Likewise. (append_composite_type_field_raw): Likewise. * gdbtypes.h (INIT_FUNC_SPECIFIC): Likewise. * gnu-v3-abi.c (gnuv3_rtti_type): Likewise. * go-exp.y (string_exp): Likewise. * go-lang.c (go_demangle): Likewise. * guile/guile.c (compute_scheme_string): Likewise. * guile/scm-cmd.c (gdbscm_parse_command_name): Likewise. (gdbscm_canonicalize_command_name): Likewise. * guile/scm-ports.c (ioscm_init_stdio_buffers): Likewise. (ioscm_init_memory_port): Likewise. (ioscm_reinit_memory_port): Likewise. * guile/scm-utils.c (gdbscm_gc_xstrdup): Likewise. (gdbscm_gc_dup_argv): Likewise. * h8300-tdep.c (h8300_push_dummy_call): Likewise. * hppa-tdep.c (internalize_unwinds): Likewise. (read_unwind_info): Likewise. * i386-cygwin-tdep.c (core_process_module_section): Likewise. (windows_core_xfer_shared_libraries): Likewise. * i386-tdep.c (i386_displaced_step_copy_insn): Likewise. (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * i386obsd-tdep.c (i386obsd_sigtramp_p): Likewise. * inf-child.c (inf_child_fileio_readlink): Likewise. * inf-ptrace.c (inf_ptrace_fetch_register): Likewise. (inf_ptrace_store_register): Likewise. * infrun.c (follow_exec): Likewise. (displaced_step_prepare_throw): Likewise. (save_stop_context): Likewise. (save_infcall_suspend_state): Likewise. * jit.c (jit_read_descriptor): Likewise. (jit_read_code_entry): Likewise. (jit_symtab_line_mapping_add_impl): Likewise. (finalize_symtab): Likewise. (jit_unwind_reg_get_impl): Likewise. * jv-exp.y (QualifiedName): Likewise. * jv-lang.c (get_java_utf8_name): Likewise. (type_from_class): Likewise. (java_demangle_type_signature): Likewise. (java_class_name_from_physname): Likewise. * jv-typeprint.c (java_type_print_base): Likewise. * jv-valprint.c (java_value_print): Likewise. * language.c (add_language): Likewise. * linespec.c (add_sal_to_sals_basic): Likewise. (add_sal_to_sals): Likewise. (decode_objc): Likewise. (find_linespec_symbols): Likewise. * linux-fork.c (fork_save_infrun_state): Likewise. * linux-nat.c (linux_nat_detach): Likewise. (linux_nat_fileio_readlink): Likewise. * linux-record.c (record_linux_sockaddr): Likewise. (record_linux_msghdr): Likewise. (Do): Likewise. * linux-tdep.c (linux_core_info_proc_mappings): Likewise. (linux_collect_regset_section_cb): Likewise. (linux_get_siginfo_data): Likewise. * linux-thread-db.c (try_thread_db_load_from_pdir_1): Likewise. (try_thread_db_load_from_dir): Likewise. (thread_db_load_search): Likewise. (info_auto_load_libthread_db): Likewise. * m32c-tdep.c (m32c_m16c_address_to_pointer): Likewise. (m32c_m16c_pointer_to_address): Likewise. * m68hc11-tdep.c (m68hc11_pseudo_register_write): Likewise. * m68k-tdep.c (m68k_get_longjmp_target): Likewise. * machoread.c (macho_check_dsym): Likewise. * macroexp.c (resize_buffer): Likewise. (gather_arguments): Likewise. (maybe_expand): Likewise. * macrotab.c (new_macro_key): Likewise. (new_source_file): Likewise. (new_macro_definition): Likewise. * mdebugread.c (parse_symbol): Likewise. (parse_type): Likewise. (parse_partial_symbols): Likewise. (psymtab_to_symtab_1): Likewise. * mem-break.c (default_memory_insert_breakpoint): Likewise. * mi/mi-cmd-break.c (mi_argv_to_format): Likewise. * mi/mi-main.c (mi_cmd_data_read_memory): Likewise. (mi_cmd_data_read_memory_bytes): Likewise. (mi_cmd_data_write_memory_bytes): Likewise. (mi_cmd_trace_frame_collected): Likewise. * mi/mi-parse.c (mi_parse_argv): Likewise. (mi_parse): Likewise. * minidebug.c (lzma_open): Likewise. (lzma_pread): Likewise. * mips-tdep.c (mips_read_fp_register_single): Likewise. (mips_print_fp_register): Likewise. * mipsnbsd-tdep.c (mipsnbsd_get_longjmp_target): Likewise. * mipsread.c (read_alphacoff_dynamic_symtab): Likewise. * mt-tdep.c (mt_register_name): Likewise. (mt_registers_info): Likewise. (mt_push_dummy_call): Likewise. * namespace.c (add_using_directive): Likewise. * nat/linux-btrace.c (perf_event_read): Likewise. (linux_enable_bts): Likewise. * nat/linux-osdata.c (linux_common_core_of_thread): Likewise. * nat/linux-ptrace.c (linux_ptrace_test_ret_to_nx): Likewise. * nto-tdep.c (nto_find_and_open_solib): Likewise. (nto_parse_redirection): Likewise. * objc-lang.c (objc_demangle): Likewise. (find_methods): Likewise. * objfiles.c (get_objfile_bfd_data): Likewise. (set_objfile_main_name): Likewise. (allocate_objfile): Likewise. (objfile_relocate): Likewise. (update_section_map): Likewise. * osabi.c (generic_elf_osabi_sniff_abi_tag_sections): Likewise. * p-exp.y (exp): Likewise. (yylex): Likewise. * p-valprint.c (pascal_object_print_value): Likewise. * parse.c (initialize_expout): Likewise. (mark_completion_tag): Likewise. (copy_name): Likewise. (parse_float): Likewise. (type_stack_reserve): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. (ppu2spu_prev_register): Likewise. * ppc-ravenscar-thread.c (supply_register_at_address): Likewise. * printcmd.c (printf_wide_c_string): Likewise. (printf_pointer): Likewise. * probe.c (parse_probes): Likewise. * python/py-cmd.c (gdbpy_parse_command_name): Likewise. (cmdpy_init): Likewise. * python/py-gdb-readline.c (gdbpy_readline_wrapper): Likewise. * python/py-symtab.c (set_sal): Likewise. * python/py-unwind.c (pyuw_sniffer): Likewise. * python/python.c (python_interactive_command): Likewise. (compute_python_string): Likewise. * ravenscar-thread.c (get_running_thread_id): Likewise. * record-full.c (record_full_exec_insn): Likewise. (record_full_core_open_1): Likewise. * regcache.c (regcache_raw_read_signed): Likewise. (regcache_raw_read_unsigned): Likewise. (regcache_cooked_read_signed): Likewise. (regcache_cooked_read_unsigned): Likewise. * remote-fileio.c (remote_fileio_func_open): Likewise. (remote_fileio_func_rename): Likewise. (remote_fileio_func_unlink): Likewise. (remote_fileio_func_stat): Likewise. (remote_fileio_func_system): Likewise. * remote-mips.c (mips_xfer_memory): Likewise. (mips_load_srec): Likewise. (pmon_end_download): Likewise. * remote.c (new_remote_state): Likewise. (map_regcache_remote_table): Likewise. (remote_register_number_and_offset): Likewise. (init_remote_state): Likewise. (get_memory_packet_size): Likewise. (remote_pass_signals): Likewise. (remote_program_signals): Likewise. (remote_start_remote): Likewise. (remote_check_symbols): Likewise. (remote_query_supported): Likewise. (extended_remote_attach): Likewise. (process_g_packet): Likewise. (store_registers_using_G): Likewise. (putpkt_binary): Likewise. (read_frame): Likewise. (compare_sections_command): Likewise. (remote_hostio_pread): Likewise. (remote_hostio_readlink): Likewise. (remote_file_put): Likewise. (remote_file_get): Likewise. (remote_pid_to_exec_file): Likewise. (_initialize_remote): Likewise. * rs6000-aix-tdep.c (rs6000_aix_ld_info_to_xml): Likewise. (rs6000_aix_core_xfer_shared_libraries_aix): Likewise. * rs6000-tdep.c (ppc_displaced_step_copy_insn): Likewise. (bfd_uses_spe_extensions): Likewise. * s390-linux-tdep.c (s390_displaced_step_copy_insn): Likewise. * score-tdep.c (score7_malloc_and_get_memblock): Likewise. * solib-dsbt.c (decode_loadmap): Likewise. (fetch_loadmap): Likewise. (scan_dyntag): Likewise. (enable_break): Likewise. (dsbt_relocate_main_executable): Likewise. * solib-frv.c (fetch_loadmap): Likewise. (enable_break2): Likewise. (frv_relocate_main_executable): Likewise. * solib-spu.c (spu_relocate_main_executable): Likewise. (spu_bfd_open): Likewise. * solib-svr4.c (lm_info_read): Likewise. (read_program_header): Likewise. (find_program_interpreter): Likewise. (scan_dyntag): Likewise. (elf_locate_base): Likewise. (open_symbol_file_object): Likewise. (read_program_headers_from_bfd): Likewise. (svr4_relocate_main_executable): Likewise. * solib-target.c (solib_target_relocate_section_addresses): Likewise. * solib.c (solib_find_1): Likewise. (exec_file_find): Likewise. (solib_find): Likewise. * source.c (openp): Likewise. (print_source_lines_base): Likewise. (forward_search_command): Likewise. * sparc-ravenscar-thread.c (supply_register_at_address): Likewise. * spu-tdep.c (spu2ppu_prev_register): Likewise. (spu_get_overlay_table): Likewise. * stabsread.c (patch_block_stabs): Likewise. (define_symbol): Likewise. (again:): Likewise. (read_member_functions): Likewise. (read_one_struct_field): Likewise. (read_enum_type): Likewise. (common_block_start): Likewise. * stack.c (read_frame_arg): Likewise. (backtrace_command): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. * symfile.c (syms_from_objfile_1): Likewise. (find_separate_debug_file): Likewise. (load_command): Likewise. (load_progress): Likewise. (load_section_callback): Likewise. (reread_symbols): Likewise. (add_filename_language): Likewise. (allocate_compunit_symtab): Likewise. (read_target_long_array): Likewise. (simple_read_overlay_table): Likewise. * symtab.c (symbol_set_names): Likewise. (resize_symbol_cache): Likewise. (rbreak_command): Likewise. (completion_list_add_name): Likewise. (completion_list_objc_symbol): Likewise. (add_filename_to_list): Likewise. * target-descriptions.c (maint_print_c_tdesc_cmd): Likewise. * target-memory.c (target_write_memory_blocks): Likewise. * target.c (target_read_string): Likewise. (read_whatever_is_readable): Likewise. (target_read_alloc_1): Likewise. (simple_search_memory): Likewise. (target_fileio_read_alloc_1): Likewise. * tilegx-tdep.c (tilegx_push_dummy_call): Likewise. * top.c (command_line_input): Likewise. * tracefile-tfile.c (tfile_fetch_registers): Likewise. * tracefile.c (tracefile_fetch_registers): Likewise. * tracepoint.c (add_memrange): Likewise. (init_collection_list): Likewise. (add_aexpr): Likewise. (trace_dump_actions): Likewise. (parse_trace_status): Likewise. (parse_tracepoint_definition): Likewise. (parse_tsv_definition): Likewise. (parse_static_tracepoint_marker_definition): Likewise. * tui/tui-file.c (tui_sfileopen): Likewise. (tui_file_adjust_strbuf): Likewise. * tui/tui-io.c (tui_expand_tabs): Likewise. * tui/tui-source.c (tui_set_source_content): Likewise. * typeprint.c (find_global_typedef): Likewise. * ui-file.c (do_ui_file_xstrdup): Likewise. (ui_file_obsavestring): Likewise. (mem_file_write): Likewise. * utils.c (make_hex_string): Likewise. (get_regcomp_error): Likewise. (puts_filtered_tabular): Likewise. (gdb_realpath_keepfile): Likewise. (ldirname): Likewise. (gdb_bfd_errmsg): Likewise. (substitute_path_component): Likewise. * valops.c (search_struct_method): Likewise. (find_oload_champ_namespace_loop): Likewise. * valprint.c (print_decimal_chars): Likewise. (read_string): Likewise. (generic_emit_char): Likewise. * varobj.c (varobj_delete): Likewise. (varobj_value_get_print_value): Likewise. * vaxobsd-tdep.c (vaxobsd_sigtramp_sniffer): Likewise. * windows-tdep.c (display_one_tib): Likewise. * xcoffread.c (read_xcoff_symtab): Likewise. (process_xcoff_symbol): Likewise. (swap_sym): Likewise. (scan_xcoff_symtab): Likewise. (xcoff_initial_scan): Likewise. * xml-support.c (gdb_xml_end_element): Likewise. (xml_process_xincludes): Likewise. (xml_fetch_content_from_file): Likewise. * xml-syscall.c (xml_list_of_syscalls): Likewise. * xstormy16-tdep.c (xstormy16_push_dummy_call): Likewise. gdb/gdbserver/ChangeLog: * ax.c (gdb_parse_agent_expr): Add cast to allocation result assignment. (gdb_unparse_agent_expr): Likewise. * hostio.c (require_data): Likewise. (handle_pread): Likewise. * linux-low.c (disable_regset): Likewise. (fetch_register): Likewise. (store_register): Likewise. (get_dynamic): Likewise. (linux_qxfer_libraries_svr4): Likewise. * mem-break.c (delete_fast_tracepoint_jump): Likewise. (set_fast_tracepoint_jump): Likewise. (uninsert_fast_tracepoint_jumps_at): Likewise. (reinsert_fast_tracepoint_jumps_at): Likewise. (validate_inserted_breakpoint): Likewise. (clone_agent_expr): Likewise. * regcache.c (init_register_cache): Likewise. * remote-utils.c (putpkt_binary_1): Likewise. (decode_M_packet): Likewise. (decode_X_packet): Likewise. (look_up_one_symbol): Likewise. (relocate_instruction): Likewise. (monitor_output): Likewise. * server.c (handle_search_memory): Likewise. (handle_qxfer_exec_file): Likewise. (handle_qxfer_libraries): Likewise. (handle_qxfer): Likewise. (handle_query): Likewise. (handle_v_cont): Likewise. (handle_v_run): Likewise. (captured_main): Likewise. * target.c (write_inferior_memory): Likewise. * thread-db.c (try_thread_db_load_from_dir): Likewise. * tracepoint.c (init_trace_buffer): Likewise. (add_tracepoint_action): Likewise. (add_traceframe): Likewise. (add_traceframe_block): Likewise. (cmd_qtdpsrc): Likewise. (cmd_qtdv): Likewise. (cmd_qtstatus): Likewise. (response_source): Likewise. (response_tsv): Likewise. (cmd_qtnotes): Likewise. (gdb_collect): Likewise. (initialize_tracepoint): Likewise.
2015-09-25 20:08:06 +02:00
gdb_byte *buf = (gdb_byte *) alloca (TYPE_LENGTH (type));
int optim, unavail, ok;
ok = gdbarch_register_to_value (gdbarch, frame, regnum, type,
buf, &optim, &unavail);
if (!ok)
{
/* This function is used while computing a location expression.
Complain about the value being optimized out, rather than
letting value_as_address complain about some random register
the expression depends on not being saved. */
error_value_optimized_out ();
}
return unpack_long (type, buf);
}
Use address_from_register in dwarf2-frame.c:read_addr_from_reg This patch fixes a problem that prevented use of the Dwarf unwinders on SPU, because dwarf2-frame.c common code did not support the situation where the stack and/or frame pointer is maintained in a *vector* register. This is because read_addr_from_reg is hard-coded to assume that such pointers can be read from registers via a simple get_frame_register / unpack_pointer operation. Now, there *is* a routine address_from_register that calls into the appropriate tdep routines to handle pointer values in "weird" registers like on SPU, but it turns out I cannot simply change dwarf2-frame.c to use address_from_register. This is because address_from_register uses value_from_register to create a (temporary) value, and that routine at some point calls get_frame_id in order to set up that value's VALUE_FRAME_ID entry. However, the dwarf2-frame.c read_addr_from_reg routine will be called during early unwinding (to unwind the frame's CFA), at which point the frame's ID is not actually known yet! This would cause an assert. On the other hand, we may notice that VALUE_FRAME_ID is only needed in the value returned by value_from_register if that value is later used as an lvalue. But this is obviously never done to the temporary value used in address_from_register. So, if we could change address_from_register to not call value_from_register but instead accept constructing a value that doesn't have VALUE_FRAME_ID set, things should be fine. To do that, we can change the value_from_register callback to accept a FRAME_ID instead of a FRAME; the only existing uses of the FRAME argument were either to extract its frame ID, or its gdbarch. (To keep a way of getting at the latter, we also change the callback's type from "f" to "m".) Together with the required follow-on changes in the existing value_from_register implementations (including the default one), this seems to fix the problem. As another minor interface cleanup, I've removed the explicit TYPE argument from address_from_register. This routine really always uses a default pointer type, and in the new implementation it -to some extent- relies on that fact, in that it will now no longer handle types that require gdbarch_convert_register_p handling. gdb: 2014-04-17 Ulrich Weigand  <uweigand@de.ibm.com> * gdbarch.sh (value_from_register): Make class "m" instead of "f". Replace FRAME argument with FRAME_ID. * gdbarch.c, gdbarch.h: Regenerate. * findvar.c (default_value_from_register): Add GDBARCH argument; replace FRAME by FRAME_ID. No longer call get_frame_id. (value_from_register): Update call to gdbarch_value_from_register. * value.h (default_value_from_register): Update prototype. * s390-linux-tdep.c (s390_value_from_register): Update interface and call to default_value_from_register. * spu-tdep.c (spu_value_from_register): Likewise. * findvar.c (address_from_register): Remove TYPE argument. Do not call value_from_register; use gdbarch_value_from_register with null_frame_id instead. * value.h (address_from_register): Update prototype. * dwarf2-frame.c (read_addr_from_reg): Use address_from_register. * dwarf2loc.c (dwarf_expr_read_addr_from_reg): Update for address_from_register interface change.
2014-04-17 14:01:39 +02:00
value = gdbarch_value_from_register (gdbarch, type, regnum, null_frame_id);
read_frame_register_value (value, frame);
Print registers not saved in the frame as "<not saved>" instead of "<optimized out>". Currently, in some scenarios, GDB prints <optimized out> when printing outer frame registers. An <optimized out> register is a confusing concept. What this really means is that the register is call-clobbered, or IOW, not saved by the callee. This patch makes GDB say that instead. Before patch: (gdb) p/x $rax $1 = <optimized out> (gdb) info registers rax rax <optimized out> After patch: (gdb) p/x $rax $1 = <not saved> (gdb) info registers rax rax <not saved> However, if for some reason the debug info describes a variable as being in such a register (**), we still want to print <optimized out> when printing the variable. IOW, <not saved> is reserved for inspecting registers at the machine level. The patch uses lval_register+optimized_out to encode the not saved registers, and makes it so that optimized out variables always end up in !lval_register values. ** See <https://sourceware.org/ml/gdb-patches/2012-08/msg00787.html>. Current/recent enough GCC doesn't mark variables/arguments as being in call-clobbered registers in the ranges corresponding to function calls, while older GCCs did. Newer GCCs will just not say where the variable is, so GDB will end up realizing the variable is optimized out. frame_unwind_got_optimized creates not_lval optimized out registers, so by default, in most cases, we'll see <optimized out>. value_of_register is the function eval.c uses for evaluating OP_REGISTER (again, $pc, etc.), and related bits. It isn't used for anything else. This function makes sure to return lval_register values. The patch makes "info registers" and the MI equivalent use it too. I think it just makes a lot of sense, as this makes it so that when printing machine registers ($pc, etc.), we go through a central function. We're likely to need a different encoding at some point, if/when we support partially saved registers. Even then, I think value_of_register will still be the spot to tag the intention to print machine register values differently. value_from_register however may also return optimized out lval_register values, so at a couple places where we're computing a variable's location from a dwarf expression, we convert the resulting value away from lval_register to a regular optimized out value. Tested on x86_64 Fedora 17 gdb/ 2013-10-02 Pedro Alves <palves@redhat.com> * cp-valprint.c (cp_print_value_fields): Adjust calls to val_print_optimized_out. * jv-valprint.c (java_print_value_fields): Likewise. * p-valprint.c (pascal_object_print_value_fields): Likewise. * dwarf2loc.c (dwarf2_evaluate_loc_desc_full) <DWARF_VALUE_REGISTER>: If the register was not saved, return a new optimized out value. * findvar.c (address_from_register): Likewise. * frame.c (put_frame_register): Tweak error string to say the register was not saved, rather than optimized out. * infcmd.c (default_print_one_register_info): Adjust call to val_print_optimized_out. Use value_of_register instead of get_frame_register_value. * mi/mi-main.c (output_register): Use value_of_register instead of get_frame_register_value. * valprint.c (valprint_check_validity): Likewise. (val_print_optimized_out): New value parameter. If the value is lval_register, print <not saved> instead. (value_check_printable, val_print_scalar_formatted): Adjust calls to val_print_optimized_out. * valprint.h (val_print_optimized_out): New value parameter. * value.c (struct value) <optimized_out>: Extend comment. (error_value_optimized_out): New function. (require_not_optimized_out): Use it. Use a different string for lval_register values. * value.h (error_value_optimized_out): New declaration. * NEWS: Mention <not saved>. gdb/testsuite/ 2013-10-02 Pedro Alves <palves@redhat.com> * gdb.dwarf2/dw2-reg-undefined.exp <pattern_rax_rbx_rcx_print, pattern_rax_rbx_rcx_info>: Set to "<not saved>". * gdb.mi/mi-reg-undefined.exp (opt_out_pattern): Delete. (not_saved_pattern): New. Replace use of the former with the latter. gdb/doc/ 2013-10-02 Pedro Alves <palves@redhat.com> * gdb.texinfo (Registers): Expand description of saved registers in frames. Explain <not saved>.
2013-10-02 18:15:46 +02:00
if (value_optimized_out (value))
{
/* This function is used while computing a location expression.
Complain about the value being optimized out, rather than
letting value_as_address complain about some random register
the expression depends on not being saved. */
error_value_optimized_out ();
}
result = value_as_address (value);
release_value (value);
return result;
}
#if GDB_SELF_TEST
namespace selftests {
namespace findvar_tests {
/* Function to test copy_integer_to_size. Store SOURCE_VAL with size
SOURCE_SIZE to a buffer, making sure no sign extending happens at this
stage. Copy buffer to a new buffer using copy_integer_to_size. Extract
copied value and compare to DEST_VALU. Copy again with a signed
copy_integer_to_size and compare to DEST_VALS. Do everything for both
LITTLE and BIG target endians. Use unsigned values throughout to make
sure there are no implicit sign extensions. */
static void
do_cint_test (ULONGEST dest_valu, ULONGEST dest_vals, int dest_size,
ULONGEST src_val, int src_size)
{
for (int i = 0; i < 2 ; i++)
{
gdb_byte srcbuf[sizeof (ULONGEST)] = {};
gdb_byte destbuf[sizeof (ULONGEST)] = {};
enum bfd_endian byte_order = i ? BFD_ENDIAN_BIG : BFD_ENDIAN_LITTLE;
/* Fill the src buffer (and later the dest buffer) with non-zero junk,
to ensure zero extensions aren't hidden. */
memset (srcbuf, 0xaa, sizeof (srcbuf));
/* Store (and later extract) using unsigned to ensure there are no sign
extensions. */
store_unsigned_integer (srcbuf, src_size, byte_order, src_val);
/* Test unsigned. */
memset (destbuf, 0xaa, sizeof (destbuf));
copy_integer_to_size (destbuf, dest_size, srcbuf, src_size, false,
byte_order);
SELF_CHECK (dest_valu == extract_unsigned_integer (destbuf, dest_size,
byte_order));
/* Test signed. */
memset (destbuf, 0xaa, sizeof (destbuf));
copy_integer_to_size (destbuf, dest_size, srcbuf, src_size, true,
byte_order);
SELF_CHECK (dest_vals == extract_unsigned_integer (destbuf, dest_size,
byte_order));
}
}
static void
copy_integer_to_size_test ()
{
/* Destination is bigger than the source, which has the signed bit unset. */
do_cint_test (0x12345678, 0x12345678, 8, 0x12345678, 4);
do_cint_test (0x345678, 0x345678, 8, 0x12345678, 3);
/* Destination is bigger than the source, which has the signed bit set. */
do_cint_test (0xdeadbeef, 0xffffffffdeadbeef, 8, 0xdeadbeef, 4);
do_cint_test (0xadbeef, 0xffffffffffadbeef, 8, 0xdeadbeef, 3);
/* Destination is smaller than the source. */
do_cint_test (0x5678, 0x5678, 2, 0x12345678, 3);
do_cint_test (0xbeef, 0xbeef, 2, 0xdeadbeef, 3);
/* Destination and source are the same size. */
do_cint_test (0x8765432112345678, 0x8765432112345678, 8, 0x8765432112345678,
8);
do_cint_test (0x432112345678, 0x432112345678, 6, 0x8765432112345678, 6);
do_cint_test (0xfeedbeaddeadbeef, 0xfeedbeaddeadbeef, 8, 0xfeedbeaddeadbeef,
8);
do_cint_test (0xbeaddeadbeef, 0xbeaddeadbeef, 6, 0xfeedbeaddeadbeef, 6);
/* Destination is bigger than the source. Source is bigger than 32bits. */
do_cint_test (0x3412345678, 0x3412345678, 8, 0x3412345678, 6);
do_cint_test (0xff12345678, 0xff12345678, 8, 0xff12345678, 6);
do_cint_test (0x432112345678, 0x432112345678, 8, 0x8765432112345678, 6);
do_cint_test (0xff2112345678, 0xffffff2112345678, 8, 0xffffff2112345678, 6);
}
} // namespace findvar_test
} // namespace selftests
#endif
gdb: add back declarations for _initialize functions I'd like to enable the -Wmissing-declarations warning. However, it warns for every _initialize function, for example: CXX dcache.o /home/smarchi/src/binutils-gdb/gdb/dcache.c: In function ‘void _initialize_dcache()’: /home/smarchi/src/binutils-gdb/gdb/dcache.c:688:1: error: no previous declaration for ‘void _initialize_dcache()’ [-Werror=missing-declarations] _initialize_dcache (void) ^~~~~~~~~~~~~~~~~~ The only practical way forward I found is to add back the declarations, which were removed by this commit: commit 481695ed5f6e0a8a9c9c50bfac1cdd2b3151e6c9 Author: John Baldwin <jhb@FreeBSD.org> Date: Sat Sep 9 11:02:37 2017 -0700 Remove unnecessary function prototypes. I don't think it's a big problem to have the declarations for these functions, but if anybody has a better solution for this, I'll be happy to use it. gdb/ChangeLog: * aarch64-fbsd-nat.c (_initialize_aarch64_fbsd_nat): Add declaration. * aarch64-fbsd-tdep.c (_initialize_aarch64_fbsd_tdep): Add declaration. * aarch64-linux-nat.c (_initialize_aarch64_linux_nat): Add declaration. * aarch64-linux-tdep.c (_initialize_aarch64_linux_tdep): Add declaration. * aarch64-newlib-tdep.c (_initialize_aarch64_newlib_tdep): Add declaration. * aarch64-tdep.c (_initialize_aarch64_tdep): Add declaration. * ada-exp.y (_initialize_ada_exp): Add declaration. * ada-lang.c (_initialize_ada_language): Add declaration. * ada-tasks.c (_initialize_tasks): Add declaration. * agent.c (_initialize_agent): Add declaration. * aix-thread.c (_initialize_aix_thread): Add declaration. * alpha-bsd-nat.c (_initialize_alphabsd_nat): Add declaration. * alpha-linux-nat.c (_initialize_alpha_linux_nat): Add declaration. * alpha-linux-tdep.c (_initialize_alpha_linux_tdep): Add declaration. * alpha-nbsd-tdep.c (_initialize_alphanbsd_tdep): Add declaration. * alpha-obsd-tdep.c (_initialize_alphaobsd_tdep): Add declaration. * alpha-tdep.c (_initialize_alpha_tdep): Add declaration. * amd64-darwin-tdep.c (_initialize_amd64_darwin_tdep): Add declaration. * amd64-dicos-tdep.c (_initialize_amd64_dicos_tdep): Add declaration. * amd64-fbsd-nat.c (_initialize_amd64fbsd_nat): Add declaration. * amd64-fbsd-tdep.c (_initialize_amd64fbsd_tdep): Add declaration. * amd64-linux-nat.c (_initialize_amd64_linux_nat): Add declaration. * amd64-linux-tdep.c (_initialize_amd64_linux_tdep): Add declaration. * amd64-nbsd-nat.c (_initialize_amd64nbsd_nat): Add declaration. * amd64-nbsd-tdep.c (_initialize_amd64nbsd_tdep): Add declaration. * amd64-obsd-nat.c (_initialize_amd64obsd_nat): Add declaration. * amd64-obsd-tdep.c (_initialize_amd64obsd_tdep): Add declaration. * amd64-sol2-tdep.c (_initialize_amd64_sol2_tdep): Add declaration. * amd64-tdep.c (_initialize_amd64_tdep): Add declaration. * amd64-windows-nat.c (_initialize_amd64_windows_nat): Add declaration. * amd64-windows-tdep.c (_initialize_amd64_windows_tdep): Add declaration. * annotate.c (_initialize_annotate): Add declaration. * arc-newlib-tdep.c (_initialize_arc_newlib_tdep): Add declaration. * arc-tdep.c (_initialize_arc_tdep): Add declaration. * arch-utils.c (_initialize_gdbarch_utils): Add declaration. * arm-fbsd-nat.c (_initialize_arm_fbsd_nat): Add declaration. * arm-fbsd-tdep.c (_initialize_arm_fbsd_tdep): Add declaration. * arm-linux-nat.c (_initialize_arm_linux_nat): Add declaration. * arm-linux-tdep.c (_initialize_arm_linux_tdep): Add declaration. * arm-nbsd-nat.c (_initialize_arm_netbsd_nat): Add declaration. * arm-nbsd-tdep.c (_initialize_arm_netbsd_tdep): Add declaration. * arm-obsd-tdep.c (_initialize_armobsd_tdep): Add declaration. * arm-pikeos-tdep.c (_initialize_arm_pikeos_tdep): Add declaration. * arm-symbian-tdep.c (_initialize_arm_symbian_tdep): Add declaration. * arm-tdep.c (_initialize_arm_tdep): Add declaration. * arm-wince-tdep.c (_initialize_arm_wince_tdep): Add declaration. * auto-load.c (_initialize_auto_load): Add declaration. * auxv.c (_initialize_auxv): Add declaration. * avr-tdep.c (_initialize_avr_tdep): Add declaration. * ax-gdb.c (_initialize_ax_gdb): Add declaration. * bfin-linux-tdep.c (_initialize_bfin_linux_tdep): Add declaration. * bfin-tdep.c (_initialize_bfin_tdep): Add declaration. * break-catch-sig.c (_initialize_break_catch_sig): Add declaration. * break-catch-syscall.c (_initialize_break_catch_syscall): Add declaration. * break-catch-throw.c (_initialize_break_catch_throw): Add declaration. * breakpoint.c (_initialize_breakpoint): Add declaration. * bsd-uthread.c (_initialize_bsd_uthread): Add declaration. * btrace.c (_initialize_btrace): Add declaration. * charset.c (_initialize_charset): Add declaration. * cli/cli-cmds.c (_initialize_cli_cmds): Add declaration. * cli/cli-dump.c (_initialize_cli_dump): Add declaration. * cli/cli-interp.c (_initialize_cli_interp): Add declaration. * cli/cli-logging.c (_initialize_cli_logging): Add declaration. * cli/cli-script.c (_initialize_cli_script): Add declaration. * cli/cli-style.c (_initialize_cli_style): Add declaration. * coff-pe-read.c (_initialize_coff_pe_read): Add declaration. * coffread.c (_initialize_coffread): Add declaration. * compile/compile-cplus-types.c (_initialize_compile_cplus_types): Add declaration. * compile/compile.c (_initialize_compile): Add declaration. * complaints.c (_initialize_complaints): Add declaration. * completer.c (_initialize_completer): Add declaration. * copying.c (_initialize_copying): Add declaration. * corefile.c (_initialize_core): Add declaration. * corelow.c (_initialize_corelow): Add declaration. * cp-abi.c (_initialize_cp_abi): Add declaration. * cp-namespace.c (_initialize_cp_namespace): Add declaration. * cp-support.c (_initialize_cp_support): Add declaration. * cp-valprint.c (_initialize_cp_valprint): Add declaration. * cris-linux-tdep.c (_initialize_cris_linux_tdep): Add declaration. * cris-tdep.c (_initialize_cris_tdep): Add declaration. * csky-linux-tdep.c (_initialize_csky_linux_tdep): Add declaration. * csky-tdep.c (_initialize_csky_tdep): Add declaration. * ctfread.c (_initialize_ctfread): Add declaration. * d-lang.c (_initialize_d_language): Add declaration. * darwin-nat-info.c (_initialize_darwin_info_commands): Add declaration. * darwin-nat.c (_initialize_darwin_nat): Add declaration. * dbxread.c (_initialize_dbxread): Add declaration. * dcache.c (_initialize_dcache): Add declaration. * disasm-selftests.c (_initialize_disasm_selftests): Add declaration. * disasm.c (_initialize_disasm): Add declaration. * dtrace-probe.c (_initialize_dtrace_probe): Add declaration. * dummy-frame.c (_initialize_dummy_frame): Add declaration. * dwarf-index-cache.c (_initialize_index_cache): Add declaration. * dwarf-index-write.c (_initialize_dwarf_index_write): Add declaration. * dwarf2-frame-tailcall.c (_initialize_tailcall_frame): Add declaration. * dwarf2-frame.c (_initialize_dwarf2_frame): Add declaration. * dwarf2expr.c (_initialize_dwarf2expr): Add declaration. * dwarf2loc.c (_initialize_dwarf2loc): Add declaration. * dwarf2read.c (_initialize_dwarf2_read): Add declaration. * elfread.c (_initialize_elfread): Add declaration. * exec.c (_initialize_exec): Add declaration. * extension.c (_initialize_extension): Add declaration. * f-lang.c (_initialize_f_language): Add declaration. * f-valprint.c (_initialize_f_valprint): Add declaration. * fbsd-nat.c (_initialize_fbsd_nat): Add declaration. * fbsd-tdep.c (_initialize_fbsd_tdep): Add declaration. * filesystem.c (_initialize_filesystem): Add declaration. * findcmd.c (_initialize_mem_search): Add declaration. * findvar.c (_initialize_findvar): Add declaration. * fork-child.c (_initialize_fork_child): Add declaration. * frame-base.c (_initialize_frame_base): Add declaration. * frame-unwind.c (_initialize_frame_unwind): Add declaration. * frame.c (_initialize_frame): Add declaration. * frv-linux-tdep.c (_initialize_frv_linux_tdep): Add declaration. * frv-tdep.c (_initialize_frv_tdep): Add declaration. * ft32-tdep.c (_initialize_ft32_tdep): Add declaration. * gcore.c (_initialize_gcore): Add declaration. * gdb-demangle.c (_initialize_gdb_demangle): Add declaration. * gdb_bfd.c (_initialize_gdb_bfd): Add declaration. * gdbarch-selftests.c (_initialize_gdbarch_selftests): Add declaration. * gdbarch.c (_initialize_gdbarch): Add declaration. * gdbtypes.c (_initialize_gdbtypes): Add declaration. * gnu-nat.c (_initialize_gnu_nat): Add declaration. * gnu-v2-abi.c (_initialize_gnu_v2_abi): Add declaration. * gnu-v3-abi.c (_initialize_gnu_v3_abi): Add declaration. * go-lang.c (_initialize_go_language): Add declaration. * go32-nat.c (_initialize_go32_nat): Add declaration. * guile/guile.c (_initialize_guile): Add declaration. * h8300-tdep.c (_initialize_h8300_tdep): Add declaration. * hppa-linux-nat.c (_initialize_hppa_linux_nat): Add declaration. * hppa-linux-tdep.c (_initialize_hppa_linux_tdep): Add declaration. * hppa-nbsd-nat.c (_initialize_hppanbsd_nat): Add declaration. * hppa-nbsd-tdep.c (_initialize_hppanbsd_tdep): Add declaration. * hppa-obsd-nat.c (_initialize_hppaobsd_nat): Add declaration. * hppa-obsd-tdep.c (_initialize_hppabsd_tdep): Add declaration. * hppa-tdep.c (_initialize_hppa_tdep): Add declaration. * i386-bsd-nat.c (_initialize_i386bsd_nat): Add declaration. * i386-cygwin-tdep.c (_initialize_i386_cygwin_tdep): Add declaration. * i386-darwin-nat.c (_initialize_i386_darwin_nat): Add declaration. * i386-darwin-tdep.c (_initialize_i386_darwin_tdep): Add declaration. * i386-dicos-tdep.c (_initialize_i386_dicos_tdep): Add declaration. * i386-fbsd-nat.c (_initialize_i386fbsd_nat): Add declaration. * i386-fbsd-tdep.c (_initialize_i386fbsd_tdep): Add declaration. * i386-gnu-nat.c (_initialize_i386gnu_nat): Add declaration. * i386-gnu-tdep.c (_initialize_i386gnu_tdep): Add declaration. * i386-go32-tdep.c (_initialize_i386_go32_tdep): Add declaration. * i386-linux-nat.c (_initialize_i386_linux_nat): Add declaration. * i386-linux-tdep.c (_initialize_i386_linux_tdep): Add declaration. * i386-nbsd-nat.c (_initialize_i386nbsd_nat): Add declaration. * i386-nbsd-tdep.c (_initialize_i386nbsd_tdep): Add declaration. * i386-nto-tdep.c (_initialize_i386nto_tdep): Add declaration. * i386-obsd-nat.c (_initialize_i386obsd_nat): Add declaration. * i386-obsd-tdep.c (_initialize_i386obsd_tdep): Add declaration. * i386-sol2-nat.c (_initialize_amd64_sol2_nat): Add declaration. * i386-sol2-tdep.c (_initialize_i386_sol2_tdep): Add declaration. * i386-tdep.c (_initialize_i386_tdep): Add declaration. * i386-windows-nat.c (_initialize_i386_windows_nat): Add declaration. * ia64-libunwind-tdep.c (_initialize_libunwind_frame): Add declaration. * ia64-linux-nat.c (_initialize_ia64_linux_nat): Add declaration. * ia64-linux-tdep.c (_initialize_ia64_linux_tdep): Add declaration. * ia64-tdep.c (_initialize_ia64_tdep): Add declaration. * ia64-vms-tdep.c (_initialize_ia64_vms_tdep): Add declaration. * infcall.c (_initialize_infcall): Add declaration. * infcmd.c (_initialize_infcmd): Add declaration. * inflow.c (_initialize_inflow): Add declaration. * infrun.c (_initialize_infrun): Add declaration. * interps.c (_initialize_interpreter): Add declaration. * iq2000-tdep.c (_initialize_iq2000_tdep): Add declaration. * jit.c (_initialize_jit): Add declaration. * language.c (_initialize_language): Add declaration. * linux-fork.c (_initialize_linux_fork): Add declaration. * linux-nat.c (_initialize_linux_nat): Add declaration. * linux-tdep.c (_initialize_linux_tdep): Add declaration. * linux-thread-db.c (_initialize_thread_db): Add declaration. * lm32-tdep.c (_initialize_lm32_tdep): Add declaration. * m2-lang.c (_initialize_m2_language): Add declaration. * m32c-tdep.c (_initialize_m32c_tdep): Add declaration. * m32r-linux-nat.c (_initialize_m32r_linux_nat): Add declaration. * m32r-linux-tdep.c (_initialize_m32r_linux_tdep): Add declaration. * m32r-tdep.c (_initialize_m32r_tdep): Add declaration. * m68hc11-tdep.c (_initialize_m68hc11_tdep): Add declaration. * m68k-bsd-nat.c (_initialize_m68kbsd_nat): Add declaration. * m68k-bsd-tdep.c (_initialize_m68kbsd_tdep): Add declaration. * m68k-linux-nat.c (_initialize_m68k_linux_nat): Add declaration. * m68k-linux-tdep.c (_initialize_m68k_linux_tdep): Add declaration. * m68k-tdep.c (_initialize_m68k_tdep): Add declaration. * machoread.c (_initialize_machoread): Add declaration. * macrocmd.c (_initialize_macrocmd): Add declaration. * macroscope.c (_initialize_macroscope): Add declaration. * maint-test-options.c (_initialize_maint_test_options): Add declaration. * maint-test-settings.c (_initialize_maint_test_settings): Add declaration. * maint.c (_initialize_maint_cmds): Add declaration. * mdebugread.c (_initialize_mdebugread): Add declaration. * memattr.c (_initialize_mem): Add declaration. * mep-tdep.c (_initialize_mep_tdep): Add declaration. * mi/mi-cmd-env.c (_initialize_mi_cmd_env): Add declaration. * mi/mi-cmds.c (_initialize_mi_cmds): Add declaration. * mi/mi-interp.c (_initialize_mi_interp): Add declaration. * mi/mi-main.c (_initialize_mi_main): Add declaration. * microblaze-linux-tdep.c (_initialize_microblaze_linux_tdep): Add declaration. * microblaze-tdep.c (_initialize_microblaze_tdep): Add declaration. * mips-fbsd-nat.c (_initialize_mips_fbsd_nat): Add declaration. * mips-fbsd-tdep.c (_initialize_mips_fbsd_tdep): Add declaration. * mips-linux-nat.c (_initialize_mips_linux_nat): Add declaration. * mips-linux-tdep.c (_initialize_mips_linux_tdep): Add declaration. * mips-nbsd-nat.c (_initialize_mipsnbsd_nat): Add declaration. * mips-nbsd-tdep.c (_initialize_mipsnbsd_tdep): Add declaration. * mips-sde-tdep.c (_initialize_mips_sde_tdep): Add declaration. * mips-tdep.c (_initialize_mips_tdep): Add declaration. * mips64-obsd-nat.c (_initialize_mips64obsd_nat): Add declaration. * mips64-obsd-tdep.c (_initialize_mips64obsd_tdep): Add declaration. * mipsread.c (_initialize_mipsread): Add declaration. * mn10300-linux-tdep.c (_initialize_mn10300_linux_tdep): Add declaration. * mn10300-tdep.c (_initialize_mn10300_tdep): Add declaration. * moxie-tdep.c (_initialize_moxie_tdep): Add declaration. * msp430-tdep.c (_initialize_msp430_tdep): Add declaration. * nds32-tdep.c (_initialize_nds32_tdep): Add declaration. * nios2-linux-tdep.c (_initialize_nios2_linux_tdep): Add declaration. * nios2-tdep.c (_initialize_nios2_tdep): Add declaration. * nto-procfs.c (_initialize_procfs): Add declaration. * objc-lang.c (_initialize_objc_language): Add declaration. * observable.c (_initialize_observer): Add declaration. * opencl-lang.c (_initialize_opencl_language): Add declaration. * or1k-linux-tdep.c (_initialize_or1k_linux_tdep): Add declaration. * or1k-tdep.c (_initialize_or1k_tdep): Add declaration. * osabi.c (_initialize_gdb_osabi): Add declaration. * osdata.c (_initialize_osdata): Add declaration. * p-valprint.c (_initialize_pascal_valprint): Add declaration. * parse.c (_initialize_parse): Add declaration. * ppc-fbsd-nat.c (_initialize_ppcfbsd_nat): Add declaration. * ppc-fbsd-tdep.c (_initialize_ppcfbsd_tdep): Add declaration. * ppc-linux-nat.c (_initialize_ppc_linux_nat): Add declaration. * ppc-linux-tdep.c (_initialize_ppc_linux_tdep): Add declaration. * ppc-nbsd-nat.c (_initialize_ppcnbsd_nat): Add declaration. * ppc-nbsd-tdep.c (_initialize_ppcnbsd_tdep): Add declaration. * ppc-obsd-nat.c (_initialize_ppcobsd_nat): Add declaration. * ppc-obsd-tdep.c (_initialize_ppcobsd_tdep): Add declaration. * printcmd.c (_initialize_printcmd): Add declaration. * probe.c (_initialize_probe): Add declaration. * proc-api.c (_initialize_proc_api): Add declaration. * proc-events.c (_initialize_proc_events): Add declaration. * proc-service.c (_initialize_proc_service): Add declaration. * procfs.c (_initialize_procfs): Add declaration. * producer.c (_initialize_producer): Add declaration. * psymtab.c (_initialize_psymtab): Add declaration. * python/python.c (_initialize_python): Add declaration. * ravenscar-thread.c (_initialize_ravenscar): Add declaration. * record-btrace.c (_initialize_record_btrace): Add declaration. * record-full.c (_initialize_record_full): Add declaration. * record.c (_initialize_record): Add declaration. * regcache-dump.c (_initialize_regcache_dump): Add declaration. * regcache.c (_initialize_regcache): Add declaration. * reggroups.c (_initialize_reggroup): Add declaration. * remote-notif.c (_initialize_notif): Add declaration. * remote-sim.c (_initialize_remote_sim): Add declaration. * remote.c (_initialize_remote): Add declaration. * reverse.c (_initialize_reverse): Add declaration. * riscv-fbsd-nat.c (_initialize_riscv_fbsd_nat): Add declaration. * riscv-fbsd-tdep.c (_initialize_riscv_fbsd_tdep): Add declaration. * riscv-linux-nat.c (_initialize_riscv_linux_nat): Add declaration. * riscv-linux-tdep.c (_initialize_riscv_linux_tdep): Add declaration. * riscv-tdep.c (_initialize_riscv_tdep): Add declaration. * rl78-tdep.c (_initialize_rl78_tdep): Add declaration. * rs6000-aix-tdep.c (_initialize_rs6000_aix_tdep): Add declaration. * rs6000-lynx178-tdep.c (_initialize_rs6000_lynx178_tdep): Add declaration. * rs6000-nat.c (_initialize_rs6000_nat): Add declaration. * rs6000-tdep.c (_initialize_rs6000_tdep): Add declaration. * run-on-main-thread.c (_initialize_run_on_main_thread): Add declaration. * rust-exp.y (_initialize_rust_exp): Add declaration. * rx-tdep.c (_initialize_rx_tdep): Add declaration. * s12z-tdep.c (_initialize_s12z_tdep): Add declaration. * s390-linux-nat.c (_initialize_s390_nat): Add declaration. * s390-linux-tdep.c (_initialize_s390_linux_tdep): Add declaration. * s390-tdep.c (_initialize_s390_tdep): Add declaration. * score-tdep.c (_initialize_score_tdep): Add declaration. * ser-go32.c (_initialize_ser_dos): Add declaration. * ser-mingw.c (_initialize_ser_windows): Add declaration. * ser-pipe.c (_initialize_ser_pipe): Add declaration. * ser-tcp.c (_initialize_ser_tcp): Add declaration. * ser-uds.c (_initialize_ser_socket): Add declaration. * ser-unix.c (_initialize_ser_hardwire): Add declaration. * serial.c (_initialize_serial): Add declaration. * sh-linux-tdep.c (_initialize_sh_linux_tdep): Add declaration. * sh-nbsd-nat.c (_initialize_shnbsd_nat): Add declaration. * sh-nbsd-tdep.c (_initialize_shnbsd_tdep): Add declaration. * sh-tdep.c (_initialize_sh_tdep): Add declaration. * skip.c (_initialize_step_skip): Add declaration. * sol-thread.c (_initialize_sol_thread): Add declaration. * solib-aix.c (_initialize_solib_aix): Add declaration. * solib-darwin.c (_initialize_darwin_solib): Add declaration. * solib-dsbt.c (_initialize_dsbt_solib): Add declaration. * solib-frv.c (_initialize_frv_solib): Add declaration. * solib-svr4.c (_initialize_svr4_solib): Add declaration. * solib-target.c (_initialize_solib_target): Add declaration. * solib.c (_initialize_solib): Add declaration. * source-cache.c (_initialize_source_cache): Add declaration. * source.c (_initialize_source): Add declaration. * sparc-linux-nat.c (_initialize_sparc_linux_nat): Add declaration. * sparc-linux-tdep.c (_initialize_sparc_linux_tdep): Add declaration. * sparc-nat.c (_initialize_sparc_nat): Add declaration. * sparc-nbsd-nat.c (_initialize_sparcnbsd_nat): Add declaration. * sparc-nbsd-tdep.c (_initialize_sparcnbsd_tdep): Add declaration. * sparc-obsd-tdep.c (_initialize_sparc32obsd_tdep): Add declaration. * sparc-sol2-tdep.c (_initialize_sparc_sol2_tdep): Add declaration. * sparc-tdep.c (_initialize_sparc_tdep): Add declaration. * sparc64-fbsd-nat.c (_initialize_sparc64fbsd_nat): Add declaration. * sparc64-fbsd-tdep.c (_initialize_sparc64fbsd_tdep): Add declaration. * sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Add declaration. * sparc64-linux-tdep.c (_initialize_sparc64_linux_tdep): Add declaration. * sparc64-nat.c (_initialize_sparc64_nat): Add declaration. * sparc64-nbsd-nat.c (_initialize_sparc64nbsd_nat): Add declaration. * sparc64-nbsd-tdep.c (_initialize_sparc64nbsd_tdep): Add declaration. * sparc64-obsd-nat.c (_initialize_sparc64obsd_nat): Add declaration. * sparc64-obsd-tdep.c (_initialize_sparc64obsd_tdep): Add declaration. * sparc64-sol2-tdep.c (_initialize_sparc64_sol2_tdep): Add declaration. * sparc64-tdep.c (_initialize_sparc64_adi_tdep): Add declaration. * stabsread.c (_initialize_stabsread): Add declaration. * stack.c (_initialize_stack): Add declaration. * stap-probe.c (_initialize_stap_probe): Add declaration. * std-regs.c (_initialize_frame_reg): Add declaration. * symfile-debug.c (_initialize_symfile_debug): Add declaration. * symfile-mem.c (_initialize_symfile_mem): Add declaration. * symfile.c (_initialize_symfile): Add declaration. * symmisc.c (_initialize_symmisc): Add declaration. * symtab.c (_initialize_symtab): Add declaration. * target.c (_initialize_target): Add declaration. * target-connection.c (_initialize_target_connection): Add declaration. * target-dcache.c (_initialize_target_dcache): Add declaration. * target-descriptions.c (_initialize_target_descriptions): Add declaration. * thread.c (_initialize_thread): Add declaration. * tic6x-linux-tdep.c (_initialize_tic6x_linux_tdep): Add declaration. * tic6x-tdep.c (_initialize_tic6x_tdep): Add declaration. * tilegx-linux-nat.c (_initialize_tile_linux_nat): Add declaration. * tilegx-linux-tdep.c (_initialize_tilegx_linux_tdep): Add declaration. * tilegx-tdep.c (_initialize_tilegx_tdep): Add declaration. * tracectf.c (_initialize_ctf): Add declaration. * tracefile-tfile.c (_initialize_tracefile_tfile): Add declaration. * tracefile.c (_initialize_tracefile): Add declaration. * tracepoint.c (_initialize_tracepoint): Add declaration. * tui/tui-hooks.c (_initialize_tui_hooks): Add declaration. * tui/tui-interp.c (_initialize_tui_interp): Add declaration. * tui/tui-layout.c (_initialize_tui_layout): Add declaration. * tui/tui-regs.c (_initialize_tui_regs): Add declaration. * tui/tui-stack.c (_initialize_tui_stack): Add declaration. * tui/tui-win.c (_initialize_tui_win): Add declaration. * tui/tui.c (_initialize_tui): Add declaration. * typeprint.c (_initialize_typeprint): Add declaration. * ui-style.c (_initialize_ui_style): Add declaration. * unittests/array-view-selftests.c (_initialize_array_view_selftests): Add declaration. * unittests/child-path-selftests.c (_initialize_child_path_selftests): Add declaration. * unittests/cli-utils-selftests.c (_initialize_cli_utils_selftests): Add declaration. * unittests/common-utils-selftests.c (_initialize_common_utils_selftests): Add declaration. * unittests/copy_bitwise-selftests.c (_initialize_copy_bitwise_utils_selftests): Add declaration. * unittests/environ-selftests.c (_initialize_environ_selftests): Add declaration. * unittests/filtered_iterator-selftests.c (_initialize_filtered_iterator_selftests): Add declaration. * unittests/format_pieces-selftests.c (_initialize_format_pieces_selftests): Add declaration. * unittests/function-view-selftests.c (_initialize_function_view_selftests): Add declaration. * unittests/help-doc-selftests.c (_initialize_help_doc_selftests): Add declaration. * unittests/lookup_name_info-selftests.c (_initialize_lookup_name_info_selftests): Add declaration. * unittests/main-thread-selftests.c (_initialize_main_thread_selftests): Add declaration. * unittests/memory-map-selftests.c (_initialize_memory_map_selftests): Add declaration. * unittests/memrange-selftests.c (_initialize_memrange_selftests): Add declaration. * unittests/mkdir-recursive-selftests.c (_initialize_mkdir_recursive_selftests): Add declaration. * unittests/observable-selftests.c (_initialize_observer_selftest): Add declaration. * unittests/offset-type-selftests.c (_initialize_offset_type_selftests): Add declaration. * unittests/optional-selftests.c (_initialize_optional_selftests): Add declaration. * unittests/parse-connection-spec-selftests.c (_initialize_parse_connection_spec_selftests): Add declaration. * unittests/rsp-low-selftests.c (_initialize_rsp_low_selftests): Add declaration. * unittests/scoped_fd-selftests.c (_initialize_scoped_fd_selftests): Add declaration. * unittests/scoped_mmap-selftests.c (_initialize_scoped_mmap_selftests): Add declaration. * unittests/scoped_restore-selftests.c (_initialize_scoped_restore_selftests): Add declaration. * unittests/string_view-selftests.c (_initialize_string_view_selftests): Add declaration. * unittests/style-selftests.c (_initialize_style_selftest): Add declaration. * unittests/tracepoint-selftests.c (_initialize_tracepoint_selftests): Add declaration. * unittests/tui-selftests.c (_initialize_tui_selftest): Add declaration. * unittests/unpack-selftests.c (_initialize_unpack_selftests): Add declaration. * unittests/utils-selftests.c (_initialize_utils_selftests): Add declaration. * unittests/vec-utils-selftests.c (_initialize_vec_utils_selftests): Add declaration. * unittests/xml-utils-selftests.c (_initialize_xml_utils): Add declaration. * user-regs.c (_initialize_user_regs): Add declaration. * utils.c (_initialize_utils): Add declaration. * v850-tdep.c (_initialize_v850_tdep): Add declaration. * valops.c (_initialize_valops): Add declaration. * valprint.c (_initialize_valprint): Add declaration. * value.c (_initialize_values): Add declaration. * varobj.c (_initialize_varobj): Add declaration. * vax-bsd-nat.c (_initialize_vaxbsd_nat): Add declaration. * vax-nbsd-tdep.c (_initialize_vaxnbsd_tdep): Add declaration. * vax-tdep.c (_initialize_vax_tdep): Add declaration. * windows-nat.c (_initialize_windows_nat): Add declaration. (_initialize_check_for_gdb_ini): Add declaration. (_initialize_loadable): Add declaration. * windows-tdep.c (_initialize_windows_tdep): Add declaration. * x86-bsd-nat.c (_initialize_x86_bsd_nat): Add declaration. * x86-linux-nat.c (_initialize_x86_linux_nat): Add declaration. * xcoffread.c (_initialize_xcoffread): Add declaration. * xml-support.c (_initialize_xml_support): Add declaration. * xstormy16-tdep.c (_initialize_xstormy16_tdep): Add declaration. * xtensa-linux-nat.c (_initialize_xtensa_linux_nat): Add declaration. * xtensa-linux-tdep.c (_initialize_xtensa_linux_tdep): Add declaration. * xtensa-tdep.c (_initialize_xtensa_tdep): Add declaration. Change-Id: I13eec7e0ed2b3c427377a7bdb055cf46da64def9
2020-01-13 20:01:38 +01:00
void _initialize_findvar ();
void
gdb: add back declarations for _initialize functions I'd like to enable the -Wmissing-declarations warning. However, it warns for every _initialize function, for example: CXX dcache.o /home/smarchi/src/binutils-gdb/gdb/dcache.c: In function ‘void _initialize_dcache()’: /home/smarchi/src/binutils-gdb/gdb/dcache.c:688:1: error: no previous declaration for ‘void _initialize_dcache()’ [-Werror=missing-declarations] _initialize_dcache (void) ^~~~~~~~~~~~~~~~~~ The only practical way forward I found is to add back the declarations, which were removed by this commit: commit 481695ed5f6e0a8a9c9c50bfac1cdd2b3151e6c9 Author: John Baldwin <jhb@FreeBSD.org> Date: Sat Sep 9 11:02:37 2017 -0700 Remove unnecessary function prototypes. I don't think it's a big problem to have the declarations for these functions, but if anybody has a better solution for this, I'll be happy to use it. gdb/ChangeLog: * aarch64-fbsd-nat.c (_initialize_aarch64_fbsd_nat): Add declaration. * aarch64-fbsd-tdep.c (_initialize_aarch64_fbsd_tdep): Add declaration. * aarch64-linux-nat.c (_initialize_aarch64_linux_nat): Add declaration. * aarch64-linux-tdep.c (_initialize_aarch64_linux_tdep): Add declaration. * aarch64-newlib-tdep.c (_initialize_aarch64_newlib_tdep): Add declaration. * aarch64-tdep.c (_initialize_aarch64_tdep): Add declaration. * ada-exp.y (_initialize_ada_exp): Add declaration. * ada-lang.c (_initialize_ada_language): Add declaration. * ada-tasks.c (_initialize_tasks): Add declaration. * agent.c (_initialize_agent): Add declaration. * aix-thread.c (_initialize_aix_thread): Add declaration. * alpha-bsd-nat.c (_initialize_alphabsd_nat): Add declaration. * alpha-linux-nat.c (_initialize_alpha_linux_nat): Add declaration. * alpha-linux-tdep.c (_initialize_alpha_linux_tdep): Add declaration. * alpha-nbsd-tdep.c (_initialize_alphanbsd_tdep): Add declaration. * alpha-obsd-tdep.c (_initialize_alphaobsd_tdep): Add declaration. * alpha-tdep.c (_initialize_alpha_tdep): Add declaration. * amd64-darwin-tdep.c (_initialize_amd64_darwin_tdep): Add declaration. * amd64-dicos-tdep.c (_initialize_amd64_dicos_tdep): Add declaration. * amd64-fbsd-nat.c (_initialize_amd64fbsd_nat): Add declaration. * amd64-fbsd-tdep.c (_initialize_amd64fbsd_tdep): Add declaration. * amd64-linux-nat.c (_initialize_amd64_linux_nat): Add declaration. * amd64-linux-tdep.c (_initialize_amd64_linux_tdep): Add declaration. * amd64-nbsd-nat.c (_initialize_amd64nbsd_nat): Add declaration. * amd64-nbsd-tdep.c (_initialize_amd64nbsd_tdep): Add declaration. * amd64-obsd-nat.c (_initialize_amd64obsd_nat): Add declaration. * amd64-obsd-tdep.c (_initialize_amd64obsd_tdep): Add declaration. * amd64-sol2-tdep.c (_initialize_amd64_sol2_tdep): Add declaration. * amd64-tdep.c (_initialize_amd64_tdep): Add declaration. * amd64-windows-nat.c (_initialize_amd64_windows_nat): Add declaration. * amd64-windows-tdep.c (_initialize_amd64_windows_tdep): Add declaration. * annotate.c (_initialize_annotate): Add declaration. * arc-newlib-tdep.c (_initialize_arc_newlib_tdep): Add declaration. * arc-tdep.c (_initialize_arc_tdep): Add declaration. * arch-utils.c (_initialize_gdbarch_utils): Add declaration. * arm-fbsd-nat.c (_initialize_arm_fbsd_nat): Add declaration. * arm-fbsd-tdep.c (_initialize_arm_fbsd_tdep): Add declaration. * arm-linux-nat.c (_initialize_arm_linux_nat): Add declaration. * arm-linux-tdep.c (_initialize_arm_linux_tdep): Add declaration. * arm-nbsd-nat.c (_initialize_arm_netbsd_nat): Add declaration. * arm-nbsd-tdep.c (_initialize_arm_netbsd_tdep): Add declaration. * arm-obsd-tdep.c (_initialize_armobsd_tdep): Add declaration. * arm-pikeos-tdep.c (_initialize_arm_pikeos_tdep): Add declaration. * arm-symbian-tdep.c (_initialize_arm_symbian_tdep): Add declaration. * arm-tdep.c (_initialize_arm_tdep): Add declaration. * arm-wince-tdep.c (_initialize_arm_wince_tdep): Add declaration. * auto-load.c (_initialize_auto_load): Add declaration. * auxv.c (_initialize_auxv): Add declaration. * avr-tdep.c (_initialize_avr_tdep): Add declaration. * ax-gdb.c (_initialize_ax_gdb): Add declaration. * bfin-linux-tdep.c (_initialize_bfin_linux_tdep): Add declaration. * bfin-tdep.c (_initialize_bfin_tdep): Add declaration. * break-catch-sig.c (_initialize_break_catch_sig): Add declaration. * break-catch-syscall.c (_initialize_break_catch_syscall): Add declaration. * break-catch-throw.c (_initialize_break_catch_throw): Add declaration. * breakpoint.c (_initialize_breakpoint): Add declaration. * bsd-uthread.c (_initialize_bsd_uthread): Add declaration. * btrace.c (_initialize_btrace): Add declaration. * charset.c (_initialize_charset): Add declaration. * cli/cli-cmds.c (_initialize_cli_cmds): Add declaration. * cli/cli-dump.c (_initialize_cli_dump): Add declaration. * cli/cli-interp.c (_initialize_cli_interp): Add declaration. * cli/cli-logging.c (_initialize_cli_logging): Add declaration. * cli/cli-script.c (_initialize_cli_script): Add declaration. * cli/cli-style.c (_initialize_cli_style): Add declaration. * coff-pe-read.c (_initialize_coff_pe_read): Add declaration. * coffread.c (_initialize_coffread): Add declaration. * compile/compile-cplus-types.c (_initialize_compile_cplus_types): Add declaration. * compile/compile.c (_initialize_compile): Add declaration. * complaints.c (_initialize_complaints): Add declaration. * completer.c (_initialize_completer): Add declaration. * copying.c (_initialize_copying): Add declaration. * corefile.c (_initialize_core): Add declaration. * corelow.c (_initialize_corelow): Add declaration. * cp-abi.c (_initialize_cp_abi): Add declaration. * cp-namespace.c (_initialize_cp_namespace): Add declaration. * cp-support.c (_initialize_cp_support): Add declaration. * cp-valprint.c (_initialize_cp_valprint): Add declaration. * cris-linux-tdep.c (_initialize_cris_linux_tdep): Add declaration. * cris-tdep.c (_initialize_cris_tdep): Add declaration. * csky-linux-tdep.c (_initialize_csky_linux_tdep): Add declaration. * csky-tdep.c (_initialize_csky_tdep): Add declaration. * ctfread.c (_initialize_ctfread): Add declaration. * d-lang.c (_initialize_d_language): Add declaration. * darwin-nat-info.c (_initialize_darwin_info_commands): Add declaration. * darwin-nat.c (_initialize_darwin_nat): Add declaration. * dbxread.c (_initialize_dbxread): Add declaration. * dcache.c (_initialize_dcache): Add declaration. * disasm-selftests.c (_initialize_disasm_selftests): Add declaration. * disasm.c (_initialize_disasm): Add declaration. * dtrace-probe.c (_initialize_dtrace_probe): Add declaration. * dummy-frame.c (_initialize_dummy_frame): Add declaration. * dwarf-index-cache.c (_initialize_index_cache): Add declaration. * dwarf-index-write.c (_initialize_dwarf_index_write): Add declaration. * dwarf2-frame-tailcall.c (_initialize_tailcall_frame): Add declaration. * dwarf2-frame.c (_initialize_dwarf2_frame): Add declaration. * dwarf2expr.c (_initialize_dwarf2expr): Add declaration. * dwarf2loc.c (_initialize_dwarf2loc): Add declaration. * dwarf2read.c (_initialize_dwarf2_read): Add declaration. * elfread.c (_initialize_elfread): Add declaration. * exec.c (_initialize_exec): Add declaration. * extension.c (_initialize_extension): Add declaration. * f-lang.c (_initialize_f_language): Add declaration. * f-valprint.c (_initialize_f_valprint): Add declaration. * fbsd-nat.c (_initialize_fbsd_nat): Add declaration. * fbsd-tdep.c (_initialize_fbsd_tdep): Add declaration. * filesystem.c (_initialize_filesystem): Add declaration. * findcmd.c (_initialize_mem_search): Add declaration. * findvar.c (_initialize_findvar): Add declaration. * fork-child.c (_initialize_fork_child): Add declaration. * frame-base.c (_initialize_frame_base): Add declaration. * frame-unwind.c (_initialize_frame_unwind): Add declaration. * frame.c (_initialize_frame): Add declaration. * frv-linux-tdep.c (_initialize_frv_linux_tdep): Add declaration. * frv-tdep.c (_initialize_frv_tdep): Add declaration. * ft32-tdep.c (_initialize_ft32_tdep): Add declaration. * gcore.c (_initialize_gcore): Add declaration. * gdb-demangle.c (_initialize_gdb_demangle): Add declaration. * gdb_bfd.c (_initialize_gdb_bfd): Add declaration. * gdbarch-selftests.c (_initialize_gdbarch_selftests): Add declaration. * gdbarch.c (_initialize_gdbarch): Add declaration. * gdbtypes.c (_initialize_gdbtypes): Add declaration. * gnu-nat.c (_initialize_gnu_nat): Add declaration. * gnu-v2-abi.c (_initialize_gnu_v2_abi): Add declaration. * gnu-v3-abi.c (_initialize_gnu_v3_abi): Add declaration. * go-lang.c (_initialize_go_language): Add declaration. * go32-nat.c (_initialize_go32_nat): Add declaration. * guile/guile.c (_initialize_guile): Add declaration. * h8300-tdep.c (_initialize_h8300_tdep): Add declaration. * hppa-linux-nat.c (_initialize_hppa_linux_nat): Add declaration. * hppa-linux-tdep.c (_initialize_hppa_linux_tdep): Add declaration. * hppa-nbsd-nat.c (_initialize_hppanbsd_nat): Add declaration. * hppa-nbsd-tdep.c (_initialize_hppanbsd_tdep): Add declaration. * hppa-obsd-nat.c (_initialize_hppaobsd_nat): Add declaration. * hppa-obsd-tdep.c (_initialize_hppabsd_tdep): Add declaration. * hppa-tdep.c (_initialize_hppa_tdep): Add declaration. * i386-bsd-nat.c (_initialize_i386bsd_nat): Add declaration. * i386-cygwin-tdep.c (_initialize_i386_cygwin_tdep): Add declaration. * i386-darwin-nat.c (_initialize_i386_darwin_nat): Add declaration. * i386-darwin-tdep.c (_initialize_i386_darwin_tdep): Add declaration. * i386-dicos-tdep.c (_initialize_i386_dicos_tdep): Add declaration. * i386-fbsd-nat.c (_initialize_i386fbsd_nat): Add declaration. * i386-fbsd-tdep.c (_initialize_i386fbsd_tdep): Add declaration. * i386-gnu-nat.c (_initialize_i386gnu_nat): Add declaration. * i386-gnu-tdep.c (_initialize_i386gnu_tdep): Add declaration. * i386-go32-tdep.c (_initialize_i386_go32_tdep): Add declaration. * i386-linux-nat.c (_initialize_i386_linux_nat): Add declaration. * i386-linux-tdep.c (_initialize_i386_linux_tdep): Add declaration. * i386-nbsd-nat.c (_initialize_i386nbsd_nat): Add declaration. * i386-nbsd-tdep.c (_initialize_i386nbsd_tdep): Add declaration. * i386-nto-tdep.c (_initialize_i386nto_tdep): Add declaration. * i386-obsd-nat.c (_initialize_i386obsd_nat): Add declaration. * i386-obsd-tdep.c (_initialize_i386obsd_tdep): Add declaration. * i386-sol2-nat.c (_initialize_amd64_sol2_nat): Add declaration. * i386-sol2-tdep.c (_initialize_i386_sol2_tdep): Add declaration. * i386-tdep.c (_initialize_i386_tdep): Add declaration. * i386-windows-nat.c (_initialize_i386_windows_nat): Add declaration. * ia64-libunwind-tdep.c (_initialize_libunwind_frame): Add declaration. * ia64-linux-nat.c (_initialize_ia64_linux_nat): Add declaration. * ia64-linux-tdep.c (_initialize_ia64_linux_tdep): Add declaration. * ia64-tdep.c (_initialize_ia64_tdep): Add declaration. * ia64-vms-tdep.c (_initialize_ia64_vms_tdep): Add declaration. * infcall.c (_initialize_infcall): Add declaration. * infcmd.c (_initialize_infcmd): Add declaration. * inflow.c (_initialize_inflow): Add declaration. * infrun.c (_initialize_infrun): Add declaration. * interps.c (_initialize_interpreter): Add declaration. * iq2000-tdep.c (_initialize_iq2000_tdep): Add declaration. * jit.c (_initialize_jit): Add declaration. * language.c (_initialize_language): Add declaration. * linux-fork.c (_initialize_linux_fork): Add declaration. * linux-nat.c (_initialize_linux_nat): Add declaration. * linux-tdep.c (_initialize_linux_tdep): Add declaration. * linux-thread-db.c (_initialize_thread_db): Add declaration. * lm32-tdep.c (_initialize_lm32_tdep): Add declaration. * m2-lang.c (_initialize_m2_language): Add declaration. * m32c-tdep.c (_initialize_m32c_tdep): Add declaration. * m32r-linux-nat.c (_initialize_m32r_linux_nat): Add declaration. * m32r-linux-tdep.c (_initialize_m32r_linux_tdep): Add declaration. * m32r-tdep.c (_initialize_m32r_tdep): Add declaration. * m68hc11-tdep.c (_initialize_m68hc11_tdep): Add declaration. * m68k-bsd-nat.c (_initialize_m68kbsd_nat): Add declaration. * m68k-bsd-tdep.c (_initialize_m68kbsd_tdep): Add declaration. * m68k-linux-nat.c (_initialize_m68k_linux_nat): Add declaration. * m68k-linux-tdep.c (_initialize_m68k_linux_tdep): Add declaration. * m68k-tdep.c (_initialize_m68k_tdep): Add declaration. * machoread.c (_initialize_machoread): Add declaration. * macrocmd.c (_initialize_macrocmd): Add declaration. * macroscope.c (_initialize_macroscope): Add declaration. * maint-test-options.c (_initialize_maint_test_options): Add declaration. * maint-test-settings.c (_initialize_maint_test_settings): Add declaration. * maint.c (_initialize_maint_cmds): Add declaration. * mdebugread.c (_initialize_mdebugread): Add declaration. * memattr.c (_initialize_mem): Add declaration. * mep-tdep.c (_initialize_mep_tdep): Add declaration. * mi/mi-cmd-env.c (_initialize_mi_cmd_env): Add declaration. * mi/mi-cmds.c (_initialize_mi_cmds): Add declaration. * mi/mi-interp.c (_initialize_mi_interp): Add declaration. * mi/mi-main.c (_initialize_mi_main): Add declaration. * microblaze-linux-tdep.c (_initialize_microblaze_linux_tdep): Add declaration. * microblaze-tdep.c (_initialize_microblaze_tdep): Add declaration. * mips-fbsd-nat.c (_initialize_mips_fbsd_nat): Add declaration. * mips-fbsd-tdep.c (_initialize_mips_fbsd_tdep): Add declaration. * mips-linux-nat.c (_initialize_mips_linux_nat): Add declaration. * mips-linux-tdep.c (_initialize_mips_linux_tdep): Add declaration. * mips-nbsd-nat.c (_initialize_mipsnbsd_nat): Add declaration. * mips-nbsd-tdep.c (_initialize_mipsnbsd_tdep): Add declaration. * mips-sde-tdep.c (_initialize_mips_sde_tdep): Add declaration. * mips-tdep.c (_initialize_mips_tdep): Add declaration. * mips64-obsd-nat.c (_initialize_mips64obsd_nat): Add declaration. * mips64-obsd-tdep.c (_initialize_mips64obsd_tdep): Add declaration. * mipsread.c (_initialize_mipsread): Add declaration. * mn10300-linux-tdep.c (_initialize_mn10300_linux_tdep): Add declaration. * mn10300-tdep.c (_initialize_mn10300_tdep): Add declaration. * moxie-tdep.c (_initialize_moxie_tdep): Add declaration. * msp430-tdep.c (_initialize_msp430_tdep): Add declaration. * nds32-tdep.c (_initialize_nds32_tdep): Add declaration. * nios2-linux-tdep.c (_initialize_nios2_linux_tdep): Add declaration. * nios2-tdep.c (_initialize_nios2_tdep): Add declaration. * nto-procfs.c (_initialize_procfs): Add declaration. * objc-lang.c (_initialize_objc_language): Add declaration. * observable.c (_initialize_observer): Add declaration. * opencl-lang.c (_initialize_opencl_language): Add declaration. * or1k-linux-tdep.c (_initialize_or1k_linux_tdep): Add declaration. * or1k-tdep.c (_initialize_or1k_tdep): Add declaration. * osabi.c (_initialize_gdb_osabi): Add declaration. * osdata.c (_initialize_osdata): Add declaration. * p-valprint.c (_initialize_pascal_valprint): Add declaration. * parse.c (_initialize_parse): Add declaration. * ppc-fbsd-nat.c (_initialize_ppcfbsd_nat): Add declaration. * ppc-fbsd-tdep.c (_initialize_ppcfbsd_tdep): Add declaration. * ppc-linux-nat.c (_initialize_ppc_linux_nat): Add declaration. * ppc-linux-tdep.c (_initialize_ppc_linux_tdep): Add declaration. * ppc-nbsd-nat.c (_initialize_ppcnbsd_nat): Add declaration. * ppc-nbsd-tdep.c (_initialize_ppcnbsd_tdep): Add declaration. * ppc-obsd-nat.c (_initialize_ppcobsd_nat): Add declaration. * ppc-obsd-tdep.c (_initialize_ppcobsd_tdep): Add declaration. * printcmd.c (_initialize_printcmd): Add declaration. * probe.c (_initialize_probe): Add declaration. * proc-api.c (_initialize_proc_api): Add declaration. * proc-events.c (_initialize_proc_events): Add declaration. * proc-service.c (_initialize_proc_service): Add declaration. * procfs.c (_initialize_procfs): Add declaration. * producer.c (_initialize_producer): Add declaration. * psymtab.c (_initialize_psymtab): Add declaration. * python/python.c (_initialize_python): Add declaration. * ravenscar-thread.c (_initialize_ravenscar): Add declaration. * record-btrace.c (_initialize_record_btrace): Add declaration. * record-full.c (_initialize_record_full): Add declaration. * record.c (_initialize_record): Add declaration. * regcache-dump.c (_initialize_regcache_dump): Add declaration. * regcache.c (_initialize_regcache): Add declaration. * reggroups.c (_initialize_reggroup): Add declaration. * remote-notif.c (_initialize_notif): Add declaration. * remote-sim.c (_initialize_remote_sim): Add declaration. * remote.c (_initialize_remote): Add declaration. * reverse.c (_initialize_reverse): Add declaration. * riscv-fbsd-nat.c (_initialize_riscv_fbsd_nat): Add declaration. * riscv-fbsd-tdep.c (_initialize_riscv_fbsd_tdep): Add declaration. * riscv-linux-nat.c (_initialize_riscv_linux_nat): Add declaration. * riscv-linux-tdep.c (_initialize_riscv_linux_tdep): Add declaration. * riscv-tdep.c (_initialize_riscv_tdep): Add declaration. * rl78-tdep.c (_initialize_rl78_tdep): Add declaration. * rs6000-aix-tdep.c (_initialize_rs6000_aix_tdep): Add declaration. * rs6000-lynx178-tdep.c (_initialize_rs6000_lynx178_tdep): Add declaration. * rs6000-nat.c (_initialize_rs6000_nat): Add declaration. * rs6000-tdep.c (_initialize_rs6000_tdep): Add declaration. * run-on-main-thread.c (_initialize_run_on_main_thread): Add declaration. * rust-exp.y (_initialize_rust_exp): Add declaration. * rx-tdep.c (_initialize_rx_tdep): Add declaration. * s12z-tdep.c (_initialize_s12z_tdep): Add declaration. * s390-linux-nat.c (_initialize_s390_nat): Add declaration. * s390-linux-tdep.c (_initialize_s390_linux_tdep): Add declaration. * s390-tdep.c (_initialize_s390_tdep): Add declaration. * score-tdep.c (_initialize_score_tdep): Add declaration. * ser-go32.c (_initialize_ser_dos): Add declaration. * ser-mingw.c (_initialize_ser_windows): Add declaration. * ser-pipe.c (_initialize_ser_pipe): Add declaration. * ser-tcp.c (_initialize_ser_tcp): Add declaration. * ser-uds.c (_initialize_ser_socket): Add declaration. * ser-unix.c (_initialize_ser_hardwire): Add declaration. * serial.c (_initialize_serial): Add declaration. * sh-linux-tdep.c (_initialize_sh_linux_tdep): Add declaration. * sh-nbsd-nat.c (_initialize_shnbsd_nat): Add declaration. * sh-nbsd-tdep.c (_initialize_shnbsd_tdep): Add declaration. * sh-tdep.c (_initialize_sh_tdep): Add declaration. * skip.c (_initialize_step_skip): Add declaration. * sol-thread.c (_initialize_sol_thread): Add declaration. * solib-aix.c (_initialize_solib_aix): Add declaration. * solib-darwin.c (_initialize_darwin_solib): Add declaration. * solib-dsbt.c (_initialize_dsbt_solib): Add declaration. * solib-frv.c (_initialize_frv_solib): Add declaration. * solib-svr4.c (_initialize_svr4_solib): Add declaration. * solib-target.c (_initialize_solib_target): Add declaration. * solib.c (_initialize_solib): Add declaration. * source-cache.c (_initialize_source_cache): Add declaration. * source.c (_initialize_source): Add declaration. * sparc-linux-nat.c (_initialize_sparc_linux_nat): Add declaration. * sparc-linux-tdep.c (_initialize_sparc_linux_tdep): Add declaration. * sparc-nat.c (_initialize_sparc_nat): Add declaration. * sparc-nbsd-nat.c (_initialize_sparcnbsd_nat): Add declaration. * sparc-nbsd-tdep.c (_initialize_sparcnbsd_tdep): Add declaration. * sparc-obsd-tdep.c (_initialize_sparc32obsd_tdep): Add declaration. * sparc-sol2-tdep.c (_initialize_sparc_sol2_tdep): Add declaration. * sparc-tdep.c (_initialize_sparc_tdep): Add declaration. * sparc64-fbsd-nat.c (_initialize_sparc64fbsd_nat): Add declaration. * sparc64-fbsd-tdep.c (_initialize_sparc64fbsd_tdep): Add declaration. * sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Add declaration. * sparc64-linux-tdep.c (_initialize_sparc64_linux_tdep): Add declaration. * sparc64-nat.c (_initialize_sparc64_nat): Add declaration. * sparc64-nbsd-nat.c (_initialize_sparc64nbsd_nat): Add declaration. * sparc64-nbsd-tdep.c (_initialize_sparc64nbsd_tdep): Add declaration. * sparc64-obsd-nat.c (_initialize_sparc64obsd_nat): Add declaration. * sparc64-obsd-tdep.c (_initialize_sparc64obsd_tdep): Add declaration. * sparc64-sol2-tdep.c (_initialize_sparc64_sol2_tdep): Add declaration. * sparc64-tdep.c (_initialize_sparc64_adi_tdep): Add declaration. * stabsread.c (_initialize_stabsread): Add declaration. * stack.c (_initialize_stack): Add declaration. * stap-probe.c (_initialize_stap_probe): Add declaration. * std-regs.c (_initialize_frame_reg): Add declaration. * symfile-debug.c (_initialize_symfile_debug): Add declaration. * symfile-mem.c (_initialize_symfile_mem): Add declaration. * symfile.c (_initialize_symfile): Add declaration. * symmisc.c (_initialize_symmisc): Add declaration. * symtab.c (_initialize_symtab): Add declaration. * target.c (_initialize_target): Add declaration. * target-connection.c (_initialize_target_connection): Add declaration. * target-dcache.c (_initialize_target_dcache): Add declaration. * target-descriptions.c (_initialize_target_descriptions): Add declaration. * thread.c (_initialize_thread): Add declaration. * tic6x-linux-tdep.c (_initialize_tic6x_linux_tdep): Add declaration. * tic6x-tdep.c (_initialize_tic6x_tdep): Add declaration. * tilegx-linux-nat.c (_initialize_tile_linux_nat): Add declaration. * tilegx-linux-tdep.c (_initialize_tilegx_linux_tdep): Add declaration. * tilegx-tdep.c (_initialize_tilegx_tdep): Add declaration. * tracectf.c (_initialize_ctf): Add declaration. * tracefile-tfile.c (_initialize_tracefile_tfile): Add declaration. * tracefile.c (_initialize_tracefile): Add declaration. * tracepoint.c (_initialize_tracepoint): Add declaration. * tui/tui-hooks.c (_initialize_tui_hooks): Add declaration. * tui/tui-interp.c (_initialize_tui_interp): Add declaration. * tui/tui-layout.c (_initialize_tui_layout): Add declaration. * tui/tui-regs.c (_initialize_tui_regs): Add declaration. * tui/tui-stack.c (_initialize_tui_stack): Add declaration. * tui/tui-win.c (_initialize_tui_win): Add declaration. * tui/tui.c (_initialize_tui): Add declaration. * typeprint.c (_initialize_typeprint): Add declaration. * ui-style.c (_initialize_ui_style): Add declaration. * unittests/array-view-selftests.c (_initialize_array_view_selftests): Add declaration. * unittests/child-path-selftests.c (_initialize_child_path_selftests): Add declaration. * unittests/cli-utils-selftests.c (_initialize_cli_utils_selftests): Add declaration. * unittests/common-utils-selftests.c (_initialize_common_utils_selftests): Add declaration. * unittests/copy_bitwise-selftests.c (_initialize_copy_bitwise_utils_selftests): Add declaration. * unittests/environ-selftests.c (_initialize_environ_selftests): Add declaration. * unittests/filtered_iterator-selftests.c (_initialize_filtered_iterator_selftests): Add declaration. * unittests/format_pieces-selftests.c (_initialize_format_pieces_selftests): Add declaration. * unittests/function-view-selftests.c (_initialize_function_view_selftests): Add declaration. * unittests/help-doc-selftests.c (_initialize_help_doc_selftests): Add declaration. * unittests/lookup_name_info-selftests.c (_initialize_lookup_name_info_selftests): Add declaration. * unittests/main-thread-selftests.c (_initialize_main_thread_selftests): Add declaration. * unittests/memory-map-selftests.c (_initialize_memory_map_selftests): Add declaration. * unittests/memrange-selftests.c (_initialize_memrange_selftests): Add declaration. * unittests/mkdir-recursive-selftests.c (_initialize_mkdir_recursive_selftests): Add declaration. * unittests/observable-selftests.c (_initialize_observer_selftest): Add declaration. * unittests/offset-type-selftests.c (_initialize_offset_type_selftests): Add declaration. * unittests/optional-selftests.c (_initialize_optional_selftests): Add declaration. * unittests/parse-connection-spec-selftests.c (_initialize_parse_connection_spec_selftests): Add declaration. * unittests/rsp-low-selftests.c (_initialize_rsp_low_selftests): Add declaration. * unittests/scoped_fd-selftests.c (_initialize_scoped_fd_selftests): Add declaration. * unittests/scoped_mmap-selftests.c (_initialize_scoped_mmap_selftests): Add declaration. * unittests/scoped_restore-selftests.c (_initialize_scoped_restore_selftests): Add declaration. * unittests/string_view-selftests.c (_initialize_string_view_selftests): Add declaration. * unittests/style-selftests.c (_initialize_style_selftest): Add declaration. * unittests/tracepoint-selftests.c (_initialize_tracepoint_selftests): Add declaration. * unittests/tui-selftests.c (_initialize_tui_selftest): Add declaration. * unittests/unpack-selftests.c (_initialize_unpack_selftests): Add declaration. * unittests/utils-selftests.c (_initialize_utils_selftests): Add declaration. * unittests/vec-utils-selftests.c (_initialize_vec_utils_selftests): Add declaration. * unittests/xml-utils-selftests.c (_initialize_xml_utils): Add declaration. * user-regs.c (_initialize_user_regs): Add declaration. * utils.c (_initialize_utils): Add declaration. * v850-tdep.c (_initialize_v850_tdep): Add declaration. * valops.c (_initialize_valops): Add declaration. * valprint.c (_initialize_valprint): Add declaration. * value.c (_initialize_values): Add declaration. * varobj.c (_initialize_varobj): Add declaration. * vax-bsd-nat.c (_initialize_vaxbsd_nat): Add declaration. * vax-nbsd-tdep.c (_initialize_vaxnbsd_tdep): Add declaration. * vax-tdep.c (_initialize_vax_tdep): Add declaration. * windows-nat.c (_initialize_windows_nat): Add declaration. (_initialize_check_for_gdb_ini): Add declaration. (_initialize_loadable): Add declaration. * windows-tdep.c (_initialize_windows_tdep): Add declaration. * x86-bsd-nat.c (_initialize_x86_bsd_nat): Add declaration. * x86-linux-nat.c (_initialize_x86_linux_nat): Add declaration. * xcoffread.c (_initialize_xcoffread): Add declaration. * xml-support.c (_initialize_xml_support): Add declaration. * xstormy16-tdep.c (_initialize_xstormy16_tdep): Add declaration. * xtensa-linux-nat.c (_initialize_xtensa_linux_nat): Add declaration. * xtensa-linux-tdep.c (_initialize_xtensa_linux_tdep): Add declaration. * xtensa-tdep.c (_initialize_xtensa_tdep): Add declaration. Change-Id: I13eec7e0ed2b3c427377a7bdb055cf46da64def9
2020-01-13 20:01:38 +01:00
_initialize_findvar ()
{
#if GDB_SELF_TEST
Add selftests run filtering With the growing number of selftests, I think it would be useful to be able to run only a subset of the tests. This patch associates a name to each registered selftest. It then allows doing something like: (gdb) maintenance selftest aarch64 Running self-tests. Running selftest aarch64-analyze-prologue. Running selftest aarch64-process-record. Ran 2 unit tests, 0 failed or with gdbserver: ./gdbserver --selftest=aarch64 In both cases, only the tests that contain "aarch64" in their name are ran. To help validate that the tests you want to run were actually ran, it also prints a message with the test name before running each test. Right now, all the arch-dependent tests are registered as a single test of the selftests. To be able to filter those too, I made them "first-class citizen" selftests. The selftest type is an interface, with different implementations for "simple selftests" and "arch selftests". The run_tests function simply iterates on that an invokes operator() on each test. I changed the tests data structure from a vector to a map, because - it allows iterating in a stable (alphabetical) order - it allows to easily verify if a test with a given name has been registered, to avoid duplicates There's also a new command "maintenance info selftests" that lists the registered selftests. gdb/ChangeLog: * common/selftest.h (selftest): New struct/interface. (register_test): Add name parameter, add new overload. (run_tests): Add filter parameter. (for_each_selftest_ftype): New typedef. (for_each_selftest): New declaration. * common/selftest.c (tests): Change type to map<string, unique_ptr<selftest>>. (simple_selftest): New struct. (register_test): New function. (register_test): Add name parameter and use it. (run_tests): Add filter parameter and use it. Add prints. Adjust to vector -> map change. * aarch64-tdep.c (_initialize_aarch64_tdep): Add names when registering selftests. * arm-tdep.c (_initialize_arm_tdep): Likewise. * disasm-selftests.c (_initialize_disasm_selftests): Likewise. * dwarf2-frame.c (_initialize_dwarf2_frame): Likewise. * dwarf2loc.c (_initialize_dwarf2loc): Likewise. * findvar.c (_initialize_findvar): Likewise. * gdbarch-selftests.c (_initialize_gdbarch_selftests): Likewise. * maint.c (maintenance_selftest): Update call to run_tests. (maintenance_info_selftests): New function. (_initialize_maint_cmds): Register "maintenance info selftests" command. Update "maintenance selftest" doc. * regcache.c (_initialize_regcache): Add names when registering selftests. * rust-exp.y (_initialize_rust_exp): Likewise. * selftest-arch.c (gdbarch_selftest): New struct. (gdbarch_tests): Remove. (register_test_foreach_arch): Add name parameter. Call register_test. (tests_with_arch): Remove, move most content to gdbarch_selftest::operator(). (_initialize_selftests_foreach_arch): Remove. * selftest-arch.h (register_test_foreach_arch): Add name parameter. (run_tests_with_arch): New declaration. * utils-selftests.c (_initialize_utils_selftests): Add names when registering selftests. * utils.c (_initialize_utils): Likewise. * unittests/array-view-selftests.c (_initialize_array_view_selftests): Likewise. * unittests/environ-selftests.c (_initialize_environ_selftests): Likewise. * unittests/function-view-selftests.c (_initialize_function_view_selftests): Likewise. * unittests/offset-type-selftests.c (_initialize_offset_type_selftests): Likewise. * unittests/optional-selftests.c (_initialize_optional_selftests): Likewise. * unittests/scoped_restore-selftests.c (_initialize_scoped_restore_selftests): Likewise. * NEWS: Document "maintenance selftest" and "maint info selftests". gdb/gdbserver/ChangeLog: * server.c (captured_main): Accept argument for --selftest. Update run_tests call. * linux-x86-tdesc-selftest.c (initialize_low_tdesc): Add names when registering selftests. gdb/doc/ChangeLog: * gdb.texinfo (Maintenance Commands): Document filter parameter of "maint selftest". Document "maint info selftests" command.
2017-09-16 14:06:03 +02:00
selftests::register_test
("copy_integer_to_size",
selftests::findvar_tests::copy_integer_to_size_test);
#endif
}