From patchwork Wed Apr 30 15:40:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Thompson X-Patchwork-Id: 29432 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f71.google.com (mail-pa0-f71.google.com [209.85.220.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7C4F4203F3 for ; Wed, 30 Apr 2014 15:41:20 +0000 (UTC) Received: by mail-pa0-f71.google.com with SMTP id kp14sf8558496pab.2 for ; Wed, 30 Apr 2014 08:41:17 -0700 (PDT) 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=F/iczUQsnnRgjqQr9G+oxKjRhMSh4Bq/KLlSTWhix4M=; b=gQm6FFMEjTK7Og7+hgHNZxb6yOnMiX83sbDWAsKddRcsKYhfslrQM/TTw30xbMB/OB xtQ1YxmVL78E0K40879w0zIeQT/3w2hYYz3hnQ5u03dJtWd+LeUAj+zhLputY27yQyt3 Y2DAEolOBRR+0w/AlUKwVwgRDizPefuvdZR4XfOBcXUihxAJVX97pApg5HaDVxNonNqa f38Liam6UavILgG1ba7lJ3HmNflP/mqiJD/lkVjTQDCLRM6q4RUDYqN48+0uLhm3es/w GqNKNFdS4AKcJXH8z90yHNxFUZBvB4l0S0tiq+2Elo7GOG/kKy4eHp1G+4K6+Bor6zx1 5KBw== X-Gm-Message-State: ALoCoQmv+RcT7FcxMIK4szvWxJHHn4K3/10L0zhQ93Qs+E1hL+7m6ZTwuCbweQ3hIgdwZEGiLajP X-Received: by 10.66.65.109 with SMTP id w13mr2675249pas.21.1398872474645; Wed, 30 Apr 2014 08:41:14 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.89.136 with SMTP id v8ls670086qgd.13.gmail; Wed, 30 Apr 2014 08:41:14 -0700 (PDT) X-Received: by 10.52.130.225 with SMTP id oh1mr3693026vdb.8.1398872474488; Wed, 30 Apr 2014 08:41:14 -0700 (PDT) Received: from mail-ve0-f179.google.com (mail-ve0-f179.google.com [209.85.128.179]) by mx.google.com with ESMTPS id sl10si2568396vdc.75.2014.04.30.08.41.14 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 30 Apr 2014 08:41:14 -0700 (PDT) Received-SPF: none (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) client-ip=209.85.128.179; Received: by mail-ve0-f179.google.com with SMTP id db12so2429986veb.10 for ; Wed, 30 Apr 2014 08:41:14 -0700 (PDT) X-Received: by 10.221.26.10 with SMTP id rk10mr4391389vcb.0.1398872474422; Wed, 30 Apr 2014 08:41:14 -0700 (PDT) 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.220.221.72 with SMTP id ib8csp289259vcb; Wed, 30 Apr 2014 08:41:13 -0700 (PDT) X-Received: by 10.180.96.225 with SMTP id dv1mr4275024wib.37.1398872473569; Wed, 30 Apr 2014 08:41:13 -0700 (PDT) Received: from mail-we0-f175.google.com (mail-we0-f175.google.com [74.125.82.175]) by mx.google.com with ESMTPS id qk5si9669779wjc.30.2014.04.30.08.41.13 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 30 Apr 2014 08:41:13 -0700 (PDT) Received-SPF: none (google.com: daniel.thompson@linaro.org does not designate permitted sender hosts) client-ip=74.125.82.175; Received: by mail-we0-f175.google.com with SMTP id q58so1843240wes.20 for ; Wed, 30 Apr 2014 08:41:13 -0700 (PDT) X-Received: by 10.180.94.226 with SMTP id df2mr4247509wib.1.1398872472747; Wed, 30 Apr 2014 08:41:12 -0700 (PDT) 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 hp5sm36719389wjb.0.2014.04.30.08.41.10 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Apr 2014 08:41:11 -0700 (PDT) From: Daniel Thompson To: kgdb-bugreport@lists.sourceforge.net, Jason Wessel Cc: patches@linaro.org, linaro-kernel@lists.linaro.org, Daniel Thompson , linux-kernel@vger.kernel.org, Paul Gortmaker , Andrew Morton , Mike Travis , Dimitri Sivanich , Hedi Berriche , John Stultz , Anton Vorontsov , Colin Cross , kernel-team@android.com Subject: [PATCH 3/3] kdb: Implement seq_file command Date: Wed, 30 Apr 2014 16:40:27 +0100 Message-Id: <1398872427-18435-4-git-send-email-daniel.thompson@linaro.org> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1398872427-18435-1-git-send-email-daniel.thompson@linaro.org> References: <1398781841-15152-1-git-send-email-daniel.thompson@linaro.org> <1398872427-18435-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=neutral (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) 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: , Combining the kdb seq_file infrastructure with its symbolic lookups allows a good sub-set of files held in pseudo filesystems to be displayed by kdb. The seq_file command does exactly this and allows a significant subset of pseudo files to be safely examined whilst debugging (and in the hands of a brave expert an even bigger subset can be unsafely examined). Good arguments to try with this command include: cpuinfo_op, gpiolib_seq_ops and vmalloc_op. Signed-off-by: Daniel Thompson --- kernel/debug/kdb/kdb_io.c | 6 ++++-- kernel/debug/kdb/kdb_main.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c index c68c223..5863180 100644 --- a/kernel/debug/kdb/kdb_io.c +++ b/kernel/debug/kdb/kdb_io.c @@ -878,8 +878,10 @@ int kdb_print_seq_file(const struct seq_operations *ops) struct seq_file m = { .buf = seq_buf, .size = sizeof(seq_buf), - /* .lock is deliberately uninitialized to help reveal - * unsupportable show methods + /* .lock is deliberately left uninitialized because it is + * used by seq_file read/lseek wrapper functions. It cannot be + * used from any of the seq_operations (assuming the ops are + * deadlock free with the normal interface). */ .op = ops, }; diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c index 0b097c8..d87731c 100644 --- a/kernel/debug/kdb/kdb_main.c +++ b/kernel/debug/kdb/kdb_main.c @@ -1734,6 +1734,32 @@ static int kdb_mm(int argc, const char **argv) } /* + * kdb_seq_file - This function implements the 'seq_file' command. + * seq_file address-expression + */ +static int kdb_seq_file(int argc, const char **argv) +{ + int diag; + unsigned long addr; + int nextarg; + long offset; + char *name; + const struct seq_operations *ops; + + nextarg = 1; + diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, &name); + if (diag) + return diag; + + if (nextarg != argc+1) + return KDB_ARGCOUNT; + + ops = (const struct seq_operations *) (addr + offset); + kdb_printf("Using sequence_ops at 0x%p (%s)\n", ops, name); + return kdb_print_seq_file(ops); +} + +/* * kdb_go - This function implements the 'go' command. * go [address-expression] */ @@ -2838,6 +2864,8 @@ static void __init kdb_inittab(void) "Display per_cpu variables", 3, KDB_REPEAT_NONE); kdb_register_repeat("grephelp", kdb_grep_help, "", "Display help on | grep", 0, KDB_REPEAT_NONE); + kdb_register_repeat("seq_file", kdb_seq_file, "", + "Show a seq_file using struct seq_operations", 3, KDB_REPEAT_NONE); } /* Execute any commands defined in kdb_cmds. */