2116 jio_snprintf(fname, sizeof(fname), "/proc/%d/maps", pid); |
2116 jio_snprintf(fname, sizeof(fname), "/proc/%d/maps", pid); |
2117 |
2117 |
2118 if (!_print_ascii_file(fname, st)) { |
2118 if (!_print_ascii_file(fname, st)) { |
2119 st->print("Can not get library information for pid = %d\n", pid); |
2119 st->print("Can not get library information for pid = %d\n", pid); |
2120 } |
2120 } |
|
2121 } |
|
2122 |
|
2123 int os::get_loaded_modules_info(os::LoadedModulesCallbackFunc callback, void *param) { |
|
2124 FILE *procmapsFile = NULL; |
|
2125 |
|
2126 // Open the procfs maps file for the current process |
|
2127 if ((procmapsFile = fopen("/proc/self/maps", "r")) != NULL) { |
|
2128 // Allocate PATH_MAX for file name plus a reasonable size for other fields. |
|
2129 char line[PATH_MAX + 100]; |
|
2130 |
|
2131 // Read line by line from 'file' |
|
2132 while (fgets(line, sizeof(line), procmapsFile) != NULL) { |
|
2133 u8 base, top, offset, inode; |
|
2134 char permissions[5]; |
|
2135 char device[6]; |
|
2136 char name[PATH_MAX + 1]; |
|
2137 |
|
2138 // Parse fields from line |
|
2139 sscanf(line, "%lx-%lx %4s %lx %5s %ld %s", &base, &top, permissions, &offset, device, &inode, name); |
|
2140 |
|
2141 // Filter by device id '00:00' so that we only get file system mapped files. |
|
2142 if (strcmp(device, "00:00") != 0) { |
|
2143 |
|
2144 // Call callback with the fields of interest |
|
2145 if(callback(name, (address)base, (address)top, param)) { |
|
2146 // Oops abort, callback aborted |
|
2147 fclose(procmapsFile); |
|
2148 return 1; |
|
2149 } |
|
2150 } |
|
2151 } |
|
2152 fclose(procmapsFile); |
|
2153 } |
|
2154 return 0; |
2121 } |
2155 } |
2122 |
2156 |
2123 void os::print_os_info_brief(outputStream* st) { |
2157 void os::print_os_info_brief(outputStream* st) { |
2124 os::Linux::print_distro_info(st); |
2158 os::Linux::print_distro_info(st); |
2125 |
2159 |