forked from Imagelibrary/binutils-gdb
Use std::vector for "registers_used" in compile feature
This changes the GDB compile code to use std::vector<bool> when computing which registers are used. This is a bit more idiomatic, but the main benefit is that it also adds some checking when the libstd++ debug mode is enabled. 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.
This commit is contained in:
@@ -487,7 +487,7 @@ static void
|
||||
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)
|
||||
@@ -541,7 +541,7 @@ static void
|
||||
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)
|
||||
{
|
||||
@@ -606,7 +606,7 @@ generate_c_for_for_one_variable (compile_instance *compiler,
|
||||
|
||||
/* 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,
|
||||
@@ -618,10 +618,9 @@ generate_c_for_variable_locations (compile_instance *compiler,
|
||||
/* 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. */
|
||||
@@ -641,7 +640,7 @@ generate_c_for_variable_locations (compile_instance *compiler,
|
||||
{
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user