< prev index next >

src/jdk.hotspot.agent/macosx/native/libsaproc/ps_core.c

Print this page


 199 //---------------------------------------------------------------
 200 // Part of the class sharing workaround:
 201 //
 202 // With class sharing, pages are mapped from classes.jsa file.
 203 // The read-only class sharing pages are mapped as MAP_SHARED,
 204 // PROT_READ pages. These pages are not dumped into core dump.
 205 // With this workaround, these pages are read from classes.jsa.
 206 
 207 // FIXME: !HACK ALERT!
 208 // The format of sharing achive file header is needed to read shared heap
 209 // file mappings. For now, I am hard coding portion of FileMapHeader here.
 210 // Refer to filemap.hpp.
 211 
 212 // FileMapHeader describes the shared space data in the file to be
 213 // mapped.  This structure gets written to a file.  It is not a class,
 214 // so that the compilers don't add any compiler-private data to it.
 215 
 216 #define NUM_SHARED_MAPS 9
 217 
 218 // Refer to FileMapInfo::_current_version in filemap.hpp
 219 #define CURRENT_ARCHIVE_VERSION 3
 220 
 221 typedef unsigned char* address;
 222 typedef uintptr_t      uintx;
 223 typedef intptr_t       intx;
 224 
 225 
 226 struct FileMapHeader {
 227   int     _magic;                   // identify file type.
 228   int     _crc;                     // header crc checksum.
 229   int     _version;                 // (from enum, above.)
 230   size_t  _alignment;               // how shared archive should be aligned
 231   int     _obj_alignment;           // value of ObjectAlignmentInBytes
 232   address _narrow_oop_base;         // compressed oop encoding base
 233   int     _narrow_oop_shift;        // compressed oop encoding shift
 234   bool    _compact_strings;         // value of CompactStrings
 235   uintx   _max_heap_size;           // java max heap size during dumping
 236   int     _narrow_oop_mode;         // compressed oop encoding mode
 237   int     _narrow_klass_shift;      // save narrow klass base and shift
 238   address _narrow_klass_base;
 239   char*   _misc_data_patching_start;
 240   char*   _read_only_tables_start;
 241   address _cds_i2i_entry_code_buffers;
 242   size_t  _cds_i2i_entry_code_buffers_size;
 243   size_t  _core_spaces_size;        // number of bytes allocated by the core spaces
 244                                     // (mc, md, ro, rw and od).
 245 



 246 
 247   struct space_info {
 248     int     _crc;          // crc checksum of the current space
 249     size_t  _file_offset;  // sizeof(this) rounded to vm page size
 250     union {
 251       char*  _base;        // copy-on-write base address
 252       intx   _offset;      // offset from the compressed oop encoding base, only used
 253                            // by archive heap space
 254     } _addr;
 255     size_t _used;          // for setting space top on read
 256     // 4991491 NOTICE These are C++ bool's in filemap.hpp and must match up with
 257     // the C type matching the C++ bool type on any given platform.
 258     // We assume the corresponding C type is char but licensees
 259     // may need to adjust the type of these fields.
 260     char   _read_only;     // read only space?
 261     char   _allow_exec;    // executable code in space?


 262   } _space[NUM_SHARED_MAPS];
 263 
 264   // Ignore the rest of the FileMapHeader. We don't need those fields here.
 265 };
 266 
 267 static bool read_jboolean(struct ps_prochandle* ph, uintptr_t addr, jboolean* pvalue) {
 268   jboolean i;
 269   if (ps_pread(ph, (psaddr_t) addr, &i, sizeof(i)) == PS_OK) {
 270     *pvalue = i;
 271     return true;
 272   } else {
 273     return false;
 274   }
 275 }
 276 
 277 static bool read_pointer(struct ps_prochandle* ph, uintptr_t addr, uintptr_t* pvalue) {
 278   uintptr_t uip;
 279   if (ps_pread(ph, (psaddr_t) addr, (char *)&uip, sizeof(uip)) == PS_OK) {
 280     *pvalue = uip;
 281     return true;




 199 //---------------------------------------------------------------
 200 // Part of the class sharing workaround:
 201 //
 202 // With class sharing, pages are mapped from classes.jsa file.
 203 // The read-only class sharing pages are mapped as MAP_SHARED,
 204 // PROT_READ pages. These pages are not dumped into core dump.
 205 // With this workaround, these pages are read from classes.jsa.
 206 
 207 // FIXME: !HACK ALERT!
 208 // The format of sharing achive file header is needed to read shared heap
 209 // file mappings. For now, I am hard coding portion of FileMapHeader here.
 210 // Refer to filemap.hpp.
 211 
 212 // FileMapHeader describes the shared space data in the file to be
 213 // mapped.  This structure gets written to a file.  It is not a class,
 214 // so that the compilers don't add any compiler-private data to it.
 215 
 216 #define NUM_SHARED_MAPS 9
 217 
 218 // Refer to FileMapInfo::_current_version in filemap.hpp
 219 #define CURRENT_ARCHIVE_VERSION 4
 220 
 221 typedef unsigned char* address;
 222 typedef uintptr_t      uintx;
 223 typedef intptr_t       intx;
 224 
 225 
 226 struct FileMapHeader {
 227   int     _magic;                   // identify file type.
 228   int     _crc;                     // header crc checksum.
 229   int     _version;                 // (from enum, above.)
 230   size_t  _alignment;               // how shared archive should be aligned
 231   int     _obj_alignment;           // value of ObjectAlignmentInBytes
 232   address _narrow_oop_base;         // compressed oop encoding base
 233   int     _narrow_oop_shift;        // compressed oop encoding shift
 234   bool    _compact_strings;         // value of CompactStrings
 235   uintx   _max_heap_size;           // java max heap size during dumping
 236   int     _narrow_oop_mode;         // compressed oop encoding mode
 237   int     _narrow_klass_shift;      // save narrow klass base and shift
 238   address _narrow_klass_base;
 239   char*   _misc_data_patching_start;
 240   char*   _read_only_tables_start;
 241   address _cds_i2i_entry_code_buffers;
 242   size_t  _cds_i2i_entry_code_buffers_size;
 243   size_t  _core_spaces_size;        // number of bytes allocated by the core spaces
 244                                     // (mc, md, ro, rw and od).
 245   struct MemRegion {
 246     address   _start;
 247     size_t    _word_size;
 248   } _g1_reserved;                   // reserved region at dump time.
 249 
 250   struct space_info {
 251     int     _crc;          // crc checksum of the current space
 252     size_t  _file_offset;  // sizeof(this) rounded to vm page size
 253     union {
 254       char*  _base;        // copy-on-write base address
 255       intx   _offset;      // offset from the compressed oop encoding base, only used
 256                            // by archive heap space
 257     } _addr;
 258     size_t _used;          // for setting space top on read
 259     // 4991491 NOTICE These are C++ bool's in filemap.hpp and must match up with
 260     // the C type matching the C++ bool type on any given platform.
 261     // We assume the corresponding C type is char but licensees
 262     // may need to adjust the type of these fields.
 263     char   _read_only;     // read only space?
 264     char   _allow_exec;    // executable code in space?
 265     address _oopmap;       // bitmap for relocating embedded oops
 266     size_t  _oopmap_size_in_bits;
 267   } _space[NUM_SHARED_MAPS];
 268 
 269   // Ignore the rest of the FileMapHeader. We don't need those fields here.
 270 };
 271 
 272 static bool read_jboolean(struct ps_prochandle* ph, uintptr_t addr, jboolean* pvalue) {
 273   jboolean i;
 274   if (ps_pread(ph, (psaddr_t) addr, &i, sizeof(i)) == PS_OK) {
 275     *pvalue = i;
 276     return true;
 277   } else {
 278     return false;
 279   }
 280 }
 281 
 282 static bool read_pointer(struct ps_prochandle* ph, uintptr_t addr, uintptr_t* pvalue) {
 283   uintptr_t uip;
 284   if (ps_pread(ph, (psaddr_t) addr, (char *)&uip, sizeof(uip)) == PS_OK) {
 285     *pvalue = uip;
 286     return true;


< prev index next >