From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 64879 invoked by alias); 26 Mar 2015 18:28:23 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 64865 invoked by uid 89); 26 Mar 2015 18:28:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 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-oi0-f46.google.com Received: from mail-oi0-f46.google.com (HELO mail-oi0-f46.google.com) (209.85.218.46) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 26 Mar 2015 18:28:15 +0000 Received: by oifl3 with SMTP id l3so56900970oif.0 for ; Thu, 26 Mar 2015 11:28:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=X9rFWJiaFYeOH5wZ5sUFu8qQkQdtMor/esXAHgSnDHg=; b=PdBuQRaILEXeJYot5FMtlziqIdLhqVpme2RFl1MSnOQyF+eeSjBzzJPGMvBswRT/9s U1v/0tuUbFpB18AB7rcVE68HjyxHCgWN2vxVP/1hDTwLeZnKW1YQvO6PpB5UFQKWfnVx VJ2lvNMx2TKuokpRUoxVStfA4/qxvoo759HrnlOYC4HXTcFFuWK0EKUvk3jNVLU6IIyR YnlKPncKfJC1oITu834OIgYGAeHme61D8P5T8SqBBcelRBGCMvnsv2f0JdMiEAXJ10oE /viV0ve9bTcLkEAsB6DbAt0UlsT/SGx6a4eqGUaF6amA3KLsMIfBKC4XEBLERbX5kPUR sb5A== X-Gm-Message-State: ALoCoQklbuJmUIPX5l39IEtvFiCHy1rWEpR7TWJ3ky17WAqk4UhL7nvy5uyNp6bIXs8KUWgmaGaM MIME-Version: 1.0 X-Received: by 10.202.219.87 with SMTP id s84mr8449535oig.114.1427394493641; Thu, 26 Mar 2015 11:28:13 -0700 (PDT) Received: by 10.182.142.226 with HTTP; Thu, 26 Mar 2015 11:28:13 -0700 (PDT) In-Reply-To: References: Date: Thu, 26 Mar 2015 18:28:00 -0000 Message-ID: Subject: Re: How to compare $arg0 with string literal? From: Doug Evans To: Aleksey Midenkov Cc: "gdb@sourceware.org" Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2015-03/txt/msg00102.txt.bz2 On Thu, Mar 26, 2015 at 9:27 AM, Aleksey Midenkov wrote: > F.ex. > > define logging > if $argc == 1 > if $arg0 == off > set logging off > set logging file gdb.log > else if $arg0 == stop > set logging off > else > set logging $arg0 > end > else > set logging $arg0 $arg1 > end > show logging > end > > When type 'logging off' I get error about no such symbol 'off'... Such things are not supported in gdb's own scripting language. However, with a bit of Python-provided magic ($_streq): define logging if $argc == 1 if $_streq("$arg0", "off") set logging off set logging file gdb.log else if $_streq("$arg0", "stop") set logging off else set logging $arg0 end end else set logging $arg0 $arg1 end show logging end Note that gdb's if/else syntax is a pain.