小编oca*_*eau的帖子

eBPF - 无法从跟踪点 sys_enter_execve 读取 argv 和 envp

我学习 BPF 是为了自己的乐趣,但我很难弄清楚如何读取argvenvp从上下文传递到我的 eBPF 程序以进行 sys_enter_execve

我将在这里展示我的 BPF 程序,然后稍后更详细地解释我想要完成的任务。

这是我的代码:

#include <linux/bpf.h>
#include <bpf_helpers.h>

struct
{
    __uint(type, BPF_MAP_TYPE_ARRAY);
    __type(key, __u32);
    __type(value, char[300]);
    __uint(max_entries, 1);
} mymap SEC(".maps");

// Based on /sys/kernel/debug/tracing/events/syscalls/sys_enter_execve/format
struct execve_args {
    short common_type;
    char common_flags;
    char common_preempt_count;
    int common_pid;
    int __syscall_nr;
    char *filename;
    const char *const *argv;
    const char *const *envp;
};

SEC("tracepoint/syscalls/sys_enter_execve")
int bpf_prog(struct execve_args *ctx) {
  
  __u32 index = 0;
  __u64 *value = bpf_map_lookup_elem(&mymap, &index);

  // An array of length 300 …
Run Code Online (Sandbox Code Playgroud)

linux bpf ebpf

4
推荐指数
1
解决办法
1582
查看次数

为什么我需要 NSRunLoop 来运行计时器?

我购买了 Objective-C 的 Big Nerd Ranch Guide,但有一些NSRunLoop我想不通的地方。

这是书中的一段代码:

NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:2.0 
                                                  target:logger
                                                selector:@selector(updateLastTime:)
                                                userInfo:nil
                                                 repeats:YES];
[[NSRunLoop currentRunLoop] run];
Run Code Online (Sandbox Code Playgroud)

我的问题是,为什么我需要为要处理NSRunLoopNSTimer对象放置一个?为什么它需要在最后,而不是开始?

为什么它不像其他函数或对象的方法那样我只需要调用一个函数来处理它并登录到控制台?

我真的很想弄清楚这里每个细节的每个逻辑。

cocoa nstimer nsrunloop

3
推荐指数
1
解决办法
666
查看次数

标签 统计

bpf ×1

cocoa ×1

ebpf ×1

linux ×1

nsrunloop ×1

nstimer ×1