comparison src/share/vm/services/heapDumper.cpp @ 6275:957c266d8bc5

Merge with http://hg.openjdk.java.net/hsx/hsx24/hotspot/
author Doug Simon <doug.simon@oracle.com>
date Tue, 21 Aug 2012 10:39:19 +0200
parents 1d7922586cf6
children da91efe96a93
comparison
equal deleted inserted replaced
5891:fd8832ae511d 6275:957c266d8bc5
434 DumpWriter::DumpWriter(const char* path) { 434 DumpWriter::DumpWriter(const char* path) {
435 // try to allocate an I/O buffer of io_buffer_size. If there isn't 435 // try to allocate an I/O buffer of io_buffer_size. If there isn't
436 // sufficient memory then reduce size until we can allocate something. 436 // sufficient memory then reduce size until we can allocate something.
437 _size = io_buffer_size; 437 _size = io_buffer_size;
438 do { 438 do {
439 _buffer = (char*)os::malloc(_size); 439 _buffer = (char*)os::malloc(_size, mtInternal);
440 if (_buffer == NULL) { 440 if (_buffer == NULL) {
441 _size = _size >> 1; 441 _size = _size >> 1;
442 } 442 }
443 } while (_buffer == NULL && _size > 0); 443 } while (_buffer == NULL && _size > 0);
444 assert((_size > 0 && _buffer != NULL) || (_size == 0 && _buffer == NULL), "sanity check"); 444 assert((_size > 0 && _buffer != NULL) || (_size == 0 && _buffer == NULL), "sanity check");
1403 gc_before_heap_dump) { 1403 gc_before_heap_dump) {
1404 _local_writer = writer; 1404 _local_writer = writer;
1405 _gc_before_heap_dump = gc_before_heap_dump; 1405 _gc_before_heap_dump = gc_before_heap_dump;
1406 _is_segmented_dump = false; 1406 _is_segmented_dump = false;
1407 _dump_start = (jlong)-1; 1407 _dump_start = (jlong)-1;
1408 _klass_map = new (ResourceObj::C_HEAP) GrowableArray<Klass*>(INITIAL_CLASS_COUNT, true); 1408 _klass_map = new (ResourceObj::C_HEAP, mtInternal) GrowableArray<Klass*>(INITIAL_CLASS_COUNT, true);
1409 _stack_traces = NULL; 1409 _stack_traces = NULL;
1410 _num_threads = 0; 1410 _num_threads = 0;
1411 if (oome) { 1411 if (oome) {
1412 assert(!Thread::current()->is_VM_thread(), "Dump from OutOfMemoryError cannot be called by the VMThread"); 1412 assert(!Thread::current()->is_VM_thread(), "Dump from OutOfMemoryError cannot be called by the VMThread");
1413 // get OutOfMemoryError zero-parameter constructor 1413 // get OutOfMemoryError zero-parameter constructor
1424 ~VM_HeapDumper() { 1424 ~VM_HeapDumper() {
1425 if (_stack_traces != NULL) { 1425 if (_stack_traces != NULL) {
1426 for (int i=0; i < _num_threads; i++) { 1426 for (int i=0; i < _num_threads; i++) {
1427 delete _stack_traces[i]; 1427 delete _stack_traces[i];
1428 } 1428 }
1429 FREE_C_HEAP_ARRAY(ThreadStackTrace*, _stack_traces); 1429 FREE_C_HEAP_ARRAY(ThreadStackTrace*, _stack_traces, mtInternal);
1430 } 1430 }
1431 delete _klass_map; 1431 delete _klass_map;
1432 } 1432 }
1433 1433
1434 VMOp_Type type() const { return VMOp_HeapDumper; } 1434 VMOp_Type type() const { return VMOp_HeapDumper; }
1648 frame* fr = vf->frame_pointer(); 1648 frame* fr = vf->frame_pointer();
1649 assert(fr != NULL, "sanity check"); 1649 assert(fr != NULL, "sanity check");
1650 if (fr->is_entry_frame()) { 1650 if (fr->is_entry_frame()) {
1651 last_entry_frame = fr; 1651 last_entry_frame = fr;
1652 } 1652 }
1653 if (fr->is_ricochet_frame()) {
1654 fr->oops_ricochet_do(&blk, vf->register_map());
1655 }
1656 } 1653 }
1657 vf = vf->sender(); 1654 vf = vf->sender();
1658 } 1655 }
1659 } else { 1656 } else {
1660 // no last java frame but there may be JNI locals 1657 // no last java frame but there may be JNI locals
1804 DumperSupport::write_header(writer(), HPROF_TRACE, 3*sizeof(u4)); 1801 DumperSupport::write_header(writer(), HPROF_TRACE, 3*sizeof(u4));
1805 writer()->write_u4((u4) STACK_TRACE_ID); 1802 writer()->write_u4((u4) STACK_TRACE_ID);
1806 writer()->write_u4(0); // thread number 1803 writer()->write_u4(0); // thread number
1807 writer()->write_u4(0); // frame count 1804 writer()->write_u4(0); // frame count
1808 1805
1809 _stack_traces = NEW_C_HEAP_ARRAY(ThreadStackTrace*, Threads::number_of_threads()); 1806 _stack_traces = NEW_C_HEAP_ARRAY(ThreadStackTrace*, Threads::number_of_threads(), mtInternal);
1810 int frame_serial_num = 0; 1807 int frame_serial_num = 0;
1811 for (JavaThread* thread = Threads::first(); thread != NULL ; thread = thread->next()) { 1808 for (JavaThread* thread = Threads::first(); thread != NULL ; thread = thread->next()) {
1812 oop threadObj = thread->threadObj(); 1809 oop threadObj = thread->threadObj();
1813 if (threadObj != NULL && !thread->is_exiting() && !thread->is_hidden_from_external_view()) { 1810 if (threadObj != NULL && !thread->is_exiting() && !thread->is_hidden_from_external_view()) {
1814 // dump thread stack trace 1811 // dump thread stack trace
2003 const size_t dlen = strlen(base_path); // if heap dump dir specified 2000 const size_t dlen = strlen(base_path); // if heap dump dir specified
2004 jio_snprintf(&base_path[dlen], sizeof(base_path)-dlen, "%s%d%s", 2001 jio_snprintf(&base_path[dlen], sizeof(base_path)-dlen, "%s%d%s",
2005 dump_file_name, os::current_process_id(), dump_file_ext); 2002 dump_file_name, os::current_process_id(), dump_file_ext);
2006 } 2003 }
2007 const size_t len = strlen(base_path) + 1; 2004 const size_t len = strlen(base_path) + 1;
2008 my_path = (char*)os::malloc(len); 2005 my_path = (char*)os::malloc(len, mtInternal);
2009 if (my_path == NULL) { 2006 if (my_path == NULL) {
2010 warning("Cannot create heap dump file. Out of system memory."); 2007 warning("Cannot create heap dump file. Out of system memory.");
2011 return; 2008 return;
2012 } 2009 }
2013 strncpy(my_path, base_path, len); 2010 strncpy(my_path, base_path, len);
2014 } else { 2011 } else {
2015 // Append a sequence number id for dumps following the first 2012 // Append a sequence number id for dumps following the first
2016 const size_t len = strlen(base_path) + max_digit_chars + 2; // for '.' and \0 2013 const size_t len = strlen(base_path) + max_digit_chars + 2; // for '.' and \0
2017 my_path = (char*)os::malloc(len); 2014 my_path = (char*)os::malloc(len, mtInternal);
2018 if (my_path == NULL) { 2015 if (my_path == NULL) {
2019 warning("Cannot create heap dump file. Out of system memory."); 2016 warning("Cannot create heap dump file. Out of system memory.");
2020 return; 2017 return;
2021 } 2018 }
2022 jio_snprintf(my_path, len, "%s.%d", base_path, dump_file_seq); 2019 jio_snprintf(my_path, len, "%s.%d", base_path, dump_file_seq);