Commit 15fe301b authored by john's avatar john
Browse files

added patch for zlib to make 64bit lib and added options for passing base for jars

parent 3d925817
......@@ -21,17 +21,24 @@
<equals arg1="${os.name}" arg2="linux" casesensitive="no" trim="yes"/>
</condition>
<condition property="32bit">
<equals arg1="${os.name}" arg2="32" casesensitive="no" trim="yes"/>
</condition>
<condition property="64bit">
<equals arg1="${os.name}" arg2="64" casesensitive="no" trim="yes"/>
</condition>
<property name="download-dir" value="${agent-dir}/download"/>
<!-- http://zlib.net/zlib-1.2.5.tar.gz -->
<property name="zlib" value="zlib"/>
<property name="zlib-version" value="1.2.5"/>
<property name="zlib-basename" value="${zlib}-${zlib-version}"/>
<property name="zlib-name" value="${zlib-basename}.tar.gz"/>
<property name="zlib-url" value="http://${zlib}.net"/>
<property name="zlib-lib-base" value="z"/>
<property name="cli" value="commons-cli"/>
<property name="cli-version" value="1.2"/>
<property name="cli-basename" value="${cli}-${cli-version}"/>
......@@ -47,17 +54,34 @@
<mkdir dir="${dist-dir}"/>
</target>
<target name="libs" depends="init,asm,bcel">
<target name="zlibsrc" depends="init">
<antcall target="check-source">
<param name="target-file" value="${zlib-name}" />
<param name="target-dir" value="${download-dir}" />
<param name="target-url" value="${zlib-url}"/>
</antcall>
<untar src="${download-dir}/${zlib-name}" dest="${agent-dir}/build" compression="gzip"/>
<patch patchfile="${agent-dir}/${zlib}.patch" dir="${agent-dir}/build" strip="1" ignorewhitespace="yes"/>
</target>
<target name="buildzlib32" depends="init,zlibsrc" unless="64bit">
<exec executable="sh" dir="${agent-dir}/build/${zlib-basename}" >
<arg value="configure"/>
</exec>
<exec executable="make" dir="${agent-dir}/build/${zlib-basename}" />
</target>
<target name="buildzlib64" depends="init,zlibsrc" if="64bit">
<exec executable="sh" dir="${agent-dir}/build/${zlib-basename}" >
<arg value="configure"/>
<arg value="--64"/>
</exec>
<exec executable="make" dir="${agent-dir}/build/${zlib-basename}" />
</target>
<target name="buildzlib" depends="buildzlib32,buildzlib64"/>
<target name="libs" depends="init,asm,bcel,buildzlib">
<copy file="${asm-jar}" todir="${dist-dir}"/>
<copy file="${asm-commons-jar}" todir="${dist-dir}"/>
......@@ -93,7 +117,7 @@
<arg value="JAVA_HOME=${java.home}/.."/>
<arg value="OSNAME=linux"/>
<!-- <arg value="OPT=true"/> -->
<arg value="ZLIB_DIR=${agent-dir}/build/${zlib-basename}"/>
<arg value="ZLIB_DIR=${agent-dir}/build/${zlib-basename}"/>
<arg value="ZLIB_LIB=${zlib-lib-base}"/>
</exec>
<copy todir="${agent-dir}/lib">
......
......@@ -46,6 +46,9 @@
#define LOG_FILE_NAME "DACAPO_JVMTI_LOG_FILE"
#define DEFAULT_LOG_FILE_NAME "dacapo-jvmti.log"
#define JAR_LIST "agent.jar:asm-3.3.jar:asm-commons-3.3.jar"
#define JAR_BASE "dist"
struct class_list_s {
struct class_list_s* next;
jclass klass;
......@@ -60,12 +63,15 @@ jvmtiCapabilities availableCapabilities;
jvmtiCapabilities capabilities;
jvmtiEventCallbacks callbacks;
MonitorLockType agentLock;
MonitorLockType lockClass;
MonitorLockType agentLock;
MonitorLockType lockClass;
jboolean jvmRunning = FALSE;
jboolean jvmStopped = FALSE;
char agentOptions[12800];
char* agentOptions = NULL; // [12800];
char* jarList = JAR_LIST;
char* jarBase = JAR_BASE;
char* jarSet = NULL;
jboolean requiresTransform = FALSE;
jboolean storeClassFiles = FALSE;
jboolean instrumentClasses = FALSE;
......@@ -75,7 +81,7 @@ jboolean storeClassFilesTXed = FALSE;
char storeClassFileBase[8192];
jboolean breakOnLoad = FALSE;
char breakOnLoadClass[10240];
char* breakOnLoadClass = NULL;
struct exclude_list_s {
struct exclude_list_s* next;
......@@ -129,9 +135,9 @@ void reportJVMTIError(FILE* fh, jvmtiError errorNumber, const char *str)
static void agent_exclude_list()
{
char temp[MAX_EXCLUDE_LIST_LENGTH];
char* temp = NULL;
if (isSelected(OPT_EXCLUDE_CLASSES,temp)) {
if (isSelected(OPT_EXCLUDE_CLASSES,&temp)) {
int start=0, next=0;
while (temp[next] != '\0') {
......@@ -156,7 +162,12 @@ static void agent_exclude_list()
}
}
if (isSelected(OPT_EXCLUDE_PACKAGES,temp)) {
if (temp != NULL) {
free(temp);
temp = NULL;
}
if (isSelected(OPT_EXCLUDE_PACKAGES,&temp)) {
int start=0, next=0;
while (temp[next] != '\0') {
......@@ -180,8 +191,58 @@ static void agent_exclude_list()
start = ++next;
}
}
if (temp != NULL) {
free(temp);
temp = NULL;
}
}
static void agent_ext_java()
{
char* temp = NULL;
const char* newJarBase = jarBase;
if (isSelected(OPT_BASE,&temp))
newJarBase = (temp != NULL)?temp:jarBase;
int newJarBaseLength = strlen(newJarBase);
int jarCount = 1;
int i = 0;
int jarListLength = strlen(jarList);
for(i = 0; i < jarListLength; i++) {
if (jarList[i] == ':') jarCount++;
}
int slash = newJarBase[newJarBaseLength-1]=='/'?0:1;
int jarSetSize = (newJarBaseLength + slash) * jarCount + jarListLength;
jarSet = (char*)malloc(sizeof(char)*(jarSetSize + 1));
char* jarSetPtr = jarSet;
int j = -1;
for(i = 0; i < jarCount; i++) {
strcpy(jarSetPtr,newJarBase);
jarSetPtr += newJarBaseLength;
if (slash==1) *(jarSetPtr++) = '/';
int k = j+1;
while (jarList[k]!=':' && jarList[k]!='\0') {
*(jarSetPtr++) = jarList[k++];
}
if ((i + 1) < jarCount) *(jarSetPtr++) = ':';
j = k;
}
jarSet[jarSetSize] = '\0';
if (temp != NULL) {
free(temp);
temp = NULL;
}
}
/* Agent_OnLoad: This is called immediately after the shared library is
* loaded. This is the first code executed.
*/
......@@ -200,12 +261,10 @@ Agent_OnLoad(JavaVM *vm, char *options, void *reserved)
(void)memset(&lockTag,0, sizeof(lockTag));
(void)memset(&lockClass,0, sizeof(lockClass));
if (options==NULL || strlen(options)==0) {
agentOptions[0] = '\0';
} else {
strncpy(agentOptions,options,sizeof(agentOptions)-1);
if (options!=NULL && strlen(options)!=0) {
agentOptions = (char*)malloc(strlen(options)+1);
strcpy(agentOptions,options);
}
agentOptions[sizeof(agentOptions)-1] = '\0';
jvm = vm;
res = JVMTI_FUNC_PTR(jvm,GetEnv)(jvm, (void **)&baseEnv, JVMTI_VERSION_1);
......@@ -264,6 +323,8 @@ Agent_OnLoad(JavaVM *vm, char *options, void *reserved)
return FALSE;
}
agent_ext_java();
agent_exclude_list();
allocation_init();
exception_init();
......@@ -358,7 +419,7 @@ static void processOptions() {
loadClasses = isSelected(OPT_LOAD_CLASSES,NULL);
methodCalls = isSelected(OPT_METHOD_EVENTS,NULL);
breakOnLoad = isSelected(OPT_BREAK,breakOnLoadClass);
breakOnLoad = isSelected(OPT_BREAK,&breakOnLoadClass);
instrumentClasses =
isSelected(OPT_CLINIT,NULL) ||
......@@ -550,7 +611,8 @@ callbackClassFileLoadHook(jvmtiEnv *jvmti, JNIEnv* env,
*new_class_data = NULL;
*new_class_data_len = 0;
sprintf(command, "java -classpath dist/agent.jar:dist/asm-3.3.jar:dist/asm-commons-3.3.jar org.dacapo.instrument.Instrument '%s' '%s' '%s' \"%s\"",infile,outfile,(name!=NULL?name:"NULL"),agentOptions);
sprintf(command, "java -classpath \"%s\" org.dacapo.instrument.Instrument \"%s\" \"%s\" \"%s\" \"%s\"",jarSet,infile,outfile,(name!=NULL?name:"NULL"),agentOptions);
if (system(command) == 0) {
readClassData(infile,new_class_data,new_class_data_len);
}
......
......@@ -25,9 +25,13 @@ void allocation_callbacks(const jvmtiCapabilities* capabilities, jvmtiEventCallb
if (capabilities->can_generate_vm_object_alloc_events) DEFINE_CALLBACK(callbacks,VMObjectAlloc,JVMTI_EVENT_VM_OBJECT_ALLOC);
if (capabilities->can_generate_object_free_events) DEFINE_CALLBACK(callbacks,ObjectFree,JVMTI_EVENT_OBJECT_FREE);
}
char arg[1024];
if (isSelected(OPT_GC,arg)) {
char* arg = NULL;
if (isSelected(OPT_GC,&arg)) {
gcForceCycle = atol(arg);
if (arg != NULL) {
free(arg);
arg = NULL;
}
}
}
......
......@@ -18,11 +18,13 @@ void call_chain_callbacks(const jvmtiCapabilities* capabilities, jvmtiEventCallb
void call_chain_logon(JNIEnv* env) {
if (jvmRunning && !jvmStopped) {
char arg[1024];
char* arg = NULL;
long frequency = 0;
if (isSelected(OPT_CALL_CHAIN,arg))
if (isSelected(OPT_CALL_CHAIN,&arg))
frequency = atol(arg);
free(arg);
if (0 < frequency) {
setReportCallChain(env, frequency, (jboolean)TRUE);
} else {
......
......@@ -195,9 +195,13 @@ _Bool dacapo_log_init() {
}
/* make log file */
char tmpFile[10240];
if (isSelected(OPT_LOG_FILE,tmpFile)) {
char* tmpFile = NULL;
if (isSelected(OPT_LOG_FILE,&tmpFile)) {
setLogFileName(tmpFile);
if (tmpFile != NULL) {
free(tmpFile);
tmpFile = NULL;
}
}
gettimeofday(&startTime, NULL);
......
......@@ -44,14 +44,16 @@ static struct option_s* findOption(const char* option) {
return NULL;
}
_Bool isSelected(const char* option, char* argument) {
_Bool isSelected(const char* option, char** argument) {
struct option_s* opt = findOption(option);
if (opt!=NULL && argument!=NULL) {
if (opt->argument!=NULL)
strncpy(argument,opt->argument,opt->argLength);
argument[opt->argLength]='\0';
if (opt != NULL && argument != NULL) {
if (*argument==NULL)
*argument = (char*)malloc(opt->argLength+1);
if (0 < opt->argLength) strncpy(*argument,opt->argument,opt->argLength);
(*argument)[opt->argLength]='\0';
}
return opt!=NULL;
}
......
......@@ -12,7 +12,7 @@
#define OPT_LOAD_CLASSES "load_classes"
#define OPT_THREAD "thread"
#define OPT_ALLOCATE "allocate"
#define OPT_POINTER "pointer"
#define OPT_POINTER "pointer"
#define OPT_BREAK "break"
#define OPT_MONITOR "monitor"
#define OPT_LOG_FILE "log_file"
......@@ -26,8 +26,9 @@
#define OPT_INTERVAL "interval"
#define OPT_EXCLUDE_PACKAGES "exclude_package"
#define OPT_EXCLUDE_CLASSES "exclude_classes"
#define OPT_BASE "base"
_Bool isSelected(const char* option, char* argument);
_Bool isSelected(const char* option, char** argument);
_Bool hasArgument(const char* option);
void reportOptionsList();
void makeOptionList(const char* options);
......
......@@ -238,7 +238,7 @@ public class AllocateInstrument extends Instrument {
mg.returnValue();
mg.endMethod();
} catch (NoSuchMethodException nsme) {
} catch (NoSuchMethodException nsme) {
System.err.println("Unable to find "+LOG_INTERNAL_NAME);
System.err.println("M:"+nsme);
nsme.printStackTrace();
......
diff -urNw zl-a/zlib-1.2.5/configure zl-e/zlib-1.2.5/configure
--- zl-a/zlib-1.2.5/configure 2010-04-20 14:15:19.000000000 +1000
+++ zl-e/zlib-1.2.5/configure 2010-07-15 11:14:43.758060936 +1000
@@ -106,7 +106,7 @@
if test "$gcc" -eq 1 && ($cc -c $cflags $test.c) 2>/dev/null; then
CC="$cc"
SFLAGS="${CFLAGS--O3} -fPIC"
- CFLAGS="${CFLAGS--O3}"
+ CFLAGS="${CFLAGS--O3} -fPIC"
if test $build64 -eq 1; then
CFLAGS="${CFLAGS} -m64"
SFLAGS="${SFLAGS} -m64"
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment