Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1420965pxj; Sat, 29 May 2021 13:03:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJySP0CTVJqoaDfsUlscigqrDP6hRMs5pXH/uUjjsbA91DSXzcJsfcKFvZIZkZkYTOgm/nIP X-Received: by 2002:a92:b111:: with SMTP id t17mr11932891ilh.208.1622318604843; Sat, 29 May 2021 13:03:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622318604; cv=none; d=google.com; s=arc-20160816; b=g4pXCtS9+6mhiEDTo9sHU9TkN4MSmdTThmqVnhWH61ATDdAEIn6CQcjzd+IBGp3Fxg 3TN1b6MkVpxUzq/U7XVXwBh53Aa6bhcbbdR3k21t+muZWm016yUGkzPHG9H+HkUEdsxG l+rglRhusd9X41+2E+tiGxM21bNJiYy+9I3SUClezhrYHJN+SMHE+/BolKv5VutoFLJW 0j6oYNub0NX9d/13SF35UNb+HTk6UzVU1VJJ/vCLOUHOwHknrAyNctjCuzZ2lFw7f5fF a05L8+HdwYG+U0VikaM50+bFijarSbxG3fv42ouuQF4p07g726T2UPjxqUW6YaEj+OqX 6qNQ== 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=LQuVxRAcjK8t/Sazz0aajGG1OlfHP3rRgE9A+ESecds=; b=ugvxHv3o7L3R+K8fo3wK8kniS8X5G7wLYJhaYg7kZ9fNocM68Kn57OO8mqMhkkN4EB HlcWf300DZ847egags7p0vzMy4DdiEWP/HuShhLGhVUnxkiFywTI7lf7fHvv+oSU3G/9 dTVdxlU5jdynsnj+eRRqy0RGcvjsIPK+KhoK8qFl/65/56MhuqIQ8dPHC+yXsFH0p++k zeu+0o8EuSnb5jgAsGb+LIpPxHyAViJXakoFgUFEEmTk6PvVZfvuFSqNvBjk5a6diKpI 3BVyYkbtac96sfnDMfb878l2LXwHBnvzqyuIKrPvQg2+hnuzhda2pZ/IALw4JuPwbWCN Av6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=NY61Xmp3; 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 m12si10571802jav.104.2021.05.29.13.03.12; Sat, 29 May 2021 13:03:24 -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=NY61Xmp3; 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 S229911AbhE2UEG (ORCPT + 99 others); Sat, 29 May 2021 16:04:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229838AbhE2UD6 (ORCPT ); Sat, 29 May 2021 16:03:58 -0400 Received: from mail-ot1-x332.google.com (mail-ot1-x332.google.com [IPv6:2607:f8b0:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D7CDC06174A for ; Sat, 29 May 2021 13:02:21 -0700 (PDT) Received: by mail-ot1-x332.google.com with SMTP id u25-20020a0568302319b02902ac3d54c25eso7006856ote.1 for ; Sat, 29 May 2021 13:02:21 -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=LQuVxRAcjK8t/Sazz0aajGG1OlfHP3rRgE9A+ESecds=; b=NY61Xmp3mEWcjAoc4o4oX2i5B2pZjMfZkyVBRN9PaA+RryaZbwjo6NHTk7dpsyoRHp b33vfvng039quAsJwtyw815nVWGGmMHakMU1Tla6ylL0YA0vvCGwKbDPLUlCJRKdjVhm KYzpPVlG6kTZceNI00KYs5NFtMQ4i1/BgJ+YvE0SGsI7r8j1NrGLXevNlZhBNVd40WQl PThG4yNsV9VmawcqEJA+18q937FJkM/69r938nXlhZKX7fugHHxLigX+ewVURLXGgIG+ 8ApTnLzpwMUdGN0/JcEAQ+uRi83b1Eejv94gWDYTeTg1PzKiv1ElkgfYHfzwIOV5koYN Jd4g== 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=LQuVxRAcjK8t/Sazz0aajGG1OlfHP3rRgE9A+ESecds=; b=gBMbbld2UysWGP/EdI8+y2K/lI9L4Xg/54h69Ikw32uwXptyRjaYKJVHXh3cCfY09R rKcrXoP5Ef+EM7sn8Smr7kpmw15IODrPtgnwcfSG+2ovGjc8v7All87N0re6QSiKKkcX ZjC0ixffOt7ZY1GmEnRZ3XoMwhQGQ01f39WgJKs+pCUm9UxR4NR4phG8ng6ZvbrRyUNq VFUSBjOXdFrVKG3t/g3ZlVB1gq3me+reGrb5cciEj/vcmGzk9V3yawhdUE8V5jgHTkX1 y3zZzCLGoDIC/YvAsL3L62GMF3lYkro62LgeIjXr55brAab5IAfXHiKqJW5c68EScC31 JZOg== X-Gm-Message-State: AOAM5330CcZGZNjheSbJgpkaPVfn7TXbHrGGxWH08tNE85zr2WJakrAc NFMjYBXTx4K28QTh+cabO7s= X-Received: by 2002:a9d:6655:: with SMTP id q21mr11771536otm.185.1622318540699; Sat, 29 May 2021 13:02:20 -0700 (PDT) Received: from frodo.. (c-24-9-77-57.hsd1.co.comcast.net. [24.9.77.57]) by smtp.googlemail.com with ESMTPSA id t39sm1868064ooi.42.2021.05.29.13.02.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 May 2021 13:02:20 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org Cc: Jim Cromie Subject: [RFC PATCH v6 07/34] dyndbg: refactor part of ddebug_change to ddebug_match_site Date: Sat, 29 May 2021 14:00:02 -0600 Message-Id: <20210529200029.205306-8-jim.cromie@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210529200029.205306-1-jim.cromie@gmail.com> References: <20210529200029.205306-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 78d4a9020600..839dd128ba20 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -143,6 +143,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 @@ -171,38 +213,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.31.1