ducky.errors module¶
-
exception
ducky.errors.AccessViolationError(message=None)[source]¶ Bases:
ducky.errors.ErrorRaised when an operation was requested without having adequate permission to do so.
messageattribute will provide better idea about the fault.
-
exception
ducky.errors.AssemblerError(location=None, message=None, line=None, info=None)[source]¶ Bases:
ducky.errors.ErrorBase class for all assembler-related exceptions. Provides common properties, helping to locate related input in the source file.
Parameters: - location (ducky.cpu.assembly.SourceLocation) – if set, points to the location in the source file that was processed when the exception occured.
- message (str) – more detailed description.
- line (str) – input source line.
- info – additional details of the exception. This value is usually part
of the
message, but is stored as well.
-
exception
ducky.errors.AssemblyIllegalCharError(c=None, **kwargs)[source]¶ Bases:
ducky.errors.AssemblerError
-
exception
ducky.errors.AssemblyParseError(token=None, **kwargs)[source]¶ Bases:
ducky.errors.AssemblerError
-
exception
ducky.errors.BadLinkerScriptError(script, exc, *args, **kwargs)[source]¶ Bases:
ducky.errors.LinkerError
-
exception
ducky.errors.ConflictingNamesError(**kwargs)[source]¶ Bases:
ducky.errors.AssemblerError
-
exception
ducky.errors.CoprocessorError(msg, *args, **kwargs)[source]¶ Bases:
ducky.errors.ExecutionException__SimpleESR,ducky.errors.ExecutionExceptionBase class for coprocessor errors. Raised when coprocessors needs to signal its own exception, when none of alread yavailable exceptions would do.
-
EXCEPTION_INDEX= 25¶
-
-
exception
ducky.errors.DisassembleMismatchError(**kwargs)[source]¶ Bases:
ducky.errors.AssemblerError
-
exception
ducky.errors.DivideByZeroError(*args, **kwargs)[source]¶ Bases:
ducky.errors.ExecutionException__SimpleESR,ducky.errors.ExecutionExceptionRaised when divisor in a mathematical operation was equal to zero.
-
EXCEPTION_INDEX= 18¶
-
-
exception
ducky.errors.EncodingLargeValueError(**kwargs)[source]¶ Bases:
ducky.errors.AssemblerError
-
exception
ducky.errors.Error(message=None)[source]¶ Bases:
exceptions.ExceptionBase class for all Ducky exceptions.
Parameters: message (str) – optional description.
-
class
ducky.errors.ExceptionList[source]¶ Bases:
enum.IntEnumList of exception IDs (
EVTindices).-
COUNT= 32¶
-
CoprocessorError= 25¶
-
DivideByZero= 18¶
-
DoubleFault= 21¶
-
FIRST_HW= 0¶
-
FIRST_SW= 16¶
-
InvalidException= 24¶
-
InvalidInstSet= 17¶
-
InvalidOpcode= 16¶
-
LAST_HW= 15¶
-
LAST_SW= 31¶
-
MemoryAccess= 22¶
-
PrivilegedInstr= 20¶
-
RegisterAccess= 23¶
-
UnalignedAccess= 19¶
-
_member_map_= OrderedDict([('FIRST_HW', <ExceptionList.FIRST_HW: 0>), ('LAST_HW', <ExceptionList.LAST_HW: 15>), ('InvalidOpcode', <ExceptionList.InvalidOpcode: 16>), ('FIRST_SW', <ExceptionList.InvalidOpcode: 16>), ('InvalidInstSet', <ExceptionList.InvalidInstSet: 17>), ('DivideByZero', <ExceptionList.DivideByZero: 18>), ('UnalignedAccess', <ExceptionList.UnalignedAccess: 19>), ('PrivilegedInstr', <ExceptionList.PrivilegedInstr: 20>), ('DoubleFault', <ExceptionList.DoubleFault: 21>), ('MemoryAccess', <ExceptionList.MemoryAccess: 22>), ('RegisterAccess', <ExceptionList.RegisterAccess: 23>), ('InvalidException', <ExceptionList.InvalidException: 24>), ('CoprocessorError', <ExceptionList.CoprocessorError: 25>), ('LAST_SW', <ExceptionList.LAST_SW: 31>), ('COUNT', <ExceptionList.COUNT: 32>)])¶
-
_member_names_= ['FIRST_HW', 'LAST_HW', 'InvalidOpcode', 'InvalidInstSet', 'DivideByZero', 'UnalignedAccess', 'PrivilegedInstr', 'DoubleFault', 'MemoryAccess', 'RegisterAccess', 'InvalidException', 'CoprocessorError', 'LAST_SW', 'COUNT']¶
-
_member_type_¶ alias of
int
-
_value2member_map_= {0: <ExceptionList.FIRST_HW: 0>, 32: <ExceptionList.COUNT: 32>, 15: <ExceptionList.LAST_HW: 15>, 16: <ExceptionList.InvalidOpcode: 16>, 17: <ExceptionList.InvalidInstSet: 17>, 18: <ExceptionList.DivideByZero: 18>, 19: <ExceptionList.UnalignedAccess: 19>, 20: <ExceptionList.PrivilegedInstr: 20>, 21: <ExceptionList.DoubleFault: 21>, 22: <ExceptionList.MemoryAccess: 22>, 23: <ExceptionList.RegisterAccess: 23>, 24: <ExceptionList.InvalidException: 24>, 25: <ExceptionList.CoprocessorError: 25>, 31: <ExceptionList.LAST_SW: 31>}¶
-
-
exception
ducky.errors.ExecutionException(msg, core=None, ip=None)[source]¶ Bases:
exceptions.ExceptionBase class for all execution-related exceptions, i.e. exceptions raised as a direct result of requests made by running code. Runnign code can then take care of handling these exceptions, usually by preparing service routines and setting up the
EVT.Unless said otherwise, the exception is always raised before making any changes in the VM state.
Parameters: - msg (string) – message describing exceptional state.
- core (ducky.cpu.CPUCore) – CPU core that raised exception, if any.
- ip (u32_t) – address of an instruction that caused exception, if any.
-
runtime_handle()[source]¶ This method is called by CPU code, to find out if it is possible for runtime to handle the exception, and possibly recover from it. If it is possible, this method should make necessary arrangements, and then return
True. Many exceptions, e.g. when division by zero was requested, will tell CPU to run exception service routine, and by returningTruesignal that it’s not necessary to take care of such exception anymore.Return type: bool Returns: Truewhen it’s no longer necessary for VM code to take care of this exception.
-
class
ducky.errors.ExecutionException__SimpleESR[source]¶ Bases:
objectHelper mixin class - as one of parents, it brings to its children very simle - and most of the time sufficient - implementation of runtime_handle method. Such exceptions will tell CPU to run exception service routine with a secific index, specified by class variable
EXCEPTION_INDEX.The address of the offensive instruction - or the value of
IPwhen exception was raised, since there may be exceptions not raised in response to the executed instruction - is passed to CPU as the first argument of ESR.
-
exception
ducky.errors.IncompatibleSectionFlagsError(dst_section, src_section, *args, **kwargs)[source]¶ Bases:
ducky.errors.LinkerError
-
exception
ducky.errors.IncompleteDirectiveError(**kwargs)[source]¶ Bases:
ducky.errors.AssemblerError
-
exception
ducky.errors.InvalidExceptionError(exc_index, *args, **kwargs)[source]¶ Bases:
ducky.errors.ExecutionException__SimpleESR,ducky.errors.ExecutionExceptionRaised when requested exception index is invalid (out of bounds).
-
EXCEPTION_INDEX= 24¶
-
-
exception
ducky.errors.InvalidFrameError(saved_sp, current_sp, *args, **kwargs)[source]¶ Bases:
ducky.errors.ExecutionException__SimpleESR,ducky.errors.ExecutionExceptionRaised when VM checks each call stack frame to be cleaned before it’s left, and there are some values on stack when
retorretintare executed. In such case, the actualSPvalues does not equal to a saved one, and exception is raised.Parameters: - saved_sp (u32_t) –
SPas saved at the moment the frame was created. - current_sp (u32_t) – current
SP
- saved_sp (u32_t) –
-
exception
ducky.errors.InvalidInstructionSetError(inst_set, *args, **kwargs)[source]¶ Bases:
ducky.errors.ExecutionException__SimpleESR,ducky.errors.ExecutionExceptionRaised when switch to unknown or invalid instruction set was requested.
Parameters: inst_set (int) – instruction set id. -
EXCEPTION_INDEX= 17¶
-
-
exception
ducky.errors.InvalidOpcodeError(opcode, *args, **kwargs)[source]¶ Bases:
ducky.errors.ExecutionException__SimpleESR,ducky.errors.ExecutionExceptionRaised when unknown or invalid opcode is found in instruction.
Parameters: opcode (int) – wrong opcode. -
EXCEPTION_INDEX= 16¶
-
-
exception
ducky.errors.InvalidResourceError(message=None)[source]¶ Bases:
ducky.errors.ErrorRaised when an operation was requested on somehow invalid resource.
messageattribute will provide better idea about the fault.
-
exception
ducky.errors.LinkerError(message=None)[source]¶ Bases:
ducky.errors.Error
-
exception
ducky.errors.MemoryAccessError(access, address, pte, *args, **kwargs)[source]¶ Bases:
ducky.errors.ExecutionException__SimpleESR,ducky.errors.ExecutionExceptionRaised when MMU decides the requested memory operation is now allowed, e.g. when page tables are enabled, and corresponding
PTEdenies write access.Parameters: - access (str) –
read,writeorexecute. - address (u32_t) – address where memory access shuld have happen.
- pte (ducky.mm.PageTableEntry) –
PTEguarding this particular memory location.
-
EXCEPTION_INDEX= 22¶
- access (str) –
-
exception
ducky.errors.OperandMismatchError(instr, expected, actual)[source]¶ Bases:
ducky.errors.Error
-
exception
ducky.errors.PatchTooLargeError(message=None)[source]¶ Bases:
ducky.errors.LinkerError
-
exception
ducky.errors.PrivilegedInstructionError(*args, **kwargs)[source]¶ Bases:
ducky.errors.ExecutionException__SimpleESR,ducky.errors.ExecutionExceptionRaised when privileged instruction was about to be executed in non-privileged mode.
-
EXCEPTION_INDEX= 20¶
-
-
exception
ducky.errors.RegisterAccessError(access, reg, *args, **kwargs)[source]¶ Bases:
ducky.errors.ExecutionException__SimpleESR,ducky.errors.ExecutionExceptionRaised when instruction tries to access a registerall which is not available for requested operation, e.g. writing into read-only control register will raise this exception.
Parameters: - access (str) –
readorwrite. - reg (str) – register name.
-
EXCEPTION_INDEX= 23¶
- access (str) –
-
exception
ducky.errors.TooManyLabelsError(**kwargs)[source]¶ Bases:
ducky.errors.AssemblerError
-
exception
ducky.errors.UnalignedAccessError(*args, **kwargs)[source]¶ Bases:
ducky.errors.ExecutionException__SimpleESR,ducky.errors.ExecutionExceptionRaised when only properly aligned memory access is allowed, and running code attempts to access memory without honoring this restriction (e.g.
LWreading from byte-aligned address).-
EXCEPTION_INDEX= 19¶
-
-
exception
ducky.errors.UnalignedJumpTargetError(**kwargs)[source]¶ Bases:
ducky.errors.AssemblerError
-
exception
ducky.errors.UnknownDestinationSectionError(src_section, *args, **kwargs)[source]¶ Bases:
ducky.errors.LinkerError
-
exception
ducky.errors.UnknownFileError(**kwargs)[source]¶ Bases:
ducky.errors.AssemblerError
-
exception
ducky.errors.UnknownInstructionError(**kwargs)[source]¶ Bases:
ducky.errors.AssemblerError
-
exception
ducky.errors.UnknownPatternError(**kwargs)[source]¶ Bases:
ducky.errors.AssemblerError
-
exception
ducky.errors.UnknownSymbolError(message=None)[source]¶ Bases:
ducky.errors.LinkerError