From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 74243 invoked by alias); 15 Aug 2018 09:31:05 -0000 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 Received: (qmail 74234 invoked by uid 89); 15 Aug 2018 09:31:05 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: =?ISO-8859-1?Q?No, score=-1.9 required=5.0 tests=BAYES_00,MIME_BASE64_BLANKS,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:997, It=e2, It, sve?= X-HELO: EUR03-DB5-obe.outbound.protection.outlook.com Received: from mail-eopbgr40049.outbound.protection.outlook.com (HELO EUR03-DB5-obe.outbound.protection.outlook.com) (40.107.4.49) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 15 Aug 2018 09:31:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector1-arm-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Gq1mqYhwKOEKUmDYmw/Yhh80z2xXoa8Wms0mSDaPyXA=; b=f9qHfkv8I4Cbo3Wz/dAqMYpB5lZcQuQ3sktwgPxXPQ5iNgtG7EuUjXL8Bv8b1SG42xM5BTpUiatqLpILDf2tzN620/vvP+g8y2KqUZfp8FNuoNUA/5RlYcnY5v0GAB43Wqm9br8TjGm9b5PUeuz1gjkGhYyvYGpuaJveTNAMYaE= Received: from DB6PR0802MB2133.eurprd08.prod.outlook.com (10.172.226.148) by DB6PR0802MB2262.eurprd08.prod.outlook.com (10.172.227.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1038.23; Wed, 15 Aug 2018 09:31:00 +0000 Received: from DB6PR0802MB2133.eurprd08.prod.outlook.com ([fe80::6c67:c822:7f7d:d62d]) by DB6PR0802MB2133.eurprd08.prod.outlook.com ([fe80::6c67:c822:7f7d:d62d%7]) with mapi id 15.20.1038.025; Wed, 15 Aug 2018 09:31:00 +0000 From: Alan Hayward To: GDB Patches CC: nd Subject: Request for 8.2, SVE cores && adding SVE to NEWS file etc Date: Wed, 15 Aug 2018 09:31:00 -0000 Message-ID: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alan.Hayward@arm.com; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) Content-Type: text/plain; charset="utf-8" Content-ID: <0ED186E1810A6E43BE604DE6D9BDFEE3@eurprd08.prod.outlook.com> Content-Transfer-Encoding: base64 MIME-Version: 1.0 X-IsSubscribed: yes X-SW-Source: 2018-08/txt/msg00389.txt.bz2 V2FzbuKAmXQgc3VyZSBpZiB0aGlzIHdhcyB0aGUgYmVzdCBwbGFjZSB0byBh c2suDQoNCjEpIElzIDguMiBzdGlsbCBvcGVuIHRvIG5ldyBmdW5jdGlvbmFs aXR5PyBJdOKAmWQgYmUgcmVhbGx5IHVzZWZ1bCB0byBoYXZlIGNvcmUgc3Vw cG9ydCBmb3IgQWFyY2g2NCBTVkUgaW4gOC4yDQooR2l2ZW4gU1ZFIGlzIHN1 cHBvcnRlZCBpbiA4LjIsIEkgZ3Vlc3MgeW91IGNvdWxkIGFyZ3VlIGl04oCZ cyBhIGJ1ZyBmaXggOikuICkNCkN1cnJlbnRseSBpbiA4LjIsIEdEQiB3aWxs IGp1c3QgaWdub3JlIHRoZSBTVkUgcGFydHMgb2YgYSBjb3JlIGZpbGUuDQoN ClRoZSBmb3VyIGNvbW1pdHMgYXJlOg0KKEVhcmxpZXN0IHBhdGNoIGlzIG9i diwgc2Vjb25kIGlzIGEgbWVjaGFuaWNhbCBjaGFuZ2UgYWNyb3NzIG1hbnkg ZmlsZXMsIHRoZSBmaW5hbCB0d28gYXJlIGFhcmNoNjQgb25seSkNCg0KMGM3 NmUwNmQ1YyAgIDIgZGF5cyBhZ28gQWxhbiBIYXl3YXJkICAgIFBhcnNlIFNW RSByZWdpc3RlcnMgaW4gYWFyY2g2NCBjb3JlIGZpbGUgcmVhZGluZy93cml0 aW5nDQpiN2ZkNjViOWRjICAgMiBkYXlzIGFnbyBBbGFuIEhheXdhcmQgICAg RGV0ZWN0IFNWRSB3aGVuIHJlYWRpbmcgYWFyY2g2NCBjb3JlIGZpbGVzDQph NjE2YmI5NDUwICAgMiBkYXlzIGFnbyBBbGFuIEhheXdhcmQgICAgU3BsaXQg c2l6ZSBpbiByZWdzZXQgc2VjdGlvbiBpdGVyYXRvcnMNCmRiZDUzNGZlZTQg ICA1IGRheXMgYWdvIEFsYW4gSGF5d2FyZCAgICBSZW5hbWUgc2l6ZSBpbiBn ZXRfY29yZV9yZWdpc3Rlcl9zZWN0aW8NCg0KDQoyKSBJ4oCZdmUgc3BvdHRl ZCB0aGF0IEFhcmNoNjQgU1ZFIHN1cHBvcnQgc2hvdWxkIHByb2JhYmx5IGJl IG1lbnRpb25lZCBpbiB0aGUgTkVXUyBmaWxlLg0KQXJlIHRoZXJlIGFueSBv dGhlciBkb2N1bWVudGF0aW9uIHR5cGUgZmlsZXMgdGhhdCBuZWVkIHVwZGF0 aW5nIGFsb25nc2lkZT8NCg0KDQpUaGFua3MsDQpBbGFuLg0KDQoNCg0KDQo= >From gdb-patches-return-149843-listarch-gdb-patches=sources.redhat.com@sourceware.org Wed Aug 15 14:39:37 2018 Return-Path: Delivered-To: listarch-gdb-patches@sources.redhat.com Received: (qmail 124388 invoked by alias); 15 Aug 2018 14:39:37 -0000 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 Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 124281 invoked by uid 89); 15 Aug 2018 14:39:36 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.6 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wm0-f48.google.com Received: from mail-wm0-f48.google.com (HELO mail-wm0-f48.google.com) (74.125.82.48) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 15 Aug 2018 14:39:34 +0000 Received: by mail-wm0-f48.google.com with SMTP id f21-v6so1593960wmc.5 for ; Wed, 15 Aug 2018 07:39:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=3+Td9r4j9Zl3CBR+ipxh/nLuECEmEVxUdtBOkN8pdrs=; b=gCJE+MFYmubk53CXrabas7IBF4c5669Shmw2Y7/m3rAkcURuw6Mp5EHMQeGcjpUCt2 yjYVs8q+ZxwlMbURWT8ixYadsVczJ/xV/cjDvuM1rzLXzovJrszYmpoECdRlzeWKB2km lC8xUXzRehCBucleYXPgVRdiiXrRKsmPzJ3fJ6hpvfnM4qyi4ajxwh5EfpWo318JaGzv /ZRFWCZ0SzF0nIKaUnKw9wpCBb/rGS8sU6JPe0RCHCtRNiRi8PiFJ5tfwjc0KeyPwLdG JiAj8XbAuGgKBP99yrYpdggyF/Zcr6QjrE9xosMHz9cfrQLFgPa5Gc0kIlo66eFu1RJo pueQ== Return-Path: Received: from localhost (host86-152-213-13.range86-152.btcentralplus.com. [86.152.213.13]) by smtp.gmail.com with ESMTPSA id j133-v6sm5078365wmd.12.2018.08.15.07.39.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 15 Aug 2018 07:39:30 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 2/2] gdb: Allow parenthesis to group arguments to user-defined commands Date: Wed, 15 Aug 2018 14:39:00 -0000 Message-Id: In-Reply-To: References: In-Reply-To: References: X-IsSubscribed: yes X-SW-Source: 2018-08/txt/msg00391.txt.bz2 Content-length: 6920 When calling a user-defined command then currently, arguments are whitespace separated. This means that it is impossible to pass a single argument that contains a whitespace. The exception to the no whitespace rule is strings, a string argument, enclosed in double, or single quotes, can contain whitespace. However, if a user wants to reference, for example, a type name that contains a space, as in these examples: user_command *((unsigned long long *) some_pointer) user_command {unsigned long long}some_pointer then this will not work, as the whitespace between 'unsigned' and 'long', as well as the whitespace between 'long' and 'long', will mean GDB interprets this as many arguments. The solution proposed in this patch is to allow parenthesis to be used to group arguments, so the use could now write: user_command (*((unsigned long long *) some_pointer)) user_command ({unsigned long long}some_pointer) And GDB will interpret these as a single argument. gdb/ChangeLog: * cli/cli-script.c (user_args::user_args): Allow parenthesis to group arguments. gdb/testsuite/ChangeLog: * gdb.base/commands.exp (args_with_whitespace): New proc, which is added to the list of procs to call. * gdb.base/run.c (global_var): Defined global. gdb/doc/ChangeLog: * gdb.texinfo (Define): Additional documentation about argument syntax. --- gdb/ChangeLog | 5 ++++ gdb/cli/cli-script.c | 8 +++++- gdb/doc/ChangeLog | 5 ++++ gdb/doc/gdb.texinfo | 54 +++++++++++++++++++++++++++++++++---- gdb/testsuite/ChangeLog | 6 +++++ gdb/testsuite/gdb.base/commands.exp | 36 +++++++++++++++++++++++++ gdb/testsuite/gdb.base/run.c | 3 +++ 7 files changed, 111 insertions(+), 6 deletions(-) diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c index 6f31a400197..fd80ab9fbcf 100644 --- a/gdb/cli/cli-script.c +++ b/gdb/cli/cli-script.c @@ -758,6 +758,7 @@ user_args::user_args (const char *command_line) int squote = 0; int dquote = 0; int bsquote = 0; + int pdepth = 0; /* Strip whitespace. */ while (*p == ' ' || *p == '\t') @@ -769,7 +770,8 @@ user_args::user_args (const char *command_line) /* Get to the end of this argument. */ while (*p) { - if (((*p == ' ' || *p == '\t')) && !squote && !dquote && !bsquote) + if (((*p == ' ' || *p == '\t')) + && !squote && !dquote && !bsquote && pdepth == 0) break; else { @@ -793,6 +795,10 @@ user_args::user_args (const char *command_line) squote = 1; else if (*p == '"') dquote = 1; + else if (*p == '(') + pdepth++; + else if (*p == ')') + pdepth--; } p++; } diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 433a2698a92..11cbef97b8f 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -25219,14 +25219,58 @@ @noindent This defines the command @code{adder}, which prints the sum of -its three arguments. Note the arguments are text substitutions, so they may -reference variables, use complex expressions, or even perform inferior -functions calls. +its three arguments. + +The arguments to user-defined commands are text substitutions, so they +may reference variables, use complex expressions, or even perform +inferior functions calls. Each argument is separated with whitespace, +so in the previous example three arguments were passed. The following +example also passes three arguments, though the arguments are more +complex: + +@smallexample +adder 10+1 10+2 10+3 +@end smallexample + +@noindent +However, if whitespace were added around the @code{+} characters, then +9 arguments would be passed, @code{adder} only uses the first 3 of +these arguments, and the others would be silently ignored: + +@smallexample +adder 10 + 1 10 + 2 10 + 3 +@end smallexample + +@noindent +Parenthesis can be uses to group complex expressions that include +whitespace into a single argument, so the previous example can be +modified to pass just 3 arguments again, like this: + +@smallexample +adder (10 + 1) (10 + 2) (10 + 3) +@end smallexample + +@noindent +The parenthesis are passed through as part of the argument, so the +previous example causes @value{GDBN} to evaluate: + +@smallexample +print (10 + 1) + (10 + 2) + (10 + 3) +@end smallexample + +@noindent +Nested parenthesis are also allowed within an argument, in the +following example 3 arguments are still passed: + +@smallexample +adder (10 + 1) (10 + (1 + 1)) (10 + (1 + (1 + 1))) +@end smallexample @cindex argument count in user-defined commands @cindex how many arguments (user-defined commands) -In addition, @code{$argc} may be used to find out how many arguments have -been passed. +@noindent +Within a user-defined command @code{$argc} may be used to find out how +many arguments have been passed. @smallexample define adder diff --git a/gdb/testsuite/gdb.base/commands.exp b/gdb/testsuite/gdb.base/commands.exp index 7ce33fdefa9..42ffd6fa0af 100644 --- a/gdb/testsuite/gdb.base/commands.exp +++ b/gdb/testsuite/gdb.base/commands.exp @@ -1125,6 +1125,41 @@ proc_with_prefix backslash_in_multi_line_command_test {} { gdb_test "print 1" "" "run command" } +proc_with_prefix args_with_whitespace {} { + gdb_test_multiple "define show_args" "define show_args" { + -re "End with" { + pass "define show_args" + } + } + + # This test should alternate between 0xdeadbeef and 0xfeedface two times. + gdb_test \ + [multi_line_input \ + {printf "nargs=%d:", $argc} \ + {set $i = 0} \ + {while $i < $argc} \ + {printf " "} \ + {eval "echo '$arg%d'", $i} \ + {set $i = $i + 1} \ + {end} \ + {printf "\n"} \ + {end}] \ + "" \ + "enter commands" + + gdb_test "show_args 1 2 3" \ + "nargs=3: '1' '2' '3'" + + gdb_test "show_args 1 (1 + 1) (1 + (1 + 1))" \ + "nargs=3: '1' '\\(1 \\+ 1\\)' '\\(1 \\+ \\(1 \\+ 1\\)\\)'" + + gdb_test "show_args ({unsigned long long} &global_var)" \ + "nargs=1: '\\({unsigned long long} &global_var\\)'" + + gdb_test "show_args (*((unsigned long long *) &global_var))" \ + "nargs=1: '\\(\\*\\(\\(unsigned long long \\*\\) &global_var\\)\\)'" +} + gdbvar_simple_if_test gdbvar_simple_while_test gdbvar_complex_if_while_test @@ -1154,5 +1189,6 @@ backslash_in_multi_line_command_test define_if_without_arg_test loop_break_test loop_continue_test +args_with_whitespace # This one should come last, as it redefines "backtrace". redefine_backtrace_test diff --git a/gdb/testsuite/gdb.base/run.c b/gdb/testsuite/gdb.base/run.c index 614b018260d..d89bad78bb4 100644 --- a/gdb/testsuite/gdb.base/run.c +++ b/gdb/testsuite/gdb.base/run.c @@ -8,6 +8,9 @@ #include "../lib/unbuffer_output.c" +/* Used by commands.exp test script. */ +volatile unsigned long long global_var = 34; + int factorial (int); int -- 2.14.4