| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 import os | 5 import os |
| 6 | 6 |
| 7 import cr | 7 import cr |
| 8 | 8 |
| 9 | 9 |
| 10 class GdbDebugger(cr.Debugger): | 10 class GdbDebugger(cr.Debugger): |
| 11 """An implementation of cr.Debugger that launches gdb.""" | 11 """An implementation of cr.Debugger that launches gdb.""" |
| 12 | 12 |
| 13 DETECTED = cr.Config('DETECTED') | 13 DETECTED = cr.Config('DETECTED') |
| 14 | 14 |
| 15 @property | 15 @property |
| 16 def enabled(self): | 16 def enabled(self): |
| 17 return (cr.LinuxPlatform.GetInstance().is_active and | 17 return (cr.LinuxPlatform.GetInstance().is_active and |
| 18 self.DETECTED.Find('CR_GDB')) | 18 self.DETECTED.Find('CR_GDB')) |
| 19 | 19 |
| 20 def Invoke(self, context, targets, arguments): | 20 def Invoke(self, targets, arguments): |
| 21 for target in targets: | 21 for target in targets: |
| 22 cr.Host.Execute( | 22 cr.Host.Execute( |
| 23 target, | 23 target, |
| 24 '{CR_GDB}', '--eval-command=run', '--args', | 24 '{CR_GDB}', '--eval-command=run', '--args', |
| 25 '{CR_BINARY}', | 25 '{CR_BINARY}', |
| 26 '{CR_RUN_ARGUMENTS}', | 26 '{CR_RUN_ARGUMENTS}', |
| 27 *arguments | 27 *arguments |
| 28 ) | 28 ) |
| 29 | 29 |
| 30 def Attach(self, context, targets, arguments): | 30 def Attach(self, targets, arguments): |
| 31 raise NotImplementedError('Attach not currently supported for gdb.') | 31 raise NotImplementedError('Attach not currently supported for gdb.') |
| 32 | 32 |
| 33 @classmethod | 33 @classmethod |
| 34 def ClassInit(cls): | 34 def ClassInit(cls): |
| 35 # Attempt to find a valid gdb on the path. | 35 # Attempt to find a valid gdb on the path. |
| 36 gdb_binaries = cr.Host.SearchPath('gdb') | 36 gdb_binaries = cr.Host.SearchPath('gdb') |
| 37 if gdb_binaries: | 37 if gdb_binaries: |
| 38 cls.DETECTED.Set(CR_GDB=gdb_binaries[0]) | 38 cls.DETECTED.Set(CR_GDB=gdb_binaries[0]) |
| 39 | 39 |
| OLD | NEW |