Lines Matching defs:gdata

51  * All setting of global data (gdata) is done here.
58 * should be found in the GlobalData structure pointed to by gdata
70 GlobalData *gdata;
100 * gdata->callbackBlock, which will block this callback if VM_DEATH
110 rawMonitorEnter(gdata->callbackLock); \
111 if (gdata->vm_death_callback_active) { \
114 rawMonitorExit(gdata->callbackLock); \
116 rawMonitorEnter(gdata->callbackBlock); \
117 rawMonitorExit(gdata->callbackBlock); \
120 gdata->active_callbacks++; \
122 rawMonitorExit(gdata->callbackLock); \
128 rawMonitorEnter(gdata->callbackLock); \
129 gdata->active_callbacks--; \
131 if (gdata->vm_death_callback_active) { \
132 if (gdata->active_callbacks == 0) { \
133 rawMonitorNotifyAll(gdata->callbackLock); \
136 rawMonitorExit(gdata->callbackLock); \
138 rawMonitorEnter(gdata->callbackBlock); \
139 rawMonitorExit(gdata->callbackBlock); \
286 if (gdata->output_format != 'b') {
323 (void)remove(gdata->output_filename);
493 "%s option error: %s (%s)", AGENTNAME, description, gdata->options);
524 gdata->options = all_options;
551 gdata->utf8_output_filename = HPROF_MALLOC((int)strlen(suboption)+1);
552 (void)strcpy(gdata->utf8_output_filename, suboption);
565 gdata->net_hostname = HPROF_MALLOC((int)strlen(suboption)+1);
566 (void)strcpy(gdata->net_hostname, suboption);
567 gdata->net_port = (int)strtol(port_number, NULL, 10);
574 gdata->output_format = 'a';
576 gdata->output_format = 'b';
584 gdata->max_trace_depth = (int)strtol(suboption, &endptr, 10);
585 if ((endptr != NULL && *endptr != 0) || gdata->max_trace_depth < 0) {
588 gdata->prof_trace_depth = gdata->max_trace_depth;
593 gdata->sample_interval = (int)strtol(suboption, &endptr, 10);
594 if ((endptr != NULL && *endptr != 0) || gdata->sample_interval <= 0) {
601 gdata->cutoff_point = strtod(suboption, &endptr);
602 if ((endptr != NULL && *endptr != 0) || gdata->cutoff_point < 0) {
611 gdata->cpu_sampling = JNI_TRUE;
613 gdata->cpu_timing = JNI_TRUE;
614 gdata->old_timing_format = JNI_FALSE;
616 gdata->cpu_timing = JNI_TRUE;
617 gdata->old_timing_format = JNI_TRUE;
626 gdata->heap_dump = JNI_TRUE;
628 gdata->alloc_sites = JNI_TRUE;
630 gdata->heap_dump = JNI_TRUE;
631 gdata->alloc_sites = JNI_TRUE;
636 if ( !setBinarySwitch(&options, &(gdata->lineno_in_traces)) ) {
640 if ( !setBinarySwitch(&options, &(gdata->thread_in_traces)) ) {
644 if ( !setBinarySwitch(&options, &(gdata->dump_on_exit)) ) {
648 if ( !setBinarySwitch(&options, &(gdata->micro_state_accounting)) ) {
652 if ( !setBinarySwitch(&options, &(gdata->force_output)) ) {
656 if ( !setBinarySwitch(&options, &(gdata->verbose)) ) {
660 if ( !setBinarySwitch(&options, &(gdata->primfields)) ) {
664 if ( !setBinarySwitch(&options, &(gdata->primarrays)) ) {
668 if ( !setBinarySwitch(&options, &(gdata->monitor_tracing)) ) {
672 if ( !setBinarySwitch(&options, &(gdata->gc_okay)) ) {
679 gdata->logflags = (int)strtol(suboption, NULL, 0);
684 gdata->debugflags = (int)strtol(suboption, NULL, 0);
686 if ( !setBinarySwitch(&options, &(gdata->coredump)) ) {
692 if ( !setBinarySwitch(&options, &(gdata->errorexit)) ) {
696 if ( !setBinarySwitch(&options, &(gdata->pause)) ) {
700 if ( !setBinarySwitch(&options, &(gdata->debug)) ) {
709 gdata->experiment = (int)strtol(suboption, NULL, 0);
718 if (gdata->output_format == 'b') {
719 if (gdata->cpu_timing) {
722 if (gdata->monitor_tracing) {
727 if (gdata->old_timing_format) {
728 gdata->prof_trace_depth = 2;
731 if (gdata->output_format == 'b') {
738 gdata->utf8_output_filename = HPROF_MALLOC((int)strlen(default_filename)+1);
739 (void)strcpy(gdata->utf8_output_filename, default_filename);
742 if ( gdata->utf8_output_filename != NULL ) {
743 /* UTF-8 to platform encoding (fill in gdata->output_filename) */
744 ulen = (int)strlen(gdata->utf8_output_filename);
745 gdata->output_filename = (char*)HPROF_MALLOC(ulen*3+3);
747 (void)strcpy(gdata->output_filename, gdata->utf8_output_filename);
749 (void)(gdata->npt->utf8ToPlatform)
750 (gdata->npt->utf, (jbyte*)gdata->utf8_output_filename, ulen,
751 gdata->output_filename, ulen*3+3);
755 /* By default we turn on gdata->alloc_sites and gdata->heap_dump */
756 if ( !gdata->cpu_timing &&
757 !gdata->cpu_sampling &&
758 !gdata->monitor_tracing &&
759 !gdata->alloc_sites &&
760 !gdata->heap_dump) {
761 gdata->heap_dump = JNI_TRUE;
762 gdata->alloc_sites = JNI_TRUE;
765 if ( gdata->alloc_sites || gdata->heap_dump ) {
766 gdata->obj_watch = JNI_TRUE;
768 if ( gdata->obj_watch || gdata->cpu_timing ) {
769 gdata->bci = JNI_TRUE;
773 if (gdata->heap_dump) {
778 base = gdata->output_filename;
783 gdata->heapfilename = HPROF_MALLOC(len + 5);
784 (void)strcpy(gdata->heapfilename, base);
785 (void)strcat(gdata->heapfilename, ".TMP");
786 make_unique_filename(&(gdata->heapfilename));
787 (void)remove(gdata->heapfilename);
788 if (gdata->output_format == 'b') {
789 if ( gdata->logflags & LOG_CHECK_BINARY ) {
793 gdata->checkfilename =
796 (void)strcpy(gdata->checkfilename, default_filename);
797 (void)strcat(gdata->checkfilename, check_suffix);
798 (void)remove(gdata->checkfilename);
799 gdata->check_fd = md_creat(gdata->checkfilename);
801 if ( gdata->debug ) {
802 gdata->logflags |= LOG_CHECK_BINARY;
804 gdata->heap_fd = md_creat_binary(gdata->heapfilename);
806 gdata->heap_fd = md_creat(gdata->heapfilename);
808 if ( gdata->heap_fd < 0 ) {
812 "can't create temp heap file: %s", gdata->heapfilename);
818 if ( gdata->net_port > 0 ) {
820 gdata->fd = connect_to_socket(gdata->net_hostname, (unsigned short)gdata->net_port);
821 if (gdata->fd <= 0) {
825 "can't connect to %s:%u", gdata->net_hostname, gdata->net_port);
830 gdata->socket = JNI_TRUE;
833 if ( !gdata->force_output ) {
834 make_unique_filename(&(gdata->output_filename));
837 (void)remove(gdata->output_filename);
839 if (gdata->output_format == 'b') {
840 gdata->fd = md_creat_binary(gdata->output_filename);
842 gdata->fd = md_creat(gdata->output_filename);
844 if (gdata->fd < 0) {
848 "can't create profile file: %s", gdata->output_filename);
863 if (gdata->cpu_sampling || gdata->cpu_timing || gdata->monitor_tracing) {
864 rawMonitorEnter(gdata->data_access_lock);
867 if (gdata->cpu_sampling || gdata->cpu_timing) {
870 if (gdata->monitor_tracing) {
874 if (gdata->cpu_sampling || gdata->cpu_timing || gdata->monitor_tracing) {
875 rawMonitorExit(gdata->data_access_lock);
885 if (gdata->monitor_tracing) {
888 monitor_write_contended_time(env, gdata->cutoff_point);
890 if (gdata->heap_dump) {
896 if (gdata->alloc_sites) {
898 site_write(env, 0, gdata->cutoff_point);
900 if (gdata->cpu_sampling) {
902 trace_output_cost(env, gdata->cutoff_point);
904 if (gdata->cpu_timing) {
905 if (!gdata->old_timing_format) {
907 trace_output_cost(env, gdata->cutoff_point);
942 if ( class_count != gdata->class_count ) {
944 rawMonitorEnter(gdata->data_access_lock); {
960 } rawMonitorExit(gdata->data_access_lock);
966 gdata->class_count = class_count;
979 rawMonitorEnter(gdata->object_free_lock); {
980 stack = gdata->object_free_stack;
981 gdata->object_free_stack = NULL; /* Will trigger new stack */
982 } rawMonitorExit(gdata->object_free_lock);
1032 rawMonitorEnter(gdata->gc_finish_lock); {
1033 gdata->gc_finish_active = JNI_TRUE;
1034 } rawMonitorExit(gdata->gc_finish_lock);
1041 rawMonitorEnter(gdata->gc_finish_lock); {
1043 if ( gdata->gc_finish_stop_request ) {
1048 rawMonitorWait(gdata->gc_finish_lock, 0);
1050 if ( gdata->gc_finish_stop_request ) {
1055 if ( active && gdata->gc_finish > 0 ) {
1057 gdata->gc_finish = 0;
1060 } rawMonitorExit(gdata->gc_finish_lock);
1083 rawMonitorEnter(gdata->gc_finish_lock); {
1084 gdata->gc_finish_active = JNI_FALSE;
1085 rawMonitorNotifyAll(gdata->gc_finish_lock);
1086 } rawMonitorExit(gdata->gc_finish_lock);
1100 if (gdata->bci) {
1116 if (gdata->cpu_timing) {
1120 if (gdata->monitor_tracing) {
1130 if (gdata->obj_watch) {
1145 rawMonitorEnter(gdata->data_access_lock); {
1151 gdata->jvm_initializing = JNI_TRUE;
1154 gdata->header = "JAVA PROFILE 1.0.1";
1155 gdata->segmented = JNI_FALSE;
1156 if (gdata->output_format == 'b') {
1158 gdata->maxMemory = getMaxMemory(env);
1159 gdata->maxHeapSegment = (jlong)2000000000;
1161 if ( gdata->maxMemory >= gdata->maxHeapSegment ) {
1162 gdata->header = "JAVA PROFILE 1.0.2";
1163 gdata->segmented = JNI_TRUE; /* 1.0.2 */
1180 gdata->thread_cnum = class_find_or_create("Ljava/lang/Thread;",
1182 class_add_status(gdata->thread_cnum, CLASS_SYSTEM);
1191 gdata->system_class_size = 0;
1194 gdata->system_trace_index = tls_get_trace(tls_index, env,
1195 gdata->max_trace_depth, JNI_FALSE);
1196 gdata->system_object_site_index = site_find_or_create(
1197 cnum, gdata->system_trace_index);
1200 gdata->hprof_trace_index = tls_get_trace(tls_index, env,
1201 gdata->max_trace_depth, JNI_FALSE);
1202 gdata->hprof_site_index = site_find_or_create(
1203 cnum, gdata->hprof_trace_index);
1205 if ( gdata->logflags & LOG_DUMP_LISTS ) {
1213 if ( gdata->bci ) {
1220 rawMonitorEnter(gdata->gc_finish_lock); {
1223 } rawMonitorExit(gdata->gc_finish_lock);
1226 if ( gdata->socket ) {
1231 if ( gdata->cpu_sampling ) {
1242 if ( gdata->bci ) {
1247 gdata->jvm_initialized = JNI_TRUE;
1248 gdata->jvm_initializing = JNI_FALSE;
1252 } rawMonitorExit(gdata->data_access_lock);
1260 * Use local flag to minimize gdata->dump_lock hold time.
1270 rawMonitorEnter(gdata->gc_finish_lock); {
1280 gdata->gc_finish_stop_request = JNI_TRUE;
1281 rawMonitorNotifyAll(gdata->gc_finish_lock);
1283 while ( gdata->gc_finish_active ) {
1284 rawMonitorWait(gdata->gc_finish_lock,0);
1286 } rawMonitorExit(gdata->gc_finish_lock);
1299 rawMonitorEnter(gdata->callbackBlock); {
1309 rawMonitorEnter(gdata->callbackLock); {
1311 if ( gdata->bci ) {
1314 gdata->vm_death_callback_active = JNI_TRUE;
1315 while (gdata->active_callbacks > 0) {
1316 rawMonitorWait(gdata->callbackLock, 0);
1318 } rawMonitorExit(gdata->callbackLock);
1325 rawMonitorEnter(gdata->data_access_lock); {
1326 if ( gdata->jvm_initializing ) {
1330 if ( !gdata->jvm_initialized ) {
1334 if (gdata->jvm_shut_down) {
1338 } rawMonitorExit(gdata->data_access_lock);
1341 if ( gdata->cpu_sampling ) {
1346 rawMonitorEnter(gdata->dump_lock); {
1348 gdata->jvm_shut_down = JNI_TRUE;
1350 if (!gdata->dump_in_process) {
1352 gdata->dump_in_process = JNI_TRUE;
1354 * Setting gdata->dump_in_process will cause cpu sampling to pause
1361 } rawMonitorExit(gdata->dump_lock);
1364 if (gdata->dump_on_exit && need_to_dump) {
1382 } rawMonitorExit(gdata->callbackBlock);
1385 if (gdata->socket) {
1392 if ( gdata->fd >= 0 ) {
1393 (void)md_close(gdata->fd);
1394 gdata->fd = -1;
1395 if ( gdata->logflags & LOG_CHECK_BINARY ) {
1396 if (gdata->output_format == 'b' && gdata->output_filename != NULL) {
1397 check_binary_file(gdata->output_filename);
1401 if ( gdata->heap_fd >= 0 ) {
1402 (void)md_close(gdata->heap_fd);
1403 gdata->heap_fd = -1;
1406 if ( gdata->check_fd >= 0 ) {
1407 (void)md_close(gdata->check_fd);
1408 gdata->check_fd = -1;
1412 if (gdata->heap_dump) {
1413 (void)remove(gdata->heapfilename);
1417 if ( gdata->logflags & LOG_DUMP_LISTS ) {
1463 if (!gdata->bci) {
1468 rawMonitorEnter(gdata->data_access_lock); {
1471 if ( gdata->bci_counter == 0 ) {
1476 gdata->bci_counter++;
1484 (gdata->java_crw_demo_classname_function))
1529 if ( (!gdata->jvm_initialized)
1530 && (!gdata->jvm_initializing)
1532 || gdata->bci_counter < 8 ) ) {
1541 ((JavaCrwDemo)(gdata->java_crw_demo_function))(
1549 (gdata->cpu_timing)?TRACKER_CALL_NAME:NULL,
1550 (gdata->cpu_timing)?TRACKER_CALL_SIG:NULL,
1551 (gdata->cpu_timing)?TRACKER_RETURN_NAME:NULL,
1552 (gdata->cpu_timing)?TRACKER_RETURN_SIG:NULL,
1553 (gdata->obj_watch)?TRACKER_OBJECT_INIT_NAME:NULL,
1554 (gdata->obj_watch)?TRACKER_OBJECT_INIT_SIG:NULL,
1555 (gdata->obj_watch)?TRACKER_NEWARRAY_NAME:NULL,
1556 (gdata->obj_watch)?TRACKER_NEWARRAY_SIG:NULL,
1580 } rawMonitorExit(gdata->data_access_lock);
1594 rawMonitorEnter(gdata->data_access_lock); {
1603 } rawMonitorExit(gdata->data_access_lock);
1617 rawMonitorEnter(gdata->data_access_lock); {
1627 } rawMonitorExit(gdata->data_access_lock);
1642 rawMonitorEnter(gdata->dump_lock); {
1643 if (!gdata->dump_in_process) {
1645 gdata->dump_in_process = JNI_TRUE;
1647 } rawMonitorExit(gdata->dump_lock);
1652 rawMonitorEnter(gdata->dump_lock); {
1653 gdata->dump_in_process = JNI_FALSE;
1654 } rawMonitorExit(gdata->dump_lock);
1656 if (gdata->cpu_sampling && !gdata->jvm_shut_down) {
1735 gdata->gc_start_time = md_get_timemillis();
1748 if ( gdata->gc_start_time != -1L ) {
1749 gdata->time_in_gc += (md_get_timemillis() - gdata->gc_start_time);
1750 gdata->gc_start_time = -1L;
1754 rawMonitorEnter(gdata->gc_finish_lock); {
1758 if ( gdata->gc_finish_active ) {
1759 gdata->gc_finish++;
1760 rawMonitorNotifyAll(gdata->gc_finish_lock);
1762 } rawMonitorExit(gdata->gc_finish_lock);
1776 rawMonitorEnter(gdata->object_free_lock); {
1777 if ( !gdata->jvm_shut_down ) {
1780 stack = gdata->object_free_stack;
1782 gdata->object_free_stack = stack_init(512, 512, sizeof(jlong));
1783 stack = gdata->object_free_stack;
1787 } rawMonitorExit(gdata->object_free_lock);
1848 if (gdata->bci) {
1851 if (gdata->obj_watch) {
1854 if (gdata->cpu_timing || gdata->cpu_sampling) {
1861 if (gdata->monitor_tracing) {
1949 if ( gdata!=NULL && gdata->isLoaded==JNI_TRUE ) {
1954 gdata = get_gdata();
1956 gdata->isLoaded = JNI_TRUE;
1960 LOG2("Agent_OnLoad", "gdata setup");
1962 gdata->jvm = vm;
1972 NPT_INITIALIZE(npt_lib, &(gdata->npt), NPT_VERSION, NULL);
1973 if ( gdata->npt == NULL ) {
1976 gdata->npt->utf = (gdata->npt->utfInitialize)(NULL);
1977 if ( gdata->npt->utf == NULL ) {
1984 gdata->debug_malloc_lock = createRawMonitor("HPROF debug_malloc lock");
2008 if ( gdata->pause ) {
2018 gdata->dump_lock = createRawMonitor("HPROF dump lock");
2019 gdata->data_access_lock = createRawMonitor("HPROF data access lock");
2020 gdata->callbackLock = createRawMonitor("HPROF callback lock");
2021 gdata->callbackBlock = createRawMonitor("HPROF callback block");
2022 gdata->object_free_lock = createRawMonitor("HPROF object free lock");
2023 gdata->gc_finish_lock = createRawMonitor("HPROF gc_finish lock");
2031 gdata->jvm_initializing = JNI_FALSE;
2032 gdata->jvm_initialized = JNI_FALSE;
2033 gdata->vm_death_callback_active = JNI_FALSE;
2034 gdata->active_callbacks = 0;
2042 gdata->micro_sec_ticks = md_get_microsecs();
2045 if ( gdata->bci ) {
2048 gdata->java_crw_demo_library = load_library("java_crw_demo");
2052 gdata->java_crw_demo_function =
2053 lookup_library_symbol(gdata->java_crw_demo_library,
2058 gdata->java_crw_demo_classname_function =
2059 lookup_library_symbol(gdata->java_crw_demo_library,
2074 gdata->isLoaded = JNI_FALSE;
2076 stack = gdata->object_free_stack;
2077 gdata->object_free_stack = NULL;
2093 /* Deallocate any memory in gdata */
2094 if ( gdata->net_hostname != NULL ) {
2095 HPROF_FREE(gdata->net_hostname);
2097 if ( gdata->utf8_output_filename != NULL ) {
2098 HPROF_FREE(gdata->utf8_output_filename);
2100 if ( gdata->output_filename != NULL ) {
2101 HPROF_FREE(gdata->output_filename);
2103 if ( gdata->heapfilename != NULL ) {
2104 HPROF_FREE(gdata->heapfilename);
2106 if ( gdata->checkfilename != NULL ) {
2107 HPROF_FREE(gdata->checkfilename);
2109 if ( gdata->options != NULL ) {
2110 HPROF_FREE(gdata->options);
2121 * destroyRawMonitor(gdata->callbackLock);
2122 * destroyRawMonitor(gdata->callbackBlock);
2123 * destroyRawMonitor(gdata->gc_finish_lock);
2124 * destroyRawMonitor(gdata->object_free_lock);
2125 * destroyRawMonitor(gdata->listener_loop_lock);
2126 * destroyRawMonitor(gdata->cpu_loop_lock);
2128 * gdata->jvmti = NULL;
2132 destroyRawMonitor(gdata->dump_lock);
2133 gdata->dump_lock = NULL;
2134 destroyRawMonitor(gdata->data_access_lock);
2135 gdata->data_access_lock = NULL;
2136 if ( gdata->cpu_sample_lock != NULL ) {
2137 destroyRawMonitor(gdata->cpu_sample_lock);
2138 gdata->cpu_sample_lock = NULL;
2141 destroyRawMonitor(gdata->debug_malloc_lock);
2142 gdata->debug_malloc_lock = NULL;
2146 if ( gdata->bci && gdata->java_crw_demo_library != NULL ) {
2147 md_unload_library(gdata->java_crw_demo_library);
2148 gdata->java_crw_demo_library = NULL;
2151 /* You would think you could clear out gdata and set it to NULL, but
2155 * some raw monitor actions to do, but they need access to gdata to do it.
2157 * (void)memset(gdata, 0, sizeof(GlobalData));
2158 * gdata = NULL;