Bug 6611 - read-only variable typo warnings should list alternatives
Summary: read-only variable typo warnings should list alternatives
Status: RESOLVED FIXED
Alias: None
Product: systemtap
Classification: Unclassified
Component: translator (show other bugs)
Version: unspecified
: P2 enhancement
Target Milestone: ---
Assignee: Stan Cox
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-06-09 19:03 UTC by Frank Ch. Eigler
Modified: 2008-08-05 18:41 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Frank Ch. Eigler 2008-06-09 19:03:02 UTC
The same way as we list alternatives when someone
misspells a $context variable, we should do the same
when eliding a read-only variable:

probe foo = bar { var1="foo" }
probe foo { prinln(var) }  # <- should list "var1" as an alternative

Then one can *list* local variables available in a probe using
a hack like
   % stap -e "probe SOMEWHERE { nosuchvar }"
   WARNING: read-only local variable nosuchvar (alternatives: foo, bar, baz) ...

(It's conceivable to also warn for the "var1" side of the
mismatch, in the "eliding unused local variable" branch in
elaborate.cxx:semantic_pass_opt2.)
Comment 1 Stan Cox 2008-06-16 18:16:46 UTC
Bug 6611: read-only variable typo warnings should list alternatives.
Comment 2 Ananth Mavinakayanahalli 2008-07-03 11:40:21 UTC
Stan,

I am seeing:

[root@... systemtap-3july]# stap -vv testsuite/systemtap.base/warnings.stp
SystemTap translator/driver (version 0.7/0.133 non-git sources)
Copyright (C) 2005-2008 Red Hat, Inc. and others
This is free software; see the source for copying conditions.
Session arch: i686 release: 2.6.26-rc8-reloc
Created temporary directory "/tmp/stapur8vlp"
Searched '/usr/local/share/systemtap/tapset/i686/*.stp', found 2
Searched '/usr/local/share/systemtap/tapset/*.stp', found 41
Pass 1: parsed user script and 43 library script(s) in 500usr/20sys/526real ms.
semantic error: multiple addresses for fs/bio.c:135 (try fs/bio.c:131 or
fs/bio.c:136)
semantic error: no match while resolving probe point
kernel.statement("bio_init@fs/bio.c:135")
semantic error: no match while resolving probe point probea
Pass 2: analyzed script: 2 probe(s), 5 function(s), 0 embed(s), 1 global(s) in
220usr/140sys/348real ms.
Pass 2: analysis failed.  Try again with more '-v' (verbose) options.
Running rm -rf /tmp/stapur8vlp

on a 2.6.26-rc8 kernel, resulting in the test failing with a

FAIL: warnings (0)
Comment 3 Frank Ch. Eigler 2008-07-03 16:52:13 UTC
Yeah, the test case should not hard-code a line number like that.
hy not just kernel.function("bio_init"); perhaps using the relative
line number syntax if needed.
Comment 4 Stan Cox 2008-08-05 18:41:50 UTC
systemtap.base/warnings.stp: Use relative instead of absolute line.