1 /* 2 * Copyright (C) 2008 Google Inc. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.hit; 18 19 public class StackTrace { 20 int mSerialNumber; 21 int mThreadSerialNumber; 22 StackFrame[] mFrames; 23 24 /* 25 * For subsets of the stack frame we'll reference the parent list of frames 26 * but keep track of its offset into the parent's list of stack frame ids. 27 * This alleviates the need to constantly be duplicating subsections of the 28 * list of stack frame ids. 29 */ 30 StackTrace mParent = null; 31 int mOffset = 0; 32 StackTrace()33 private StackTrace() { 34 35 } 36 StackTrace(int serial, int thread, StackFrame[] frames)37 public StackTrace(int serial, int thread, StackFrame[] frames) { 38 mSerialNumber = serial; 39 mThreadSerialNumber = thread; 40 mFrames = frames; 41 } 42 fromDepth(int startingDepth)43 public final StackTrace fromDepth(int startingDepth) { 44 StackTrace result = new StackTrace(); 45 46 if (mParent != null) { 47 result.mParent = mParent; 48 } else { 49 result.mParent = this; 50 } 51 52 result.mOffset = startingDepth + mOffset; 53 54 return result; 55 } 56 dump()57 public final void dump() { 58 final int N = mFrames.length; 59 60 for (int i = 0; i < N; i++) { 61 System.out.println(mFrames[i].toString()); 62 } 63 } 64 } 65