aboutsummaryrefslogtreecommitdiffstats
path: root/ddms/libs/ddmlib
diff options
context:
space:
mode:
authorSiva Velusamy <vsiva@google.com>2011-10-06 09:35:33 -0700
committerSiva Velusamy <vsiva@google.com>2011-10-06 11:34:32 -0700
commited552915f84f9f6acb5c34f3b9e413d0b1534af3 (patch)
tree630f60f046506aba733f1fa41d04421a0b07c829 /ddms/libs/ddmlib
parent9a8de7350e1f8fb3a99c62c769e448d8e277f8fb (diff)
downloadsdk-ed552915f84f9f6acb5c34f3b9e413d0b1534af3.zip
sdk-ed552915f84f9f6acb5c34f3b9e413d0b1534af3.tar.gz
sdk-ed552915f84f9f6acb5c34f3b9e413d0b1534af3.tar.bz2
Add support for importing saved heap data.
Change-Id: I8552af1754f5093dcdb156f7f81e3beef776835a
Diffstat (limited to 'ddms/libs/ddmlib')
-rw-r--r--ddms/libs/ddmlib/src/com/android/ddmlib/NativeAllocationInfo.java66
1 files changed, 37 insertions, 29 deletions
diff --git a/ddms/libs/ddmlib/src/com/android/ddmlib/NativeAllocationInfo.java b/ddms/libs/ddmlib/src/com/android/ddmlib/NativeAllocationInfo.java
index 6730c8c..385ce0d 100644
--- a/ddms/libs/ddmlib/src/com/android/ddmlib/NativeAllocationInfo.java
+++ b/ddms/libs/ddmlib/src/com/android/ddmlib/NativeAllocationInfo.java
@@ -30,6 +30,13 @@ import java.util.regex.Pattern;
* storage for resolved stack trace, this is merely for convenience.
*/
public final class NativeAllocationInfo {
+ /* Keywords used as delimiters in the string representation of a NativeAllocationInfo */
+ public static final String END_STACKTRACE_KW = "EndStacktrace";
+ public static final String BEGIN_STACKTRACE_KW = "BeginStacktrace:";
+ public static final String TOTAL_SIZE_KW = "TotalSize:";
+ public static final String SIZE_KW = "Size:";
+ public static final String ALLOCATIONS_KW = "Allocations:";
+
/* constants for flag bits */
private static final int FLAG_ZYGOTE_CHILD = (1<<31);
private static final int FLAG_MASK = (FLAG_ZYGOTE_CHILD);
@@ -66,7 +73,7 @@ public final class NativeAllocationInfo {
* @param size The size of the allocations.
* @param allocations the allocation count
*/
- NativeAllocationInfo(int size, int allocations) {
+ public NativeAllocationInfo(int size, int allocations) {
this.mSize = size & ~FLAG_MASK;
this.mIsZygoteChild = ((size & FLAG_ZYGOTE_CHILD) != 0);
this.mAllocations = allocations;
@@ -76,7 +83,7 @@ public final class NativeAllocationInfo {
* Adds a stack call address for this allocation.
* @param address The address to add.
*/
- void addStackCallAddress(long address) {
+ public void addStackCallAddress(long address) {
mStackCallAddresses.add(address);
}
@@ -209,40 +216,41 @@ public final class NativeAllocationInfo {
@Override
public String toString() {
StringBuffer buffer = new StringBuffer();
- buffer.append("Allocations: ");
+ buffer.append(ALLOCATIONS_KW);
+ buffer.append(' ');
buffer.append(mAllocations);
- buffer.append("\n"); //$NON-NLS-1$
+ buffer.append('\n');
- buffer.append("Size: ");
+ buffer.append(SIZE_KW);
+ buffer.append(' ');
buffer.append(mSize);
- buffer.append("\n"); //$NON-NLS-1$
+ buffer.append('\n');
- buffer.append("Total Size: ");
+ buffer.append(TOTAL_SIZE_KW);
+ buffer.append(' ');
buffer.append(mSize * mAllocations);
- buffer.append("\n"); //$NON-NLS-1$
-
- Iterator<Long> addrIterator = mStackCallAddresses.iterator();
-
- if (mResolvedStackCall == null) {
- return buffer.toString();
- }
+ buffer.append('\n');
+
+ if (mResolvedStackCall != null) {
+ buffer.append(BEGIN_STACKTRACE_KW);
+ buffer.append('\n');
+ for (NativeStackCallInfo source : mResolvedStackCall) {
+ long addr = source.getAddress();
+ if (addr == 0) {
+ continue;
+ }
- Iterator<NativeStackCallInfo> sourceIterator = mResolvedStackCall.iterator();
-
- while (sourceIterator.hasNext()) {
- long addr = addrIterator.next();
- NativeStackCallInfo source = sourceIterator.next();
- if (addr == 0)
- continue;
-
- if (source.getLineNumber() != -1) {
- buffer.append(String.format("\t%1$08x\t%2$s --- %3$s --- %4$s:%5$d\n", addr,
- source.getLibraryName(), source.getMethodName(),
- source.getSourceFile(), source.getLineNumber()));
- } else {
- buffer.append(String.format("\t%1$08x\t%2$s --- %3$s --- %4$s\n", addr,
- source.getLibraryName(), source.getMethodName(), source.getSourceFile()));
+ if (source.getLineNumber() != -1) {
+ buffer.append(String.format("\t%1$08x\t%2$s --- %3$s --- %4$s:%5$d\n", addr,
+ source.getLibraryName(), source.getMethodName(),
+ source.getSourceFile(), source.getLineNumber()));
+ } else {
+ buffer.append(String.format("\t%1$08x\t%2$s --- %3$s --- %4$s\n", addr,
+ source.getLibraryName(), source.getMethodName(), source.getSourceFile()));
+ }
}
+ buffer.append(END_STACKTRACE_KW);
+ buffer.append('\n');
}
return buffer.toString();