From owner-freebsd-dtrace@FreeBSD.ORG Fri Jun 6 11:40:16 2014 Return-Path: Delivered-To: freebsd-dtrace@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 9AD647C1; Fri, 6 Jun 2014 11:40:16 +0000 (UTC) Received: from nexus.ut.mephi.ru (nexus.ut.mephi.ru [85.143.112.92]) by mx1.freebsd.org (Postfix) with ESMTP id 19CBE25C1; Fri, 6 Jun 2014 11:40:15 +0000 (UTC) Received: from [85.143.112.127] (unknown [85.143.112.127]) (using TLSv1 with cipher ECDHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: dyokunev@ut.mephi.ru) by nexus.ut.mephi.ru (Postfix) with ESMTPSA id 42E1322E1A62; Fri, 6 Jun 2014 15:40:07 +0400 (MSK) Message-ID: <5391A8B4.4030906@ut.mephi.ru> Date: Fri, 06 Jun 2014 15:40:36 +0400 From: Dmitry Yu Okunev Organization: NRNU MEPhI User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Icedove/24.4.0 MIME-Version: 1.0 To: Mark Johnston Subject: Re: failed to resolve cwd: Unknown variable name References: <5388A227.7050805@ut.mephi.ru> <538EAAF1.1030005@ut.mephi.ru> In-Reply-To: X-Enigmail-Version: 1.6 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="fTouAIcmO3bwgWq656h71xuXKm6vmEQr6" X-LastMilter: passed X-LastMilter-Score: 0 Cc: freebsd-dtrace@freebsd.org X-BeenThere: freebsd-dtrace@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "A discussion list for developers working on DTrace in FreeBSD." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Jun 2014 11:40:16 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --fTouAIcmO3bwgWq656h71xuXKm6vmEQr6 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 06/04/2014 05:25 PM, Mark Johnston wrote: > On Wed, Jun 4, 2014 at 1:13 AM, Dmitry Yu Okunev = wrote: >> On 06/04/2014 06:28 AM, Mark Johnston wrote: >>> On Fri, May 30, 2014 at 11:22 AM, Dmitry Yu Okunev wrote: >>>> But when I try to use the variable I get a failure: >>>>> dtrace: invalid probe specifier syscall:::entry { printf("%s", cwd)= ; >>>> }: in action list: failed to resolve cwd: Unknown variable name >>>> >>>> You can get the same error by running a dtrace-script from official >>>> FreeBSD distribution: >>>>> /usr/share/dtrace/toolkit/opensnoop -c >>> So one can get a bit of the way there with something ugly like >>> >>> inline string cwd =3D >>> stringof(curthread->td_proc->p_fd->fd_cdir->v_cache_dst.tqh_first->nc= _name); >>> >>> to get the last component of a process' cwd (it needs a check for a >>> missing cache entry), but I don't see any easy way to get at the full= >>> cwd. Calling vn_fullpath() in probe context would be a pretty bad ide= a >>> since it may invoke VFS operations >> >> Hm. If it's performance problem only, then personally I can endure tha= t. >> >> Can I use vn_fullpath*() in dtrace probes on current FreeBSD? >=20 > It's a safety thing. DTrace probes execute with interrupts disabled, > so they're fairly limited in what they're allowed to do. Name > resolution potentially requires the underlying filesystem code to read > from disk or invoke an RPC, which cannot be done in probe context. > Hence my suggestion of a cache-only lookup function that could be > callable from within a probe. Well. Here're two problems: 1. The solution returns only the last component of cwd. How to get the rest? I can handle it myself (if it's possible), but if somebody already have working solution that would be great :) 2. Is this solution steady to FreeBSD version updates? I think that this headers can be changed with every major version. --=20 Best regards, Dmitry, head of UNIX-tech department NRNU MEPhI, tel. 8 (495) 788-56-99, ext. 8255 --fTouAIcmO3bwgWq656h71xuXKm6vmEQr6 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Using GnuPG with Icedove - http://www.enigmail.net/ iQIcBAEBAgAGBQJTkai1AAoJEK2K5AyOMGec2X8QALJIHX2zuZ+2JtqFZ1ONoE1f 2GHzB29EkpNgdsVh2pdlGjUN+PaTQlh3aUJknqrfxpXidvfYnkwy5FRUEuBRSHcT Ne/FXsERE8lbfgP8Av/EF/lbFOM0lfbIKFT6IEldv+/6Zb2SSBBE9lKzyQWmOTbp gbFFsc2KbXPxG30/ARXI9ElbLsG/7n3WVN6It2WMt9uaxyOAVFdMvfpBA2SmlwLj age9BQNwyBt8p8mrf+zAjH/Ex2Q4VG3XFRNDHGD2p0YjWuZDxuV5qT0xu7us9R+A rpG6H04fhLHfldlsY7Lqbu2VykVsz2odoECiVLkSU3vkoj8vRuh7xXFx4s0uG08V H6WTYe3FNrBMzO/o26Pg6kbpTksWDiCa7NVboysJxQeGVdiHWyeku1zwRiEwFxCa c/GdRkGRzqYj3yUo9qnYeXg8RGDZQ7kRD+J0gjQas7Mj4mPB+8aYfZ+RopykYiDF IvOlBTd8KCyRnhZWdsERWz7OOeiUQjtWv88/bYhB9E+VMl6p9HO2KfkDlL4WUcuP kMtyH73kboMl5QfQyieJmN1tP3ompTa/uCYiBUnFrW3kJxrgHBoycs6b3zBYJXYh nv3FClp1qsf1tZeZxmeIxlaNymHWGwRf+7bLjmI3J9tP6XL+zCz8ZbzenPJ3Vz/A IEJfmSuHaykN/pY64jV3 =LDuB -----END PGP SIGNATURE----- --fTouAIcmO3bwgWq656h71xuXKm6vmEQr6--