【问题标题】:Systemtap script to C code conversion and compilationSystemtap 脚本到 C 代码的转换和编译
【发布时间】:2012-04-10 18:38:15
【问题描述】:

我的学期项目是网络级反恶意软件。它的主要组件是Manager和Agent。 Agent 为 Manager 提供:

1. CPU usage, Memory usage and B/W usage information

2. Network related Information - 

    Network Profiling
    Function calls from Network Sockets
    TCP packets related information

3. Disk Related Information - 

    I/O monitoring
    File Read/Writes
    File Attribute changes

4. General Profiling

    Function calls
    Call Graph
    Frequently used system calls
    call volume per process

这四个功能中的每一个都以线程的形式实现。我们的平台是Linux。我们找到了一个叫systemtap的工具……

http://sourceware.org/systemtap/SystemTap_Beginners_Guide/useful-systemtap-scripts.html

我们发现这是一个更好的选择,而不是利用诸如 top、ifstat、tcpdump 等 linux 命令。实际上,所有要做的就是从代理 Java 程序调用脚本或可执行文件。

“systemtap”使用的所有脚本都是用 systemtap 脚本语言编写的。前端工具(stap)将此脚本转换为C代码,然后编译为内核文件。

stap --tmpdir=/home/test/nettop.stp

通过使用上面的命令,我已经设法获得了转换后的C代码文件。但是由于依赖问题,文件没有被编译。

gcc nettop.c nettop.c:10:29:致命错误:runtime_defines.h:没有这样的文件或目录 编译终止。

gcc -B /usr/share/systemtap/runtime/ -B /usr/src/kernels/3.3.1-3.fc16.x86_64/include/nettop.c nettop.c:10:29:致命错误:runtime_defines.h:没有这样的文件或目录 编译终止。

gcc --sysroot=/usr/nettop.c nettop.c:10:29:致命错误:runtime_defines.h:没有这样的文件或目录 编译终止。

systemtap 运行时标头都使用 linux/header 格式,表示 systemtap 的类路径设置为 /usr/../../../。 。/包括。将所有标题复制到特定文件夹很容易,但编辑它们以反映正确的路径名称是不可能的。有 106 个运行时标头引用超过一千个 linux 标头。

一个。 如何让 gcc 使用特定文件夹作为库?

b. 此代理架构是否有更好的替代方案?

PS:希望这个问题不要太含糊。感谢您提前回复。

【问题讨论】:

    标签: linux gcc architecture systemtap


    【解决方案1】:

    不要尝试手动编译 systemtap 的中间 C 代码。相反,通过 stap(或通过 staprun 编译的 .ko)运行脚本,并通过 stdout 使用它们的输出。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-16
      • 1970-01-01
      相关资源
      最近更新 更多