From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 81680 invoked by alias); 27 Mar 2015 16:26:03 -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 81652 invoked by uid 89); 27 Mar 2015 16:26:02 -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-ob0-f172.google.com Received: from mail-ob0-f172.google.com (HELO mail-ob0-f172.google.com) (209.85.214.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 27 Mar 2015 16:26:01 +0000 Received: by obvd1 with SMTP id d1so11177512obv.0 for ; Fri, 27 Mar 2015 09:25:59 -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=4wVZTCVsFptQJtLaubbRusn2BEHNs8/Gl5TwmFQvWdE=; b=I/T/u3BqrPtzTPz4mAN4kim+RDuNz9KehKC1htGyp4i3UhmhRzx1IxkgjNYTRa7Yx5 csFCrMi+9cyuBRrAdRu9z2FqWkUtC58ZY/9Cc4CfPVYVK0It3sKRy8xBxYfBSqLMss56 fetmvQT9XRiyKZA4SZ1bWcyeHL1ADnRCukUoc9tUyJNX7l1QUoUjklGENdOFohWROyOn 60kqCxvDiP5jhP57VNmxwAahJSRISxcaZ7E8pKbLVCrC7dk43AC8odR6g4ZPEBcUkUhH ncLGt5OisQR283NSy56/59HsPXOPlVCj5QmDkZhMqLUVlYOb36FClJD+mgl555qxhpDS H9tA== X-Gm-Message-State: ALoCoQmFKoThcKC+2+ELH250zXM5ia0q9Hrd/aOMeslPfAZk66lZ1A7pwofahFg3J+XGPPgkY0ud MIME-Version: 1.0 X-Received: by 10.182.72.225 with SMTP id g1mr17105365obv.80.1427473559520; Fri, 27 Mar 2015 09:25:59 -0700 (PDT) Received: by 10.182.142.226 with HTTP; Fri, 27 Mar 2015 09:25:59 -0700 (PDT) In-Reply-To: References: Date: Fri, 27 Mar 2015 16:26: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/msg00106.txt.bz2 On Thu, Mar 26, 2015 at 11:35 PM, Aleksey Midenkov wrote: > On Thu, Mar 26, 2015 at 9:28 PM, Doug Evans wrote: >> 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. > > Sure thing, gdb's syntax could be a bit richer... Also, if I get this > error message does that mean that my gdb is not Python-powered? > > (gdb) p $_streq("off", "off") > Invalid data type for function to be called. I'd use "py print 42" or some such as a more direct test of whether python is present. btw, which version of gdb are you using?