Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1175104

[PATCH 4/4] perf probe: Add failure check when show variable range

From He Kuang <hekuang@huawei.com>
Newsgroups linux.kernel
Subject [PATCH 4/4] perf probe: Add failure check when show variable range
Date 2015-07-01 11:10 +0200
Message-ID <pHmbL-3go-5@gated-at.bofh.it> (permalink)
References <pHmbL-3go-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Change improper type size_t to diffptr_t to make consistent with libdw
and handle error code.

Signed-off-by: He Kuang <hekuang@huawei.com>
---
 tools/perf/util/dwarf-aux.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c
index 2cb4c82..da96eb1 100644
--- a/tools/perf/util/dwarf-aux.c
+++ b/tools/perf/util/dwarf-aux.c
@@ -965,7 +965,7 @@ static int die_get_var_innermost_scope(Dwarf_Die *sp_die, Dwarf_Die *vr_die,
 {
 	Dwarf_Die *scopes;
 	int count;
-	size_t offset = 0;
+	ptrdiff_t offset = 0;
 	Dwarf_Addr base;
 	Dwarf_Addr start, end;
 	Dwarf_Addr entry;
@@ -991,6 +991,9 @@ static int die_get_var_innermost_scope(Dwarf_Die *sp_die, Dwarf_Die *vr_die,
 
 	while ((offset = dwarf_ranges(&scopes[1], offset, &base,
 				&start, &end)) > 0) {
+		if (offset < 0)
+			goto out;
+
 		start -= entry;
 		end -= entry;
 
@@ -1029,7 +1032,7 @@ int die_get_var_range(Dwarf_Die *sp_die, Dwarf_Die *vr_die, struct strbuf *buf)
 	Dwarf_Addr entry;
 	Dwarf_Op *op;
 	size_t nops;
-	size_t offset = 0;
+	ptrdiff_t offset = 0;
 	Dwarf_Attribute attr;
 	bool first = true;
 	const char *name;
@@ -1048,6 +1051,9 @@ int die_get_var_range(Dwarf_Die *sp_die, Dwarf_Die *vr_die, struct strbuf *buf)
 	while ((offset = dwarf_getlocations(
 				&attr, offset, &base,
 				&start, &end, &op, &nops)) > 0) {
+		if (offset < 0)
+			return offset;
+
 		if (start == 0) {
 			/* Single Location Descriptions */
 			ret = die_get_var_innermost_scope(sp_die, vr_die, buf);
-- 
1.8.5.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 1/4] perf record: Use %ld for long type sample counter He Kuang <hekuang@huawei.com> - 2015-07-01 11:10 +0200
  [PATCH 4/4] perf probe: Add failure check when show variable range He Kuang <hekuang@huawei.com> - 2015-07-01 11:10 +0200
  [PATCH 3/4] perf probe: Enable --range option according to libdw version He Kuang <hekuang@huawei.com> - 2015-07-01 11:10 +0200
  [PATCH 2/4] perf probe: Fix failure to probe online module He Kuang <hekuang@huawei.com> - 2015-07-01 11:10 +0200

csiph-web