Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 200251 | Differences between
and this patch

Collapse All | Expand All

(-)src-native/src/JPIAgent/ECWrapper.h (-3 / +4 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005 - 2007 IBM Corporation, Intel Corporation.
2
 * Copyright (c) 2005 - 2008 IBM Corporation, Intel Corporation.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 32-39 Link Here
32
    ECWrapper(CPrint* pCPrint, CFilters* pCFilters, COptions* pCOptions);
32
    ECWrapper(CPrint* pCPrint, CFilters* pCFilters, COptions* pCOptions);
33
    ~ECWrapper(void);
33
    ~ECWrapper(void);
34
34
35
    void InitACCollector(CEC_Callbacks* callbacks);
35
    void InitACCollector();
36
36
	void RegisterMartiniCallbacks(CEC_Callbacks* callbacks);
37
	
37
//protected:
38
//protected:
38
    static CPrint* m_pCPrint;
39
    static CPrint* m_pCPrint;
39
    static CFilters* m_pCFilters;
40
    static CFilters* m_pCFilters;
(-)src-native/src/JPIAgent/Makefile (-1 / +2 lines)
Lines 3-9 Link Here
3
include $(ROOTDIR)/src/makefile.inc
3
include $(ROOTDIR)/src/makefile.inc
4
4
5
INCLUDES = -I ../../include/JPIAgent \
5
INCLUDES = -I ../../include/JPIAgent \
6
	-I ../../include/Martini
6
	-I ../../include/Martini -I $(JAVA_HOME)/include -I $(JAVA_HOME)/include/linux
7
7
8
OBJS = $(OBJDIR)/ECWrapper.o \
8
OBJS = $(OBJDIR)/ECWrapper.o \
9
	$(OBJDIR)/ECCallbacks.o \
9
	$(OBJDIR)/ECCallbacks.o \
Lines 11-16 Link Here
11
	$(OBJDIR)/Options.o \
11
	$(OBJDIR)/Options.o \
12
	$(OBJDIR)/Performance.o \
12
	$(OBJDIR)/Performance.o \
13
	$(OBJDIR)/Print.o \
13
	$(OBJDIR)/Print.o \
14
	$(OBJDIR)/Profiler.o \
14
	$(OBJDIR)/PrintXML.o \
15
	$(OBJDIR)/PrintXML.o \
15
	$(OBJDIR)/utility.o \
16
	$(OBJDIR)/utility.o \
16
	$(OBJDIR)/ECJvmtiAgent.o
17
	$(OBJDIR)/ECJvmtiAgent.o
(-)src-native/src/JPIAgent/ECWrapper.cpp (-52 / +125 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005 - 2007 IBM Corporation, Intel Corporation.
2
 * Copyright (c) 2005 - 2008 IBM Corporation, Intel Corporation.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 47-114 Link Here
47
47
48
//=== ACC_ENV ===============================================================================================
48
//=== ACC_ENV ===============================================================================================
49
49
50
static bool ACTracingStarted = false;
51
static bool appTracingStarted = false;
52
static bool tracingStarted = false;
53
static bool printingStarted = false;
54
55
static void startTracing();
56
static void start();
57
static void stopTracing();
58
static void stop();
59
60
extern "C" int isProfilerApiEnabled() {
61
	return (ECWrapper::m_pCOptions != NULL) &&	ECWrapper::m_pCOptions->isProfilerApiEnabled();
62
}
63
64
API_EXPORT void ACC_CALL ACStartTracing() {
65
    LOG_TRACE("ACStartTracing command!");
66
	if (ACTracingStarted) return;
67
	
68
	ACTracingStarted = true;
69
	startTracing();
70
}
71
72
extern "C" void appStartTracing() {
73
    LOG_TRACE("appStartTracing command!");
74
	if (appTracingStarted) return;
75
	
76
	appTracingStarted = true;
77
	startTracing();
78
}
79
50
/** START_TRACING  *************************************************************
80
/** START_TRACING  *************************************************************
51
* This is the entry point which must be called to start a trace. It takes
81
* This is the entry point which must be called to start a trace. It takes
52
* care of emitting all the header information.
82
* care of emitting all the header information.
53
*/
83
*/
54
API_EXPORT void ACC_CALL 
84
static void startTracing() {
55
StartTracing() 
85
	if (tracingStarted) return;
56
{
86
	
57
    LOG_TRACE("StartTracing command!");
87
	bool profilerApiEnabled = false;
58
    LOG_ASSERT(ECWrapper::m_pCPrint != 0);
88
	bool standaloneMode = false;
59
    ECWrapper::m_pCPrint->m_jvmtiAgent_suspendIO = false;
89
	
60
    ECWrapper::m_pCPrint->PrintStartingFragments();
90
	if (ECWrapper::m_pCOptions != NULL) {
61
}
91
		profilerApiEnabled = ECWrapper::m_pCOptions->isProfilerApiEnabled();
62
92
		standaloneMode = ECWrapper::m_pCOptions->isStandAlone(); 
63
/** STOP_TRACING  **************************************************************
93
	}
64
* This is where a trace is stopped.
94
	
65
*/
95
	bool toTrace = (standaloneMode || ACTracingStarted) && (appTracingStarted || !profilerApiEnabled);
66
API_EXPORT void ACC_CALL 
96
67
StopTracing() 
97
	if (!toTrace) return;
68
{
98
	
69
    LOG_TRACE("StopTracing command!");
99
	start();
70
    LOG_ASSERT(ECWrapper::m_pCPrint != 0);
100
	tracingStarted = true;
71
    LOG_ASSERT(ECWrapper::m_pCOptions != 0);
72
    ECWrapper::m_pCPrint->printTraceEndElement();
73
    ECWrapper::m_pCPrint->m_jvmtiAgent_suspendIO = true;
74
}
101
}
75
102
76
API_EXPORT void ACC_CALL 
103
static void start() {
77
Start()
78
{
79
    LOG_TRACE("Start command!");
104
    LOG_TRACE("Start command!");
105
106
   	LOG_ASSERT(ECWrapper::m_pCPrint != 0);
107
   	ECWrapper::m_pCPrint->m_jvmtiAgent_suspendIO = false;
108
109
	if (!printingStarted) {
110
    	ECWrapper::m_pCPrint->PrintStartingFragments();
111
		printingStarted = true;
112
	}
113
	
80
    LOG_ASSERT(ECWrapper::m_pCallbacks != 0);
114
    LOG_ASSERT(ECWrapper::m_pCallbacks != 0);
115
81
    ECWrapper::m_pCallbacks->Start();
116
    ECWrapper::m_pCallbacks->Start();
82
}
117
}
83
118
84
API_EXPORT void ACC_CALL 
119
API_EXPORT void ACC_CALL ACStopTracing() {
85
Stop()
120
    LOG_TRACE("ACStop command!");
86
{
121
    if (!ACTracingStarted) return;
87
    LOG_TRACE("Stop command!");
122
    
88
    LOG_ASSERT(ECWrapper::m_pCallbacks != 0);
123
    ACTracingStarted = false;
89
    ECWrapper::m_pCallbacks->Stop();
124
    stopTracing();
90
}
125
}
91
126
92
API_EXPORT void ACC_CALL
127
extern "C" void appStopTracing() {
93
Resume()
128
    LOG_TRACE("appStop command!");
94
{
129
    if (!appTracingStarted) return;
95
    LOG_TRACE("Resume command!");
130
    
96
    LOG_ASSERT(ECWrapper::m_pCallbacks != 0);
131
    appTracingStarted = false;
97
    LOG_ASSERT(ECWrapper::m_pCPrint != 0);
132
    stopTracing();
98
    ECWrapper::m_pCPrint->m_jvmtiAgent_suspendIO = false;
99
    ECWrapper::m_pCallbacks->Start();
100
}
133
}
101
134
102
API_EXPORT void ACC_CALL
135
/** STOP_TRACING  **************************************************************
103
Pause()
136
* This is where a trace is stopped.
104
{
137
*/
105
    LOG_TRACE("Pause command!");
138
static void stopTracing() {
139
	if (!tracingStarted) return;
140
141
	bool profilerApiEnabled = false;
142
	bool standaloneMode = false;
143
	
144
	if (ECWrapper::m_pCOptions != NULL) {
145
		profilerApiEnabled = ECWrapper::m_pCOptions->isProfilerApiEnabled();
146
		standaloneMode = ECWrapper::m_pCOptions->isStandAlone(); 
147
	}
148
	
149
	bool toTrace = (standaloneMode || ACTracingStarted) && (appTracingStarted || !profilerApiEnabled);
150
	if (toTrace) return;
151
	
152
	tracingStarted = false;
153
	stop();
154
}
155
156
static void stop() {
157
    LOG_TRACE("Stop command!");
158
	    
106
    LOG_ASSERT(ECWrapper::m_pCallbacks != 0);
159
    LOG_ASSERT(ECWrapper::m_pCallbacks != 0);
107
    LOG_ASSERT(ECWrapper::m_pCPrint != 0);
108
    ECWrapper::m_pCallbacks->Stop();
160
    ECWrapper::m_pCallbacks->Stop();
161
   	LOG_ASSERT(ECWrapper::m_pCPrint != 0);
109
    ECWrapper::m_pCPrint->m_jvmtiAgent_suspendIO = true;
162
    ECWrapper::m_pCPrint->m_jvmtiAgent_suspendIO = true;
110
}
163
}
111
164
165
extern "C" void printCustomElement(const char* str) {
166
    LOG_ASSERT(ECWrapper::m_pCPrint != 0);
167
    ECWrapper::m_pCPrint->printCustomElement(str);
168
}
169
112
API_EXPORT void ACC_CALL
170
API_EXPORT void ACC_CALL
113
Attach()
171
Attach()
114
{
172
{
Lines 123-128 Link Here
123
    LOG_TRACE("Detach command!");
181
    LOG_TRACE("Detach command!");
124
    LOG_ASSERT(ECWrapper::m_pCallbacks != 0);
182
    LOG_ASSERT(ECWrapper::m_pCallbacks != 0);
125
    ECWrapper::m_pCallbacks->Detach();
183
    ECWrapper::m_pCallbacks->Detach();
184
185
   	LOG_ASSERT(ECWrapper::m_pCPrint != 0);
186
    
187
	if (printingStarted) {
188
    	ECWrapper::m_pCPrint->printTraceEndElement();
189
		printingStarted = false;
190
    }
191
192
    ECWrapper::m_pCPrint->m_jvmtiAgent_suspendIO = true;
126
}
193
}
127
194
128
API_EXPORT void ACC_CALL
195
API_EXPORT void ACC_CALL
Lines 164-170 Link Here
164
{
231
{
165
    LOG_TRACE("RunGC command!");
232
    LOG_TRACE("RunGC command!");
166
    LOG_ASSERT(ECWrapper::m_pCallbacks != 0);
233
    LOG_ASSERT(ECWrapper::m_pCallbacks != 0);
167
    ECWrapper::m_pCallbacks->CustomCommand(RUN_GC_COMMAND, 0);
234
    if (ECWrapper::m_pCallbacks != NULL) {
235
    	ECWrapper::m_pCallbacks->CustomCommand(RUN_GC_COMMAND, 0);
236
    }
237
}
238
239
extern "C" void runGC() {
240
	RunGC();
168
}
241
}
169
242
170
API_EXPORT void ACC_CALL
243
API_EXPORT void ACC_CALL
Lines 201-212 Link Here
201
ECWrapper::PrepareACCEnv() 
274
ECWrapper::PrepareACCEnv() 
202
{
275
{
203
    static ACCFunctions_ functions;
276
    static ACCFunctions_ functions;
204
    functions.StartTracing = &StartTracing;
277
    functions.StartTracing = &ACStartTracing;
205
    functions.StopTracing = &StopTracing;
278
    functions.StopTracing = &ACStopTracing;
206
    functions.Start = &Start;
279
207
    functions.Stop = &Stop;
208
    functions.Pause = &Pause;
209
    functions.Resume = &Resume;
210
    functions.Detach = &Detach;
280
    functions.Detach = &Detach;
211
    functions.Attach = &Attach;
281
    functions.Attach = &Attach;
212
    functions.AddFilter = &AddFilter;
282
    functions.AddFilter = &AddFilter;
Lines 223-232 Link Here
223
    return &ac_env;
293
    return &ac_env;
224
}
294
}
225
295
296
void ECWrapper::RegisterMartiniCallbacks(CEC_Callbacks* callbacks) {
297
    m_pCallbacks = callbacks;
298
}
299
226
void 
300
void 
227
ECWrapper::InitACCollector(CEC_Callbacks* callbacks)
301
ECWrapper::InitACCollector()
228
{
302
{
229
    m_pCallbacks = callbacks;
230
    ACC_ENV* ac_env = PrepareACCEnv();
303
    ACC_ENV* ac_env = PrepareACCEnv();
231
304
232
    Martini::OSA::ILibraryLoader* libraryLoader;
305
    Martini::OSA::ILibraryLoader* libraryLoader;
(-)src-native/src/JPIAgent/ECJvmtiAgent.cpp (-5 / +14 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005 - 2007 IBM Corporation, Intel Corporation.
2
 * Copyright (c) 2005 - 2008 IBM Corporation, Intel Corporation.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 18-24 Link Here
18
18
19
using namespace Martini::ExternalControl;
19
using namespace Martini::ExternalControl;
20
using namespace Martini::JPIAgent;
20
using namespace Martini::JPIAgent;
21
21
 
22
/////////////////////////////////////////////////////////////////
22
/////////////////////////////////////////////////////////////////
23
23
24
Martini::OSA::IThreadSync* lockObject = Martini::OSA::CreateThreadSync();
24
Martini::OSA::IThreadSync* lockObject = Martini::OSA::CreateThreadSync();
Lines 74-84 Link Here
74
    bool static isInitACCollectorInvoked = false;
74
    bool static isInitACCollectorInvoked = false;
75
    int res = m_Callbacks.RegisterMartiniCallback_(command, callback);
75
    int res = m_Callbacks.RegisterMartiniCallback_(command, callback);
76
    if (res == 1) {
76
    if (res == 1) {
77
        if ((command == CMD_START) && m_Options.isStandAlone()) {
77
        if ((command == CMD_START) && m_Options.isStandAlone() && !m_Options.isProfilerApiEnabled()) {
78
            m_Print.m_jvmtiAgent_suspendIO = false; 
79
        	m_Print.PrintStartingFragments();
80
        
78
            m_Callbacks.Start();
81
            m_Callbacks.Start();
79
        }
82
        }
80
        if (!isInitACCollectorInvoked && m_Callbacks.ProfCallbacksAvailable() && !m_Options.isStandAlone()) {
83
        
81
            m_ECWrapper.InitACCollector(&m_Callbacks);
84
        if (!isInitACCollectorInvoked && m_Callbacks.ProfCallbacksAvailable()) {
85
            m_ECWrapper.RegisterMartiniCallbacks(&m_Callbacks);
86
 			
87
 			if (!m_Options.isStandAlone()) {
88
            	m_ECWrapper.InitACCollector();
89
            }
90
            
82
            isInitACCollectorInvoked = true;
91
            isInitACCollectorInvoked = true;
83
        }
92
        }
84
    }
93
    }
(-)src-native/src/JPIAgent/Options.cpp (-112 / +86 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005 - 2007 IBM Corporation, Intel Corporation.
2
 * Copyright (c) 2005 - 2008 IBM Corporation, Intel Corporation.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 57-63 Link Here
57
{
57
{
58
         1                         /* Provide timestamps by default */
58
         1                         /* Provide timestamps by default */
59
        ,0                         /* Standalone mode */
59
        ,0                         /* Standalone mode */
60
//        ,0                         /* Application mode */
60
        ,0                         /* profilerApiEnabled */
61
        ,1                         /* Enabled mode */
61
        ,1                         /* Enabled mode */
62
        ,1                         /* Filters */
62
        ,1                         /* Filters */
63
        ,1                         /* Options */
63
        ,1                         /* Options */
Lines 115-140 Link Here
115
    strcpy(m_jvmtiAgent_Options.workDir, DEFAULT_WORK_DIR); 
115
    strcpy(m_jvmtiAgent_Options.workDir, DEFAULT_WORK_DIR); 
116
}
116
}
117
117
118
int 
119
COptions::getToken(const char **src, char *buf, int buflen, char sep)
120
{
121
    int i;
122
    const char *p = *src;
123
    for (i = 0; i < buflen; i++) {
124
        if (p[i] == 0 || p[i] == sep) {
125
            buf[i] = 0;
126
            if (p[i] == sep) {
127
                i++;
128
            }
129
            *src += i;
130
            return i;
131
        }
132
        buf[i] = p[i];
133
    }
134
    /* overflow */
135
    return 0;
136
}
137
138
/** PRINT_USAGE **********************************************************************
118
/** PRINT_USAGE **********************************************************************
139
* Print the command line useage of the program.
119
* Print the command line useage of the program.
140
*/
120
*/
Lines 155-160 Link Here
155
        "\n"
135
        "\n"
156
        "Supported option names and values:\n"
136
        "Supported option names and values:\n"
157
        "  server=standalone|enabled|controlled\n" 
137
        "  server=standalone|enabled|controlled\n" 
138
        "  api=true|false\tWhether to enable the Profiler API (true) or not (false). Default is false.\n" 
158
        "  file=<file>\t\tOutput file (default is %s)\n"
139
        "  file=<file>\t\tOutput file (default is %s)\n"
159
        "  \t\t\tOnly applicable when server=standalone\n"
140
        "  \t\t\tOnly applicable when server=standalone\n"
160
        "  filters=<file>\tFilter definition file (default is %s)\n"
141
        "  filters=<file>\tFilter definition file (default is %s)\n"
Lines 434-563 Link Here
434
    return rc;
415
    return rc;
435
}
416
}
436
417
437
/** PROCESS_INVOCATION_OPTIONS *******************************************
418
int COptions::parseOptions(char* buf) {
438
* Takes the command line parameters and populates the m_jvmtiAgent_Options
419
	int outputSpecified = 0;
439
* with the correct values based upon the options specified.
440
* @param   optionString - the command line args
441
* @returns
442
*/
443
444
int
445
COptions::ProcessInvocationOptions(const char *str)
446
{
447
    char *buf = 0; 
448
    int buflen; 
449
    int outputSpecified = 0;
450
    if (str == 0) str = "";
451
420
452
    /* if "help" is specified print out the useage */
421
	char* pnext = buf;
453
    if ((STRICOLL(str, "help")) == 0) {
422
    while (pnext) {
454
        return -1;
423
    	char* pname = pnext;	// current tag
455
    }
424
    	
456
425
    	pnext = strchr(pnext, ',');
457
    while (*str) {
426
    	if (pnext != NULL) {
458
        buflen= strlen(str)+1; 
427
    		*pnext++ = '\0';	// next tag
459
        buf = (char *)malloc(buflen); 
428
    	}
460
        if (!buf) {
429
    	
461
            goto mem_error; 
430
    	char* pvalue = strchr(pname, '=');
462
        }
431
    	if (pvalue != NULL) {
432
    		*pvalue++ = '\0';
433
    	}
463
434
464
        /* All options contain an "=" */
465
        if (!getToken(&str, buf, buflen, '=')) {
466
            goto bad_option;
467
        }
468
        /* Specied output file */
435
        /* Specied output file */
469
        if (STRICOLL(buf, "file") == 0) {
436
        if (STRICOLL(pname, "file") == 0) {
470
            if (outputSpecified || !getToken(&str, buf, buflen, ',')) {
437
            if (outputSpecified || pvalue == NULL) return -1;
471
                goto bad_option;
438
            
472
            }
439
            strcpyrealloc(&m_jvmtiAgent_Options.outputFileName, pvalue);
473
            strcpyrealloc(&m_jvmtiAgent_Options.outputFileName, buf);
474
            outputSpecified = 1;
440
            outputSpecified = 1;
475
        } else if (STRICOLL(buf, "filters") == 0) {
441
        } else if (STRICOLL(pname, "filters") == 0) {
476
            if (!getToken(&str, buf, buflen, ',')) {
442
            if (pvalue == NULL) return -1;
477
                goto bad_option;
443
            
478
            }
444
            strcpyrealloc(&m_jvmtiAgent_Options.filterFileName, pvalue);
479
            strcpyrealloc(&m_jvmtiAgent_Options.filterFileName,buf);
480
//        } else if (STRICOLL(buf, "debug") == 0) {
481
//            if (!getToken(&str, buf, buflen, ',')) {
482
//                goto bad_option;
483
//            } else {
484
//                goto bad_option;
485
//            }
486
        }
445
        }
487
        /* Mode of operation */
446
        /* Mode of operation */
488
        else if (STRICOLL(buf, "server") == 0) {
447
        else if (STRICOLL(pname, "server") == 0) {
489
            if (!getToken(&str, buf, buflen, ',')) {
448
            if (pvalue == NULL) return -1; 
490
                goto bad_option;
449
491
            }
492
            /* If standalone */
450
            /* If standalone */
493
            if (STRICOLL(buf,"standalone") == 0) {
451
            if (STRICOLL(pvalue,"standalone") == 0) {
494
                m_jvmtiAgent_Options.standalone = 1;
452
                m_jvmtiAgent_Options.standalone = 1;
495
                m_jvmtiAgent_Options.enabled = 0;
453
                m_jvmtiAgent_Options.enabled = 0;
496
            }
454
            }
497
            /* If enabled */
455
            /* If enabled */
498
            else if (STRICOLL(buf, "enabled") == 0) {
456
            else if (STRICOLL(pvalue, "enabled") == 0) {
499
                m_jvmtiAgent_Options.standalone = 0;
457
                m_jvmtiAgent_Options.standalone = 0;
500
                m_jvmtiAgent_Options.enabled = 1;
458
                m_jvmtiAgent_Options.enabled = 1;
501
            }
459
            }
502
            /* If controlled */
460
            /* If controlled */
503
            else if (STRICOLL(buf, "controlled") == 0) {
461
            else if (STRICOLL(pvalue, "controlled") == 0) {
504
                m_jvmtiAgent_Options.standalone = 0;
462
                m_jvmtiAgent_Options.standalone = 0;
505
                m_jvmtiAgent_Options.enabled = 0;
463
                m_jvmtiAgent_Options.enabled = 0;
506
            } else {
464
            } else {
507
                goto bad_option;
465
                return -1;
508
            }
466
            }
509
        } else if (STRICOLL(buf, "workDir") == 0) {
467
        } else if (STRICOLL(pname, "api") == 0) {
510
            if (!getToken(&str, buf, buflen, ',')) {
468
            if (pvalue == NULL) return -1; 
511
                goto bad_option;
469
        
470
            if (STRICOLL(pvalue, "true") == 0) {
471
            	m_jvmtiAgent_Options.profilerApiEnabled = 1;
512
            }
472
            }
513
            strcpyrealloc(&m_jvmtiAgent_Options.workDir, buf);
473
        } else if (STRICOLL(pname, "workDir") == 0) {
474
            if (pvalue == NULL) return -1;
475
476
            strcpyrealloc(&m_jvmtiAgent_Options.workDir, pvalue);
514
477
515
            /* create the directory */
478
            /* create the directory */
516
            if (MKDIR(m_jvmtiAgent_Options.workDir) != 0 && errno != EEXIST) {
479
            if (MKDIR(m_jvmtiAgent_Options.workDir) != 0 && errno != EEXIST) {
517
                /* couldn't create the dir and it doesn't exists either */
480
                /* couldn't create the dir and it doesn't exists either */
518
                perror(m_jvmtiAgent_Options.workDir);
481
                perror(m_jvmtiAgent_Options.workDir);
519
                goto bad_option;
482
                return -1;
520
            }
483
            }
521
484
522
            /* end of workDir */
485
            /* end of workDir */
523
        } else if (STRICOLL(buf, "profile") == 0) {
486
        } else if (STRICOLL(pname, "profile") == 0) {
524
            m_jvmtiAgent_Options.profileFile;
487
            m_jvmtiAgent_Options.profileFile;
525
            if (!getToken(&str, buf, buflen, ',')) {
488
            if (pvalue == NULL) return -1;
526
                goto bad_option;
489
527
            }
490
            strcpyrealloc(&m_jvmtiAgent_Options.profileFile, pvalue);
528
            strcpyrealloc(&m_jvmtiAgent_Options.profileFile, buf);
529
        } else {
491
        } else {
530
            char *buf2 = (char *)malloc(buflen); 
492
            if (pvalue == NULL) return -1;
531
            if (!getToken(&str, buf2, buflen, ',')) {
493
            SetProfileOption(pname, pvalue);
532
                free(buf2); 
533
                return -1;
534
            }
535
            SetProfileOption(buf, buf2);
536
            free(buf2); 
537
        }
494
        }
538
//        } else {
495
	}
539
//            /* unknown option */
496
	
540
//            fprintf(stderr, "Unknown option \"%s\"\n", buf);
497
	return 0;
541
//            fflush(stderr); 
498
}
542
//            goto bad_option;
499
543
//        }
500
/** PROCESS_INVOCATION_OPTIONS *******************************************
544
    }
501
* Takes the command line parameters and populates the m_jvmtiAgent_Options
545
    if (buf) {
502
* with the correct values based upon the options specified.
546
        free (buf); 
503
* @param   optionString - the command line args
504
* @returns
505
*/
506
507
int COptions::ProcessInvocationOptions(const char *str) {
508
    char* buf;
509
510
    if (str == NULL) return 0;
511
512
    /* if "help" is specified print out the useage */
513
    if ((STRICOLL(str, "help")) == 0) {
514
        return -1;
547
    }
515
    }
548
    return 0;
549
516
550
bad_option:
517
	buf = (char*) malloc(strlen(str) + 1);
551
    if (buf) {
518
	if (buf == NULL) {
552
        free(buf); 
519
    	fprintf(stderr, "Memory allocation error\n"); 
520
    	fflush(stderr);
521
    	return -1;
522
    } 
523
524
	strcpy(buf, str);
525
	 
526
    int r = parseOptions(buf);
527
    free(buf);
528
    
529
    if (r < 0) {
530
    	fprintf(stderr, "Illegal TIAgent option\n");
531
    	fflush(stderr);
553
    }
532
    }
554
    fprintf(stderr, "Bad TIAgent option\n");
533
    
555
    fflush(stderr); 
534
    return r;
556
    return -1;
557
mem_error:
558
    fprintf(stderr, "Memory allocation error\n"); 
559
    fflush(stderr); 
560
    return -1; 
561
}
535
}
562
536
563
/** CHECK_OPTIONS_CONSISTENCY ********************************************
537
/** CHECK_OPTIONS_CONSISTENCY ********************************************
(-)src-native/src/JPIAgent/Options.h (-3 / +7 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005 - 2007 IBM Corporation, Intel Corporation.
2
 * Copyright (c) 2005 - 2008 IBM Corporation, Intel Corporation.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 36-42 Link Here
36
    typedef struct {
36
    typedef struct {
37
        unsigned int timestamp:1;                  /* Provide timestamps on all events (TRUE) */
37
        unsigned int timestamp:1;                  /* Provide timestamps on all events (TRUE) */
38
        unsigned int standalone:1;                 /* Standalone mode  (FALSE) */
38
        unsigned int standalone:1;                 /* Standalone mode  (FALSE) */
39
//        unsigned int application:1;                /* Application mode (FALSE) */
39
        unsigned int profilerApiEnabled:1;         /* isProfilerApiEnabled (FALSE) */
40
        unsigned int enabled:1;                    /* Enabled mode  ie. attachable (TRUE)  */
40
        unsigned int enabled:1;                    /* Enabled mode  ie. attachable (TRUE)  */
41
        unsigned int filters:1;                    /* Print FILTER Elements (TRUE) */
41
        unsigned int filters:1;                    /* Print FILTER Elements (TRUE) */
42
        unsigned int options:1;                    /* Print OPTIONS Elements (TRUE) */
42
        unsigned int options:1;                    /* Print OPTIONS Elements (TRUE) */
Lines 126-131 Link Here
126
            return (m_jvmtiAgent_Options.enabled == 1) ;
126
            return (m_jvmtiAgent_Options.enabled == 1) ;
127
        }
127
        }
128
128
129
        bool isProfilerApiEnabled() {
130
            return (m_jvmtiAgent_Options.profilerApiEnabled == 1);
131
        }
132
129
        // is CG pfofiler aggregated
133
        // is CG pfofiler aggregated
130
        bool isCGExecDetails() {
134
        bool isCGExecDetails() {
131
            return (!isEnabled()) && (m_jvmtiAgent_Options.cgExecDetails == 1); //in enabled mode we support aggregated cg profiler only
135
            return (!isEnabled()) && (m_jvmtiAgent_Options.cgExecDetails == 1); //in enabled mode we support aggregated cg profiler only
Lines 154-160 Link Here
154
        ***/ 
158
        ***/ 
155
        void addUnknownOption(char *key, char *value);
159
        void addUnknownOption(char *key, char *value);
156
160
157
        int getToken(const char **src, char *buf, int buflen, char sep);
161
		int parseOptions(char* buf);
158
162
159
        /* Get the absolute directory path for the optheap working dir*/
163
        /* Get the absolute directory path for the optheap working dir*/
160
        void getWorkDir(char* buf);
164
        void getWorkDir(char* buf);
(-)src-native/src/JPIAgent/PrintXML.cpp (-1 / +1 lines)
Lines 32-38 Link Here
32
CPrintXML::PrintStartingFragments()
32
CPrintXML::PrintStartingFragments()
33
{
33
{
34
    /* If we are in standalone print the required additional elements */
34
    /* If we are in standalone print the required additional elements */
35
    if((m_pOptions->m_jvmtiAgent_Options.standalone/*||m_pOptions->m_jvmtiAgent_Options.application*/)) {
35
    if((m_pOptions->m_jvmtiAgent_Options.standalone/*||m_pOptions->m_jvmtiAgent_Options.profilerApiEnabled*/)) {
36
        printXMLStartElement();
36
        printXMLStartElement();
37
        printStandaloneTraceTagOpen();
37
        printStandaloneTraceTagOpen();
38
    }
38
    }
(-)src-native/src/JPIAgent/Makefile.dep (+3 lines)
Lines 108-113 Link Here
108
	utility.h
108
	utility.h
109
	$(CPP_COMPILE)
109
	$(CPP_COMPILE)
110
110
111
$(OBJDIR)/Profiler.o: Profiler.c
112
	$(C_COMPILE)
113
111
$(OBJDIR)/utility.o: utility.c \
114
$(OBJDIR)/utility.o: utility.c \
112
	utility.h
115
	utility.h
113
	$(CPP_COMPILE)
116
	$(CPP_COMPILE)
(-).classpath (+1 lines)
Lines 1-6 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
2
<classpath>
3
	<classpathentry kind="src" path="src.config"/>
3
	<classpathentry kind="src" path="src.config"/>
4
	<classpathentry kind="src" path="src"/>
4
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
5
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
5
	<classpathentry combineaccessrules="false" kind="src" path="/org.eclipse.tptp.platform.agentcontroller"/>
6
	<classpathentry combineaccessrules="false" kind="src" path="/org.eclipse.tptp.platform.agentcontroller"/>
6
	<classpathentry kind="output" path="bin"/>
7
	<classpathentry kind="output" path="bin"/>
(-)src-native/build/build_tptp_profiler.bat (+10 lines)
Lines 76-81 Link Here
76
:make
76
:make
77
if not defined TPTP_ACSDK_HOME goto error_acsdk_home
77
if not defined TPTP_ACSDK_HOME goto error_acsdk_home
78
if not exist %TPTP_ACSDK_HOME%\include\tptp\agents\BaseCollectorImpl.h goto error_bad_acsdk_home
78
if not exist %TPTP_ACSDK_HOME%\include\tptp\agents\BaseCollectorImpl.h goto error_bad_acsdk_home
79
if not defined JAVA_HOME goto error_java_home
80
if not exist %JAVA_HOME%\include\jòi.h goto error_bad_java_home
79
81
80
echo =============================================================
82
echo =============================================================
81
83
Lines 149-154 Link Here
149
echo TPTP_ACSDK_HOME=%TPTP_ACSDK_HOME% is not a valid TPTP AC sdk root
151
echo TPTP_ACSDK_HOME=%TPTP_ACSDK_HOME% is not a valid TPTP AC sdk root
150
goto end
152
goto end
151
153
154
:error_java_home
155
echo Please set JAVA_HOME to a J2SE 5.0 JDK root
156
goto end
157
158
:error_bad_java_home
159
echo JAVA_HOME=%JAVA_HOME% is not a valid J2SE 5.0 JDK root
160
goto end
161
152
:usage
162
:usage
153
echo Profiler Build Script for Windows
163
echo Profiler Build Script for Windows
154
echo     %0 arch mode [clean]
164
echo     %0 arch mode [clean]
(-)src-native/build/BuildJPIAgent32.mak (-2 / +11 lines)
Lines 48-53 Link Here
48
	-@erase "$(INTDIR)\Options.obj"
48
	-@erase "$(INTDIR)\Options.obj"
49
	-@erase "$(INTDIR)\Performance.obj"
49
	-@erase "$(INTDIR)\Performance.obj"
50
	-@erase "$(INTDIR)\Print.obj"
50
	-@erase "$(INTDIR)\Print.obj"
51
	-@erase "$(INTDIR)\Profiler.obj"
51
	-@erase "$(INTDIR)\PrintXML.obj"
52
	-@erase "$(INTDIR)\PrintXML.obj"
52
	-@erase "$(INTDIR)\utility.obj"
53
	-@erase "$(INTDIR)\utility.obj"
53
	-@erase "$(INTDIR)\vc*.idb"
54
	-@erase "$(INTDIR)\vc*.idb"
Lines 62-68 Link Here
62
"$(INTDIR)" :
63
"$(INTDIR)" :
63
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
64
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
64
65
65
CPP_PROJ=/nologo /MT /W3 /GX /O2 /I "./../include/Martini" /I "./../include/JPIAgent" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "IA32_ARCH" /D "ECWRAPPER_EXPORTS" /Fp"$(INTDIR)\BuildJPIAgent32.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
66
CPP_PROJ=/nologo /MT /W3 /GX /O2 /I "./../include/Martini" /I "$(JAVA_HOME)\include" /I "$(JAVA_HOME)\include\win32" /I "./../include/JPIAgent" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "IA32_ARCH" /D "ECWRAPPER_EXPORTS" /Fp"$(INTDIR)\BuildJPIAgent32.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
66
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32 
67
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32 
67
BSC32=bscmake.exe
68
BSC32=bscmake.exe
68
BSC32_FLAGS=/nologo /o"$(OUTDIR)\BuildJPIAgent32.bsc" 
69
BSC32_FLAGS=/nologo /o"$(OUTDIR)\BuildJPIAgent32.bsc" 
Lines 79-84 Link Here
79
	"$(INTDIR)\Performance.obj" \
80
	"$(INTDIR)\Performance.obj" \
80
	"$(INTDIR)\Print.obj" \
81
	"$(INTDIR)\Print.obj" \
81
	"$(INTDIR)\PrintXML.obj" \
82
	"$(INTDIR)\PrintXML.obj" \
83
	"$(INTDIR)\Profiler.obj" \
82
	"$(INTDIR)\utility.obj"
84
	"$(INTDIR)\utility.obj"
83
85
84
"$(OUTDIR)\JPIAgent.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
86
"$(OUTDIR)\JPIAgent.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
Lines 106-111 Link Here
106
	-@erase "$(INTDIR)\Performance.obj"
108
	-@erase "$(INTDIR)\Performance.obj"
107
	-@erase "$(INTDIR)\Print.obj"
109
	-@erase "$(INTDIR)\Print.obj"
108
	-@erase "$(INTDIR)\PrintXML.obj"
110
	-@erase "$(INTDIR)\PrintXML.obj"
111
	-@erase "$(INTDIR)\Profiler.obj"
109
	-@erase "$(INTDIR)\utility.obj"
112
	-@erase "$(INTDIR)\utility.obj"
110
	-@erase "$(INTDIR)\vc*.idb"
113
	-@erase "$(INTDIR)\vc*.idb"
111
	-@erase "$(INTDIR)\vc*.pdb"
114
	-@erase "$(INTDIR)\vc*.pdb"
Lines 121-127 Link Here
121
"$(INTDIR)" :
124
"$(INTDIR)" :
122
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
125
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
123
126
124
CPP_PROJ=/nologo /MTd /W3 /Gm /GX /ZI /Od /I "./../include/JPIAgent" /I "./../include/Martini" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "IA32_ARCH" /D "ECWRAPPER_EXPORTS" /Fp"$(INTDIR)\BuildJPIAgent32.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c 
127
CPP_PROJ=/nologo /MTd /W3 /Gm /GX /ZI /Od /I "./../include/JPIAgent" /I "$(JAVA_HOME)\include" /I "$(JAVA_HOME)\include\win32" /I "./../include/Martini" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "IA32_ARCH" /D "ECWRAPPER_EXPORTS" /Fp"$(INTDIR)\BuildJPIAgent32.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c 
125
MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32 
128
MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32 
126
BSC32=bscmake.exe
129
BSC32=bscmake.exe
127
BSC32_FLAGS=/nologo /o"$(OUTDIR)\BuildJPIAgent32.bsc" 
130
BSC32_FLAGS=/nologo /o"$(OUTDIR)\BuildJPIAgent32.bsc" 
Lines 138-143 Link Here
138
	"$(INTDIR)\Performance.obj" \
141
	"$(INTDIR)\Performance.obj" \
139
	"$(INTDIR)\Print.obj" \
142
	"$(INTDIR)\Print.obj" \
140
	"$(INTDIR)\PrintXML.obj" \
143
	"$(INTDIR)\PrintXML.obj" \
144
	"$(INTDIR)\Profiler.obj" \
141
	"$(INTDIR)\utility.obj"
145
	"$(INTDIR)\utility.obj"
142
146
143
"$(OUTDIR)\JPIAgent.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
147
"$(OUTDIR)\JPIAgent.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
Lines 234-239 Link Here
234
"$(INTDIR)\PrintXML.obj" : $(SOURCE) "$(INTDIR)"
238
"$(INTDIR)\PrintXML.obj" : $(SOURCE) "$(INTDIR)"
235
	$(CPP) $(CPP_PROJ) $(SOURCE)
239
	$(CPP) $(CPP_PROJ) $(SOURCE)
236
240
241
SOURCE=..\src\JPIAgent\Profiler.c
242
243
"$(INTDIR)\Profiler.obj" : $(SOURCE) "$(INTDIR)"
244
	$(CPP) $(CPP_PROJ) $(SOURCE)
245
237
SOURCE=..\src\JPIAgent\utility.c
246
SOURCE=..\src\JPIAgent\utility.c
238
247
239
"$(INTDIR)\utility.obj" : $(SOURCE) "$(INTDIR)"
248
"$(INTDIR)\utility.obj" : $(SOURCE) "$(INTDIR)"
(-)src-native/build/BuildJPIAgentEM64T.mak (-2 / +11 lines)
Lines 46-51 Link Here
46
	-@erase "$(INTDIR)\Performance.obj"
46
	-@erase "$(INTDIR)\Performance.obj"
47
	-@erase "$(INTDIR)\Print.obj"
47
	-@erase "$(INTDIR)\Print.obj"
48
	-@erase "$(INTDIR)\PrintXML.obj"
48
	-@erase "$(INTDIR)\PrintXML.obj"
49
	-@erase "$(INTDIR)\Profiler.obj"
49
	-@erase "$(INTDIR)\utility.obj"
50
	-@erase "$(INTDIR)\utility.obj"
50
	-@erase "$(INTDIR)\vc*.idb"
51
	-@erase "$(INTDIR)\vc*.idb"
51
	-@erase "$(INTDIR)\BuildJPIAgent32.pch"
52
	-@erase "$(INTDIR)\BuildJPIAgent32.pch"
Lines 59-65 Link Here
59
"$(INTDIR)" :
60
"$(INTDIR)" :
60
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
61
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
61
62
62
CPP_PROJ=/nologo /MT /W3 /EHsc /O2 /I "./../include/Martini" /I "./../include/JPIAgent" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "EM64T_ARCH" /D "ECWRAPPER_EXPORTS" /Fp"$(INTDIR)\BuildJPIAgent.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
63
CPP_PROJ=/nologo /MT /W3 /EHsc /O2 /I "./../include/Martini" /I "$(JAVA_HOME)\include" /I "$(JAVA_HOME)\include\win32" /I "./../include/JPIAgent" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "EM64T_ARCH" /D "ECWRAPPER_EXPORTS" /Fp"$(INTDIR)\BuildJPIAgent.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
63
	
64
	
64
LINKEM64T=link.exe
65
LINKEM64T=link.exe
65
LINKEM64T_FLAGS=Rpcrt4.lib bufferoverflowu.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib uuid.lib MartiniOSA.lib /nologo /dll /pdb:none /machine:amd64 /out:"$(OUTDIR)\JPIAgent.dll" /implib:"$(OUTDIR)\JPIAgent.lib" /libpath:"..\bin\windows\release\EM64T" /libpath:"..\windows\debug\EM64T" 
66
LINKEM64T_FLAGS=Rpcrt4.lib bufferoverflowu.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib uuid.lib MartiniOSA.lib /nologo /dll /pdb:none /machine:amd64 /out:"$(OUTDIR)\JPIAgent.dll" /implib:"$(OUTDIR)\JPIAgent.lib" /libpath:"..\bin\windows\release\EM64T" /libpath:"..\windows\debug\EM64T" 
Lines 72-77 Link Here
72
	"$(INTDIR)\Performance.obj" \
73
	"$(INTDIR)\Performance.obj" \
73
	"$(INTDIR)\Print.obj" \
74
	"$(INTDIR)\Print.obj" \
74
	"$(INTDIR)\PrintXML.obj" \
75
	"$(INTDIR)\PrintXML.obj" \
76
	"$(INTDIR)\Profiler.obj" \
75
	"$(INTDIR)\utility.obj"
77
	"$(INTDIR)\utility.obj"
76
78
77
"$(OUTDIR)\JPIAgent.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINKEM64T_OBJS)
79
"$(OUTDIR)\JPIAgent.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINKEM64T_OBJS)
Lines 99-104 Link Here
99
	-@erase "$(INTDIR)\Performance.obj"
101
	-@erase "$(INTDIR)\Performance.obj"
100
	-@erase "$(INTDIR)\Print.obj"
102
	-@erase "$(INTDIR)\Print.obj"
101
	-@erase "$(INTDIR)\PrintXML.obj"
103
	-@erase "$(INTDIR)\PrintXML.obj"
104
	-@erase "$(INTDIR)\Profiler.obj"
102
	-@erase "$(INTDIR)\utility.obj"
105
	-@erase "$(INTDIR)\utility.obj"
103
	-@erase "$(INTDIR)\vc*.idb"
106
	-@erase "$(INTDIR)\vc*.idb"
104
	-@erase "$(INTDIR)\vc*.pdb"
107
	-@erase "$(INTDIR)\vc*.pdb"
Lines 114-120 Link Here
114
"$(INTDIR)" :
117
"$(INTDIR)" :
115
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
118
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
116
119
117
CPP_PROJ=/nologo /MTd /W3 /EHsc /Od /I "./../include/JPIAgent" /I "./../include/Martini" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "EM64T_ARCH" /D "ECWRAPPER_EXPORTS" /Fp"$(INTDIR)\BuildJPIAgentEM64T.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
120
CPP_PROJ=/nologo /MTd /W3 /EHsc /Od /I "./../include/JPIAgent" /I "$(JAVA_HOME)\include" /I "$(JAVA_HOME)\include\win32" /I "./../include/Martini" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "EM64T_ARCH" /D "ECWRAPPER_EXPORTS" /Fp"$(INTDIR)\BuildJPIAgentEM64T.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
118
	
121
	
119
LINKEM64T=link.exe
122
LINKEM64T=link.exe
120
LINKEM64T_FLAGS=Rpcrt4.lib bufferoverflowu.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib MartiniOSA.lib /nologo /dll /pdb:none /debug /machine:amd64 /out:"$(OUTDIR)\JPIAgent.dll" /implib:"$(OUTDIR)\JPIAgent.lib" /libpath:"..\bin\windows\debug\EM64T"
123
LINKEM64T_FLAGS=Rpcrt4.lib bufferoverflowu.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib MartiniOSA.lib /nologo /dll /pdb:none /debug /machine:amd64 /out:"$(OUTDIR)\JPIAgent.dll" /implib:"$(OUTDIR)\JPIAgent.lib" /libpath:"..\bin\windows\debug\EM64T"
Lines 126-131 Link Here
126
	"$(INTDIR)\Options.obj" \
129
	"$(INTDIR)\Options.obj" \
127
	"$(INTDIR)\Performance.obj" \
130
	"$(INTDIR)\Performance.obj" \
128
	"$(INTDIR)\Print.obj" \
131
	"$(INTDIR)\Print.obj" \
132
	"$(INTDIR)\Profiler.obj" \
129
	"$(INTDIR)\PrintXML.obj" \
133
	"$(INTDIR)\PrintXML.obj" \
130
	"$(INTDIR)\utility.obj"
134
	"$(INTDIR)\utility.obj"
131
135
Lines 224-229 Link Here
224
	$(CPP) $(CPP_PROJ) $(SOURCE)
228
	$(CPP) $(CPP_PROJ) $(SOURCE)
225
229
226
230
231
SOURCE=..\src\JPIAgent\Profiler.c
232
233
"$(INTDIR)\Profiler.obj" : $(SOURCE) "$(INTDIR)"
234
	$(CPP) $(CPP_PROJ) $(SOURCE)
235
227
SOURCE=..\src\JPIAgent\utility.c
236
SOURCE=..\src\JPIAgent\utility.c
228
237
229
"$(INTDIR)\utility.obj" : $(SOURCE) "$(INTDIR)"
238
"$(INTDIR)\utility.obj" : $(SOURCE) "$(INTDIR)"
(-)src-native/build/build_tptp_profiler.script (+1 lines)
Lines 21-26 Link Here
21
#--------------------------------------------------
21
#--------------------------------------------------
22
22
23
if test -a $TPTP_ACSDK_HOME/include/tptp/agents/BaseCollectorImpl.h ; then echo TPTP_ACSDK_HOME OK; else echo Please set TPTP_ACSDK_HOME; exit 1; fi
23
if test -a $TPTP_ACSDK_HOME/include/tptp/agents/BaseCollectorImpl.h ; then echo TPTP_ACSDK_HOME OK; else echo Please set TPTP_ACSDK_HOME; exit 1; fi
24
if test -a $JAVA_HOME/include/jni.h ; then echo JAVA_HOME OK; else echo Please set JAVA_HOME to a valid J2SE 5.0 JDK root; exit 1; fi
24
25
25
export EXTRA_INCLUDES='-I $(TPTP_ACSDK_HOME)/include -I $(TPTP_ACSDK_HOME)/include/tptp/agents'
26
export EXTRA_INCLUDES='-I $(TPTP_ACSDK_HOME)/include -I $(TPTP_ACSDK_HOME)/include/tptp/agents'
26
27
(-)src-native/build/BuildJPIAgentIPF.mak (-2 / +10 lines)
Lines 46-51 Link Here
46
	-@erase "$(INTDIR)\Performance.obj"
46
	-@erase "$(INTDIR)\Performance.obj"
47
	-@erase "$(INTDIR)\Print.obj"
47
	-@erase "$(INTDIR)\Print.obj"
48
	-@erase "$(INTDIR)\PrintXML.obj"
48
	-@erase "$(INTDIR)\PrintXML.obj"
49
	-@erase "$(INTDIR)\Profiler.obj"
49
	-@erase "$(INTDIR)\utility.obj"
50
	-@erase "$(INTDIR)\utility.obj"
50
	-@erase "$(INTDIR)\vc*.idb"
51
	-@erase "$(INTDIR)\vc*.idb"
51
	-@erase "$(INTDIR)\BuildJPIAgent32.pch"
52
	-@erase "$(INTDIR)\BuildJPIAgent32.pch"
Lines 59-65 Link Here
59
"$(INTDIR)" :
60
"$(INTDIR)" :
60
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
61
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
61
62
62
CPP_PROJ=/nologo /MT /W3 /EHsc /O2 /I "./../include/Martini" /I "./../include/JPIAgent" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "IPF_ARCH" /D "ECWRAPPER_EXPORTS" /Fp"$(INTDIR)\BuildJPIAgent.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
63
CPP_PROJ=/nologo /MT /W3 /EHsc /O2 /I "./../include/Martini" /I "$(JAVA_HOME)\include" /I "$(JAVA_HOME)\include\win32" /I "./../include/JPIAgent" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "IPF_ARCH" /D "ECWRAPPER_EXPORTS" /Fp"$(INTDIR)\BuildJPIAgent.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
63
	
64
	
64
LINKIPF=link.exe  
65
LINKIPF=link.exe  
65
LINKIPF_FLAGS=Rpcrt4.lib bufferoverflowu.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib uuid.lib MartiniOSA.lib /nologo /dll /pdb:none /machine:ia64 /out:"$(OUTDIR)\JPIAgent.dll" /implib:"$(OUTDIR)\JPIAgent.lib" /libpath:"..\bin\windows\release\IPF" /libpath:"..\windows\debug\IPF" 
66
LINKIPF_FLAGS=Rpcrt4.lib bufferoverflowu.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib uuid.lib MartiniOSA.lib /nologo /dll /pdb:none /machine:ia64 /out:"$(OUTDIR)\JPIAgent.dll" /implib:"$(OUTDIR)\JPIAgent.lib" /libpath:"..\bin\windows\release\IPF" /libpath:"..\windows\debug\IPF" 
Lines 71-76 Link Here
71
	"$(INTDIR)\Options.obj" \
72
	"$(INTDIR)\Options.obj" \
72
	"$(INTDIR)\Performance.obj" \
73
	"$(INTDIR)\Performance.obj" \
73
	"$(INTDIR)\Print.obj" \
74
	"$(INTDIR)\Print.obj" \
75
	"$(INTDIR)\Profiler.obj" \
74
	"$(INTDIR)\PrintXML.obj" \
76
	"$(INTDIR)\PrintXML.obj" \
75
	"$(INTDIR)\utility.obj"
77
	"$(INTDIR)\utility.obj"
76
78
Lines 99-104 Link Here
99
	-@erase "$(INTDIR)\Performance.obj"
101
	-@erase "$(INTDIR)\Performance.obj"
100
	-@erase "$(INTDIR)\Print.obj"
102
	-@erase "$(INTDIR)\Print.obj"
101
	-@erase "$(INTDIR)\PrintXML.obj"
103
	-@erase "$(INTDIR)\PrintXML.obj"
104
	-@erase "$(INTDIR)\Profiler.obj"
102
	-@erase "$(INTDIR)\utility.obj"
105
	-@erase "$(INTDIR)\utility.obj"
103
	-@erase "$(INTDIR)\vc*.idb"
106
	-@erase "$(INTDIR)\vc*.idb"
104
	-@erase "$(INTDIR)\vc*.pdb"
107
	-@erase "$(INTDIR)\vc*.pdb"
Lines 114-120 Link Here
114
"$(INTDIR)" :
117
"$(INTDIR)" :
115
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
118
    if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
116
119
117
CPP_PROJ=/nologo /MTd /W3 /EHsc /Od /I "./../include/JPIAgent" /I "./../include/Martini" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "IPF_ARCH" /D "ECWRAPPER_EXPORTS" /Fp"$(INTDIR)\BuildJPIAgentIPF.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
120
CPP_PROJ=/nologo /MTd /W3 /EHsc /Od /I "./../include/JPIAgent" /I "$(JAVA_HOME)\include" /I "$(JAVA_HOME)\include\win32" /I "./../include/Martini" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "IPF_ARCH" /D "ECWRAPPER_EXPORTS" /Fp"$(INTDIR)\BuildJPIAgentIPF.pch" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
118
	
121
	
119
LINKIPF=link.exe
122
LINKIPF=link.exe
120
LINKIPF_FLAGS=Rpcrt4.lib bufferoverflowu.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib uuid.lib MartiniOSA.lib /nologo /dll /pdb:none /debug /machine:ia64 /out:"$(OUTDIR)\JPIAgent.dll" /implib:"$(OUTDIR)\JPIAgent.lib" /libpath:"..\bin\windows\debug\IPF" 
123
LINKIPF_FLAGS=Rpcrt4.lib bufferoverflowu.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib uuid.lib MartiniOSA.lib /nologo /dll /pdb:none /debug /machine:ia64 /out:"$(OUTDIR)\JPIAgent.dll" /implib:"$(OUTDIR)\JPIAgent.lib" /libpath:"..\bin\windows\debug\IPF" 
Lines 126-131 Link Here
126
	"$(INTDIR)\Options.obj" \
129
	"$(INTDIR)\Options.obj" \
127
	"$(INTDIR)\Performance.obj" \
130
	"$(INTDIR)\Performance.obj" \
128
	"$(INTDIR)\Print.obj" \
131
	"$(INTDIR)\Print.obj" \
132
	"$(INTDIR)\Profiler.obj" \
129
	"$(INTDIR)\PrintXML.obj" \
133
	"$(INTDIR)\PrintXML.obj" \
130
	"$(INTDIR)\utility.obj"
134
	"$(INTDIR)\utility.obj"
131
135
Lines 224-229 Link Here
224
"$(INTDIR)\PrintXML.obj" : $(SOURCE) "$(INTDIR)"
228
"$(INTDIR)\PrintXML.obj" : $(SOURCE) "$(INTDIR)"
225
	$(CPP) $(CPP_PROJ) $(SOURCE)
229
	$(CPP) $(CPP_PROJ) $(SOURCE)
226
230
231
SOURCE=..\src\JPIAgent\Profiler.cpp
232
233
"$(INTDIR)\Profiler.obj" : $(SOURCE) "$(INTDIR)"
234
	$(CPP) $(CPP_PROJ) $(SOURCE)
227
235
228
SOURCE=..\src\JPIAgent\utility.c
236
SOURCE=..\src\JPIAgent\utility.c
229
237
(-)src-native/build/BuildJPIAgent32.dsp (-2 / +10 lines)
Lines 43-49 Link Here
43
# PROP Ignore_Export_Lib 0
43
# PROP Ignore_Export_Lib 0
44
# PROP Target_Dir ""
44
# PROP Target_Dir ""
45
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /c
45
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /c
46
# ADD CPP /nologo /MT /W3 /GX /Zi /O2 /I "./../include/Martini" /I "./../include/JPIAgent" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "IA32_ARCH" /D "ECWRAPPER_EXPORTS" /D "EC_ENV_EXPORTS" /YX /FD /c
46
# ADD CPP /nologo /MT /W3 /GX /Zi /O2 /I "./../include/Martini" /I "$(JAVA_HOME)\include" /I "$(JAVA_HOME)\include\win32" /I "./../include/JPIAgent" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "IA32_ARCH" /D "ECWRAPPER_EXPORTS" /D "EC_ENV_EXPORTS" /YX /FD /c
47
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
47
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
48
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
48
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
49
# ADD BASE RSC /l 0x409 /d "NDEBUG"
49
# ADD BASE RSC /l 0x409 /d "NDEBUG"
Lines 69-75 Link Here
69
# PROP Ignore_Export_Lib 0
69
# PROP Ignore_Export_Lib 0
70
# PROP Target_Dir ""
70
# PROP Target_Dir ""
71
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /GZ /c
71
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /GZ /c
72
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "./../include/JPIAgent" /I "./../include/Martini" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "IA32_ARCH" /D "ECWRAPPER_EXPORTS" /D "EC_ENV_EXPORTS" /YX /FD /GZ /c
72
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "./../include/JPIAgent" /I "./../include/Martini" /I "$(JAVA_HOME)\include" /I "$(JAVA_HOME)\include\win32" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "IA32_ARCH" /D "ECWRAPPER_EXPORTS" /D "EC_ENV_EXPORTS" /YX /FD /GZ /c
73
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
73
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
74
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
74
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
75
# ADD BASE RSC /l 0x409 /d "_DEBUG"
75
# ADD BASE RSC /l 0x409 /d "_DEBUG"
Lines 125-130 Link Here
125
# End Source File
125
# End Source File
126
# Begin Source File
126
# Begin Source File
127
127
128
SOURCE=..\src\JPIAgent\Profiler.c
129
# End Source File
130
# Begin Source File
131
128
SOURCE=..\src\JPIAgent\utility.c
132
SOURCE=..\src\JPIAgent\utility.c
129
# End Source File
133
# End Source File
130
# End Group
134
# End Group
Lines 181-186 Link Here
181
# End Source File
185
# End Source File
182
# Begin Source File
186
# Begin Source File
183
187
188
SOURCE=..\src\JPIAgent\Profiler.h
189
# End Source File
190
# Begin Source File
191
184
SOURCE=..\src\JPIAgent\strings.h
192
SOURCE=..\src\JPIAgent\strings.h
185
# End Source File
193
# End Source File
186
# Begin Source File
194
# Begin Source File
(-)src-native/src/ACCollector/ACCollector.cpp (-16 / +5 lines)
Lines 135-151 Link Here
135
    }
135
    }
136
136
137
    if (m_isEnabledDataCollection) {
137
    if (m_isEnabledDataCollection) {
138
        m_ACC_env->StartTracing();
139
        m_ACC_env->Attach(); 
138
        m_ACC_env->Attach(); 
140
        m_isWaiting = false;
139
        m_isWaiting = false;
141
        m_ACC_env->Start();
140
        m_ACC_env->StartTracing();
142
        m_isTracing = true;
141
        m_isTracing = true;
143
    }
142
    }
144
    else {
143
    else {
145
        m_ACC_env->Attach(); 
144
        m_ACC_env->Attach(); 
146
        m_isWaiting = false;
145
        m_isWaiting = false;
147
        m_isTracing = true;
146
        m_isTracing = true;
148
        m_isFirstAfterStart = true;
149
    }
147
    }
150
//    if (m_ACC_env->IsAgentInitialized()) {
148
//    if (m_ACC_env->IsAgentInitialized()) {
151
//        SendVMAgentInitializedCommand();
149
//        SendVMAgentInitializedCommand();
Lines 163-169 Link Here
163
    if (!isAgentInitialized(cmdBlock->getContextID())) {
161
    if (!isAgentInitialized(cmdBlock->getContextID())) {
164
        return 0;
162
        return 0;
165
    }
163
    }
166
    m_ACC_env->Stop();
167
    m_ACC_env->Detach();
164
    m_ACC_env->Detach();
168
    m_ACC_env->StopTracing();
165
    m_ACC_env->StopTracing();
169
    m_isTracing = false;
166
    m_isTracing = false;
Lines 178-194 Link Here
178
        return 0;
175
        return 0;
179
    }
176
    }
180
177
181
178
    m_ACC_env->StartTracing(); 
182
    if (m_isFirstAfterStart && !m_isEnabledDataCollection) {
183
        m_ACC_env->StartTracing();
184
//        m_ACC_env->Start();
185
        m_ACC_env->Resume();
186
        m_isFirstAfterStart = false;
187
    }
188
    else {
189
        m_ACC_env->Resume();
190
    }
191
192
179
193
    return BaseCollectorImpl::resume(cmdBlock);
180
    return BaseCollectorImpl::resume(cmdBlock);
194
}
181
}
Lines 203-209 Link Here
203
    if (!isAgentInitialized(cmdBlock->getContextID())) {
190
    if (!isAgentInitialized(cmdBlock->getContextID())) {
204
        return 0;
191
        return 0;
205
    }
192
    }
206
    m_ACC_env->Pause();
193
194
    m_ACC_env->StopTracing();
195
207
    return BaseCollectorImpl::pause(cmdBlock);
196
    return BaseCollectorImpl::pause(cmdBlock);
208
}
197
}
209
198
(-)src-native/include/JPIAgent/ACC_Env.h (-21 / +1 lines)
Lines 1-5 Link Here
1
/************************************************************************
1
/************************************************************************
2
 * Copyright (c) 2005 - 2007 Intel Corporation.
2
 * Copyright (c) 2005 - 2008 Intel Corporation.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 38-47 Link Here
38
struct ACCFunctions_ {
38
struct ACCFunctions_ {
39
    void (ACC_CALL *StartTracing)();
39
    void (ACC_CALL *StartTracing)();
40
    void (ACC_CALL *StopTracing)();
40
    void (ACC_CALL *StopTracing)();
41
    void (ACC_CALL *Start)();
42
    void (ACC_CALL *Stop)();
43
    void (ACC_CALL *Pause)();
44
    void (ACC_CALL *Resume)();
45
    void (ACC_CALL *Detach)();
41
    void (ACC_CALL *Detach)();
46
    void (ACC_CALL *Attach)();
42
    void (ACC_CALL *Attach)();
47
    void (ACC_CALL *AddFilter)(char *iid, char *classPattern, char *methodPattern, char *filterMode);//strcmp("INCLUDE", mode) == 0 ? INCLUDE : EXCLUDE
43
    void (ACC_CALL *AddFilter)(char *iid, char *classPattern, char *methodPattern, char *filterMode);//strcmp("INCLUDE", mode) == 0 ? INCLUDE : EXCLUDE
Lines 66-87 Link Here
66
        functions->StopTracing();
62
        functions->StopTracing();
67
    }
63
    }
68
64
69
    void Start() {
70
        functions->Start();
71
    }
72
73
    void Stop() {
74
        functions->Stop();
75
    }
76
77
    void Pause() {
78
        functions->Pause();
79
    }
80
81
    void Resume() {
82
        functions->Resume();
83
    }
84
85
    void Detach() {
65
    void Detach() {
86
        functions->Detach();
66
        functions->Detach();
87
    }
67
    }
(-)src-native/src/JPIAgent/Profiler.c (+73 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 Intel Corporation.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * $Id: Profiler.c,v 1.0 2008/01/21 21:32:13 ialelekov Exp $ 
9
 ***********************************************************************/
10
11
#include "Profiler.h"
12
13
extern void appStartTracing();		// defined in ECWrapper.cpp
14
extern void appStopTracing();
15
extern int isProfilerApiEnabled();
16
extern int runGC();
17
extern void printCustomElement(const char* str);
18
19
JNIEXPORT jint JNICALL Java_org_eclipse_tptp_profiler_Profiler_initialize0
20
  (JNIEnv *env, jobject thisObj) {
21
  
22
  	return isProfilerApiEnabled() ? 0 : -1;
23
  }
24
25
/*
26
 * Class:     org_eclipse_tptp_profiler_Profiler
27
 * Method:    startProfiling0
28
 * Signature: ()I
29
 */
30
JNIEXPORT jint JNICALL Java_org_eclipse_tptp_profiler_Profiler_startProfiling0
31
  (JNIEnv *env, jobject thisObj) {
32
33
  	appStartTracing();
34
  
35
  	return 0;
36
  }
37
38
/*
39
 * Class:     org_eclipse_tptp_profiler_Profiler
40
 * Method:    stopProfiling0
41
 * Signature: ()I
42
 */
43
JNIEXPORT jint JNICALL Java_org_eclipse_tptp_profiler_Profiler_stopProfiling0
44
  (JNIEnv *env, jobject thisObj) {
45
46
	if (!isProfilerApiEnabled()) return -1;
47
  	
48
	appStopTracing();
49
  
50
  	return 0;
51
  }
52
  
53
/*
54
 * Class:     org_eclipse_tptp_profiler_Profiler
55
 * Method:    runGC0
56
 * Signature: ()I
57
 */
58
JNIEXPORT jint JNICALL Java_org_eclipse_tptp_profiler_Profiler_runGC0
59
  (JNIEnv *env, jobject thisObj) {
60
61
	runGC();
62
  
63
  	return 0;
64
  }
65
   
66
 JNIEXPORT void JNICALL Java_org_eclipse_tptp_profiler_Profiler_emitXMLFragment0
67
  (JNIEnv *env, jobject thisObj, jstring xmlFragment) {
68
 
69
 	const char *native = (*env)->GetStringUTFChars(env, xmlFragment, NULL);
70
 	printCustomElement(native);
71
	(*env)->ReleaseStringUTFChars(env, xmlFragment, native);
72
 }
73
 
(-)src/org/eclipse/tptp/profiler/ProfilerNotAvailableException.java (+23 lines)
Added Link Here
1
/************************************************************************
2
 * Copyright (c) 2008 Intel Corporation.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *    Intel Corporation - Initial API and implementation
10
 *
11
 * $Id: ProfilerNotAvailableException.java,v 1.0 2008/02/06 14:58:42 ialelekov Exp $  
12
 ************************************************************************/
13
package org.eclipse.tptp.profiler;
14
15
/**
16
 * Thrown if required library <code>JPIAgent</code> can not be found.   
17
 * See the Profiler's documentation for details of the environment setting.
18
 * 
19
 * @since TPTP 4.5
20
 */
21
public class ProfilerNotAvailableException extends Exception {
22
	private static final long serialVersionUID = 1L;
23
}
(-)src/org/eclipse/tptp/profiler/Profiler.java (+145 lines)
Added Link Here
1
/************************************************************************
2
 * Copyright (c) 2008 Intel Corporation.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *    Intel Corporation - Initial API and implementation
10
 *
11
 * $Id: Profiler.java,v 1.0 2008/02/06 14:58:42 ialelekov Exp $  
12
 ************************************************************************/
13
package org.eclipse.tptp.profiler;
14
15
/**
16
 * Exposes an API for controlling the profiler. 
17
 * This class is a singleton and cannot be instantiated by the user. 
18
 * In order to access it an application must use {@link #getProfiler()}.
19
 * 
20
 * @since TPTP 4.5
21
 */
22
23
public class Profiler {
24
	private final static String AGENT_NAME = "JPIAgent";
25
	private static Profiler instance = null;
26
	private static boolean nativesAvailable = false;
27
28
	private boolean isProfiling = false;
29
	private boolean isActive = false;
30
31
	static {
32
		try {
33
			System.loadLibrary(AGENT_NAME);
34
			nativesAvailable = true;
35
		}
36
		catch(Throwable e) {}
37
	}
38
	
39
	/**
40
	 * Native delegate to startup the profiler.  Checks if profiling is possible.
41
	 */
42
	 private native int initialize0();
43
44
	 private Profiler() {
45
		isActive = initialize0() == 0;
46
	}
47
	
48
	/**
49
	 * Returns the singleton Profiler's instance.
50
	 * 	 
51
	 * @return Profiler
52
	 * @throws ProfilerAPINotAvailableException - If API is disabled
53
	 * @throws ProfilerNotAvailableException - If native library <code>JPIAgent</code> not found
54
	 */
55
	public static Profiler getProfiler() throws ProfilerNotAvailableException {
56
		if (!nativesAvailable) throw new ProfilerNotAvailableException();
57
		
58
		if (instance == null) instance = new Profiler();
59
		
60
		if (!instance.isActive) throw new ProfilerAPINotAvailableException();
61
		
62
		return instance;
63
	}
64
65
	/**
66
	 * Native delegate of startProfiling().
67
	 * @returns  0 - the profile session was created successfuly.
68
	 *
69
	 */
70
	private native int startProfiling0();
71
72
	/**
73
	 * Starts data collection.
74
	 * 
75
	 * @return <code>true</code> if data collection started; <code>false</code> otherwise
76
	 * @throws ProfilerAPINotAvailableException - If API is disabled
77
	 */
78
	public boolean startProfiling() throws ProfilerAPINotAvailableException {
79
		if (!isActive) throw new ProfilerAPINotAvailableException();
80
81
		synchronized(this) {
82
			if (!isProfiling) {
83
				isProfiling = startProfiling0() == 0;
84
			}
85
		}
86
		
87
		return isProfiling;
88
	}
89
	
90
	/**
91
	 * Native delgate to stopProfiling.
92
	 */
93
	private native int stopProfiling0();
94
	
95
	/**
96
	 * Stops data collection.
97
	 * 
98
	 * @return <code>true</code> if data collection stopped; <code>false</code> otherwise
99
	 * @throws ProfilerAPINotAvailableException - If API is disabled
100
	 */
101
	public boolean stopProfiling() throws ProfilerAPINotAvailableException {
102
		if (!isActive) throw new ProfilerAPINotAvailableException();
103
104
		synchronized(this) {
105
			if (isProfiling) {
106
				isProfiling = !(stopProfiling0() == 0);
107
			}
108
		}
109
		
110
		return !isProfiling;
111
	}
112
	
113
	/**
114
	 * Native delgate to runGC.
115
	 */
116
	private native int runGC0();
117
	
118
	/**
119
	 * Runs the garbage collector.
120
	 * 
121
	 * @throws ProfilerAPINotAvailableException - If API is disabled
122
	 */
123
	public void runGC() throws ProfilerAPINotAvailableException {
124
		if (!isActive) throw new ProfilerAPINotAvailableException();
125
126
		runGC0();
127
	}
128
	
129
	/**
130
	 * Native delgate to emitXMLFragment.
131
	 */
132
	private native void emitXMLFragment0(String xmlFragment);
133
	
134
	/**
135
	 * Saves the XML fragment to the output destination.
136
	 * 
137
	 * @param xmlFragment - The XML fragment to save
138
	 * @throws ProfilerAPINotAvailableException - If API is disabled
139
	 */
140
	public void emitXMLFragment(String xmlFragment) throws ProfilerAPINotAvailableException {
141
		if (!isActive) throw new ProfilerAPINotAvailableException();
142
143
		emitXMLFragment0(xmlFragment);
144
	}
145
}
(-)src-native/src/JPIAgent/Profiler.h (+63 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 Intel Corporation.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * $Id: Profiler.h,v 1.0 2008/01/21 21:32:13 ialelekov Exp $ 
9
 ***********************************************************************/
10
 
11
/* DO NOT EDIT THIS FILE - it is machine generated */
12
#include <jni.h>
13
/* Header for class org_eclipse_tptp_platform_jvmti_runtime_profiler_Profiler */
14
15
#ifndef _Included_org_eclipse_tptp_profiler_Profiler
16
#define _Included_org_eclipse_tptp_profiler_Profiler
17
#ifdef __cplusplus
18
extern "C" {
19
#endif
20
/*
21
 * Class:     org_eclipse_tptp_profiler_Profiler
22
 * Method:    initialize0
23
 * Signature: ()I
24
 */
25
JNIEXPORT jint JNICALL Java_org_eclipse_tptp_profiler_Profiler_initialize0
26
  (JNIEnv *, jobject);
27
28
/*
29
 * Class:     org_eclipse_tptp_profiler_Profiler
30
 * Method:    startProfiling0
31
 * Signature: ()I
32
 */
33
JNIEXPORT jint JNICALL Java_org_eclipse_tptp_profiler_Profiler_startProfiling0
34
  (JNIEnv *, jobject);
35
36
/*
37
 * Class:     org_eclipse_tptp_profiler_Profiler
38
 * Method:    stopProfiling0
39
 * Signature: ()I
40
 */
41
JNIEXPORT jint JNICALL Java_org_eclipse_tptp_profiler_Profiler_stopProfiling0
42
  (JNIEnv *, jobject);
43
44
/*
45
 * Class:     org_eclipse_tptp_profiler_Profiler
46
 * Method:    runGC0
47
 * Signature: ()I
48
 */
49
JNIEXPORT jint JNICALL Java_org_eclipse_tptp_profiler_Profiler_runGC0
50
  (JNIEnv *, jobject);
51
52
/*
53
 * Class:     org_eclipse_tptp_profiler_Profiler
54
 * Method:    emitXMLFragment0
55
 * Signature: (Ljava/lang/String;)I
56
 */
57
JNIEXPORT void JNICALL Java_org_eclipse_tptp_profiler_Profiler_emitXMLFragment0
58
  (JNIEnv *, jobject, jstring);
59
60
#ifdef __cplusplus
61
}
62
#endif
63
#endif
(-)src/org/eclipse/tptp/profiler/ProfilerAPINotAvailableException.java (+23 lines)
Added Link Here
1
/************************************************************************
2
 * Copyright (c) 2008 Intel Corporation.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *    Intel Corporation - Initial API and implementation
10
 *
11
 * $Id: ProfilerAPINotAvailableException.java,v 1.0 2008/02/06 14:58:42 ialelekov Exp $  
12
 ************************************************************************/
13
package org.eclipse.tptp.profiler;
14
15
/**
16
 * Thrown when an application attempts to use disabled Profiler API.   
17
 * To enable API see the Profiler's documentation.
18
 *
19
 * @since TPTP 4.5
20
 */
21
public class ProfilerAPINotAvailableException extends ProfilerNotAvailableException {
22
	private static final long serialVersionUID = 1L;
23
}

Return to bug 200251