buffer.getInt() /* allocations */);
for (int j = 0 ; j < backtraceSize ; j++) {
- long addr = ((long)buffer.getInt()) & 0x00000000ffffffffL;
+ long addr = (buffer.getInt()) & 0x00000000ffffffffL;
info.addStackCallAddress(addr);;
}
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();
// 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);
}
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();
private static final int NUM_PALETTE_ENTRIES = HeapSegmentElement.KIND_NATIVE+2 +1;
private static final String[] mMapLegend = new String[NUM_PALETTE_ENTRIES];
private static final PaletteData mMapPalette = createPalette();
-
+
private static final int ALLOC_DISPLAY_ALL = 0;
private static final int ALLOC_DISPLAY_PRE_ZYGOTE = 1;
private static final int ALLOC_DISPLAY_POST_ZYGOTE = 2;
private Table mDetailTable;
private Label mImage;
-
+
private int mAllocDisplayMode = ALLOC_DISPLAY_ALL;
/**
/** list of NativeAllocationInfo objects filled with the list from ClientData */
private final ArrayList<NativeAllocationInfo> mAllocations =
new ArrayList<NativeAllocationInfo>();
-
+
/** list of the {@link NativeAllocationInfo} being displayed based on the selection
* of {@link #mAllocDisplayCombo}.
*/
if (info.isStackCallResolved() == false) {
final Long[] list = info.getStackCallAddresses();
final int size = list.length;
-
+
ArrayList<NativeStackCallInfo> resolvedStackCall =
- new ArrayList<NativeStackCallInfo>();
+ new ArrayList<NativeStackCallInfo>();
for (int i = 0; i < size; i++) {
long addr = list[i];
resolvedStackCall.add(source);
}
-
+
info.setResolvedStackCall(resolvedStackCall);
}
// after every DISPLAY_PER_PAGE we ask for a ui refresh, unless
gl.verticalSpacing = 0;
mBase.setLayout(gl);
mBase.setLayoutData(new GridData(GridData.FILL_BOTH));
-
+
// composite for <update btn> <status>
Composite tmp = new Composite(mBase, SWT.NONE);
tmp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Composite top_layout = new Composite(mBase, SWT.NONE);
top_layout.setLayout(gl = new GridLayout(4, false));
gl.marginWidth = gl.marginHeight = 0;
-
+
new Label(top_layout, SWT.NONE).setText("Show:");
-
+
mAllocDisplayCombo = new Combo(top_layout, SWT.DROP_DOWN | SWT.READ_ONLY);
mAllocDisplayCombo.setLayoutData(new GridData(
GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL));
}
});
mAllocDisplayCombo.select(0);
-
+
// separator
Label separator = new Label(top_layout, SWT.SEPARATOR | SWT.VERTICAL);
GridData gd;
}
}
});
-
+
/*
* TODO: either fix the diff mechanism or remove it altogether.
mDiffUpdateButton = new Button(top_layout, SWT.NONE);
}
});
mDisplayModeCombo.setEnabled(false);
-
+
mSymbolsButton = new Button(top_layout, SWT.PUSH);
mSymbolsButton.setText("Load Symbols");
mSymbolsButton.setEnabled(false);
return mBase;
}
-
+
/**
* Sets the focus to the proper control inside the panel.
*/
// we're done: do something
mDisplayModeCombo.setEnabled(true);
mSaveButton.setEnabled(true);
-
+
mStackCallThread = null;
} else {
// work in progress, update the progress bar.
// get the current selection of the allocation
int index = mAllocationTable.getSelectionIndex();
NativeAllocationInfo info = null;
-
+
if (index != -1) {
info = (NativeAllocationInfo)mAllocationTable.getItem(index).getData();
}
addTableToFocusListener(mLibraryAllocationTable);
addTableToFocusListener(mDetailTable);
}
-
+
protected void onAllocDisplayChange() {
mAllocDisplayMode = mAllocDisplayCombo.getSelectionIndex();
-
+
// create the new list
updateAllocDisplayList();
-
+
updateTotalMemoryDisplay();
// reset the ui.
updatePageUI();
switchDisplayMode();
}
-
+
private void updateAllocDisplayList() {
mTotalSize = 0;
mDisplayedAllocations.clear();
continue;
}
}
-
+
int count = mDisplayedAllocations.size();
-
+
mPageCount = count / DISPLAY_PER_PAGE;
// need to add a page for the rest of the div
mPageCount++;
}
}
-
+
private void updateTotalMemoryDisplay() {
switch (mAllocDisplayMode) {
case ALLOC_DISPLAY_ALL:
}
private void initAllocationDisplay() {
+ if (mStackCallThread != null) {
+ mStackCallThread.quit();
+ }
+
mAllocations.clear();
mAllocations.addAll(mClientData.getNativeAllocationList());
-
+
updateAllocDisplayList();
// if we have a previous clientdata and it matches the current one. we
private void fillDetailTable(final NativeAllocationInfo mi) {
mDetailTable.removeAll();
mDetailTable.setRedraw(false);
-
+
try {
// populate the detail Table with the back trace
Long[] addresses = mi.getStackCallAddresses();
NativeStackCallInfo[] resolvedStackCall = mi.getResolvedStackCall();
-
+
if (resolvedStackCall == null) {
return;
}
if (addresses[i] == null || addresses[i].longValue() == 0) {
continue;
}
-
+
long addr = addresses[i].longValue();
NativeStackCallInfo source = resolvedStackCall[i];
-
+
TableItem item = new TableItem(mDetailTable, SWT.NONE);
item.setText(0, String.format("%08x", addr)); //$NON-NLS-1$
-
+
String libraryName = source.getLibraryName();
String methodName = source.getMethodName();
String sourceFile = source.getSourceFile();
int lineNumber = source.getLineNumber();
-
+
if (libraryName != null)
item.setText(1, libraryName);
if (methodName != null)
public void widgetSelected(SelectionEvent e) {
// get the selection index
int index = mAllocationTable.getSelectionIndex();
- TableItem item = mAllocationTable.getItem(index);
- if (item != null && item.getData() instanceof NativeAllocationInfo) {
- fillDetailTable((NativeAllocationInfo)item.getData());
+ if (index >= 0 && index < mAllocationTable.getItemCount()) {
+ TableItem item = mAllocationTable.getItem(index);
+ if (item != null && item.getData() instanceof NativeAllocationInfo) {
+ fillDetailTable((NativeAllocationInfo)item.getData());
+ }
}
}
});
// get the index in the library allocation table
int index2 = mLibraryAllocationTable.getSelectionIndex();
// get the MallocInfo object
- LibraryAllocations liballoc = mLibraryAllocations.get(index1);
- NativeAllocationInfo info = liballoc.getAllocation(index2);
- fillDetailTable(info);
+ if (index1 != -1 && index2 != -1) {
+ LibraryAllocations liballoc = mLibraryAllocations.get(index1);
+ NativeAllocationInfo info = liballoc.getAllocation(index2);
+ fillDetailTable(info);
+ }
}
});
private void sortAllocationsPerLibrary() {
if (mClientData != null) {
mLibraryAllocations.clear();
-
+
// create a hash map of LibraryAllocations to access aggregate
// objects already created
HashMap<String, LibraryAllocations> libcache =
return new PaletteData(colors);
}
-
+
private void saveAllocations(String fileName) {
try {
PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(fileName)));
-
+
for (NativeAllocationInfo alloc : mAllocations) {
out.println(alloc.toString());
}