
Java 问题,目前遇到了一个比较奇怪的问题:
想找到一种方式查到当前 jvm ( windows 平台)的 C++的方法调用栈的情况呢? 具体是那个位置造成了死循环(目前看 jdk 层 java 代码未产生死循环)。
方法名是 WindowsNativeDispatcher.CreateFile0 ,通过 JDK 源码,找到了 natvie 方法的 c 文件
下面是具体代码:
JNIEXPORT jlong JNICALL Java_sun_nio_fs_WindowsNativeDispatcher_CreateFile0(JNIEnv* env, jclass this, jlong address, jint dwDesiredAccess, jint dwShareMode, jlong sdAddress, jint dwCreationDisposition, jint dwFlagsAndAttributes) { HANDLE handle; LPCWSTR lpFileName = jlong_to_ptr(address); SECURITY_ATTRIBUTES securityAttributes; LPSECURITY_ATTRIBUTES lpSecurityAttributes; PSECURITY_DESCRIPTOR lpSecurityDescriptor = jlong_to_ptr(sdAddress); if (lpSecurityDescriptor == NULL) { lpSecurityAttributes = NULL; } else { securityAttributes.nLength = sizeof(SECURITY_ATTRIBUTES); securityAttributes.lpSecurityDescriptor = lpSecurityDescriptor; securityAttributes.bInheritHandle = FALSE; lpSecurityAttributes = &securityAttributes; } handle = CreateFileW(lpFileName, (DWORD)dwDesiredAccess, (DWORD)dwShareMode, lpSecurityAttributes, (DWORD)dwCreationDisposition, (DWORD)dwFlagsAndAttributes, NULL); if (handle == INVALID_HANDLE_VALUE) { throwWindowsException(env, GetLastError()); } return ptr_to_jlong(handle); } 1 ysc3839 2022-07-25 22:13:12 +08:00 via Android 用调试器附加就能看了,比如 x64dbg 。 不过需要有调试符号才能看到函数名。如果是系统 DLL 可以从微软服务器加载调试符号。 |
3 codefever 2022-07-25 22:55:32 +08:00 jstat ,可以实时监测系统资源占用与 jvm 运行情况 |