lkml.org 
[lkml]   [2011]   [Jul]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 13/21] dynamic_debug: require 'a' flag to explicitly mark pending queries
Date
Require that user mark pending queries explicitly, otherwise warn
that they do not apply. Note that pending rules are still applied
by default, and are only added to pending-list if they do not apply,
and bear the flag.

Also test that query hasnt already been added to pending-list,
if it has (according to queries_match), just update the found query.

Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
---
lib/dynamic_debug.c | 52 +++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 46 insertions(+), 6 deletions(-)
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index bee1376..0faac83 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -91,6 +91,7 @@ static struct { unsigned flag:8; char opt_char; } opt_array[] = {
{ _DPRINTK_FLAGS_INCL_FUNCNAME, 'f' },
{ _DPRINTK_FLAGS_INCL_LINENO, 'l' },
{ _DPRINTK_FLAGS_INCL_TID, 't' },
+ { _DPRINTK_FLAGS_APPEND, 'a' },
};

/* format a string into buf[] which describes the _ddebug's flags */
@@ -454,12 +455,47 @@ static int ddebug_parse_flags(const char *str, unsigned int *flagsp,
return 0;
}

-/* copy query off stack, save flags & mask, and store in pending-list */
+static int queries_match(struct ddebug_query *q1, struct ddebug_query *q2)
+{
+ if (!q1->module ^ !q2->module ||
+ !q1->filename ^ !q2->filename ||
+ !q1->function ^ !q2->function ||
+ !q1->format ^ !q2->format)
+ return 0; /* a match-spec set/unset state differs */
+
+ if (q1->last_lineno != q2->last_lineno ||
+ q1->first_lineno != q2->first_lineno)
+ return 0;
+
+ if ((q1->module && strcmp(q1->module, q2->module)) ||
+ (q1->filename && strcmp(q1->filename, q2->filename)) ||
+ (q1->function && strcmp(q1->function, q2->function)) ||
+ (q1->format && strcmp(q1->format, q2->format)))
+ return 0;
+ return 1;
+}
+
+/* copy query off stack, save flags & mask, and store in pending-list,
+ after checking that query isnt already there
+ */
static int ddebug_save_pending(struct ddebug_query *query,
unsigned int flags, unsigned int mask)
{
- struct pending_query *pq;
+ struct pending_query *pq, *pqnext;

+ list_for_each_entry_safe(pq, pqnext, &pending_queries, link) {
+ if (queries_match(query, &pq->query)) {
+ /* query already in list, update flags */
+ if (pq->flags != flags)
+ pq->flags = flags;
+ if (pq->mask != mask)
+ pq->mask = mask;
+ if (verbose)
+ pr_info("already pending, updated it: %s\n",
+ show_pending_query(pq));
+ return 0;
+ }
+ }
if (verbose)
pr_info("add to pending: %s\n", show_ddebug_query(query));

@@ -511,9 +547,13 @@ static int ddebug_exec_query(char *query_string)
nfound = ddebug_change(&query, flags, mask);

pr_info("nfound %d on %s\n", nfound, show_ddebug_query(&query));
- if (!nfound)
- return ddebug_save_pending(&query, flags, mask);
-
+ if (!nfound) {
+ if (flags & _DPRINTK_FLAGS_APPEND)
+ return ddebug_save_pending(&query, flags, mask);
+ else
+ pr_warn("no match on: %s\n",
+ show_ddebug_query(&query));
+ }
return 0;
}

--
1.7.4.1


\
 
 \ /
  Last update: 2011-07-11 09:51    [from the cache]
©2003-2011 Jasper Spaans