[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240210235009.2405808-26-ukaszb@chromium.org>
Date: Sun, 11 Feb 2024 00:49:55 +0100
From: Łukasz Bartosik <ukaszb@...omium.org>
To: Jason Baron <jbaron@...mai.com>,
Jim Cromie <jim.cromie@...il.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Kees Cook <keescook@...omium.org>,
Douglas Anderson <dianders@...omium.org>
Cc: Guenter Roeck <groeck@...gle.com>,
Yaniv Tzoreff <yanivt@...gle.com>,
Benson Leung <bleung@...gle.com>,
Steven Rostedt <rostedt@...dmis.org>,
Vincent Whitchurch <vincent.whitchurch@...s.com>,
Pekka Paalanen <ppaalanen@...il.com>,
Sean Paul <seanpaul@...omium.org>,
Daniel Vetter <daniel@...ll.ch>,
Simon Ser <contact@...rsion.fr>,
John Ogness <john.ogness@...utronix.de>,
Petr Mladek <pmladek@...e.com>,
Sergey Senozhatsky <sergey.senozhatsky@...il.com>,
linux-kernel@...r.kernel.org,
upstream@...ihalf.com
Subject: [PATCH v4 25/39] dyndbg: don't process queries when trace cmd fails
When trace open or close command fails then stop processing next
queries in multiquery string. The rationale behing this behavior
is to stop processing queries which might be dependent on success
of open/close trace commands.
Signed-off-by: Łukasz Bartosik <ukaszb@...omium.org>
---
lib/dynamic_debug.c | 25 ++++++++++++++++++-------
1 file changed, 18 insertions(+), 7 deletions(-)
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index 3d0c6b5faa31..d8cd40faeb4d 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -939,7 +939,8 @@ static int ddebug_parse_flags(const char *str, struct flag_settings *modifiers)
return 0;
}
-static int ddebug_exec_query(char *query_string, const char *modname)
+static int ddebug_exec_query(char *query_string, const char *modname,
+ bool *is_trace_cmd)
{
struct flag_settings modifiers = { .trace_dst = DST_NOT_SET };
struct ddebug_query query = {};
@@ -954,7 +955,8 @@ static int ddebug_exec_query(char *query_string, const char *modname)
}
/* check for open, close commands */
- if (is_dd_trace_cmd(words[0]))
+ *is_trace_cmd = is_dd_trace_cmd(words[0]);
+ if (*is_trace_cmd)
return ddebug_parse_cmd(words, nwords-1);
if (ddebug_parse_query(words, nwords-1, &query, modname)) {
@@ -991,16 +993,19 @@ static int ddebug_exec_query(char *query_string, const char *modname)
return -EINVAL;
}
-/* handle multiple queries in query string, continue on error, return
- last error or number of matching callsites. Module name is either
- in param (for boot arg) or perhaps in query string.
-*/
+/* handle multiple queries in query string, continue on error with
+ * exception of open and close commands, return last error or number
+ * of matching callsites. Module name is either in param (for boot arg)
+ * or perhaps in query string.
+ */
static int ddebug_exec_queries(char *query, const char *modname)
{
char *split;
int i, errs = 0, exitcode = 0, rc, nfound = 0;
for (i = 0; query; query = split) {
+ bool is_trace_cmd = false;
+
split = strpbrk(query, "%;\n");
if (split)
*split++ = '\0';
@@ -1011,10 +1016,16 @@ static int ddebug_exec_queries(char *query, const char *modname)
vpr_info("query %d: \"%s\" mod:%s\n", i, query, modname ?: "*");
- rc = ddebug_exec_query(query, modname);
+ rc = ddebug_exec_query(query, modname, &is_trace_cmd);
if (rc < 0) {
errs++;
exitcode = rc;
+ /*
+ * if open or close command failed then
+ * do not continue with next queries
+ */
+ if (is_trace_cmd)
+ break;
} else {
nfound += rc;
}
--
2.43.0.687.g38aa6559b0-goog
Powered by blists - more mailing lists