Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1326278ybh; Sun, 19 Jul 2020 16:13:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+TA80Am2lVxN6t4UE14y8kjSG/0Hxf2YoUxFFopSnj1vkrOeXhX+WJJJjmFCXDCo2Uxsu X-Received: by 2002:aa7:db53:: with SMTP id n19mr19378359edt.338.1595200423688; Sun, 19 Jul 2020 16:13:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595200423; cv=none; d=google.com; s=arc-20160816; b=Y7hKjNQgTSLUWyaGHiAU0thGJhj/RBoXpd1owiuSU22+YNkuHj6CQDgbmpLakcCn03 tNdkrFUPew75iBOBL3f3RBzhiS/A7JG963piIQ93G6VigMt+ru1qwBCaW8nT5hkUdccb EDISpeOE1oJH1L5W+k93sKOMaRnBUWwapLLdZJ1wX+ritv2LF3mQEztca2txq+fEC42B 0Klt+zGyZWXOpwVj7dfN3md5sFbplW3E0GOWN/sqNaKxKenu37KQOvmzzP0gIJB6wUH3 aDej8gORpOC9Dr6d+oHcdo/hCUCQr3SK5uzw1mnqfiTVWlvru3GVGoId6CQr2Lv5fj0Y tW3w== 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=NRXB+JS42nffvxMyjWW2qiYBpadQLCn8VyzG3U8X8TA=; b=NW7pEBJHf0CfO8QEslooN/rriyXe5vn6INbVSN249RsAHq8gVX3ZAMMJWSf4m7hAuC hnWckTKtgmCfAqmRf0szWA+d96w5Of7zMV0KA8G7G8L0toEKM2J09mdleC/0614Vtf/6 TiGzjJrWdMB8Ireij/mWgOeR/ZuAIyihKqX2OQFOAAG0lDtrGfrqhMA3jCIkfUir2wC2 g03KrbDhcnEI/fgbHHYxANBOFbHl3AI4Qw4Mlg+1+8lhOalNKa1VVm0/N0Rn+//qplHS YJqqmQ/goG/aLDz36qopbrQfPVCf1ouO/pj7YqZDTA6GOconpTKsfEQqt5ZEAuB9uMyq 4J+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=pcXDVwy9; 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 rp17si9195616ejb.67.2020.07.19.16.13.20; Sun, 19 Jul 2020 16:13:43 -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=pcXDVwy9; 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 S1727820AbgGSXMF (ORCPT + 99 others); Sun, 19 Jul 2020 19:12:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727071AbgGSXLq (ORCPT ); Sun, 19 Jul 2020 19:11:46 -0400 Received: from mail-oi1-x243.google.com (mail-oi1-x243.google.com [IPv6:2607:f8b0:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2807C0619D2; Sun, 19 Jul 2020 16:11:45 -0700 (PDT) Received: by mail-oi1-x243.google.com with SMTP id r8so12999144oij.5; Sun, 19 Jul 2020 16:11:45 -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=NRXB+JS42nffvxMyjWW2qiYBpadQLCn8VyzG3U8X8TA=; b=pcXDVwy9RftphiIDcWquMAKxmUKx4I1iGGUBYh+MFy5v6w9JzewC45GD+nE2vtbKAh +slRGlBtr+UFAd0ug9zzZW3YcwLbSS8+9SYTDI6NFJwjv1WNRYF3fVQW6uYFc8BuXWMV SmnKM2BVt7BrryTS2PpmjGJB97q54XCOxA+O0iftMoy0VR99myhJaQIZfN/206+zFhsz VfAlpTi2WDOSk4l+1GUcr7crPvAYh542UpJKbRinouAk5D/Ww7FHX0lSo5lDbbXPAX65 l+RXG/MfTNmNLJ7oabIwkHTncd8HSu02zhJDtyMEUlcIpKUv4YzzWnNw17DJgGr/Q7ZD 4H0A== 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=NRXB+JS42nffvxMyjWW2qiYBpadQLCn8VyzG3U8X8TA=; b=D65wNxNu4MVwLJbChuLGPVUb7eokdX2CpgWA6xa6gGiW6bca1Sn8OwkDpSo23N5Nsa xt6CSDoLoyE5+BzDO7yfaKFI0gxeCuSUer599gSHBvJTCRYwtEGWOHNFQk9cyts5K96R IeyJ16eqmuavtPKOmDshPMMQq5aYYoyljbipUB4CBYT9FAC5lSzHLVs4Upe7BRDtC7jE o0RJyqXSXqUOvSnukZg/H1zS7Nc0rjqEVNjkZo01UafuXb0/bM3va5Y9zy4k3qrdU+7q gmFUtaDPztXyvNGkwPxf0QdI/MkmzUCDnbr801pMgBio6ojHKKtgBrdlTa8SV/nGeVMJ gdzQ== X-Gm-Message-State: AOAM531GtNaS63shw/F8/p94TAq/bSQjIT7PW9ahgpfdX6qTHOGjlQXc K9bjAu9aFtx35XfR1NQIrh3gxClS9O+ZgA== X-Received: by 2002:aca:edc1:: with SMTP id l184mr16733658oih.99.1595200304774; Sun, 19 Jul 2020 16:11:44 -0700 (PDT) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:6ba0::5e16]) by smtp.googlemail.com with ESMTPSA id q19sm2394680ooi.14.2020.07.19.16.11.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Jul 2020 16:11:44 -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 , Jonathan Corbet , Will Deacon , Andrew Morton , Orson Zhai , Petr Mladek , linux-doc@vger.kernel.org Subject: [PATCH v5 14/18] dyndbg: accept query terms like file=bar and module=foo Date: Sun, 19 Jul 2020 17:10:54 -0600 Message-Id: <20200719231058.1586423-15-jim.cromie@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200719231058.1586423-1-jim.cromie@gmail.com> References: <20200719231058.1586423-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 words, space separated. Change to also accept "keyword=arg" form as well, and drop !(nwords%2) requirement. Then in rest of function, use new keyword, arg variables instead of word[i], word[i+1] Signed-off-by: Jim Cromie --- .../admin-guide/dynamic-debug-howto.rst | 1 + lib/dynamic_debug.c | 53 ++++++++++++------- 2 files changed, 34 insertions(+), 20 deletions(-) diff --git a/Documentation/admin-guide/dynamic-debug-howto.rst b/Documentation/admin-guide/dynamic-debug-howto.rst index 6c04aea8f4cd..e5a8def45f3f 100644 --- a/Documentation/admin-guide/dynamic-debug-howto.rst +++ b/Documentation/admin-guide/dynamic-debug-howto.rst @@ -156,6 +156,7 @@ against. Possible keywords are::: ``line-range`` cannot contain space, e.g. "1-30" is valid range but "1 - 30" is not. + ``module=foo`` combined keyword=value form is interchangably accepted The meanings of each keyword are: diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 7eb963b1bd11..fad6c34c930d 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -341,7 +341,8 @@ static int check_set(const char **dest, char *src, char *name) /* * Parse words[] as a ddebug query specification, which is a series - * of (keyword, value) pairs chosen from these possibilities: + * of (keyword, value) pairs or combined keyword=value terms, + * chosen from these possibilities: * * func * file @@ -360,22 +361,34 @@ 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]; + arg = strchr(keyword, '='); + if (arg) { + *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 */ @@ -391,18 +404,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