| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Provides an interface to communicate with the device via the adb command. | 5 """Provides an interface to communicate with the device via the adb command. |
| 6 | 6 |
| 7 Assumes adb binary is currently on system path. | 7 Assumes adb binary is currently on system path. |
| 8 """ | 8 """ |
| 9 # pylint: disable-all | 9 # pylint: disable-all |
| 10 | 10 |
| (...skipping 1620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1631 Shared_Dirty, Private_Clean, Private_Dirty, VmHWM. | 1631 Shared_Dirty, Private_Clean, Private_Dirty, VmHWM. |
| 1632 """ | 1632 """ |
| 1633 showmap = self.RunShellCommand('showmap %d' % pid) | 1633 showmap = self.RunShellCommand('showmap %d' % pid) |
| 1634 if not showmap or not showmap[-1].endswith('TOTAL'): | 1634 if not showmap or not showmap[-1].endswith('TOTAL'): |
| 1635 logging.warning('Invalid output for showmap %s', str(showmap)) | 1635 logging.warning('Invalid output for showmap %s', str(showmap)) |
| 1636 return {} | 1636 return {} |
| 1637 items = showmap[-1].split() | 1637 items = showmap[-1].split() |
| 1638 if len(items) != 9: | 1638 if len(items) != 9: |
| 1639 logging.warning('Invalid TOTAL for showmap %s', str(items)) | 1639 logging.warning('Invalid TOTAL for showmap %s', str(items)) |
| 1640 return {} | 1640 return {} |
| 1641 usage_dict = collections.defaultdict(int) | 1641 usage_dict = { |
| 1642 usage_dict.update({ | |
| 1643 'Size': int(items[0].strip()), | 1642 'Size': int(items[0].strip()), |
| 1644 'Rss': int(items[1].strip()), | 1643 'Rss': int(items[1].strip()), |
| 1645 'Pss': int(items[2].strip()), | 1644 'Pss': int(items[2].strip()), |
| 1646 'Shared_Clean': int(items[3].strip()), | 1645 'Shared_Clean': int(items[3].strip()), |
| 1647 'Shared_Dirty': int(items[4].strip()), | 1646 'Shared_Dirty': int(items[4].strip()), |
| 1648 'Private_Clean': int(items[5].strip()), | 1647 'Private_Clean': int(items[5].strip()), |
| 1649 'Private_Dirty': int(items[6].strip()), | 1648 'Private_Dirty': int(items[6].strip()), |
| 1650 }) | 1649 } |
| 1651 peak_value_kb = 0 | |
| 1652 for line in self.GetProtectedFileContents('/proc/%s/status' % pid): | 1650 for line in self.GetProtectedFileContents('/proc/%s/status' % pid): |
| 1653 if not line.startswith('VmHWM:'): # Format: 'VmHWM: +[0-9]+ kB' | 1651 if not line.startswith('VmHWM:'): # Format: 'VmHWM: +[0-9]+ kB' |
| 1654 continue | 1652 continue |
| 1655 peak_value_kb = int(line.split(':')[1].strip().split(' ')[0]) | 1653 usage_dict['VmHWM'] = int(line.split(':')[1].strip().split(' ')[0]) |
| 1656 break | 1654 break |
| 1657 usage_dict['VmHWM'] = peak_value_kb | 1655 else: |
| 1658 if not peak_value_kb: | |
| 1659 logging.warning('Could not find memory peak value for pid ' + str(pid)) | 1656 logging.warning('Could not find memory peak value for pid ' + str(pid)) |
| 1657 usage_dict['VmHWM'] = 0 |
| 1660 | 1658 |
| 1661 return usage_dict | 1659 return usage_dict |
| 1662 | 1660 |
| 1663 def ProcessesUsingDevicePort(self, device_port): | 1661 def ProcessesUsingDevicePort(self, device_port): |
| 1664 """Lists processes using the specified device port on loopback interface. | 1662 """Lists processes using the specified device port on loopback interface. |
| 1665 | 1663 |
| 1666 Args: | 1664 Args: |
| 1667 device_port: Port on device we want to check. | 1665 device_port: Port on device we want to check. |
| 1668 | 1666 |
| 1669 Returns: | 1667 Returns: |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1960 """ | 1958 """ |
| 1961 def __init__(self, output): | 1959 def __init__(self, output): |
| 1962 self._output = output | 1960 self._output = output |
| 1963 | 1961 |
| 1964 def write(self, data): | 1962 def write(self, data): |
| 1965 data = data.replace('\r\r\n', '\n') | 1963 data = data.replace('\r\r\n', '\n') |
| 1966 self._output.write(data) | 1964 self._output.write(data) |
| 1967 | 1965 |
| 1968 def flush(self): | 1966 def flush(self): |
| 1969 self._output.flush() | 1967 self._output.flush() |
| OLD | NEW |