Date: Fri, 06 Jun 2014 15:40:36 +0400 From: Dmitry Yu Okunev <dyokunev@ut.mephi.ru> To: Mark Johnston <markj@freebsd.org> Cc: freebsd-dtrace@freebsd.org Subject: Re: failed to resolve cwd: Unknown variable name Message-ID: <5391A8B4.4030906@ut.mephi.ru> In-Reply-To: <CAMw1wOw4dkUeOrrdbHqmO-A_qB09dMaCr_aDTJSfSvZ8Ku3EUg@mail.gmail.com> References: <5388A227.7050805@ut.mephi.ru> <CAMw1wOwMU--0tDEjnK%2BcWW00d=d%2B%2B8BVmSCQ7XbR85bMQ0fhWw@mail.gmail.com> <538EAAF1.1030005@ut.mephi.ru> <CAMw1wOw4dkUeOrrdbHqmO-A_qB09dMaCr_aDTJSfSvZ8Ku3EUg@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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 <dyokunev@ut.mephi.ru>= wrote: >> On 06/04/2014 06:28 AM, Mark Johnston wrote: >>> On Fri, May 30, 2014 at 11:22 AM, Dmitry Yu Okunev <dyokunev@ut.mephi= =2Eru> 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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5391A8B4.4030906>