From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8244 invoked by alias); 3 Apr 2015 09:36:57 -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 8226 invoked by uid 89); 3 Apr 2015 09:36:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-ob0-f173.google.com Received: from mail-ob0-f173.google.com (HELO mail-ob0-f173.google.com) (209.85.214.173) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 03 Apr 2015 09:36:55 +0000 Received: by obbec2 with SMTP id ec2so164188807obb.3 for ; Fri, 03 Apr 2015 02:36:54 -0700 (PDT) X-Received: by 10.182.92.165 with SMTP id cn5mr1990554obb.10.1428053814126; Fri, 03 Apr 2015 02:36:54 -0700 (PDT) MIME-Version: 1.0 Received: by 10.182.134.202 with HTTP; Fri, 3 Apr 2015 02:36:32 -0700 (PDT) In-Reply-To: References: From: Aleksey Midenkov Date: Fri, 03 Apr 2015 09:36:00 -0000 Message-ID: Subject: Re: How to compare $arg0 with string literal? To: Doug Evans Cc: "gdb@sourceware.org" Content-Type: text/plain; charset=UTF-8 X-SW-Source: 2015-04/txt/msg00007.txt.bz2 On Fri, Mar 27, 2015 at 7:25 PM, Doug Evans wrote: > 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? That host where this error occurs is always outdated. 7.2-60.el6_4.1 On my local machine is latest version and $_streq() works. On 7.2 'py print' : (gdb) py print 42 42 (gdb) py prind 42 File "", line 1 prind 42 ^ SyntaxError: unexpected EOF while parsing Error while executing Python code.