Mercurial > hg > graal-compiler
comparison src/share/vm/runtime/thread.cpp @ 1694:ab3fd720516c
6378314: Bad warning message when agent library not found. local directory is not searched.
Summary: Print a more detailed error message for agent library load failure.
Reviewed-by: jcoomes, never, ohair, coleenp
Contributed-by: jeremymanson@google.com
author | rasbold |
---|---|
date | Tue, 10 Aug 2010 19:17:57 -0400 |
parents | 126ea7725993 |
children | 21e519b91576 |
comparison
equal
deleted
inserted
replaced
1681:126ea7725993 | 1694:ab3fd720516c |
---|---|
3279 | 3279 |
3280 if (library == NULL) { | 3280 if (library == NULL) { |
3281 char buffer[JVM_MAXPATHLEN]; | 3281 char buffer[JVM_MAXPATHLEN]; |
3282 char ebuf[1024]; | 3282 char ebuf[1024]; |
3283 const char *name = agent->name(); | 3283 const char *name = agent->name(); |
3284 const char *msg = "Could not find agent library "; | |
3284 | 3285 |
3285 if (agent->is_absolute_path()) { | 3286 if (agent->is_absolute_path()) { |
3286 library = hpi::dll_load(name, ebuf, sizeof ebuf); | 3287 library = hpi::dll_load(name, ebuf, sizeof ebuf); |
3287 if (library == NULL) { | 3288 if (library == NULL) { |
3289 const char *sub_msg = " in absolute path, with error: "; | |
3290 size_t len = strlen(msg) + strlen(name) + strlen(sub_msg) + strlen(ebuf) + 1; | |
3291 char *buf = NEW_C_HEAP_ARRAY(char, len); | |
3292 jio_snprintf(buf, len, "%s%s%s%s", msg, name, sub_msg, ebuf); | |
3288 // If we can't find the agent, exit. | 3293 // If we can't find the agent, exit. |
3289 vm_exit_during_initialization("Could not find agent library in absolute path", name); | 3294 vm_exit_during_initialization(buf, NULL); |
3295 FREE_C_HEAP_ARRAY(char, buf); | |
3290 } | 3296 } |
3291 } else { | 3297 } else { |
3292 // Try to load the agent from the standard dll directory | 3298 // Try to load the agent from the standard dll directory |
3293 hpi::dll_build_name(buffer, sizeof(buffer), Arguments::get_dll_dir(), name); | 3299 hpi::dll_build_name(buffer, sizeof(buffer), Arguments::get_dll_dir(), name); |
3294 library = hpi::dll_load(buffer, ebuf, sizeof ebuf); | 3300 library = hpi::dll_load(buffer, ebuf, sizeof ebuf); |
3297 if (library == NULL && strcmp(name, "instrument") == 0) { | 3303 if (library == NULL && strcmp(name, "instrument") == 0) { |
3298 char *props = Arguments::get_kernel_properties(); | 3304 char *props = Arguments::get_kernel_properties(); |
3299 char *home = Arguments::get_java_home(); | 3305 char *home = Arguments::get_java_home(); |
3300 const char *fmt = "%s/bin/java %s -Dkernel.background.download=false" | 3306 const char *fmt = "%s/bin/java %s -Dkernel.background.download=false" |
3301 " sun.jkernel.DownloadManager -download client_jvm"; | 3307 " sun.jkernel.DownloadManager -download client_jvm"; |
3302 int length = strlen(props) + strlen(home) + strlen(fmt) + 1; | 3308 size_t length = strlen(props) + strlen(home) + strlen(fmt) + 1; |
3303 char *cmd = AllocateHeap(length); | 3309 char *cmd = NEW_C_HEAP_ARRAY(char, length); |
3304 jio_snprintf(cmd, length, fmt, home, props); | 3310 jio_snprintf(cmd, length, fmt, home, props); |
3305 int status = os::fork_and_exec(cmd); | 3311 int status = os::fork_and_exec(cmd); |
3306 FreeHeap(props); | 3312 FreeHeap(props); |
3307 FreeHeap(cmd); | |
3308 if (status == -1) { | 3313 if (status == -1) { |
3309 warning(cmd); | 3314 warning(cmd); |
3310 vm_exit_during_initialization("fork_and_exec failed: %s", | 3315 vm_exit_during_initialization("fork_and_exec failed: %s", |
3311 strerror(errno)); | 3316 strerror(errno)); |
3312 } | 3317 } |
3318 FREE_C_HEAP_ARRAY(char, cmd); | |
3313 // when this comes back the instrument.dll should be where it belongs. | 3319 // when this comes back the instrument.dll should be where it belongs. |
3314 library = hpi::dll_load(buffer, ebuf, sizeof ebuf); | 3320 library = hpi::dll_load(buffer, ebuf, sizeof ebuf); |
3315 } | 3321 } |
3316 #endif // KERNEL | 3322 #endif // KERNEL |
3317 if (library == NULL) { // Try the local directory | 3323 if (library == NULL) { // Try the local directory |
3318 char ns[1] = {0}; | 3324 char ns[1] = {0}; |
3319 hpi::dll_build_name(buffer, sizeof(buffer), ns, name); | 3325 hpi::dll_build_name(buffer, sizeof(buffer), ns, name); |
3320 library = hpi::dll_load(buffer, ebuf, sizeof ebuf); | 3326 library = hpi::dll_load(buffer, ebuf, sizeof ebuf); |
3321 if (library == NULL) { | 3327 if (library == NULL) { |
3328 const char *sub_msg = " on the library path, with error: "; | |
3329 size_t len = strlen(msg) + strlen(name) + strlen(sub_msg) + strlen(ebuf) + 1; | |
3330 char *buf = NEW_C_HEAP_ARRAY(char, len); | |
3331 jio_snprintf(buf, len, "%s%s%s%s", msg, name, sub_msg, ebuf); | |
3322 // If we can't find the agent, exit. | 3332 // If we can't find the agent, exit. |
3323 vm_exit_during_initialization("Could not find agent library on the library path or in the local directory", name); | 3333 vm_exit_during_initialization(buf, NULL); |
3334 FREE_C_HEAP_ARRAY(char, buf); | |
3324 } | 3335 } |
3325 } | 3336 } |
3326 } | 3337 } |
3327 agent->set_os_lib(library); | 3338 agent->set_os_lib(library); |
3328 } | 3339 } |