jdk/src/share/back/eventFilter.c
changeset 7978 120267233d5e
parent 5506 202f599c92aa
child 9035 1255eb81cc2f
equal deleted inserted replaced
7976:f273c0d04215 7978:120267233d5e
     1 /*
     1 /*
     2  * Copyright (c) 2001, 2008, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2001, 2010, 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.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    37 #include "eventFilterRestricted.h"
    37 #include "eventFilterRestricted.h"
    38 #include "eventHandlerRestricted.h"
    38 #include "eventHandlerRestricted.h"
    39 #include "stepControl.h"
    39 #include "stepControl.h"
    40 #include "threadControl.h"
    40 #include "threadControl.h"
    41 #include "SDE.h"
    41 #include "SDE.h"
       
    42 #include "jvmti.h"
    42 
    43 
    43 typedef struct ClassFilter {
    44 typedef struct ClassFilter {
    44     jclass clazz;
    45     jclass clazz;
    45 } ClassFilter;
    46 } ClassFilter;
    46 
    47 
   273             return strncmp(pattern, start, compLen) == 0;
   274             return strncmp(pattern, start, compLen) == 0;
   274         }
   275         }
   275     }
   276     }
   276 }
   277 }
   277 
   278 
       
   279 static jboolean isVersionGte12x() {
       
   280     jint version;
       
   281     jvmtiError err =
       
   282         JVMTI_FUNC_PTR(gdata->jvmti,GetVersionNumber)(gdata->jvmti, &version);
       
   283 
       
   284     if (err == JVMTI_ERROR_NONE) {
       
   285         jint major, minor;
       
   286 
       
   287         major = (version & JVMTI_VERSION_MASK_MAJOR)
       
   288                     >> JVMTI_VERSION_SHIFT_MAJOR;
       
   289         minor = (version & JVMTI_VERSION_MASK_MINOR)
       
   290                     >> JVMTI_VERSION_SHIFT_MINOR;
       
   291         return (major > 1 || major == 1 && minor >= 2);
       
   292     } else {
       
   293         return JNI_FALSE;
       
   294     }
       
   295 }
       
   296 
   278 /* Return the object instance in which the event occurred */
   297 /* Return the object instance in which the event occurred */
   279 /* Return NULL if static or if an error occurs */
   298 /* Return NULL if static or if an error occurs */
   280 static jobject
   299 static jobject
   281 eventInstance(EventInfo *evinfo)
   300 eventInstance(EventInfo *evinfo)
   282 {
   301 {
   283     jobject     object          = NULL;
   302     jobject     object          = NULL;
   284     jthread     thread          ;
   303     jthread     thread          ;
   285     jmethodID   method          ;
   304     jmethodID   method          ;
   286     jint        modifiers       = 0;
   305     jint        modifiers       = 0;
   287     jvmtiError  error;
   306     jvmtiError  error;
       
   307 
       
   308     static jboolean got_version = JNI_FALSE;
       
   309     static jboolean is_version_gte_12x = JNI_FALSE;
       
   310 
       
   311     if (!got_version) {
       
   312         is_version_gte_12x = isVersionGte12x();
       
   313         got_version = JNI_TRUE;
       
   314     }
   288 
   315 
   289     switch (evinfo->ei) {
   316     switch (evinfo->ei) {
   290         case EI_SINGLE_STEP:
   317         case EI_SINGLE_STEP:
   291         case EI_BREAKPOINT:
   318         case EI_BREAKPOINT:
   292         case EI_FRAME_POP:
   319         case EI_FRAME_POP:
   312     error = methodModifiers(method, &modifiers);
   339     error = methodModifiers(method, &modifiers);
   313 
   340 
   314     /* fail if error or static (0x8) */
   341     /* fail if error or static (0x8) */
   315     if (error == JVMTI_ERROR_NONE && thread!=NULL && (modifiers & 0x8) == 0) {
   342     if (error == JVMTI_ERROR_NONE && thread!=NULL && (modifiers & 0x8) == 0) {
   316         FrameNumber fnum            = 0;
   343         FrameNumber fnum            = 0;
   317         /* get slot zero object "this" */
   344         if (is_version_gte_12x) {
   318         error = JVMTI_FUNC_PTR(gdata->jvmti,GetLocalObject)
   345             /* Use new 1.2.x function, GetLocalInstance */
   319                     (gdata->jvmti, thread, fnum, 0, &object);
   346             error = JVMTI_FUNC_PTR(gdata->jvmti,GetLocalInstance)
   320         if (error != JVMTI_ERROR_NONE)
   347                         (gdata->jvmti, thread, fnum, &object);
       
   348         } else {
       
   349             /* get slot zero object "this" */
       
   350             error = JVMTI_FUNC_PTR(gdata->jvmti,GetLocalObject)
       
   351                         (gdata->jvmti, thread, fnum, 0, &object);
       
   352         }
       
   353         if (error != JVMTI_ERROR_NONE) {
   321             object = NULL;
   354             object = NULL;
       
   355         }
   322     }
   356     }
   323 
   357 
   324     return object;
   358     return object;
   325 }
   359 }
   326 
   360