ltrace命令是用来跟踪进程调用库函数的情况。

ltrace -h
Usage: ltrace [option ...] [command [arg ...]]
Trace library calls of a given program.

-a, --align=COLUMN align return values in a secific column.
-A MAXELTS maximum number of array elements to print.
-b, --no-signals don't print signals.
-c count time and calls, and report a summary on exit.
-C, --demangle decode low-level symbol names into user-level names.
-D, --debug=MASK enable debugging (see -Dh or --debug=help).
-Dh, --debug=help show help on debugging.
-e FILTER modify which library calls to trace.
-f trace children (fork() and clone()).
-F, --config=FILE load alternate configuration file (may be repeated).
-h, --help display this help and exit.
-i print instruction pointer at time of library call.
-l, --library=LIBRARY_PATTERN only trace symbols implemented by this library.
-L do NOT display library calls.
-n, --indent=NR indent output by NR spaces for each call level nesting.
-o, --output=FILENAME write the trace output to file with given name.
-p PID attach to the process with the process ID pid.
-r print relative timestamps.
-s STRSIZE specify the maximum string size to print.
-S trace system calls as well as library calls.
-t, -tt, -ttt print absolute timestamps.
-T show the time spent inside each call.
-u USERNAME run command with the userid, groupid of username.
-V, --version output version information and exit.
-x FILTER modify which static functions to trace.

https://blog.csdn.net/macky0668/article/details/6839520

运行strace,出现问题:

ptrace: Operation not permitted.

早上发现一个进程没有相应, 试图gdb之.

(gdb) attach 30721
Attaching to program: /data0/s/bin/s, process 30721
ptrace: Operation not permitted.

晕倒, 俺已经是sudo权限了. 后来看到一篇博客说:当他已经在 gdb 某个进程时, 试图再利用 gcore 来手动产生一个 core 文件而不得(可以在gdb下用 generate-core-file 完成), 我有所启发, 莫非还有别人在gdb 这个进程.

ps 一下, 发现我的猜想是对的, 我进一步猜想, strace 也应该会失败.

0> strace -p 30721
attach: ptrace(PTRACE_ATTACH, ...): Operation not permitted

果然如此, 两者都用到了 ptrace 这个系统调用.  man ptrace 可以查看详情:

The  ptrace  system  call provides a means by which a parent process may observe and control the execution of another pro-cess, and examine and change its core image and registers.  It is primarily used to  implement  breakpoint  debugging  and system call tracing.

看linux内核详解的话, 应该能给出更深层次的解释, 我现在还留在意会阶段.

 
 
 

linux申请strace ,lstrace, ptrace, dtrace的更多相关文章

  1. Linux利器 strace [看出process呼叫哪個system call]

    Linux利器 strace strace常用来跟踪进程执行时的系统调用和所接收的信号. 在Linux世界,进程不能直接访问硬件设备,当进程需要访问硬件设备(比如读取磁盘文件,接收网络数据等等)时,必 ...

  2. linux神器strace

    man strace: strace - trace system calls and signals DESCRIPTION In the simplest case strace runs the ...

  3. Finding the source of signals on Linux with strace, auditd, or systemtap

    inux and UNIX® like operating systems commonly use signals to communicate between processes. The use ...

  4. 使用strace,lstrace,truss来跟踪程序的运行过程

    使用truss.strace或ltrace诊断软件问题 2008-07-05 16:25 使用truss.strace或ltrace诊断软件问题          进程无法启动,软件运行速度突然变慢, ...

  5. Linux调试工具strace和gdb常用命令小结

    strace和gdb是Linux环境下的两个常用调试工具,这里是个人在使用过程中对这两个工具常用参数的总结,留作日后查看使用. strace调试工具 strace工具用于跟踪进程执行时的系统调用和所接 ...

  6. linux下strace命令详解

    简介 strace常用来跟踪进程执行时的系统调用和所接收的信号. 在Linux世界,进程不能直接访问硬件设备,当进程需要访问硬件设备(比如读取磁盘文件,接收网络数据等等)时,必须由用户态模式切换至内核 ...

  7. oracle linux 7.3 下用dtrace 跟踪 mysql-community-server-5.6.20

    第一部分:oracle linux 7.3 dtrace 安装: http://public-yum.oracle.com/   内核升极到 [root@server1 SPECS]# uname - ...

  8. 使用 Linux 的 strace 命令跟踪/调试程序的常用选项

    原文:http://linoxide.com/linux-command/linux-strace-command-examples/作者: Raghu 在调试的时候,strace能帮助你追踪到一个程 ...

  9. linux下 玩转ptrace

    译者序:在开发Hust Online Judge的过程中,查阅了不少资料,关于调试器技术的资料在网上是很少,即便是UNIX编程巨著<UNIX环境高级编程>中,相关内容也不多,直到我在 ht ...

随机推荐

  1. BP

    下面内容抄袭这里的:galaxy.agh.edu.pl/~vlsi/AI/backp_t_en/backprop.html Principles of training multi-layer neu ...

  2. 项目启动报错java.net.SocketException: Unrecognized Windows Sockets error: 0: JVM_Bind

    项目已启动的情况下,MyEclipse异常退出.再次打开后重启项目,项目报错:java.net.SocketException: Unrecognized Windows Sockets error: ...

  3. 洛谷P1182 数列分段【二分】【贪心】

    题目:https://www.luogu.org/problemnew/show/P1182 题意: 有n个数,要分成连续的m段.将每段中的数相加,问之和的最大值的最小值是多少. 思路: 和P1316 ...

  4. 洛谷P1192 台阶问题【记忆化搜索】

    题目:https://www.luogu.org/problemnew/show/P1192 题意: 给定n和k,一个人一次可以迈1~k步,问走n步有多少种方案. 思路: 本来傻乎乎上来就递归,显然会 ...

  5. [No0000CE]检测非空格字符作为密码的密码强度

    Regex.Replace(pwd, "^(?:([a-z])|([A-Z])|([0-9])|(.)){6,}|(.)+$", "$1$2$3$4$5").L ...

  6. linux 编程

    edit skill: 1. i:当前光标前插入 2. a:当前光标后插入 3. SHIFT+a—行尾插入 4. SHIFT+i—行首插入 5. o—>下一行插入 6. SHIFT+o--上一行 ...

  7. iOS ARC编译器规则和内存管理规则

    iOS 开发当中,自动引用计数已经是标准的内存管理方案.除了一些老旧的项目或者库已经没有人使用手动来管理内存了吧. ARC无疑是把开发者从繁琐的保留/释放引用对象逻辑中解脱出来.但这并不是万事大吉了, ...

  8. Sethi model

    小结: 1. 销量 广告 微分方程 动态系统 市场份额 https://en.wikipedia.org/wiki/Sethi_model The Sethi model was developed ...

  9. 新的ipad,用xcode编译报错 dyld_shared_cache_extract_dylibs

    删掉  ~/Library/Developer/Xcode/iOS DeviceSupport/ 这个目录下的特定文件夹就行啦. 其实是因为  device is busy  生成文件夹过程中拔掉了设 ...

  10. Linux svn服务器搭建

    一.安装 yum -y install subversion 二.建立版本库目录 mkdir /var/svn/svnrepos 三.创建svn版本库 svnadmin create /var/svn ...