From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4917 invoked by alias); 1 Oct 2012 18:08:18 -0000 Received: (qmail 4710 invoked by uid 22791); 1 Oct 2012 18:08:15 -0000 X-SWARE-Spam-Status: No, hits=-5.2 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,KHOP_RCVD_TRUST,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE,RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail-gh0-f201.google.com (HELO mail-gh0-f201.google.com) (209.85.160.201) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 01 Oct 2012 18:08:09 +0000 Received: by ghbz19 with SMTP id z19so621987ghb.0 for ; Mon, 01 Oct 2012 11:08:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=date:message-id:to:subject:from:x-gm-message-state; bh=vn6z9hVAzN82sUzTToV5dIxMTQhUQTx5aD+s5P6rDLw=; b=h/Ga99R6MBnVyui6BavYUhIC87y/OtbmrMWvmKdLaPPjSHLa8NchHdhpjCn/b1yhb0 KC6MCUAt4mspmYUdTQ+wEEq1iJqd0E1rS9vu8X0vToMljZ9ezHxAtvyIw8+nE+FKt8t2 BAngLniN9RbT5LxM/H4Bg1xAsG0/ATqXrM/D+zFyWgkrRQ8Om3XW+huaWSVC2rnDJQ6k 5V1RWaLZgdcY0ccZ3L34C7t8YWAshrVR2JfbfzWsJsmZaOL8rL1+3Y+0+ULno+t4pzd8 8w0zwe7WCy5yYcXsqLSn+IGZtwWI8n9iQWOMSkqPv04qEytKcN645RsMEwhZ3W9aiGtg wfwA== Received: by 10.236.78.199 with SMTP id g47mr12735907yhe.0.1349114889243; Mon, 01 Oct 2012 11:08:09 -0700 (PDT) Received: from wpzn4.hot.corp.google.com (216-239-44-65.google.com [216.239.44.65]) by gmr-mx.google.com with ESMTPS id u42si3780378yhg.5.2012.10.01.11.08.09 (version=TLSv1/SSLv3 cipher=AES128-SHA); Mon, 01 Oct 2012 11:08:09 -0700 (PDT) Received: from ruffy2.mtv.corp.google.com (ruffy2.mtv.corp.google.com [172.18.110.129]) by wpzn4.hot.corp.google.com (Postfix) with ESMTP id BD4DD1E0043; Mon, 1 Oct 2012 11:08:08 -0700 (PDT) Date: Mon, 01 Oct 2012 18:08:00 -0000 Message-Id: To: keiths@redhat.com, gdb-patches@sourceware.org Subject: [RFA] partial fix for 14643 From: dje@google.com X-Gm-Message-State: ALoCoQmxyxxsNTTtWt9j3/fLQvcM8SJQr8NWE+2+w0cwA96H1KKNQoeaXunfICUzg2I0GK2G8sdoTmLYxfC8GLIawgYeRXZBr+sR3jzIVk4GeMRLiLRG3w7XKZy3iIBLrlVBnb1aGz8puCthlw34/Z2mdfQkdzh3TaiyamwXR/HGz0cAJCPbUAr5qRQktDYwXK7Q2FipTWlsPdye/AdvZnlLRDbPE5YJJg== X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-10/txt/msg00012.txt.bz2 Hi. This patch fixes two problems I found with linespec parsing: b thread.c:42 b thread It does not fix "b foo:: thread ::bar()". My fix for that is a bit hackish, and that case isn't as important. Ok to check in? [It depends on this patch, http://sourceware.org/ml/gdb-patches/2012-10/msg00011.html but only because it passes "message" to gdb_breakpoint.] 2012-10-01 Doug Evans PR 14643. * linespec.c (struct ls_parser): New member keyword_ok. (linespec_lexer_lex_string): Add comment. (linespec_lexer_lex_one): Ignore keywords if it's the wrong place for one. (parse_linespec): Set keyword_ok. testsuite/ * gdb.linespec/ls-errs.exp: Change tests of "b if|task|thread". * gdb.linespec/thread.c: New file. * gdb.linespec/thread.exp: New file. Index: linespec.c =================================================================== RCS file: /cvs/src/src/gdb/linespec.c,v retrieving revision 1.170 diff -u -p -r1.170 linespec.c --- linespec.c 25 Sep 2012 12:22:54 -0000 1.170 +++ linespec.c 1 Oct 2012 15:35:47 -0000 @@ -286,6 +286,11 @@ struct ls_parser /* Is the entire linespec quote-enclosed? */ int is_quote_enclosed; + /* Is a keyword syntactically valid at this point? + In, e.g., "break thread thread 1", the leading "keyword" must not + be interpreted as such. */ + int keyword_ok; + /* The state of the parse. */ struct linespec_state state; #define PARSER_STATE(PPTR) (&(PPTR)->state) @@ -607,6 +612,10 @@ linespec_lexer_lex_string (linespec_pars if (isspace (*PARSER_STREAM (parser))) { p = skip_spaces (PARSER_STREAM (parser)); + /* When we get here we know we've found something followed by + a space (we skip over parens and templates below). + So if we find a keyword now, we know it is a keyword and not, + say, a function name. */ if (linespec_lexer_lex_keyword (p) != NULL) { LS_TOKEN_STOKEN (token).ptr = start; @@ -716,8 +725,10 @@ linespec_lexer_lex_one (linespec_parser /* Skip any whitespace. */ PARSER_STREAM (parser) = skip_spaces (PARSER_STREAM (parser)); - /* Check for a keyword. */ - keyword = linespec_lexer_lex_keyword (PARSER_STREAM (parser)); + /* Check for a keyword, they end the linespec. */ + keyword = NULL; + if (parser->keyword_ok) + keyword = linespec_lexer_lex_keyword (PARSER_STREAM (parser)); if (keyword != NULL) { parser->lexer.current.type = LSTOKEN_KEYWORD; @@ -2024,6 +2035,10 @@ parse_linespec (linespec_parser *parser, } } + /* A keyword at the start cannot be interpreted as such. + Consider "b thread thread 42". */ + parser->keyword_ok = 0; + parser->lexer.saved_arg = *argptr; parser->lexer.stream = argptr; file_exception.reason = 0; @@ -2098,6 +2113,9 @@ parse_linespec (linespec_parser *parser, else if (token.type != LSTOKEN_STRING && token.type != LSTOKEN_NUMBER) unexpected_linespec_error (parser); + /* Now we can recognize keywords. */ + parser->keyword_ok = 1; + /* Shortcut: If the next token is not LSTOKEN_COLON, we know that this token cannot represent a filename. */ token = linespec_lexer_peek_token (parser); Index: testsuite/gdb.linespec/ls-errs.exp =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.linespec/ls-errs.exp,v retrieving revision 1.4 diff -u -p -r1.4 ls-errs.exp --- testsuite/gdb.linespec/ls-errs.exp 30 Jul 2012 17:45:37 -0000 1.4 +++ testsuite/gdb.linespec/ls-errs.exp 1 Oct 2012 15:35:48 -0000 @@ -171,7 +171,7 @@ foreach x {"3" "+100" "-100" "foo"} { } foreach x {"if" "task" "thread"} { - add the_tests $x unexpected_opt "keyword" $x + add the_tests $x invalid_function $x } add the_tests "'main.c'flubber" unexpected_opt "string" "flubber" Index: testsuite/gdb.linespec/thread.c =================================================================== RCS file: testsuite/gdb.linespec/thread.c diff -N testsuite/gdb.linespec/thread.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ testsuite/gdb.linespec/thread.c 1 Oct 2012 15:35:48 -0000 @@ -0,0 +1,31 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2012 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* http://sourceware.org/bugzilla/show_bug.cgi?id=14643 */ + +static void +thread () +{ +} + +int +main () +{ + int x = 0; + thread (); /* set breakpoint 1 here */ + return x; +} Index: testsuite/gdb.linespec/thread.exp =================================================================== RCS file: testsuite/gdb.linespec/thread.exp diff -N testsuite/gdb.linespec/thread.exp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ testsuite/gdb.linespec/thread.exp 1 Oct 2012 15:35:48 -0000 @@ -0,0 +1,41 @@ +# Copyright 2012 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# http://sourceware.org/bugzilla/show_bug.cgi?id=14643 +# gdb 7.5 thinks "thread" is a linespec keyword. + +standard_testfile +set exefile $testfile + +if {[prepare_for_testing $testfile $exefile $srcfile {debug}]} { + return -1 +} + +if ![runto_main] { + fail "Can't run to main" + return 0 +} + +set bp_location1 [gdb_get_line_number "set breakpoint 1 here"] + +gdb_test "break $srcfile:$bp_location1" \ + "Breakpoint.*at.* file .*$srcfile, line $bp_location1\\." \ + "breakpoint line number in file" + +gdb_continue_to_breakpoint "$bp_location1" + +gdb_breakpoint "thread" "message" + +gdb_continue_to_breakpoint "thread function"