From patchwork Fri Feb 27 17:48:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Evans X-Patchwork-Id: 5348 Received: (qmail 4412 invoked by alias); 27 Feb 2015 17:48:44 -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 4393 invoked by uid 89); 27 Feb 2015 17:48:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.7 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mail-qc0-f202.google.com Received: from mail-qc0-f202.google.com (HELO mail-qc0-f202.google.com) (209.85.216.202) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 27 Feb 2015 17:48:41 +0000 Received: by qcxm20 with SMTP id m20so2481808qcx.0 for ; Fri, 27 Feb 2015 09:48:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:cc:date:message-id:mime-version :content-type; bh=OaArVlRQ4QuIv8Tm3CbN6FysWc2c/tNWDA/mVhQz6Tw=; b=fFlaDF174/XAvHPk2+VcS5EEHtw0YwQXFpQYQATMmHpnEkpZJXscS5SAlTMzGy9frd Gd3Mu9pGKRvIRfK4q3JZRtzL8klsZe06UnC3tnRi4u04ciwpnIupkGjO58nNp94yP4h3 5pYQ78Bv4hie9NBXfoPuClEbAGSTGOJmTb/A3G55JUO3g4CYfoBcFEjBt55K2oEgBCE+ lQcLSsW6usbSLEeFEkqcmaBX4Za6sJ9Pl9ojeFX4GToA6q7Un043lpuj/R7hgP0fLPIo vul710xHKDpV+VQVxurAjgbqoMbofzHFFOGvhGAt4Pj0yMS9J6vs25Zq48dpMndONaqm EfJg== X-Gm-Message-State: ALoCoQmIh6Wz9SRlo34YxmvBnDsqcO1ZAyedk54eH37KN7/TdaH2D92hyNQA3gNIHwREm2xRAfSY X-Received: by 10.236.216.69 with SMTP id f65mr13541423yhp.58.1425059319608; Fri, 27 Feb 2015 09:48:39 -0800 (PST) Received: from corpmail-nozzle1-1.hot.corp.google.com ([100.108.1.104]) by gmr-mx.google.com with ESMTPS id p65si171824yhd.5.2015.02.27.09.48.39 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Feb 2015 09:48:39 -0800 (PST) Received: from ruffy.mtv.corp.google.com ([172.17.128.44]) by corpmail-nozzle1-1.hot.corp.google.com with ESMTPS id pgs57G7P.1; Fri, 27 Feb 2015 09:48:39 -0800 From: Doug Evans To: gdb-patches@sourceware.org Subject: [PATCH] [PR 17960] Temp fix for 17960 cc: keiths@redhat.com, gbenson@redhat.com Date: Fri, 27 Feb 2015 09:48:38 -0800 Message-ID: MIME-Version: 1.0 X-IsSubscribed: yes Hi. I wrote a simple fix for 17960 until Keith's more complete patch is ready. I don't intend to check this in, just filing this for reference sake. 2015-02-23 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 81fdddf..5859fce 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -5562,9 +5562,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; @@ -5620,8 +5620,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); @@ -5657,6 +5655,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; + volatile struct gdb_exception except; + + 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_CATCH (except, RETURN_MASK_ERROR) + { + make_file_symbol_completion_list_1 (text, word, srcfile); + } + if (except.reason < 0) + { + if (except.error != MAX_COMPLETIONS_REACHED_ERROR) + throw_exception (except); + } + + 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 f77bfe2..5afd851 100644 --- a/gdb/testsuite/gdb.base/completion.exp +++ b/gdb/testsuite/gdb.base/completion.exp @@ -777,6 +777,84 @@ 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" + +# gdb/17960 +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" + +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" + +# # Completion limiting. #