From patchwork Wed Jan 7 16:10:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Thompson X-Patchwork-Id: 42835 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 19A832055F for ; Wed, 7 Jan 2015 16:10:29 +0000 (UTC) Received: by mail-wi0-f197.google.com with SMTP id l15sf932224wiw.8 for ; Wed, 07 Jan 2015 08:10:28 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=1yf+nYhm7a8ZoRCXyf7TKWZZdo8CteXSuUQuaTyYku4=; b=ALq6UpavWhmzFH+HNsceVnTnJsivwGV0prHlYCrTUWMEO3hFCzipyQnkllgqHovopJ 49VmtpaqixyeQ/2QGwo9OZORQuU3LFupuv1NT55djVGgq5UnkCdh1tAvx+z6EiGy0H+T HfwLoF1UVhdrYt2Xrb0scrMupnNfCbTQLVk2L2CRI9GHY/8oXgIRYogp5gBnJn2XTUBP KHg18z3K8I1ism52nRSwGBGreCxbPemUJPBk7N1joYaAfD036bWCKwIii9pn0nmrkKMU 0hLBIa+doLOJEGWXWWa1LX6YEgV3aWp80I57CjS8JbYh4VBAdESCRUZ7+pnWtsuXgPwV IQSw== X-Gm-Message-State: ALoCoQmBv3jUa93Xx6qMalb9m8009slk9Q0lJ3Cp5YKyojBwb2L7RjDKNpHo8Fjwz26hLcXP9+PJ X-Received: by 10.152.42.196 with SMTP id q4mr417343lal.6.1420647028284; Wed, 07 Jan 2015 08:10:28 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.120.132 with SMTP id lc4ls190360lab.1.gmail; Wed, 07 Jan 2015 08:10:28 -0800 (PST) X-Received: by 10.112.160.104 with SMTP id xj8mr5963032lbb.62.1420647028147; Wed, 07 Jan 2015 08:10:28 -0800 (PST) Received: from mail-lb0-f170.google.com (mail-lb0-f170.google.com. [209.85.217.170]) by mx.google.com with ESMTPS id q2si3618931lbb.130.2015.01.07.08.10.27 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 07 Jan 2015 08:10:27 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.170 as permitted sender) client-ip=209.85.217.170; Received: by mail-lb0-f170.google.com with SMTP id 10so1338025lbg.29 for ; Wed, 07 Jan 2015 08:10:27 -0800 (PST) X-Received: by 10.152.23.38 with SMTP id j6mr5893961laf.81.1420647027723; Wed, 07 Jan 2015 08:10:27 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.9.200 with SMTP id c8csp1529093lbb; Wed, 7 Jan 2015 08:10:27 -0800 (PST) X-Received: by 10.194.91.234 with SMTP id ch10mr8094659wjb.114.1420647025852; Wed, 07 Jan 2015 08:10:25 -0800 (PST) Received: from mail-wg0-f52.google.com (mail-wg0-f52.google.com. [74.125.82.52]) by mx.google.com with ESMTPS id sb19si5275381wjb.6.2015.01.07.08.10.25 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 07 Jan 2015 08:10:25 -0800 (PST) Received-SPF: pass (google.com: domain of daniel.thompson@linaro.org designates 74.125.82.52 as permitted sender) client-ip=74.125.82.52; Received: by mail-wg0-f52.google.com with SMTP id x12so1443544wgg.39 for ; Wed, 07 Jan 2015 08:10:25 -0800 (PST) X-Received: by 10.180.73.108 with SMTP id k12mr8846830wiv.24.1420647025529; Wed, 07 Jan 2015 08:10:25 -0800 (PST) Received: from sundance.lan (cpc4-aztw19-0-0-cust157.18-1.cable.virginm.net. [82.33.25.158]) by mx.google.com with ESMTPSA id s4sm18370956wiy.13.2015.01.07.08.10.23 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Jan 2015 08:10:24 -0800 (PST) From: Daniel Thompson To: Jason Wessel Cc: Daniel Thompson , linux-kernel@vger.kernel.org, kgdb-bugreport@lists.sourceforge.net, Andrew Morton , Ingo Molnar , patches@linaro.org, linaro-kernel@lists.linaro.org, John Stultz , Sumit Semwal Subject: [RESEND PATCH 3.19-rc2 2/3] kdb: Provide forward search at more prompt Date: Wed, 7 Jan 2015 16:10:13 +0000 Message-Id: <1420647014-4897-3-git-send-email-daniel.thompson@linaro.org> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1420647014-4897-1-git-send-email-daniel.thompson@linaro.org> References: <1410438579-7839-1-git-send-email-daniel.thompson@linaro.org> <1420647014-4897-1-git-send-email-daniel.thompson@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: daniel.thompson@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.170 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Currently kdb allows the output of comamnds to be filtered using the | grep feature. This is useful but does not permit the output emitted shortly after a string match to be examined without wading through the entire unfiltered output of the command. Such a feature is particularly useful to navigate function traces because these traces often have a useful trigger string *before* the point of interest. This patch reuses the existing filtering logic to introduce a simple forward search to kdb that can be triggered from the more prompt. Signed-off-by: Daniel Thompson --- kernel/debug/kdb/kdb_io.c | 22 ++++++++++++++++++++-- kernel/debug/kdb/kdb_main.c | 7 ++++--- kernel/debug/kdb/kdb_private.h | 2 ++ 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c index 7c70812caea5..70e0f494d3f8 100644 --- a/kernel/debug/kdb/kdb_io.c +++ b/kernel/debug/kdb/kdb_io.c @@ -680,6 +680,12 @@ int vkdb_printf(const char *fmt, va_list ap) size_avail = sizeof(kdb_buffer) - len; goto kdb_print_out; } + if (kdb_grepping_flag >= KDB_GREPPING_FLAG_SEARCH) + /* + * This was a interactive search (using '/' at more + * prompt) and it has completed. Clear the flag. + */ + kdb_grepping_flag = 0; /* * at this point the string is a full line and * should be printed, up to the null. @@ -794,11 +800,23 @@ kdb_printit: kdb_nextline = linecount - 1; kdb_printf("\r"); suspend_grep = 1; /* for this recursion */ + } else if (buf1[0] == '/' && !kdb_grepping_flag) { + kdb_printf("\r"); + kdb_getstr(kdb_grep_string, KDB_GREP_STRLEN, + kdbgetenv("SEARCHPROMPT") ?: "search> "); + *strchrnul(kdb_grep_string, '\n') = '\0'; + kdb_grepping_flag += KDB_GREPPING_FLAG_SEARCH; + suspend_grep = 1; /* for this recursion */ } else if (buf1[0] && buf1[0] != '\n') { /* user hit something other than enter */ suspend_grep = 1; /* for this recursion */ - kdb_printf("\nOnly 'q' or 'Q' are processed at more " - "prompt, input ignored\n"); + if (buf1[0] != '/') + kdb_printf( + "\nOnly 'q', 'Q' or '/' are processed at " + "more prompt, input ignored\n"); + else + kdb_printf("\n'/' cannot be used during | " + "grep filtering, input ignored\n"); } else if (kdb_grepping_flag) { /* user hit enter */ suspend_grep = 1; /* for this recursion */ diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c index 9d10cb20cef1..c36f6f6696c2 100644 --- a/kernel/debug/kdb/kdb_main.c +++ b/kernel/debug/kdb/kdb_main.c @@ -42,8 +42,7 @@ #include #include "kdb_private.h" -#define GREP_LEN 256 -char kdb_grep_string[GREP_LEN]; +char kdb_grep_string[KDB_GREP_STRLEN]; int kdb_grepping_flag; EXPORT_SYMBOL(kdb_grepping_flag); int kdb_grep_leading; @@ -827,7 +826,7 @@ static void parse_grep(const char *str) len = strlen(cp); if (!len) return; - if (len >= GREP_LEN) { + if (len >= KDB_GREP_STRLEN) { kdb_printf("search string too long\n"); return; } @@ -1241,6 +1240,8 @@ static int kdb_local(kdb_reason_t reason, int error, struct pt_regs *regs, kdb_nextline = 1; KDB_STATE_CLEAR(SUPPRESS); kdb_grepping_flag = 0; + /* ensure the old search does not leak into '/' commands */ + kdb_grep_string[0] = '\0'; cmdbuf = cmd_cur; *cmdbuf = '\0'; diff --git a/kernel/debug/kdb/kdb_private.h b/kernel/debug/kdb/kdb_private.h index 7afd3c8c41d5..30ed4f3d8606 100644 --- a/kernel/debug/kdb/kdb_private.h +++ b/kernel/debug/kdb/kdb_private.h @@ -197,7 +197,9 @@ extern int kdb_main_loop(kdb_reason_t, kdb_reason_t, /* Miscellaneous functions and data areas */ extern int kdb_grepping_flag; +#define KDB_GREPPING_FLAG_SEARCH 0x8000 extern char kdb_grep_string[]; +#define KDB_GREP_STRLEN 256 extern int kdb_grep_leading; extern int kdb_grep_trailing; extern char *kdb_cmds[];