| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 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 """ | 5 """ |
| 6 Manages a debugging session with GDB. | 6 Manages a debugging session with GDB. |
| 7 | 7 |
| 8 This module is meant to be imported from inside GDB. Once loaded, the | 8 This module is meant to be imported from inside GDB. Once loaded, the |
| 9 |DebugSession| attaches GDB to a running Mojo Shell process on an Android | 9 |DebugSession| attaches GDB to a running Mojo Shell process on an Android |
| 10 device using a remote gdbserver. | 10 device using a remote gdbserver. |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 self._package_name = package_name | 80 self._package_name = package_name |
| 81 self._adb = adb | 81 self._adb = adb |
| 82 self._remote_file_cache = os.path.join(os.getenv('HOME'), '.mojosymbols') | 82 self._remote_file_cache = os.path.join(os.getenv('HOME'), '.mojosymbols') |
| 83 | 83 |
| 84 if pyelftools_dir != None: | 84 if pyelftools_dir != None: |
| 85 sys.path.append(pyelftools_dir) | 85 sys.path.append(pyelftools_dir) |
| 86 try: | 86 try: |
| 87 import elftools.elf.elffile as elffile | 87 import elftools.elf.elffile as elffile |
| 88 except ImportError: | 88 except ImportError: |
| 89 logging.fatal("Unable to find elftools module; please install it " | 89 logging.fatal("Unable to find elftools module; please install it " |
| 90 "(for exmple, using 'pip install elftools')") | 90 "(for example, using 'pip install pyelftools')") |
| 91 sys.exit(1) | 91 sys.exit(1) |
| 92 | 92 |
| 93 self._elffile_module = elffile | 93 self._elffile_module = elffile |
| 94 | 94 |
| 95 self._libraries = self._find_libraries(build_directory) | 95 self._libraries = self._find_libraries(build_directory) |
| 96 self._rfc = RemoteFileConnection('localhost', 10000) | 96 self._rfc = RemoteFileConnection('localhost', 10000) |
| 97 self._remote_file_reader_process = None | 97 self._remote_file_reader_process = None |
| 98 if not os.path.exists(self._remote_file_cache): | 98 if not os.path.exists(self._remote_file_cache): |
| 99 os.makedirs(self._remote_file_cache) | 99 os.makedirs(self._remote_file_cache) |
| 100 self._done_mapping = set() | 100 self._done_mapping = set() |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 subprocess.check_call([self._adb, 'forward', 'tcp:10000', 'tcp:%d' % port]) | 264 subprocess.check_call([self._adb, 'forward', 'tcp:10000', 'tcp:%d' % port]) |
| 265 self._rfc.connect() | 265 self._rfc.connect() |
| 266 | 266 |
| 267 _gdb_execute('target remote localhost:9999') | 267 _gdb_execute('target remote localhost:9999') |
| 268 | 268 |
| 269 self._update_symbols() | 269 self._update_symbols() |
| 270 def on_stop(_): | 270 def on_stop(_): |
| 271 self._update_symbols() | 271 self._update_symbols() |
| 272 gdb.events.stop.connect(on_stop) | 272 gdb.events.stop.connect(on_stop) |
| 273 gdb.events.exited.connect(self.stop) | 273 gdb.events.exited.connect(self.stop) |
| OLD | NEW |