strace

How to parse strace in shell into plain text?

一个人想着一个人 提交于 2019-11-27 23:19:09
I've trace log generated by strace command like on running PHP by: sudo strace -e sendto -fp $(pgrep -n php) -o strace.log And the output looks like: 11208 sendto(4, "set 29170397297_-cache-schema 85 0 127240\r\n\257\202\v\0?\0\0\0\2\27\10stdClass\24\7\21\3cid\21\6schema\21\4d\37ata\25\n\247\21\5block\24\6\21\6fields\24\f\21\3bid\24\2\5\21\4type 0\37erial\21\10not null\5\21\6module\24\4\16\7\21\7va\37rchar\21\6length\6@\16\t\5\21\7default\r\21\5de\2lta@ \5\16\v\16\f\6 \35\7\16\r\21\0010\21\5t \207 C \30@6\2\16\r\r n\4tatus@0\4\21\3int /\7\6\0\21\4size \222\finy\21\6weight\24\3 ;\0\22\300 \6

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

元气小坏坏 提交于 2019-11-27 20:03:13
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 FreeBSD? I am especially interested in tracing file-system related calls. jspcal 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. Under current versions of macOS, executables under paths covered by SIP (like /usr/bin ) cannot be

What is the difference between “$(cat file)”, “$(<file)” and “read … < file” for files with one line?

心不动则不痛 提交于 2019-11-27 18:13:55
问题 I have an input file that contains only one line: $ cat input foo bar I want to use this line in my script and there are 3 ways to get it that I know of: line=$(cat input) line=$(<input) IFS= read -r line < input For example, using command substitution means I spawn a subshell, whereas with read I do not, correct? What other differences are there and is one way preferred over the others? I also noticed (with strace ) that only read triggers the syscall openat for some reason. How is it

A lot of SIGSEGV while strace'ing java process

一世执手 提交于 2019-11-27 17:44:49
问题 Interesting stuff occurred while I debug one of the unit tests on CI server (maven build actually). I connect to java process with strace -ff -e trace=network -p [pid] to trace network activity of build process. And that's what I saw: Process 26324 attached Process 26325 attached (waiting for parent) Process 26325 resumed (parent 26312 ready) Process 26325 detached Process 26324 detached Process 26320 detached Process 26317 detached Process 26308 resumed [pid 26308] --- SIGCHLD (Child exited)

gdb break when program opens specific file

北城以北 提交于 2019-11-27 17:22:46
问题 Back story: While running a program under strace I notice that '/dev/urandom' is being open 'ed. I would like to know where this call is coming from (it is not part of the program itself, it is part of the system). So, using gdb, I am trying to break (using catch syscall open ) program execution when the open call is issued, so I can see a backtrace. The problem is that open is being called alot , like several hundred times so I can't narrow down the specific call that is opening /dev/urandom

Android: How to strace an app using ADB shell am start

怎甘沉沦 提交于 2019-11-27 11:23:02
问题 I need help on stracing Android apps in the SDK emulator. Here is my setup: I have an Android SDK emulator running the Android API 4.03 ADB shell connected to emulator. I am able to install an APK using the ADB install filename.apk I am able to run the app using the ADB shell am start -a android.intent.action.Main -n com.akproduction.notepad/com.akproduction.notepad.NoteList I try to strace using (ADB shell) strace am start -a android.intent.action.Main -n com.akproduction.notepad/com

How to track child process using strace?

痞子三分冷 提交于 2019-11-27 09:48:30
问题 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 trick or tool to quickly figure out which thread created another? Or better yet, print the tree of thread creations like pstree ? 回答1: strace -f to trace child process that's fork() ed. 回答2: There is a perl script called strace-graph . Here is a

MySQL 分析利器 strace & Perf

百般思念 提交于 2019-11-27 09:28:41
Perf   安装perf      yum install -y perf   执行:      perf top / grep " " * -r Strace介绍及用途   strace 是一个用于诊断,分析linux用户态进程的工具 (pstrace,losf, gbd, pstrack, pt-pmp) MySQL启动后会启动多少线程   strace /usr/local/mysql/bin/mysqld   # /usr/local/mysql/bin/mysqld --verbose --help | grep my.cnf   /etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf   my.cnf, $MYSQL_TCP_PORT, /etc/services, built-in default   操心系统查看:     ps -T `pidof mysqld`   利用pstack     pstack `pidof mysql`   推荐MySQL5.7以上的版本     select thread_id ,name from performanct_schema.threads 使用strace的正确姿势   最简单使用     strace -T -t -o /tmp

how to intercept linux signals ? (in C)

拈花ヽ惹草 提交于 2019-11-27 07:16:12
问题 I need to intercept and trace signals from any binaries, like strace does it under linux. I don't need a so verbose output like the real one strace. I just want to know how it works, how can I intercept signal and how can I trace them. Thanks in advance :) 回答1: strace uses the ptrace() system call for tracing, which also allows you to intercept (and possibly manipulate) signals sent to the process. Here's a tiny example: #include <sys/ptrace.h> #include <unistd.h> #include <sys/types.h>

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

烂漫一生 提交于 2019-11-27 05:53:16
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? I suppose you meant strace -fetrace=open ? dtruss -f -t open python myfile.py 来源: https://stackoverflow.com/questions/1925978/equivalent-of-strace-feopen-command-on-mac-os-x