From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 56048 invoked by alias); 19 Oct 2016 11:33:50 -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 56022 invoked by uid 89); 19 Oct 2016 11:33:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.1 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW,RCVD_IN_SEMBACKSCATTER,RCVD_IN_SORBS_SPAM autolearn=no version=3.3.2 spammy=Hx-languages-length:1808 X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0b-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.158.5) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 19 Oct 2016 11:33:39 +0000 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id u9JBTGNW072968 for ; Wed, 19 Oct 2016 07:33:37 -0400 Received: from e06smtp12.uk.ibm.com (e06smtp12.uk.ibm.com [195.75.94.108]) by mx0a-001b2d01.pphosted.com with ESMTP id 26676q2t3p-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 19 Oct 2016 07:33:37 -0400 Received: from localhost by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 19 Oct 2016 12:33:36 +0100 Received: from d06dlp03.portsmouth.uk.ibm.com (9.149.20.15) by e06smtp12.uk.ibm.com (192.168.101.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 19 Oct 2016 12:33:33 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id D61F01B08023 for ; Wed, 19 Oct 2016 12:35:36 +0100 (BST) Received: from d06av05.portsmouth.uk.ibm.com (d06av05.portsmouth.uk.ibm.com [9.149.37.229]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u9JBXXh850659572 for ; Wed, 19 Oct 2016 11:33:33 GMT Received: from d06av05.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av05.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u9JBXWvp010613 for ; Wed, 19 Oct 2016 05:33:33 -0600 Received: from ThinkPad (dyn-9-152-212-68.boeblingen.de.ibm.com [9.152.212.68]) by d06av05.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u9JBXWh7010597 for ; Wed, 19 Oct 2016 05:33:32 -0600 Date: Wed, 19 Oct 2016 11:33:00 -0000 From: Philipp Rudo To: gdb-patches@sourceware.org Subject: Re: [PATCH v2 31/31] Support an "unlimited" number of user-defined arguments In-Reply-To: <1476839539-8374-32-git-send-email-palves@redhat.com> References: <1476839539-8374-1-git-send-email-palves@redhat.com> <1476839539-8374-32-git-send-email-palves@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16101911-0008-0000-0000-000002E25A5D X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16101911-0009-0000-0000-00001A64A1E9 Message-Id: <20161019133349.2bc6ccf2@ThinkPad> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-10-19_07:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1609300000 definitions=main-1610190210 X-IsSubscribed: yes X-SW-Source: 2016-10/txt/msg00561.txt.bz2 Hi On Wed, 19 Oct 2016 02:12:19 +0100 Pedro Alves wrote: > I recently wrote a user-defined command that could benefit from > supporting an unlimited number of arguments: > > http://palves.net/list-active-signal-handlers-with-gdb/ > > E.g., 'info signal-dispositions 1 2 3 4 5 6 7 8 9 10 11' > > However, we currently only support up to 10 arguments passed to > user-defined commands ($arg0..$arg9). > > I can't find a good reason for that, other than "old code with hard > coded limits". This patch removes that limit and modernizes the code > along the way: > > - Makes the user_args struct a real C++ class that uses std::vector > for storage. > > - Removes the "next" pointer from within user_args and uses a > std::vector to maintain a stack instead. > > - Adds a new RAII-based scoped_user_args_level class to help > push/pop user args in the stack instead of using a cleanup. > > I also needed a way to convert a number to a std::string, so I added a > new utility for that, gdb::to_string. Yet another thing that can go > away with C++11. [... snip ...] > +/* Returns a string representation of VAL. Replacement for > + std::to_string, which is only available in C++11 or later. */ > + > +namespace gdb { > + > +template > +inline std::string > +to_string (const T &val) > +{ > + std::stringstream ss; > + > + ss << val; > + return ss.str (); > +} > + > +} > + > /* Make a copy of the string at PTR with LEN characters > (and add a null character at the end in the copy). > Uses malloc to get the space. Returns the address of the copy. */ Is this really necessary? As far as I understood the discussion, we jump directly to C++11. Thus there is no need for an homemade to_string. Philipp