From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 113494 invoked by alias); 27 Mar 2015 06:35:50 -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 113481 invoked by uid 89); 27 Mar 2015 06:35: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,FREEMAIL_FROM,KAM_FROM_URIBL_PCCC,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=no version=3.3.2 X-HELO: mail-oi0-f45.google.com Received: from mail-oi0-f45.google.com (HELO mail-oi0-f45.google.com) (209.85.218.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 27 Mar 2015 06:35:48 +0000 Received: by oiag65 with SMTP id g65so68585776oia.2 for ; Thu, 26 Mar 2015 23:35:46 -0700 (PDT) X-Received: by 10.182.75.194 with SMTP id e2mr14759057obw.17.1427438146738; Thu, 26 Mar 2015 23:35:46 -0700 (PDT) MIME-Version: 1.0 Received: by 10.182.135.193 with HTTP; Thu, 26 Mar 2015 23:35:26 -0700 (PDT) In-Reply-To: References: From: Aleksey Midenkov Date: Fri, 27 Mar 2015 06:35: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-03/txt/msg00104.txt.bz2 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.