systemtap/stap-pr6905-weaken-lineno-checks.diff

63 lines
1.8 KiB
Diff

From 2d4a8f7a704619f1df32a24cfb284cf0fe936e5d Mon Sep 17 00:00:00 2001
From: wenji huang <wjhuang@localhost.localdomain>
Date: Sun, 14 Dec 2008 23:54:05 -0500
Subject: [PATCH 1/1] PR6905: Weaken the checking of line number for WILDCARD and make RANGE smart.
---
tapsets.cxx | 24 ++++++++++++++++++++----
1 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/tapsets.cxx b/tapsets.cxx
index 4d9a021..391e54e 100644
--- a/tapsets.cxx
+++ b/tapsets.cxx
@@ -1242,18 +1242,33 @@ struct dwflpp
}
else if (line_type == WILDCARD)
function_line (&lineno);
+ else if (line_type == RANGE) {
+ int start_lineno;
+ function_line (&start_lineno);
+ lineno = start_lineno > lineno ? start_lineno : lineno;
+ if (lineno > lines[1]) { /* invalid line range */
+ stringstream advice;
+ advice << "Starting line number for " << srcfile << " : " << lineno;
+ throw semantic_error (advice.str());
+ }
+ }
+
for (int l = lineno; ; l = l + 1)
{
set<int> lines_probed;
pair<set<int>::iterator,bool> line_probed;
- dwarf_assert ("dwarf_getsrc_file",
- dwarf_getsrc_file (module_dwarf,
- srcfile, l, 0,
- &srcsp, &nsrcs));
+ int ret = 0;
+
+ ret = dwarf_getsrc_file (module_dwarf, srcfile, l, 0,
+ &srcsp, &nsrcs);
if (line_type == WILDCARD || line_type == RANGE)
{
Dwarf_Addr line_addr;
+
+ if (ret != 0) /* tolerate invalid line number out of assert */
+ break;
+
dwarf_lineno (srcsp [0], &lineno);
line_probed = lines_probed.insert(lineno);
if (lineno != l || line_probed.second == false || nsrcs > 1)
@@ -1263,6 +1278,7 @@ struct dwflpp
break;
}
+ dwarf_assert ("dwarf_getsrc_file", ret);
// NB: Formerly, we used to filter, because:
// dwarf_getsrc_file gets one *near hits* for line numbers, not
--
1.5.6