Mate Toth-Pal | a8797e1 | 2020-06-05 21:14:26 +0200 | [diff] [blame^] | 1 | #-------------------------------------------------------------------------------
|
| 2 | # Copyright (c) 2020, Arm Limited. All rights reserved.
|
| 3 | #
|
| 4 | # SPDX-License-Identifier: BSD-3-Clause
|
| 5 | #
|
| 6 | #-------------------------------------------------------------------------------
|
| 7 |
|
| 8 | """Defines the interface that a debugger control class have to implement
|
| 9 | """
|
| 10 |
|
| 11 | class Location(object):
|
| 12 | """A helper class to store the properties of a location where breakpoint
|
| 13 | can be put
|
| 14 | """
|
| 15 | def __init__(self, symbol=None, offset=0, filename=None, line=None):
|
| 16 | self.symbol = symbol
|
| 17 | self.offset = offset
|
| 18 | self.filename = filename
|
| 19 | self.line = line
|
| 20 |
|
| 21 | def __str__(self):
|
| 22 | ret = ""
|
| 23 | if self.symbol:
|
| 24 | ret += str(self.symbol)
|
| 25 |
|
| 26 | if self.offset:
|
| 27 | ret += "+" + str(self.offset)
|
| 28 |
|
| 29 | if self.filename:
|
| 30 | if self.symbol:
|
| 31 | ret += " @ "
|
| 32 | ret += str(self.filename) + ":" + str(self.line)
|
| 33 |
|
| 34 | return ret
|
| 35 |
|
| 36 | def __unicode__(self):
|
| 37 | return str(self), "utf-8"
|
| 38 |
|
| 39 | class AbstractDebugger(object):
|
| 40 | """The interface that a debugger control class have to implement
|
| 41 | """
|
| 42 | def __init__(self):
|
| 43 | pass
|
| 44 |
|
| 45 | def set_breakpoint(self, name, location):
|
| 46 | """Put a breakpoint at a location
|
| 47 |
|
| 48 | Args:
|
| 49 | name: The name of the location. This name is returned by
|
| 50 | get_triggered_breakpoint
|
| 51 | location: An instance of a Location class
|
| 52 | """
|
| 53 | raise NotImplementedError('subclasses must override set_breakpoint()!')
|
| 54 |
|
| 55 | def trigger_interrupt(self, interrupt_line):
|
| 56 | """trigger an interrupt on the interrupt line specified in the parameter
|
| 57 |
|
| 58 | Args:
|
| 59 | interrupt_line: The number of the interrupt line
|
| 60 | """
|
| 61 | raise NotImplementedError('subclasses must override trigger_interrupt()!')
|
| 62 |
|
| 63 | def continue_execution(self):
|
| 64 | """Continue the execution
|
| 65 | """
|
| 66 | raise NotImplementedError('subclasses must override continue_execution()!')
|
| 67 |
|
| 68 | def clear_breakpoints(self):
|
| 69 | """Clear all breakpoints
|
| 70 | """
|
| 71 | raise NotImplementedError('subclasses must override clear_breakpoints()!')
|
| 72 |
|
| 73 | def get_triggered_breakpoint(self):
|
| 74 | """Get the name of the last triggered breakpoint
|
| 75 | """
|
| 76 | raise NotImplementedError('subclasses must override get_triggered_breakpoint()!')
|