From patchwork Tue Aug 11 00:19:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Evans X-Patchwork-Id: 8126 Received: (qmail 104264 invoked by alias); 11 Aug 2015 00:19:05 -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 104251 invoked by uid 89); 11 Aug 2015 00:19:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD, SPF_PASS 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; Tue, 11 Aug 2015 00:19:03 +0000 Received: by pacum4 with SMTP id um4so15701600pac.1 for ; Mon, 10 Aug 2015 17:19:01 -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:cc :content-type; bh=8EejF9L1k7kuFTj2q4X9rISEp6lG/kMV/TGZTxy1YhM=; b=CtZt2AxuwGWNOtvmpPV7d0OjGxZaMNbI9lxgY0YGksD1AjkVDE+ZpvWLxsv6FXmpvI jcL/zPuGxDXcVQzFTFMv7afsORcNCzi67SwC/xIr01yRsQkpewnhEpejibLidF+KZdfY pejUMEC3SBdQm8XuaPnggiMOcrxl7p9uqW6Mgsz6kDS4r/IZLtY+R2rDH7GU78TkBadu VzXHc7bv8JBrs3KBUZkuYjSvfszF4wsH5DIf2hw8CQy/KE3PBNFcfjyRnJVFEFQLvvlS MN+C8+UhD4w/yT81B6qbq/NAFqFPHZzfAAZftQJviF0upp0G4TkX5Y7Zzbr5ybYXtHUt llnw== X-Gm-Message-State: ALoCoQlb5TVweKZh1mTq+VRN9fOpzfkuxqFlEV7AvTFxNa4fTXIbx2MetvpCdBbqI15qFyyb6f1t MIME-Version: 1.0 X-Received: by 10.68.180.161 with SMTP id dp1mr2413272pbc.13.1439252341391; Mon, 10 Aug 2015 17:19:01 -0700 (PDT) Message-ID: <047d7b6d95948d5902051cfe0c34@google.com> Date: Tue, 11 Aug 2015 00:19:01 +0000 Subject: Re: [RFC/7.10] Temp fix for 17960 assertion failure? From: Doug Evans To: Keith Seitz Cc: "gdb-patches@sourceware.org ml" X-IsSubscribed: yes Doug Evans writes: > On Fri, Aug 7, 2015 at 8:48 AM, Keith Seitz wrote: > > Hi, Doug, > > > > A while ago you posted a temporary patch to squash the completer > > assertion failure reported in 17960: > > > > (gdb) break gdb.c:ma > > ./../src/gdb/completer.c:837: internal-error: maybe_add_completion: > > Assertion `tracker != NULL' failed. > > A problem internal to GDB has been detected, > > further debugging may prove unreliable. > > > > Proposed patch: > > https://sourceware.org/ml/gdb-patches/2015-02/msg00830.html > > > > Should we add this to 7.10? > > Ah, righto. > Sounds good to me. > I'll take care of it. [apologies if you get this twice, mailer problems] Heya, thanks for flagging this. It's great to not let this get into 7.10. Here's the patch that I committed to trunk and 7.10. I had to tweak the testcase to trigger the bug as the .exp had changed a bit and max-completions was now "unlimited" at the point of the test, whereas the test requires a fixed limit. I verified an unpatched gdb still crashes with the test. 2015-08-10 Doug Evans Keith Seitz PR gdb/17960 * symtab.c (make_file_symbol_completion_list_1): Renamed from make_file_symbol_completion_list and made static. (make_file_symbol_completion_list): New function. testsuite/ * gdb.base/completion.exp: Add location completer tests. diff --git a/gdb/symtab.c b/gdb/symtab.c index ebafe53..5278265 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -5604,9 +5604,9 @@ make_symbol_completion_list_fn (struct cmd_list_element *ignore, /* Like make_symbol_completion_list, but returns a list of symbols defined in a source file FILE. */ -VEC (char_ptr) * -make_file_symbol_completion_list (const char *text, const char *word, - const char *srcfile) +static VEC (char_ptr) * +make_file_symbol_completion_list_1 (const char *text, const char *word, + const char *srcfile) { struct symbol *sym; struct symtab *s; @@ -5662,8 +5662,6 @@ make_file_symbol_completion_list (const char *text, const char *word, sym_text_len = strlen (sym_text); - return_val = NULL; - /* Find the symtab for SRCFILE (this loads it if it was not yet read in). */ s = lookup_symtab (srcfile); @@ -5699,6 +5697,36 @@ make_file_symbol_completion_list (const char *text, const char *word, return (return_val); } +/* Wrapper around make_file_symbol_completion_list_1 + to handle MAX_COMPLETIONS_REACHED_ERROR. */ + +VEC (char_ptr) * +make_file_symbol_completion_list (const char *text, const char *word, + const char *srcfile) +{ + struct cleanup *back_to, *cleanups; + + completion_tracker = new_completion_tracker (); + cleanups = make_cleanup_free_completion_tracker (&completion_tracker); + return_val = NULL; + back_to = make_cleanup (do_free_completion_list, &return_val); + + TRY + { + make_file_symbol_completion_list_1 (text, word, srcfile); + } + CATCH (except, RETURN_MASK_ERROR) + { + if (except.error != MAX_COMPLETIONS_REACHED_ERROR) + throw_exception (except); + } + END_CATCH + + discard_cleanups (back_to); + do_cleanups (cleanups); + return return_val; +} + /* A helper function for make_source_files_completion_list. It adds another file name to a list of possible completions, growing the list as necessary. */ diff --git a/gdb/testsuite/gdb.base/completion.exp b/gdb/testsuite/gdb.base/completion.exp index 1eb0fd8..f0e4dec 100644 --- a/gdb/testsuite/gdb.base/completion.exp +++ b/gdb/testsuite/gdb.base/completion.exp @@ -777,6 +777,88 @@ gdb_test_multiple "" "$test" { } # +# Tests for the location completer +# + +# Turn off pending breakpoint support so that we don't get queried +# all the time. +gdb_test_no_output "set breakpoint pending off" + +set subsrc [string range $srcfile 0 [expr {[string length $srcfile] - 3}]] +set test "tab complete break $subsrc" +send_gdb "break $subsrc\t\t" +gdb_test_multiple "" $test { + -re "break\.c.*break1\.c.*$gdb_prompt " { + send_gdb "1\t\n" + gdb_test_multiple "" $test { + -re ".*Function \"$srcfile2\" not defined\..*$gdb_prompt " { + pass $test + } + -re "$gdb_prompt p$" { + fail $test + } + } + } + + -re "$gdb_prompt p$" { + fail $test + } +} + +gdb_test "complete break $subsrc" "break\.c.*break1\.c" + +set test "tab complete break need" +send_gdb "break need\t" +gdb_test_multiple "" $test { + -re "break need_malloc " { + send_gdb "\n" + gdb_test_multiple "" $test { + -re ".*Breakpoint.*at .*/$srcfile, line .*$gdb_prompt " { + pass $test + gdb_test_no_output "delete breakpoint \$bpnum" \ + "delete breakpoint for $test" + } + -re "$gdb_prompt p$" { + fail $test + } + } + } + -re "$gdb_prompt p$" { + fail $test + } +} + +gdb_test "complete break need" "need_malloc" + +# gdb/17960 +# Enabling max-completions is necessary to trigger the bug. +gdb_test_no_output "set max-completions 10" +set test "tab complete break $srcfile:ma" +send_gdb "break $srcfile:ma\t" +gdb_test_multiple "" $test { + -re "break $srcfile:main " { + send_gdb "\n" + gdb_test_multiple "" $test { + -re ".*Breakpoint.*at .*/$srcfile, line .*$gdb_prompt " { + pass $test + gdb_test_no_output "delete breakpoint \$bpnum" \ + "delete breakpoint for $test" + } + -re "$gdb_prompt p$" { + fail $test + } + } + } + -re "$gdb_prompt p$" { + fail $test + } +} + +gdb_test "complete break $srcfile:ma" "break\.c:main" + +# End of gdb/17960 testing. + +# # Completion limiting. #