mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-02 20:53:06 +08:00
Use std::string and unique_xmalloc_ptr in compile/ code
Change various things in the compile/ code to use std::string or unique_xmalloc_ptr as appropriate. This allows the removal of some cleanups. ChangeLog 2017-09-03 Tom Tromey <tom@tromey.com> * compile/compile.c (compile_register_name_mangled): Return std::string. * compile/compile-loc2c.c (pushf_register_address): Update. (pushf_register): Update. * compile/compile-c-types.c (convert_array): Update. * compile/compile-c-symbols.c (generate_vla_size): Update. (error_symbol_once): Use a gdb::unique_xmalloc_ptr. (symbol_substitution_name): Return a gdb::unique_xmalloc_ptr. (convert_one_symbol): Update. (generate_c_for_for_one_variable): Update. * compile/compile-c-support.c (c_get_range_decl_name): Return a std::string. (generate_register_struct): Update. * compile/compile-internal.h (c_get_range_decl_name): Return a std::string. (compile_register_name_mangled): Return std::string.
This commit is contained in:
@ -58,10 +58,10 @@ c_get_mode_for_size (int size)
|
||||
|
||||
/* See compile-internal.h. */
|
||||
|
||||
char *
|
||||
std::string
|
||||
c_get_range_decl_name (const struct dynamic_prop *prop)
|
||||
{
|
||||
return xstrprintf ("__gdb_prop_%s", host_address_to_string (prop));
|
||||
return string_printf ("__gdb_prop_%s", host_address_to_string (prop));
|
||||
}
|
||||
|
||||
|
||||
@ -263,8 +263,7 @@ generate_register_struct (struct ui_file *stream, struct gdbarch *gdbarch,
|
||||
if (registers_used[i])
|
||||
{
|
||||
struct type *regtype = check_typedef (register_type (gdbarch, i));
|
||||
char *regname = compile_register_name_mangled (gdbarch, i);
|
||||
struct cleanup *cleanups = make_cleanup (xfree, regname);
|
||||
std::string regname = compile_register_name_mangled (gdbarch, i);
|
||||
|
||||
seen = 1;
|
||||
|
||||
@ -282,7 +281,8 @@ generate_register_struct (struct ui_file *stream, struct gdbarch *gdbarch,
|
||||
switch (TYPE_CODE (regtype))
|
||||
{
|
||||
case TYPE_CODE_PTR:
|
||||
fprintf_filtered (stream, "__gdb_uintptr %s", regname);
|
||||
fprintf_filtered (stream, "__gdb_uintptr %s",
|
||||
regname.c_str ());
|
||||
break;
|
||||
|
||||
case TYPE_CODE_INT:
|
||||
@ -297,7 +297,7 @@ generate_register_struct (struct ui_file *stream, struct gdbarch *gdbarch,
|
||||
fprintf_unfiltered (stream,
|
||||
"int %s"
|
||||
" __attribute__ ((__mode__(__%s__)))",
|
||||
regname,
|
||||
regname.c_str (),
|
||||
mode);
|
||||
break;
|
||||
}
|
||||
@ -310,12 +310,10 @@ generate_register_struct (struct ui_file *stream, struct gdbarch *gdbarch,
|
||||
" unsigned char %s[%d]"
|
||||
" __attribute__((__aligned__("
|
||||
"__BIGGEST_ALIGNMENT__)))",
|
||||
regname,
|
||||
regname.c_str (),
|
||||
TYPE_LENGTH (regtype));
|
||||
}
|
||||
fputs_unfiltered (";\n", stream);
|
||||
|
||||
do_cleanups (cleanups);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user