lkml.org 
[lkml]   [2011]   [Jul]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 14/25] dynamic_debug: refactor query_matches_callsite out of ddebug_change
Date
This makes no behavioral change, its just a code-move.  Originally
done cuz it looked momentarily to be useful in the query-vs-query
check needed soon.

If this function is reused, note that it excludes check of the module;
that is done once for the table, this code refactors the test inside
the loop over the module's ddebug callsites.

Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
---
lib/dynamic_debug.c | 52 +++++++++++++++++++++++++++++---------------------
1 files changed, 30 insertions(+), 22 deletions(-)

diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index 7e4f919..c0a5d20 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -143,6 +143,35 @@ static char *show_pending_query(struct pending_query *pq)
return p;
}

+static bool query_matches_callsite(struct _ddebug *dp,
+ const struct ddebug_query *query)
+{
+ /* match against the source filename */
+ if (query->filename != NULL &&
+ strcmp(query->filename, dp->filename) &&
+ strcmp(query->filename, basename(dp->filename)))
+ return false;
+
+ /* match against the function */
+ if (query->function != NULL &&
+ strcmp(query->function, dp->function))
+ return false;
+
+ /* match against the format */
+ if (query->format != NULL &&
+ strstr(dp->format, query->format) == NULL)
+ 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. Tells
@@ -170,28 +199,7 @@ static int ddebug_change(const struct ddebug_query *query,
for (i = 0 ; i < dt->num_ddebugs ; i++) {
struct _ddebug *dp = &dt->ddebugs[i];

- /* match against the source filename */
- if (query->filename != NULL &&
- strcmp(query->filename, dp->filename) &&
- strcmp(query->filename, basename(dp->filename)))
- continue;
-
- /* match against the function */
- if (query->function != NULL &&
- strcmp(query->function, dp->function))
- continue;
-
- /* match against the format */
- if (query->format != NULL &&
- strstr(dp->format, query->format) == NULL)
- 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 (!query_matches_callsite(dp, query))
continue;

nfound++;
--
1.7.4.1


\
 
 \ /
  Last update: 2011-07-25 23:47    [W:1.560 / U:0.200 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site