hotspot/agent/src/share/native/sadis.c
changeset 16351 032b310a3e2f
parent 14847 92a59a418262
child 28162 cf13d6e8e46f
equal deleted inserted replaced
15935:50da9e5eb858 16351:032b310a3e2f
     1 /*
     1 /*
     2  * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    46 
    46 
    47 #else
    47 #else
    48 
    48 
    49 #include <string.h>
    49 #include <string.h>
    50 #include <dlfcn.h>
    50 #include <dlfcn.h>
       
    51 
       
    52 #ifndef __APPLE__
    51 #include <link.h>
    53 #include <link.h>
       
    54 #endif
    52 
    55 
    53 #endif
    56 #endif
    54 
    57 
    55 #include <limits.h>
    58 #include <limits.h>
    56 #include <stdio.h>
    59 #include <stdio.h>
   107                                                                            jclass disclass,
   110                                                                            jclass disclass,
   108                                                                            jstring jrepath_s,
   111                                                                            jstring jrepath_s,
   109                                                                            jstring libname_s) {
   112                                                                            jstring libname_s) {
   110   uintptr_t func = 0;
   113   uintptr_t func = 0;
   111   const char* error_message = NULL;
   114   const char* error_message = NULL;
   112   const char* java_home;
       
   113   jboolean isCopy;
   115   jboolean isCopy;
   114   uintptr_t *handle = NULL;
       
   115 
   116 
   116   const char * jrepath = (*env)->GetStringUTFChars(env, jrepath_s, &isCopy); // like $JAVA_HOME/jre/lib/sparc/
   117   const char * jrepath = (*env)->GetStringUTFChars(env, jrepath_s, &isCopy); // like $JAVA_HOME/jre/lib/sparc/
   117   const char * libname = (*env)->GetStringUTFChars(env, libname_s, &isCopy);
   118   const char * libname = (*env)->GetStringUTFChars(env, libname_s, &isCopy);
   118   char buffer[128];
   119   char buffer[128];
   119 
   120 
   165                              unsigned char* start, uintptr_t length,
   166                              unsigned char* start, uintptr_t length,
   166                              void* (*event_callback)(void*, const char*, void*),
   167                              void* (*event_callback)(void*, const char*, void*),
   167                              void* event_stream,
   168                              void* event_stream,
   168                              int (*printf_callback)(void*, const char*, ...),
   169                              int (*printf_callback)(void*, const char*, ...),
   169                              void* printf_stream,
   170                              void* printf_stream,
   170                              const char* options);
   171                              const char* options,
       
   172                              int newline);
   171 
   173 
   172 /* container for call back state when decoding instructions */
   174 /* container for call back state when decoding instructions */
   173 typedef struct {
   175 typedef struct {
   174   JNIEnv* env;
   176   JNIEnv* env;
   175   jobject dis;
   177   jobject dis;
   279                                                          startPc + end - start,
   281                                                          startPc + end - start,
   280                                                          (unsigned char*)start,
   282                                                          (unsigned char*)start,
   281                                                          end - start,
   283                                                          end - start,
   282                                                          &event_to_env,  (void*) &denv,
   284                                                          &event_to_env,  (void*) &denv,
   283                                                          &printf_to_env, (void*) &denv,
   285                                                          &printf_to_env, (void*) &denv,
   284                                                          options);
   286                                                          options, 0 /* newline */);
   285 
   287 
   286   /* cleanup */
   288   /* cleanup */
   287   (*env)->ReleaseByteArrayElements(env, code, start, JNI_ABORT);
   289   (*env)->ReleaseByteArrayElements(env, code, start, JNI_ABORT);
   288   (*env)->ReleaseStringUTFChars(env, options_s, options);
   290   (*env)->ReleaseStringUTFChars(env, options_s, options);
   289 }
   291 }