Eliminate make_cleanup_obstack_free, introduce auto_obstack
This commit eliminates make_cleanup_obstack_free, replacing it with a new auto_obstack type that inherits obstack to add cdtors. These changes in the parsers may not be obvious: - obstack_init (&name_obstack); - make_cleanup_obstack_free (&name_obstack); + name_obstack.clear (); Here, the 'name_obstack' variable is a global. The change means that the obstack's contents from a previous parse will stay around until the next parsing starts. I.e., memory won't be reclaimed until then. I don't think that's a problem, these objects don't really grow much at all. The other option I tried was to add a separate type that is like auto_obstack but manages an external obstack, just for those cases. I like the current approach better as that other approach adds more boilerplate and yet another type to learn. gdb/ChangeLog: 2017-06-27 Pedro Alves <palves@redhat.com> * c-exp.y (name_obstack): Now an auto_obstack. (yylex): Use auto_obstack::clear. (c_parse): Use auto_obstack::clear instead of reinitializing and freeing the obstack. * c-lang.c (evaluate_subexp_c): Use auto_obstack. * d-exp.y (name_obstack): Now an auto_obstack. (yylex): Use auto_obstack::clear. (d_parse): Use auto_obstack::clear instead of reinitializing and freeing the obstack. * dwarf2loc.c (fetch_const_value_from_synthetic_pointer): Use auto_obstack. * dwarf2read.c (create_addrmap_from_index) (dwarf2_build_psymtabs_hard) (update_enumeration_type_from_children): Likewise. * gdb_obstack.h (auto_obstack): New type. * go-exp.y (name_obstack): Now an auto_obstack. (build_packaged_name): Use auto_obstack::clear. (go_parse): Use auto_obstack::clear instead of reinitializing and freeing the obstack. * linux-tdep.c (linux_make_mappings_corefile_notes): Use auto_obstack. * printcmd.c (printf_wide_c_string, ui_printf): Use auto_obstack. * rust-exp.y (work_obstack): Now an auto_obstack. (rust_parse, rust_lex_tests): Use auto_obstack::clear instead of reinitializing and freeing the obstack. * utils.c (do_obstack_free, make_cleanup_obstack_free): Delete. (host_char_to_target): Use auto_obstack. * utils.h (make_cleanup_obstack_free): Delete declaration. * valprint.c (generic_emit_char, generic_printstr): Use auto_obstack.
This commit is contained in:
parent
6806377956
commit
8268c77870
14 changed files with 88 additions and 100 deletions
|
@ -1,3 +1,36 @@
|
||||||
|
2017-06-27 Pedro Alves <palves@redhat.com>
|
||||||
|
|
||||||
|
* c-exp.y (name_obstack): Now an auto_obstack.
|
||||||
|
(yylex): Use auto_obstack::clear.
|
||||||
|
(c_parse): Use auto_obstack::clear instead of reinitializing and
|
||||||
|
freeing the obstack.
|
||||||
|
* c-lang.c (evaluate_subexp_c): Use auto_obstack.
|
||||||
|
* d-exp.y (name_obstack): Now an auto_obstack.
|
||||||
|
(yylex): Use auto_obstack::clear.
|
||||||
|
(d_parse): Use auto_obstack::clear instead of reinitializing and
|
||||||
|
freeing the obstack.
|
||||||
|
* dwarf2loc.c (fetch_const_value_from_synthetic_pointer): Use
|
||||||
|
auto_obstack.
|
||||||
|
* dwarf2read.c (create_addrmap_from_index)
|
||||||
|
(dwarf2_build_psymtabs_hard)
|
||||||
|
(update_enumeration_type_from_children): Likewise.
|
||||||
|
* gdb_obstack.h (auto_obstack): New type.
|
||||||
|
* go-exp.y (name_obstack): Now an auto_obstack.
|
||||||
|
(build_packaged_name): Use auto_obstack::clear.
|
||||||
|
(go_parse): Use auto_obstack::clear instead of reinitializing and
|
||||||
|
freeing the obstack.
|
||||||
|
* linux-tdep.c (linux_make_mappings_corefile_notes): Use
|
||||||
|
auto_obstack.
|
||||||
|
* printcmd.c (printf_wide_c_string, ui_printf): Use auto_obstack.
|
||||||
|
* rust-exp.y (work_obstack): Now an auto_obstack.
|
||||||
|
(rust_parse, rust_lex_tests): Use auto_obstack::clear instead of
|
||||||
|
reinitializing and freeing the obstack.
|
||||||
|
* utils.c (do_obstack_free, make_cleanup_obstack_free): Delete.
|
||||||
|
(host_char_to_target): Use auto_obstack.
|
||||||
|
* utils.h (make_cleanup_obstack_free): Delete declaration.
|
||||||
|
* valprint.c (generic_emit_char, generic_printstr): Use
|
||||||
|
auto_obstack.
|
||||||
|
|
||||||
2017-06-27 Simon Marchi <simon.marchi@ericsson.com>
|
2017-06-27 Simon Marchi <simon.marchi@ericsson.com>
|
||||||
|
|
||||||
* darwin-nat.c (darwin_check_new_threads): Don't handle dummy
|
* darwin-nat.c (darwin_check_new_threads): Don't handle dummy
|
||||||
|
|
10
gdb/c-exp.y
10
gdb/c-exp.y
|
@ -2806,7 +2806,7 @@ static int popping;
|
||||||
|
|
||||||
/* Temporary storage for c_lex; this holds symbol names as they are
|
/* Temporary storage for c_lex; this holds symbol names as they are
|
||||||
built up. */
|
built up. */
|
||||||
static struct obstack name_obstack;
|
auto_obstack name_obstack;
|
||||||
|
|
||||||
/* Classify a NAME token. The contents of the token are in `yylval'.
|
/* Classify a NAME token. The contents of the token are in `yylval'.
|
||||||
Updates yylval and returns the new token type. BLOCK is the block
|
Updates yylval and returns the new token type. BLOCK is the block
|
||||||
|
@ -3067,7 +3067,7 @@ yylex (void)
|
||||||
current = *VEC_index (token_and_value, token_fifo, next_to_examine);
|
current = *VEC_index (token_and_value, token_fifo, next_to_examine);
|
||||||
++next_to_examine;
|
++next_to_examine;
|
||||||
|
|
||||||
obstack_free (&name_obstack, obstack_base (&name_obstack));
|
name_obstack.clear ();
|
||||||
checkpoint = 0;
|
checkpoint = 0;
|
||||||
if (current.token == FILENAME)
|
if (current.token == FILENAME)
|
||||||
search_block = current.value.bval;
|
search_block = current.value.bval;
|
||||||
|
@ -3169,6 +3169,9 @@ c_parse (struct parser_state *par_state)
|
||||||
gdb_assert (par_state != NULL);
|
gdb_assert (par_state != NULL);
|
||||||
pstate = par_state;
|
pstate = par_state;
|
||||||
|
|
||||||
|
/* Note that parsing (within yyparse) freely installs cleanups
|
||||||
|
assuming they'll be run here (below). */
|
||||||
|
|
||||||
back_to = make_cleanup (free_current_contents, &expression_macro_scope);
|
back_to = make_cleanup (free_current_contents, &expression_macro_scope);
|
||||||
make_cleanup_clear_parser_state (&pstate);
|
make_cleanup_clear_parser_state (&pstate);
|
||||||
|
|
||||||
|
@ -3197,8 +3200,7 @@ c_parse (struct parser_state *par_state)
|
||||||
|
|
||||||
VEC_free (token_and_value, token_fifo);
|
VEC_free (token_and_value, token_fifo);
|
||||||
popping = 0;
|
popping = 0;
|
||||||
obstack_init (&name_obstack);
|
name_obstack.clear ();
|
||||||
make_cleanup_obstack_free (&name_obstack);
|
|
||||||
|
|
||||||
result = yyparse ();
|
result = yyparse ();
|
||||||
do_cleanups (back_to);
|
do_cleanups (back_to);
|
||||||
|
|
|
@ -570,15 +570,12 @@ evaluate_subexp_c (struct type *expect_type, struct expression *exp,
|
||||||
{
|
{
|
||||||
int oplen, limit;
|
int oplen, limit;
|
||||||
struct type *type;
|
struct type *type;
|
||||||
struct obstack output;
|
|
||||||
struct cleanup *cleanup;
|
|
||||||
struct value *result;
|
struct value *result;
|
||||||
c_string_type dest_type;
|
c_string_type dest_type;
|
||||||
const char *dest_charset;
|
const char *dest_charset;
|
||||||
int satisfy_expected = 0;
|
int satisfy_expected = 0;
|
||||||
|
|
||||||
obstack_init (&output);
|
auto_obstack output;
|
||||||
cleanup = make_cleanup_obstack_free (&output);
|
|
||||||
|
|
||||||
++*pos;
|
++*pos;
|
||||||
oplen = longest_to_int (exp->elts[*pos].longconst);
|
oplen = longest_to_int (exp->elts[*pos].longconst);
|
||||||
|
@ -656,7 +653,6 @@ evaluate_subexp_c (struct type *expect_type, struct expression *exp,
|
||||||
result = allocate_value (type);
|
result = allocate_value (type);
|
||||||
else
|
else
|
||||||
result = value_cstring ("", 0, type);
|
result = value_cstring ("", 0, type);
|
||||||
do_cleanups (cleanup);
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -702,7 +698,6 @@ evaluate_subexp_c (struct type *expect_type, struct expression *exp,
|
||||||
obstack_object_size (&output),
|
obstack_object_size (&output),
|
||||||
type);
|
type);
|
||||||
}
|
}
|
||||||
do_cleanups (cleanup);
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
11
gdb/d-exp.y
11
gdb/d-exp.y
|
@ -1342,7 +1342,7 @@ static int popping;
|
||||||
|
|
||||||
/* Temporary storage for yylex; this holds symbol names as they are
|
/* Temporary storage for yylex; this holds symbol names as they are
|
||||||
built up. */
|
built up. */
|
||||||
static struct obstack name_obstack;
|
static auto_obstack name_obstack;
|
||||||
|
|
||||||
/* Classify an IDENTIFIER token. The contents of the token are in `yylval'.
|
/* Classify an IDENTIFIER token. The contents of the token are in `yylval'.
|
||||||
Updates yylval and returns the new token type. BLOCK is the block
|
Updates yylval and returns the new token type. BLOCK is the block
|
||||||
|
@ -1480,7 +1480,7 @@ yylex (void)
|
||||||
first try building up a name until we find the qualified module. */
|
first try building up a name until we find the qualified module. */
|
||||||
if (current.token == UNKNOWN_NAME)
|
if (current.token == UNKNOWN_NAME)
|
||||||
{
|
{
|
||||||
obstack_free (&name_obstack, obstack_base (&name_obstack));
|
name_obstack.clear ();
|
||||||
obstack_grow (&name_obstack, current.value.sval.ptr,
|
obstack_grow (&name_obstack, current.value.sval.ptr,
|
||||||
current.value.sval.length);
|
current.value.sval.length);
|
||||||
|
|
||||||
|
@ -1533,7 +1533,7 @@ yylex (void)
|
||||||
if (current.token != TYPENAME && current.token != '.')
|
if (current.token != TYPENAME && current.token != '.')
|
||||||
goto do_pop;
|
goto do_pop;
|
||||||
|
|
||||||
obstack_free (&name_obstack, obstack_base (&name_obstack));
|
name_obstack.clear ();
|
||||||
checkpoint = 0;
|
checkpoint = 0;
|
||||||
if (current.token == '.')
|
if (current.token == '.')
|
||||||
search_block = NULL;
|
search_block = NULL;
|
||||||
|
@ -1627,6 +1627,8 @@ d_parse (struct parser_state *par_state)
|
||||||
gdb_assert (par_state != NULL);
|
gdb_assert (par_state != NULL);
|
||||||
pstate = par_state;
|
pstate = par_state;
|
||||||
|
|
||||||
|
/* Note that parsing (within yyparse) freely installs cleanups
|
||||||
|
assuming they're run here (below). */
|
||||||
back_to = make_cleanup (null_cleanup, NULL);
|
back_to = make_cleanup (null_cleanup, NULL);
|
||||||
|
|
||||||
scoped_restore restore_yydebug = make_scoped_restore (&yydebug,
|
scoped_restore restore_yydebug = make_scoped_restore (&yydebug,
|
||||||
|
@ -1639,8 +1641,7 @@ d_parse (struct parser_state *par_state)
|
||||||
|
|
||||||
VEC_free (token_and_value, token_fifo);
|
VEC_free (token_and_value, token_fifo);
|
||||||
popping = 0;
|
popping = 0;
|
||||||
obstack_init (&name_obstack);
|
name_obstack.clear ();
|
||||||
make_cleanup_obstack_free (&name_obstack);
|
|
||||||
|
|
||||||
result = yyparse ();
|
result = yyparse ();
|
||||||
do_cleanups (back_to);
|
do_cleanups (back_to);
|
||||||
|
|
|
@ -2121,13 +2121,10 @@ fetch_const_value_from_synthetic_pointer (sect_offset die, LONGEST byte_offset,
|
||||||
struct type *type)
|
struct type *type)
|
||||||
{
|
{
|
||||||
struct value *result = NULL;
|
struct value *result = NULL;
|
||||||
struct obstack temp_obstack;
|
|
||||||
struct cleanup *cleanup;
|
|
||||||
const gdb_byte *bytes;
|
const gdb_byte *bytes;
|
||||||
LONGEST len;
|
LONGEST len;
|
||||||
|
|
||||||
obstack_init (&temp_obstack);
|
auto_obstack temp_obstack;
|
||||||
cleanup = make_cleanup_obstack_free (&temp_obstack);
|
|
||||||
bytes = dwarf2_fetch_constant_bytes (die, per_cu, &temp_obstack, &len);
|
bytes = dwarf2_fetch_constant_bytes (die, per_cu, &temp_obstack, &len);
|
||||||
|
|
||||||
if (bytes != NULL)
|
if (bytes != NULL)
|
||||||
|
@ -2144,8 +2141,6 @@ fetch_const_value_from_synthetic_pointer (sect_offset die, LONGEST byte_offset,
|
||||||
else
|
else
|
||||||
result = allocate_optimized_out_value (TYPE_TARGET_TYPE (type));
|
result = allocate_optimized_out_value (TYPE_TARGET_TYPE (type));
|
||||||
|
|
||||||
do_cleanups (cleanup);
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3060,13 +3060,11 @@ create_addrmap_from_index (struct objfile *objfile, struct mapped_index *index)
|
||||||
{
|
{
|
||||||
struct gdbarch *gdbarch = get_objfile_arch (objfile);
|
struct gdbarch *gdbarch = get_objfile_arch (objfile);
|
||||||
const gdb_byte *iter, *end;
|
const gdb_byte *iter, *end;
|
||||||
struct obstack temp_obstack;
|
|
||||||
struct addrmap *mutable_map;
|
struct addrmap *mutable_map;
|
||||||
struct cleanup *cleanup;
|
|
||||||
CORE_ADDR baseaddr;
|
CORE_ADDR baseaddr;
|
||||||
|
|
||||||
obstack_init (&temp_obstack);
|
auto_obstack temp_obstack;
|
||||||
cleanup = make_cleanup_obstack_free (&temp_obstack);
|
|
||||||
mutable_map = addrmap_create_mutable (&temp_obstack);
|
mutable_map = addrmap_create_mutable (&temp_obstack);
|
||||||
|
|
||||||
iter = index->address_table;
|
iter = index->address_table;
|
||||||
|
@ -3107,7 +3105,6 @@ create_addrmap_from_index (struct objfile *objfile, struct mapped_index *index)
|
||||||
|
|
||||||
objfile->psymtabs_addrmap = addrmap_create_fixed (mutable_map,
|
objfile->psymtabs_addrmap = addrmap_create_fixed (mutable_map,
|
||||||
&objfile->objfile_obstack);
|
&objfile->objfile_obstack);
|
||||||
do_cleanups (cleanup);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The hash function for strings in the mapped index. This is the same as
|
/* The hash function for strings in the mapped index. This is the same as
|
||||||
|
@ -6626,7 +6623,6 @@ static void
|
||||||
dwarf2_build_psymtabs_hard (struct objfile *objfile)
|
dwarf2_build_psymtabs_hard (struct objfile *objfile)
|
||||||
{
|
{
|
||||||
struct cleanup *back_to, *addrmap_cleanup;
|
struct cleanup *back_to, *addrmap_cleanup;
|
||||||
struct obstack temp_obstack;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (dwarf_read_debug)
|
if (dwarf_read_debug)
|
||||||
|
@ -6649,8 +6645,7 @@ dwarf2_build_psymtabs_hard (struct objfile *objfile)
|
||||||
|
|
||||||
/* Create a temporary address map on a temporary obstack. We later
|
/* Create a temporary address map on a temporary obstack. We later
|
||||||
copy this to the final obstack. */
|
copy this to the final obstack. */
|
||||||
obstack_init (&temp_obstack);
|
auto_obstack temp_obstack;
|
||||||
make_cleanup_obstack_free (&temp_obstack);
|
|
||||||
objfile->psymtabs_addrmap = addrmap_create_mutable (&temp_obstack);
|
objfile->psymtabs_addrmap = addrmap_create_mutable (&temp_obstack);
|
||||||
addrmap_cleanup = make_cleanup (psymtabs_addrmap_cleanup, objfile);
|
addrmap_cleanup = make_cleanup (psymtabs_addrmap_cleanup, objfile);
|
||||||
|
|
||||||
|
@ -13796,15 +13791,12 @@ update_enumeration_type_from_children (struct die_info *die,
|
||||||
struct type *type,
|
struct type *type,
|
||||||
struct dwarf2_cu *cu)
|
struct dwarf2_cu *cu)
|
||||||
{
|
{
|
||||||
struct obstack obstack;
|
|
||||||
struct die_info *child_die;
|
struct die_info *child_die;
|
||||||
int unsigned_enum = 1;
|
int unsigned_enum = 1;
|
||||||
int flag_enum = 1;
|
int flag_enum = 1;
|
||||||
ULONGEST mask = 0;
|
ULONGEST mask = 0;
|
||||||
struct cleanup *old_chain;
|
|
||||||
|
|
||||||
obstack_init (&obstack);
|
auto_obstack obstack;
|
||||||
old_chain = make_cleanup_obstack_free (&obstack);
|
|
||||||
|
|
||||||
for (child_die = die->child;
|
for (child_die = die->child;
|
||||||
child_die != NULL && child_die->tag;
|
child_die != NULL && child_die->tag;
|
||||||
|
@ -13849,8 +13841,6 @@ update_enumeration_type_from_children (struct die_info *die,
|
||||||
TYPE_UNSIGNED (type) = 1;
|
TYPE_UNSIGNED (type) = 1;
|
||||||
if (flag_enum)
|
if (flag_enum)
|
||||||
TYPE_FLAG_ENUM (type) = 1;
|
TYPE_FLAG_ENUM (type) = 1;
|
||||||
|
|
||||||
do_cleanups (old_chain);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Given a DW_AT_enumeration_type die, set its type. We do not
|
/* Given a DW_AT_enumeration_type die, set its type. We do not
|
||||||
|
|
|
@ -63,4 +63,19 @@ extern char *obconcat (struct obstack *obstackp, ...) ATTRIBUTE_SENTINEL;
|
||||||
|
|
||||||
extern char *obstack_strdup (struct obstack *obstackp, const char *string);
|
extern char *obstack_strdup (struct obstack *obstackp, const char *string);
|
||||||
|
|
||||||
|
/* An obstack that frees itself on scope exit. */
|
||||||
|
struct auto_obstack : obstack
|
||||||
|
{
|
||||||
|
auto_obstack ()
|
||||||
|
{ obstack_init (this); }
|
||||||
|
|
||||||
|
~auto_obstack ()
|
||||||
|
{ obstack_free (this, NULL); }
|
||||||
|
|
||||||
|
/* Free all memory in the obstack but leave it valid for further
|
||||||
|
allocation. */
|
||||||
|
void clear ()
|
||||||
|
{ obstack_free (this, obstack_base (this)); }
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1297,7 +1297,7 @@ static int popping;
|
||||||
|
|
||||||
/* Temporary storage for yylex; this holds symbol names as they are
|
/* Temporary storage for yylex; this holds symbol names as they are
|
||||||
built up. */
|
built up. */
|
||||||
static struct obstack name_obstack;
|
static auto_obstack name_obstack;
|
||||||
|
|
||||||
/* Build "package.name" in name_obstack.
|
/* Build "package.name" in name_obstack.
|
||||||
For convenience of the caller, the name is NUL-terminated,
|
For convenience of the caller, the name is NUL-terminated,
|
||||||
|
@ -1309,7 +1309,7 @@ build_packaged_name (const char *package, int package_len,
|
||||||
{
|
{
|
||||||
struct stoken result;
|
struct stoken result;
|
||||||
|
|
||||||
obstack_free (&name_obstack, obstack_base (&name_obstack));
|
name_obstack.clear ();
|
||||||
obstack_grow (&name_obstack, package, package_len);
|
obstack_grow (&name_obstack, package, package_len);
|
||||||
obstack_grow_str (&name_obstack, ".");
|
obstack_grow_str (&name_obstack, ".");
|
||||||
obstack_grow (&name_obstack, name, name_len);
|
obstack_grow (&name_obstack, name, name_len);
|
||||||
|
@ -1567,6 +1567,8 @@ go_parse (struct parser_state *par_state)
|
||||||
gdb_assert (par_state != NULL);
|
gdb_assert (par_state != NULL);
|
||||||
pstate = par_state;
|
pstate = par_state;
|
||||||
|
|
||||||
|
/* Note that parsing (within yyparse) freely installs cleanups
|
||||||
|
assuming they'll be run here (below). */
|
||||||
back_to = make_cleanup (null_cleanup, NULL);
|
back_to = make_cleanup (null_cleanup, NULL);
|
||||||
|
|
||||||
scoped_restore restore_yydebug = make_scoped_restore (&yydebug,
|
scoped_restore restore_yydebug = make_scoped_restore (&yydebug,
|
||||||
|
@ -1579,8 +1581,7 @@ go_parse (struct parser_state *par_state)
|
||||||
|
|
||||||
VEC_free (token_and_value, token_fifo);
|
VEC_free (token_and_value, token_fifo);
|
||||||
popping = 0;
|
popping = 0;
|
||||||
obstack_init (&name_obstack);
|
name_obstack.clear ();
|
||||||
make_cleanup_obstack_free (&name_obstack);
|
|
||||||
|
|
||||||
result = yyparse ();
|
result = yyparse ();
|
||||||
do_cleanups (back_to);
|
do_cleanups (back_to);
|
||||||
|
|
|
@ -1506,16 +1506,12 @@ linux_make_mappings_corefile_notes (struct gdbarch *gdbarch, bfd *obfd,
|
||||||
char *note_data, int *note_size)
|
char *note_data, int *note_size)
|
||||||
{
|
{
|
||||||
struct cleanup *cleanup;
|
struct cleanup *cleanup;
|
||||||
struct obstack data_obstack, filename_obstack;
|
|
||||||
struct linux_make_mappings_data mapping_data;
|
struct linux_make_mappings_data mapping_data;
|
||||||
struct type *long_type
|
struct type *long_type
|
||||||
= arch_integer_type (gdbarch, gdbarch_long_bit (gdbarch), 0, "long");
|
= arch_integer_type (gdbarch, gdbarch_long_bit (gdbarch), 0, "long");
|
||||||
gdb_byte buf[sizeof (ULONGEST)];
|
gdb_byte buf[sizeof (ULONGEST)];
|
||||||
|
|
||||||
obstack_init (&data_obstack);
|
auto_obstack data_obstack, filename_obstack;
|
||||||
cleanup = make_cleanup_obstack_free (&data_obstack);
|
|
||||||
obstack_init (&filename_obstack);
|
|
||||||
make_cleanup_obstack_free (&filename_obstack);
|
|
||||||
|
|
||||||
mapping_data.file_count = 0;
|
mapping_data.file_count = 0;
|
||||||
mapping_data.data_obstack = &data_obstack;
|
mapping_data.data_obstack = &data_obstack;
|
||||||
|
@ -1548,7 +1544,6 @@ linux_make_mappings_corefile_notes (struct gdbarch *gdbarch, bfd *obfd,
|
||||||
obstack_object_size (&data_obstack));
|
obstack_object_size (&data_obstack));
|
||||||
}
|
}
|
||||||
|
|
||||||
do_cleanups (cleanup);
|
|
||||||
return note_data;
|
return note_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2255,8 +2255,6 @@ printf_wide_c_string (struct ui_file *stream, const char *format,
|
||||||
"wchar_t", NULL, 0);
|
"wchar_t", NULL, 0);
|
||||||
int wcwidth = TYPE_LENGTH (wctype);
|
int wcwidth = TYPE_LENGTH (wctype);
|
||||||
gdb_byte *buf = (gdb_byte *) alloca (wcwidth);
|
gdb_byte *buf = (gdb_byte *) alloca (wcwidth);
|
||||||
struct obstack output;
|
|
||||||
struct cleanup *inner_cleanup;
|
|
||||||
|
|
||||||
tem = value_as_address (value);
|
tem = value_as_address (value);
|
||||||
|
|
||||||
|
@ -2275,8 +2273,7 @@ printf_wide_c_string (struct ui_file *stream, const char *format,
|
||||||
read_memory (tem, str, j);
|
read_memory (tem, str, j);
|
||||||
memset (&str[j], 0, wcwidth);
|
memset (&str[j], 0, wcwidth);
|
||||||
|
|
||||||
obstack_init (&output);
|
auto_obstack output;
|
||||||
inner_cleanup = make_cleanup_obstack_free (&output);
|
|
||||||
|
|
||||||
convert_between_encodings (target_wide_charset (gdbarch),
|
convert_between_encodings (target_wide_charset (gdbarch),
|
||||||
host_charset (),
|
host_charset (),
|
||||||
|
@ -2285,7 +2282,6 @@ printf_wide_c_string (struct ui_file *stream, const char *format,
|
||||||
obstack_grow_str0 (&output, "");
|
obstack_grow_str0 (&output, "");
|
||||||
|
|
||||||
fprintf_filtered (stream, format, obstack_base (&output));
|
fprintf_filtered (stream, format, obstack_base (&output));
|
||||||
do_cleanups (inner_cleanup);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Subroutine of ui_printf to simplify it.
|
/* Subroutine of ui_printf to simplify it.
|
||||||
|
@ -2531,8 +2527,6 @@ ui_printf (const char *arg, struct ui_file *stream)
|
||||||
struct type *wctype = lookup_typename (current_language, gdbarch,
|
struct type *wctype = lookup_typename (current_language, gdbarch,
|
||||||
"wchar_t", NULL, 0);
|
"wchar_t", NULL, 0);
|
||||||
struct type *valtype;
|
struct type *valtype;
|
||||||
struct obstack output;
|
|
||||||
struct cleanup *inner_cleanup;
|
|
||||||
const gdb_byte *bytes;
|
const gdb_byte *bytes;
|
||||||
|
|
||||||
valtype = value_type (val_args[i]);
|
valtype = value_type (val_args[i]);
|
||||||
|
@ -2542,8 +2536,7 @@ ui_printf (const char *arg, struct ui_file *stream)
|
||||||
|
|
||||||
bytes = value_contents (val_args[i]);
|
bytes = value_contents (val_args[i]);
|
||||||
|
|
||||||
obstack_init (&output);
|
auto_obstack output;
|
||||||
inner_cleanup = make_cleanup_obstack_free (&output);
|
|
||||||
|
|
||||||
convert_between_encodings (target_wide_charset (gdbarch),
|
convert_between_encodings (target_wide_charset (gdbarch),
|
||||||
host_charset (),
|
host_charset (),
|
||||||
|
@ -2554,7 +2547,6 @@ ui_printf (const char *arg, struct ui_file *stream)
|
||||||
|
|
||||||
fprintf_filtered (stream, current_substring,
|
fprintf_filtered (stream, current_substring,
|
||||||
obstack_base (&output));
|
obstack_base (&output));
|
||||||
do_cleanups (inner_cleanup);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case double_arg:
|
case double_arg:
|
||||||
|
|
|
@ -185,7 +185,7 @@ static int unit_testing;
|
||||||
|
|
||||||
/* Obstack for data temporarily allocated during parsing. */
|
/* Obstack for data temporarily allocated during parsing. */
|
||||||
|
|
||||||
static struct obstack work_obstack;
|
static auto_obstack work_obstack;
|
||||||
|
|
||||||
/* Result of parsing. Points into work_obstack. */
|
/* Result of parsing. Points into work_obstack. */
|
||||||
|
|
||||||
|
@ -2446,13 +2446,17 @@ int
|
||||||
rust_parse (struct parser_state *state)
|
rust_parse (struct parser_state *state)
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
struct cleanup *cleanup;
|
|
||||||
|
|
||||||
obstack_init (&work_obstack);
|
work_obstack.clear ();
|
||||||
cleanup = make_cleanup_obstack_free (&work_obstack);
|
|
||||||
rust_ast = NULL;
|
rust_ast = NULL;
|
||||||
|
|
||||||
pstate = state;
|
pstate = state;
|
||||||
|
|
||||||
|
/* Note that parsing (within rustyyparse) freely installs cleanups
|
||||||
|
assuming they're run here (below). */
|
||||||
|
struct cleanup *cleanup = make_cleanup (null_cleanup, NULL);
|
||||||
|
|
||||||
result = rustyyparse ();
|
result = rustyyparse ();
|
||||||
|
|
||||||
if (!result || (parse_completion && rust_ast != NULL))
|
if (!result || (parse_completion && rust_ast != NULL))
|
||||||
|
@ -2631,7 +2635,7 @@ rust_lex_tests (void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
obstack_init (&work_obstack);
|
work_obstack.clear ();
|
||||||
unit_testing = 1;
|
unit_testing = 1;
|
||||||
|
|
||||||
rust_lex_test_one ("", 0);
|
rust_lex_test_one ("", 0);
|
||||||
|
@ -2722,7 +2726,6 @@ rust_lex_tests (void)
|
||||||
rust_lex_test_completion ();
|
rust_lex_test_completion ();
|
||||||
rust_lex_test_push_back ();
|
rust_lex_test_push_back ();
|
||||||
|
|
||||||
obstack_free (&work_obstack, NULL);
|
|
||||||
unit_testing = 0;
|
unit_testing = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
24
gdb/utils.c
24
gdb/utils.c
|
@ -166,24 +166,6 @@ make_cleanup_fclose (FILE *file)
|
||||||
return make_cleanup (do_fclose_cleanup, file);
|
return make_cleanup (do_fclose_cleanup, file);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Helper function which does the work for make_cleanup_obstack_free. */
|
|
||||||
|
|
||||||
static void
|
|
||||||
do_obstack_free (void *arg)
|
|
||||||
{
|
|
||||||
struct obstack *ob = (struct obstack *) arg;
|
|
||||||
|
|
||||||
obstack_free (ob, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Return a new cleanup that frees OBSTACK. */
|
|
||||||
|
|
||||||
struct cleanup *
|
|
||||||
make_cleanup_obstack_free (struct obstack *obstack)
|
|
||||||
{
|
|
||||||
return make_cleanup (do_obstack_free, obstack);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Helper function for make_cleanup_ui_out_redirect_pop. */
|
/* Helper function for make_cleanup_ui_out_redirect_pop. */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1277,13 +1259,10 @@ query (const char *ctlstr, ...)
|
||||||
static int
|
static int
|
||||||
host_char_to_target (struct gdbarch *gdbarch, int c, int *target_c)
|
host_char_to_target (struct gdbarch *gdbarch, int c, int *target_c)
|
||||||
{
|
{
|
||||||
struct obstack host_data;
|
|
||||||
char the_char = c;
|
char the_char = c;
|
||||||
struct cleanup *cleanups;
|
|
||||||
int result = 0;
|
int result = 0;
|
||||||
|
|
||||||
obstack_init (&host_data);
|
auto_obstack host_data;
|
||||||
cleanups = make_cleanup_obstack_free (&host_data);
|
|
||||||
|
|
||||||
convert_between_encodings (target_charset (gdbarch), host_charset (),
|
convert_between_encodings (target_charset (gdbarch), host_charset (),
|
||||||
(gdb_byte *) &the_char, 1, 1,
|
(gdb_byte *) &the_char, 1, 1,
|
||||||
|
@ -1295,7 +1274,6 @@ host_char_to_target (struct gdbarch *gdbarch, int c, int *target_c)
|
||||||
*target_c = *(char *) obstack_base (&host_data);
|
*target_c = *(char *) obstack_base (&host_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
do_cleanups (cleanups);
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -78,9 +78,6 @@ extern struct cleanup *(make_cleanup_free_section_addr_info
|
||||||
|
|
||||||
extern struct cleanup *make_cleanup_fclose (FILE *file);
|
extern struct cleanup *make_cleanup_fclose (FILE *file);
|
||||||
|
|
||||||
struct obstack;
|
|
||||||
extern struct cleanup *make_cleanup_obstack_free (struct obstack *obstack);
|
|
||||||
|
|
||||||
extern struct cleanup *make_cleanup_restore_integer (int *variable);
|
extern struct cleanup *make_cleanup_restore_integer (int *variable);
|
||||||
extern struct cleanup *make_cleanup_restore_uinteger (unsigned int *variable);
|
extern struct cleanup *make_cleanup_restore_uinteger (unsigned int *variable);
|
||||||
|
|
||||||
|
|
|
@ -2484,8 +2484,6 @@ generic_emit_char (int c, struct type *type, struct ui_file *stream,
|
||||||
{
|
{
|
||||||
enum bfd_endian byte_order
|
enum bfd_endian byte_order
|
||||||
= gdbarch_byte_order (get_type_arch (type));
|
= gdbarch_byte_order (get_type_arch (type));
|
||||||
struct obstack wchar_buf, output;
|
|
||||||
struct cleanup *cleanups;
|
|
||||||
gdb_byte *buf;
|
gdb_byte *buf;
|
||||||
int need_escape = 0;
|
int need_escape = 0;
|
||||||
|
|
||||||
|
@ -2495,8 +2493,7 @@ generic_emit_char (int c, struct type *type, struct ui_file *stream,
|
||||||
wchar_iterator iter (buf, TYPE_LENGTH (type), encoding, TYPE_LENGTH (type));
|
wchar_iterator iter (buf, TYPE_LENGTH (type), encoding, TYPE_LENGTH (type));
|
||||||
|
|
||||||
/* This holds the printable form of the wchar_t data. */
|
/* This holds the printable form of the wchar_t data. */
|
||||||
obstack_init (&wchar_buf);
|
auto_obstack wchar_buf;
|
||||||
cleanups = make_cleanup_obstack_free (&wchar_buf);
|
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
@ -2543,8 +2540,7 @@ generic_emit_char (int c, struct type *type, struct ui_file *stream,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The output in the host encoding. */
|
/* The output in the host encoding. */
|
||||||
obstack_init (&output);
|
auto_obstack output;
|
||||||
make_cleanup_obstack_free (&output);
|
|
||||||
|
|
||||||
convert_between_encodings (INTERMEDIATE_ENCODING, host_charset (),
|
convert_between_encodings (INTERMEDIATE_ENCODING, host_charset (),
|
||||||
(gdb_byte *) obstack_base (&wchar_buf),
|
(gdb_byte *) obstack_base (&wchar_buf),
|
||||||
|
@ -2553,8 +2549,6 @@ generic_emit_char (int c, struct type *type, struct ui_file *stream,
|
||||||
obstack_1grow (&output, '\0');
|
obstack_1grow (&output, '\0');
|
||||||
|
|
||||||
fputs_filtered ((const char *) obstack_base (&output), stream);
|
fputs_filtered ((const char *) obstack_base (&output), stream);
|
||||||
|
|
||||||
do_cleanups (cleanups);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return the repeat count of the next character/byte in ITER,
|
/* Return the repeat count of the next character/byte in ITER,
|
||||||
|
@ -2813,7 +2807,6 @@ generic_printstr (struct ui_file *stream, struct type *type,
|
||||||
enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type));
|
enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type));
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
int width = TYPE_LENGTH (type);
|
int width = TYPE_LENGTH (type);
|
||||||
struct obstack wchar_buf, output;
|
|
||||||
struct cleanup *cleanup;
|
struct cleanup *cleanup;
|
||||||
int finished = 0;
|
int finished = 0;
|
||||||
struct converted_character *last;
|
struct converted_character *last;
|
||||||
|
@ -2885,8 +2878,7 @@ generic_printstr (struct ui_file *stream, struct type *type,
|
||||||
|
|
||||||
/* WCHAR_BUF is the obstack we use to represent the string in
|
/* WCHAR_BUF is the obstack we use to represent the string in
|
||||||
wchar_t form. */
|
wchar_t form. */
|
||||||
obstack_init (&wchar_buf);
|
auto_obstack wchar_buf;
|
||||||
make_cleanup_obstack_free (&wchar_buf);
|
|
||||||
|
|
||||||
/* Print the output string to the obstack. */
|
/* Print the output string to the obstack. */
|
||||||
print_converted_chars_to_obstack (&wchar_buf, converted_chars, quote_char,
|
print_converted_chars_to_obstack (&wchar_buf, converted_chars, quote_char,
|
||||||
|
@ -2896,8 +2888,7 @@ generic_printstr (struct ui_file *stream, struct type *type,
|
||||||
obstack_grow_wstr (&wchar_buf, LCST ("..."));
|
obstack_grow_wstr (&wchar_buf, LCST ("..."));
|
||||||
|
|
||||||
/* OUTPUT is where we collect `char's for printing. */
|
/* OUTPUT is where we collect `char's for printing. */
|
||||||
obstack_init (&output);
|
auto_obstack output;
|
||||||
make_cleanup_obstack_free (&output);
|
|
||||||
|
|
||||||
convert_between_encodings (INTERMEDIATE_ENCODING, host_charset (),
|
convert_between_encodings (INTERMEDIATE_ENCODING, host_charset (),
|
||||||
(gdb_byte *) obstack_base (&wchar_buf),
|
(gdb_byte *) obstack_base (&wchar_buf),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue