< prev index next >

hotspot/agent/src/os/solaris/proc/saproc.cpp

Print this page
rev 7131 : 8049049: Unportable format string argument mismatch in hotspot/agent/src/os/solaris/proc/saproc.cpp
Summary: Cast arguments on printing
Reviewed-by: dholmes, sspitsyn, jbachorik


 297     strcpy(alt_path, alt_root);
 298     strcat(alt_path, name);
 299     handle = dlopen(alt_path, mode);
 300     if (_libsaproc_debug && handle) {
 301       printf("libsaproc DEBUG: pathmap_dlopen substituted %s\n", alt_path);
 302     }
 303 
 304     if (handle == NULL && strrchr(name, '/')) {
 305       strcpy(alt_path, alt_root);
 306       strcat(alt_path, strrchr(name, '/'));
 307       handle = dlopen(alt_path, mode);
 308       if (_libsaproc_debug && handle) {
 309         printf("libsaproc DEBUG: pathmap_dlopen substituted %s\n", alt_path);
 310       }
 311     }
 312   }
 313   if (handle == NULL) {
 314     handle = dlopen(name, mode);
 315   }
 316   if (_libsaproc_debug) {
 317     printf("libsaproc DEBUG: pathmap_dlopen %s return 0x%x\n", name, handle);
 318   }
 319   return handle;
 320 }
 321 
 322 // libproc and libthread_db callback functions
 323 
 324 extern "C" {
 325 
 326 static int
 327 init_libthread_db_ptrs(void *cd, const prmap_t *pmp, const char *object_name) {
 328   Debugger* dbg = (Debugger*) cd;
 329   JNIEnv* env = dbg->env;
 330   jobject this_obj = dbg->this_obj;
 331   struct ps_prochandle* ph = (struct ps_prochandle*) env->GetLongField(this_obj, p_ps_prochandle_ID);
 332 
 333   char *s1 = 0, *s2 = 0;
 334   char libthread_db[PATH_MAX];
 335 
 336   if (strstr(object_name, "/libthread.so.") == NULL)
 337      return (0);


 644   int fd = libsaproc_open(classes_jsa, O_RDONLY);
 645   if (fd < 0) {
 646     char errMsg[ERR_MSG_SIZE];
 647     sprintf(errMsg, "can't open shared archive file %s", classes_jsa);
 648     THROW_NEW_DEBUGGER_EXCEPTION_(errMsg, 1);
 649   } else {
 650     print_debug("opened shared archive file %s\n", classes_jsa);
 651   }
 652 
 653   // parse classes.jsa
 654   struct FileMapHeader* pheader = (struct FileMapHeader*) malloc(sizeof(struct FileMapHeader));
 655   if (pheader == NULL) {
 656     close(fd);
 657     THROW_NEW_DEBUGGER_EXCEPTION_("can't allocate memory for shared file map header", 1);
 658   }
 659 
 660   memset(pheader, 0, sizeof(struct FileMapHeader));
 661   // read FileMapHeader
 662   size_t n = read(fd, pheader, sizeof(struct FileMapHeader));
 663   if (n != sizeof(struct FileMapHeader)) {
 664     free(pheader);
 665     close(fd);
 666     char errMsg[ERR_MSG_SIZE];
 667     sprintf(errMsg, "unable to read shared archive file map header from %s", classes_jsa);


 668     THROW_NEW_DEBUGGER_EXCEPTION_(errMsg, 1);
 669   }
 670 
 671   // check file magic
 672   if (pheader->_magic != 0xf00baba2) {
 673     free(pheader);
 674     close(fd);
 675     char errMsg[ERR_MSG_SIZE];
 676     sprintf(errMsg, "%s has bad shared archive magic 0x%x, expecting 0xf00baba2",
 677                    classes_jsa, pheader->_magic);


 678     THROW_NEW_DEBUGGER_EXCEPTION_(errMsg, 1);
 679   }
 680 
 681   // check version
 682   if (pheader->_version != CURRENT_ARCHIVE_VERSION) {
 683     free(pheader);
 684     close(fd);
 685     char errMsg[ERR_MSG_SIZE];
 686     sprintf(errMsg, "%s has wrong shared archive version %d, expecting %d",
 687                    classes_jsa, pheader->_version, CURRENT_ARCHIVE_VERSION);


 688     THROW_NEW_DEBUGGER_EXCEPTION_(errMsg, 1);
 689   }
 690 
 691   if (_libsaproc_debug) {
 692     for (int m = 0; m < NUM_SHARED_MAPS; m++) {
 693        print_debug("shared file offset %d mapped at 0x%lx, size = %ld, read only? = %d\n",
 694           pheader->_space[m]._file_offset, pheader->_space[m]._base,
 695           pheader->_space[m]._used, pheader->_space[m]._read_only);
 696     }
 697   }
 698 
 699   // FIXME: For now, omitting other checks such as VM version etc.
 700 
 701   // store class archive file fd and map header in debugger object fields
 702   dbg->env->SetIntField(this_obj, classes_jsa_fd_ID, fd);
 703   dbg->env->SetLongField(this_obj, p_file_map_header_ID, (jlong)(uintptr_t) pheader);
 704   return 1;
 705 }
 706 
 707 } // extern "C"




 297     strcpy(alt_path, alt_root);
 298     strcat(alt_path, name);
 299     handle = dlopen(alt_path, mode);
 300     if (_libsaproc_debug && handle) {
 301       printf("libsaproc DEBUG: pathmap_dlopen substituted %s\n", alt_path);
 302     }
 303 
 304     if (handle == NULL && strrchr(name, '/')) {
 305       strcpy(alt_path, alt_root);
 306       strcat(alt_path, strrchr(name, '/'));
 307       handle = dlopen(alt_path, mode);
 308       if (_libsaproc_debug && handle) {
 309         printf("libsaproc DEBUG: pathmap_dlopen substituted %s\n", alt_path);
 310       }
 311     }
 312   }
 313   if (handle == NULL) {
 314     handle = dlopen(name, mode);
 315   }
 316   if (_libsaproc_debug) {
 317     printf("libsaproc DEBUG: pathmap_dlopen %s return 0x%lx\n", name, (unsigned long) handle);
 318   }
 319   return handle;
 320 }
 321 
 322 // libproc and libthread_db callback functions
 323 
 324 extern "C" {
 325 
 326 static int
 327 init_libthread_db_ptrs(void *cd, const prmap_t *pmp, const char *object_name) {
 328   Debugger* dbg = (Debugger*) cd;
 329   JNIEnv* env = dbg->env;
 330   jobject this_obj = dbg->this_obj;
 331   struct ps_prochandle* ph = (struct ps_prochandle*) env->GetLongField(this_obj, p_ps_prochandle_ID);
 332 
 333   char *s1 = 0, *s2 = 0;
 334   char libthread_db[PATH_MAX];
 335 
 336   if (strstr(object_name, "/libthread.so.") == NULL)
 337      return (0);


 644   int fd = libsaproc_open(classes_jsa, O_RDONLY);
 645   if (fd < 0) {
 646     char errMsg[ERR_MSG_SIZE];
 647     sprintf(errMsg, "can't open shared archive file %s", classes_jsa);
 648     THROW_NEW_DEBUGGER_EXCEPTION_(errMsg, 1);
 649   } else {
 650     print_debug("opened shared archive file %s\n", classes_jsa);
 651   }
 652 
 653   // parse classes.jsa
 654   struct FileMapHeader* pheader = (struct FileMapHeader*) malloc(sizeof(struct FileMapHeader));
 655   if (pheader == NULL) {
 656     close(fd);
 657     THROW_NEW_DEBUGGER_EXCEPTION_("can't allocate memory for shared file map header", 1);
 658   }
 659 
 660   memset(pheader, 0, sizeof(struct FileMapHeader));
 661   // read FileMapHeader
 662   size_t n = read(fd, pheader, sizeof(struct FileMapHeader));
 663   if (n != sizeof(struct FileMapHeader)) {


 664     char errMsg[ERR_MSG_SIZE];
 665     sprintf(errMsg, "unable to read shared archive file map header from %s", classes_jsa);
 666     close(fd);
 667     free(pheader);
 668     THROW_NEW_DEBUGGER_EXCEPTION_(errMsg, 1);
 669   }
 670 
 671   // check file magic
 672   if (pheader->_magic != 0xf00baba2) {


 673     char errMsg[ERR_MSG_SIZE];
 674     sprintf(errMsg, "%s has bad shared archive magic 0x%x, expecting 0xf00baba2",
 675                    classes_jsa, pheader->_magic);
 676     close(fd);
 677     free(pheader);
 678     THROW_NEW_DEBUGGER_EXCEPTION_(errMsg, 1);
 679   }
 680 
 681   // check version
 682   if (pheader->_version != CURRENT_ARCHIVE_VERSION) {


 683     char errMsg[ERR_MSG_SIZE];
 684     sprintf(errMsg, "%s has wrong shared archive version %d, expecting %d",
 685                    classes_jsa, pheader->_version, CURRENT_ARCHIVE_VERSION);
 686     close(fd);
 687     free(pheader);
 688     THROW_NEW_DEBUGGER_EXCEPTION_(errMsg, 1);
 689   }
 690 
 691   if (_libsaproc_debug) {
 692     for (int m = 0; m < NUM_SHARED_MAPS; m++) {
 693        print_debug("shared file offset %d mapped at 0x%lx, size = %ld, read only? = %d\n",
 694           pheader->_space[m]._file_offset, pheader->_space[m]._base,
 695           pheader->_space[m]._used, pheader->_space[m]._read_only);
 696     }
 697   }
 698 
 699   // FIXME: For now, omitting other checks such as VM version etc.
 700 
 701   // store class archive file fd and map header in debugger object fields
 702   dbg->env->SetIntField(this_obj, classes_jsa_fd_ID, fd);
 703   dbg->env->SetLongField(this_obj, p_file_map_header_ID, (jlong)(uintptr_t) pheader);
 704   return 1;
 705 }
 706 
 707 } // extern "C"


< prev index next >