Mercurial > hg > graal-compiler
comparison src/share/vm/runtime/arguments.cpp @ 12215:621eda7235d2
7164841: Improvements to the GC log file rotation
Summary: made changes to easily identify current log file in rotation. Parameterize the input with %t for time replacement in file name.
Reviewed-by: ccheung, tschatzl, tamao, zgu
Contributed-by: yumin.qi@oracle.com
author | minqi |
---|---|
date | Mon, 16 Sep 2013 15:35:04 -0700 |
parents | bb57d48691f5 |
children | 06ae47d9d088 dfae98867ee8 |
comparison
equal
deleted
inserted
replaced
12212:4472884d8b37 | 12215:621eda7235d2 |
---|---|
1837 if (UseGCLogFileRotation) { | 1837 if (UseGCLogFileRotation) { |
1838 if ((Arguments::gc_log_filename() == NULL) || | 1838 if ((Arguments::gc_log_filename() == NULL) || |
1839 (NumberOfGCLogFiles == 0) || | 1839 (NumberOfGCLogFiles == 0) || |
1840 (GCLogFileSize == 0)) { | 1840 (GCLogFileSize == 0)) { |
1841 jio_fprintf(defaultStream::output_stream(), | 1841 jio_fprintf(defaultStream::output_stream(), |
1842 "To enable GC log rotation, use -Xloggc:<filename> -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=<num_of_files> -XX:GCLogFileSize=<num_of_size>\n" | 1842 "To enable GC log rotation, use -Xloggc:<filename> -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=<num_of_files> -XX:GCLogFileSize=<num_of_size>[k|K|m|M|g|G]\n" |
1843 "where num_of_file > 0 and num_of_size > 0\n" | 1843 "where num_of_file > 0 and num_of_size > 0\n" |
1844 "GC log rotation is turned off\n"); | 1844 "GC log rotation is turned off\n"); |
1845 UseGCLogFileRotation = false; | 1845 UseGCLogFileRotation = false; |
1846 } | 1846 } |
1847 } | 1847 } |
1849 if (UseGCLogFileRotation && GCLogFileSize < 8*K) { | 1849 if (UseGCLogFileRotation && GCLogFileSize < 8*K) { |
1850 FLAG_SET_CMDLINE(uintx, GCLogFileSize, 8*K); | 1850 FLAG_SET_CMDLINE(uintx, GCLogFileSize, 8*K); |
1851 jio_fprintf(defaultStream::output_stream(), | 1851 jio_fprintf(defaultStream::output_stream(), |
1852 "GCLogFileSize changed to minimum 8K\n"); | 1852 "GCLogFileSize changed to minimum 8K\n"); |
1853 } | 1853 } |
1854 } | |
1855 | |
1856 // This function is called for -Xloggc:<filename>, it can be used | |
1857 // to check if a given file name(or string) conforms to the following | |
1858 // specification: | |
1859 // A valid string only contains "[A-Z][a-z][0-9].-_%[p|t]" | |
1860 // %p and %t only allowed once. We only limit usage of filename not path | |
1861 bool is_filename_valid(const char *file_name) { | |
1862 const char* p = file_name; | |
1863 char file_sep = os::file_separator()[0]; | |
1864 const char* cp; | |
1865 // skip prefix path | |
1866 for (cp = file_name; *cp != '\0'; cp++) { | |
1867 if (*cp == '/' || *cp == file_sep) { | |
1868 p = cp + 1; | |
1869 } | |
1870 } | |
1871 | |
1872 int count_p = 0; | |
1873 int count_t = 0; | |
1874 while (*p != '\0') { | |
1875 if ((*p >= '0' && *p <= '9') || | |
1876 (*p >= 'A' && *p <= 'Z') || | |
1877 (*p >= 'a' && *p <= 'z') || | |
1878 *p == '-' || | |
1879 *p == '_' || | |
1880 *p == '.') { | |
1881 p++; | |
1882 continue; | |
1883 } | |
1884 if (*p == '%') { | |
1885 if(*(p + 1) == 'p') { | |
1886 p += 2; | |
1887 count_p ++; | |
1888 continue; | |
1889 } | |
1890 if (*(p + 1) == 't') { | |
1891 p += 2; | |
1892 count_t ++; | |
1893 continue; | |
1894 } | |
1895 } | |
1896 return false; | |
1897 } | |
1898 return count_p < 2 && count_t < 2; | |
1854 } | 1899 } |
1855 | 1900 |
1856 // Check consistency of GC selection | 1901 // Check consistency of GC selection |
1857 bool Arguments::check_gc_consistency() { | 1902 bool Arguments::check_gc_consistency() { |
1858 check_gclog_consistency(); | 1903 check_gclog_consistency(); |
2804 } else if (match_option(option, "-Xloggc:", &tail)) { | 2849 } else if (match_option(option, "-Xloggc:", &tail)) { |
2805 // Redirect GC output to the file. -Xloggc:<filename> | 2850 // Redirect GC output to the file. -Xloggc:<filename> |
2806 // ostream_init_log(), when called will use this filename | 2851 // ostream_init_log(), when called will use this filename |
2807 // to initialize a fileStream. | 2852 // to initialize a fileStream. |
2808 _gc_log_filename = strdup(tail); | 2853 _gc_log_filename = strdup(tail); |
2854 if (!is_filename_valid(_gc_log_filename)) { | |
2855 jio_fprintf(defaultStream::output_stream(), | |
2856 "Invalid file name for use with -Xloggc: Filename can only contain the " | |
2857 "characters [A-Z][a-z][0-9]-_.%%[p|t] but it has been %s\n" | |
2858 "Note %%p or %%t can only be used once\n", _gc_log_filename); | |
2859 return JNI_EINVAL; | |
2860 } | |
2809 FLAG_SET_CMDLINE(bool, PrintGC, true); | 2861 FLAG_SET_CMDLINE(bool, PrintGC, true); |
2810 FLAG_SET_CMDLINE(bool, PrintGCTimeStamps, true); | 2862 FLAG_SET_CMDLINE(bool, PrintGCTimeStamps, true); |
2811 | 2863 |
2812 // JNI hooks | 2864 // JNI hooks |
2813 } else if (match_option(option, "-Xcheck", &tail)) { | 2865 } else if (match_option(option, "-Xcheck", &tail)) { |