< prev index next >

src/jdk.jdwp.agent/share/native/libjdwp/util.c

Print this page

1531      * at the same time.
1532      */
1533 
1534     /*
1535      * Restore exception state from before call
1536      */
1537     if (throwable != NULL) {
1538         JNI_FUNC_PTR(env,Throw)(env, throwable);
1539     } else {
1540         JNI_FUNC_PTR(env,ExceptionClear)(env);
1541     }
1542 }
1543 
1544 jboolean
1545 isClass(jobject object)
1546 {
1547     JNIEnv *env = getEnv();
1548     return JNI_FUNC_PTR(env,IsInstanceOf)(env, object, gdata->classClass);
1549 }
1550 







1551 jboolean
1552 isThread(jobject object)
1553 {
1554     JNIEnv *env = getEnv();
1555     return JNI_FUNC_PTR(env,IsInstanceOf)(env, object, gdata->threadClass);
1556 }
1557 
1558 jboolean
1559 isThreadGroup(jobject object)
1560 {
1561     JNIEnv *env = getEnv();
1562     return JNI_FUNC_PTR(env,IsInstanceOf)(env, object, gdata->threadGroupClass);
1563 }
1564 
1565 jboolean
1566 isString(jobject object)
1567 {
1568     JNIEnv *env = getEnv();
1569     return JNI_FUNC_PTR(env,IsInstanceOf)(env, object, gdata->stringClass);
1570 }

1924     index2jvmti[EI_SINGLE_STEP        -EI_min] = JVMTI_EVENT_SINGLE_STEP;
1925     index2jvmti[EI_BREAKPOINT         -EI_min] = JVMTI_EVENT_BREAKPOINT;
1926     index2jvmti[EI_FRAME_POP          -EI_min] = JVMTI_EVENT_FRAME_POP;
1927     index2jvmti[EI_EXCEPTION          -EI_min] = JVMTI_EVENT_EXCEPTION;
1928     index2jvmti[EI_THREAD_START       -EI_min] = JVMTI_EVENT_THREAD_START;
1929     index2jvmti[EI_THREAD_END         -EI_min] = JVMTI_EVENT_THREAD_END;
1930     index2jvmti[EI_CLASS_PREPARE      -EI_min] = JVMTI_EVENT_CLASS_PREPARE;
1931     index2jvmti[EI_GC_FINISH          -EI_min] = JVMTI_EVENT_GARBAGE_COLLECTION_FINISH;
1932     index2jvmti[EI_CLASS_LOAD         -EI_min] = JVMTI_EVENT_CLASS_LOAD;
1933     index2jvmti[EI_FIELD_ACCESS       -EI_min] = JVMTI_EVENT_FIELD_ACCESS;
1934     index2jvmti[EI_FIELD_MODIFICATION -EI_min] = JVMTI_EVENT_FIELD_MODIFICATION;
1935     index2jvmti[EI_EXCEPTION_CATCH    -EI_min] = JVMTI_EVENT_EXCEPTION_CATCH;
1936     index2jvmti[EI_METHOD_ENTRY       -EI_min] = JVMTI_EVENT_METHOD_ENTRY;
1937     index2jvmti[EI_METHOD_EXIT        -EI_min] = JVMTI_EVENT_METHOD_EXIT;
1938     index2jvmti[EI_MONITOR_CONTENDED_ENTER      -EI_min] = JVMTI_EVENT_MONITOR_CONTENDED_ENTER;
1939     index2jvmti[EI_MONITOR_CONTENDED_ENTERED    -EI_min] = JVMTI_EVENT_MONITOR_CONTENDED_ENTERED;
1940     index2jvmti[EI_MONITOR_WAIT       -EI_min] = JVMTI_EVENT_MONITOR_WAIT;
1941     index2jvmti[EI_MONITOR_WAITED     -EI_min] = JVMTI_EVENT_MONITOR_WAITED;
1942     index2jvmti[EI_VM_INIT            -EI_min] = JVMTI_EVENT_VM_INIT;
1943     index2jvmti[EI_VM_DEATH           -EI_min] = JVMTI_EVENT_VM_DEATH;


1944 
1945     index2jdwp[EI_SINGLE_STEP         -EI_min] = JDWP_EVENT(SINGLE_STEP);
1946     index2jdwp[EI_BREAKPOINT          -EI_min] = JDWP_EVENT(BREAKPOINT);
1947     index2jdwp[EI_FRAME_POP           -EI_min] = JDWP_EVENT(FRAME_POP);
1948     index2jdwp[EI_EXCEPTION           -EI_min] = JDWP_EVENT(EXCEPTION);
1949     index2jdwp[EI_THREAD_START        -EI_min] = JDWP_EVENT(THREAD_START);
1950     index2jdwp[EI_THREAD_END          -EI_min] = JDWP_EVENT(THREAD_END);
1951     index2jdwp[EI_CLASS_PREPARE       -EI_min] = JDWP_EVENT(CLASS_PREPARE);
1952     index2jdwp[EI_GC_FINISH           -EI_min] = JDWP_EVENT(CLASS_UNLOAD);
1953     index2jdwp[EI_CLASS_LOAD          -EI_min] = JDWP_EVENT(CLASS_LOAD);
1954     index2jdwp[EI_FIELD_ACCESS        -EI_min] = JDWP_EVENT(FIELD_ACCESS);
1955     index2jdwp[EI_FIELD_MODIFICATION  -EI_min] = JDWP_EVENT(FIELD_MODIFICATION);
1956     index2jdwp[EI_EXCEPTION_CATCH     -EI_min] = JDWP_EVENT(EXCEPTION_CATCH);
1957     index2jdwp[EI_METHOD_ENTRY        -EI_min] = JDWP_EVENT(METHOD_ENTRY);
1958     index2jdwp[EI_METHOD_EXIT         -EI_min] = JDWP_EVENT(METHOD_EXIT);
1959     index2jdwp[EI_MONITOR_CONTENDED_ENTER             -EI_min] = JDWP_EVENT(MONITOR_CONTENDED_ENTER);
1960     index2jdwp[EI_MONITOR_CONTENDED_ENTERED           -EI_min] = JDWP_EVENT(MONITOR_CONTENDED_ENTERED);
1961     index2jdwp[EI_MONITOR_WAIT        -EI_min] = JDWP_EVENT(MONITOR_WAIT);
1962     index2jdwp[EI_MONITOR_WAITED      -EI_min] = JDWP_EVENT(MONITOR_WAITED);
1963     index2jdwp[EI_VM_INIT             -EI_min] = JDWP_EVENT(VM_INIT);
1964     index2jdwp[EI_VM_DEATH            -EI_min] = JDWP_EVENT(VM_DEATH);



1965 }
1966 
1967 jdwpEvent
1968 eventIndex2jdwp(EventIndex i)
1969 {
1970     if ( i < EI_min || i > EI_max ) {
1971         EXIT_ERROR(AGENT_ERROR_INVALID_INDEX,"bad EventIndex");
1972     }
1973     return index2jdwp[i-EI_min];
1974 }
1975 
1976 jvmtiEvent
1977 eventIndex2jvmti(EventIndex i)
1978 {
1979     if ( i < EI_min || i > EI_max ) {
1980         EXIT_ERROR(AGENT_ERROR_INVALID_INDEX,"bad EventIndex");
1981     }
1982     return index2jvmti[i-EI_min];
1983 }
1984 

2011         case EI_FIELD_MODIFICATION:
2012             return "EI_FIELD_MODIFICATION";
2013         case EI_EXCEPTION_CATCH:
2014             return "EI_EXCEPTION_CATCH";
2015         case EI_METHOD_ENTRY:
2016             return "EI_METHOD_ENTRY";
2017         case EI_METHOD_EXIT:
2018             return "EI_METHOD_EXIT";
2019         case EI_MONITOR_CONTENDED_ENTER:
2020             return "EI_MONITOR_CONTENDED_ENTER";
2021         case EI_MONITOR_CONTENDED_ENTERED:
2022             return "EI_MONITOR_CONTENDED_ENTERED";
2023         case EI_MONITOR_WAIT:
2024             return "EI_MONITOR_WAIT";
2025         case EI_MONITOR_WAITED:
2026             return "EI_MONITOR_WAITED";
2027         case EI_VM_INIT:
2028             return "EI_VM_INIT";
2029         case EI_VM_DEATH:
2030             return "EI_VM_DEATH";




2031         default:
2032             JDI_ASSERT(JNI_FALSE);
2033             return "Bad EI";
2034     }
2035 }
2036 
2037 #endif
2038 
2039 EventIndex
2040 jdwp2EventIndex(jdwpEvent eventType)
2041 {
2042     switch ( eventType ) {
2043         case JDWP_EVENT(SINGLE_STEP):
2044             return EI_SINGLE_STEP;
2045         case JDWP_EVENT(BREAKPOINT):
2046             return EI_BREAKPOINT;
2047         case JDWP_EVENT(FRAME_POP):
2048             return EI_FRAME_POP;
2049         case JDWP_EVENT(EXCEPTION):
2050             return EI_EXCEPTION;

2124         case JVMTI_EVENT_METHOD_ENTRY:
2125             return EI_METHOD_ENTRY;
2126         case JVMTI_EVENT_METHOD_EXIT:
2127             return EI_METHOD_EXIT;
2128         /*
2129          * There is no JVMTI_EVENT_METHOD_EXIT_WITH_RETURN_VALUE.
2130          * The normal JVMTI_EVENT_METHOD_EXIT always contains the return value.
2131          */
2132         case JVMTI_EVENT_MONITOR_CONTENDED_ENTER:
2133             return EI_MONITOR_CONTENDED_ENTER;
2134         case JVMTI_EVENT_MONITOR_CONTENDED_ENTERED:
2135             return EI_MONITOR_CONTENDED_ENTERED;
2136         case JVMTI_EVENT_MONITOR_WAIT:
2137             return EI_MONITOR_WAIT;
2138         case JVMTI_EVENT_MONITOR_WAITED:
2139             return EI_MONITOR_WAITED;
2140         case JVMTI_EVENT_VM_INIT:
2141             return EI_VM_INIT;
2142         case JVMTI_EVENT_VM_DEATH:
2143             return EI_VM_DEATH;






2144         default:
2145             EXIT_ERROR(AGENT_ERROR_INVALID_INDEX,"JVMTI to EventIndex mapping");
2146             break;
2147     }
2148     return (EventIndex)0;
2149 }
2150 
2151 /* This routine is commonly used, maps jvmti and agent errors to the best
2152  *    jdwp error code we can map to.
2153  */
2154 jdwpError
2155 map2jdwpError(jvmtiError error)
2156 {
2157     switch ( (int)error ) {
2158         case JVMTI_ERROR_NONE:
2159             return JDWP_ERROR(NONE);
2160         case AGENT_ERROR_INVALID_THREAD:
2161         case JVMTI_ERROR_INVALID_THREAD:
2162             return JDWP_ERROR(INVALID_THREAD);
2163         case JVMTI_ERROR_INVALID_THREAD_GROUP:

1531      * at the same time.
1532      */
1533 
1534     /*
1535      * Restore exception state from before call
1536      */
1537     if (throwable != NULL) {
1538         JNI_FUNC_PTR(env,Throw)(env, throwable);
1539     } else {
1540         JNI_FUNC_PTR(env,ExceptionClear)(env);
1541     }
1542 }
1543 
1544 jboolean
1545 isClass(jobject object)
1546 {
1547     JNIEnv *env = getEnv();
1548     return JNI_FUNC_PTR(env,IsInstanceOf)(env, object, gdata->classClass);
1549 }
1550 
1551 jboolean
1552 isVThread(jobject object)
1553 {
1554     JNIEnv *env = getEnv();
1555     return JNI_FUNC_PTR(env,IsVirtualThread)(env, object);
1556 }
1557 
1558 jboolean
1559 isThread(jobject object)
1560 {
1561     JNIEnv *env = getEnv();
1562     return JNI_FUNC_PTR(env,IsInstanceOf)(env, object, gdata->threadClass);
1563 }
1564 
1565 jboolean
1566 isThreadGroup(jobject object)
1567 {
1568     JNIEnv *env = getEnv();
1569     return JNI_FUNC_PTR(env,IsInstanceOf)(env, object, gdata->threadGroupClass);
1570 }
1571 
1572 jboolean
1573 isString(jobject object)
1574 {
1575     JNIEnv *env = getEnv();
1576     return JNI_FUNC_PTR(env,IsInstanceOf)(env, object, gdata->stringClass);
1577 }

1931     index2jvmti[EI_SINGLE_STEP        -EI_min] = JVMTI_EVENT_SINGLE_STEP;
1932     index2jvmti[EI_BREAKPOINT         -EI_min] = JVMTI_EVENT_BREAKPOINT;
1933     index2jvmti[EI_FRAME_POP          -EI_min] = JVMTI_EVENT_FRAME_POP;
1934     index2jvmti[EI_EXCEPTION          -EI_min] = JVMTI_EVENT_EXCEPTION;
1935     index2jvmti[EI_THREAD_START       -EI_min] = JVMTI_EVENT_THREAD_START;
1936     index2jvmti[EI_THREAD_END         -EI_min] = JVMTI_EVENT_THREAD_END;
1937     index2jvmti[EI_CLASS_PREPARE      -EI_min] = JVMTI_EVENT_CLASS_PREPARE;
1938     index2jvmti[EI_GC_FINISH          -EI_min] = JVMTI_EVENT_GARBAGE_COLLECTION_FINISH;
1939     index2jvmti[EI_CLASS_LOAD         -EI_min] = JVMTI_EVENT_CLASS_LOAD;
1940     index2jvmti[EI_FIELD_ACCESS       -EI_min] = JVMTI_EVENT_FIELD_ACCESS;
1941     index2jvmti[EI_FIELD_MODIFICATION -EI_min] = JVMTI_EVENT_FIELD_MODIFICATION;
1942     index2jvmti[EI_EXCEPTION_CATCH    -EI_min] = JVMTI_EVENT_EXCEPTION_CATCH;
1943     index2jvmti[EI_METHOD_ENTRY       -EI_min] = JVMTI_EVENT_METHOD_ENTRY;
1944     index2jvmti[EI_METHOD_EXIT        -EI_min] = JVMTI_EVENT_METHOD_EXIT;
1945     index2jvmti[EI_MONITOR_CONTENDED_ENTER      -EI_min] = JVMTI_EVENT_MONITOR_CONTENDED_ENTER;
1946     index2jvmti[EI_MONITOR_CONTENDED_ENTERED    -EI_min] = JVMTI_EVENT_MONITOR_CONTENDED_ENTERED;
1947     index2jvmti[EI_MONITOR_WAIT       -EI_min] = JVMTI_EVENT_MONITOR_WAIT;
1948     index2jvmti[EI_MONITOR_WAITED     -EI_min] = JVMTI_EVENT_MONITOR_WAITED;
1949     index2jvmti[EI_VM_INIT            -EI_min] = JVMTI_EVENT_VM_INIT;
1950     index2jvmti[EI_VM_DEATH           -EI_min] = JVMTI_EVENT_VM_DEATH;
1951     index2jvmti[EI_VIRTUAL_THREAD_START -EI_min] = JVMTI_EVENT_VIRTUAL_THREAD_START;
1952     index2jvmti[EI_VIRTUAL_THREAD_END   -EI_min] = JVMTI_EVENT_VIRTUAL_THREAD_END;
1953 
1954     index2jdwp[EI_SINGLE_STEP         -EI_min] = JDWP_EVENT(SINGLE_STEP);
1955     index2jdwp[EI_BREAKPOINT          -EI_min] = JDWP_EVENT(BREAKPOINT);
1956     index2jdwp[EI_FRAME_POP           -EI_min] = JDWP_EVENT(FRAME_POP);
1957     index2jdwp[EI_EXCEPTION           -EI_min] = JDWP_EVENT(EXCEPTION);
1958     index2jdwp[EI_THREAD_START        -EI_min] = JDWP_EVENT(THREAD_START);
1959     index2jdwp[EI_THREAD_END          -EI_min] = JDWP_EVENT(THREAD_END);
1960     index2jdwp[EI_CLASS_PREPARE       -EI_min] = JDWP_EVENT(CLASS_PREPARE);
1961     index2jdwp[EI_GC_FINISH           -EI_min] = JDWP_EVENT(CLASS_UNLOAD);
1962     index2jdwp[EI_CLASS_LOAD          -EI_min] = JDWP_EVENT(CLASS_LOAD);
1963     index2jdwp[EI_FIELD_ACCESS        -EI_min] = JDWP_EVENT(FIELD_ACCESS);
1964     index2jdwp[EI_FIELD_MODIFICATION  -EI_min] = JDWP_EVENT(FIELD_MODIFICATION);
1965     index2jdwp[EI_EXCEPTION_CATCH     -EI_min] = JDWP_EVENT(EXCEPTION_CATCH);
1966     index2jdwp[EI_METHOD_ENTRY        -EI_min] = JDWP_EVENT(METHOD_ENTRY);
1967     index2jdwp[EI_METHOD_EXIT         -EI_min] = JDWP_EVENT(METHOD_EXIT);
1968     index2jdwp[EI_MONITOR_CONTENDED_ENTER             -EI_min] = JDWP_EVENT(MONITOR_CONTENDED_ENTER);
1969     index2jdwp[EI_MONITOR_CONTENDED_ENTERED           -EI_min] = JDWP_EVENT(MONITOR_CONTENDED_ENTERED);
1970     index2jdwp[EI_MONITOR_WAIT        -EI_min] = JDWP_EVENT(MONITOR_WAIT);
1971     index2jdwp[EI_MONITOR_WAITED      -EI_min] = JDWP_EVENT(MONITOR_WAITED);
1972     index2jdwp[EI_VM_INIT             -EI_min] = JDWP_EVENT(VM_INIT);
1973     index2jdwp[EI_VM_DEATH            -EI_min] = JDWP_EVENT(VM_DEATH);
1974     /* Just map VIRTUAL_THREAD_START/END to THREAD_START/END. */
1975     index2jdwp[EI_VIRTUAL_THREAD_START -EI_min] = JDWP_EVENT(THREAD_START);
1976     index2jdwp[EI_VIRTUAL_THREAD_END   -EI_min] = JDWP_EVENT(THREAD_END);
1977 }
1978 
1979 jdwpEvent
1980 eventIndex2jdwp(EventIndex i)
1981 {
1982     if ( i < EI_min || i > EI_max ) {
1983         EXIT_ERROR(AGENT_ERROR_INVALID_INDEX,"bad EventIndex");
1984     }
1985     return index2jdwp[i-EI_min];
1986 }
1987 
1988 jvmtiEvent
1989 eventIndex2jvmti(EventIndex i)
1990 {
1991     if ( i < EI_min || i > EI_max ) {
1992         EXIT_ERROR(AGENT_ERROR_INVALID_INDEX,"bad EventIndex");
1993     }
1994     return index2jvmti[i-EI_min];
1995 }
1996 

2023         case EI_FIELD_MODIFICATION:
2024             return "EI_FIELD_MODIFICATION";
2025         case EI_EXCEPTION_CATCH:
2026             return "EI_EXCEPTION_CATCH";
2027         case EI_METHOD_ENTRY:
2028             return "EI_METHOD_ENTRY";
2029         case EI_METHOD_EXIT:
2030             return "EI_METHOD_EXIT";
2031         case EI_MONITOR_CONTENDED_ENTER:
2032             return "EI_MONITOR_CONTENDED_ENTER";
2033         case EI_MONITOR_CONTENDED_ENTERED:
2034             return "EI_MONITOR_CONTENDED_ENTERED";
2035         case EI_MONITOR_WAIT:
2036             return "EI_MONITOR_WAIT";
2037         case EI_MONITOR_WAITED:
2038             return "EI_MONITOR_WAITED";
2039         case EI_VM_INIT:
2040             return "EI_VM_INIT";
2041         case EI_VM_DEATH:
2042             return "EI_VM_DEATH";
2043         case EI_VIRTUAL_THREAD_START:
2044             return "EI_VIRTUAL_THREAD_START";
2045         case EI_VIRTUAL_THREAD_END:
2046             return "EI_VIRTUAL_THREAD_END";
2047         default:
2048             JDI_ASSERT(JNI_FALSE);
2049             return "Bad EI";
2050     }
2051 }
2052 
2053 #endif
2054 
2055 EventIndex
2056 jdwp2EventIndex(jdwpEvent eventType)
2057 {
2058     switch ( eventType ) {
2059         case JDWP_EVENT(SINGLE_STEP):
2060             return EI_SINGLE_STEP;
2061         case JDWP_EVENT(BREAKPOINT):
2062             return EI_BREAKPOINT;
2063         case JDWP_EVENT(FRAME_POP):
2064             return EI_FRAME_POP;
2065         case JDWP_EVENT(EXCEPTION):
2066             return EI_EXCEPTION;

2140         case JVMTI_EVENT_METHOD_ENTRY:
2141             return EI_METHOD_ENTRY;
2142         case JVMTI_EVENT_METHOD_EXIT:
2143             return EI_METHOD_EXIT;
2144         /*
2145          * There is no JVMTI_EVENT_METHOD_EXIT_WITH_RETURN_VALUE.
2146          * The normal JVMTI_EVENT_METHOD_EXIT always contains the return value.
2147          */
2148         case JVMTI_EVENT_MONITOR_CONTENDED_ENTER:
2149             return EI_MONITOR_CONTENDED_ENTER;
2150         case JVMTI_EVENT_MONITOR_CONTENDED_ENTERED:
2151             return EI_MONITOR_CONTENDED_ENTERED;
2152         case JVMTI_EVENT_MONITOR_WAIT:
2153             return EI_MONITOR_WAIT;
2154         case JVMTI_EVENT_MONITOR_WAITED:
2155             return EI_MONITOR_WAITED;
2156         case JVMTI_EVENT_VM_INIT:
2157             return EI_VM_INIT;
2158         case JVMTI_EVENT_VM_DEATH:
2159             return EI_VM_DEATH;
2160         /* vthread events */
2161         case JVMTI_EVENT_VIRTUAL_THREAD_START:
2162             return EI_VIRTUAL_THREAD_START;
2163         case JVMTI_EVENT_VIRTUAL_THREAD_END:
2164             return EI_VIRTUAL_THREAD_END;
2165 
2166         default:
2167             EXIT_ERROR(AGENT_ERROR_INVALID_INDEX,"JVMTI to EventIndex mapping");
2168             break;
2169     }
2170     return (EventIndex)0;
2171 }
2172 
2173 /* This routine is commonly used, maps jvmti and agent errors to the best
2174  *    jdwp error code we can map to.
2175  */
2176 jdwpError
2177 map2jdwpError(jvmtiError error)
2178 {
2179     switch ( (int)error ) {
2180         case JVMTI_ERROR_NONE:
2181             return JDWP_ERROR(NONE);
2182         case AGENT_ERROR_INVALID_THREAD:
2183         case JVMTI_ERROR_INVALID_THREAD:
2184             return JDWP_ERROR(INVALID_THREAD);
2185         case JVMTI_ERROR_INVALID_THREAD_GROUP:
< prev index next >