1880 StickyClassDumper class_dumper(writer());
1881 ClassLoaderData::the_null_class_loader_data()->classes_do(&class_dumper);
1882
1883 // fixes up the length of the dump record and writes the HPROF_HEAP_DUMP_END record.
1884 DumperSupport::end_of_dump(writer());
1885
1886 // Now we clear the global variables, so that a future dumper might run.
1887 clear_global_dumper();
1888 clear_global_writer();
1889 }
1890
1891 void VM_HeapDumper::dump_stack_traces() {
1892 // write a HPROF_TRACE record without any frames to be referenced as object alloc sites
1893 DumperSupport::write_header(writer(), HPROF_TRACE, 3*sizeof(u4));
1894 writer()->write_u4((u4) STACK_TRACE_ID);
1895 writer()->write_u4(0); // thread number
1896 writer()->write_u4(0); // frame count
1897
1898 _stack_traces = NEW_C_HEAP_ARRAY(ThreadStackTrace*, Threads::number_of_threads(), mtInternal);
1899 int frame_serial_num = 0;
1900 ThreadsListHandle tlh;
1901 JavaThreadIterator jti(tlh.list());
1902 for (JavaThread* thread = jti.first(); thread != NULL; thread = jti.next()) {
1903 oop threadObj = thread->threadObj();
1904 if (threadObj != NULL && !thread->is_exiting() && !thread->is_hidden_from_external_view()) {
1905 // dump thread stack trace
1906 ThreadStackTrace* stack_trace = new ThreadStackTrace(thread, false);
1907 stack_trace->dump_stack_at_safepoint(-1);
1908 _stack_traces[_num_threads++] = stack_trace;
1909
1910 // write HPROF_FRAME records for this thread's stack trace
1911 int depth = stack_trace->get_stack_depth();
1912 int thread_frame_start = frame_serial_num;
1913 int extra_frames = 0;
1914 // write fake frame that makes it look like the thread, which caused OOME,
1915 // is in the OutOfMemoryError zero-parameter constructor
1916 if (thread == _oome_thread && _oome_constructor != NULL) {
1917 int oome_serial_num = _klass_map->find(_oome_constructor->method_holder());
1918 // the class serial number starts from 1
1919 assert(oome_serial_num > 0, "OutOfMemoryError class not found");
1920 DumperSupport::dump_stack_frame(writer(), ++frame_serial_num, oome_serial_num,
1921 _oome_constructor, 0);
1922 extra_frames++;
|
1880 StickyClassDumper class_dumper(writer());
1881 ClassLoaderData::the_null_class_loader_data()->classes_do(&class_dumper);
1882
1883 // fixes up the length of the dump record and writes the HPROF_HEAP_DUMP_END record.
1884 DumperSupport::end_of_dump(writer());
1885
1886 // Now we clear the global variables, so that a future dumper might run.
1887 clear_global_dumper();
1888 clear_global_writer();
1889 }
1890
1891 void VM_HeapDumper::dump_stack_traces() {
1892 // write a HPROF_TRACE record without any frames to be referenced as object alloc sites
1893 DumperSupport::write_header(writer(), HPROF_TRACE, 3*sizeof(u4));
1894 writer()->write_u4((u4) STACK_TRACE_ID);
1895 writer()->write_u4(0); // thread number
1896 writer()->write_u4(0); // frame count
1897
1898 _stack_traces = NEW_C_HEAP_ARRAY(ThreadStackTrace*, Threads::number_of_threads(), mtInternal);
1899 int frame_serial_num = 0;
1900 for (JavaThreadIteratorWithHandle jtiwh; JavaThread *thread = jtiwh.next(); ) {
1901 oop threadObj = thread->threadObj();
1902 if (threadObj != NULL && !thread->is_exiting() && !thread->is_hidden_from_external_view()) {
1903 // dump thread stack trace
1904 ThreadStackTrace* stack_trace = new ThreadStackTrace(thread, false);
1905 stack_trace->dump_stack_at_safepoint(-1);
1906 _stack_traces[_num_threads++] = stack_trace;
1907
1908 // write HPROF_FRAME records for this thread's stack trace
1909 int depth = stack_trace->get_stack_depth();
1910 int thread_frame_start = frame_serial_num;
1911 int extra_frames = 0;
1912 // write fake frame that makes it look like the thread, which caused OOME,
1913 // is in the OutOfMemoryError zero-parameter constructor
1914 if (thread == _oome_thread && _oome_constructor != NULL) {
1915 int oome_serial_num = _klass_map->find(_oome_constructor->method_holder());
1916 // the class serial number starts from 1
1917 assert(oome_serial_num > 0, "OutOfMemoryError class not found");
1918 DumperSupport::dump_stack_frame(writer(), ++frame_serial_num, oome_serial_num,
1919 _oome_constructor, 0);
1920 extra_frames++;
|