From patchwork Thu Sep 8 18:44:11 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Diego Novillo X-Patchwork-Id: 113931 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id D7DFCB708F for ; Fri, 9 Sep 2011 04:44:34 +1000 (EST) Received: (qmail 28687 invoked by alias); 8 Sep 2011 18:44:32 -0000 Received: (qmail 28678 invoked by uid 22791); 8 Sep 2011 18:44:31 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RP_MATCHES_RCVD, SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (74.125.121.67) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 08 Sep 2011 18:44:16 +0000 Received: from wpaz24.hot.corp.google.com (wpaz24.hot.corp.google.com [172.24.198.88]) by smtp-out.google.com with ESMTP id p88IiETo031382; Thu, 8 Sep 2011 11:44:14 -0700 Received: from topo.tor.corp.google.com (topo.tor.corp.google.com [172.29.41.2]) by wpaz24.hot.corp.google.com with ESMTP id p88IiCIH001679; Thu, 8 Sep 2011 11:44:12 -0700 Received: by topo.tor.corp.google.com (Postfix, from userid 54752) id 08CE01DA1D5; Thu, 8 Sep 2011 14:44:11 -0400 (EDT) To: reply@codereview.appspotmail.com, crowl@google.com, gcc-patches@gcc.gnu.org Subject: [pph] Fix token dumping within a window (issue4991046) Message-Id: <20110908184412.08CE01DA1D5@topo.tor.corp.google.com> Date: Thu, 8 Sep 2011 14:44:11 -0400 (EDT) From: dnovillo@google.com (Diego Novillo) X-System-Of-Record: true X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org When dumping a range of tokens, I was not properly counting the tokens to be dumped, which resulted in empty output when dumping a range of tokens in the middle of a large array. I also reduced the size of the window to print. It was too large to be useful. Tested on x86_64. Committed to branch. Diego. * parser.c (cp_lexer_dump_tokens): Properly count number of printed tokens to know when to stop. (cp_debug_parser): Reduce token window size to 20. --- This patch is available for review at http://codereview.appspot.com/4991046 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 700ca64..a46edba 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -259,7 +259,7 @@ cp_lexer_dump_tokens (FILE *file, VEC(cp_token,gc) *buffer, cp_token *start_token, unsigned num, cp_token *curr_token) { - unsigned i; + unsigned i, nprinted; cp_token *token; bool do_print; @@ -281,7 +281,8 @@ cp_lexer_dump_tokens (FILE *file, VEC(cp_token,gc) *buffer, } do_print = false; - for (i = 0; VEC_iterate (cp_token, buffer, i, token) && i < num; i++) + nprinted = 0; + for (i = 0; VEC_iterate (cp_token, buffer, i, token) && nprinted < num; i++) { if (token == start_token) do_print = true; @@ -289,6 +290,7 @@ cp_lexer_dump_tokens (FILE *file, VEC(cp_token,gc) *buffer, if (!do_print) continue; + nprinted++; if (token == curr_token) fprintf (file, "[["); @@ -462,7 +464,7 @@ cp_debug_parser_tokens (FILE *file, cp_parser *parser, int window_size) void cp_debug_parser (FILE *file, cp_parser *parser) { - const size_t window_size = 200; + const size_t window_size = 20; if (file == NULL) file = stderr;