int test_receive_stream() {
    IT("receives a streamed callback message");
    reset_callback();
    
    Stream stream;
    stream.expect((uint8_t*)"payload",7);
    
    ShimClient shimClient;
    shimClient.setAllowConnect(true);
    
    byte connack[] = { 0x20, 0x02, 0x00, 0x00 };
    shimClient.respond(connack,4);
    
    PubSubClient client(server, 1883, callback, shimClient, stream);
    int rc = client.connect((char*)"client_test1");
    IS_TRUE(rc);
    
    byte publish[] = {0x30,0xe,0x0,0x5,0x74,0x6f,0x70,0x69,0x63,0x70,0x61,0x79,0x6c,0x6f,0x61,0x64};
    shimClient.respond(publish,16);
    
    rc = client.loop();

    IS_TRUE(rc);
    
    IS_TRUE(callback_called);
    IS_TRUE(strcmp(lastTopic,"topic")==0);
    IS_TRUE(lastLength == 7);
    
    IS_FALSE(stream.error());
    IS_FALSE(shimClient.error());

    END_IT
}
Example #2
0
static int sensors_config(const char *key, const char *value) {
  if (sensor_list == NULL)
    sensor_list = ignorelist_create(1);

  /* TODO: This setting exists for compatibility with old versions of
   * lm-sensors. Remove support for those ancient versions in the next
   * major release. */
  if (strcasecmp(key, "SensorConfigFile") == 0) {
    char *tmp = strdup(value);
    if (tmp != NULL) {
      sfree(conffile);
      conffile = tmp;
    }
  } else if (strcasecmp(key, "Sensor") == 0) {
    if (ignorelist_add(sensor_list, value)) {
      ERROR("sensors plugin: "
            "Cannot add value to ignorelist.");
      return 1;
    }
  } else if (strcasecmp(key, "IgnoreSelected") == 0) {
    ignorelist_set_invert(sensor_list, 1);
    if (IS_TRUE(value))
      ignorelist_set_invert(sensor_list, 0);
  }
#if (SENSORS_API_VERSION >= 0x400) && (SENSORS_API_VERSION < 0x500)
  else if (strcasecmp(key, "UseLabels") == 0) {
    use_labels = IS_TRUE(value);
  }
#endif
  else {
    return -1;
  }

  return 0;
}
Example #3
0
/* Hoist det of loop.
e.g: while (a=10,b+=3,c<a) {
		IR-LIST;
	 }

be replaced by

	 a = 10;
	 b += 3;
	 while (c<a) {
		IR-LIST;
		a = 10;
	    b += 3;
	 } */
bool IR_CFS_OPT::hoist_loop(IR ** head, IR * ir)
{
	IS_TRUE(IR_type(ir)==IR_DO_WHILE ||
		    IR_type(ir)==IR_WHILE_DO ||
			IR_type(ir)==IR_DO_LOOP, ("need LOOP"));
	IS_TRUE(LOOP_det(ir), ("DET is NULL"));
	IR * det = LOOP_det(ir);

	INT i = 0;
	while (det != NULL) {
		i++;
		det = IR_next(det);
	}

	IR * new_list = NULL, * new_body_list = NULL;
	if (i > 1) {
		det = LOOP_det(ir);
		while (i > 1) {
			IR * c = det;
			IS_TRUE(c->is_stmt(), ("Non-stmt ir should be remove "
								   "during reshape_ir_tree()"));
			det = IR_next(det);
			remove(&LOOP_det(ir), c);
			add_next(&new_list, c);
			i--;
		}
		new_body_list = m_ru->dup_irs_list(new_list);
		insertbefore(head, ir, new_list);
		add_next(&LOOP_body(ir), new_body_list);
		return true;
	}
	return false;
}
int test_receive_oversized_message() {
    IT("drops an oversized message");
    reset_callback();
    
    ShimClient shimClient;
    shimClient.setAllowConnect(true);
    
    byte connack[] = { 0x20, 0x02, 0x00, 0x00 };
    shimClient.respond(connack,4);
    
    PubSubClient client(server, 1883, callback, shimClient);
    int rc = client.connect((char*)"client_test1");
    IS_TRUE(rc);
    
    byte length = MQTT_MAX_PACKET_SIZE+1;
    byte publish[] = {0x30,length-2,0x0,0x5,0x74,0x6f,0x70,0x69,0x63,0x70,0x61,0x79,0x6c,0x6f,0x61,0x64};
    byte bigPublish[length];
    memset(bigPublish,'A',length);
    bigPublish[length] = 'B';
    memcpy(bigPublish,publish,16);
    shimClient.respond(bigPublish,length);
    
    rc = client.loop();
    
    IS_TRUE(rc);
    
    IS_FALSE(callback_called);
    
    IS_FALSE(shimClient.error());

    END_IT
}
//----------------------------------------------------------//
// CFileDirectTextReader::Open
//----------------------------------------------------------//
CFile::Error::Enum CFileDirectTextReader::Open(void)
{
	if (IS_TRUE(Validate()))
	{
		if (IS_FALSE(IsOpen()))
		{
			m_pFile = SysFileIO::Fopen(m_strFileName.ConstBuffer(), "rt");
			m_nSize = 0;

			if (IS_TRUE(IsOpen()))
			{
				SysFileIO::Fseek(m_pFile, 0, SEEK_END);
				m_nSize = SysFileIO::Ftell(m_pFile);
				SysFileIO::Fseek(m_pFile, 0, SEEK_SET);

				return Error::Ok;
			}

			return Error::FileOpenFailed;
		}

		return Error::FileAlreadyOpen;
	}

	return Error::Failed;
}
Example #6
0
/* Canonicalize det of IF.
e.g: if (a=10,b+=3,c<a) {...}
be replaced by
	 a = 10;
	 b += 3;
	 if (c<a) {...} */
bool IR_CFS_OPT::hoist_if(IR ** head, IR * ir)
{
	IS_TRUE(IR_type(ir) == IR_IF, ("need IF"));
	IS_TRUE(IF_det(ir), ("DET is NULL"));

	IR * det = IF_det(ir);
	INT i = 0;
	while (det != NULL) {
		i++;
		det = IR_next(det);
	}

	IR * new_list = NULL;
	if (i > 1) {
		det = IF_det(ir);
		while (i > 1) {
			IR * c = det;
			IS_TRUE(c->is_stmt(),
				("Non-stmt ir should be remove during reshape_ir_tree()"));
			det = IR_next(det);
			remove(&IF_det(ir), c);
			add_next(&new_list, c);
			i--;
		}
		insertbefore(head, ir, new_list);
		return true;
	}
	return false;
}
Example #7
0
static int interface_config(const char *key, const char *value) {
  if (ignorelist == NULL)
    ignorelist = ignorelist_create(/* invert = */ 1);

  if (strcasecmp(key, "Interface") == 0) {
    ignorelist_add(ignorelist, value);
  } else if (strcasecmp(key, "IgnoreSelected") == 0) {
    int invert = 1;
    if (IS_TRUE(value))
      invert = 0;
    ignorelist_set_invert(ignorelist, invert);
  } else if (strcasecmp(key, "ReportInactive") == 0)
    report_inactive = IS_TRUE(value);
  else if (strcasecmp(key, "UniqueName") == 0) {
#ifdef HAVE_LIBKSTAT
    if (IS_TRUE(value))
      unique_name = true;
#else
    WARNING("interface plugin: the \"UniqueName\" option is only valid on "
            "Solaris.");
#endif /* HAVE_LIBKSTAT */
  } else {
    return -1;
  }

  return 0;
}
Example #8
0
static int df_config (const char *key, const char *value)
{
	df_init ();

	if (strcasecmp (key, "Device") == 0)
	{
		if (ignorelist_add (il_device, value))
			return (1);
		return (0);
	}
	else if (strcasecmp (key, "MountPoint") == 0)
	{
		if (ignorelist_add (il_mountpoint, value))
			return (1);
		return (0);
	}
	else if (strcasecmp (key, "FSType") == 0)
	{
		if (ignorelist_add (il_fstype, value))
			return (1);
		return (0);
	}
	else if (strcasecmp (key, "IgnoreSelected") == 0)
	{
		if (IS_TRUE (value))
		{
			ignorelist_set_invert (il_device, 0);
			ignorelist_set_invert (il_mountpoint, 0);
			ignorelist_set_invert (il_fstype, 0);
		}
		else
		{
			ignorelist_set_invert (il_device, 1);
			ignorelist_set_invert (il_mountpoint, 1);
			ignorelist_set_invert (il_fstype, 1);
		}
		return (0);
	}
	else if (strcasecmp (key, "ReportByDevice") == 0)
	{
		if (IS_TRUE (value))
			by_device = 1;

		return (0);
	}
	else if (strcasecmp (key, "ReportInodes") == 0)
	{
		if (IS_TRUE (value))
			report_inodes = 1;
		else
			report_inodes = 0;

		return (0);
	}


	return (-1);
}
//----------------------------------------------------------//
// CFileDirectTextReader::GetString
//----------------------------------------------------------//
//-- Description
// Read a string from an open direct access file.
// A string is determined as terminated by a newline
// character or the end of file. Any trailing newline will be
// stripped from the output string.
//----------------------------------------------------------//
s8* CFileDirectTextReader::GetString(s8* pDstBuffer, size_t nDstBufferSize)
{
	if ( IS_TRUE(Validate())
		&& IS_TRUE(IsOpen())
		&& IS_PTR(pDstBuffer)
		&& (nDstBufferSize > 0) )
	{
		return SysFileIO::Fgets(m_pFile, pDstBuffer, nDstBufferSize);
	}

	return NULL;
}
Example #10
0
//Reverse edge direction
EDGE * GRAPH::rev_edge(EDGE * e)
{
	IS_TRUE(m_pool != NULL, ("not yet initialized."));
	IS_TRUE(m_is_direction, ("graph is indirection"));
	void * einfo = EDGE_info(e);
	VERTEX * from = EDGE_from(e);
	VERTEX * to = EDGE_to(e);
	remove_edge(e);
	e = add_edge(VERTEX_id(to), VERTEX_id(from));
	EDGE_info(e) = einfo;
	return e;
}
Example #11
0
static int cpu_config (char const *key, char const *value) /* {{{ */
{
	if (strcasecmp (key, "ReportByCpu") == 0)
		report_by_cpu = IS_TRUE (value) ? 1 : 0;
	else if (strcasecmp (key, "ValuesPercentage") == 0)
		report_percent = IS_TRUE (value) ? 1 : 0;
	else if (strcasecmp (key, "ReportByState") == 0)
		report_by_state = IS_TRUE (value) ? 1 : 0;
	else
		return (-1);

	return (0);
} /* }}} int cpu_config */
//----------------------------------------------------------//
// CFileDirectTextReader::GetString
//----------------------------------------------------------//
//-- Description
// Read a string from an open direct access file.
// A string is determined as terminated by a newline
// character or the end of file. Any trailing newline will be
// stripped from the output string.
//----------------------------------------------------------//
IFixedString& CFileDirectTextReader::GetString(IFixedString& strString)
{
	if (IS_TRUE(Validate())
		&& IS_TRUE(IsOpen()) )
	{
		if (IS_NULL_PTR(SysFileIO::Fgets(m_pFile, strString.Buffer(), strString.Size())))
		{
			//-- fgets got nothing. Mirror that in the FixedString.
			strString.Clear();
		}
	}

	return strString;
}
Example #13
0
//Reverse all edge direction
void GRAPH::rev_edges()
{
	IS_TRUE(m_pool != NULL, ("not yet initialized."));
	IS_TRUE(m_is_direction, ("graph is indirection"));
	LIST<EDGE*> list;
	EDGE * e;
	INT c;
	for (e = get_first_edge(c); e != NULL; e = get_next_edge(c)) {
		list.append_tail(e);		
	}
	for (e = list.get_head(); e != NULL; e = list.get_next()) { 
		rev_edge(e);
	}	
}
Example #14
0
static int disk_config (const char *key, const char *value)
{
  if (ignorelist == NULL)
    ignorelist = ignorelist_create (/* invert = */ 1);
  if (ignorelist == NULL)
    return (1);

  if (strcasecmp ("Disk", key) == 0)
  {
    ignorelist_add (ignorelist, value);
  }
  else if (strcasecmp ("IgnoreSelected", key) == 0)
  {
    int invert = 1;
    if (IS_TRUE (value))
      invert = 0;
    ignorelist_set_invert (ignorelist, invert);
  }
  else if (strcasecmp ("UseBSDName", key) == 0)
  {
#if HAVE_IOKIT_IOKITLIB_H
    use_bsd_name = IS_TRUE (value) ? 1 : 0;
#else
    WARNING ("disk plugin: The \"UseBSDName\" option is only supported "
        "on Mach / Mac OS X and will be ignored.");
#endif
  }
  else if (strcasecmp ("UdevNameAttr", key) == 0)
  {
#if HAVE_LIBUDEV
    if (conf_udev_name_attr != NULL)
    {
      free (conf_udev_name_attr);
      conf_udev_name_attr = NULL;
    }
    if ((conf_udev_name_attr = strdup (value)) == NULL)
      return (1);
#else
    WARNING ("disk plugin: The \"UdevNameAttr\" option is only supported "
        "if collectd is built with libudev support");
#endif
  }
  else
  {
    return (-1);
  }

  return (0);
} /* int disk_config */
Example #15
0
static int huge_config_callback(const char *key, const char *val)
{
  DEBUG("%s: HugePages config key='%s', val='%s'", g_plugin_name, key, val);

  if (strcasecmp(key, g_cfg_rpt_numa) == 0) {
    g_flag_rpt_numa = IS_TRUE(val);
    return 0;
  }
  if (strcasecmp(key, g_cfg_rpt_mm) == 0) {
    g_flag_rpt_mm = IS_TRUE(val);
    return 0;
  }

  return -1;
}
int test_keepalive_disconnects_hung() {
    IT("disconnects a hung connection");
    
    ShimClient shimClient;
    shimClient.setAllowConnect(true);
    
    byte connack[] = { 0x20, 0x02, 0x00, 0x00 };
    shimClient.respond(connack,4);
    
    PubSubClient client(server, 1883, callback, shimClient);
    int rc = client.connect((char*)"client_test1");
    IS_TRUE(rc);
    
    byte pingreq[] = { 0xC0,0x0 };
    shimClient.expect(pingreq,2);
    
    for (int i = 0; i < 32; i++) {
        sleep(1);
        rc = client.loop();
    }
    IS_FALSE(rc);
    
    IS_FALSE(shimClient.error());

    END_IT
}
Example #17
0
EDGE * GRAPH::get_edge(UINT from, UINT to)
{
	IS_TRUE(m_pool != NULL, ("not yet initialized."));
	VERTEX * fp = get_vertex(from);
	VERTEX * tp = get_vertex(to);
	return get_edge(fp, tp);
}
Example #18
0
EDGE * GRAPH::get_edge(VERTEX const* from, VERTEX const* to)
{
	IS_TRUE(m_pool != NULL, ("not yet initialized."));
	if (from == NULL || to == NULL) return NULL;
	EDGE_C * el = VERTEX_out_list(from);
	while (el != NULL) {
		EDGE * e = EC_edge(el);
		if (EDGE_from(e) == from && EDGE_to(e) == to) {
			return e;
		}
		if (!m_is_direction && 
			(EDGE_from(e) == to && EDGE_to(e) == from)) {
			return e;
		}
		el = EC_next(el);
	}
	
	if (!m_is_direction) {
		EDGE_C * el = VERTEX_out_list(to);
		while (el != NULL) {
			EDGE * e = EC_edge(el);
			if (EDGE_from(e) == to && EDGE_to(e) == from) {
				return e;
			}
			el = EC_next(el);
		}
	}
	return NULL;
}
Example #19
0
EDGE * GRAPH::new_edge(VERTEX * from, VERTEX * to)
{
	IS_TRUE(m_pool != NULL, ("not yet initialized."));
	if (from == NULL || to == NULL) return NULL;
	EDGE teste;
	VERTEX testfrom, testto;
	if (m_is_unique) {
		VERTEX_id(&testfrom) = VERTEX_id(from);
		VERTEX_id(&testto) = VERTEX_id(to);
		EDGE_from(&teste) = &testfrom;
		EDGE_to(&teste) = &testto;
		if (m_is_direction) {			
			return m_edges.append((ULONG)&teste, NULL);
		} else {
			EDGE * e = NULL;
			if (m_edges.find(&teste, &e)) {
				IS_TRUE0(e);
				return e;
			}
			
			//Both check from->to and to->from
			EDGE_from(&teste) = &testto;
			EDGE_to(&teste) = &testfrom;
			return m_edges.append((ULONG)&teste, NULL);
		}
		IS_TRUE0(0);
	}
	return m_edges.append(new_edge_c(from, to));
}
Example #20
0
void IR_GVN::dump_bb_labs(LIST<LABEL_INFO*> & lst)
{
	for (LABEL_INFO * li = lst.get_head(); li != NULL; li = lst.get_next()) {
		switch (LABEL_INFO_type(li)) {
		case L_CLABEL:
			note(CLABEL_STR_FORMAT, CLABEL_CONT(li));
			break;
		case L_ILABEL:
			note(ILABEL_STR_FORMAT, ILABEL_CONT(li));
			break;
		case L_PRAGMA:
			note("%s", LABEL_INFO_pragma(li));
			break;
		default: IS_TRUE(0,("unsupport"));
		}
		if (LABEL_INFO_is_try_start(li) ||
			LABEL_INFO_is_try_end(li) ||
			LABEL_INFO_is_catch_start(li)) {
			fprintf(g_tfile, "(");
			if (LABEL_INFO_is_try_start(li)) {
				fprintf(g_tfile, "try_start,");
			}
			if (LABEL_INFO_is_try_end(li)) {
				fprintf(g_tfile, "try_end,");
			}
			if (LABEL_INFO_is_catch_start(li)) {
				fprintf(g_tfile, "catch_start");
			}
			fprintf(g_tfile, ")");
		}
		fprintf(g_tfile, " ");
	}
}
Example #21
0
static int mysql_config_set_boolean (int *ret_boolean, /* {{{ */
				oconfig_item_t *ci)
{
	int status = 0;

	if (ci->values_num != 1)
		status = -1;

	if (status == 0)
	{
		if (ci->values[0].type == OCONFIG_TYPE_BOOLEAN)
			*ret_boolean = ci->values[0].value.boolean;
		else if (ci->values[0].type == OCONFIG_TYPE_STRING)
		{
			if (IS_TRUE (ci->values[0].value.string))
				*ret_boolean = 1;
			else if (IS_FALSE (ci->values[0].value.string))
				*ret_boolean = 0;
			else
				status = -1;
		}
		else
			status = -1;
	}

	if (status != 0)
	{
		WARNING ("mysql plugin: The `%s' config option "
			"needs exactly one boolean argument.", ci->key);
		return (-1);
	}
	return (0);
} /* }}} mysql_config_set_boolean */
Example #22
0
void GRAPH::dump_dot(CHAR const* name)
{
	if (name == NULL) {
		name = "graph.dot";
	}
	unlink(name);
	FILE * h = fopen(name, "a+");
	IS_TRUE(h, ("%s create failed!!!", name));

	fprintf(h, "digraph G {\n");
	//Print node
	INT c;
	for (VERTEX const* v = m_vertexs.get_first(c); 
		 v != NULL; v = m_vertexs.get_next(c)) {
		fprintf(h, "\nnode%d [shape = Mrecord, label=\"{BB%d}\"];", 
				VERTEX_id(v), VERTEX_id(v));
	}

	//Print edge
	for (EDGE const* e = m_edges.get_first(c); 
		 e != NULL; e = m_edges.get_next(c)) {
		fprintf(h, "\nnode%d->node%d[label=\"%s\"]",
					VERTEX_id(EDGE_from(e)), 
					VERTEX_id(EDGE_to(e)),
					""); 
	}
	fprintf(h, "\n}\n");
	fclose(h);
}
Example #23
0
static int apcups_config (const char *key, const char *value)
{
	if (strcasecmp (key, "host") == 0)
	{
		if (conf_host != NULL)
		{
			free (conf_host);
			conf_host = NULL;
		}
		if ((conf_host = strdup (value)) == NULL)
			return (1);
	}
	else if (strcasecmp (key, "Port") == 0)
	{
		int port_tmp = atoi (value);
		if (port_tmp < 1 || port_tmp > 65535)
		{
			WARNING ("apcups plugin: Invalid port: %i", port_tmp);
			return (1);
		}
		conf_port = port_tmp;
	}
	else if (strcasecmp (key, "ReportSeconds") == 0)
	{
		if (IS_TRUE (value))
			conf_report_seconds = 1;
		else
			conf_report_seconds = 0;
	}
	else
	{
		return (-1);
	}
	return (0);
}
Example #24
0
static int smart_config (const char *key, const char *value)
{
  if (ignorelist == NULL)
    ignorelist = ignorelist_create (/* invert = */ 1);
  if (ignorelist == NULL)
    return (1);

  if (strcasecmp ("Disk", key) == 0)
  {
    ignorelist_add (ignorelist, value);
  }
  else if (strcasecmp ("IgnoreSelected", key) == 0)
  {
    int invert = 1;
    if (IS_TRUE (value))
      invert = 0;
    ignorelist_set_invert (ignorelist, invert);
  }
  else
  {
    return (-1);
  }

  return (0);
} /* int smart_config */
Example #25
0
static int cpu_config (const char *key, const char *value)
{
	if (strcasecmp (key, "ReportByCpu") == 0) {
		report_by_cpu = IS_TRUE (value) ? 1 : 0;
		if (!report_by_cpu)
			report_percent = 1;
	}
	if (strcasecmp (key, "ValuesPercentage") == 0) {
		report_percent = IS_TRUE (value) ? 1 : 0;
		if (!report_percent)
			report_by_cpu = 1;
	}
	if (strcasecmp (key, "ReportActive") == 0)
		report_active = IS_TRUE (value) ? 1 : 0;
	return (-1);
}
Example #26
0
static int conn_config (const char *key, const char *value)
{
  if (strcasecmp (key, "ListeningPorts") == 0)
  {
    if (IS_TRUE (value))
      port_collect_listening = 1;
    else
      port_collect_listening = 0;
  }
  else if ((strcasecmp (key, "LocalPort") == 0)
      || (strcasecmp (key, "RemotePort") == 0))
  {
      port_entry_t *pe;
      int port = atoi (value);

      if ((port < 1) || (port > 65535))
      {
	ERROR ("tcpconns plugin: Invalid port: %i", port);
	return (1);
      }

      pe = conn_get_port_entry ((uint16_t) port, 1 /* create */);
      if (pe == NULL)
      {
	ERROR ("tcpconns plugin: conn_get_port_entry failed.");
	return (1);
      }

      if (strcasecmp (key, "LocalPort") == 0)
	pe->flags |= PORT_COLLECT_LOCAL;
      else
	pe->flags |= PORT_COLLECT_REMOTE;
  }
  else if (strcasecmp (key, "AllPortsSummary") == 0)
  {
    if (IS_TRUE (value))
      port_collect_total = 1;
    else
      port_collect_total = 0;
  }
  else
  {
    return (-1);
  }

  return (0);
} /* int conn_config */
Example #27
0
void * GRAPH::_xmalloc(ULONG size)
{
	IS_TRUE(m_pool != NULL, ("not init"));
	void * p = smpool_malloc_h(size, m_pool);
	IS_TRUE0(p);
	memset(p, 0, size);
	return p;
}
//----------------------------------------------------------//
// CWinSysRollupContainer::CancelScroll
//----------------------------------------------------------//
//-- Description
// Force cancel any scrollbar activity
//----------------------------------------------------------//
void CWinSysRollupContainer::CancelScroll(void)
{
	if (IS_TRUE(m_bDraggingScrollbar))
	{
		m_bDraggingScrollbar = false;
		Update(true);
	}
}
Example #29
0
static int lpar_config(const char *key, const char *value) {
  if (strcasecmp("CpuPoolStats", key) == 0) {
    if (IS_TRUE(value))
      pool_stats = true;
    else
      pool_stats = false;
  } else if (strcasecmp("ReportBySerial", key) == 0) {
    if (IS_TRUE(value))
      report_by_serial = true;
    else
      report_by_serial = false;
  } else {
    return -1;
  }

  return 0;
} /* int lpar_config */
Example #30
0
VN * IR_GVN::comp_sc(IR const* exp, bool & change)
{
	VN * evn = m_ir2vn.get(IR_id(exp));
	if (evn != NULL) { return evn; }

	evn = comp_mem(exp, change);
	if (evn != NULL) { return evn; }

	DU_SET const* du = m_du->get_du_c(exp);
	IS_TRUE(du, ("This situation should be catched in comp_mem()"));
	IS_TRUE0(du->get_elem_count() > 0);

	IR const* exp_stmt = const_cast<IR*>(exp)->get_stmt();
	IR const* domdef = m_du->find_dom_def(exp, exp_stmt, du, false);
	if (domdef == NULL) { return NULL; }
	if (domdef->is_stid() && ST_ofst(domdef) != exp->get_ofst()) {
		return NULL;
	}
	if (!domdef->is_stid() && !domdef->is_stpr()) {
		return comp_sc_by_anon_domdef(exp, domdef, change);
	}
	switch (IR_type(exp)) {
	case IR_LD:
		if (domdef->is_stpr() || (LD_idinfo(exp) != ST_idinfo(domdef))) {
			return NULL;
		}
		break;
	case IR_PR:
		if (domdef->is_stid() || PR_no(exp) != STPR_no(domdef)) {
			return NULL;
		}
		break;
	default: IS_TRUE(0, ("unsupport"));
	}

	VN * uni_vn = m_ir2vn.get(IR_id(domdef));
	if (uni_vn == NULL) {
		uni_vn = new_vn();
		VN_type(uni_vn) = VN_VAR;
		m_ir2vn.set(IR_id(domdef), uni_vn);
	}
	m_ir2vn.set(IR_id(exp), uni_vn);
	change = true;
	return uni_vn;
}