From: tip-bot for Franck Bui-Huu <fbuihuu@gmail.com>
To: linux-tip-commits@vger.kernel.org
Cc: acme@redhat.com, linux-kernel@vger.kernel.org, hpa@zytor.com,
mingo@redhat.com, masami.hiramatsu.pt@hitachi.com,
fbuihuu@gmail.com, tglx@linutronix.de
Subject: [tip:perf/core] perf probe: Don't always consider EOF as an error when listing source code
Date: Wed, 22 Dec 2010 11:31:56 GMT [thread overview]
Message-ID: <tip-fde52dbd7f71934aba4e150f3d1d51e826a08850@git.kernel.org> (raw)
In-Reply-To: <1292854685-8230-6-git-send-email-fbuihuu@gmail.com>
Commit-ID: fde52dbd7f71934aba4e150f3d1d51e826a08850
Gitweb: http://git.kernel.org/tip/fde52dbd7f71934aba4e150f3d1d51e826a08850
Author: Franck Bui-Huu <fbuihuu@gmail.com>
AuthorDate: Mon, 20 Dec 2010 15:18:04 +0100
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 21 Dec 2010 16:20:12 -0200
perf probe: Don't always consider EOF as an error when listing source code
When listing a whole file or a function which is located at the end,
perf-probe -L output wrongly: "Source file is shorter than expected.".
This is because show_one_line() always consider EOF as an error.
This patch fixes this by not considering EOF as an error when dumping
the trailing lines. Otherwise it's still an error and perf-probe still
outputs its warning.
Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
LKML-Reference: <1292854685-8230-6-git-send-email-fbuihuu@gmail.com>
Signed-off-by: Franck Bui-Huu <fbuihuu@gmail.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/probe-event.c | 38 ++++++++++++++++++++++++++------------
1 files changed, 26 insertions(+), 12 deletions(-)
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 3ba9c53..80cc0bc 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -287,7 +287,7 @@ static int get_real_path(const char *raw_path, const char *comp_dir,
#define LINEBUF_SIZE 256
#define NR_ADDITIONAL_LINES 2
-static int show_one_line(FILE *fp, int l, bool skip, bool show_num)
+static int __show_one_line(FILE *fp, int l, bool skip, bool show_num)
{
char buf[LINEBUF_SIZE];
const char *color = show_num ? "" : PERF_COLOR_BLUE;
@@ -306,16 +306,30 @@ static int show_one_line(FILE *fp, int l, bool skip, bool show_num)
} while (strchr(buf, '\n') == NULL);
- return 0;
+ return 1;
error:
- if (feof(fp))
+ if (ferror(fp)) {
pr_warning("Source file is shorter than expected.\n");
- else
- pr_warning("File read error: %s\n", strerror(errno));
+ return -1;
+ }
+ return 0;
+}
- return -1;
+static int _show_one_line(FILE *fp, int l, bool skip, bool show_num)
+{
+ int rv = __show_one_line(fp, l, skip, show_num);
+ if (rv == 0) {
+ pr_warning("Source file is shorter than expected.\n");
+ rv = -1;
+ }
+ return rv;
}
+#define show_one_line_with_num(f,l) _show_one_line(f,l,false,true)
+#define show_one_line(f,l) _show_one_line(f,l,false,false)
+#define skip_one_line(f,l) _show_one_line(f,l,true,false)
+#define show_one_line_or_eof(f,l) __show_one_line(f,l,false,false)
+
/*
* Show line-range always requires debuginfo to find source file and
* line number.
@@ -374,27 +388,27 @@ int show_line_range(struct line_range *lr, const char *module)
}
/* Skip to starting line number */
while (l < lr->start) {
- ret = show_one_line(fp, l++, true, false);
+ ret = skip_one_line(fp, l++);
if (ret < 0)
goto end;
}
list_for_each_entry(ln, &lr->line_list, list) {
for (; ln->line > l; l++) {
- ret = show_one_line(fp, l - lr->offset, false, false);
+ ret = show_one_line(fp, l - lr->offset);
if (ret < 0)
goto end;
}
- ret = show_one_line(fp, l++ - lr->offset, false, true);
+ ret = show_one_line_with_num(fp, l++ - lr->offset);
if (ret < 0)
goto end;
}
if (lr->end == INT_MAX)
lr->end = l + NR_ADDITIONAL_LINES;
- while (l <= lr->end && !feof(fp)) {
- ret = show_one_line(fp, l++ - lr->offset, false, false);
- if (ret < 0)
+ while (l <= lr->end) {
+ ret = show_one_line_or_eof(fp, l++ - lr->offset);
+ if (ret <= 0)
break;
}
end:
next prev parent reply other threads:[~2010-12-22 11:32 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-20 14:17 [PATCH 0/6] Minor cleanups & fixes for perf-probe(1) Franck Bui-Huu
2010-12-20 14:18 ` [PATCH 1/6] perf-tools: make perf-probe -L display the absolute path of the dumped file Franck Bui-Huu
2010-12-21 5:30 ` Masami Hiramatsu
2010-12-22 11:30 ` [tip:perf/core] perf probe: Make " tip-bot for Franck Bui-Huu
2010-12-20 14:18 ` [PATCH 2/6] perf-probe: rewrite show_one_line() to make it simpler Franck Bui-Huu
2010-12-21 8:55 ` Masami Hiramatsu
2010-12-22 11:30 ` [tip:perf/core] perf probe: Rewrite " tip-bot for Franck Bui-Huu
2010-12-20 14:18 ` [PATCH 3/6] perf-probe: clean up redundant tests in show_line_range() Franck Bui-Huu
2010-12-21 9:47 ` Masami Hiramatsu
2010-12-22 11:31 ` [tip:perf/core] perf probe: Clean " tip-bot for Franck Bui-Huu
2010-12-20 14:18 ` [PATCH 4/6] perf-probe: Fix line range description since a single file is allowed Franck Bui-Huu
2010-12-22 11:31 ` [tip:perf/core] perf probe: " tip-bot for Franck Bui-Huu
2010-12-20 14:18 ` [PATCH 5/6] perf-probe: don't always consider EOF as an error when listing source code Franck Bui-Huu
2010-12-21 11:54 ` Masami Hiramatsu
2010-12-22 11:31 ` tip-bot for Franck Bui-Huu [this message]
2010-12-22 13:14 ` [tip:perf/core] perf probe: Don't " Franck Bui-Huu
2010-12-22 14:43 ` Arnaldo Carvalho de Melo
2010-12-22 16:37 ` Franck Bui-Huu
2010-12-25 8:58 ` [tip:perf/core] perf probe: Fix wrong warning in __show_one_line() if read(1) errors happen tip-bot for Franck Bui-Huu
2010-12-26 14:11 ` Masami Hiramatsu
2010-12-20 14:18 ` [PATCH 6/6] perf-probe: handle gracefully some stupid and buggy line syntaxes Franck Bui-Huu
2010-12-21 13:10 ` Masami Hiramatsu
2010-12-22 11:32 ` [tip:perf/core] perf probe: Handle " tip-bot for Franck Bui-Huu
2010-12-21 13:11 ` [PATCH 0/6] Minor cleanups & fixes for perf-probe(1) Masami Hiramatsu
2010-12-21 18:01 ` Franck Bui-Huu
2010-12-21 21:05 ` Arnaldo Carvalho de Melo
2010-12-22 13:11 ` Franck Bui-Huu
2010-12-24 0:36 ` Masami Hiramatsu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tip-fde52dbd7f71934aba4e150f3d1d51e826a08850@git.kernel.org \
--to=fbuihuu@gmail.com \
--cc=acme@redhat.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=masami.hiramatsu.pt@hitachi.com \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome