mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-15 04:31:49 +08:00
0d12e84cfc
I touched symtab.h and was surprised to see how many files were rebuilt. I looked into it a bit, and found that defs.h includes gdbarch.h, which in turn includes many things. gdbarch.h is only needed by a minority ofthe files in gdb, so this patch removes the include from defs.h and updates the fallout. I did "wc -l" on the files in build/gdb/.deps; this patch reduces the line count from 139935 to 137030; so there are definitely future build-time savings here. Note that while I configured with --enable-targets=all, it's possible that some *-nat.c file needs an update. I could not test all of these. The buildbot caught a few problems along these lines. gdb/ChangeLog 2019-07-10 Tom Tromey <tom@tromey.com> * defs.h: Don't include gdbarch.h. * aarch64-ravenscar-thread.c, aarch64-tdep.c, alpha-bsd-tdep.h, alpha-linux-tdep.c, alpha-mdebug-tdep.c, arch-utils.h, arm-tdep.h, ax-general.c, btrace.c, buildsym-legacy.c, buildsym.h, c-lang.c, cli/cli-decode.h, cli/cli-dump.c, cli/cli-script.h, cli/cli-style.h, coff-pe-read.h, compile/compile-c-support.c, compile/compile-cplus.h, compile/compile-loc2c.c, corefile.c, cp-valprint.c, cris-linux-tdep.c, ctf.c, d-lang.c, d-namespace.c, dcache.c, dicos-tdep.c, dictionary.c, disasm-selftests.c, dummy-frame.c, dummy-frame.h, dwarf2-frame-tailcall.c, dwarf2expr.c, expression.h, f-lang.c, frame-base.c, frame-unwind.c, frv-linux-tdep.c, gdbarch-selftests.c, gdbtypes.h, go-lang.c, hppa-nbsd-tdep.c, hppa-obsd-tdep.c, i386-dicos-tdep.c, i386-tdep.h, ia64-vms-tdep.c, interps.h, language.c, linux-record.c, location.h, m2-lang.c, m32r-linux-tdep.c, mem-break.c, memattr.c, mn10300-linux-tdep.c, nios2-linux-tdep.c, objfiles.h, opencl-lang.c, or1k-linux-tdep.c, p-lang.c, parser-defs.h, ppc-tdep.h, probe.h, python/py-record-btrace.c, record-btrace.c, record.h, regcache-dump.c, regcache.h, riscv-fbsd-tdep.c, riscv-linux-tdep.c, rust-exp.y, sh-linux-tdep.c, sh-nbsd-tdep.c, source-cache.c, sparc-nbsd-tdep.c, sparc-obsd-tdep.c, sparc-ravenscar-thread.c, sparc64-fbsd-tdep.c, std-regs.c, target-descriptions.h, target-float.c, tic6x-linux-tdep.c, tilegx-linux-tdep.c, top.c, tracefile.c, trad-frame.c, type-stack.h, ui-style.c, utils.c, utils.h, valarith.c, valprint.c, varobj.c, x86-tdep.c, xml-support.h, xtensa-linux-tdep.c, cli/cli-cmds.h: Update. * s390-linux-nat.c, procfs.c, inf-ptrace.c: Likewise.
337 lines
8.2 KiB
C
337 lines
8.2 KiB
C
/* Copyright (C) 1986-2019 Free Software Foundation, Inc.
|
|
|
|
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 "gdbcmd.h"
|
|
#include "regcache.h"
|
|
#include "gdbsupport/def-vector.h"
|
|
#include "valprint.h"
|
|
#include "remote.h"
|
|
#include "reggroups.h"
|
|
#include "target.h"
|
|
#include "gdbarch.h"
|
|
|
|
/* Dump registers from regcache, used for dumping raw registers and
|
|
cooked registers. */
|
|
|
|
class register_dump_regcache : public register_dump
|
|
{
|
|
public:
|
|
register_dump_regcache (regcache *regcache, bool dump_pseudo)
|
|
: register_dump (regcache->arch ()), m_regcache (regcache),
|
|
m_dump_pseudo (dump_pseudo)
|
|
{
|
|
}
|
|
|
|
protected:
|
|
void dump_reg (ui_file *file, int regnum) override
|
|
{
|
|
if (regnum < 0)
|
|
{
|
|
if (m_dump_pseudo)
|
|
fprintf_unfiltered (file, "Cooked value");
|
|
else
|
|
fprintf_unfiltered (file, "Raw value");
|
|
}
|
|
else
|
|
{
|
|
if (regnum < gdbarch_num_regs (m_gdbarch) || m_dump_pseudo)
|
|
{
|
|
auto size = register_size (m_gdbarch, regnum);
|
|
|
|
if (size == 0)
|
|
return;
|
|
|
|
gdb::def_vector<gdb_byte> buf (size);
|
|
auto status = m_regcache->cooked_read (regnum, buf.data ());
|
|
|
|
if (status == REG_UNKNOWN)
|
|
fprintf_unfiltered (file, "<invalid>");
|
|
else if (status == REG_UNAVAILABLE)
|
|
fprintf_unfiltered (file, "<unavailable>");
|
|
else
|
|
{
|
|
print_hex_chars (file, buf.data (), size,
|
|
gdbarch_byte_order (m_gdbarch), true);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
/* Just print "<cooked>" for pseudo register when
|
|
regcache_dump_raw. */
|
|
fprintf_unfiltered (file, "<cooked>");
|
|
}
|
|
}
|
|
}
|
|
|
|
private:
|
|
regcache *m_regcache;
|
|
|
|
/* Dump pseudo registers or not. */
|
|
const bool m_dump_pseudo;
|
|
};
|
|
|
|
/* Dump from reg_buffer, used when there is no thread or
|
|
registers. */
|
|
|
|
class register_dump_reg_buffer : public register_dump, reg_buffer
|
|
{
|
|
public:
|
|
register_dump_reg_buffer (gdbarch *gdbarch, bool dump_pseudo)
|
|
: register_dump (gdbarch), reg_buffer (gdbarch, dump_pseudo)
|
|
{
|
|
}
|
|
|
|
protected:
|
|
void dump_reg (ui_file *file, int regnum) override
|
|
{
|
|
if (regnum < 0)
|
|
{
|
|
if (m_has_pseudo)
|
|
fprintf_unfiltered (file, "Cooked value");
|
|
else
|
|
fprintf_unfiltered (file, "Raw value");
|
|
}
|
|
else
|
|
{
|
|
if (regnum < gdbarch_num_regs (m_gdbarch) || m_has_pseudo)
|
|
{
|
|
auto size = register_size (m_gdbarch, regnum);
|
|
|
|
if (size == 0)
|
|
return;
|
|
|
|
auto status = get_register_status (regnum);
|
|
|
|
gdb_assert (status != REG_VALID);
|
|
|
|
if (status == REG_UNKNOWN)
|
|
fprintf_unfiltered (file, "<invalid>");
|
|
else
|
|
fprintf_unfiltered (file, "<unavailable>");
|
|
}
|
|
else
|
|
{
|
|
/* Just print "<cooked>" for pseudo register when
|
|
regcache_dump_raw. */
|
|
fprintf_unfiltered (file, "<cooked>");
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
/* For "maint print registers". */
|
|
|
|
class register_dump_none : public register_dump
|
|
{
|
|
public:
|
|
register_dump_none (gdbarch *arch)
|
|
: register_dump (arch)
|
|
{}
|
|
|
|
protected:
|
|
void dump_reg (ui_file *file, int regnum) override
|
|
{}
|
|
};
|
|
|
|
/* For "maint print remote-registers". */
|
|
|
|
class register_dump_remote : public register_dump
|
|
{
|
|
public:
|
|
register_dump_remote (gdbarch *arch)
|
|
: register_dump (arch)
|
|
{}
|
|
|
|
protected:
|
|
void dump_reg (ui_file *file, int regnum) override
|
|
{
|
|
if (regnum < 0)
|
|
{
|
|
fprintf_unfiltered (file, "Rmt Nr g/G Offset");
|
|
}
|
|
else if (regnum < gdbarch_num_regs (m_gdbarch))
|
|
{
|
|
int pnum, poffset;
|
|
|
|
if (remote_register_number_and_offset (m_gdbarch, regnum,
|
|
&pnum, &poffset))
|
|
fprintf_unfiltered (file, "%7d %11d", pnum, poffset);
|
|
}
|
|
}
|
|
};
|
|
|
|
/* For "maint print register-groups". */
|
|
|
|
class register_dump_groups : public register_dump
|
|
{
|
|
public:
|
|
register_dump_groups (gdbarch *arch)
|
|
: register_dump (arch)
|
|
{}
|
|
|
|
protected:
|
|
void dump_reg (ui_file *file, int regnum) override
|
|
{
|
|
if (regnum < 0)
|
|
fprintf_unfiltered (file, "Groups");
|
|
else
|
|
{
|
|
const char *sep = "";
|
|
struct reggroup *group;
|
|
|
|
for (group = reggroup_next (m_gdbarch, NULL);
|
|
group != NULL;
|
|
group = reggroup_next (m_gdbarch, group))
|
|
{
|
|
if (gdbarch_register_reggroup_p (m_gdbarch, regnum, group))
|
|
{
|
|
fprintf_unfiltered (file,
|
|
"%s%s", sep, reggroup_name (group));
|
|
sep = ",";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
enum regcache_dump_what
|
|
{
|
|
regcache_dump_none, regcache_dump_raw,
|
|
regcache_dump_cooked, regcache_dump_groups,
|
|
regcache_dump_remote
|
|
};
|
|
|
|
static void
|
|
regcache_print (const char *args, enum regcache_dump_what what_to_dump)
|
|
{
|
|
/* Where to send output. */
|
|
stdio_file file;
|
|
ui_file *out;
|
|
|
|
if (args == NULL)
|
|
out = gdb_stdout;
|
|
else
|
|
{
|
|
if (!file.open (args, "w"))
|
|
perror_with_name (_("maintenance print architecture"));
|
|
out = &file;
|
|
}
|
|
|
|
std::unique_ptr<register_dump> dump;
|
|
std::unique_ptr<regcache> regs;
|
|
gdbarch *gdbarch;
|
|
|
|
if (target_has_registers)
|
|
gdbarch = get_current_regcache ()->arch ();
|
|
else
|
|
gdbarch = target_gdbarch ();
|
|
|
|
switch (what_to_dump)
|
|
{
|
|
case regcache_dump_none:
|
|
dump.reset (new register_dump_none (gdbarch));
|
|
break;
|
|
case regcache_dump_remote:
|
|
dump.reset (new register_dump_remote (gdbarch));
|
|
break;
|
|
case regcache_dump_groups:
|
|
dump.reset (new register_dump_groups (gdbarch));
|
|
break;
|
|
case regcache_dump_raw:
|
|
case regcache_dump_cooked:
|
|
{
|
|
auto dump_pseudo = (what_to_dump == regcache_dump_cooked);
|
|
|
|
if (target_has_registers)
|
|
dump.reset (new register_dump_regcache (get_current_regcache (),
|
|
dump_pseudo));
|
|
else
|
|
{
|
|
/* For the benefit of "maint print registers" & co when
|
|
debugging an executable, allow dumping a regcache even when
|
|
there is no thread selected / no registers. */
|
|
dump.reset (new register_dump_reg_buffer (target_gdbarch (),
|
|
dump_pseudo));
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
|
|
dump->dump (out);
|
|
}
|
|
|
|
static void
|
|
maintenance_print_registers (const char *args, int from_tty)
|
|
{
|
|
regcache_print (args, regcache_dump_none);
|
|
}
|
|
|
|
static void
|
|
maintenance_print_raw_registers (const char *args, int from_tty)
|
|
{
|
|
regcache_print (args, regcache_dump_raw);
|
|
}
|
|
|
|
static void
|
|
maintenance_print_cooked_registers (const char *args, int from_tty)
|
|
{
|
|
regcache_print (args, regcache_dump_cooked);
|
|
}
|
|
|
|
static void
|
|
maintenance_print_register_groups (const char *args, int from_tty)
|
|
{
|
|
regcache_print (args, regcache_dump_groups);
|
|
}
|
|
|
|
static void
|
|
maintenance_print_remote_registers (const char *args, int from_tty)
|
|
{
|
|
regcache_print (args, regcache_dump_remote);
|
|
}
|
|
|
|
void
|
|
_initialize_regcache_dump (void)
|
|
{
|
|
add_cmd ("registers", class_maintenance, maintenance_print_registers,
|
|
_("Print the internal register configuration.\n"
|
|
"Takes an optional file parameter."), &maintenanceprintlist);
|
|
add_cmd ("raw-registers", class_maintenance,
|
|
maintenance_print_raw_registers,
|
|
_("Print the internal register configuration "
|
|
"including raw values.\n"
|
|
"Takes an optional file parameter."), &maintenanceprintlist);
|
|
add_cmd ("cooked-registers", class_maintenance,
|
|
maintenance_print_cooked_registers,
|
|
_("Print the internal register configuration "
|
|
"including cooked values.\n"
|
|
"Takes an optional file parameter."), &maintenanceprintlist);
|
|
add_cmd ("register-groups", class_maintenance,
|
|
maintenance_print_register_groups,
|
|
_("Print the internal register configuration "
|
|
"including each register's group.\n"
|
|
"Takes an optional file parameter."),
|
|
&maintenanceprintlist);
|
|
add_cmd ("remote-registers", class_maintenance,
|
|
maintenance_print_remote_registers, _("\
|
|
Print the internal register configuration including each register's\n\
|
|
remote register number and buffer offset in the g/G packets.\n\
|
|
Takes an optional file parameter."),
|
|
&maintenanceprintlist);
|
|
}
|