From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12198 invoked by alias); 6 Dec 2012 23:11:40 -0000 Received: (qmail 12187 invoked by uid 22791); 6 Dec 2012 23:11:39 -0000 X-SWARE-Spam-Status: No, hits=-6.1 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 06 Dec 2012 23:11:33 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qB6NBWrU012793 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 6 Dec 2012 18:11:33 -0500 Received: from fche.csb (vpn-11-103.rdu.redhat.com [10.11.11.103]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id qB6NBWi0032189; Thu, 6 Dec 2012 18:11:32 -0500 Received: by fche.csb (Postfix, from userid 2569) id B30D15816B; Thu, 6 Dec 2012 18:11:31 -0500 (EST) To: Mehul Choube Cc: "systemtap@sourceware.org" Subject: Re: script compilation fails at 'Pass 4' References: From: fche@redhat.com (Frank Ch. Eigler) Date: Thu, 06 Dec 2012 23:11:00 -0000 In-Reply-To: (Mehul Choube's message of "Thu, 6 Dec 2012 01:38:32 -0800") Message-ID: User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Mailing-List: contact systemtap-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: systemtap-owner@sourceware.org X-SW-Source: 2012-q4/txt/msg00261.txt.bz2 Mehul_Choube wrote: > http://pastebin.com/vyKHBGd0 sockname() can't work like that. Systemtap embedded-C code runs within the kernel, and can't call userspace glibc functions or system calls like that. Try instead: ######################################################################## function print_fd(fd) { task = task_current() sock = task_file_handle_socket(task,fd) if (sock) { fam = socket_family(sock) if (fam == %{ AF_INET %}) { printf("%s[%d] fd %d: %s\n", execname(), tid(), fd, socket_ipv4_sockname(sock)) return 0 } /* other cases as per pfiles.stp */ } } probe syscall.connect.return { if ($return >= 0) print_fd($return) } /* the rest verbatim from pfiles.stp */ %{ #include #include #include #include #include %} function task_file_handle_socket:long (task:long, fd:long) %{ /* pure */ struct task_struct *p = (struct task_struct *)((long)STAP_ARG_task); struct files_struct *files; struct file *filp; struct dentry *dentry; struct inode *inode; rcu_read_lock(); if ((files = kread(&p->files)) && (filp = fcheck_files(files, STAP_ARG_fd)) && (dentry = kread(&filp->f_dentry)) && (inode = kread(&filp->f_dentry->d_inode))) { if (S_ISSOCK(kread(&inode->i_mode))) STAP_RETVALUE = (long)SOCKET_I(inode); } CATCH_DEREF_FAULT(); rcu_read_unlock(); %} function socket_family:long (sock:long) %{ /* pure */ struct socket *sock = (struct socket *)((long)STAP_ARG_sock); const struct proto_ops *ops = kread(&sock->ops); STAP_RETVALUE = (long)kread(&ops->family); CATCH_DEREF_FAULT(); %} function socket_ipv4_sockname:string (sock:long) %{ /* pure */ struct socket *sock = (struct socket *)((long)STAP_ARG_sock); const struct proto_ops *ops = kread(&sock->ops); struct sockaddr_in in_addr; __be32 addr, port; int err, len; err = ops->getname (sock, (struct sockaddr*)(&in_addr), &len, 0); if (!err) { addr = in_addr.sin_addr.s_addr; port = htons(in_addr.sin_port); snprintf(STAP_RETVALUE, MAXSTRINGLEN, " sockname: AF_INET " NIPQUAD_FMT " port: %d", NIPQUAD(addr), port); } CATCH_DEREF_FAULT(); %}