< prev index next >

test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/GetLocalVariable/getlocal003/getlocal003.cpp

Print this page


   1 /*
   2  * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */


  50   printf(", signature: %s\n", lvt_elem->signature);
  51 }
  52 
  53 static void
  54 test_locals(jvmtiEnv *jvmti, jthread thr, jlocation location) {
  55     jvmtiError err;
  56     jint intVal;
  57     jlong longVal;
  58     jfloat floatVal;
  59     jdouble doubleVal;
  60     jobject obj;
  61     jint i;
  62 
  63     for (i = 0; i < entryCount; i++) {
  64         if (table[i].start_location > location ||
  65             table[i].start_location + table[i].length < location) {
  66             continue;  /* The local variable is not visible */
  67         }
  68         print_LocalVariableEntry(&table[i]);
  69         char sig = table[i].signature[0];
  70         int slot = table[i].slot;
  71 
  72         if (sig == 'Z' || sig == 'B' || sig == 'C' || sig == 'S') {
  73             sig = 'I'; // covered by GetLocalInt
  74         }
  75         err = jvmti->GetLocalInt(thr, 0, slot, &intVal);
  76         printf(" GetLocalInt:     %s (%d)\n", TranslateError(err), err);
  77         if (err != JVMTI_ERROR_NONE && sig == 'I') {
  78             printf("FAIL: GetLocalInt failed to get value of int\n");
  79             result = STATUS_FAILED;
  80         } else if (err != JVMTI_ERROR_TYPE_MISMATCH && sig != 'I') {
  81             printf("FAIL: GetLocalInt did not return JVMTI_ERROR_TYPE_MISMATCH for non-int\n");
  82             result = STATUS_FAILED;
  83         }
  84 
  85         err = jvmti->GetLocalLong(thr, 0, slot, &longVal);
  86         printf(" GetLocalLong:    %s (%d)\n", TranslateError(err), err);
  87         if (err != JVMTI_ERROR_NONE && sig == 'J') {
  88             printf("FAIL: GetLocalLong failed to get value of long\n");
  89             result = STATUS_FAILED;
  90         } else if (err != JVMTI_ERROR_INVALID_SLOT &&
  91                    err != JVMTI_ERROR_TYPE_MISMATCH &&
  92                    sig != 'J') {
  93             printf("FAIL: GetLocalLong did not return JVMTI_ERROR_INVALID_SLOT"
  94                    " nor JVMTI_ERROR_TYPE_MISMATCH for non-long\n");
  95             result = STATUS_FAILED;
  96         }
  97 
  98         err = jvmti->GetLocalFloat(thr, 0, slot, &floatVal);
  99         printf(" GetLocalFloat:   %s (%d)\n", TranslateError(err), err);
 100         if (err != JVMTI_ERROR_NONE && sig == 'F') {
 101             printf("FAIL: GetLocalFloat failed to get value of float\n");
 102             result = STATUS_FAILED;
 103         } else if (err != JVMTI_ERROR_TYPE_MISMATCH && sig != 'F') {
 104             printf("FAIL: GetLocalFloat did not return JVMTI_ERROR_TYPE_MISMATCH for non-float\n");
 105             result = STATUS_FAILED;
 106         }
 107 
 108         err = jvmti->GetLocalDouble(thr, 0, slot, &doubleVal);
 109         printf(" GetLocalDouble:  %s (%d)\n", TranslateError(err), err);
 110         if (err != JVMTI_ERROR_NONE && sig == 'D') {
 111             printf("FAIL: GetLocalDouble failed to get value of double\n");
 112             result = STATUS_FAILED;
 113         } else if (err != JVMTI_ERROR_INVALID_SLOT &&
 114                    err != JVMTI_ERROR_TYPE_MISMATCH &&
 115                    sig != 'D') {
 116             printf("FAIL: GetLocalDouble did not return JVMTI_ERROR_INVALID_SLOT"
 117                    " nor JVMTI_ERROR_TYPE_MISMATCH for non-double\n");
 118             result = STATUS_FAILED;
 119         }
 120 
 121         err = jvmti->GetLocalObject(thr, 0, slot, &obj);
 122         printf(" GetLocalObject:  %s (%d)\n", TranslateError(err), err);
 123         if (err != JVMTI_ERROR_NONE && sig == 'L') {
 124             printf("FAIL: GetLocalObject failed to get value of object\n");
 125             result = STATUS_FAILED;
 126         } else if (err != JVMTI_ERROR_TYPE_MISMATCH && sig != 'L') {
 127             printf("FAIL: GetLocalObject did not return JVMTI_ERROR_TYPE_MISMATCH for non-object\n");
 128             result = STATUS_FAILED;
 129         }
 130     }
 131 }
 132 
 133 static void JNICALL
 134 MethodExit(jvmtiEnv *jvmti_env,
 135            JNIEnv *env,
 136            jthread thr,
 137            jmethodID method,
 138            jboolean was_poped_by_exception,
 139            jvalue return_value) {
 140 
 141     jvmtiError err;
 142     jlocation location;
 143     jmethodID frame_method = NULL;
 144 
 145     if (mid != method) {
 146         return;


   1 /*
   2  * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */


  50   printf(", signature: %s\n", lvt_elem->signature);
  51 }
  52 
  53 static void
  54 test_locals(jvmtiEnv *jvmti, jthread thr, jlocation location) {
  55     jvmtiError err;
  56     jint intVal;
  57     jlong longVal;
  58     jfloat floatVal;
  59     jdouble doubleVal;
  60     jobject obj;
  61     jint i;
  62 
  63     for (i = 0; i < entryCount; i++) {
  64         if (table[i].start_location > location ||
  65             table[i].start_location + table[i].length < location) {
  66             continue;  /* The local variable is not visible */
  67         }
  68         print_LocalVariableEntry(&table[i]);
  69         char sig = table[i].signature[0];

  70 
  71         if (sig == 'Z' || sig == 'B' || sig == 'C' || sig == 'S') {
  72             sig = 'I'; // covered by GetLocalInt
  73         }
  74         err = jvmti->GetLocalInt(thr, 0, table[i].slot, &intVal);
  75         printf(" GetLocalInt:     %s (%d)\n", TranslateError(err), err);
  76         if (err != JVMTI_ERROR_NONE && sig == 'I') {
  77             printf("FAIL: GetLocalInt failed to get value of int\n");
  78             result = STATUS_FAILED;
  79         } else if (err != JVMTI_ERROR_TYPE_MISMATCH && sig != 'I') {
  80             printf("FAIL: GetLocalInt did not return JVMTI_ERROR_TYPE_MISMATCH for non-int\n");
  81             result = STATUS_FAILED;
  82         }
  83 
  84         err = jvmti->GetLocalLong(thr, 0, table[i].slot, &longVal);
  85         printf(" GetLocalLong:    %s (%d)\n", TranslateError(err), err);
  86         if (err != JVMTI_ERROR_NONE && sig == 'J') {
  87             printf("FAIL: GetLocalLong failed to get value of long\n");
  88             result = STATUS_FAILED;
  89         } else if (err != JVMTI_ERROR_TYPE_MISMATCH && sig != 'J') {
  90             printf("FAIL: GetLocalLong did not return JVMTI_ERROR_TYPE_MISMATCH for non-long\n");



  91             result = STATUS_FAILED;
  92         }
  93 
  94         err = jvmti->GetLocalFloat(thr, 0, table[i].slot, &floatVal);
  95         printf(" GetLocalFloat:   %s (%d)\n", TranslateError(err), err);
  96         if (err != JVMTI_ERROR_NONE && table[i].signature[0] == 'F') {
  97             printf("FAIL: GetLocalFloat failed to get value of float\n");
  98             result = STATUS_FAILED;
  99         } else if (err != JVMTI_ERROR_TYPE_MISMATCH && table[i].signature[0] != 'F') {
 100             printf("FAIL: GetLocalFloat did not return JVMTI_ERROR_TYPE_MISMATCH for non-float\n");
 101             result = STATUS_FAILED;
 102         }
 103 
 104         err = jvmti->GetLocalDouble(thr, 0, table[i].slot, &doubleVal);
 105         printf(" GetLocalDouble:  %s (%d)\n", TranslateError(err), err);
 106         if (err != JVMTI_ERROR_NONE && table[i].signature[0] == 'D') {
 107             printf("FAIL: GetLocalDouble failed to get value of double\n");
 108             result = STATUS_FAILED;
 109         } else if (err != JVMTI_ERROR_TYPE_MISMATCH && table[i].signature[0] != 'D') {
 110             printf("FAIL: GetLocalDouble did not return JVMTI_ERROR_TYPE_MISMATCH for non-double\n");



 111             result = STATUS_FAILED;
 112         }
 113 
 114         err = jvmti->GetLocalObject(thr, 0, table[i].slot, &obj);
 115         printf(" GetLocalObject:  %s (%d)\n", TranslateError(err), err);
 116         if (err != JVMTI_ERROR_NONE && table[i].signature[0] == 'L') {
 117             printf("FAIL: GetLocalObject failed to get value of object\n");
 118             result = STATUS_FAILED;
 119         } else if (err != JVMTI_ERROR_TYPE_MISMATCH && table[i].signature[0] != 'L') {
 120             printf("FAIL: GetLocalObject did not return JVMTI_ERROR_TYPE_MISMATCH for non-object\n");
 121             result = STATUS_FAILED;
 122         }
 123     }
 124 }
 125 
 126 static void JNICALL
 127 MethodExit(jvmtiEnv *jvmti_env,
 128            JNIEnv *env,
 129            jthread thr,
 130            jmethodID method,
 131            jboolean was_poped_by_exception,
 132            jvalue return_value) {
 133 
 134     jvmtiError err;
 135     jlocation location;
 136     jmethodID frame_method = NULL;
 137 
 138     if (mid != method) {
 139         return;


< prev index next >