Distributions
› Ubuntu
› Fedora
› CentOS
中文资源站
› 网易开源镜像站
blueberryman
V2EX  ›  Linux

有没有人知道怎么能看到函数真实的系统调用

  •  
  •   blueberryman · Sep 12, 2019 via Android · 5012 views
    This topic created in 2612 days ago, the information mentioned may be changed or developed.

    我现在想到的就是用 strace 看带 pthread_con_wait 函数的文件,但是这样的话,pthread_con_wait 的系统调用会跟其它的函数混在一起,有什么办法能直接看到吗?或者 linux 官方有说明文档吗?感觉 man 的东西太少了,没说实现原理

    8 replies  •  2019-11-12 18:00:52 +08:00
    nthhdy
    nthhdy
    Sep 12, 2019
    1
    直接看到是指啥?
    strace + grep 不行吗
    feather12315
    feather12315
    Sep 12, 2019 via Android
    2
    ltrace 看 library 调用,
    strace 看 syscall 调用
    ipoh
    ipoh
    Sep 12, 2019
    3
    直接看库函数的源代码
    blueberryman
    blueberryman
    OP
    Sep 15, 2019 via Android
    4
    @nthhdy 行是行,但是我得写一个应用该函数的程序才能用 strace 跑,我能不能知道函数名直接就找到函数源码
    yumenami
    yumenami
    Sep 16, 2019
    5
    具体啥需求?
    之前写了一个静态分析内核代码的程序,记录函数和文件的关系,然后调用的时候做匹配
    但是 bad case 太多了,而且很多指针的调用也分析不到
    不少情况不如直接用 strace 跑
    blueberryman
    blueberryman
    OP
    Sep 16, 2019 via Android
    6
    @yumenami 前几天在跟同事讨论 pthread_condition_wait 是不是线程安全时,寻思看看其内部的实现机制,但是找不到合适的方法。我想到了一个,用 strace。但是用 strace 得先编好一个的程序,再运行它,才能查看其实现原理。如果我想直接查看某个函数的实现原理,有什么好办法吗?
    nthhdy
    nthhdy
    Oct 7, 2019
    7
    @blueberryman 那不是应该看 pthread_condition_wait 的实现源码么。而且 pthread_condition_wait 这个函数是实现线程间通信、处理竞争条件的原语,不存在说这个函数本身是不是线程安全。
    cmingxu
    cmingxu
    Nov 12, 2019
    8
    strace -p <pid> -e pthread_con_wait 可以么
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   3619 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 121ms · UTC 05:18 · PVG 13:18 · LAX 21:18 · JFK 00:18
    ♥ Do have faith in what you're doing.