From patchwork Fri May 15 22:20:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Evans X-Patchwork-Id: 6759 Received: (qmail 48382 invoked by alias); 15 May 2015 22:20:34 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 48367 invoked by uid 89); 15 May 2015 22:20:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_05, RCVD_IN_DNSWL_LOW, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mail-pa0-f74.google.com Received: from mail-pa0-f74.google.com (HELO mail-pa0-f74.google.com) (209.85.220.74) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 15 May 2015 22:20:33 +0000 Received: by pablj1 with SMTP id lj1so8968947pab.0 for ; Fri, 15 May 2015 15:20:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:message-id:date:subject:from:to :content-type; bh=sc4VOr+9Ph32q6AqICzkV2PHObLOIYCayjULoBHNT3o=; b=bW5i3Pvhe2LAdPpsH7eNXhBwhncA+HnJDuaWFVZYPqmjfjTC6H4qh/HpGEuDwjUQgr ry+aE7ZVyiy9hwIzSal7rNf+DeHMpJBIYResKgF/nbbny+YjjAp+Qs7EVqxnNFdNd68v WiB0P2sceekuUCUpjt7atfKKUTgyuuZpcJWQ1rypfhZmB7HFEcDtOcxWHBcFvrDqOjbG 8/HpNF1Y641Iirw/j/yX4wevlKAN85DogG61LQpiCYbcJmp674LARMydBeOczeGrcGBh iBVaj7rrH/nDoLN9DdIf9ebkSwt71Gzfx1OPSYVGVye3pAnQLIdddfUvw/gytwkFWhj4 n+qw== X-Gm-Message-State: ALoCoQl2XiSC7FcHRGs7PvoNKkkv8LR22rY5/jZRwZEpPup49yCbh5Enezbc1P2op9Lk4xO9L54os2uTgA+WxXJpDng/5WBeHJhl2WMSWMVBlKYamlCqzSHg6jT2sm69pGeYIWvaqU0TtTnopJea9zwRcostLBZjyGea/KWqLh3wzf0IhDslIpM= MIME-Version: 1.0 X-Received: by 10.70.54.193 with SMTP id l1mr15907962pdp.11.1431728431504; Fri, 15 May 2015 15:20:31 -0700 (PDT) Message-ID: <089e0160b1be9352da05162640cb@google.com> Date: Fri, 15 May 2015 22:20:31 +0000 Subject: [PATCH] Make file-based lookup more interruptable From: Doug Evans To: gdb-patches@sourceware.org X-IsSubscribed: yes 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 * 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,