2006-03-28 19:19:16 +00:00
|
|
|
|
/* Prologue value handling for GDB.
|
2014-01-01 03:54:24 +00:00
|
|
|
|
Copyright (C) 2003-2014 Free Software Foundation, Inc.
|
2006-03-28 19:19:16 +00:00
|
|
|
|
|
|
|
|
|
This file is part of GDB.
|
|
|
|
|
|
|
|
|
|
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
|
2007-08-23 18:08:50 +00:00
|
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
2006-03-28 19:19:16 +00:00
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
2011-01-10 20:38:51 +00:00
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
2006-03-28 19:19:16 +00:00
|
|
|
|
|
|
|
|
|
#include "defs.h"
|
remove gdb_string.h
This removes gdb_string.h. This patch is purely mechanical. I
created it by running the two commands:
git rm common/gdb_string.h
perl -pi -e's/"gdb_string.h"/<string.h>/;' *.[chyl] */*.[chyl]
2013-11-18 Tom Tromey <tromey@redhat.com>
* common/gdb_string.h: Remove.
* aarch64-tdep.c: Use string.h, not gdb_string.h.
* ada-exp.y: Use string.h, not gdb_string.h.
* ada-lang.c: Use string.h, not gdb_string.h.
* ada-lex.l: Use string.h, not gdb_string.h.
* ada-typeprint.c: Use string.h, not gdb_string.h.
* ada-valprint.c: Use string.h, not gdb_string.h.
* aix-thread.c: Use string.h, not gdb_string.h.
* alpha-linux-tdep.c: Use string.h, not gdb_string.h.
* alpha-mdebug-tdep.c: Use string.h, not gdb_string.h.
* alpha-nat.c: Use string.h, not gdb_string.h.
* alpha-osf1-tdep.c: Use string.h, not gdb_string.h.
* alpha-tdep.c: Use string.h, not gdb_string.h.
* alphanbsd-tdep.c: Use string.h, not gdb_string.h.
* amd64-dicos-tdep.c: Use string.h, not gdb_string.h.
* amd64-linux-nat.c: Use string.h, not gdb_string.h.
* amd64-linux-tdep.c: Use string.h, not gdb_string.h.
* amd64-nat.c: Use string.h, not gdb_string.h.
* amd64-sol2-tdep.c: Use string.h, not gdb_string.h.
* amd64fbsd-tdep.c: Use string.h, not gdb_string.h.
* amd64obsd-tdep.c: Use string.h, not gdb_string.h.
* arch-utils.c: Use string.h, not gdb_string.h.
* arm-linux-nat.c: Use string.h, not gdb_string.h.
* arm-linux-tdep.c: Use string.h, not gdb_string.h.
* arm-tdep.c: Use string.h, not gdb_string.h.
* arm-wince-tdep.c: Use string.h, not gdb_string.h.
* armbsd-tdep.c: Use string.h, not gdb_string.h.
* armnbsd-nat.c: Use string.h, not gdb_string.h.
* armnbsd-tdep.c: Use string.h, not gdb_string.h.
* armobsd-tdep.c: Use string.h, not gdb_string.h.
* avr-tdep.c: Use string.h, not gdb_string.h.
* ax-gdb.c: Use string.h, not gdb_string.h.
* ax-general.c: Use string.h, not gdb_string.h.
* bcache.c: Use string.h, not gdb_string.h.
* bfin-tdep.c: Use string.h, not gdb_string.h.
* breakpoint.c: Use string.h, not gdb_string.h.
* build-id.c: Use string.h, not gdb_string.h.
* buildsym.c: Use string.h, not gdb_string.h.
* c-exp.y: Use string.h, not gdb_string.h.
* c-lang.c: Use string.h, not gdb_string.h.
* c-typeprint.c: Use string.h, not gdb_string.h.
* c-valprint.c: Use string.h, not gdb_string.h.
* charset.c: Use string.h, not gdb_string.h.
* cli-out.c: Use string.h, not gdb_string.h.
* cli/cli-cmds.c: Use string.h, not gdb_string.h.
* cli/cli-decode.c: Use string.h, not gdb_string.h.
* cli/cli-dump.c: Use string.h, not gdb_string.h.
* cli/cli-interp.c: Use string.h, not gdb_string.h.
* cli/cli-logging.c: Use string.h, not gdb_string.h.
* cli/cli-script.c: Use string.h, not gdb_string.h.
* cli/cli-setshow.c: Use string.h, not gdb_string.h.
* cli/cli-utils.c: Use string.h, not gdb_string.h.
* coffread.c: Use string.h, not gdb_string.h.
* common/common-utils.c: Use string.h, not gdb_string.h.
* common/filestuff.c: Use string.h, not gdb_string.h.
* common/linux-procfs.c: Use string.h, not gdb_string.h.
* common/linux-ptrace.c: Use string.h, not gdb_string.h.
* common/signals.c: Use string.h, not gdb_string.h.
* common/vec.h: Use string.h, not gdb_string.h.
* core-regset.c: Use string.h, not gdb_string.h.
* corefile.c: Use string.h, not gdb_string.h.
* corelow.c: Use string.h, not gdb_string.h.
* cp-abi.c: Use string.h, not gdb_string.h.
* cp-support.c: Use string.h, not gdb_string.h.
* cp-valprint.c: Use string.h, not gdb_string.h.
* cris-tdep.c: Use string.h, not gdb_string.h.
* d-lang.c: Use string.h, not gdb_string.h.
* dbxread.c: Use string.h, not gdb_string.h.
* dcache.c: Use string.h, not gdb_string.h.
* demangle.c: Use string.h, not gdb_string.h.
* dicos-tdep.c: Use string.h, not gdb_string.h.
* disasm.c: Use string.h, not gdb_string.h.
* doublest.c: Use string.h, not gdb_string.h.
* dsrec.c: Use string.h, not gdb_string.h.
* dummy-frame.c: Use string.h, not gdb_string.h.
* dwarf2-frame.c: Use string.h, not gdb_string.h.
* dwarf2loc.c: Use string.h, not gdb_string.h.
* dwarf2read.c: Use string.h, not gdb_string.h.
* elfread.c: Use string.h, not gdb_string.h.
* environ.c: Use string.h, not gdb_string.h.
* eval.c: Use string.h, not gdb_string.h.
* event-loop.c: Use string.h, not gdb_string.h.
* exceptions.c: Use string.h, not gdb_string.h.
* exec.c: Use string.h, not gdb_string.h.
* expprint.c: Use string.h, not gdb_string.h.
* f-exp.y: Use string.h, not gdb_string.h.
* f-lang.c: Use string.h, not gdb_string.h.
* f-typeprint.c: Use string.h, not gdb_string.h.
* f-valprint.c: Use string.h, not gdb_string.h.
* fbsd-nat.c: Use string.h, not gdb_string.h.
* findcmd.c: Use string.h, not gdb_string.h.
* findvar.c: Use string.h, not gdb_string.h.
* fork-child.c: Use string.h, not gdb_string.h.
* frame.c: Use string.h, not gdb_string.h.
* frv-linux-tdep.c: Use string.h, not gdb_string.h.
* frv-tdep.c: Use string.h, not gdb_string.h.
* gdb.c: Use string.h, not gdb_string.h.
* gdb_bfd.c: Use string.h, not gdb_string.h.
* gdbarch.c: Use string.h, not gdb_string.h.
* gdbtypes.c: Use string.h, not gdb_string.h.
* gnu-nat.c: Use string.h, not gdb_string.h.
* gnu-v2-abi.c: Use string.h, not gdb_string.h.
* gnu-v3-abi.c: Use string.h, not gdb_string.h.
* go-exp.y: Use string.h, not gdb_string.h.
* go-lang.c: Use string.h, not gdb_string.h.
* go32-nat.c: Use string.h, not gdb_string.h.
* hppa-hpux-tdep.c: Use string.h, not gdb_string.h.
* hppa-linux-nat.c: Use string.h, not gdb_string.h.
* hppanbsd-tdep.c: Use string.h, not gdb_string.h.
* hppaobsd-tdep.c: Use string.h, not gdb_string.h.
* i386-cygwin-tdep.c: Use string.h, not gdb_string.h.
* i386-dicos-tdep.c: Use string.h, not gdb_string.h.
* i386-linux-nat.c: Use string.h, not gdb_string.h.
* i386-linux-tdep.c: Use string.h, not gdb_string.h.
* i386-nto-tdep.c: Use string.h, not gdb_string.h.
* i386-sol2-tdep.c: Use string.h, not gdb_string.h.
* i386-tdep.c: Use string.h, not gdb_string.h.
* i386bsd-tdep.c: Use string.h, not gdb_string.h.
* i386gnu-nat.c: Use string.h, not gdb_string.h.
* i386nbsd-tdep.c: Use string.h, not gdb_string.h.
* i386obsd-tdep.c: Use string.h, not gdb_string.h.
* i387-tdep.c: Use string.h, not gdb_string.h.
* ia64-libunwind-tdep.c: Use string.h, not gdb_string.h.
* ia64-linux-nat.c: Use string.h, not gdb_string.h.
* inf-child.c: Use string.h, not gdb_string.h.
* inf-ptrace.c: Use string.h, not gdb_string.h.
* inf-ttrace.c: Use string.h, not gdb_string.h.
* infcall.c: Use string.h, not gdb_string.h.
* infcmd.c: Use string.h, not gdb_string.h.
* inflow.c: Use string.h, not gdb_string.h.
* infrun.c: Use string.h, not gdb_string.h.
* interps.c: Use string.h, not gdb_string.h.
* iq2000-tdep.c: Use string.h, not gdb_string.h.
* irix5-nat.c: Use string.h, not gdb_string.h.
* jv-exp.y: Use string.h, not gdb_string.h.
* jv-lang.c: Use string.h, not gdb_string.h.
* jv-typeprint.c: Use string.h, not gdb_string.h.
* jv-valprint.c: Use string.h, not gdb_string.h.
* language.c: Use string.h, not gdb_string.h.
* linux-fork.c: Use string.h, not gdb_string.h.
* linux-nat.c: Use string.h, not gdb_string.h.
* lm32-tdep.c: Use string.h, not gdb_string.h.
* m2-exp.y: Use string.h, not gdb_string.h.
* m2-typeprint.c: Use string.h, not gdb_string.h.
* m32c-tdep.c: Use string.h, not gdb_string.h.
* m32r-linux-nat.c: Use string.h, not gdb_string.h.
* m32r-linux-tdep.c: Use string.h, not gdb_string.h.
* m32r-rom.c: Use string.h, not gdb_string.h.
* m32r-tdep.c: Use string.h, not gdb_string.h.
* m68hc11-tdep.c: Use string.h, not gdb_string.h.
* m68k-tdep.c: Use string.h, not gdb_string.h.
* m68kbsd-tdep.c: Use string.h, not gdb_string.h.
* m68klinux-nat.c: Use string.h, not gdb_string.h.
* m68klinux-tdep.c: Use string.h, not gdb_string.h.
* m88k-tdep.c: Use string.h, not gdb_string.h.
* macrocmd.c: Use string.h, not gdb_string.h.
* main.c: Use string.h, not gdb_string.h.
* mdebugread.c: Use string.h, not gdb_string.h.
* mem-break.c: Use string.h, not gdb_string.h.
* memattr.c: Use string.h, not gdb_string.h.
* memory-map.c: Use string.h, not gdb_string.h.
* mep-tdep.c: Use string.h, not gdb_string.h.
* mi/mi-cmd-break.c: Use string.h, not gdb_string.h.
* mi/mi-cmd-disas.c: Use string.h, not gdb_string.h.
* mi/mi-cmd-env.c: Use string.h, not gdb_string.h.
* mi/mi-cmd-stack.c: Use string.h, not gdb_string.h.
* mi/mi-cmd-var.c: Use string.h, not gdb_string.h.
* mi/mi-cmds.c: Use string.h, not gdb_string.h.
* mi/mi-console.c: Use string.h, not gdb_string.h.
* mi/mi-getopt.c: Use string.h, not gdb_string.h.
* mi/mi-interp.c: Use string.h, not gdb_string.h.
* mi/mi-main.c: Use string.h, not gdb_string.h.
* mi/mi-parse.c: Use string.h, not gdb_string.h.
* microblaze-rom.c: Use string.h, not gdb_string.h.
* microblaze-tdep.c: Use string.h, not gdb_string.h.
* mingw-hdep.c: Use string.h, not gdb_string.h.
* minidebug.c: Use string.h, not gdb_string.h.
* minsyms.c: Use string.h, not gdb_string.h.
* mips-irix-tdep.c: Use string.h, not gdb_string.h.
* mips-linux-tdep.c: Use string.h, not gdb_string.h.
* mips-tdep.c: Use string.h, not gdb_string.h.
* mips64obsd-tdep.c: Use string.h, not gdb_string.h.
* mipsnbsd-tdep.c: Use string.h, not gdb_string.h.
* mipsread.c: Use string.h, not gdb_string.h.
* mn10300-linux-tdep.c: Use string.h, not gdb_string.h.
* mn10300-tdep.c: Use string.h, not gdb_string.h.
* monitor.c: Use string.h, not gdb_string.h.
* moxie-tdep.c: Use string.h, not gdb_string.h.
* mt-tdep.c: Use string.h, not gdb_string.h.
* nbsd-tdep.c: Use string.h, not gdb_string.h.
* nios2-linux-tdep.c: Use string.h, not gdb_string.h.
* nto-procfs.c: Use string.h, not gdb_string.h.
* nto-tdep.c: Use string.h, not gdb_string.h.
* objc-lang.c: Use string.h, not gdb_string.h.
* objfiles.c: Use string.h, not gdb_string.h.
* opencl-lang.c: Use string.h, not gdb_string.h.
* osabi.c: Use string.h, not gdb_string.h.
* osdata.c: Use string.h, not gdb_string.h.
* p-exp.y: Use string.h, not gdb_string.h.
* p-lang.c: Use string.h, not gdb_string.h.
* p-typeprint.c: Use string.h, not gdb_string.h.
* parse.c: Use string.h, not gdb_string.h.
* posix-hdep.c: Use string.h, not gdb_string.h.
* ppc-linux-nat.c: Use string.h, not gdb_string.h.
* ppc-sysv-tdep.c: Use string.h, not gdb_string.h.
* ppcfbsd-tdep.c: Use string.h, not gdb_string.h.
* ppcnbsd-tdep.c: Use string.h, not gdb_string.h.
* ppcobsd-tdep.c: Use string.h, not gdb_string.h.
* printcmd.c: Use string.h, not gdb_string.h.
* procfs.c: Use string.h, not gdb_string.h.
* prologue-value.c: Use string.h, not gdb_string.h.
* python/py-auto-load.c: Use string.h, not gdb_string.h.
* python/py-gdb-readline.c: Use string.h, not gdb_string.h.
* ravenscar-thread.c: Use string.h, not gdb_string.h.
* regcache.c: Use string.h, not gdb_string.h.
* registry.c: Use string.h, not gdb_string.h.
* remote-fileio.c: Use string.h, not gdb_string.h.
* remote-m32r-sdi.c: Use string.h, not gdb_string.h.
* remote-mips.c: Use string.h, not gdb_string.h.
* remote-sim.c: Use string.h, not gdb_string.h.
* remote.c: Use string.h, not gdb_string.h.
* reverse.c: Use string.h, not gdb_string.h.
* rs6000-aix-tdep.c: Use string.h, not gdb_string.h.
* ser-base.c: Use string.h, not gdb_string.h.
* ser-go32.c: Use string.h, not gdb_string.h.
* ser-mingw.c: Use string.h, not gdb_string.h.
* ser-pipe.c: Use string.h, not gdb_string.h.
* ser-tcp.c: Use string.h, not gdb_string.h.
* ser-unix.c: Use string.h, not gdb_string.h.
* serial.c: Use string.h, not gdb_string.h.
* sh-tdep.c: Use string.h, not gdb_string.h.
* sh64-tdep.c: Use string.h, not gdb_string.h.
* shnbsd-tdep.c: Use string.h, not gdb_string.h.
* skip.c: Use string.h, not gdb_string.h.
* sol-thread.c: Use string.h, not gdb_string.h.
* solib-dsbt.c: Use string.h, not gdb_string.h.
* solib-frv.c: Use string.h, not gdb_string.h.
* solib-osf.c: Use string.h, not gdb_string.h.
* solib-spu.c: Use string.h, not gdb_string.h.
* solib-target.c: Use string.h, not gdb_string.h.
* solib.c: Use string.h, not gdb_string.h.
* somread.c: Use string.h, not gdb_string.h.
* source.c: Use string.h, not gdb_string.h.
* sparc-nat.c: Use string.h, not gdb_string.h.
* sparc-sol2-tdep.c: Use string.h, not gdb_string.h.
* sparc-tdep.c: Use string.h, not gdb_string.h.
* sparc64-tdep.c: Use string.h, not gdb_string.h.
* sparc64fbsd-tdep.c: Use string.h, not gdb_string.h.
* sparc64nbsd-tdep.c: Use string.h, not gdb_string.h.
* sparcnbsd-tdep.c: Use string.h, not gdb_string.h.
* spu-linux-nat.c: Use string.h, not gdb_string.h.
* spu-multiarch.c: Use string.h, not gdb_string.h.
* spu-tdep.c: Use string.h, not gdb_string.h.
* stabsread.c: Use string.h, not gdb_string.h.
* stack.c: Use string.h, not gdb_string.h.
* std-regs.c: Use string.h, not gdb_string.h.
* symfile.c: Use string.h, not gdb_string.h.
* symmisc.c: Use string.h, not gdb_string.h.
* symtab.c: Use string.h, not gdb_string.h.
* target.c: Use string.h, not gdb_string.h.
* thread.c: Use string.h, not gdb_string.h.
* tilegx-linux-nat.c: Use string.h, not gdb_string.h.
* tilegx-tdep.c: Use string.h, not gdb_string.h.
* top.c: Use string.h, not gdb_string.h.
* tracepoint.c: Use string.h, not gdb_string.h.
* tui/tui-command.c: Use string.h, not gdb_string.h.
* tui/tui-data.c: Use string.h, not gdb_string.h.
* tui/tui-disasm.c: Use string.h, not gdb_string.h.
* tui/tui-file.c: Use string.h, not gdb_string.h.
* tui/tui-layout.c: Use string.h, not gdb_string.h.
* tui/tui-out.c: Use string.h, not gdb_string.h.
* tui/tui-regs.c: Use string.h, not gdb_string.h.
* tui/tui-source.c: Use string.h, not gdb_string.h.
* tui/tui-stack.c: Use string.h, not gdb_string.h.
* tui/tui-win.c: Use string.h, not gdb_string.h.
* tui/tui-windata.c: Use string.h, not gdb_string.h.
* tui/tui-winsource.c: Use string.h, not gdb_string.h.
* typeprint.c: Use string.h, not gdb_string.h.
* ui-file.c: Use string.h, not gdb_string.h.
* ui-out.c: Use string.h, not gdb_string.h.
* user-regs.c: Use string.h, not gdb_string.h.
* utils.c: Use string.h, not gdb_string.h.
* v850-tdep.c: Use string.h, not gdb_string.h.
* valarith.c: Use string.h, not gdb_string.h.
* valops.c: Use string.h, not gdb_string.h.
* valprint.c: Use string.h, not gdb_string.h.
* value.c: Use string.h, not gdb_string.h.
* varobj.c: Use string.h, not gdb_string.h.
* vax-tdep.c: Use string.h, not gdb_string.h.
* vaxnbsd-tdep.c: Use string.h, not gdb_string.h.
* vaxobsd-tdep.c: Use string.h, not gdb_string.h.
* windows-nat.c: Use string.h, not gdb_string.h.
* xcoffread.c: Use string.h, not gdb_string.h.
* xml-support.c: Use string.h, not gdb_string.h.
* xstormy16-tdep.c: Use string.h, not gdb_string.h.
* xtensa-linux-nat.c: Use string.h, not gdb_string.h.
2013-11-06 14:14:23 +00:00
|
|
|
|
#include <string.h>
|
2006-03-28 19:19:16 +00:00
|
|
|
|
#include "gdb_assert.h"
|
|
|
|
|
#include "prologue-value.h"
|
|
|
|
|
#include "regcache.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Constructors. */
|
|
|
|
|
|
|
|
|
|
pv_t
|
|
|
|
|
pv_unknown (void)
|
|
|
|
|
{
|
|
|
|
|
pv_t v = { pvk_unknown, 0, 0 };
|
|
|
|
|
|
|
|
|
|
return v;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pv_t
|
|
|
|
|
pv_constant (CORE_ADDR k)
|
|
|
|
|
{
|
|
|
|
|
pv_t v;
|
|
|
|
|
|
|
|
|
|
v.kind = pvk_constant;
|
|
|
|
|
v.reg = -1; /* for debugging */
|
|
|
|
|
v.k = k;
|
|
|
|
|
|
|
|
|
|
return v;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pv_t
|
|
|
|
|
pv_register (int reg, CORE_ADDR k)
|
|
|
|
|
{
|
|
|
|
|
pv_t v;
|
|
|
|
|
|
|
|
|
|
v.kind = pvk_register;
|
|
|
|
|
v.reg = reg;
|
|
|
|
|
v.k = k;
|
|
|
|
|
|
|
|
|
|
return v;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Arithmetic operations. */
|
|
|
|
|
|
|
|
|
|
/* If one of *A and *B is a constant, and the other isn't, swap the
|
|
|
|
|
values as necessary to ensure that *B is the constant. This can
|
|
|
|
|
reduce the number of cases we need to analyze in the functions
|
|
|
|
|
below. */
|
|
|
|
|
static void
|
|
|
|
|
constant_last (pv_t *a, pv_t *b)
|
|
|
|
|
{
|
|
|
|
|
if (a->kind == pvk_constant
|
|
|
|
|
&& b->kind != pvk_constant)
|
|
|
|
|
{
|
|
|
|
|
pv_t temp = *a;
|
|
|
|
|
*a = *b;
|
|
|
|
|
*b = temp;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pv_t
|
|
|
|
|
pv_add (pv_t a, pv_t b)
|
|
|
|
|
{
|
|
|
|
|
constant_last (&a, &b);
|
|
|
|
|
|
|
|
|
|
/* We can add a constant to a register. */
|
|
|
|
|
if (a.kind == pvk_register
|
|
|
|
|
&& b.kind == pvk_constant)
|
|
|
|
|
return pv_register (a.reg, a.k + b.k);
|
|
|
|
|
|
|
|
|
|
/* We can add a constant to another constant. */
|
|
|
|
|
else if (a.kind == pvk_constant
|
|
|
|
|
&& b.kind == pvk_constant)
|
|
|
|
|
return pv_constant (a.k + b.k);
|
|
|
|
|
|
|
|
|
|
/* Anything else we don't know how to add. We don't have a
|
|
|
|
|
representation for, say, the sum of two registers, or a multiple
|
|
|
|
|
of a register's value (adding a register to itself). */
|
|
|
|
|
else
|
|
|
|
|
return pv_unknown ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pv_t
|
|
|
|
|
pv_add_constant (pv_t v, CORE_ADDR k)
|
|
|
|
|
{
|
|
|
|
|
/* Rather than thinking of all the cases we can and can't handle,
|
|
|
|
|
we'll just let pv_add take care of that for us. */
|
|
|
|
|
return pv_add (v, pv_constant (k));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pv_t
|
|
|
|
|
pv_subtract (pv_t a, pv_t b)
|
|
|
|
|
{
|
|
|
|
|
/* This isn't quite the same as negating B and adding it to A, since
|
|
|
|
|
we don't have a representation for the negation of anything but a
|
|
|
|
|
constant. For example, we can't negate { pvk_register, R1, 10 },
|
|
|
|
|
but we do know that { pvk_register, R1, 10 } minus { pvk_register,
|
|
|
|
|
R1, 5 } is { pvk_constant, <ignored>, 5 }.
|
|
|
|
|
|
|
|
|
|
This means, for example, that we could subtract two stack
|
|
|
|
|
addresses; they're both relative to the original SP. Since the
|
|
|
|
|
frame pointer is set based on the SP, its value will be the
|
|
|
|
|
original SP plus some constant (probably zero), so we can use its
|
|
|
|
|
value just fine, too. */
|
|
|
|
|
|
|
|
|
|
constant_last (&a, &b);
|
|
|
|
|
|
|
|
|
|
/* We can subtract two constants. */
|
|
|
|
|
if (a.kind == pvk_constant
|
|
|
|
|
&& b.kind == pvk_constant)
|
|
|
|
|
return pv_constant (a.k - b.k);
|
|
|
|
|
|
|
|
|
|
/* We can subtract a constant from a register. */
|
|
|
|
|
else if (a.kind == pvk_register
|
|
|
|
|
&& b.kind == pvk_constant)
|
|
|
|
|
return pv_register (a.reg, a.k - b.k);
|
|
|
|
|
|
|
|
|
|
/* We can subtract a register from itself, yielding a constant. */
|
|
|
|
|
else if (a.kind == pvk_register
|
|
|
|
|
&& b.kind == pvk_register
|
|
|
|
|
&& a.reg == b.reg)
|
|
|
|
|
return pv_constant (a.k - b.k);
|
|
|
|
|
|
|
|
|
|
/* We don't know how to subtract anything else. */
|
|
|
|
|
else
|
|
|
|
|
return pv_unknown ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pv_t
|
|
|
|
|
pv_logical_and (pv_t a, pv_t b)
|
|
|
|
|
{
|
|
|
|
|
constant_last (&a, &b);
|
|
|
|
|
|
|
|
|
|
/* We can 'and' two constants. */
|
|
|
|
|
if (a.kind == pvk_constant
|
|
|
|
|
&& b.kind == pvk_constant)
|
|
|
|
|
return pv_constant (a.k & b.k);
|
|
|
|
|
|
|
|
|
|
/* We can 'and' anything with the constant zero. */
|
|
|
|
|
else if (b.kind == pvk_constant
|
|
|
|
|
&& b.k == 0)
|
|
|
|
|
return pv_constant (0);
|
|
|
|
|
|
|
|
|
|
/* We can 'and' anything with ~0. */
|
|
|
|
|
else if (b.kind == pvk_constant
|
|
|
|
|
&& b.k == ~ (CORE_ADDR) 0)
|
|
|
|
|
return a;
|
|
|
|
|
|
|
|
|
|
/* We can 'and' a register with itself. */
|
|
|
|
|
else if (a.kind == pvk_register
|
|
|
|
|
&& b.kind == pvk_register
|
|
|
|
|
&& a.reg == b.reg
|
|
|
|
|
&& a.k == b.k)
|
|
|
|
|
return a;
|
|
|
|
|
|
|
|
|
|
/* Otherwise, we don't know. */
|
|
|
|
|
else
|
|
|
|
|
return pv_unknown ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Examining prologue values. */
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
pv_is_identical (pv_t a, pv_t b)
|
|
|
|
|
{
|
|
|
|
|
if (a.kind != b.kind)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
switch (a.kind)
|
|
|
|
|
{
|
|
|
|
|
case pvk_unknown:
|
|
|
|
|
return 1;
|
|
|
|
|
case pvk_constant:
|
|
|
|
|
return (a.k == b.k);
|
|
|
|
|
case pvk_register:
|
|
|
|
|
return (a.reg == b.reg && a.k == b.k);
|
|
|
|
|
default:
|
2010-08-18 19:13:33 +00:00
|
|
|
|
gdb_assert_not_reached ("unexpected prologue value kind");
|
2006-03-28 19:19:16 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
pv_is_constant (pv_t a)
|
|
|
|
|
{
|
|
|
|
|
return (a.kind == pvk_constant);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
pv_is_register (pv_t a, int r)
|
|
|
|
|
{
|
|
|
|
|
return (a.kind == pvk_register
|
|
|
|
|
&& a.reg == r);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
pv_is_register_k (pv_t a, int r, CORE_ADDR k)
|
|
|
|
|
{
|
|
|
|
|
return (a.kind == pvk_register
|
|
|
|
|
&& a.reg == r
|
|
|
|
|
&& a.k == k);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enum pv_boolean
|
|
|
|
|
pv_is_array_ref (pv_t addr, CORE_ADDR size,
|
|
|
|
|
pv_t array_addr, CORE_ADDR array_len,
|
|
|
|
|
CORE_ADDR elt_size,
|
|
|
|
|
int *i)
|
|
|
|
|
{
|
|
|
|
|
/* Note that, since .k is a CORE_ADDR, and CORE_ADDR is unsigned, if
|
|
|
|
|
addr is *before* the start of the array, then this isn't going to
|
|
|
|
|
be negative... */
|
|
|
|
|
pv_t offset = pv_subtract (addr, array_addr);
|
|
|
|
|
|
|
|
|
|
if (offset.kind == pvk_constant)
|
|
|
|
|
{
|
|
|
|
|
/* This is a rather odd test. We want to know if the SIZE bytes
|
|
|
|
|
at ADDR don't overlap the array at all, so you'd expect it to
|
|
|
|
|
be an || expression: "if we're completely before || we're
|
|
|
|
|
completely after". But with unsigned arithmetic, things are
|
|
|
|
|
different: since it's a number circle, not a number line, the
|
|
|
|
|
right values for offset.k are actually one contiguous range. */
|
|
|
|
|
if (offset.k <= -size
|
|
|
|
|
&& offset.k >= array_len * elt_size)
|
|
|
|
|
return pv_definite_no;
|
|
|
|
|
else if (offset.k % elt_size != 0
|
|
|
|
|
|| size != elt_size)
|
|
|
|
|
return pv_maybe;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
*i = offset.k / elt_size;
|
|
|
|
|
return pv_definite_yes;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return pv_maybe;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Areas. */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* A particular value known to be stored in an area.
|
|
|
|
|
|
|
|
|
|
Entries form a ring, sorted by unsigned offset from the area's base
|
|
|
|
|
register's value. Since entries can straddle the wrap-around point,
|
|
|
|
|
unsigned offsets form a circle, not a number line, so the list
|
|
|
|
|
itself is structured the same way --- there is no inherent head.
|
|
|
|
|
The entry with the lowest offset simply follows the entry with the
|
|
|
|
|
highest offset. Entries may abut, but never overlap. The area's
|
|
|
|
|
'entry' pointer points to an arbitrary node in the ring. */
|
|
|
|
|
struct area_entry
|
|
|
|
|
{
|
|
|
|
|
/* Links in the doubly-linked ring. */
|
|
|
|
|
struct area_entry *prev, *next;
|
|
|
|
|
|
|
|
|
|
/* Offset of this entry's address from the value of the base
|
|
|
|
|
register. */
|
|
|
|
|
CORE_ADDR offset;
|
|
|
|
|
|
|
|
|
|
/* The size of this entry. Note that an entry may wrap around from
|
|
|
|
|
the end of the address space to the beginning. */
|
|
|
|
|
CORE_ADDR size;
|
|
|
|
|
|
|
|
|
|
/* The value stored here. */
|
|
|
|
|
pv_t value;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct pv_area
|
|
|
|
|
{
|
|
|
|
|
/* This area's base register. */
|
|
|
|
|
int base_reg;
|
|
|
|
|
|
|
|
|
|
/* The mask to apply to addresses, to make the wrap-around happen at
|
|
|
|
|
the right place. */
|
|
|
|
|
CORE_ADDR addr_mask;
|
|
|
|
|
|
|
|
|
|
/* An element of the doubly-linked ring of entries, or zero if we
|
|
|
|
|
have none. */
|
|
|
|
|
struct area_entry *entry;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct pv_area *
|
2009-06-17 18:39:13 +00:00
|
|
|
|
make_pv_area (int base_reg, int addr_bit)
|
2006-03-28 19:19:16 +00:00
|
|
|
|
{
|
|
|
|
|
struct pv_area *a = (struct pv_area *) xmalloc (sizeof (*a));
|
|
|
|
|
|
|
|
|
|
memset (a, 0, sizeof (*a));
|
|
|
|
|
|
|
|
|
|
a->base_reg = base_reg;
|
|
|
|
|
a->entry = 0;
|
|
|
|
|
|
|
|
|
|
/* Remember that shift amounts equal to the type's width are
|
|
|
|
|
undefined. */
|
2009-06-17 18:39:13 +00:00
|
|
|
|
a->addr_mask = ((((CORE_ADDR) 1 << (addr_bit - 1)) - 1) << 1) | 1;
|
2006-03-28 19:19:16 +00:00
|
|
|
|
|
|
|
|
|
return a;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Delete all entries from AREA. */
|
|
|
|
|
static void
|
|
|
|
|
clear_entries (struct pv_area *area)
|
|
|
|
|
{
|
|
|
|
|
struct area_entry *e = area->entry;
|
|
|
|
|
|
|
|
|
|
if (e)
|
|
|
|
|
{
|
|
|
|
|
/* This needs to be a do-while loop, in order to actually
|
|
|
|
|
process the node being checked for in the terminating
|
|
|
|
|
condition. */
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
struct area_entry *next = e->next;
|
2010-05-16 01:27:02 +00:00
|
|
|
|
|
2006-03-28 19:19:16 +00:00
|
|
|
|
xfree (e);
|
2006-11-18 23:57:08 +00:00
|
|
|
|
e = next;
|
2006-03-28 19:19:16 +00:00
|
|
|
|
}
|
|
|
|
|
while (e != area->entry);
|
|
|
|
|
|
|
|
|
|
area->entry = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
free_pv_area (struct pv_area *area)
|
|
|
|
|
{
|
|
|
|
|
clear_entries (area);
|
|
|
|
|
xfree (area);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
do_free_pv_area_cleanup (void *arg)
|
|
|
|
|
{
|
|
|
|
|
free_pv_area ((struct pv_area *) arg);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct cleanup *
|
|
|
|
|
make_cleanup_free_pv_area (struct pv_area *area)
|
|
|
|
|
{
|
|
|
|
|
return make_cleanup (do_free_pv_area_cleanup, (void *) area);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
pv_area_store_would_trash (struct pv_area *area, pv_t addr)
|
|
|
|
|
{
|
|
|
|
|
/* It may seem odd that pvk_constant appears here --- after all,
|
|
|
|
|
that's the case where we know the most about the address! But
|
|
|
|
|
pv_areas are always relative to a register, and we don't know the
|
|
|
|
|
value of the register, so we can't compare entry addresses to
|
|
|
|
|
constants. */
|
|
|
|
|
return (addr.kind == pvk_unknown
|
|
|
|
|
|| addr.kind == pvk_constant
|
|
|
|
|
|| (addr.kind == pvk_register && addr.reg != area->base_reg));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Return a pointer to the first entry we hit in AREA starting at
|
|
|
|
|
OFFSET and going forward.
|
|
|
|
|
|
|
|
|
|
This may return zero, if AREA has no entries.
|
|
|
|
|
|
|
|
|
|
And since the entries are a ring, this may return an entry that
|
2011-07-05 04:35:00 +00:00
|
|
|
|
entirely precedes OFFSET. This is the correct behavior: depending
|
2006-03-28 19:19:16 +00:00
|
|
|
|
on the sizes involved, we could still overlap such an area, with
|
|
|
|
|
wrap-around. */
|
|
|
|
|
static struct area_entry *
|
|
|
|
|
find_entry (struct pv_area *area, CORE_ADDR offset)
|
|
|
|
|
{
|
|
|
|
|
struct area_entry *e = area->entry;
|
|
|
|
|
|
|
|
|
|
if (! e)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
/* If the next entry would be better than the current one, then scan
|
|
|
|
|
forward. Since we use '<' in this loop, it always terminates.
|
|
|
|
|
|
|
|
|
|
Note that, even setting aside the addr_mask stuff, we must not
|
|
|
|
|
simplify this, in high school algebra fashion, to
|
|
|
|
|
(e->next->offset < e->offset), because of the way < interacts
|
|
|
|
|
with wrap-around. We have to subtract offset from both sides to
|
|
|
|
|
make sure both things we're comparing are on the same side of the
|
|
|
|
|
discontinuity. */
|
|
|
|
|
while (((e->next->offset - offset) & area->addr_mask)
|
|
|
|
|
< ((e->offset - offset) & area->addr_mask))
|
|
|
|
|
e = e->next;
|
|
|
|
|
|
|
|
|
|
/* If the previous entry would be better than the current one, then
|
|
|
|
|
scan backwards. */
|
|
|
|
|
while (((e->prev->offset - offset) & area->addr_mask)
|
|
|
|
|
< ((e->offset - offset) & area->addr_mask))
|
|
|
|
|
e = e->prev;
|
|
|
|
|
|
|
|
|
|
/* In case there's some locality to the searches, set the area's
|
|
|
|
|
pointer to the entry we've found. */
|
|
|
|
|
area->entry = e;
|
|
|
|
|
|
|
|
|
|
return e;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Return non-zero if the SIZE bytes at OFFSET would overlap ENTRY;
|
|
|
|
|
return zero otherwise. AREA is the area to which ENTRY belongs. */
|
|
|
|
|
static int
|
|
|
|
|
overlaps (struct pv_area *area,
|
|
|
|
|
struct area_entry *entry,
|
|
|
|
|
CORE_ADDR offset,
|
|
|
|
|
CORE_ADDR size)
|
|
|
|
|
{
|
|
|
|
|
/* Think carefully about wrap-around before simplifying this. */
|
|
|
|
|
return (((entry->offset - offset) & area->addr_mask) < size
|
|
|
|
|
|| ((offset - entry->offset) & area->addr_mask) < entry->size);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
pv_area_store (struct pv_area *area,
|
|
|
|
|
pv_t addr,
|
|
|
|
|
CORE_ADDR size,
|
|
|
|
|
pv_t value)
|
|
|
|
|
{
|
|
|
|
|
/* Remove any (potentially) overlapping entries. */
|
|
|
|
|
if (pv_area_store_would_trash (area, addr))
|
|
|
|
|
clear_entries (area);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
CORE_ADDR offset = addr.k;
|
|
|
|
|
struct area_entry *e = find_entry (area, offset);
|
|
|
|
|
|
|
|
|
|
/* Delete all entries that we would overlap. */
|
|
|
|
|
while (e && overlaps (area, e, offset, size))
|
|
|
|
|
{
|
|
|
|
|
struct area_entry *next = (e->next == e) ? 0 : e->next;
|
2010-05-16 01:27:02 +00:00
|
|
|
|
|
2006-03-28 19:19:16 +00:00
|
|
|
|
e->prev->next = e->next;
|
|
|
|
|
e->next->prev = e->prev;
|
|
|
|
|
|
|
|
|
|
xfree (e);
|
|
|
|
|
e = next;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Move the area's pointer to the next remaining entry. This
|
|
|
|
|
will also zero the pointer if we've deleted all the entries. */
|
|
|
|
|
area->entry = e;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Now, there are no entries overlapping us, and area->entry is
|
|
|
|
|
either zero or pointing at the closest entry after us. We can
|
|
|
|
|
just insert ourselves before that.
|
|
|
|
|
|
|
|
|
|
But if we're storing an unknown value, don't bother --- that's
|
|
|
|
|
the default. */
|
|
|
|
|
if (value.kind == pvk_unknown)
|
|
|
|
|
return;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
CORE_ADDR offset = addr.k;
|
|
|
|
|
struct area_entry *e = (struct area_entry *) xmalloc (sizeof (*e));
|
2010-05-16 01:27:02 +00:00
|
|
|
|
|
2006-03-28 19:19:16 +00:00
|
|
|
|
e->offset = offset;
|
|
|
|
|
e->size = size;
|
|
|
|
|
e->value = value;
|
|
|
|
|
|
|
|
|
|
if (area->entry)
|
|
|
|
|
{
|
|
|
|
|
e->prev = area->entry->prev;
|
|
|
|
|
e->next = area->entry;
|
|
|
|
|
e->prev->next = e->next->prev = e;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
e->prev = e->next = e;
|
|
|
|
|
area->entry = e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pv_t
|
|
|
|
|
pv_area_fetch (struct pv_area *area, pv_t addr, CORE_ADDR size)
|
|
|
|
|
{
|
|
|
|
|
/* If we have no entries, or we can't decide how ADDR relates to the
|
|
|
|
|
entries we do have, then the value is unknown. */
|
|
|
|
|
if (! area->entry
|
|
|
|
|
|| pv_area_store_would_trash (area, addr))
|
|
|
|
|
return pv_unknown ();
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
CORE_ADDR offset = addr.k;
|
|
|
|
|
struct area_entry *e = find_entry (area, offset);
|
|
|
|
|
|
|
|
|
|
/* If this entry exactly matches what we're looking for, then
|
|
|
|
|
we're set. Otherwise, say it's unknown. */
|
|
|
|
|
if (e->offset == offset && e->size == size)
|
|
|
|
|
return e->value;
|
|
|
|
|
else
|
|
|
|
|
return pv_unknown ();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
pv_area_find_reg (struct pv_area *area,
|
|
|
|
|
struct gdbarch *gdbarch,
|
|
|
|
|
int reg,
|
|
|
|
|
CORE_ADDR *offset_p)
|
|
|
|
|
{
|
|
|
|
|
struct area_entry *e = area->entry;
|
|
|
|
|
|
|
|
|
|
if (e)
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
if (e->value.kind == pvk_register
|
|
|
|
|
&& e->value.reg == reg
|
|
|
|
|
&& e->value.k == 0
|
|
|
|
|
&& e->size == register_size (gdbarch, reg))
|
|
|
|
|
{
|
|
|
|
|
if (offset_p)
|
|
|
|
|
*offset_p = e->offset;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
e = e->next;
|
|
|
|
|
}
|
|
|
|
|
while (e != area->entry);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
pv_area_scan (struct pv_area *area,
|
|
|
|
|
void (*func) (void *closure,
|
|
|
|
|
pv_t addr,
|
|
|
|
|
CORE_ADDR size,
|
|
|
|
|
pv_t value),
|
|
|
|
|
void *closure)
|
|
|
|
|
{
|
|
|
|
|
struct area_entry *e = area->entry;
|
|
|
|
|
pv_t addr;
|
|
|
|
|
|
|
|
|
|
addr.kind = pvk_register;
|
|
|
|
|
addr.reg = area->base_reg;
|
|
|
|
|
|
|
|
|
|
if (e)
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
addr.k = e->offset;
|
|
|
|
|
func (closure, addr, e->size, e->value);
|
|
|
|
|
e = e->next;
|
|
|
|
|
}
|
|
|
|
|
while (e != area->entry);
|
|
|
|
|
}
|