From: Sterling Augustine <saugustine@google.com>
To: gdb-patches@sourceware.org
Subject: [PATCH] Make map_symbol_filenames_psymtab interruptible
Date: Thu, 27 Oct 2011 20:29:00 -0000 [thread overview]
Message-ID: <CAEG7qUw8OsAY+i45tYqfPcuKWZ2eauLOKnGcty6s68y2omYWWw@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 857 bytes --]
Hi,
Enclosed is a patch to allow interrupting
map_symbol_filenames_psymtab. This patch adds a call to QUIT in
map_symbol_filenames_psymtab, and several functions to cleanup data
that would have leaked.
Also, this patch adds a cleanup for the existing leak in
default_make_symbol_completion_list_break_on (check return_val's
relation to the existing QUITs). Although the new QUIT doesn't
introduce this particular leak, it creates many more opportunities for
it to happen.
Thanks,
Sterling
--
2011-10-27 Sterling Augustine <saugustine@google.com>
* psymtab.c (map_symbol_filenames_psymtab): Call QUIT.
* symtab.c (free_completion_list): New function.
(do_free_completion_list): Likewise.
(default_make_symbol_completion_list_break_on): New variable
back_to. Call make_cleanup and discard_cleanups.
(make_source_files_completion_list): Likewise.
[-- Attachment #2: cleanup.patch --]
[-- Type: text/x-patch, Size: 2478 bytes --]
Index: psymtab.c
===================================================================
RCS file: /cvs/src/src/gdb/psymtab.c,v
retrieving revision 1.30
diff -d -u -r1.30 psymtab.c
--- psymtab.c 10 Jun 2011 21:48:04 -0000 1.30
+++ psymtab.c 27 Oct 2011 19:39:02 -0000
@@ -1093,6 +1093,7 @@
if (ps->readin)
continue;
+ QUIT;
fullname = psymtab_to_fullname (ps);
(*fun) (ps->filename, fullname, data);
}
Index: symtab.c
===================================================================
RCS file: /cvs/src/src/gdb/symtab.c,v
retrieving revision 1.283
diff -d -u -r1.283 symtab.c
--- symtab.c 21 Jul 2011 15:13:29 -0000 1.283
+++ symtab.c 27 Oct 2011 19:39:02 -0000
@@ -3573,6 +3573,26 @@
return 1;
}
+/* Free any memory associated with a completion list. */
+static void
+free_completion_list (char ***list_ptr)
+{
+ int i = 0;
+ char **list = *list_ptr;
+ while (list[i] != NULL)
+ {
+ xfree (list[i]);
+ i++;
+ }
+ xfree (list);
+}
+
+static void
+do_free_completion_list (void *list)
+{
+ free_completion_list (list);
+}
+
/* Helper routine for make_symbol_completion_list. */
static int return_val_size;
@@ -3810,6 +3830,7 @@
/* Length of sym_text. */
int sym_text_len;
struct add_name_data datum;
+ struct cleanup *back_to;
/* Now look for the symbol we are supposed to complete on. */
{
@@ -3886,6 +3907,7 @@
return_val_index = 0;
return_val = (char **) xmalloc ((return_val_size + 1) * sizeof (char *));
return_val[0] = NULL;
+ back_to = make_cleanup (do_free_completion_list, &return_val);
datum.sym_text = sym_text;
datum.sym_text_len = sym_text_len;
@@ -3995,6 +4017,7 @@
macro_for_each (macro_user_macros, add_macro_name, &datum);
}
+ discard_cleanups (back_to);
return (return_val);
}
@@ -4244,12 +4267,15 @@
char **list = (char **) xmalloc (list_alloced * sizeof (char *));
const char *base_name;
struct add_partial_filename_data datum;
+ struct cleanup *back_to;
list[0] = NULL;
if (!have_full_symbols () && !have_partial_symbols ())
return list;
+ back_to = make_cleanup (do_free_completion_list, &list);
+
ALL_SYMTABS (objfile, s)
{
if (not_interesting_fname (s->filename))
@@ -4285,6 +4311,7 @@
datum.list_used = &list_used;
datum.list_alloced = &list_alloced;
map_partial_symbol_filenames (maybe_add_partial_symtab_filename, &datum);
+ discard_cleanups (back_to);
return list;
}
next reply other threads:[~2011-10-27 19:57 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-27 20:29 Sterling Augustine [this message]
2011-10-28 15:59 ` Tom Tromey
2011-10-28 17:36 ` Sterling Augustine
2011-10-28 18:14 ` Sterling Augustine
2011-11-02 20:48 ` Phil Muldoon
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=CAEG7qUw8OsAY+i45tYqfPcuKWZ2eauLOKnGcty6s68y2omYWWw@mail.gmail.com \
--to=saugustine@google.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