From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Tue, 27 May 2014 14:30:18 -0700 From: Nick Owens To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Message-ID: <20140527213018.GQ3763@iota.offblast.org> References: <20140527201016.GP3763@iota.offblast.org> <0e05f8946ce2cff4a4ad7d2e044b984d@ladd.quanstro.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="BouVgDkIlpb7X6Bk" Content-Disposition: inline In-Reply-To: <0e05f8946ce2cff4a4ad7d2e044b984d@ladd.quanstro.net> User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [9fans] 8l -e Topicbox-Message-UUID: f2dc67c4-ead8-11e9-9d60-3106f5b1d025 --BouVgDkIlpb7X6Bk Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, May 27, 2014 at 04:16:24PM -0400, erik quanstrom wrote: > > you can see there is a JMP over _tracein and a RET before _traceout. > > what gives? >=20 > ah, that's the magic! the idea is to be able to enable and disable these= tracepoints > at runtime in a multiprocessor environment without any locking. >=20 > - erik >=20 ok. i'm beginning to understand better. is there a specific use case, such as the kernel or userland? i didn't see anything like a tool that could poke nops into the right places. i started to write an acid function to put the nops in one named function, and then i realized that the ret can appear several times in one function and i would need to search for and patch them out. but only the *first* ret, not second, e.g.: setvar+0x3a 0x0000adf5 RET <--- should be NOP setvar+0x3b 0x0000adf6 CALL _traceout(SB) setvar+0x40 0x0000adfb RET <--- should not be NOP i was able to patch the JMP, and the RET but only in the case where it appears at the bottom of a function. defn traceon(fn){ bound =3D fnbound(fn); // nop first jmp *(bound[0]) =3D 0x90\b; *(bound[0]+1) =3D 0x90\b; // and the ret // XXX should search for ret *(bound[1]-7) =3D 0x90\b; } maybe these were not the droids i was looking for. my real goal is to make timing statistics for function calls in a program. perhaps this goal is better fulfilled simply by prof! --BouVgDkIlpb7X6Bk Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.13 (OpenBSD) iQIcBAEBAgAGBQJThQPqAAoJEAlFY6k1Rs31imgP/3h5jdWO+RLPumjxFtGXnYDp PkcRHFVgUcXceGnXWF1u2W6huEefSqRvvudb8C2rcIA7Gb+PMmpHttW8eqDVtHES 0mXTTCIlHMfMSAr4b7UB1m0rk4vx3Cv0id6/SqnuWPNFfwqAdCgev9WnINs9LCCt 6WxMT4UAfeTeEeBA2ECiuJrGpI+WIqpM3FeWLhE2iRtS5blQoW22+BX54T9emPCB 5U4mEFDM1Q2xulmq4TwJmRH5cpOpOyCKPAO8mHb+R2A1Li/dYbWICXTzjBQ87oBm HpU4pkS1xOda2X0p+dSEZugzIF0u2E2twXFJBoVrry79GIRXzf+0/+w339TFlprM 4oR/u0MT5m7pVejBF5TjPXZncPqZ7a+QB53NQRd5zQmdLkn0m8RVu51W5nMDjyTy PU+RX1JnufxnACcOUToTO4ZnfQfcl0swLPMtYWYMouoVJej+ifjIBtxcUhD74VCz cUZ1Nyqmsj4TF0d9AIkAizFTQiirhQXYX48JqI1SD88gC7+6oVd6GrEQfsNyPGeX +uuDqXo2WMdoflK7zggmsJyaBkBLvmBVeqkN0kQMUq4jvc1IBZGU2VpH1Xp88yQ0 n348kHbV2QsYEZwHi2HueqU6eiszJCdqxP3u6OJKR1/kXHsyhyrL4hp3Ii2EJ2DQ VE7GPwTYaYpHJf1dQ9iz =8eXT -----END PGP SIGNATURE----- --BouVgDkIlpb7X6Bk--