brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.8 KiB · 0bac873 Raw
101 lines · python
1# DExTer : Debugging Experience Tester2# ~~~~~~   ~         ~~         ~   ~~3#4# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.5# See https://llvm.org/LICENSE.txt for license information.6# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception7 8from ctypes import *9from enum import *10from functools import partial11 12from .utils import *13 14 15class BreakpointTypes(IntEnum):16    DEBUG_BREAKPOINT_CODE = 017    DEBUG_BREAKPOINT_DATA = 118    DEBUG_BREAKPOINT_TIME = 219    DEBUG_BREAKPOINT_INLINE = 320 21 22class BreakpointFlags(IntFlag):23    DEBUG_BREAKPOINT_GO_ONLY = 0x0000000124    DEBUG_BREAKPOINT_DEFERRED = 0x0000000225    DEBUG_BREAKPOINT_ENABLED = 0x0000000426    DEBUG_BREAKPOINT_ADDER_ONLY = 0x0000000827    DEBUG_BREAKPOINT_ONE_SHOT = 0x0000001028 29 30DebugBreakpoint2IID = IID(31    0x1B278D20,32    0x79F2,33    0x426E,34    IID_Data4_Type(0xA3, 0xF9, 0xC1, 0xDD, 0xF3, 0x75, 0xD4, 0x8E),35)36 37 38class DebugBreakpoint2(Structure):39    pass40 41 42class DebugBreakpoint2Vtbl(Structure):43    wrp = partial(WINFUNCTYPE, c_long, POINTER(DebugBreakpoint2))44    idb_setoffset = wrp(c_ulonglong)45    idb_setflags = wrp(c_ulong)46    _fields_ = [47        ("QueryInterface", c_void_p),48        ("AddRef", c_void_p),49        ("Release", c_void_p),50        ("GetId", c_void_p),51        ("GetType", c_void_p),52        ("GetAdder", c_void_p),53        ("GetFlags", c_void_p),54        ("AddFlags", c_void_p),55        ("RemoveFlags", c_void_p),56        ("SetFlags", idb_setflags),57        ("GetOffset", c_void_p),58        ("SetOffset", idb_setoffset),59        ("GetDataParameters", c_void_p),60        ("SetDataParameters", c_void_p),61        ("GetPassCount", c_void_p),62        ("SetPassCount", c_void_p),63        ("GetCurrentPassCount", c_void_p),64        ("GetMatchThreadId", c_void_p),65        ("SetMatchThreadId", c_void_p),66        ("GetCommand", c_void_p),67        ("SetCommand", c_void_p),68        ("GetOffsetExpression", c_void_p),69        ("SetOffsetExpression", c_void_p),70        ("GetParameters", c_void_p),71        ("GetCommandWide", c_void_p),72        ("SetCommandWide", c_void_p),73        ("GetOffsetExpressionWide", c_void_p),74        ("SetOffsetExpressionWide", c_void_p),75    ]76 77 78DebugBreakpoint2._fields_ = [("lpVtbl", POINTER(DebugBreakpoint2Vtbl))]79 80 81class Breakpoint(object):82    def __init__(self, breakpoint):83        self.breakpoint = breakpoint.contents84        self.vt = self.breakpoint.lpVtbl.contents85 86    def SetFlags(self, flags):87        res = self.vt.SetFlags(self.breakpoint, flags)88        aborter(res, "Breakpoint SetFlags")89 90    def SetOffset(self, offs):91        res = self.vt.SetOffset(self.breakpoint, offs)92        aborter(res, "Breakpoint SetOffset")93 94    def RemoveFlags(self, flags):95        res = self.vt.RemoveFlags(self.breakpoint, flags)96        aborter(res, "Breakpoint RemoveFlags")97 98    def die(self):99        self.breakpoint = None100        self.vt = None101