8185003: JMX: Add a version of ThreadMXBean.dumpAllThreads with a maxDepth argument

Added two new API's to limit the stack trace depth

Reviewed-by: mchung, dfuchs, rriggs, egahlin
This commit is contained in:
Ujwal Vangapally 2017-10-05 01:31:53 -07:00 committed by Ujwal Vangapally
parent 2990ce8012
commit 96d0817455
10 changed files with 317 additions and 80 deletions

View file

@ -562,6 +562,10 @@ void ThreadStackTrace::dump_stack_at_safepoint(int maxDepth) {
vframe* start_vf = _thread->last_java_vframe(&reg_map);
int count = 0;
for (vframe* f = start_vf; f; f = f->sender() ) {
if (maxDepth >= 0 && count == maxDepth) {
// Skip frames if more than maxDepth
break;
}
if (f->is_java_frame()) {
javaVFrame* jvf = javaVFrame::cast(f);
add_stack_frame(jvf);
@ -569,10 +573,6 @@ void ThreadStackTrace::dump_stack_at_safepoint(int maxDepth) {
} else {
// Ignore non-Java frames
}
if (maxDepth > 0 && count == maxDepth) {
// Skip frames if more than maxDepth
break;
}
}
}