1
1
/*
2
- * Copyright (c) 2002, 2023 , Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2002, 2024 , Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
@@ -399,8 +399,11 @@ static bool setImageAndSymbolPath(JNIEnv* env, jobject obj) {
399
399
IDebugSymbols* ptrIDebugSymbols = (IDebugSymbols*)env->GetLongField (obj, ptrIDebugSymbols_ID);
400
400
CHECK_EXCEPTION_ (false );
401
401
402
- ptrIDebugSymbols->SetImagePath (imagePath);
403
- ptrIDebugSymbols->SetSymbolPath (symbolPath);
402
+ COM_VERIFY_OK_ (ptrIDebugSymbols->SetImagePath (imagePath),
403
+ " Windbg Error: SetImagePath failed!" , false );
404
+ COM_VERIFY_OK_ (ptrIDebugSymbols->SetSymbolPath (symbolPath),
405
+ " Windbg Error: SetSymbolPath failed!" , false );
406
+
404
407
return true ;
405
408
}
406
409
@@ -829,6 +832,8 @@ JNIEXPORT jstring JNICALL Java_sun_jvm_hotspot_debugger_windbg_WindbgDebuggerLoc
829
832
return res;
830
833
}
831
834
835
+ #define SYMBOL_BUFSIZE 512
836
+
832
837
/*
833
838
* Class: sun_jvm_hotspot_debugger_windbg_WindbgDebuggerLocal
834
839
* Method: lookupByName0
@@ -852,10 +857,22 @@ JNIEXPORT jlong JNICALL Java_sun_jvm_hotspot_debugger_windbg_WindbgDebuggerLocal
852
857
if (ptrIDebugSymbols->GetOffsetByName (name, &offset) != S_OK) {
853
858
return (jlong) 0 ;
854
859
}
860
+
861
+ // See JDK-8311993: WinDbg intermittently returns offset of "module!class::`vftable'" symbol
862
+ // when requested for decorated "class" or "class*" (i.e. "??_7class@@6B@"/"??_7class*@@6B@").
863
+ // As a workaround check if returned symbol contains requested symbol.
864
+ ULONG64 disp = 0L ;
865
+ char buf[SYMBOL_BUFSIZE];
866
+ memset (buf, 0 , sizeof (buf));
867
+ if (ptrIDebugSymbols->GetNameByOffset (offset, buf, sizeof (buf), 0 , &disp) == S_OK) {
868
+ if (strstr (buf, name) == nullptr ) {
869
+ return (jlong)0 ;
870
+ }
871
+ }
872
+
855
873
return (jlong) offset;
856
874
}
857
875
858
- #define SYMBOL_BUFSIZE 512
859
876
/*
860
877
* Class: sun_jvm_hotspot_debugger_windbg_WindbgDebuggerLocal
861
878
* Method: lookupByAddress0
0 commit comments