Copyright (C) 2018 Free Software Foundation, Inc.
- Contributed by Alessandro Forin(af@cs.cmu.edu) at CMU
- and by Per Bothner(bothner@cs.wisc.edu) at U.Wisconsin
- and by Todd Snyder <todd@bluespec.com>
- and by Mike Frysinger <vapier@gentoo.org>.
-
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
#include "common-defs.h"
#include "opcode/riscv-opc.h"
#include "cli/cli-decode.h"
-#include "observer.h"
+#include "observable.h"
/* The stack must be 16-byte aligned. */
#define SP_ALIGNMENT 16
case 4:
return ebreak;
default:
- gdb_assert_not_reached ("unhandled breakpoint kind");
+ gdb_assert_not_reached (_("unhandled breakpoint kind"));
}
}
static const char *
riscv_register_name (struct gdbarch *gdbarch, int regnum)
{
- if (tdesc_has_registers (gdbarch_target_desc (gdbarch)))
- return tdesc_register_name (gdbarch, regnum);
-
/* Prefer to use the alias. */
if (regnum >= RISCV_ZERO_REGNUM && regnum <= RISCV_LAST_REGNUM)
{
{
static char buf[20];
- sprintf (buf, "csr%d", regnum - RISCV_FIRST_CSR_REGNUM);
+ xsnprintf (buf, sizeof (buf), "csr%d",
+ regnum - RISCV_FIRST_CSR_REGNUM);
return buf;
}
/* If we need more, grab it now. */
instlen = riscv_insn_length (buf[0]);
+ gdb_assert (instlen <= sizeof (buf));
*len = instlen;
- if (instlen > sizeof (buf))
- internal_error (__FILE__, __LINE__,
- _("%s: riscv_insn_length returned %i"),
- __func__, instlen);
- else if (instlen > 2)
+
+ if (instlen > 2)
{
status = target_read_memory (addr + 2, buf + 2, instlen - 2);
if (status)
break;
default:
- error ("unknown argument location type");
+ gdb_assert_not_reached (_("unknown argument location type"));
}
}
break;
default:
- error ("unknown argument location type");
+ gdb_assert_not_reached (_("unknown argument location type"));
}
if (second_arg_length > 0)
dwarf2_append_unwinders (gdbarch);
frame_unwind_append_unwinder (gdbarch, &riscv_frame_unwind);
- /* Check any target description for validity. */
- if (tdesc_has_registers (info.target_desc))
- {
- const struct tdesc_feature *feature;
- struct tdesc_arch_data *tdesc_data;
- int valid_p;
-
- feature = tdesc_find_feature (info.target_desc, "org.gnu.gdb.riscv.cpu");
- if (feature == NULL)
- goto no_tdata;
-
- tdesc_data = tdesc_data_alloc ();
-
- valid_p = 1;
- for (i = RISCV_ZERO_REGNUM; i <= RISCV_LAST_FP_REGNUM; ++i)
- valid_p &= tdesc_numbered_register (feature, tdesc_data, i,
- riscv_gdb_reg_names[i]);
- for (i = RISCV_FIRST_CSR_REGNUM; i <= RISCV_LAST_CSR_REGNUM; ++i)
- {
- char buf[20];
-
- sprintf (buf, "csr%d", i - RISCV_FIRST_CSR_REGNUM);
- valid_p &= tdesc_numbered_register (feature, tdesc_data, i, buf);
- }
-
- valid_p &= tdesc_numbered_register (feature, tdesc_data, i++, "priv");
-
- if (!valid_p)
- tdesc_data_cleanup (tdesc_data);
- else
- tdesc_use_registers (gdbarch, info.target_desc, tdesc_data);
- }
- no_tdata:
-
for (i = 0; i < ARRAY_SIZE (riscv_register_aliases); ++i)
user_reg_add (gdbarch, riscv_register_aliases[i].name,
value_of_riscv_user_reg, &riscv_register_aliases[i].regnum);
= register_inferior_data_with_cleanup (NULL, riscv_inferior_data_cleanup);
/* Observers used to invalidate the inferior data when needed. */
- observer_attach_inferior_exit (riscv_invalidate_inferior_data);
- observer_attach_inferior_appeared (riscv_invalidate_inferior_data);
+ gdb::observers::inferior_exit.attach (riscv_invalidate_inferior_data);
+ gdb::observers::inferior_appeared.attach (riscv_invalidate_inferior_data);
/* Add root prefix command for all "set debug riscv" and "show debug
riscv" commands. */