From: Doug Evans <dje@google.com>
To: gdb-patches@sourceware.org
Subject: [PATCH] Make file-based lookup more interruptable
Date: Fri, 15 May 2015 22:20:00 -0000 [thread overview]
Message-ID: <089e0160b1be9352da05162640cb@google.com> (raw)
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,
next reply other threads:[~2015-05-15 22:20 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-15 22:20 Doug Evans [this message]
2015-05-19 11:55 ` Yao Qi
2015-05-22 17:46 ` Doug Evans
2015-06-02 0:03 ` Doug Evans
2015-06-02 7:59 ` Yao Qi
2015-06-02 12:34 ` Doug Evans
2015-06-02 13:08 ` Yao Qi
2015-06-02 13:20 ` Doug Evans
2015-06-02 13:46 ` Yao Qi
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=089e0160b1be9352da05162640cb@google.com \
--to=dje@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