Mercurial > hg > graal-compiler
comparison src/share/vm/runtime/arguments.cpp @ 10170:3c0584fec1e6
8010428: Special -agentpath checks needed with minimal VM to produce proper error message
Reviewed-by: dholmes, alanb, cjplummer, olagneau
Contributed-by: Carlos Lucasius <carlos.lucasius@oracle.com>
author | dholmes |
---|---|
date | Sun, 28 Apr 2013 18:24:04 -0400 |
parents | 480d934f62a8 |
children | e01e02a9fcb6 |
comparison
equal
deleted
inserted
replaced
10169:e10e43e58e92 | 10170:3c0584fec1e6 |
---|---|
2222 } | 2222 } |
2223 | 2223 |
2224 return JNI_OK; | 2224 return JNI_OK; |
2225 } | 2225 } |
2226 | 2226 |
2227 // Checks if name in command-line argument -agent{lib,path}:name[=options] | |
2228 // represents a valid HPROF of JDWP agent. is_path==true denotes that we | |
2229 // are dealing with -agentpath (case where name is a path), otherwise with | |
2230 // -agentlib | |
2231 bool valid_hprof_or_jdwp_agent(char *name, bool is_path) { | |
2232 char *_name; | |
2233 const char *_hprof = "hprof", *_jdwp = "jdwp"; | |
2234 size_t _len_hprof, _len_jdwp, _len_prefix; | |
2235 | |
2236 if (is_path) { | |
2237 if ((_name = strrchr(name, (int) *os::file_separator())) == NULL) { | |
2238 return false; | |
2239 } | |
2240 | |
2241 _name++; // skip past last path separator | |
2242 _len_prefix = strlen(JNI_LIB_PREFIX); | |
2243 | |
2244 if (strncmp(_name, JNI_LIB_PREFIX, _len_prefix) != 0) { | |
2245 return false; | |
2246 } | |
2247 | |
2248 _name += _len_prefix; | |
2249 _len_hprof = strlen(_hprof); | |
2250 _len_jdwp = strlen(_jdwp); | |
2251 | |
2252 if (strncmp(_name, _hprof, _len_hprof) == 0) { | |
2253 _name += _len_hprof; | |
2254 } | |
2255 else if (strncmp(_name, _jdwp, _len_jdwp) == 0) { | |
2256 _name += _len_jdwp; | |
2257 } | |
2258 else { | |
2259 return false; | |
2260 } | |
2261 | |
2262 if (strcmp(_name, JNI_LIB_SUFFIX) != 0) { | |
2263 return false; | |
2264 } | |
2265 | |
2266 return true; | |
2267 } | |
2268 | |
2269 if (strcmp(name, _hprof) == 0 || strcmp(name, _jdwp) == 0) { | |
2270 return true; | |
2271 } | |
2272 | |
2273 return false; | |
2274 } | |
2275 | |
2227 jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, | 2276 jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, |
2228 SysClassPath* scp_p, | 2277 SysClassPath* scp_p, |
2229 bool* scp_assembly_required_p, | 2278 bool* scp_assembly_required_p, |
2230 FlagValueOrigin origin) { | 2279 FlagValueOrigin origin) { |
2231 // Remaining part of option string | 2280 // Remaining part of option string |
2320 char *options = NULL; | 2369 char *options = NULL; |
2321 if(pos != NULL) { | 2370 if(pos != NULL) { |
2322 options = strcpy(NEW_C_HEAP_ARRAY(char, strlen(pos + 1) + 1, mtInternal), pos + 1); | 2371 options = strcpy(NEW_C_HEAP_ARRAY(char, strlen(pos + 1) + 1, mtInternal), pos + 1); |
2323 } | 2372 } |
2324 #if !INCLUDE_JVMTI | 2373 #if !INCLUDE_JVMTI |
2325 if ((strcmp(name, "hprof") == 0) || (strcmp(name, "jdwp") == 0)) { | 2374 if (valid_hprof_or_jdwp_agent(name, is_absolute_path)) { |
2326 jio_fprintf(defaultStream::error_stream(), | 2375 jio_fprintf(defaultStream::error_stream(), |
2327 "Profiling and debugging agents are not supported in this VM\n"); | 2376 "Profiling and debugging agents are not supported in this VM\n"); |
2328 return JNI_ERR; | 2377 return JNI_ERR; |
2329 } | 2378 } |
2330 #endif // !INCLUDE_JVMTI | 2379 #endif // !INCLUDE_JVMTI |