Exemplo n.º 1
0
 public ClientDataInfo(Client client) {
   this.clientData = client.getClientData();
   this.client = client;
   this.name = name();
   this.pid = clientData.getPid();
   this.port = port();
 }
Exemplo n.º 2
0
  /**
   * Sent when a new client is selected. The new client can be accessed with {@link
   * #getCurrentClient()}.
   */
  @Override
  public void clientSelected() {
    if (mTop.isDisposed()) return;

    Client client = getCurrentClient();

    Log.d("ddms", "HeapPanel: changed " + client);

    if (client != null) {
      ClientData cd = client.getClientData();

      if (client.isHeapUpdateEnabled()) {
        mGcButton.setEnabled(true);
        mDisplayMode.setEnabled(true);
        setUpdateStatus(ENABLED);
      } else {
        setUpdateStatus(NOT_ENABLED);
        mGcButton.setEnabled(false);
        mDisplayMode.setEnabled(false);
      }

      fillSummaryTable(cd);

      int mode = mDisplayMode.getSelectionIndex();
      if (mode == 0) {
        fillDetailedTable(client, false /* forceRedraw */);
      } else {
        if (DISPLAY_HEAP_BITMAP) {
          renderHeapData(cd, mode - 1, false /* forceRedraw */);
        }
      }
    } else {
      mGcButton.setEnabled(false);
      mDisplayMode.setEnabled(false);
      fillSummaryTable(null);
      fillDetailedTable(null, true);
      setUpdateStatus(NOT_SELECTED);
    }

    // sizes of things change frequently, so redo layout
    // mScrolledComposite.setMinSize(mDisplayStack.topControl.computeSize(SWT.DEFAULT,
    //        SWT.DEFAULT));
    mDisplayBase.layout();
    // mScrolledComposite.redraw();
  }
Exemplo n.º 3
0
  private void fillDetailedTable(Client client, boolean forceRedraw) {
    // first check if the client is invalid or heap updates are not enabled.
    if (client == null || client.isHeapUpdateEnabled() == false) {
      mStatisticsTable.removeAll();
      showChart(null);
      return;
    }

    ClientData cd = client.getClientData();

    Map<Integer, ArrayList<HeapSegmentElement>> heapMap;

    // Atomically get and clear the heap data.
    synchronized (cd) {
      if (serializeHeapData(cd.getVmHeapData()) == false && forceRedraw == false) {
        // no change, we return.
        return;
      }

      heapMap = cd.getVmHeapData().getProcessedHeapMap();
    }

    // we have new data, lets display it.

    // First, get the current selection, and its key.
    int index = mStatisticsTable.getSelectionIndex();
    Integer selectedKey = null;
    if (index != -1) {
      selectedKey = (Integer) mStatisticsTable.getItem(index).getData();
    }

    // disable redraws and remove all from the table.
    mStatisticsTable.setRedraw(false);
    mStatisticsTable.removeAll();

    if (heapMap != null) {
      int selectedIndex = -1;
      ArrayList<HeapSegmentElement> selectedList = null;

      // get the keys
      Set<Integer> keys = heapMap.keySet();
      int iter = 0; // use a manual iter int because Set<?> doesn't have an index
      // based accessor.
      for (Integer key : keys) {
        ArrayList<HeapSegmentElement> list = heapMap.get(key);

        // check if this is the key that is supposed to be selected
        if (key.equals(selectedKey)) {
          selectedIndex = iter;
          selectedList = list;
        }
        iter++;

        TableItem item = new TableItem(mStatisticsTable, SWT.NONE);
        item.setData(key);

        // get the type
        item.setText(0, mMapLegend[key]);

        // set the count, smallest, largest
        int count = list.size();
        item.setText(1, addCommasToNumber(count));

        if (count > 0) {
          item.setText(3, prettyByteCount(list.get(0).getLength()));
          item.setText(4, prettyByteCount(list.get(count - 1).getLength()));

          int median = count / 2;
          HeapSegmentElement element = list.get(median);
          long size = element.getLength();
          item.setText(5, prettyByteCount(size));

          long totalSize = 0;
          for (int i = 0; i < count; i++) {
            element = list.get(i);

            size = element.getLength();
            totalSize += size;
          }

          // set the average and total
          item.setText(2, prettyByteCount(totalSize));
          item.setText(6, prettyByteCount(totalSize / count));
        }
      }

      mStatisticsTable.setRedraw(true);

      if (selectedIndex != -1) {
        mStatisticsTable.setSelection(selectedIndex);
        showChart(selectedList);
      } else {
        showChart(null);
      }
    } else {
      mStatisticsTable.setRedraw(true);
    }
  }
Exemplo n.º 4
0
 protected Integer port() {
   int port = client.getDebuggerListenPort();
   return port;
 }