This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Inconsistent behavior of 'delete'


WAS: [Bug translator/2115] support some function calls on maps
fche at redhat dot com wrote:
> "clear" == "delete MAP"

I tried this out, and sure enough it works.  But, I noticed that it
currently only works in two specific cases: deleting one index from a
map of ints, or deleting an entire map (but not a pmap).

IMHO, 'delete' should just work for any (L-value) type of operand.
Deleting scalars (int, string, or stat) should reset them to their
initial state.  All map types should support deleting either individual
indices or the entire map, whether it's a map of ints or strings or a
pmap of stats.

Using 'delete' only really makes sense for globals, but if it's
implemented as suggested above, it might as well just work for local
ints and strings as well.  This is fine - my whole argument is to
maintain universal semantics.

I wrote a pass-4 script to try all of these cases (below), but I wanted
to make sure everyone agrees with my concept of 'delete' before I check
it in to the testsuite.  Right now this fails with an obscure message:
"terminate called after throwing an instance of 'semantic_error*'".

Comments?


Josh


PS: delete doesn't have any documentation in the map pages - the only
mention is in stapex(5) as somewhat of an aside.  Once we decide how it
should work, I can write that up for stap(1)...


pass-4 script: delete.stp
----------------------------------------
#! stap -p4

global a, b, c, d, e, f

probe begin {
    a = 1; delete a;
    b = "b"; delete b;
    c <<< 1; delete c;
    d[1] = 1; delete d[1]; delete d;
    e[1] = "e"; delete e[1]; delete e;
    f[1] <<< 1; delete f[1]; delete f;

    x = 1; delete x;
    y = "y"; delete y;
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]