1.1 --- a/src/share/tools/hsdis/hsdis-demo.c Fri Nov 02 07:44:11 2012 -0700 1.2 +++ b/src/share/tools/hsdis/hsdis-demo.c Fri Nov 02 13:30:47 2012 -0700 1.3 @@ -85,9 +85,11 @@ 1.4 1.5 #include "dlfcn.h" 1.6 1.7 -#define DECODE_INSTRUCTIONS_NAME "decode_instructions_virtual" 1.8 +#define DECODE_INSTRUCTIONS_VIRTUAL_NAME "decode_instructions_virtual" 1.9 +#define DECODE_INSTRUCTIONS_NAME "decode_instructions" 1.10 #define HSDIS_NAME "hsdis" 1.11 static void* decode_instructions_pv = 0; 1.12 +static void* decode_instructions_sv = 0; 1.13 static const char* hsdis_path[] = { 1.14 HSDIS_NAME"-"LIBARCH LIB_EXT, 1.15 "./" HSDIS_NAME"-"LIBARCH LIB_EXT, 1.16 @@ -101,11 +103,12 @@ 1.17 void* dllib = NULL; 1.18 const char* *next_in_path = hsdis_path; 1.19 while (1) { 1.20 - decode_instructions_pv = dlsym(dllib, DECODE_INSTRUCTIONS_NAME); 1.21 - if (decode_instructions_pv != NULL) 1.22 + decode_instructions_pv = dlsym(dllib, DECODE_INSTRUCTIONS_VIRTUAL_NAME); 1.23 + decode_instructions_sv = dlsym(dllib, DECODE_INSTRUCTIONS_NAME); 1.24 + if (decode_instructions_pv != NULL || decode_instructions_sv != NULL) 1.25 return NULL; 1.26 if (dllib != NULL) 1.27 - return "plugin does not defined "DECODE_INSTRUCTIONS_NAME; 1.28 + return "plugin does not defined "DECODE_INSTRUCTIONS_VIRTUAL_NAME" and "DECODE_INSTRUCTIONS_NAME; 1.29 for (dllib = NULL; dllib == NULL; ) { 1.30 const char* next_lib = (*next_in_path++); 1.31 if (next_lib == NULL) 1.32 @@ -213,20 +216,44 @@ 1.33 printf("%s: %s\n", err, dlerror()); 1.34 exit(1); 1.35 } 1.36 - printf("Decoding from %p to %p...\n", from, to); 1.37 - decode_instructions_ftype decode_instructions 1.38 - = (decode_instructions_ftype) decode_instructions_pv; 1.39 + decode_func_vtype decode_instructions_v 1.40 + = (decode_func_vtype) decode_instructions_pv; 1.41 + decode_func_stype decode_instructions_s 1.42 + = (decode_func_stype) decode_instructions_sv; 1.43 void* res; 1.44 - if (raw && xml) { 1.45 - res = (*decode_instructions)(from, to, (unsigned char*)from, to - from, simple_handle_event, stdout, NULL, stdout, options); 1.46 - } else if (raw) { 1.47 - res = (*decode_instructions)(from, to, (unsigned char*)from, to - from, simple_handle_event, stdout, NULL, stdout, options); 1.48 - } else { 1.49 - res = (*decode_instructions)(from, to, (unsigned char*)from, to - from, 1.50 - handle_event, (void*) event_cookie, 1.51 - fprintf_callback, stdout, 1.52 - options); 1.53 + if (decode_instructions_pv != NULL) { 1.54 + printf("\nDecoding from %p to %p...with %s\n", from, to, DECODE_INSTRUCTIONS_VIRTUAL_NAME); 1.55 + if (raw) { 1.56 + res = (*decode_instructions_v)(from, to, 1.57 + (unsigned char*)from, to - from, 1.58 + simple_handle_event, stdout, 1.59 + NULL, stdout, 1.60 + options, 0); 1.61 + } else { 1.62 + res = (*decode_instructions_v)(from, to, 1.63 + (unsigned char*)from, to - from, 1.64 + handle_event, (void*) event_cookie, 1.65 + fprintf_callback, stdout, 1.66 + options, 0); 1.67 + } 1.68 + if (res != (void*)to) 1.69 + printf("*** Result was %p!\n", res); 1.70 } 1.71 - if (res != (void*)to) 1.72 - printf("*** Result was %p!\n", res); 1.73 + void* sres; 1.74 + if (decode_instructions_sv != NULL) { 1.75 + printf("\nDecoding from %p to %p...with old decode_instructions\n", from, to, DECODE_INSTRUCTIONS_NAME); 1.76 + if (raw) { 1.77 + sres = (*decode_instructions_s)(from, to, 1.78 + simple_handle_event, stdout, 1.79 + NULL, stdout, 1.80 + options); 1.81 + } else { 1.82 + sres = (*decode_instructions_s)(from, to, 1.83 + handle_event, (void*) event_cookie, 1.84 + fprintf_callback, stdout, 1.85 + options); 1.86 + } 1.87 + if (sres != (void *)to) 1.88 + printf("*** Result of decode_instructions %p!\n", sres); 1.89 + } 1.90 }