This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH] Make file-based lookup more interruptable
- From: Doug Evans <dje at google dot com>
- To: gdb-patches at sourceware dot org
- Date: Fri, 15 May 2015 22:20:31 +0000
- Subject: [PATCH] Make file-based lookup more interruptable
- Authentication-results: sourceware.org; auth=none
Hi.
This patch makes, for example, "b 'foo.c':bar" more interruptable.
I put the QUIT calls at two logical levels for robustness and clarity:
iterate_over_symtabs and map_symtabs_matching_filename.
I plan to do the same for other QUIT calls I've already added
and plan to add.
2015-05-15 Doug Evans <dje@google.com>
* completer.c (location_completer): Protect file_to_match with cleanup.
* dwarf2read.c (dw2_map_symtabs_matching_filename): Add QUIT calls.
* psymtab.c (psym_map_symtabs_matching_filename): Add QUIT call.
* symtab.c (iterate_over_symtabs): Add QUIT calls.
diff --git a/gdb/completer.c b/gdb/completer.c
index c8c0e4c..c796951 100644
--- a/gdb/completer.c
+++ b/gdb/completer.c
@@ -195,7 +195,6 @@ location_completer (struct cmd_list_element *ignore,
int quoted = *text == '\'' || *text == '"';
int quote_char = '\0';
const char *colon = NULL;
- char *file_to_match = NULL;
const char *symbol_start = text;
const char *orig_text = text;
size_t text_len;
@@ -241,12 +240,17 @@ location_completer (struct cmd_list_element *ignore,
text++;
text_len = strlen (text);
- /* Where is the file name? */
- if (colon)
+ /* Where is the file name?
+ If the text includes a colon, they want completion only on a
+ symbol name after the colon. Otherwise, we need to complete on
+ symbols as well as on files. */
+ if (colon != NULL)
{
- char *s;
+ char *s, *file_to_match;
+ struct cleanup *cleanup;
- file_to_match = (char *) xmalloc (colon - text + 1);
+ file_to_match = xmalloc (colon - text + 1);
+ cleanup = make_cleanup (xfree, file_to_match);
strncpy (file_to_match, text, colon - text + 1);
/* Remove trailing colons and quotes from the file name. */
for (s = file_to_match + (colon - text);
@@ -254,15 +258,9 @@ location_completer (struct cmd_list_element *ignore,
s--)
if (*s == ':' || *s == quote_char)
*s = '\0';
- }
- /* If the text includes a colon, they want completion only on a
- symbol name after the colon. Otherwise, we need to complete on
- symbols as well as on files. */
- if (colon)
- {
list = make_file_symbol_completion_list (symbol_start, word,
file_to_match);
- xfree (file_to_match);
+ do_cleanups (cleanup);
}
else
{
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 4d892d8..ca8573a 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -3448,6 +3448,8 @@ dw2_map_symtabs_matching_filename (struct objfile
*objfile, const char *name,
struct dwarf2_per_cu_data *per_cu = dw2_get_cu (i);
struct quick_file_names *file_data;
+ QUIT;
+
/* We only need to look at symtabs not already expanded. */
if (per_cu->v.quick->compunit_symtab)
continue;
@@ -3461,6 +3463,8 @@ dw2_map_symtabs_matching_filename (struct objfile
*objfile, const char *name,
const char *this_name = file_data->file_names[j];
const char *this_real_name;
+ QUIT;
+
if (compare_filenames_for_search (this_name, name))
{
if (dw2_map_expand_apply (objfile, per_cu, name, real_path,
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 383e4c4..27ba2ba 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -169,6 +169,8 @@ psym_map_symtabs_matching_filename (struct objfile
*objfile,
ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, pst)
{
+ QUIT;
+
/* We can skip shared psymtabs here, because any file name will be
attached to the unshared psymtab. */
if (pst->user != NULL)
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 72df872..f06622a 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -443,6 +443,8 @@ iterate_over_symtabs (const char *name,
ALL_OBJFILES (objfile)
{
+ QUIT;
+
if (iterate_over_some_symtabs (name, real_path, callback, data,
objfile->compunit_symtabs, NULL))
{
@@ -456,6 +458,8 @@ iterate_over_symtabs (const char *name,
ALL_OBJFILES (objfile)
{
+ QUIT;
+
if (objfile->sf
&& objfile->sf->qf->map_symtabs_matching_filename (objfile,
name,