static int attach_lua_uprobes()

in profiler/profile.cpp [303:336]


static int attach_lua_uprobes(struct profile_bpf *obj, struct bpf_link *links[])
{
	char lua_path[128];
	if (env.pid)
	{
		int res = 0;

		res = get_pid_lib_path(env.pid, "luajit-5.1.so", lua_path, sizeof(lua_path));
		if (res < 0)
		{
			fprintf(stderr, "warning: failed to get lib path for pid %d\n", env.pid);
			return -1;
		}
	}

	links[0] = attach_lua_func(lua_path, "lua_resume", obj->progs.handle_entry_lua);
	if (!links[0])
	{
		return -1;
	}

	links[1] = attach_lua_func(lua_path, "lua_pcall", obj->progs.handle_entry_lua);
	if (!links[1])
	{
		return -1;
	}

	links[2] = attach_lua_func(lua_path, "lua_yield", obj->progs.handle_entry_lua_cancel);
	if (!links[2])
	{
		return -1;
	}
	return 0;
}