This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
[Bug translator/11556] New: @cast() with array indexing on pointers
- From: "dsmith at redhat dot com" <sourceware-bugzilla at sourceware dot org>
- To: systemtap at sources dot redhat dot com
- Date: 28 Apr 2010 21:11:10 -0000
- Subject: [Bug translator/11556] New: @cast() with array indexing on pointers
- Reply-to: sourceware-bugzilla at sourceware dot org
While working on bug #9871, I tried to rewrite _get_fopv_size() from vfs.stp
from embedded-C into script language.
Here's the original embedded-C function:
function _get_fopv_size:long (iov:long, nr_segs:long)
%{ /* pure */
struct iovec *iovp = (struct iovec *)(long)THIS->iov;
if (iovp) {
int i;
THIS->__retvalue = 0;
for (i = 0 ; i < THIS->nr_segs ; i++)
THIS->__retvalue += kread(&(iovp[i].iov_len));
} else
THIS->__retvalue = -1;
CATCH_DEREF_FAULT();
%}
Here's my script language conversion:
function _get_fopv_size:long (iovp:long, nr_segs:long)
{
if (iovp) {
val = 0
for (i = 0; i < nr_segs; i++)
val += @cast(iovp, "iovec")[i]->iov_len
return val
}
return -1
}
But this fails with an error:
semantic error: invalid access '[i]' for struct iovec: operator '[' at
/usr/local/share/systemtap/tapset/vfs.stp:134:31
source: val += @cast(iovp, "iovec")[i]->iov_len
^
I asked Josh, who implemented @cast(), about this, and he said:
> Right, well we actually do support array indexing on pointers. The
> issue is a complication in the way @cast works. When we normally do
> array access on pointers, we're looking at a type DIE of a pointer. For
> the @cast, we're looking at the actual struct DIE rather than a pointer DIE.
>
> I think we could make this work though, perhaps adding a special-case
> for having an array access as the first component in @cast. It
> shouldn't be too hard to do the pointer arithmetic first and then
> proceed normally. (Famous Last Words...)
So, I'd like @cast to be able to do array indexing on pointers.
--
Summary: @cast() with array indexing on pointers
Product: systemtap
Version: unspecified
Status: NEW
Severity: enhancement
Priority: P2
Component: translator
AssignedTo: systemtap at sources dot redhat dot com
ReportedBy: dsmith at redhat dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=11556
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.