Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp103189pxf; Tue, 16 Mar 2021 23:58:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzh2Lse+KORYLGbVgXp853nWDzLMaNGdfolihw/Ho77oJLJHx9p941DdWm/YuX5lFq0/GFW X-Received: by 2002:a05:6402:19a:: with SMTP id r26mr39792957edv.44.1615964290007; Tue, 16 Mar 2021 23:58:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615964290; cv=none; d=google.com; s=arc-20160816; b=GKyAgovaVVd3T3yME7ijPSSUZ/PNX4KehmH60ErHdViK/QPsYMQvknHV1GU2xV5oWJ N+1mHs/GLmBeSfuSeAw3ymfVomX2QujbBtkUqc0DfY2B3a4M17dEaFur01h+AHbQyqEK Wf/0rFWwhI3hcI5Ome9Z59wquZ0XKq0mRPF8isAdk907N5Jb+vMdpLScZBwQ7CcWRHyk kpke6RccqOvxYfuH5S4VF5AXUJg8N/lCpHdjeTZqRh3Y+qY8eOx1Dd7NE7pSECr7YI5z s1hAIH+XmsBSD3S+msQL+vUFromhDtqkoMh+xMJmwcVgX4Wpxh1b0vCm+WjfOl/BC2R+ IvKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=QdQI/+lAb+gYcRJWejMVqh44KMAoB3pFOSAUQhYLugQ=; b=i5Yhr6AbCLKB3YofEcMDIY7kk+Qvqh6Znk1EAsCyAi8Prwbb/7MseSYwdqqPKfcvPJ tcCx/iDrDfuSBcegpUP8jADJYHNfKiuDDs2P8ekvG+GsBq3u4Ly+2TpQHURLTAxoSLCA AEM34OH5qnjLKxG3CkDIU8nrMPX5nQN9QBqKQQUx4BymXYGtP7WhymA2tz55tHY6PsXw d8sNi7kCPHf23w3GxICQ38gwwJFhGemcZL40f0A+cev/P2hbhh+NLbzxeWWIxZHZSGdf kWAPaLv0kXTR88CcNQaSWrE4ANGEnW5JguYfyD3KmmrULq2FbMasfy867FuiE0Z3RqtO hd2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=T7zVl2JO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e17si15589565edy.193.2021.03.16.23.57.48; Tue, 16 Mar 2021 23:58:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=T7zVl2JO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231222AbhCQGzC (ORCPT + 99 others); Wed, 17 Mar 2021 02:55:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230319AbhCQGyZ (ORCPT ); Wed, 17 Mar 2021 02:54:25 -0400 Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5051C06174A for ; Tue, 16 Mar 2021 23:54:24 -0700 (PDT) Received: by mail-io1-xd31.google.com with SMTP id z13so39866811iox.8 for ; Tue, 16 Mar 2021 23:54:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QdQI/+lAb+gYcRJWejMVqh44KMAoB3pFOSAUQhYLugQ=; b=T7zVl2JOnYIV/Bsq4L7te15XwB+NKN11FPFFLZyNNFpBAmojejBD26YAsCVpFAzrkY lemBgRx2iNvAypJeC8Lz5A0H9HlHWO29AGD3cBejRMR8lpUuXEtYYeCPo0fX/kQZTgSl JsqKYJwI7Vn7KwG/u6I+RY/UGpyfCESHf3ih5DAmk8TFSupC2+M40iEt5lxkP/XD3V9R HdvKAZpAHdpYLqumQrQiJ8bvDU0bLvKTZOeDJSHTkSb+L0tk4fGCYZnfBkXfqfPLXeAN 7AtCRWtKt1y6oue47+NaU4qnweua7Tr7vbSBZkSZb9isnoPQMAsUThDjZi+V6C1Awt+O REMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QdQI/+lAb+gYcRJWejMVqh44KMAoB3pFOSAUQhYLugQ=; b=dDp4oiG7rwVjhM5aZZIDU4IxmBMoT5V6OdtZCI515dXypl9r3N2aT//LgVbonVkSNZ kOrAbBgwWSXClLsM+KGIuBmnmAEXDiNVga/3RDHXGGgAlNUCnipIFMCUO/BRrRFx2pyW iiyOd/BvXI2yzFY58YSVSL/HvgAyQUmX7+0yz1vR2iT8a0a+DNDA7lnjCR/wSPTRjNtE ycBrSNeXWHs6u18hL6EofkaE6EsvoOt9LSRGEysZ7zYSRNy48kMMCDnqMyTtbV21Turp tCRvN06eoujzN/1www8GV83x5rd49QOJmepVmMud/AjJ5QRMPhymXPXdv+xlwxOT11fd 2Tiw== X-Gm-Message-State: AOAM530L/KDV+XZngBZaV2VXh/hd4gSslM7eM1Vvl6dAf32yMKWrTFxr ZBmQi1bU5FrK62x7EQSiKjZ+BBNn9DYwfA== X-Received: by 2002:a05:6638:3791:: with SMTP id w17mr1705594jal.91.1615964064242; Tue, 16 Mar 2021 23:54:24 -0700 (PDT) Received: from frodo.mearth (c-24-9-77-57.hsd1.co.comcast.net. [24.9.77.57]) by smtp.googlemail.com with ESMTPSA id w13sm10583057ilg.48.2021.03.16.23.54.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 23:54:23 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org Cc: Jim Cromie Subject: [RFC PATCH v4 03/19] dyndbg: refactor part of ddebug_change to ddebug_match_site Date: Wed, 17 Mar 2021 00:53:56 -0600 Message-Id: <20210317065412.2890414-4-jim.cromie@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210317065412.2890414-1-jim.cromie@gmail.com> References: <20210317065412.2890414-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Move all the site-match logic into a separate function, reindent the code, and replace the continues with return falses. No functional changes. Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 75 ++++++++++++++++++++++++++------------------- 1 file changed, 43 insertions(+), 32 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index c3c35dcc6a59..9cff9db15937 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -142,6 +142,48 @@ static void vpr_info_dq(const struct ddebug_query *query, const char *msg) query->first_lineno, query->last_lineno); } +static int ddebug_match_site(const struct ddebug_query *query, + const struct _ddebug *dp) +{ + struct _ddebug_site *dc = dp->site; + + /* match against the source filename */ + if (query->filename && + !match_wildcard(query->filename, dc->filename) && + !match_wildcard(query->filename, + kbasename(dc->filename)) && + !match_wildcard(query->filename, + trim_prefix(dc->filename))) + return false; + + /* match against the function */ + if (query->function && + !match_wildcard(query->function, dc->function)) + return false; + + /* match against the format */ + if (query->format) { + if (*query->format == '^') { + char *p; + /* anchored search. match must be at beginning */ + p = strstr(dp->format, query->format+1); + if (p != dp->format) + return false; + } else if (!strstr(dp->format, query->format)) + return false; + } + + /* match against the line number range */ + if (query->first_lineno && + dp->lineno < query->first_lineno) + return false; + if (query->last_lineno && + dp->lineno > query->last_lineno) + return false; + + return true; +} + /* * Search the tables for _ddebug's which match the given `query' and * apply the `flags' and `mask' to them. Returns number of matching @@ -170,38 +212,7 @@ static int ddebug_change(const struct ddebug_query *query, struct _ddebug *dp = &dt->ddebugs[i]; struct _ddebug_site *dc = dp->site; - /* match against the source filename */ - if (query->filename && - !match_wildcard(query->filename, dc->filename) && - !match_wildcard(query->filename, - kbasename(dc->filename)) && - !match_wildcard(query->filename, - trim_prefix(dc->filename))) - continue; - - /* match against the function */ - if (query->function && - !match_wildcard(query->function, dc->function)) - continue; - - /* match against the format */ - if (query->format) { - if (*query->format == '^') { - char *p; - /* anchored search. match must be at beginning */ - p = strstr(dp->format, query->format+1); - if (p != dp->format) - continue; - } else if (!strstr(dp->format, query->format)) - continue; - } - - /* match against the line number range */ - if (query->first_lineno && - dp->lineno < query->first_lineno) - continue; - if (query->last_lineno && - dp->lineno > query->last_lineno) + if (!ddebug_match_site(query, dp)) continue; nfound++; -- 2.29.2