コード例 #1
0
static void
create_and_free_provider(int argc, char **argv)
{
	usdt_provider_t *provider;
	usdt_probedef_t *probedef;

	if ((provider = usdt_create_provider("testlibusdt", "modname")) == NULL) {
		fprintf(stderr, "unable to create provider\n");
		exit (1);
	}
	if ((probedef = usdt_create_probe((const char *)argv[1],
					  (const char *)argv[2],
					  (argc-3), (const char **)&argv[3])) == NULL)
	{
		fprintf(stderr, "unable to create probe\n");
		exit (1);
	}
	usdt_provider_add_probe(provider, probedef);

	if ((usdt_provider_enable(provider)) < 0) {
		fprintf(stderr, "unable to enable provider: %s\n", usdt_errstr(provider));
		exit (1);
	}

	if ((usdt_provider_disable(provider)) < 0) {
		fprintf(stderr, "unable to disable provider: %s\n", usdt_errstr(provider));
		exit (1);
	}

	usdt_probe_release(probedef);
	usdt_provider_free(provider);
}
コード例 #2
0
ファイル: usdt.c プロジェクト: kevinykchan/ruby-usdt
/**
 * USDT::Provider.create :name, :modname
 */
static VALUE provider_create(VALUE self, VALUE name, VALUE mod) {
  Check_Type(name, T_SYMBOL);
  Check_Type(mod, T_SYMBOL);

  const char *namestr = rb_id2name(rb_to_id(name));
  const char *modstr = rb_id2name(rb_to_id(mod));

  usdt_provider_t* p = usdt_create_provider(namestr, modstr);

  VALUE rbProvider = Data_Wrap_Struct(USDT_Provider, NULL, free, p);

  if (rb_block_given_p()) {
    rb_yield(rbProvider);
  }

  return rbProvider;
}