+2021-01-23 Tom Tromey <tom@tromey.com>
+
+ * symtab.h (struct symbol_computed_ops) <generate_c_location>:
+ Change type of "registers_used".
+ * dwarf2/loc.h (dwarf2_compile_property_to_c): Update.
+ * dwarf2/loc.c (dwarf2_compile_property_to_c)
+ (locexpr_generate_c_location, loclist_generate_c_location): Change
+ type of "registers_used".
+ * compile/compile.h (compile_dwarf_expr_to_c)
+ (compile_dwarf_bounds_to_c): Update.
+ * compile/compile-loc2c.c (pushf_register_address)
+ (pushf_register, do_compile_dwarf_expr_to_c)
+ (compile_dwarf_expr_to_c, compile_dwarf_bounds_to_c): Change type
+ of "registers_used".
+ * compile/compile-c.h (generate_c_for_variable_locations):
+ Update.
+ * compile/compile-c-symbols.c (generate_vla_size)
+ (generate_c_for_for_one_variable): Change type of
+ "registers_used".
+ (generate_c_for_variable_locations): Return std::vector.
+ * compile/compile-c-support.c (generate_register_struct): Change
+ type of "registers_used".
+ (compute): Update.
+
2021-01-23 Tom Tromey <tom@tromey.com>
* compile/compile-internal.h (class compile_instance)
static void
generate_register_struct (struct ui_file *stream, struct gdbarch *gdbarch,
- const unsigned char *registers_used)
+ const std::vector<bool> ®isters_used)
{
int i;
int seen = 0;
fputs_unfiltered ("struct " COMPILE_I_SIMPLE_REGISTER_STRUCT_TAG " {\n",
stream);
- if (registers_used != NULL)
+ if (!registers_used.empty ())
for (i = 0; i < gdbarch_num_regs (gdbarch); ++i)
{
if (registers_used[i])
before generating the function header, so we can define the
register struct before the function body. This requires a
temporary stream. */
- gdb::unique_xmalloc_ptr<unsigned char> registers_used
+ std::vector<bool> registers_used
= generate_c_for_variable_locations (m_instance, &var_stream, m_arch,
expr_block, expr_pc);
mode, mode);
}
- generate_register_struct (&buf, m_arch, registers_used.get ());
+ generate_register_struct (&buf, m_arch, registers_used);
}
AddCodeHeaderPolicy::add_code_header (m_instance->scope (), &buf);
generate_vla_size (compile_instance *compiler,
string_file *stream,
struct gdbarch *gdbarch,
- unsigned char *registers_used,
+ std::vector<bool> ®isters_used,
CORE_ADDR pc,
struct type *type,
struct symbol *sym)
generate_c_for_for_one_variable (compile_instance *compiler,
string_file *stream,
struct gdbarch *gdbarch,
- unsigned char *registers_used,
+ std::vector<bool> ®isters_used,
CORE_ADDR pc,
struct symbol *sym)
{
/* See compile-c.h. */
-gdb::unique_xmalloc_ptr<unsigned char>
+std::vector<bool>
generate_c_for_variable_locations (compile_instance *compiler,
string_file *stream,
struct gdbarch *gdbarch,
/* If we're already in the static or global block, there is nothing
to write. */
if (static_block == NULL || block == static_block)
- return NULL;
+ return {};
- gdb::unique_xmalloc_ptr<unsigned char> registers_used
- (XCNEWVEC (unsigned char, gdbarch_num_regs (gdbarch)));
+ std::vector<bool> registers_used (gdbarch_num_regs (gdbarch));
/* Ensure that a given name is only entered once. This reflects the
reality of shadowing. */
{
if (!symbol_seen (symhash.get (), sym))
generate_c_for_for_one_variable (compiler, stream, gdbarch,
- registers_used.get (), pc, sym);
+ registers_used, pc, sym);
}
/* If we just finished the outermost block of a function, we're
register number, where each element indicates if the corresponding
register is needed to compute a local variable. */
-extern gdb::unique_xmalloc_ptr<unsigned char>
+extern std::vector<bool>
generate_c_for_variable_locations
(compile_instance *compiler,
string_file *stream,
static void
pushf_register_address (int indent, string_file *stream,
- unsigned char *registers_used,
+ std::vector<bool> ®isters_used,
struct gdbarch *gdbarch, int regnum)
{
std::string regname = compile_register_name_mangled (gdbarch, regnum);
- registers_used[regnum] = 1;
+ registers_used[regnum] = true;
pushf (indent, stream,
"(" GCC_UINTPTR ") &" COMPILE_I_SIMPLE_REGISTER_ARG_NAME "->%s",
regname.c_str ());
static void
pushf_register (int indent, string_file *stream,
- unsigned char *registers_used,
+ std::vector<bool> ®isters_used,
struct gdbarch *gdbarch, int regnum, uint64_t offset)
{
std::string regname = compile_register_name_mangled (gdbarch, regnum);
- registers_used[regnum] = 1;
+ registers_used[regnum] = true;
if (offset == 0)
pushf (indent, stream, COMPILE_I_SIMPLE_REGISTER_ARG_NAME "->%s",
regname.c_str ());
const char *result_name,
struct symbol *sym, CORE_ADDR pc,
struct gdbarch *arch,
- unsigned char *registers_used,
+ std::vector<bool> ®isters_used,
unsigned int addr_size,
const gdb_byte *op_ptr, const gdb_byte *op_end,
CORE_ADDR *initial,
void
compile_dwarf_expr_to_c (string_file *stream, const char *result_name,
struct symbol *sym, CORE_ADDR pc,
- struct gdbarch *arch, unsigned char *registers_used,
+ struct gdbarch *arch,
+ std::vector<bool> ®isters_used,
unsigned int addr_size,
const gdb_byte *op_ptr, const gdb_byte *op_end,
dwarf2_per_cu_data *per_cu,
const char *result_name,
const struct dynamic_prop *prop,
struct symbol *sym, CORE_ADDR pc,
- struct gdbarch *arch, unsigned char *registers_used,
+ struct gdbarch *arch,
+ std::vector<bool> ®isters_used,
unsigned int addr_size,
const gdb_byte *op_ptr, const gdb_byte *op_end,
dwarf2_per_cu_data *per_cu,
struct symbol *sym,
CORE_ADDR pc,
struct gdbarch *arch,
- unsigned char *registers_used,
+ std::vector<bool> ®isters_used,
unsigned int addr_size,
const gdb_byte *op_ptr,
const gdb_byte *op_end,
const struct dynamic_prop *prop,
struct symbol *sym, CORE_ADDR pc,
struct gdbarch *arch,
- unsigned char *registers_used,
+ std::vector<bool> ®isters_used,
unsigned int addr_size,
const gdb_byte *op_ptr,
const gdb_byte *op_end,
dwarf2_compile_property_to_c (string_file *stream,
const char *result_name,
struct gdbarch *gdbarch,
- unsigned char *registers_used,
+ std::vector<bool> ®isters_used,
const struct dynamic_prop *prop,
CORE_ADDR pc,
struct symbol *sym)
static void
locexpr_generate_c_location (struct symbol *sym, string_file *stream,
struct gdbarch *gdbarch,
- unsigned char *registers_used,
+ std::vector<bool> ®isters_used,
CORE_ADDR pc, const char *result_name)
{
struct dwarf2_locexpr_baton *dlbaton
static void
loclist_generate_c_location (struct symbol *sym, string_file *stream,
struct gdbarch *gdbarch,
- unsigned char *registers_used,
+ std::vector<bool> ®isters_used,
CORE_ADDR pc, const char *result_name)
{
struct dwarf2_loclist_baton *dlbaton
void dwarf2_compile_property_to_c (string_file *stream,
const char *result_name,
struct gdbarch *gdbarch,
- unsigned char *registers_used,
+ std::vector<bool> ®isters_used,
const struct dynamic_prop *prop,
CORE_ADDR address,
struct symbol *sym);
void (*generate_c_location) (struct symbol *symbol, string_file *stream,
struct gdbarch *gdbarch,
- unsigned char *registers_used,
+ std::vector<bool> ®isters_used,
CORE_ADDR pc, const char *result_name);
};