From: Pedro Alves <palves@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 02/40] Eliminate make_cleanup_obstack_free, introduce auto_obstack
Date: Fri, 02 Jun 2017 12:22:00 -0000 [thread overview]
Message-ID: <1496406158-12663-3-git-send-email-palves@redhat.com> (raw)
In-Reply-To: <1496406158-12663-1-git-send-email-palves@redhat.com>
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 them.
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:
yyyy-mm-dd 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, write_psymtabs_to_index):
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.
---
gdb/c-exp.y | 10 ++++++----
gdb/c-lang.c | 7 +------
gdb/d-exp.y | 11 ++++++-----
gdb/dwarf2loc.c | 7 +------
gdb/dwarf2read.c | 37 +++++++------------------------------
gdb/gdb_obstack.h | 15 +++++++++++++++
gdb/go-exp.y | 9 +++++----
gdb/linux-tdep.c | 7 +------
gdb/printcmd.c | 12 ++----------
gdb/rust-exp.y | 15 +++++++++------
gdb/utils.c | 24 +-----------------------
gdb/utils.h | 3 ---
gdb/valprint.c | 17 ++++-------------
13 files changed, 58 insertions(+), 116 deletions(-)
diff --git a/gdb/c-exp.y b/gdb/c-exp.y
index 283b737..bdcd51f 100644
--- a/gdb/c-exp.y
+++ b/gdb/c-exp.y
@@ -2806,7 +2806,7 @@ static int popping;
/* Temporary storage for c_lex; this holds symbol names as they are
built up. */
-static struct obstack name_obstack;
+auto_obstack name_obstack;
/* Classify a NAME token. The contents of the token are in `yylval'.
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);
++next_to_examine;
- obstack_free (&name_obstack, obstack_base (&name_obstack));
+ name_obstack.clear ();
checkpoint = 0;
if (current.token == FILENAME)
search_block = current.value.bval;
@@ -3169,6 +3169,9 @@ c_parse (struct parser_state *par_state)
gdb_assert (par_state != NULL);
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);
make_cleanup_clear_parser_state (&pstate);
@@ -3197,8 +3200,7 @@ c_parse (struct parser_state *par_state)
VEC_free (token_and_value, token_fifo);
popping = 0;
- obstack_init (&name_obstack);
- make_cleanup_obstack_free (&name_obstack);
+ name_obstack.clear ();
result = yyparse ();
do_cleanups (back_to);
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index a6d533d..de8868b 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -570,15 +570,12 @@ evaluate_subexp_c (struct type *expect_type, struct expression *exp,
{
int oplen, limit;
struct type *type;
- struct obstack output;
- struct cleanup *cleanup;
struct value *result;
c_string_type dest_type;
const char *dest_charset;
int satisfy_expected = 0;
- obstack_init (&output);
- cleanup = make_cleanup_obstack_free (&output);
+ auto_obstack output;
++*pos;
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);
else
result = value_cstring ("", 0, type);
- do_cleanups (cleanup);
return result;
}
@@ -702,7 +698,6 @@ evaluate_subexp_c (struct type *expect_type, struct expression *exp,
obstack_object_size (&output),
type);
}
- do_cleanups (cleanup);
return result;
}
break;
diff --git a/gdb/d-exp.y b/gdb/d-exp.y
index 62df737..d392a5c 100644
--- a/gdb/d-exp.y
+++ b/gdb/d-exp.y
@@ -1342,7 +1342,7 @@ static int popping;
/* Temporary storage for yylex; this holds symbol names as they are
built up. */
-static struct obstack name_obstack;
+static auto_obstack name_obstack;
/* Classify an IDENTIFIER token. The contents of the token are in `yylval'.
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. */
if (current.token == UNKNOWN_NAME)
{
- obstack_free (&name_obstack, obstack_base (&name_obstack));
+ name_obstack.clear ();
obstack_grow (&name_obstack, current.value.sval.ptr,
current.value.sval.length);
@@ -1533,7 +1533,7 @@ yylex (void)
if (current.token != TYPENAME && current.token != '.')
goto do_pop;
- obstack_free (&name_obstack, obstack_base (&name_obstack));
+ name_obstack.clear ();
checkpoint = 0;
if (current.token == '.')
search_block = NULL;
@@ -1627,6 +1627,8 @@ d_parse (struct parser_state *par_state)
gdb_assert (par_state != NULL);
pstate = par_state;
+ /* Note that parsing (within yyparse) freely installs cleanups
+ assuming they're run here (below). */
back_to = make_cleanup (null_cleanup, NULL);
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);
popping = 0;
- obstack_init (&name_obstack);
- make_cleanup_obstack_free (&name_obstack);
+ name_obstack.clear ();
result = yyparse ();
do_cleanups (back_to);
diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c
index 127167d..3f652a2 100644
--- a/gdb/dwarf2loc.c
+++ b/gdb/dwarf2loc.c
@@ -2125,13 +2125,10 @@ fetch_const_value_from_synthetic_pointer (sect_offset die, LONGEST byte_offset,
struct type *type)
{
struct value *result = NULL;
- struct obstack temp_obstack;
- struct cleanup *cleanup;
const gdb_byte *bytes;
LONGEST len;
- obstack_init (&temp_obstack);
- cleanup = make_cleanup_obstack_free (&temp_obstack);
+ auto_obstack temp_obstack;
bytes = dwarf2_fetch_constant_bytes (die, per_cu, &temp_obstack, &len);
if (bytes != NULL)
@@ -2148,8 +2145,6 @@ fetch_const_value_from_synthetic_pointer (sect_offset die, LONGEST byte_offset,
else
result = allocate_optimized_out_value (TYPE_TARGET_TYPE (type));
- do_cleanups (cleanup);
-
return result;
}
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index b58d0fc..cb33fc9 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -3057,13 +3057,11 @@ create_addrmap_from_index (struct objfile *objfile, struct mapped_index *index)
{
struct gdbarch *gdbarch = get_objfile_arch (objfile);
const gdb_byte *iter, *end;
- struct obstack temp_obstack;
struct addrmap *mutable_map;
- struct cleanup *cleanup;
CORE_ADDR baseaddr;
- obstack_init (&temp_obstack);
- cleanup = make_cleanup_obstack_free (&temp_obstack);
+ auto_obstack temp_obstack;
+
mutable_map = addrmap_create_mutable (&temp_obstack);
iter = index->address_table;
@@ -3104,7 +3102,6 @@ create_addrmap_from_index (struct objfile *objfile, struct mapped_index *index)
objfile->psymtabs_addrmap = addrmap_create_fixed (mutable_map,
&objfile->objfile_obstack);
- do_cleanups (cleanup);
}
/* The hash function for strings in the mapped index. This is the same as
@@ -6623,7 +6620,6 @@ static void
dwarf2_build_psymtabs_hard (struct objfile *objfile)
{
struct cleanup *back_to, *addrmap_cleanup;
- struct obstack temp_obstack;
int i;
if (dwarf_read_debug)
@@ -6646,8 +6642,7 @@ dwarf2_build_psymtabs_hard (struct objfile *objfile)
/* Create a temporary address map on a temporary obstack. We later
copy this to the final obstack. */
- obstack_init (&temp_obstack);
- make_cleanup_obstack_free (&temp_obstack);
+ auto_obstack temp_obstack;
objfile->psymtabs_addrmap = addrmap_create_mutable (&temp_obstack);
addrmap_cleanup = make_cleanup (psymtabs_addrmap_cleanup, objfile);
@@ -13793,15 +13788,12 @@ update_enumeration_type_from_children (struct die_info *die,
struct type *type,
struct dwarf2_cu *cu)
{
- struct obstack obstack;
struct die_info *child_die;
int unsigned_enum = 1;
int flag_enum = 1;
ULONGEST mask = 0;
- struct cleanup *old_chain;
- obstack_init (&obstack);
- old_chain = make_cleanup_obstack_free (&obstack);
+ auto_obstack obstack;
for (child_die = die->child;
child_die != NULL && child_die->tag;
@@ -13846,8 +13838,6 @@ update_enumeration_type_from_children (struct die_info *die,
TYPE_UNSIGNED (type) = 1;
if (flag_enum)
TYPE_FLAG_ENUM (type) = 1;
-
- do_cleanups (old_chain);
}
/* Given a DW_AT_enumeration_type die, set its type. We do not
@@ -23870,8 +23860,6 @@ write_psymtabs_to_index (struct objfile *objfile, const char *dir)
{
struct cleanup *cleanup;
char *filename;
- struct obstack contents, addr_obstack, constant_pool, symtab_obstack;
- struct obstack cu_list, types_cu_list;
int i;
FILE *out_file;
struct mapped_symtab *symtab;
@@ -23904,14 +23892,7 @@ write_psymtabs_to_index (struct objfile *objfile, const char *dir)
symtab = create_mapped_symtab ();
make_cleanup (cleanup_mapped_symtab, symtab);
- obstack_init (&addr_obstack);
- make_cleanup_obstack_free (&addr_obstack);
-
- obstack_init (&cu_list);
- make_cleanup_obstack_free (&cu_list);
-
- obstack_init (&types_cu_list);
- make_cleanup_obstack_free (&types_cu_list);
+ auto_obstack addr_obstack, cu_list, types_cu_list;
htab_up psyms_seen (htab_create_alloc (100, htab_hash_pointer,
htab_eq_pointer,
@@ -23987,14 +23968,10 @@ write_psymtabs_to_index (struct objfile *objfile, const char *dir)
lists. */
uniquify_cu_indices (symtab);
- obstack_init (&constant_pool);
- make_cleanup_obstack_free (&constant_pool);
- obstack_init (&symtab_obstack);
- make_cleanup_obstack_free (&symtab_obstack);
+ auto_obstack constant_pool, symtab_obstack;
write_hash_table (symtab, &symtab_obstack, &constant_pool);
- obstack_init (&contents);
- make_cleanup_obstack_free (&contents);
+ auto_obstack contents;
size_of_contents = 6 * sizeof (offset_type);
total_len = size_of_contents;
diff --git a/gdb/gdb_obstack.h b/gdb/gdb_obstack.h
index 3f34d96..b241c82 100644
--- a/gdb/gdb_obstack.h
+++ b/gdb/gdb_obstack.h
@@ -63,4 +63,19 @@ extern char *obconcat (struct obstack *obstackp, ...) ATTRIBUTE_SENTINEL;
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
diff --git a/gdb/go-exp.y b/gdb/go-exp.y
index 057e227..f2f3596 100644
--- a/gdb/go-exp.y
+++ b/gdb/go-exp.y
@@ -1297,7 +1297,7 @@ static int popping;
/* Temporary storage for yylex; this holds symbol names as they are
built up. */
-static struct obstack name_obstack;
+static auto_obstack name_obstack;
/* Build "package.name" in name_obstack.
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;
- obstack_free (&name_obstack, obstack_base (&name_obstack));
+ name_obstack.clear ();
obstack_grow (&name_obstack, package, package_len);
obstack_grow_str (&name_obstack, ".");
obstack_grow (&name_obstack, name, name_len);
@@ -1567,6 +1567,8 @@ go_parse (struct parser_state *par_state)
gdb_assert (par_state != NULL);
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);
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);
popping = 0;
- obstack_init (&name_obstack);
- make_cleanup_obstack_free (&name_obstack);
+ name_obstack.clear ();
result = yyparse ();
do_cleanups (back_to);
diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
index 016aadf..db6db35 100644
--- a/gdb/linux-tdep.c
+++ b/gdb/linux-tdep.c
@@ -1503,16 +1503,12 @@ linux_make_mappings_corefile_notes (struct gdbarch *gdbarch, bfd *obfd,
char *note_data, int *note_size)
{
struct cleanup *cleanup;
- struct obstack data_obstack, filename_obstack;
struct linux_make_mappings_data mapping_data;
struct type *long_type
= arch_integer_type (gdbarch, gdbarch_long_bit (gdbarch), 0, "long");
gdb_byte buf[sizeof (ULONGEST)];
- obstack_init (&data_obstack);
- cleanup = make_cleanup_obstack_free (&data_obstack);
- obstack_init (&filename_obstack);
- make_cleanup_obstack_free (&filename_obstack);
+ auto_obstack data_obstack, filename_obstack;
mapping_data.file_count = 0;
mapping_data.data_obstack = &data_obstack;
@@ -1545,7 +1541,6 @@ linux_make_mappings_corefile_notes (struct gdbarch *gdbarch, bfd *obfd,
obstack_object_size (&data_obstack));
}
- do_cleanups (cleanup);
return note_data;
}
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index 02d6e1c..fd6e03c 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -2305,8 +2305,6 @@ printf_wide_c_string (struct ui_file *stream, const char *format,
"wchar_t", NULL, 0);
int wcwidth = TYPE_LENGTH (wctype);
gdb_byte *buf = (gdb_byte *) alloca (wcwidth);
- struct obstack output;
- struct cleanup *inner_cleanup;
tem = value_as_address (value);
@@ -2325,8 +2323,7 @@ printf_wide_c_string (struct ui_file *stream, const char *format,
read_memory (tem, str, j);
memset (&str[j], 0, wcwidth);
- obstack_init (&output);
- inner_cleanup = make_cleanup_obstack_free (&output);
+ auto_obstack output;
convert_between_encodings (target_wide_charset (gdbarch),
host_charset (),
@@ -2335,7 +2332,6 @@ printf_wide_c_string (struct ui_file *stream, const char *format,
obstack_grow_str0 (&output, "");
fprintf_filtered (stream, format, obstack_base (&output));
- do_cleanups (inner_cleanup);
}
/* Subroutine of ui_printf to simplify it.
@@ -2581,8 +2577,6 @@ ui_printf (const char *arg, struct ui_file *stream)
struct type *wctype = lookup_typename (current_language, gdbarch,
"wchar_t", NULL, 0);
struct type *valtype;
- struct obstack output;
- struct cleanup *inner_cleanup;
const gdb_byte *bytes;
valtype = value_type (val_args[i]);
@@ -2592,8 +2586,7 @@ ui_printf (const char *arg, struct ui_file *stream)
bytes = value_contents (val_args[i]);
- obstack_init (&output);
- inner_cleanup = make_cleanup_obstack_free (&output);
+ auto_obstack output;
convert_between_encodings (target_wide_charset (gdbarch),
host_charset (),
@@ -2604,7 +2597,6 @@ ui_printf (const char *arg, struct ui_file *stream)
fprintf_filtered (stream, current_substring,
obstack_base (&output));
- do_cleanups (inner_cleanup);
}
break;
case double_arg:
diff --git a/gdb/rust-exp.y b/gdb/rust-exp.y
index 64b7c55..c7361bc 100644
--- a/gdb/rust-exp.y
+++ b/gdb/rust-exp.y
@@ -185,7 +185,7 @@ static int unit_testing;
/* Obstack for data temporarily allocated during parsing. */
-static struct obstack work_obstack;
+static auto_obstack work_obstack;
/* Result of parsing. Points into work_obstack. */
@@ -2446,13 +2446,17 @@ int
rust_parse (struct parser_state *state)
{
int result;
- struct cleanup *cleanup;
- obstack_init (&work_obstack);
- cleanup = make_cleanup_obstack_free (&work_obstack);
+ work_obstack.clear ();
+
rust_ast = NULL;
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 ();
if (!result || (parse_completion && rust_ast != NULL))
@@ -2631,7 +2635,7 @@ rust_lex_tests (void)
{
int i;
- obstack_init (&work_obstack);
+ work_obstack.clear ();
unit_testing = 1;
rust_lex_test_one ("", 0);
@@ -2722,7 +2726,6 @@ rust_lex_tests (void)
rust_lex_test_completion ();
rust_lex_test_push_back ();
- obstack_free (&work_obstack, NULL);
unit_testing = 0;
}
diff --git a/gdb/utils.c b/gdb/utils.c
index b4332f8..00b1bbb 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -169,24 +169,6 @@ make_cleanup_fclose (FILE *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. */
static void
@@ -1332,13 +1314,10 @@ query (const char *ctlstr, ...)
static int
host_char_to_target (struct gdbarch *gdbarch, int c, int *target_c)
{
- struct obstack host_data;
char the_char = c;
- struct cleanup *cleanups;
int result = 0;
- obstack_init (&host_data);
- cleanups = make_cleanup_obstack_free (&host_data);
+ auto_obstack host_data;
convert_between_encodings (target_charset (gdbarch), host_charset (),
(gdb_byte *) &the_char, 1, 1,
@@ -1350,7 +1329,6 @@ host_char_to_target (struct gdbarch *gdbarch, int c, int *target_c)
*target_c = *(char *) obstack_base (&host_data);
}
- do_cleanups (cleanups);
return result;
}
diff --git a/gdb/utils.h b/gdb/utils.h
index f3e8007..3347c23 100644
--- a/gdb/utils.h
+++ b/gdb/utils.h
@@ -78,9 +78,6 @@ extern struct cleanup *(make_cleanup_free_section_addr_info
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_uinteger (unsigned int *variable);
diff --git a/gdb/valprint.c b/gdb/valprint.c
index 6937dab..44810b9 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -2432,8 +2432,6 @@ generic_emit_char (int c, struct type *type, struct ui_file *stream,
{
enum bfd_endian byte_order
= gdbarch_byte_order (get_type_arch (type));
- struct obstack wchar_buf, output;
- struct cleanup *cleanups;
gdb_byte *buf;
int need_escape = 0;
@@ -2443,8 +2441,7 @@ generic_emit_char (int c, struct type *type, struct ui_file *stream,
wchar_iterator iter (buf, TYPE_LENGTH (type), encoding, TYPE_LENGTH (type));
/* This holds the printable form of the wchar_t data. */
- obstack_init (&wchar_buf);
- cleanups = make_cleanup_obstack_free (&wchar_buf);
+ auto_obstack wchar_buf;
while (1)
{
@@ -2491,8 +2488,7 @@ generic_emit_char (int c, struct type *type, struct ui_file *stream,
}
/* The output in the host encoding. */
- obstack_init (&output);
- make_cleanup_obstack_free (&output);
+ auto_obstack output;
convert_between_encodings (INTERMEDIATE_ENCODING, host_charset (),
(gdb_byte *) obstack_base (&wchar_buf),
@@ -2501,8 +2497,6 @@ generic_emit_char (int c, struct type *type, struct ui_file *stream,
obstack_1grow (&output, '\0');
fputs_filtered ((const char *) obstack_base (&output), stream);
-
- do_cleanups (cleanups);
}
/* Return the repeat count of the next character/byte in ITER,
@@ -2761,7 +2755,6 @@ generic_printstr (struct ui_file *stream, struct type *type,
enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type));
unsigned int i;
int width = TYPE_LENGTH (type);
- struct obstack wchar_buf, output;
struct cleanup *cleanup;
int finished = 0;
struct converted_character *last;
@@ -2833,8 +2826,7 @@ generic_printstr (struct ui_file *stream, struct type *type,
/* WCHAR_BUF is the obstack we use to represent the string in
wchar_t form. */
- obstack_init (&wchar_buf);
- make_cleanup_obstack_free (&wchar_buf);
+ auto_obstack wchar_buf;
/* Print the output string to the obstack. */
print_converted_chars_to_obstack (&wchar_buf, converted_chars, quote_char,
@@ -2844,8 +2836,7 @@ generic_printstr (struct ui_file *stream, struct type *type,
obstack_grow_wstr (&wchar_buf, LCST ("..."));
/* OUTPUT is where we collect `char's for printing. */
- obstack_init (&output);
- make_cleanup_obstack_free (&output);
+ auto_obstack output;
convert_between_encodings (INTERMEDIATE_ENCODING, host_charset (),
(gdb_byte *) obstack_base (&wchar_buf),
--
2.5.5
next prev parent reply other threads:[~2017-06-02 12:22 UTC|newest]
Thread overview: 182+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-02 12:22 [PATCH 00/40] C++ debugging improvements: breakpoints, TAB completion, more Pedro Alves
2017-06-02 12:22 ` Pedro Alves [this message]
2017-06-26 13:47 ` [PATCH 02/40] Eliminate make_cleanup_obstack_free, introduce auto_obstack Yao Qi
2017-06-27 10:25 ` Pedro Alves
2017-06-28 10:36 ` Yao Qi
2017-06-28 14:39 ` Pedro Alves
2017-06-28 21:33 ` Yao Qi
2017-06-02 12:22 ` [PATCH 01/40] Make gdb.base/dmsym.exp independent of "set language ada" Pedro Alves
2017-07-18 19:42 ` Simon Marchi
2017-07-20 17:00 ` Pedro Alves
2017-06-02 12:22 ` [PATCH 03/40] Fix gdb.base/completion.exp with --target_board=dwarf4-gdb-index Pedro Alves
2017-07-13 20:28 ` Keith Seitz
2017-07-14 16:02 ` Pedro Alves
2017-06-02 12:22 ` [PATCH 14/40] Introduce CP_OPERATOR_STR/CP_OPERATOR_LEN and use throughout Pedro Alves
2017-07-14 18:04 ` Keith Seitz
2017-07-17 14:55 ` Pedro Alves
2017-06-02 12:22 ` [PATCH 06/40] Expression completer should not match explicit location options Pedro Alves
2017-06-29 8:29 ` Yao Qi
2017-06-29 10:56 ` Pedro Alves
2017-06-29 11:08 ` Pedro Alves
2017-06-29 15:23 ` Pedro Alves
2017-06-29 11:24 ` Yao Qi
2017-06-29 15:25 ` Pedro Alves
2017-06-02 12:22 ` [PATCH 08/40] completion_list_add_name wrapper functions Pedro Alves
2017-06-27 12:56 ` Yao Qi
2017-06-27 15:35 ` Pedro Alves
2017-06-02 12:23 ` [PATCH 11/40] Introduce class completion_tracker & rewrite completion<->readline interaction Pedro Alves
2017-07-14 17:23 ` Keith Seitz
2017-07-17 13:56 ` Pedro Alves
2017-07-18 8:23 ` Christophe Lyon
[not found] ` <845f435e-d3d5-b327-4e3a-ce9434bd6ffd@redhat.com>
2017-07-18 10:42 ` [pushed] Fix GDB builds that include the simulator (Re: [PATCH 11/40] Introduce class completion_tracker & rewrite completion<->readline interaction) Pedro Alves
2018-03-05 21:43 ` [PATCH 11/40] Introduce class completion_tracker & rewrite completion<->readline interaction Simon Marchi
2017-06-02 12:23 ` [PATCH 38/40] Use TOLOWER in SYMBOL_HASH_NEXT Pedro Alves
2017-08-09 19:25 ` Keith Seitz
2017-11-25 0:35 ` [pushed] " Pedro Alves
2017-06-02 12:23 ` [PATCH 13/40] Introduce strncmp_iw Pedro Alves
2017-06-29 8:42 ` Yao Qi
2017-07-17 19:16 ` Pedro Alves
2017-06-02 12:23 ` [PATCH 09/40] Rename make_symbol_completion_list_fn -> symbol_completer Pedro Alves
2017-06-28 21:40 ` Yao Qi
2017-07-13 20:46 ` Keith Seitz
2017-07-17 11:00 ` Pedro Alves
2017-06-02 12:23 ` [PATCH 28/40] lookup_name_info::make_ignore_params Pedro Alves
2017-08-08 20:55 ` Keith Seitz
2017-11-08 16:18 ` Pedro Alves
2017-06-02 12:23 ` [PATCH 19/40] Fix cp_find_first_component_aux bug Pedro Alves
2017-07-17 19:17 ` Keith Seitz
2017-07-17 19:50 ` Pedro Alves
2017-07-17 21:38 ` Keith Seitz
2017-07-20 17:03 ` Pedro Alves
2017-06-02 12:23 ` [PATCH 40/40] Document breakpoints / linespec & co improvements (manual + NEWS) Pedro Alves
2017-06-02 13:01 ` Eli Zaretskii
2017-06-02 13:33 ` Pedro Alves
2017-06-21 15:50 ` Pedro Alves
2017-06-21 19:14 ` Pedro Alves
2017-06-22 19:45 ` Eli Zaretskii
2017-06-22 19:42 ` Eli Zaretskii
2017-06-21 13:32 ` Pedro Alves
2017-06-21 18:26 ` Eli Zaretskii
2017-06-21 19:01 ` Pedro Alves
2017-06-22 19:43 ` Eli Zaretskii
2017-06-02 12:23 ` [PATCH 18/40] A smarter linespec completer Pedro Alves
2017-07-15 0:07 ` Keith Seitz
2017-07-17 18:21 ` Pedro Alves
2017-07-17 19:02 ` Keith Seitz
2017-07-17 19:33 ` Pedro Alves
2017-06-02 12:23 ` [PATCH 27/40] Make cp_remove_params return a unique_ptr Pedro Alves
2017-08-08 20:35 ` Keith Seitz
2017-10-09 15:13 ` Pedro Alves
2017-06-02 12:23 ` [PATCH 10/40] Clean up "completer_handle_brkchars" callback handling Pedro Alves
2017-07-13 21:08 ` Keith Seitz
2017-07-17 11:14 ` Pedro Alves
2017-06-02 12:23 ` [PATCH 37/40] Fix completing an empty string Pedro Alves
2017-08-09 18:01 ` Keith Seitz
2017-11-25 0:28 ` Pedro Alves
2017-06-02 12:23 ` [PATCH 34/40] Make strcmp_iw NOT ignore whitespace in the middle of tokens Pedro Alves
2017-08-09 15:48 ` Keith Seitz
2017-11-24 23:38 ` [pushed] " Pedro Alves
2017-06-02 12:23 ` [PATCH 15/40] Rewrite/enhance explicit locations completer, parse left->right Pedro Alves
2017-07-14 20:55 ` Keith Seitz
2017-07-17 19:24 ` Pedro Alves
2017-06-02 12:23 ` [PATCH 39/40] Breakpoints in symbols with ABI tags (PR c++/19436) Pedro Alves
2017-08-09 19:34 ` Keith Seitz
2017-11-27 17:14 ` Pedro Alves
2017-06-02 12:23 ` [PATCH 36/40] Add comprehensive C++ operator linespec/location/completion tests Pedro Alves
2017-08-09 17:59 ` Keith Seitz
2017-11-25 0:18 ` [pushed] " Pedro Alves
2017-11-30 15:43 ` Yao Qi
2017-11-30 16:06 ` Pedro Alves
2017-11-30 16:35 ` [pushed] Fix gdb.linespec/cpls-ops.exp on 32-bit (Re: [pushed] Re: [PATCH 36/40] Add comprehensive C++ operator linespec/location/completion tests) Pedro Alves
2017-06-02 12:23 ` [PATCH 35/40] Comprehensive C++ linespec/completer tests Pedro Alves
2017-08-09 17:30 ` Keith Seitz
2017-11-24 16:25 ` Pedro Alves
2017-06-02 12:28 ` [PATCH 24/40] Per-language symbol name hashing algorithm Pedro Alves
2017-07-18 17:33 ` Keith Seitz
2017-07-20 18:53 ` Pedro Alves
2017-11-08 16:08 ` Pedro Alves
2017-06-02 12:29 ` [PATCH 16/40] Explicit locations -label completer Pedro Alves
2017-07-14 21:32 ` Keith Seitz
2017-06-02 12:29 ` [PATCH 07/40] objfile_per_bfd_storage non-POD Pedro Alves
2017-06-27 12:00 ` Yao Qi
2017-06-27 15:30 ` Pedro Alves
2017-06-02 12:29 ` [PATCH 17/40] Linespec lexing and C++ operators Pedro Alves
2017-07-14 21:45 ` Keith Seitz
2017-07-17 19:34 ` Pedro Alves
2017-06-02 12:29 ` [PATCH 33/40] Make the linespec/location completer ignore data symbols Pedro Alves
2017-08-09 15:42 ` Keith Seitz
2017-11-08 16:22 ` Pedro Alves
2017-06-02 12:29 ` [PATCH 12/40] "complete" command and completion word break characters Pedro Alves
2017-07-14 17:50 ` Keith Seitz
2017-07-17 14:36 ` Pedro Alves
2017-06-02 12:29 ` [PATCH 21/40] Use SYMBOL_MATCHES_SEARCH_NAME some more Pedro Alves
2017-07-17 21:39 ` Keith Seitz
2017-07-20 17:08 ` Pedro Alves
2017-06-02 12:29 ` [PATCH 05/40] command.h: Include scoped_restore_command.h Pedro Alves
2017-06-27 11:30 ` Yao Qi
2017-06-27 11:45 ` Pedro Alves
2017-06-27 11:52 ` Pedro Alves
2017-06-27 12:03 ` Pedro Alves
2017-06-27 15:46 ` [PATCH 05/40] command.h: Include common/scoped_restore.h Pedro Alves
2017-06-28 7:54 ` Yao Qi
2017-06-28 14:20 ` Pedro Alves
2017-06-02 12:30 ` [PATCH 32/40] Make "break foo" find "A::foo", A::B::foo", etc. [C++ and wild matching] Pedro Alves
2017-08-08 23:48 ` Keith Seitz
2017-11-22 16:48 ` Pedro Alves
2017-11-24 16:48 ` Pedro Alves
2017-11-24 16:57 ` Pedro Alves
2017-11-28 0:39 ` Keith Seitz
2017-11-28 0:02 ` Keith Seitz
2017-11-28 0:21 ` Pedro Alves
2017-11-28 0:42 ` Keith Seitz
2017-06-02 12:30 ` [PATCH 30/40] Use search_domain::FUNCTIONS_DOMAIN when setting breakpoints Pedro Alves
2017-08-08 21:07 ` Keith Seitz
2017-11-08 16:20 ` Pedro Alves
2017-06-02 12:30 ` [PATCH 20/40] Eliminate block_iter_name_* Pedro Alves
2017-07-17 19:47 ` Keith Seitz
2017-07-20 17:05 ` Pedro Alves
2017-06-02 12:31 ` [PATCH 04/40] Fix TAB-completion + .gdb_index slowness (generalize filename_seen_cache) Pedro Alves
2017-07-13 20:41 ` Keith Seitz
2017-07-14 19:40 ` Pedro Alves
2017-07-17 10:51 ` Pedro Alves
2017-06-02 12:31 ` [PATCH 29/40] Simplify completion_list_add_name | remove sym_text / sym_text_len Pedro Alves
2017-08-08 20:59 ` Keith Seitz
2017-11-08 16:19 ` Pedro Alves
2017-06-02 12:31 ` [PATCH 22/40] get_int_var_value Pedro Alves
2017-07-17 22:11 ` Keith Seitz
2017-07-20 17:15 ` Pedro Alves
2017-06-02 12:33 ` [PATCH 31/40] Handle custom completion match prefix / LCD Pedro Alves
2017-08-08 21:28 ` Keith Seitz
2017-11-27 17:11 ` Pedro Alves
2017-06-02 12:39 ` [PATCH 25/40] Introduce lookup_name_info and generalize Ada's FULL/WILD name matching Pedro Alves
2017-07-18 20:14 ` Keith Seitz
2017-07-18 22:31 ` Pedro Alves
2017-07-20 19:00 ` Pedro Alves
2017-07-20 19:06 ` Pedro Alves
2017-08-08 20:29 ` Keith Seitz
2017-10-19 17:36 ` Pedro Alves
2017-11-01 15:38 ` Joel Brobecker
2017-11-08 16:10 ` Pedro Alves
2017-11-08 22:15 ` Joel Brobecker
2017-06-02 12:39 ` [PATCH 26/40] Optimize .gdb_index symbol name searching Pedro Alves
2017-08-08 20:32 ` Keith Seitz
2017-11-08 16:14 ` Pedro Alves
2017-11-08 16:16 ` [pushed] Reorder/reindent dw2_expand_symtabs_matching & friends (Re: [PATCH 26/40] Optimize .gdb_index symbol name searching) Pedro Alves
2017-11-18 5:23 ` [PATCH 26/40] Optimize .gdb_index symbol name searching Simon Marchi
2017-11-20 0:33 ` Pedro Alves
2017-11-20 0:42 ` [PATCH 1/3] 0xff chars in name components table; cp-name-parser lex UTF-8 identifiers Pedro Alves
2017-11-20 1:38 ` Simon Marchi
2017-11-20 11:56 ` Pedro Alves
2017-11-20 16:50 ` Simon Marchi
2017-11-21 0:11 ` Pedro Alves
2017-11-20 0:42 ` [PATCH 2/3] Unit test name-component bounds searching directly Pedro Alves
2017-11-20 3:16 ` Simon Marchi
2017-11-20 14:17 ` Pedro Alves
2017-11-20 0:42 ` [PATCH 3/3] Fix mapped_index::find_name_components_bounds upper bound computation Pedro Alves
2017-11-20 3:17 ` Simon Marchi
2017-06-02 12:39 ` [PATCH 23/40] Make language_def O(1) Pedro Alves
2017-07-17 23:03 ` Keith Seitz
2017-07-20 17:40 ` Pedro Alves
2017-07-20 18:12 ` Get rid of "set language local"? (was: Re: [PATCH 23/40] Make language_def O(1)) Pedro Alves
2017-07-20 23:44 ` Matt Rice
2017-06-02 15:26 ` [PATCH 00/40] C++ debugging improvements: breakpoints, TAB completion, more Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1496406158-12663-3-git-send-email-palves@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox