How to trace system calls of a program in Mac OS X?
You can use dtruss like in
sudo dtruss find ~/repo -depth 2 -type d -name '.git'
The manual page of that utility will help you to tailor the use of the tool to your needs.
Mac OSX: Using dtruss?
This article explains how to accomplish this:
Enabling D-Trace on system with SIP
You can disable SIP entirely by doing the following:
- Reboot your mac
- Hold ⌘R during reboot
- From the Utilities menu, run Terminal
- Enter the following command
csrutil disable
Alternatively you can re-enable SIP while still allowing dtrace
to work by also running the following:
csrutil enable --without dtrace
Finding number of dlopen calls of an ELF binary in C
You could simply use ltrace
:
Example:
#include <dlfcn.h>
#include <stdio.h>
int main(int C, char **V)
{
char **a = V+1;
while(*a){
void *h;
if(0==(h=dlopen(*a++, RTLD_LAZY)))
fprintf(stderr, "%s\n", dlerror());
}
}
Compile it:
$ gcc example.c -fpic -pie
Invoke it on self and count dlopen
calls:
$ ltrace -o /dev/fd/3 \
./a.out ./a.out ./a.out ./a.out 3>&1 >/dev/null| \
grep ^dlopen\( -c
3
Related Topics
How to Boot the Linux Kernel Without Creating an Initrd Image
How to Read a Sector Using a Bio Request in Linux Kernel
Ubuntu Equivalent of Yum's Whatprovides, to Find Which Package Provides a File
Packet Sniffing Using Raw Sockets in Linux in C
Configure and Build Opencv to Custom Ffmpeg Install
How to Get Ec2 Load Balancing Properly Set Up to Allow for Real Time File Syncing
Compile Swift Script with Static Swift Core Library
Bash Scripting - Read Single Keystroke Including Special Keys Enter and Space
Errors in Make File:*** Missing Separator. Stop
Svg to PDF on a Shared Linux Server
Linux: Create Random Directory/File Hierarchy
Debugging in Pycharm with Sudo Privileges
Using a User's .Bashrc in a Systemd Service