< prev index next >

agent/src/os/linux/LinuxDebuggerLocal.c

Print this page
rev 8073 : 8078521: AARCH64: Add AArch64 SA support
Reviewed-by: kvn


  36 #if defined(x86_64) && !defined(amd64)
  37 #define amd64 1
  38 #endif
  39 
  40 #ifdef i386
  41 #include "sun_jvm_hotspot_debugger_x86_X86ThreadContext.h"
  42 #endif
  43 
  44 #ifdef amd64
  45 #include "sun_jvm_hotspot_debugger_amd64_AMD64ThreadContext.h"
  46 #endif
  47 
  48 #if defined(sparc) || defined(sparcv9)
  49 #include "sun_jvm_hotspot_debugger_sparc_SPARCThreadContext.h"
  50 #endif
  51 
  52 #ifdef ppc64
  53 #include "sun_jvm_hotspot_debugger_ppc64_PPC64ThreadContext.h"
  54 #endif
  55 




  56 static jfieldID p_ps_prochandle_ID = 0;
  57 static jfieldID threadList_ID = 0;
  58 static jfieldID loadObjectList_ID = 0;
  59 
  60 static jmethodID createClosestSymbol_ID = 0;
  61 static jmethodID createLoadObject_ID = 0;
  62 static jmethodID getThreadForThreadId_ID = 0;
  63 static jmethodID listAdd_ID = 0;
  64 
  65 #define CHECK_EXCEPTION_(value) if ((*env)->ExceptionOccurred(env)) { return value; }
  66 #define CHECK_EXCEPTION if ((*env)->ExceptionOccurred(env)) { return;}
  67 #define THROW_NEW_DEBUGGER_EXCEPTION_(str, value) { throw_new_debugger_exception(env, str); return value; }
  68 #define THROW_NEW_DEBUGGER_EXCEPTION(str) { throw_new_debugger_exception(env, str); return;}
  69 
  70 void throw_new_debugger_exception(JNIEnv* env, const char* errMsg) {
  71   jclass clazz;
  72   clazz = (*env)->FindClass(env, "sun/jvm/hotspot/debugger/DebuggerException");
  73   CHECK_EXCEPTION;
  74   (*env)->ThrowNew(env, clazz, errMsg);
  75 }


 351 
 352   struct user_regs_struct gregs;
 353   jboolean isCopy;
 354   jlongArray array;
 355   jlong *regs;
 356   int i;
 357 
 358   struct ps_prochandle* ph = get_proc_handle(env, this_obj);
 359   if (get_lwp_regs(ph, lwp_id, &gregs) != true) {
 360      THROW_NEW_DEBUGGER_EXCEPTION_("get_thread_regs failed for a lwp", 0);
 361   }
 362 
 363 #undef NPRGREG
 364 #ifdef i386
 365 #define NPRGREG sun_jvm_hotspot_debugger_x86_X86ThreadContext_NPRGREG
 366 #endif
 367 #ifdef amd64
 368 #define NPRGREG sun_jvm_hotspot_debugger_amd64_AMD64ThreadContext_NPRGREG
 369 #endif
 370 #ifdef aarch64
 371 #define NPRGREG 32
 372 #endif
 373 #if defined(sparc) || defined(sparcv9)
 374 #define NPRGREG sun_jvm_hotspot_debugger_sparc_SPARCThreadContext_NPRGREG
 375 #endif
 376 #ifdef ppc64
 377 #define NPRGREG sun_jvm_hotspot_debugger_ppc64_PPC64ThreadContext_NPRGREG
 378 #endif
 379 
 380 
 381   array = (*env)->NewLongArray(env, NPRGREG);
 382   CHECK_EXCEPTION_(0);
 383   regs = (*env)->GetLongArrayElements(env, array, &isCopy);
 384 
 385 #undef REG_INDEX
 386 
 387 #ifdef i386
 388 #define REG_INDEX(reg) sun_jvm_hotspot_debugger_x86_X86ThreadContext_##reg
 389 
 390   regs[REG_INDEX(GS)]  = (uintptr_t) gregs.xgs;
 391   regs[REG_INDEX(FS)]  = (uintptr_t) gregs.xfs;


 456   regs[REG_INDEX(R_G2)]  = gregs.u_regs[1];
 457   regs[REG_INDEX(R_G3)]  = gregs.u_regs[2];
 458   regs[REG_INDEX(R_G4)]  = gregs.u_regs[3];
 459   regs[REG_INDEX(R_G5)]  = gregs.u_regs[4];
 460   regs[REG_INDEX(R_G6)]  = gregs.u_regs[5];
 461   regs[REG_INDEX(R_G7)]  = gregs.u_regs[6];
 462   regs[REG_INDEX(R_O0)]  = gregs.u_regs[7];
 463   regs[REG_INDEX(R_O1)]  = gregs.u_regs[8];
 464   regs[REG_INDEX(R_O2)]  = gregs.u_regs[ 9];
 465   regs[REG_INDEX(R_O3)]  = gregs.u_regs[10];
 466   regs[REG_INDEX(R_O4)]  = gregs.u_regs[11];
 467   regs[REG_INDEX(R_O5)]  = gregs.u_regs[12];
 468   regs[REG_INDEX(R_O6)]  = gregs.u_regs[13];
 469   regs[REG_INDEX(R_O7)]  = gregs.u_regs[14];
 470 #endif /* sparc */
 471 
 472 #if defined(aarch64)
 473 
 474 #define REG_INDEX(reg) sun_jvm_hotspot_debugger_aarch64_AARCH64ThreadContext_##reg
 475 







 476 #endif /* aarch64 */
 477 
 478 #ifdef ppc64
 479 #define REG_INDEX(reg) sun_jvm_hotspot_debugger_ppc64_PPC64ThreadContext_##reg
 480 
 481   regs[REG_INDEX(LR)] = gregs.link;
 482   regs[REG_INDEX(NIP)] = gregs.nip;
 483   regs[REG_INDEX(R0)]  = gregs.gpr[0];
 484   regs[REG_INDEX(R1)]  = gregs.gpr[1];
 485   regs[REG_INDEX(R2)]  = gregs.gpr[2];
 486   regs[REG_INDEX(R3)]  = gregs.gpr[3];
 487   regs[REG_INDEX(R4)]  = gregs.gpr[4];
 488   regs[REG_INDEX(R5)]  = gregs.gpr[5];
 489   regs[REG_INDEX(R6)]  = gregs.gpr[6];
 490   regs[REG_INDEX(R7)]  = gregs.gpr[7];
 491   regs[REG_INDEX(R8)]  = gregs.gpr[8];
 492   regs[REG_INDEX(R9)]  = gregs.gpr[9];
 493   regs[REG_INDEX(R10)] = gregs.gpr[10];
 494   regs[REG_INDEX(R11)] = gregs.gpr[11];
 495   regs[REG_INDEX(R12)] = gregs.gpr[12];




  36 #if defined(x86_64) && !defined(amd64)
  37 #define amd64 1
  38 #endif
  39 
  40 #ifdef i386
  41 #include "sun_jvm_hotspot_debugger_x86_X86ThreadContext.h"
  42 #endif
  43 
  44 #ifdef amd64
  45 #include "sun_jvm_hotspot_debugger_amd64_AMD64ThreadContext.h"
  46 #endif
  47 
  48 #if defined(sparc) || defined(sparcv9)
  49 #include "sun_jvm_hotspot_debugger_sparc_SPARCThreadContext.h"
  50 #endif
  51 
  52 #ifdef ppc64
  53 #include "sun_jvm_hotspot_debugger_ppc64_PPC64ThreadContext.h"
  54 #endif
  55 
  56 #ifdef aarch64
  57 #include "sun_jvm_hotspot_debugger_aarch64_AARCH64ThreadContext.h"
  58 #endif
  59 
  60 static jfieldID p_ps_prochandle_ID = 0;
  61 static jfieldID threadList_ID = 0;
  62 static jfieldID loadObjectList_ID = 0;
  63 
  64 static jmethodID createClosestSymbol_ID = 0;
  65 static jmethodID createLoadObject_ID = 0;
  66 static jmethodID getThreadForThreadId_ID = 0;
  67 static jmethodID listAdd_ID = 0;
  68 
  69 #define CHECK_EXCEPTION_(value) if ((*env)->ExceptionOccurred(env)) { return value; }
  70 #define CHECK_EXCEPTION if ((*env)->ExceptionOccurred(env)) { return;}
  71 #define THROW_NEW_DEBUGGER_EXCEPTION_(str, value) { throw_new_debugger_exception(env, str); return value; }
  72 #define THROW_NEW_DEBUGGER_EXCEPTION(str) { throw_new_debugger_exception(env, str); return;}
  73 
  74 void throw_new_debugger_exception(JNIEnv* env, const char* errMsg) {
  75   jclass clazz;
  76   clazz = (*env)->FindClass(env, "sun/jvm/hotspot/debugger/DebuggerException");
  77   CHECK_EXCEPTION;
  78   (*env)->ThrowNew(env, clazz, errMsg);
  79 }


 355 
 356   struct user_regs_struct gregs;
 357   jboolean isCopy;
 358   jlongArray array;
 359   jlong *regs;
 360   int i;
 361 
 362   struct ps_prochandle* ph = get_proc_handle(env, this_obj);
 363   if (get_lwp_regs(ph, lwp_id, &gregs) != true) {
 364      THROW_NEW_DEBUGGER_EXCEPTION_("get_thread_regs failed for a lwp", 0);
 365   }
 366 
 367 #undef NPRGREG
 368 #ifdef i386
 369 #define NPRGREG sun_jvm_hotspot_debugger_x86_X86ThreadContext_NPRGREG
 370 #endif
 371 #ifdef amd64
 372 #define NPRGREG sun_jvm_hotspot_debugger_amd64_AMD64ThreadContext_NPRGREG
 373 #endif
 374 #ifdef aarch64
 375 #define NPRGREG 33
 376 #endif
 377 #if defined(sparc) || defined(sparcv9)
 378 #define NPRGREG sun_jvm_hotspot_debugger_sparc_SPARCThreadContext_NPRGREG
 379 #endif
 380 #ifdef ppc64
 381 #define NPRGREG sun_jvm_hotspot_debugger_ppc64_PPC64ThreadContext_NPRGREG
 382 #endif
 383 
 384 
 385   array = (*env)->NewLongArray(env, NPRGREG);
 386   CHECK_EXCEPTION_(0);
 387   regs = (*env)->GetLongArrayElements(env, array, &isCopy);
 388 
 389 #undef REG_INDEX
 390 
 391 #ifdef i386
 392 #define REG_INDEX(reg) sun_jvm_hotspot_debugger_x86_X86ThreadContext_##reg
 393 
 394   regs[REG_INDEX(GS)]  = (uintptr_t) gregs.xgs;
 395   regs[REG_INDEX(FS)]  = (uintptr_t) gregs.xfs;


 460   regs[REG_INDEX(R_G2)]  = gregs.u_regs[1];
 461   regs[REG_INDEX(R_G3)]  = gregs.u_regs[2];
 462   regs[REG_INDEX(R_G4)]  = gregs.u_regs[3];
 463   regs[REG_INDEX(R_G5)]  = gregs.u_regs[4];
 464   regs[REG_INDEX(R_G6)]  = gregs.u_regs[5];
 465   regs[REG_INDEX(R_G7)]  = gregs.u_regs[6];
 466   regs[REG_INDEX(R_O0)]  = gregs.u_regs[7];
 467   regs[REG_INDEX(R_O1)]  = gregs.u_regs[8];
 468   regs[REG_INDEX(R_O2)]  = gregs.u_regs[ 9];
 469   regs[REG_INDEX(R_O3)]  = gregs.u_regs[10];
 470   regs[REG_INDEX(R_O4)]  = gregs.u_regs[11];
 471   regs[REG_INDEX(R_O5)]  = gregs.u_regs[12];
 472   regs[REG_INDEX(R_O6)]  = gregs.u_regs[13];
 473   regs[REG_INDEX(R_O7)]  = gregs.u_regs[14];
 474 #endif /* sparc */
 475 
 476 #if defined(aarch64)
 477 
 478 #define REG_INDEX(reg) sun_jvm_hotspot_debugger_aarch64_AARCH64ThreadContext_##reg
 479 
 480   {
 481     int i;
 482     for (i = 0; i < 31; i++)
 483       regs[i] = gregs.regs[i];
 484     regs[REG_INDEX(SP)] = gregs.sp;
 485     regs[REG_INDEX(PC)] = gregs.pc;
 486   }
 487 #endif /* aarch64 */
 488 
 489 #ifdef ppc64
 490 #define REG_INDEX(reg) sun_jvm_hotspot_debugger_ppc64_PPC64ThreadContext_##reg
 491 
 492   regs[REG_INDEX(LR)] = gregs.link;
 493   regs[REG_INDEX(NIP)] = gregs.nip;
 494   regs[REG_INDEX(R0)]  = gregs.gpr[0];
 495   regs[REG_INDEX(R1)]  = gregs.gpr[1];
 496   regs[REG_INDEX(R2)]  = gregs.gpr[2];
 497   regs[REG_INDEX(R3)]  = gregs.gpr[3];
 498   regs[REG_INDEX(R4)]  = gregs.gpr[4];
 499   regs[REG_INDEX(R5)]  = gregs.gpr[5];
 500   regs[REG_INDEX(R6)]  = gregs.gpr[6];
 501   regs[REG_INDEX(R7)]  = gregs.gpr[7];
 502   regs[REG_INDEX(R8)]  = gregs.gpr[8];
 503   regs[REG_INDEX(R9)]  = gregs.gpr[9];
 504   regs[REG_INDEX(R10)] = gregs.gpr[10];
 505   regs[REG_INDEX(R11)] = gregs.gpr[11];
 506   regs[REG_INDEX(R12)] = gregs.gpr[12];


< prev index next >