forked from Imagelibrary/binutils-gdb
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.
411 lines
12 KiB
C
411 lines
12 KiB
C
/* Disassembly display.
|
|
|
|
Copyright (C) 1998-2013 Free Software Foundation, Inc.
|
|
|
|
Contributed by Hewlett-Packard Company.
|
|
|
|
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
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
(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
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
|
#include "defs.h"
|
|
#include "arch-utils.h"
|
|
#include "symtab.h"
|
|
#include "breakpoint.h"
|
|
#include "frame.h"
|
|
#include "value.h"
|
|
#include "source.h"
|
|
#include "disasm.h"
|
|
#include <string.h>
|
|
#include "tui/tui.h"
|
|
#include "tui/tui-data.h"
|
|
#include "tui/tui-win.h"
|
|
#include "tui/tui-layout.h"
|
|
#include "tui/tui-winsource.h"
|
|
#include "tui/tui-stack.h"
|
|
#include "tui/tui-file.h"
|
|
#include "tui/tui-disasm.h"
|
|
#include "progspace.h"
|
|
|
|
#include "gdb_curses.h"
|
|
|
|
struct tui_asm_line
|
|
{
|
|
CORE_ADDR addr;
|
|
char *addr_string;
|
|
char *insn;
|
|
};
|
|
|
|
/* Function to set the disassembly window's content.
|
|
Disassemble count lines starting at pc.
|
|
Return address of the count'th instruction after pc. */
|
|
static CORE_ADDR
|
|
tui_disassemble (struct gdbarch *gdbarch, struct tui_asm_line *asm_lines,
|
|
CORE_ADDR pc, int count)
|
|
{
|
|
struct ui_file *gdb_dis_out;
|
|
|
|
/* Now init the ui_file structure. */
|
|
gdb_dis_out = tui_sfileopen (256);
|
|
|
|
/* Now construct each line. */
|
|
for (; count > 0; count--, asm_lines++)
|
|
{
|
|
if (asm_lines->addr_string)
|
|
xfree (asm_lines->addr_string);
|
|
if (asm_lines->insn)
|
|
xfree (asm_lines->insn);
|
|
|
|
print_address (gdbarch, pc, gdb_dis_out);
|
|
asm_lines->addr = pc;
|
|
asm_lines->addr_string = xstrdup (tui_file_get_strbuf (gdb_dis_out));
|
|
|
|
ui_file_rewind (gdb_dis_out);
|
|
|
|
pc = pc + gdb_print_insn (gdbarch, pc, gdb_dis_out, NULL);
|
|
|
|
asm_lines->insn = xstrdup (tui_file_get_strbuf (gdb_dis_out));
|
|
|
|
/* Reset the buffer to empty. */
|
|
ui_file_rewind (gdb_dis_out);
|
|
}
|
|
ui_file_delete (gdb_dis_out);
|
|
return pc;
|
|
}
|
|
|
|
/* Find the disassembly address that corresponds to FROM lines above
|
|
or below the PC. Variable sized instructions are taken into
|
|
account by the algorithm. */
|
|
static CORE_ADDR
|
|
tui_find_disassembly_address (struct gdbarch *gdbarch, CORE_ADDR pc, int from)
|
|
{
|
|
CORE_ADDR new_low;
|
|
int max_lines;
|
|
int i;
|
|
struct tui_asm_line *asm_lines;
|
|
|
|
max_lines = (from > 0) ? from : - from;
|
|
if (max_lines <= 1)
|
|
return pc;
|
|
|
|
asm_lines = (struct tui_asm_line*) alloca (sizeof (struct tui_asm_line)
|
|
* max_lines);
|
|
memset (asm_lines, 0, sizeof (struct tui_asm_line) * max_lines);
|
|
|
|
new_low = pc;
|
|
if (from > 0)
|
|
{
|
|
tui_disassemble (gdbarch, asm_lines, pc, max_lines);
|
|
new_low = asm_lines[max_lines - 1].addr;
|
|
}
|
|
else
|
|
{
|
|
CORE_ADDR last_addr;
|
|
int pos;
|
|
struct minimal_symbol *msymbol;
|
|
|
|
/* Find backward an address which is a symbol and for which
|
|
disassembling from that address will fill completely the
|
|
window. */
|
|
pos = max_lines - 1;
|
|
do {
|
|
new_low -= 1 * max_lines;
|
|
msymbol = lookup_minimal_symbol_by_pc_section (new_low, 0).minsym;
|
|
|
|
if (msymbol)
|
|
new_low = SYMBOL_VALUE_ADDRESS (msymbol);
|
|
else
|
|
new_low += 1 * max_lines;
|
|
|
|
tui_disassemble (gdbarch, asm_lines, new_low, max_lines);
|
|
last_addr = asm_lines[pos].addr;
|
|
} while (last_addr > pc && msymbol);
|
|
|
|
/* Scan forward disassembling one instruction at a time until
|
|
the last visible instruction of the window matches the pc.
|
|
We keep the disassembled instructions in the 'lines' window
|
|
and shift it downward (increasing its addresses). */
|
|
if (last_addr < pc)
|
|
do
|
|
{
|
|
CORE_ADDR next_addr;
|
|
|
|
pos++;
|
|
if (pos >= max_lines)
|
|
pos = 0;
|
|
|
|
next_addr = tui_disassemble (gdbarch, &asm_lines[pos],
|
|
last_addr, 1);
|
|
|
|
/* If there are some problems while disassembling exit. */
|
|
if (next_addr <= last_addr)
|
|
break;
|
|
last_addr = next_addr;
|
|
} while (last_addr <= pc);
|
|
pos++;
|
|
if (pos >= max_lines)
|
|
pos = 0;
|
|
new_low = asm_lines[pos].addr;
|
|
}
|
|
for (i = 0; i < max_lines; i++)
|
|
{
|
|
xfree (asm_lines[i].addr_string);
|
|
xfree (asm_lines[i].insn);
|
|
}
|
|
return new_low;
|
|
}
|
|
|
|
/* Function to set the disassembly window's content. */
|
|
enum tui_status
|
|
tui_set_disassem_content (struct gdbarch *gdbarch, CORE_ADDR pc)
|
|
{
|
|
enum tui_status ret = TUI_FAILURE;
|
|
int i;
|
|
int offset = TUI_DISASM_WIN->detail.source_info.horizontal_offset;
|
|
int max_lines;
|
|
CORE_ADDR cur_pc;
|
|
struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
|
|
int tab_len = tui_default_tab_len ();
|
|
struct tui_asm_line *asm_lines;
|
|
int insn_pos;
|
|
int addr_size, max_size;
|
|
char *line;
|
|
|
|
if (pc == 0)
|
|
return TUI_FAILURE;
|
|
|
|
ret = tui_alloc_source_buffer (TUI_DISASM_WIN);
|
|
if (ret != TUI_SUCCESS)
|
|
return ret;
|
|
|
|
TUI_DISASM_WIN->detail.source_info.gdbarch = gdbarch;
|
|
TUI_DISASM_WIN->detail.source_info.start_line_or_addr.loa = LOA_ADDRESS;
|
|
TUI_DISASM_WIN->detail.source_info.start_line_or_addr.u.addr = pc;
|
|
cur_pc = (CORE_ADDR) (((struct tui_win_element *)
|
|
locator->content[0])->which_element.locator.addr);
|
|
|
|
max_lines = TUI_DISASM_WIN->generic.height - 2; /* Account for
|
|
hilite. */
|
|
|
|
/* Get temporary table that will hold all strings (addr & insn). */
|
|
asm_lines = (struct tui_asm_line*) alloca (sizeof (struct tui_asm_line)
|
|
* max_lines);
|
|
memset (asm_lines, 0, sizeof (struct tui_asm_line) * max_lines);
|
|
|
|
tui_disassemble (gdbarch, asm_lines, pc, max_lines);
|
|
|
|
/* See what is the maximum length of an address and of a line. */
|
|
addr_size = 0;
|
|
max_size = 0;
|
|
for (i = 0; i < max_lines; i++)
|
|
{
|
|
size_t len = strlen (asm_lines[i].addr_string);
|
|
|
|
if (len > addr_size)
|
|
addr_size = len;
|
|
|
|
len = strlen (asm_lines[i].insn) + tab_len;
|
|
if (len > max_size)
|
|
max_size = len;
|
|
}
|
|
max_size += addr_size + tab_len;
|
|
|
|
/* Allocate memory to create each line. */
|
|
line = (char*) alloca (max_size);
|
|
insn_pos = (1 + (addr_size / tab_len)) * tab_len;
|
|
|
|
/* Now construct each line. */
|
|
for (i = 0; i < max_lines; i++)
|
|
{
|
|
struct tui_win_element *element;
|
|
struct tui_source_element *src;
|
|
int cur_len;
|
|
|
|
element = (struct tui_win_element *) TUI_DISASM_WIN->generic.content[i];
|
|
src = &element->which_element.source;
|
|
strcpy (line, asm_lines[i].addr_string);
|
|
cur_len = strlen (line);
|
|
|
|
/* Add spaces to make the instructions start on the same
|
|
column. */
|
|
while (cur_len < insn_pos)
|
|
{
|
|
strcat (line, " ");
|
|
cur_len++;
|
|
}
|
|
|
|
strcat (line, asm_lines[i].insn);
|
|
|
|
/* Now copy the line taking the offset into account. */
|
|
if (strlen (line) > offset)
|
|
strcpy (src->line, &line[offset]);
|
|
else
|
|
src->line[0] = '\0';
|
|
|
|
src->line_or_addr.loa = LOA_ADDRESS;
|
|
src->line_or_addr.u.addr = asm_lines[i].addr;
|
|
src->is_exec_point = asm_lines[i].addr == cur_pc;
|
|
|
|
/* See whether there is a breakpoint installed. */
|
|
src->has_break = (!src->is_exec_point
|
|
&& breakpoint_here_p (current_program_space->aspace,
|
|
pc)
|
|
!= no_breakpoint_here);
|
|
|
|
xfree (asm_lines[i].addr_string);
|
|
xfree (asm_lines[i].insn);
|
|
}
|
|
TUI_DISASM_WIN->generic.content_size = i;
|
|
return TUI_SUCCESS;
|
|
}
|
|
|
|
|
|
/* Function to display the disassembly window with disassembled code. */
|
|
void
|
|
tui_show_disassem (struct gdbarch *gdbarch, CORE_ADDR start_addr)
|
|
{
|
|
struct symtab *s = find_pc_symtab (start_addr);
|
|
struct tui_win_info *win_with_focus = tui_win_with_focus ();
|
|
struct tui_line_or_address val;
|
|
|
|
val.loa = LOA_ADDRESS;
|
|
val.u.addr = start_addr;
|
|
tui_add_win_to_layout (DISASSEM_WIN);
|
|
tui_update_source_window (TUI_DISASM_WIN, gdbarch, s, val, FALSE);
|
|
|
|
/* If the focus was in the src win, put it in the asm win, if the
|
|
source view isn't split. */
|
|
if (tui_current_layout () != SRC_DISASSEM_COMMAND
|
|
&& win_with_focus == TUI_SRC_WIN)
|
|
tui_set_win_focus_to (TUI_DISASM_WIN);
|
|
|
|
return;
|
|
}
|
|
|
|
|
|
/* Function to display the disassembly window. */
|
|
void
|
|
tui_show_disassem_and_update_source (struct gdbarch *gdbarch,
|
|
CORE_ADDR start_addr)
|
|
{
|
|
struct symtab_and_line sal;
|
|
|
|
tui_show_disassem (gdbarch, start_addr);
|
|
if (tui_current_layout () == SRC_DISASSEM_COMMAND)
|
|
{
|
|
struct tui_line_or_address val;
|
|
|
|
/* Update what is in the source window if it is displayed too,
|
|
note that it follows what is in the disassembly window and
|
|
visa-versa. */
|
|
sal = find_pc_line (start_addr, 0);
|
|
val.loa = LOA_LINE;
|
|
val.u.line_no = sal.line;
|
|
tui_update_source_window (TUI_SRC_WIN, gdbarch, sal.symtab, val, TRUE);
|
|
if (sal.symtab)
|
|
{
|
|
set_current_source_symtab_and_line (&sal);
|
|
tui_update_locator_fullname (symtab_to_fullname (sal.symtab));
|
|
}
|
|
else
|
|
tui_update_locator_fullname ("?");
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
void
|
|
tui_get_begin_asm_address (struct gdbarch **gdbarch_p, CORE_ADDR *addr_p)
|
|
{
|
|
struct tui_gen_win_info *locator;
|
|
struct tui_locator_element *element;
|
|
struct gdbarch *gdbarch = get_current_arch ();
|
|
CORE_ADDR addr;
|
|
|
|
locator = tui_locator_win_info_ptr ();
|
|
element = &((struct tui_win_element *)
|
|
locator->content[0])->which_element.locator;
|
|
|
|
if (element->addr == 0)
|
|
{
|
|
struct minimal_symbol *main_symbol;
|
|
|
|
/* Find address of the start of program.
|
|
Note: this should be language specific. */
|
|
main_symbol = lookup_minimal_symbol ("main", NULL, NULL);
|
|
if (main_symbol == 0)
|
|
main_symbol = lookup_minimal_symbol ("MAIN", NULL, NULL);
|
|
if (main_symbol == 0)
|
|
main_symbol = lookup_minimal_symbol ("_start", NULL, NULL);
|
|
if (main_symbol)
|
|
addr = SYMBOL_VALUE_ADDRESS (main_symbol);
|
|
else
|
|
addr = 0;
|
|
}
|
|
else /* The target is executing. */
|
|
{
|
|
gdbarch = element->gdbarch;
|
|
addr = element->addr;
|
|
}
|
|
|
|
*gdbarch_p = gdbarch;
|
|
*addr_p = addr;
|
|
}
|
|
|
|
/* Determine what the low address will be to display in the TUI's
|
|
disassembly window. This may or may not be the same as the low
|
|
address input. */
|
|
CORE_ADDR
|
|
tui_get_low_disassembly_address (struct gdbarch *gdbarch,
|
|
CORE_ADDR low, CORE_ADDR pc)
|
|
{
|
|
int pos;
|
|
|
|
/* Determine where to start the disassembly so that the pc is about
|
|
in the middle of the viewport. */
|
|
pos = tui_default_win_viewport_height (DISASSEM_WIN, DISASSEM_COMMAND) / 2;
|
|
pc = tui_find_disassembly_address (gdbarch, pc, -pos);
|
|
|
|
if (pc < low)
|
|
pc = low;
|
|
return pc;
|
|
}
|
|
|
|
/* Scroll the disassembly forward or backward vertically. */
|
|
void
|
|
tui_vertical_disassem_scroll (enum tui_scroll_direction scroll_direction,
|
|
int num_to_scroll)
|
|
{
|
|
if (TUI_DISASM_WIN->generic.content != NULL)
|
|
{
|
|
struct gdbarch *gdbarch = TUI_DISASM_WIN->detail.source_info.gdbarch;
|
|
CORE_ADDR pc;
|
|
tui_win_content content;
|
|
struct tui_line_or_address val;
|
|
int dir;
|
|
|
|
content = (tui_win_content) TUI_DISASM_WIN->generic.content;
|
|
|
|
pc = content[0]->which_element.source.line_or_addr.u.addr;
|
|
num_to_scroll++;
|
|
dir = (scroll_direction == FORWARD_SCROLL)
|
|
? num_to_scroll : -num_to_scroll;
|
|
|
|
val.loa = LOA_ADDRESS;
|
|
val.u.addr = tui_find_disassembly_address (gdbarch, pc, dir);
|
|
tui_update_source_window_as_is (TUI_DISASM_WIN, gdbarch,
|
|
NULL, val, FALSE);
|
|
}
|
|
}
|