- /* Leading space always present. */
- fprintf_unfiltered (file, " ");
-
- dump_reg (file, regnum);
-
- fprintf_unfiltered (file, "\n");
- }
-
- if (footnote_register_offset)
- fprintf_unfiltered (file, "*%d: Inconsistent register offsets.\n",
- footnote_register_offset);
- if (footnote_register_type_name_null)
- fprintf_unfiltered (file,
- "*%d: Register type's name NULL.\n",
- footnote_register_type_name_null);
- }
-
- virtual ~register_dump () {};
-
-protected:
- register_dump (gdbarch *arch)
- : m_gdbarch (arch)
- {}
-
- /* Dump the register REGNUM contents. If REGNUM is -1, print the
- header. */
- virtual void dump_reg (ui_file *file, int regnum) = 0;
-
- gdbarch *m_gdbarch;
-};
-
-/* Dump registers from regcache, used for dump 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)
- {
- }