Questions tagged [strace]

strace is a Linux/UNIX tool for logging and analysing the system calls made by a user-side process.

strace is a diagnostic, debugging and instructional userspace utility for Linux. It is used to monitor interactions between processes and the Linux kernel, which include system calls, signal deliveries, and changes of process state. The operation of strace is made possible by the kernel feature known as .

Use this tag to ask programming questions related to the strace command and the strace() system call.

Source: Wikipedia

485 questions
298
votes
12 answers

How should strace be used?

A colleague once told me that the last option when everything has failed to debug on Linux was to use strace. I tried to learn the science behind this strange tool, but I am not a system admin guru and I didn’t really get results. So, What is it…
Bite code
  • 578,959
  • 113
  • 301
  • 329
149
votes
1 answer

Prevent strace from abbreviating arguments?

I'm trying to use strace to find out what commands a program executes using execve. Some of the arguments in these commands are quite long, and strace is abbreviating the arguments to execve (I see "..." after about 30 characters), preventing me…
Jay Conrod
  • 28,943
  • 19
  • 98
  • 110
143
votes
1 answer

Equivalent of strace -feopen < command > on mac os X

This is useful for debugging (hence programming related). On linux, we can use the command strace -feopen python myfile.py to figure out which python modules and shared objects are loaded. Is there an equivalent one-liner on macOS X?
Setjmp
  • 27,279
  • 27
  • 74
  • 92
137
votes
16 answers

How to solve "ptrace operation not permitted" when trying to attach GDB to a process?

I'm trying to attach to a program with GDB but it returns: Attaching to process 29139 Could not attach to process. If your uid matches the uid of the target process, check the setting of /proc/sys/kernel/yama/ptrace_scope, or try again as the root…
bbaytemir
  • 1,471
  • 2
  • 10
  • 5
133
votes
4 answers

How to track child process using strace?

I used strace to attach to a process briefly. The process created 90 threads. When I found the offending thread, I had to tediously search for the parent thread, then the grandparent thread, and so on all the way to the root process. Is there a…
projectshave
  • 3,771
  • 5
  • 23
  • 24
121
votes
3 answers

How to trace system calls of a program in Mac OS X?

I wanted to trace the system calls made by the find command to debug some performance issues however I could not figure out how to do this on Mac OS X Yosemite. How can I trace system calls for an arbitrary program similarly to what strace does on…
Michaël Le Barbier
  • 6,103
  • 5
  • 28
  • 57
99
votes
9 answers

Systrace for Windows

I'm looking for a Windows equivalent of Systrace or at least strace. I'm aware of StraceNT, but wondering if there are any more alternatives out there. Specifically, I'm looking for a specific way to programmatically enforce system call policies,…
Bryan
  • 2,068
  • 2
  • 15
  • 18
69
votes
3 answers

Get all modules/packages used by a python project

I have a python GUI application. And now I need to know what all libraries the application links to. So that I can check the license compatibility of all the libraries. I have tried using strace, but strace seems to report all the packages even if…
user2109788
  • 1,266
  • 2
  • 12
  • 29
68
votes
2 answers

How does strace connect to an already running process?

I do know that strace uses ptrace to do the job, but it needs to run the target process with TRACE_ME on, which don't apply for the case of an already running process. how does it work on an already running process?
new_perl
  • 7,345
  • 11
  • 42
  • 72
64
votes
9 answers

How can I get dtrace to run the traced command with non-root priviledges?

OS X lacks linux's strace, but it has dtrace which is supposed to be so much better. However, I miss the ability to do simple tracing on individual commands. For example, on linux I can write strace -f gcc hello.c to caputre all system calls, which…
Gyom
  • 3,773
  • 5
  • 29
  • 38
39
votes
1 answer

How does ptrace work in Linux?

The ptrace system call allows the parent process to inspect the attached child. For example, in Linux, strace (which is implemented with the ptrace system call) can inspect the system calls invoked by the child process. When the attached child…
daehee
  • 5,047
  • 7
  • 44
  • 70
39
votes
0 answers

Difference between gdb, valgrind, strace, ltrace and apport

I'm looking for the difference between the following debugging tools. What are those? E: On the off chance that somebody stumbles in here and was wondering about the same thing the "differences" are (shortened from the man pages): GDB Allows you to…
Det
  • 3,640
  • 5
  • 20
  • 27
38
votes
2 answers

Stracing to attach to a multi-threaded process

If I want to strace a multi-threaded process (of all of its threads), how should I do it? I know that one can do strace -f to follow forked process? But how about attaching to a process which is already multi-threaded when I start stracing? Is a…
yangsuli
  • 1,252
  • 5
  • 16
  • 33
35
votes
2 answers

What do these strace system calls mean?

I need to profile the performance of an application for which I am using strace. However, I do not really know how to interpret the various system calls the strace emits. Examples of a few of them are below: (A) lseek(3, 1600, SEEK_SET) …
Ketan Maheshwari
  • 2,002
  • 3
  • 25
  • 31
25
votes
4 answers

Show complete arguments in strace even in curly brackets

I know the -s option should display longer arguments, but it doesn't work always (probably because of those curly brackets meaning array or nested arguments?). Even after running strace -s1000 my_command this argument is still truncated: ioctl(3,…
Marki555
  • 6,434
  • 3
  • 37
  • 59
1
2 3
32 33