Path: blob/master/test/hotspot/jtreg/serviceability/tmtools/jstack/utils/ThreadStack.java
41159 views
/*1* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/22package utils;2324import java.util.Iterator;25import java.util.LinkedList;2627/**28*29* Represents the stack of the thread30*31*/32public class ThreadStack {3334private String threadType; // Thread / RealtimeThread / NoHeapRealtimeThread35private String threadName;36private String type; //daemon or not37private String priority;38private String tid;39private String nid;4041/**42* runnable or waiting on condition43*/44private String status;45private String pointerRange;4647/**48* i.e. java.lang.Thread.State: WAITING (on object monitor)49*/50private String extendedStatus;5152private LinkedList<MethodInfo> stack = new LinkedList<MethodInfo>();5354private LinkedList<LockInfo> lockOSList = new LinkedList<LockInfo>();5556public String getThreadName() {57return threadName;58}5960public void setThreadName(String threadName) {61this.threadName = threadName;62}6364public String getType() {65return type;66}6768public void setType(String type) {69this.type = type;70}7172public String getPriority() {73return priority;74}7576public void setPriority(String priority) {77this.priority = priority;78}7980public String getTid() {81return tid;82}8384public void setTid(String tid) {85this.tid = tid;86}8788public String getNid() {89return nid;90}9192public void setNid(String nid) {93this.nid = nid;94}9596public String getStatus() {97return status;98}99100public void setStatus(String status) {101this.status = status;102}103104public String getPointerRange() {105return pointerRange;106}107108public void setPointerRange(String pointerRange) {109this.pointerRange = pointerRange;110}111112public String getExtendedStatus() {113return extendedStatus;114}115116public void setExtendedStatus(String extendedStatus) {117this.extendedStatus = extendedStatus;118}119120public LinkedList<MethodInfo> getStack() {121return stack;122}123124public LinkedList<LockInfo> getLockOSList() {125return lockOSList;126}127128public void setLockOSList(LinkedList<LockInfo> lockOSList) {129this.lockOSList = lockOSList;130}131132public void addMethod(MethodInfo mi) {133stack.add(mi);134}135136public boolean hasEqualStack(ThreadStack another) {137boolean result = true;138139Iterator<MethodInfo> it1 = stack.iterator();140Iterator<MethodInfo> it2 = another.stack.iterator();141142while (it1.hasNext() && it2.hasNext()) {143144MethodInfo mi1 = it1.next();145MethodInfo mi2 = it2.next();146147if (mi1 == null && mi2 == null) {148break;149}150151boolean oneOfMethodInfoIsNull = mi1 == null && mi2 != null || mi1 != null && mi2 == null;152153if (oneOfMethodInfoIsNull || !mi1.equals(mi2)) {154result = false;155}156}157158if (it1.hasNext() || it2.hasNext()) {159Utils.log("stack sizes", String.valueOf(stack.size()), String.valueOf(another.stack.size()));160result = false;161}162163return result;164}165166public String getThreadType() {167return threadType;168}169170public void setThreadType(String threadType) {171this.threadType = threadType;172}173174}175176177