Bug 3016 - error accessing anonymous struct/union memeber
Summary: error accessing anonymous struct/union memeber
Alias: None
Product: systemtap
Classification: Unclassified
Component: translator (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Unassigned
: 4519 (view as bug list)
Depends on:
Reported: 2006-08-09 08:09 UTC by Li Guanglei
Modified: 2008-10-01 11:39 UTC (History)
3 users (show)

See Also:
Last reconfirmed:


Note You need to log in before you can comment on or make changes to this bug.
Description Li Guanglei 2006-08-09 08:09:30 UTC
stap works fine with this script:

probe kernel.function("do_mpage_readpage")
  printf("%p", $page)

But it will generate an error with this script:

probe kernel.function("do_mpage_readpage")
        printf("%p", $page->mapping) 

stap -vv says:
Pass 1: parsed user script and 40 library script(s) in 310usr/0sys/372real ms.
probe do_mpage_readpage@fs/mpage.c:179 pc=0xc0000000000e716c
semantic error: unresolved target-symbol expression: identifier '$page' at

The struct page is defined in "include/linux/mm.h" and mapping is an anonymous
struct member of struct page:

struct page {
      unsigned long flags;
      atomic_t _count; 
      atomic_t _mapcount; 
      union {
          struct {
              unsigned long private;
              struct address_space *mapping;
Comment 1 David Smith 2006-08-09 20:00:51 UTC
I've duplicated this problem, and it only occurs with the anonymous struct. 
Accessing other 'struct page' members works correctly, i.e.:

probe kernel.function("do_mpage_readpage")
	printf("%p", $page->flags) 

Comment 2 Roland McGrath 2006-08-09 20:54:01 UTC
Yes, looking for anonymous structs/unions is just not handled.
I can whip up loc2c-test changes to support it, to give a model for what the
translator needs to do.  It's straightforward.
Comment 3 Prerna 2008-09-19 06:55:18 UTC
*** Bug 4519 has been marked as a duplicate of this bug. ***
Comment 4 Prerna 2008-09-26 06:24:34 UTC
Changed the translate_components() function of tapsets.cxx to call itself
recursively for every instance of anonymous struct / union present as a member
in a given struct/ union.
Comment 5 Mark Wielaard 2008-10-01 11:39:40 UTC
I adjusted the test case a little so that it works on both older and newer
kernels by using the mapping field as in the first comment.

commit dd4918442a55569175bda0575f746e84c99cee58
Author: Mark Wielaard <mjw@redhat.com>
Date:   Wed Oct 1 13:38:16 2008 +0200

    Adjust semok/thirtythree.stp test to pass on older kernels.

diff --git a/testsuite/ChangeLog b/testsuite/ChangeLog
index f3fad07..4825cd2 100644
--- a/testsuite/ChangeLog
+++ b/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2008-10-01  Mark Wielaard  <mjw@redhat.com>
+       * semok/thirtythree.stp: Use page->mapping instead of page->inuse
+       as annonymous struct value (also available in older kernels).
 2008-09-26  Frank Ch. Eigler  <fche@elastic.org>
        PR 6916.
diff --git a/testsuite/semok/thirtythree.stp b/testsuite/semok/thirtythree.stp
index d5171f6..9007037 100755
--- a/testsuite/semok/thirtythree.stp
+++ b/testsuite/semok/thirtythree.stp
@@ -1,5 +1,5 @@
 #! stap -p2
 # Per bz3016, this should get through the semantic pass without warnings.
 probe kernel.function("do_mpage_readpage") {
-       printf("\n page ->inuse %u",$page->inuse)
+       printf("\n page->mapping %p",$page->mapping)