From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by sourceware.org (Postfix) with ESMTPS id 48F8D3858020 for ; Thu, 29 Oct 2020 17:30:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 48F8D3858020 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=alves.ped@gmail.com Received: by mail-wm1-f66.google.com with SMTP id w23so587855wmi.4 for ; Thu, 29 Oct 2020 10:30:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=1bEoCqazUTxQOTcn2BJSJSiL+ffHVxhtvgjQtSYORjE=; b=fL++aEyBBXdcjvY0TnkQiAM+29BilI98Bn49r3dEIp1Yd2Wt/bHGxlMo9zn9qEpjHs W2LUHaNJKOfXnTDjxa9UO47lQnVAno3lNR1Drpkcputy075Q2sWJ7sjFcUjZw8WgwAZl tgoQ1nNw3cS4HF3soc01zEvds83MravJrvabBpdfhqlGMW/SEoU8I7Jdz/u4EUunkw3Q dhMlpFEzNg5fhtgwbefvKs4xzdaiNfgwQYm3b6xnz2NDaSgJf5ghH/gfXflEFCG5QaV5 7oXOUpuZCW/ySgVAcXrphjG/D97z/XWhg1ZbDFoH2aLBmcigNTFeiaenL8BwucXQSDdp hONw== X-Gm-Message-State: AOAM532qFYQvHJJJA0qqmop25qgI/U4+KN/4NuBW06gBL7NqdfMvm7ju Q3EmHKAlYHsZ6tnyxpzimBs= X-Google-Smtp-Source: ABdhPJwm3OMSPN74BmLSPyebecwuMIfW+r4vKaTsUJA+2hJD+hdDVbj8HOQkEnrRRsE7DOyhq66OwQ== X-Received: by 2002:a1c:2d8f:: with SMTP id t137mr984733wmt.26.1603992626206; Thu, 29 Oct 2020 10:30:26 -0700 (PDT) Received: from ?IPv6:2001:8a0:f925:3b00:520e:b099:84db:573f? ([2001:8a0:f925:3b00:520e:b099:84db:573f]) by smtp.gmail.com with ESMTPSA id l16sm6295600wrx.5.2020.10.29.10.30.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 29 Oct 2020 10:30:24 -0700 (PDT) Subject: Re: [PATCH v4 2/2] gdb/breakpoint: add flags to 'condition' and 'break' commands to force condition To: Tankut Baris Aktemur , gdb-patches@sourceware.org References: Cc: simark@simark.ca From: Pedro Alves Message-ID: Date: Thu, 29 Oct 2020 17:30:23 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Oct 2020 17:30:28 -0000 On 10/13/20 1:25 PM, Tankut Baris Aktemur via Gdb-patches wrote: > @@ -9192,10 +9207,25 @@ find_condition_and_thread (const char *tok, CORE_ADDR pc, > if (toklen >= 1 && strncmp (tok, "if", toklen) == 0) > { > tok = cond_start = end_tok + 1; > - parse_exp_1 (&tok, pc, block_for_pc (pc), 0); > + try > + { > + parse_exp_1 (&tok, pc, block_for_pc (pc), 0); > + } > + catch (const gdb_exception_error &) > + { > + if (!force) > + throw; > + else > + tok = tok + strlen (tok); > + } > cond_end = tok; > *cond_string = savestring (cond_start, cond_end - cond_start); > } > + else if (toklen >= 1 && strncmp (tok, "-force-condition", toklen) == 0) > + { > + tok = cond_start = end_tok + 1; > + force = true; > + } > else if (toklen >= 1 && strncmp (tok, "thread", toklen) == 0) > { > const char *tmptok; Is it important to handle "-force-condition" in this position, as opposed to making it another option handled by string_to_explicit_location ? As is, this doesn't work, for example: (gdb) b -function main -force nor does: (gdb) b -force-condition main if 0 invalid explicit location argument, "-force-condition" IMO, ideally all '-' options would be handled in the same place. At some point, I think it would be nice to convert the "break" command to use gdb::option, but it isn't trivial.