[cfe-dev] tooling helper

Sean Silva silvas at purdue.edu
Mon Nov 19 10:53:51 PST 2012


There's already a premade script for this, actually. It's
DTTk/execsnoop in
<http://opensource.apple.com/tarballs/dtrace/dtrace-96.tar.gz>. It's a
bit more sophisticated than the one-liner I was thinking of but it
should work "out of the box" for your use case. The "meat" of it
though is basically

dtrace -n 'syscall::execve:return'

which should basically just indicate when processes exec. The script
just adds the usual DTrace contortions to dig out the relevant info. I
think you could also possibly do this with the proc provider on
proc:::create, but I don't currently have a machine with DTrace to
mess around on.

On Mon, Nov 19, 2012 at 6:23 AM, Laszlo Nagy
<rizsotto.mailinglist at gmail.com> wrote:
> Hi Sean,
>
> yes please, I am interested to know what other way I can do that. Basically
> I know 3 ways to do it on Linux: #1 use compiler wrapper scripts and hook
> them into the chain via CC and CXX environment variable. #2 this LD_PRELOAD
> trick. #3 try to intercept the exec calls with ptrace... Would be glad to
> know other ways as well... And if it is really easy to implement and
> integrate, I would do that happily.
>
> Regards,
> Laszlo
>
>
> On Sat, Nov 17, 2012 at 11:11 PM, Sean Silva <silvas at purdue.edu> wrote:
>>
>> > It runs the build command and intercept the 'exec' calls, filters the
>> > compiler invocations and generate the output file. (It is using
>> > LD_PRELOAD
>> > from GNU Libc, so it is not really portable.)
>>
>> FYI, this can be done ridiculously easily (it's basically a one-liner)
>> on platforms that support DTrace, which should be Mac and FreeBSD (and
>> of course Solaris and descendants, although there hasn't been a big
>> clang investment there). Let me know if you would like to integrate
>> this into the project and I can give you more information.
>>
>> -- Sean Silva
>>
>> On Sat, Nov 17, 2012 at 4:06 PM, Laszlo Nagy
>> <rizsotto.mailinglist at gmail.com> wrote:
>> > Hi,
>> >
>> > wrote a small program which might help to use the tools, which are using
>> > the
>> > tooling library. My understanding was that these tools need some
>> > compilation
>> > database. And one format is the JSON compilation database, which comes
>> > for
>> > free in a cmake project. Other projects could have difficulties to
>> > generate
>> > such file. And that's where a tool could help.
>> >
>> >   https://github.com/rizsotto/Bear
>> >
>> > It runs the build command and intercept the 'exec' calls, filters the
>> > compiler invocations and generate the output file. (It is using
>> > LD_PRELOAD
>> > from GNU Libc, so it is not really portable.)
>> >
>> > I know these kind of tools are out of scope here. But wanted to mention,
>> > because it could simplify to solve some cases. At least it did to me. ;)
>> >
>> > Regards,
>> > Laszlo
>> >
>> > _______________________________________________
>> > cfe-dev mailing list
>> > cfe-dev at cs.uiuc.edu
>> > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>> >
>
>



More information about the cfe-dev mailing list