From: Jim Cromie <jim.cromie@gmail.com>
To: jbaron@akamai.com, gregkh@linuxfoundation.org,
linux-kernel@vger.kernel.org
Cc: Jim Cromie <jim.cromie@gmail.com>
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 [thread overview]
Message-ID: <20210317065412.2890414-4-jim.cromie@gmail.com> (raw)
In-Reply-To: <20210317065412.2890414-1-jim.cromie@gmail.com>
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 <jim.cromie@gmail.com>
---
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
next prev parent reply other threads:[~2021-03-17 6:55 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-17 6:53 [RFC PATCH v4 00/19] dynamic debug diet plan Jim Cromie
2021-03-17 6:53 ` [RFC PATCH v4 01/19] dyndbg: split struct _ddebug, move display fields to new _ddebug_site Jim Cromie
2021-03-17 6:53 ` [RFC PATCH v4 02/19] dyndbg: __init iterate over __dyndbg & __dyndbg_site in parallel Jim Cromie
2021-03-17 6:53 ` Jim Cromie [this message]
2021-03-17 6:53 ` [RFC PATCH v4 04/19] dyndbg: accept null site in ddebug_match_site Jim Cromie
2021-03-17 6:53 ` [RFC PATCH v4 05/19] dyndbg: hoist ->site out of ddebug_match_site Jim Cromie
2021-03-17 6:53 ` [RFC PATCH v4 06/19] dyndbg: accept null site in ddebug_change Jim Cromie
2021-03-17 6:54 ` [RFC PATCH v4 07/19] dyndbg: accept null site in dynamic_emit_prefix Jim Cromie
2021-03-17 6:54 ` [RFC PATCH v4 08/19] dyndbg: accept null site in ddebug_proc_show Jim Cromie
2021-03-17 6:54 ` [RFC PATCH v4 09/19] dyndbg: optimize ddebug_emit_prefix Jim Cromie
2021-03-17 6:54 ` [RFC PATCH v4 10/19] dyndbg: avoid calling dyndbg_emit_prefix when it has no work Jim Cromie
2021-03-17 6:54 ` [RFC PATCH v4 11/19] dyndbg: refactor ddebug_alter_site out of ddebug_change Jim Cromie
2021-03-17 6:54 ` [RFC PATCH v4 12/19] dyndbg: allow deleting site info via control interface Jim Cromie
2021-03-17 6:54 ` [RFC PATCH v4 13/19] dyndbg+module: expose ddebug_sites to modules Jim Cromie
2021-03-17 6:54 ` [RFC PATCH v4 14/19] dyndbg: add ddebug_site(_get|_put) abstraction Jim Cromie
2021-03-17 6:54 ` [RFC PATCH v4 15/19] dyndbg: add _index to struct _ddebug Jim Cromie
2021-03-17 6:54 ` [RFC PATCH v4 16/19] dyndbg: prevent build bugs via -DNO_DYNAMIC_DEBUG_TABLE Jim Cromie
2021-03-17 6:54 ` [RFC PATCH v4 17/19] dyndbg: RFC - DECLARE/DEFINE_DYNAMIC_DEBUG_TABLE Jim Cromie
2021-03-17 6:54 ` [RFC PATCH v4 18/19] dyndbg: shuffle ddebug_table fields Jim Cromie
2021-03-17 6:54 ` [RFC PATCH v4 19/19] dyndbg: RFC add linker rules to module.lds.h Jim Cromie
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210317065412.2890414-4-jim.cromie@gmail.com \
--to=jim.cromie@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=jbaron@akamai.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®