Bug 4166 - Should support array-like indexing on $pointer variables
Summary: Should support array-like indexing on $pointer variables
Status: RESOLVED FIXED
Alias: None
Product: systemtap
Classification: Unclassified
Component: translator (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Josh Stone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-03-07 10:06 UTC by Olivier Mengué
Modified: 2009-07-15 01:43 UTC (History)
0 users

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 Olivier Mengué 2007-03-07 10:06:14 UTC
% ./crash-c_translate_array.stp
stap: loc2c.c:1584: c_translate_array: Assertion `dwarf_tag (typedie) ==
DW_TAG_array_type' failed.
Aborted (core dumped)
% cat ./crash-c_translate_array.stp
#!/usr/bin/env stap

probe syscall.execve
{
  print($argv[0])
  exit()
}
% stap -V
SystemTap translator/driver (version 0.5.4 built 2006-02-02)
Copyright (C) 2005-2006 Red Hat, Inc. and others
This is free software; see the source for copying conditions.
% cat /etc/redhat-release
Red Hat Enterprise Linux ES release 4 (Nahant Update 3)
% gcc -v
Reading specs from /usr/lib/gcc/x86_64-redhat-linux/3.4.5/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-java-awt=gtk --host=x86_64-redhat-linux
Thread model: posix
gcc version 3.4.5 20051201 (Red Hat 3.4.5-2)
%
Comment 1 Roland McGrath 2007-03-07 11:15:06 UTC
The translator is responsible for checking Dwarf types and calling c_translate_*
with only the appropriate DIE flavor for each call.  To support C-style use of
pointers with array syntax, it needs to use c_translate_pointer+addressof, then
do its own arithmetic.  c_translate_array could be extended to do this for
DW_TAG_pointer, but still it looks like the translator is not checking types
before calling loc2c.
Comment 2 Frank Ch. Eigler 2007-03-07 15:48:23 UTC
A patch has been committed to produce a cleaner exception for this case
rather than an assertion failure.  However, the code does not support pointer
arithmetic yet, so I'll relabel this bug to track this enhancement.
Comment 3 Josh Stone 2009-07-15 01:43:39 UTC
Fixed in commit d52761f8.

(In reply to comment #0)
> probe syscall.execve
> {
>   print($argv[0])
>   exit()
> }

Note that this still probably doesn't work as the author intended, as it will
print just the pointer to the argv[0].  To get the string value, one would need
to call user_string($argv[0]).