aboutsummaryrefslogtreecommitdiffstats
path: root/ddms/libs/ddmlib/src
diff options
context:
space:
mode:
authorXavier Ducrohet <xav@android.com>2011-07-18 15:54:39 -0700
committerXavier Ducrohet <xav@android.com>2011-07-18 15:56:45 -0700
commit7b04a527715099f7e584ff1e8650a0180b17bc94 (patch)
tree16b836c39b006815ed8eb5e21047fb5a8659c40c /ddms/libs/ddmlib/src
parent51b0ee115616811e9e3a1d296732917c00e1ea5b (diff)
downloadsdk-7b04a527715099f7e584ff1e8650a0180b17bc94.zip
sdk-7b04a527715099f7e584ff1e8650a0180b17bc94.tar.gz
sdk-7b04a527715099f7e584ff1e8650a0180b17bc94.tar.bz2
Various fixes to the DDMS Native heap panel.
Change-Id: I468be358b937f63adca3528fb66aa5d70e2e6827
Diffstat (limited to 'ddms/libs/ddmlib/src')
-rw-r--r--ddms/libs/ddmlib/src/com/android/ddmlib/AndroidDebugBridge.java1
-rw-r--r--ddms/libs/ddmlib/src/com/android/ddmlib/HandleNativeHeap.java53
-rw-r--r--ddms/libs/ddmlib/src/com/android/ddmlib/NativeAllocationInfo.java10
3 files changed, 31 insertions, 33 deletions
diff --git a/ddms/libs/ddmlib/src/com/android/ddmlib/AndroidDebugBridge.java b/ddms/libs/ddmlib/src/com/android/ddmlib/AndroidDebugBridge.java
index f697cba..253f41f 100644
--- a/ddms/libs/ddmlib/src/com/android/ddmlib/AndroidDebugBridge.java
+++ b/ddms/libs/ddmlib/src/com/android/ddmlib/AndroidDebugBridge.java
@@ -195,6 +195,7 @@ public final class AndroidDebugBridge {
HandleHeap.register(monitorThread);
HandleWait.register(monitorThread);
HandleProfiling.register(monitorThread);
+ HandleNativeHeap.register(monitorThread);
}
/**
diff --git a/ddms/libs/ddmlib/src/com/android/ddmlib/HandleNativeHeap.java b/ddms/libs/ddmlib/src/com/android/ddmlib/HandleNativeHeap.java
index 2b91b1e..8482863 100644
--- a/ddms/libs/ddmlib/src/com/android/ddmlib/HandleNativeHeap.java
+++ b/ddms/libs/ddmlib/src/com/android/ddmlib/HandleNativeHeap.java
@@ -171,7 +171,7 @@ final class HandleNativeHeap extends ChunkHandler {
buffer.getInt() /* allocations */);
for (int j = 0 ; j < backtraceSize ; j++) {
- long addr = ((long)buffer.getInt()) & 0x00000000ffffffffL;
+ long addr = (buffer.getInt()) & 0x00000000ffffffffL;
info.addStackCallAddress(addr);;
}
@@ -203,8 +203,8 @@ final class HandleNativeHeap extends ChunkHandler {
buffer.order(ByteOrder.BIG_ENDIAN);
int id = buffer.getInt();
- int unitsize = (int) buffer.get();
- long startAddress = (long) buffer.getInt() & 0x00000000ffffffffL;
+ int unitsize = buffer.get();
+ long startAddress = buffer.getInt() & 0x00000000ffffffffL;
int offset = buffer.getInt();
int allocationUnitCount = buffer.getInt();
@@ -218,8 +218,8 @@ final class HandleNativeHeap extends ChunkHandler {
// read the usage
while (buffer.position() < buffer.limit()) {
- int eState = (int)buffer.get() & 0x000000ff;
- int eLen = ((int)buffer.get() & 0x000000ff) + 1;
+ int eState = buffer.get() & 0x000000ff;
+ int eLen = (buffer.get() & 0x000000ff) + 1;
//Log.e("ddm-nativeheap", "solidity: " + (eState & 0x7) + " - kind: "
// + ((eState >> 3) & 0x7) + " - len: " + eLen);
}
@@ -254,36 +254,29 @@ final class HandleNativeHeap extends ChunkHandler {
long tmpStart = Long.parseLong(line.substring(0, 8), 16);
long tmpEnd = Long.parseLong(line.substring(9, 17), 16);
- /*
- * only check for library addresses as defined in
- * //device/config/prelink-linux-arm.map
- */
- if (tmpStart >= 0x0000000080000000L && tmpStart <= 0x00000000BFFFFFFFL) {
+ int index = line.indexOf('/');
- int index = line.indexOf('/');
+ if (index == -1)
+ continue;
- if (index == -1)
- continue;
+ String tmpLib = line.substring(index);
- String tmpLib = line.substring(index);
+ if (library == null ||
+ (library != null && tmpLib.equals(library) == false)) {
- if (library == null ||
- (library != null && tmpLib.equals(library) == false)) {
-
- if (library != null) {
- cd.addNativeLibraryMapInfo(startAddr, endAddr, library);
- Log.d("ddms", library + "(" + Long.toHexString(startAddr) +
- " - " + Long.toHexString(endAddr) + ")");
- }
-
- // now init the new library
- library = tmpLib;
- startAddr = tmpStart;
- endAddr = tmpEnd;
- } else {
- // add the new end
- endAddr = tmpEnd;
+ if (library != null) {
+ cd.addNativeLibraryMapInfo(startAddr, endAddr, library);
+ Log.d("ddms", library + "(" + Long.toHexString(startAddr) +
+ " - " + Long.toHexString(endAddr) + ")");
}
+
+ // now init the new library
+ library = tmpLib;
+ startAddr = tmpStart;
+ endAddr = tmpEnd;
+ } else {
+ // add the new end
+ endAddr = tmpEnd;
}
} catch (NumberFormatException e) {
e.printStackTrace();
diff --git a/ddms/libs/ddmlib/src/com/android/ddmlib/NativeAllocationInfo.java b/ddms/libs/ddmlib/src/com/android/ddmlib/NativeAllocationInfo.java
index 41d63b2..9909b9a 100644
--- a/ddms/libs/ddmlib/src/com/android/ddmlib/NativeAllocationInfo.java
+++ b/ddms/libs/ddmlib/src/com/android/ddmlib/NativeAllocationInfo.java
@@ -51,6 +51,8 @@ public final class NativeAllocationInfo {
sAllocFunctionFilter.add("chk_memalign"); //$NON-NLS-1$
sAllocFunctionFilter.add("Malloc"); //$NON-NLS-1$
sAllocFunctionFilter.add("leak_memalign"); //$NON-NLS-1$
+ sAllocFunctionFilter.add("strcmp"); //$NON-NLS-1$
+ sAllocFunctionFilter.add("dlrealloc"); //$NON-NLS-1$
}
private final int mSize;
@@ -247,7 +249,7 @@ public final class NativeAllocationInfo {
long addr = addrIterator.next();
NativeStackCallInfo info = sourceIterator.next();
if (addr != 0 && info != null) {
- if (isRelevant(info.getMethodName())) {
+ if (isRelevant(info.getMethodName(), addr)) {
return info;
}
}
@@ -265,14 +267,16 @@ public final class NativeAllocationInfo {
/**
* Returns true if the method name is relevant.
* @param methodName the method name to test.
+ * @param addr the original address. This is used because sometimes the name of the method is
+ * the address itself which is not relevant
*/
- private boolean isRelevant(String methodName) {
+ private boolean isRelevant(String methodName, long addr) {
for (String filter : sAllocFunctionFilter) {
if (methodName.contains(filter)) {
return false;
}
}
- return true;
+ return methodName.equals(Long.toString(addr, 16)) == false;
}
}