summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dwflpp.cxx32
-rw-r--r--testsuite/systemtap.base/bz6905.c7
-rw-r--r--testsuite/systemtap.base/bz6905.exp25
-rw-r--r--testsuite/systemtap.base/bz6905.stp4
4 files changed, 64 insertions, 4 deletions
diff --git a/dwflpp.cxx b/dwflpp.cxx
index ce9993c8..01cfddaa 100644
--- a/dwflpp.cxx
+++ b/dwflpp.cxx
@@ -808,19 +808,43 @@ dwflpp::iterate_over_srcfile_lines (char const * srcfile,
}
else if (line_type == WILDCARD)
function_line (&lineno);
+ else if (line_type == RANGE) { /* correct lineno */
+ int start_lineno;
+
+ function_line (&start_lineno);
+ lineno = lineno < start_lineno ? start_lineno : lineno;
+ if (lineno > lines[1]) { /* invalid line range */
+ stringstream advice;
+ advice << "Invalid line range (" << lines[0] << "-" << lines[1] << ")";
+ if (start_lineno > lines[1])
+ advice << ", the end line number " << lines[1] << " < " << start_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_assert ("dwarf_getsrc_file", ret);
+
if (line_type == WILDCARD || line_type == RANGE)
{
Dwarf_Addr line_addr;
+
+ if (ret != 0) /* tolerate invalid line number */
+ break;
+
dwarf_lineno (srcsp [0], &lineno);
+ /* Maybe lineno will exceed the input end */
+ if (line_type == RANGE && lineno > lines[1])
+ break;
line_probed = lines_probed.insert(lineno);
if (lineno != l || line_probed.second == false || nsrcs > 1)
continue;
diff --git a/testsuite/systemtap.base/bz6905.c b/testsuite/systemtap.base/bz6905.c
new file mode 100644
index 00000000..bb3f524e
--- /dev/null
+++ b/testsuite/systemtap.base/bz6905.c
@@ -0,0 +1,7 @@
+int main()
+{
+ int a;
+
+ a = a + 1;
+ return 0;
+}
diff --git a/testsuite/systemtap.base/bz6905.exp b/testsuite/systemtap.base/bz6905.exp
new file mode 100644
index 00000000..8119159e
--- /dev/null
+++ b/testsuite/systemtap.base/bz6905.exp
@@ -0,0 +1,25 @@
+set test bz6905
+
+catch {exec gcc -g -o $test $srcdir/$subdir/$test.c} err
+if {$err == "" && [file exists $test]} then { pass "$test compile" } else { fail "$test compile" }
+
+if {![utrace_p]} {
+ catch {exec rm -f $test}
+ untested "$test -p2"
+ return
+}
+
+set stapexe [exec /usr/bin/which stap]
+spawn sudo $stapexe -p2 $srcdir/$subdir/$test.stp
+set hint 0
+set probes 0
+expect {
+ -timeout 60
+ -re "# probes" { incr hint; exp_continue }
+ -re {process.*statement.*} { incr probes; exp_continue }
+ timeout { fail "$test (timeout)" }
+ eof { }
+}
+wait
+if { $hint == 1 && $probes > 0 } then { pass "$test -p2" } else { fail "$test -p2 ($probes)" }
+exec rm -f $test
diff --git a/testsuite/systemtap.base/bz6905.stp b/testsuite/systemtap.base/bz6905.stp
new file mode 100644
index 00000000..73c7d50c
--- /dev/null
+++ b/testsuite/systemtap.base/bz6905.stp
@@ -0,0 +1,4 @@
+#! stap -p2
+probe process("./bz6905").statement("main@bz6905.c:*") {
+ printf("ok")
+}