Merge "Add stack traces to logs about mismatched sequenece numbers in procstats." into nyc-dev

am: 9b87cc2

* commit '9b87cc2b8b7a72249aeb1f12b4482ea7fad29cb5':
  Add stack traces to logs about mismatched sequenece numbers in procstats.

Change-Id: Ia932b31cc3d05c4224d933d85193ca6f62d0cc8b
This commit is contained in:
Joe Onorato
2016-04-06 00:30:36 +00:00
committed by android-build-merger

View File

@@ -28,7 +28,7 @@ import com.android.internal.util.GrowingArrayUtils;
/** /**
* Class that contains a set of tables mapping byte ids to long values. * Class that contains a set of tables mapping byte ids to long values.
* *
* This class is used to store the ProcessStats data. This data happens to be * This class is used to store the ProcessStats data. This data happens to be
* a set of very sparse tables, that is mostly append or overwrite, with infrequent * a set of very sparse tables, that is mostly append or overwrite, with infrequent
* resets of the data. * resets of the data.
@@ -59,11 +59,11 @@ public class SparseMappingTable {
// Where the "index into array" part of the data appears in an offset integer. // Where the "index into array" part of the data appears in an offset integer.
private static final int INDEX_SHIFT = 16; private static final int INDEX_SHIFT = 16;
private static final int INDEX_MASK = 0xffff; private static final int INDEX_MASK = 0xffff;
private int mSequence; private int mSequence;
private int mNextIndex; private int mNextIndex;
private final ArrayList<long[]> mLongs = new ArrayList<long[]>(); private final ArrayList<long[]> mLongs = new ArrayList<long[]>();
/** /**
* A table of data as stored in a SparseMappingTable. * A table of data as stored in a SparseMappingTable.
*/ */
@@ -377,20 +377,24 @@ public class SparseMappingTable {
// since we were created or reset. // since we were created or reset.
if (mSequence == UNINITIALIZED_SEQUENCE) { if (mSequence == UNINITIALIZED_SEQUENCE) {
logOrThrow("mSequence == UNINITIALIZED_SEQUENCE in" logOrThrow("mSequence == UNINITIALIZED_SEQUENCE in"
+ " SparseMappingTable.Table. mParent.mSequence=" + mParent.mSequence); + " SparseMappingTable.Table. -- "
+ dumpInternalState());
return;
} }
// Assert that our sequence number matches mParent's. If it isn't that means // Assert that our sequence number matches mParent's. If it isn't that means
// we have been reset and our // we have been reset and our
if (mSequence != mParent.mSequence) { if (mSequence != mParent.mSequence) {
if (mSequence < mParent.mSequence) { if (mSequence < mParent.mSequence) {
logOrThrow("Sequence mismatch. SparseMappingTable.resetTable()" logOrThrow("Sequence mismatch. SparseMappingTable.resetTable()"
+ " called but not Table.resetTable() -- " + " called but not Table.resetTable() -- "
+ dumpInternalState()); + dumpInternalState());
return;
} else if (mSequence > mParent.mSequence) { } else if (mSequence > mParent.mSequence) {
logOrThrow("Sequence mismatch. Table.resetTable()" logOrThrow("Sequence mismatch. Table.resetTable()"
+ " called but not SparseMappingTable.resetTable() -- " + " called but not SparseMappingTable.resetTable() -- "
+ dumpInternalState()); + dumpInternalState());
return;
} }
} }
} }
@@ -423,7 +427,7 @@ public class SparseMappingTable {
/** /**
* Check that all the keys are valid locations in the long arrays. * Check that all the keys are valid locations in the long arrays.
* *
* If any aren't, log it and return false. Else return true. * If any aren't, log it and return false. Else return true.
*/ */
private boolean validateKeys(boolean log) { private boolean validateKeys(boolean log) {
@@ -580,7 +584,7 @@ public class SparseMappingTable {
i++; i++;
} }
} }
/** /**
* Extract the id from a key. * Extract the id from a key.
*/ */
@@ -611,7 +615,7 @@ public class SparseMappingTable {
* this is a debug build.) * this is a debug build.)
*/ */
private static void logOrThrow(String message) { private static void logOrThrow(String message) {
logOrThrow(message, null); logOrThrow(message, new RuntimeException("Stack trace"));
} }
/** /**