コード例 #1
0
ファイル: hprof_site.c プロジェクト: cedarli/java
/* Setup tag on root object */
static void
setup_tag_on_root(jlong *tag_ptr, jlong class_tag, jlong size,
		  SerialNumber thread_serial_num,
                  ObjectIndex *pindex, SiteIndex *psite)
{
    ObjectIndex object_index;
    SiteIndex   object_site_index;
    
    if ( (*tag_ptr) != (jlong)0 ) {
	object_index      = tag_extract(*tag_ptr);
	if ( psite != NULL ) {
	    object_site_index = object_get_site(object_index);
	}
    } else {
	object_site_index = site_find_or_create(
				 find_cnum(class_tag), 
				 gdata->system_trace_index);
	object_index      = object_new(object_site_index, 
				 (jint)size, OBJECT_SYSTEM, 
				 thread_serial_num);
	/* Create and set the tag. */
	*tag_ptr = tag_create(object_index);
    }
    if ( pindex != NULL ) {
        *pindex = object_index;
    }
    if ( psite != NULL ) {
	*psite = object_site_index;
    }
}
コード例 #2
0
ファイル: hprof_site.c プロジェクト: cedarli/java
/* JVMTI callback function. */
static jvmtiIterationControl JNICALL
stack_object(jvmtiHeapRootKind root_kind, 
		jlong class_tag, jlong size, jlong* tag_ptr, 
		jlong thread_tag, jint depth, jmethodID method, jint slot,
		void *user_data)
{

   /* Only calls to Allocate, Deallocate, RawMonitorEnter & RawMonitorExit
    *   are allowed here (see the JVMTI Spec).
    */

    ObjectIndex  object_index;
    SerialNumber thread_serial_num;

    HPROF_ASSERT(tag_ptr!=NULL);
    if ( (*tag_ptr) != (jlong)0 ) {
	object_index = tag_extract(*tag_ptr);
	thread_serial_num = object_get_thread_serial_number(object_index);
        thread_serial_num = checkThreadSerialNumber(thread_serial_num);
    } else {
	SiteIndex site_index;
	
        site_index = site_find_or_create(find_cnum(class_tag), 
				gdata->system_trace_index);
	if ( thread_tag != (jlong)0 ) {
	    ObjectIndex thread_object_index;

	    thread_object_index = tag_extract(thread_tag);
	    thread_serial_num = 
	           object_get_thread_serial_number(thread_object_index);
            thread_serial_num = checkThreadSerialNumber(thread_serial_num);
	} else {
	    thread_serial_num = gdata->unknown_thread_serial_num;
	}
	object_index = object_new(site_index, (jint)size, OBJECT_SYSTEM,
			    thread_serial_num);
	/* Create and set the tag. */
	*tag_ptr = tag_create(object_index);
    }

    HPROF_ASSERT(thread_serial_num!=0);
    HPROF_ASSERT(object_index!=0);
    switch ( root_kind ) {
        case JVMTI_HEAP_ROOT_STACK_LOCAL:
	    io_heap_root_java_frame(object_index, thread_serial_num, depth);
	    break;
        case JVMTI_HEAP_ROOT_JNI_LOCAL:
	    io_heap_root_jni_local(object_index, thread_serial_num, depth);
	    break;
	default:
	    break;
    }
    return JVMTI_ITERATION_CONTINUE;
}
コード例 #3
0
int	main(int ac, char **av)
{
  char	*file;
  char	*tag;
  int	ret;

  if (ac < 2)
    syntax(av[0]);
  else 
    {
      // get correct filename
      if (!strcmp(av[1], "-F"))
	{
	  if (ac < 4)
	    {
	      syntax(av[0]);
	      return (0);
	    }
	  else
	    {
	      file = av[2];
	      tag = av[3];
	    }
	}
      else
	{
	  file = DEFAULT_FILENAME;
	  tag = av[1];
	}

      // call libtag functions
      if ((ret = tag_init(file)) != tagSuccess)
	{
	  if (ret == tagNonExisting)
	    {
	      tag_exit();
	      printf("File don't exist\n");
	      return (-1);
	    }
	}
      else if ((ret = tag_create(tag)) == tagSuccess)
	{
	  tag_exit();
	  printf("Tag %s created.\n", tag);
	  return (0);
	}
      tag_exit();
      printf("Lib error %d\n", ret);
    }
  return (-1);
}
コード例 #4
0
ファイル: imap_taglist.c プロジェクト: jiapei100/gimp
void
taglist_set(TagList_t *tlist, const gchar *name, const gchar *value)
{
   GList *p;
   Tag_t *tag;

   for (p = tlist->list; p; p = p->next) {
      tag = (Tag_t*) p->data;
      if (!g_ascii_strcasecmp(tag->name, name)) {
         g_strreplace(&tag->value, value);
         return;
      }
   }
   /* Tag not found, add a new tag */
   tlist->list = g_list_append(tlist->list, tag_create(name, value));
}
コード例 #5
0
/* JVMTI callback function. */
static jvmtiIterationControl JNICALL
reference_object(jvmtiObjectReferenceKind reference_kind, 
		jlong class_tag, jlong size, jlong* tag_ptr, 
		jlong referrer_tag, jint referrer_index, void *user_data)
{

   /* Only calls to Allocate, Deallocate, RawMonitorEnter & RawMonitorExit
    *   are allowed here (see the JVMTI Spec).
    */

    RefIndex      ref_index;
    RefIndex      prev_ref_index;
    ObjectIndex   referrer_object_index;
    ObjectIndex   object_index;
    jlong         object_tag;

    HPROF_ASSERT(tag_ptr!=NULL);
    HPROF_ASSERT(referrer_tag!=(jlong)0);
    
    if ( referrer_tag != (jlong)0 ) {
	referrer_object_index = tag_extract(referrer_tag);
    } else {
        return JVMTI_ITERATION_CONTINUE;
    }
    
    object_tag = *tag_ptr;
    if ( object_tag != (jlong)0 ) {
        object_index = tag_extract(object_tag);
    } else {
        SiteIndex site_index;
	
        site_index = site_find_or_create(find_cnum(class_tag), 
			gdata->system_trace_index);
	object_index = object_new(site_index, (jint)size, OBJECT_SYSTEM,
				gdata->system_thread_serial_num);
	object_tag = tag_create(object_index);
	*tag_ptr   = object_tag;
    }

    /* Save reference information */
    prev_ref_index = object_get_references(referrer_object_index);
    ref_index = reference_new(prev_ref_index, reference_kind,
		    class_tag, size, object_tag, referrer_index);
    object_set_references(referrer_object_index, ref_index);
    
    return JVMTI_ITERATION_CONTINUE;
}
コード例 #6
0
/* Create tag and object entry for an untagged object (should be rare) */
static jlong
make_new_tag(jlong class_tag, jlong size, TraceIndex trace_index,
                  SerialNumber thread_serial_num,
                  ObjectIndex *pindex, SiteIndex *psite)
{
    ObjectIndex object_index;
    SiteIndex   object_site_index;

    HPROF_ASSERT(class_tag!=(jlong)0);
    object_site_index = site_find_or_create(find_cnum(class_tag), trace_index);
    object_index      = object_new(object_site_index, (jint)size, 
                                   OBJECT_SYSTEM, thread_serial_num);
    if ( pindex != NULL ) {
        *pindex = object_index;
    }
    if ( psite != NULL ) {
        *psite = object_site_index;
    }
    return tag_create(object_index);
}
コード例 #7
0
ファイル: reader.c プロジェクト: blakearnold/rfidentify
int reader_parse_poll_packet(struct reader *reader,
			     struct list *tagList,
			     char *packetPayload,
			     int packetPayload_len)
{
  const char *p = packetPayload;
  char idbuf[RFID_ID_LEN+1];
  int pos;

  for(;;){
    while(*p != '['){
      if(*p == '\0') return list_size(tagList);
      p++;
    }
    p++;
    pos = 0;
    // While we have a valid ID character, construct the ID.
    while((*p >= '0' && *p <= '9') ||
	  (*p >= 'A' && *p <= 'F') ||
	  (*p >= 'a' && *p <= 'f')){

      if(pos >= RFID_ID_LEN) break;
      idbuf[pos++] = *p++;
    }


    // Check it's a valid ID (must be followed by a ',' delimiter
    if(*p == ',' && pos > 0){
      struct tag *tag;
      idbuf[pos] = '\0';
      tag = tag_create();
      tag_init(tag, strdup(idbuf), reader);
      if(tag != NULL){
	list_push(tagList, tag);
      }
    }
    else if(*p == '\0') {
      return list_size(tagList);
    }
  }
}
コード例 #8
0
void ParallelMeshImpl::vertices_set_global_id(const VertexHandle vert_array[],
					      size_t gid[],
					      size_t num_vtx,
					      MsqError& err)
{
  if (gid_tag == 0)
  {
    const char GLOBAL_ID_NAME[] = "GLOBAL_ID";

    int default_gid = -1;
    gid_tag = tag_create( GLOBAL_ID_NAME, HANDLE, 1, &default_gid, err );
      // the 'HANDLE' is the type of data to store
      // the '1' is for one value per vertex
      // NULL for no default value, if you want them all
      // initialized to something, pass in a pointer to an int
      // with the value.
    MSQ_CHKERR(err);
  }

  tag_set_vertex_data( gid_tag, num_vtx, vert_array, gid, err );
  MSQ_CHKERR(err);
}
コード例 #9
0
void ParallelMeshImpl::vertices_set_processor_id(const VertexHandle vert_array[],
						 int pid[],
						 size_t num_vtx,
						 MsqError& err)
{
  if (pid_tag == 0)
  {
    const char PROCESSOR_ID_NAME[] = "PROCESSOR_ID";

    int default_pid = -1;
    pid_tag = tag_create( PROCESSOR_ID_NAME, INT, 1, &default_pid, err );
      // the 'INT' is the type of data to store
      // the '1' is for one value per vertex
      // NULL for no default value, if you want them all
      // initialized to something, pass in a pointer to an int
      // with the value.
    MSQ_CHKERR(err);
  }

  tag_set_vertex_data( pid_tag, num_vtx, vert_array, pid, err );
  MSQ_CHKERR(err); 
}
コード例 #10
0
/* JVMTI callback function. */
static jvmtiIterationControl JNICALL 
root_object(jvmtiHeapRootKind root_kind, jlong class_tag, jlong size, 
		jlong* tag_ptr, void *user_data)
{

   /* Only calls to Allocate, Deallocate, RawMonitorEnter & RawMonitorExit
    *   are allowed here (see the JVMTI Spec).
    */

    ObjectIndex   object_index;
    SiteIndex     object_site_index;
    
    HPROF_ASSERT(tag_ptr!=NULL);
    if ( (*tag_ptr) != (jlong)0 ) {
	object_index      = tag_extract(*tag_ptr);
	object_site_index = object_get_site(object_index);
    } else {
        object_site_index = site_find_or_create(find_cnum(class_tag), 
				gdata->system_trace_index);
	object_index      = object_new(object_site_index, (jint)size, 
			    OBJECT_SYSTEM, gdata->system_thread_serial_num);
	/* Create and set the tag. */
	*tag_ptr = tag_create(object_index);
    }

    switch ( root_kind ) {
        case JVMTI_HEAP_ROOT_JNI_GLOBAL: {
		SerialNumber trace_serial_num;
		SerialNumber gref_serial_num;
		
		if ( object_site_index != 0 ) {
		    SiteKey     *pkey;
		    TraceIndex  trace_index;
		    
		    pkey = get_pkey(object_site_index);
		    trace_index = pkey->trace_index;
		    trace_serial_num = trace_get_serial_number(trace_index);
		} else {
		    trace_serial_num = 
			trace_get_serial_number(gdata->system_trace_index);
		}
		gref_serial_num = gdata->gref_serial_number_counter++;
		io_heap_root_jni_global(object_index, gref_serial_num, 
					trace_serial_num);
		break;
	    }
        case JVMTI_HEAP_ROOT_SYSTEM_CLASS: {
		char *sig;

		sig = "Unknown";
		if ( object_site_index != 0 ) {
		    SiteKey *pkey;
		    
		    pkey = get_pkey(object_site_index);
		    sig = string_get(class_get_signature(pkey->cnum));
		}
		io_heap_root_system_class(object_index, sig);
		break;
	    }
        case JVMTI_HEAP_ROOT_MONITOR: {
		io_heap_root_monitor(object_index);
		break;
	    }
        case JVMTI_HEAP_ROOT_THREAD: {
		SerialNumber thread_serial_num;

		if ( object_index != 0 ) {
		    thread_serial_num = 
			  object_get_thread_serial_number(object_index);
		} else {
		    thread_serial_num = gdata->system_thread_serial_num;
		}
		io_heap_root_thread(object_index, thread_serial_num);
		break;
	    }
        case JVMTI_HEAP_ROOT_OTHER: {
		io_heap_root_unknown(object_index);
		break;
	    }
	default:
	    break;
    }
    return JVMTI_ITERATION_CONTINUE;
}
コード例 #11
0
ファイル: tags.c プロジェクト: w23/sifon
  return this;
}

tag_ptr tag_create(const char *key, const char *value) {
  tag_ptr this = CX_CREATE(tag);
  this->key = cx_string_create(key);
  this->value = cx_string_create(value);
  return this;
}

tags_ptr tags_create() {
  return cx_array_create();
}

void tags_insert(tags_ptr this, const char *key, const char *value) {
  tag_ptr tag = tag_create(key, value);
  cx_array_insert_back(this, tag);
  cx_release(tag);
}

void tags_insert_string(tags_ptr this, cx_string_ptr key, cx_string_ptr value) {
  tag_ptr tag = tag_create_string(key, value);
  cx_array_insert_back(this, tag);
  cx_release(tag);
}

cx_size_t tags_count(tags_ptr this) {
  return this->count;
}

tag_ptr tags_get(tags_ptr this, cx_size_t index) {
コード例 #12
0
ファイル: imap_taglist.c プロジェクト: jiapei100/gimp
static Tag_t*
tag_clone(Tag_t *src)
{
   return tag_create(src->name, src->value);
}