Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp433121ybt; Sat, 13 Jun 2020 09:01:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz/SObIcac8N1ytw6/JZ1n3ANEnPpLBsbRr2TiD5nWO2ubIg50+QWotZBXrsxzzI8imXo6H X-Received: by 2002:aa7:c2c4:: with SMTP id m4mr16253354edp.299.1592064090781; Sat, 13 Jun 2020 09:01:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592064090; cv=none; d=google.com; s=arc-20160816; b=CAhvEXLtIyNqY4W7Adf4PfiE2rpkyQQHFjPp6wu9busESCohpH3Bv93+/VOh413mUT hJsxn3C5T+d30gHGIwr5dDxFwtUp2LwBejbLmGCZMz4mRLsdSKVh6VmQoIC8VR594ZCV HVkIjdWTqokMTwd+Kel72cMsMkwTwPxWEA2gJ3uM/tDpljndGNDmHpKstSIcerU31PSP UJTTuYzftY1nZ3tbzJFg+yJivYIJY/P6D3ERvUItasPlFsXXYgmqYr12i1xNIjeZjDyE hIH3njqOmURhMjEEcpFL/Kli5F3fMoSyri7dHB7PcG0TnC5Hs3g6V9GhNiSd9+gvqJYk 5bZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=j7rFce4RUuKR6hKelORJV5qMjdT0yjRFDtL43viE0JM=; b=df74cmikUztF9j9102tEkil93Nt1Az4sGWR6lLxfRASsFeJ9fdlJmLtBLkAaN1zRqW t+dumIh/Y10JGmgKh4Wk1OwwnFHMJSZYZ7z8x0YSOyf6Y8/GSDIsf2Xy6m6wrdd43h2p SEhLTQpWThZwOfXL9qhsKyBZggqEzx13cdIU0tapJtKcm0wCbkDLdhsyLcRQWhsYs9rY /1CBzMqXWLQaf+0TRPb/oIkyMUo4Tg2QbzWUMNSpyT3KJWlv/9XKms2ZnW0GyNRWTxns OOSbWW2HBUhjpS+106pE9tFJv9TYEv3i+/Ce1spvpCODJM29Erj9yza/zF2F+sZB6VLj FBLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=gqWyAZFf; 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 c19si6381870ejp.127.2020.06.13.09.01.08; Sat, 13 Jun 2020 09:01:30 -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=gqWyAZFf; 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 S1726731AbgFMP66 (ORCPT + 99 others); Sat, 13 Jun 2020 11:58:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726645AbgFMP6d (ORCPT ); Sat, 13 Jun 2020 11:58:33 -0400 Received: from mail-ot1-x343.google.com (mail-ot1-x343.google.com [IPv6:2607:f8b0:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A92EEC03E96F for ; Sat, 13 Jun 2020 08:58:32 -0700 (PDT) Received: by mail-ot1-x343.google.com with SMTP id 69so9773423otv.2 for ; Sat, 13 Jun 2020 08:58:32 -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=j7rFce4RUuKR6hKelORJV5qMjdT0yjRFDtL43viE0JM=; b=gqWyAZFfsrSMItTG3/932jSIwKALSa4vRA/xEQ+ZEhBcCY2hy1MYKZRZopnZ+Dbh+O tFpcSeUsaS68wXQudYp+zd1QtrH3uiBCjzfSair6LM7VzadyHZqX4yaeAXPfG+uz3SWA p6lxkx7UAWvM31Z6JAR/1nXzg7PAsIrpNW8jBvNhyb6t2Wayun3sx74JDhFXZsbppZqb zBydI7yxQlb++upwfwSePgGeHPZf93hJkJVSJusxIsqC6pBciWrxEVAK2HwKvawdOF3a aytXJ599BptETLwyFXRRz3d8mlhypFPKG5d2886gAPpIyeB51gSbvaNn39khfNv+t6GZ WntQ== 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=j7rFce4RUuKR6hKelORJV5qMjdT0yjRFDtL43viE0JM=; b=bWWnNe9tzLidYz1S2NkSSnH3iq5OzubGzCBM279aVZmBfQCROAQVeL+i01Chx/y8NP FzKcZuaid1c5QWatny1rBGPIYkGN0663Im48QyX6ZYI5mOjwp/EulOhfujR28Ox0GSS1 D3EF2885OKL0Bfc+CfyWJXhDmKki93kMgD1dBcbWCDfNb3ikUWQOYsw6+N9YWof7ZRkH kNzFbb3SEGe6Q4FMSwFCOYcYTKqHvW5gXDtHBDiBK2fydp7g2Qjzpfs41YABvZMedInY JNT4G3ZwnFPcPX8zp3lMugBWgGch1C1WaiXcAl8DUP7gqzdgJwQ1WVwXFM/siYc9XfU/ 94cg== X-Gm-Message-State: AOAM532KA3COOOQPwwNrjkE+qlhwAArqg7DtYWj6r3y5qXma11BQ2ex+ XpX43+hgfAQenLkL6M85i4M= X-Received: by 2002:a05:6830:1383:: with SMTP id d3mr14042153otq.353.1592063912090; Sat, 13 Jun 2020 08:58:32 -0700 (PDT) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:6ba0::aaac]) by smtp.googlemail.com with ESMTPSA id 53sm2105565otv.22.2020.06.13.08.58.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Jun 2020 08:58:31 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, linux-kernel@vger.kernel.org, akpm@linuxfoundation.org, gregkh@linuxfoundation.org Cc: linux@rasmusvillemoes.dk, Jim Cromie Subject: [PATCH v2 19/24] dyndbg: accept query terms like module:foo and file=bar Date: Sat, 13 Jun 2020 09:57:33 -0600 Message-Id: <20200613155738.2249399-20-jim.cromie@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200613155738.2249399-1-jim.cromie@gmail.com> References: <20200613155738.2249399-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Current code expects "keyword" "arg" as 2 space separated words. Change to also accept "keyword:arg" and "keyword=arg" forms as well, and drop !(nwords%2) requirement. Then in rest of function, use new keyword,arg variables instead of word[i],word[i+1] --- lib/dynamic_debug.c | 49 +++++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index d67fbbc5317f..cb5c7480e026 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -375,22 +375,33 @@ static int ddebug_parse_query(char *words[], int nwords, unsigned int i; int rc = 0; char *fline; - - /* check we have an even number of words */ - if (nwords % 2 != 0) { - pr_err("expecting pairs of match-spec \n"); - return -EINVAL; - } + char *keyword, *arg; if (modname) /* support $modname.dyndbg= */ query->module = modname; - for (i = 0; i < nwords; i += 2) { - if (!strcmp(words[i], "func")) { - rc = check_set(&query->function, words[i+1], "func"); - } else if (!strcmp(words[i], "file")) { - if (check_set(&query->filename, words[i+1], "file")) + for (i = 0; i < nwords; i++) { + /* accept keyword[:=]arg */ + vpr_info("%d w:%s\n", i, words[i]); + + keyword = words[i]; + if ((arg = strpbrk(keyword, ":="))) { + *arg++ = '\0'; + } else { + i++; /* next word is arg */ + if (!(i < nwords)) { + pr_err("missing arg to keyword:%s\n", keyword); + return -EINVAL; + } + arg = words[i]; + } + vpr_info("%d key:%s arg:%s\n", i, keyword, arg); + + if (!strcmp(keyword, "func")) { + rc = check_set(&query->function, arg, "func"); + } else if (!strcmp(keyword, "file")) { + if (check_set(&query->filename, arg, "file")) return -EINVAL; /* tail :$info is function or line-range */ @@ -406,18 +417,18 @@ static int ddebug_parse_query(char *words[], int nwords, if (parse_linerange(query, fline)) return -EINVAL; } - } else if (!strcmp(words[i], "module")) { - rc = check_set(&query->module, words[i+1], "module"); - } else if (!strcmp(words[i], "format")) { - string_unescape_inplace(words[i+1], UNESCAPE_SPACE | + } else if (!strcmp(keyword, "module")) { + rc = check_set(&query->module, arg, "module"); + } else if (!strcmp(keyword, "format")) { + string_unescape_inplace(arg, UNESCAPE_SPACE | UNESCAPE_OCTAL | UNESCAPE_SPECIAL); - rc = check_set(&query->format, words[i+1], "format"); - } else if (!strcmp(words[i], "line")) { - if (parse_linerange(query, words[i+1])) + rc = check_set(&query->format, arg, "format"); + } else if (!strcmp(keyword, "line")) { + if (parse_linerange(query, arg)) return -EINVAL; } else { - pr_err("unknown keyword \"%s\"\n", words[i]); + pr_err("unknown keyword \"%s\"\n", keyword); return -EINVAL; } if (rc) -- 2.26.2