Beispiel #1
0
def __lldb_init_module(debugger: lldb.SBDebugger, internal_dict: Dict) -> None:
    debugger.HandleCommand(
        'type summary add -x "^libtorrent::digest32<.+>$" -F ' +
        "libtorrent_lldb.print_hash -p -w libtorrent")
    debugger.HandleCommand(
        'type summary add -x "^libtorrent::sha256_hash$" -F ' +
        "libtorrent_lldb.print_hash -p -w libtorrent")
    debugger.HandleCommand(
        'type summary add -x "^libtorrent::sha1_hash$" -F ' +
        "libtorrent_lldb.print_hash -p -w libtorrent")
    debugger.HandleCommand('type summary add -x "^libtorrent::span<.+>$" -F ' +
                           "libtorrent_lldb.print_span -p -w libtorrent")
    debugger.HandleCommand(
        'type summary add -x "^libtorrent::flags::bitfield_flag<.+>$" -F ' +
        "libtorrent_lldb.print_flag -p -w libtorrent")
    debugger.HandleCommand(
        'type summary add -x "^boost::asio::ip::basic_endpoint<.+>$" -F ' +
        "libtorrent_lldb.print_endpoint -p -w libtorrent")
    debugger.HandleCommand('type summary add -x "^libtorrent::bitfield$" -F ' +
                           "libtorrent_lldb.print_bitfield -p -w libtorrent")
    debugger.HandleCommand(
        'type summary add -x "^libtorrent::typed_bitfield<.+>$" -F ' +
        "libtorrent_lldb.print_bitfield -p -w libtorrent")
    debugger.HandleCommand(
        'type summary add -x "^libtorrent::aux::strong_typedef<.+>$" -F ' +
        "libtorrent_lldb.print_strong_type -p -w libtorrent")
    debugger.HandleCommand("type category enable libtorrent")
Beispiel #2
0
def initialize_category(debugger: lldb.SBDebugger):
    global module, boltzmann_solver_category

    boltzmann_solver_category = debugger.CreateCategory("BoltzmannSolver")
    boltzmann_solver_category.SetEnabled(True)

    attach_synthetic_to_type(ArrayBaseSynthProvider,
                             r"^ndarray::ArrayBase<.+,.+>$", True)
    attach_summary_to_type(particle_summary_provider,
                           "boltzmann_solver::model::particle::Particle")
Beispiel #3
0
def init(debugger: lldb.SBDebugger, command: str, _3, _4):
    """Entry point."""
    server_address = command
    thrd = threading.Thread(target=_server,
                            args=(server_address, debugger.GetID()))
    # try:
    #     v: str = debugger.GetVersionString()
    #     version = int(v[13:15])
    #     if version > 11:
    #         ci = debugger.GetCommandInterpreter()
    #         ro = lldb.SBCommandReturnObject()
    #         ci.HandleCommand("target stop-hook add -P lldb_commands.NvimGDBStopHook", ro)
    # except Exception as _:
    #     pass
    thrd.start()
Beispiel #4
0
def breakpoint_write(debugger: lldb.SBDebugger, command: str, result, internal_dict):
    bpFilePathName = command
    if bpFilePathName is None or bpFilePathName == '':
        print('Error: need argument to determine the breakpoint file.')
        return
    elif bpFilePathName.count('"') > 0:
        bpFilePathName = bpFilePathName.replace('"', '')

    # serialize the breakpoint first
    res: lldb.SBCommandReturnObject = lldb.SBCommandReturnObject()
    cmd = 'breakpoint write -f %s' % ('"' + bpFilePathName + '"')
    lldb.debugger.GetCommandInterpreter().HandleCommand(cmd, res)  # breakpoint write failed, return
    if not res.Succeeded():
        print(res.GetError())
        return

    # then get the extra data for fix
    target: lldb.SBTarget = debugger.GetSelectedTarget()

    bpFixDataList = []
    bpFixData = {}
    for m in target.breakpoint_iter():
        brkLoct: lldb.SBBreakpointLocation = m.location[0]
        if brkLoct is None:
            bpFixDataList.append(None)
            continue

        sbAddr: lldb.SBAddress = brkLoct.GetAddress()
        bpFixData['offset'] = sbAddr.offset + sbAddr.GetSection().GetFileOffset()
        sbModule: lldb.SBModule = sbAddr.GetModule()
        bpFixData['moudleName'] = sbModule.GetFileSpec().GetFilename()

        # print("offset: %s, module: %s" % (bpFixData['offset'], sbModule.GetFileSpec().GetFilename()))

        bpFixDataList.append(copy.deepcopy(bpFixData))

    if len(bpFixDataList) == 0:
        print('Breakpoint list is empty, nothing to save.')
        return

    fixBpFile(bpFixDataList, bpFilePathName)
Beispiel #5
0
def _enum_breaks(debugger: lldb.SBDebugger):
    # Ensure target is the actually selected one
    target = debugger.GetSelectedTarget()

    # Consider every breakpoint while skipping over the disabled ones
    for bidx in range(target.GetNumBreakpoints()):
        bpt = target.GetBreakpointAtIndex(bidx)
        if not bpt.IsEnabled():
            continue
        bid = str(bpt.GetID())

        # Consider every location of a breakpoint
        for lidx in range(bpt.GetNumLocations()):
            loc = bpt.GetLocationAtIndex(lidx)
            lineentry = loc.GetAddress().GetLineEntry()
            filespec = lineentry.GetFileSpec()
            filename = filespec.GetFilename()
            if not filename:
                continue
            path = os.path.join(filespec.GetDirectory(), filename)

            yield path, lineentry.GetLine(), bid
Beispiel #6
0
    def __init__(self, debugger: lldb.SBDebugger):
        self.logger = logging.getLogger(__name__)
        self.endianness = '<'
        self.debugger = debugger
        self.target = debugger.GetSelectedTarget()
        self.process = self.target.GetProcess()
        self.symbols = SymbolsJar.create(self)
        self.breakpoints = {}
        self.captured_objects = {}
        self.registers = Registers(self)

        self._dynamic_env_loaded = False
        self._symbols_loaded = False

        # the frame called within the context of the hit BP
        self._bp_frame = None

        self._add_global('symbols', self.symbols, [])
        self._add_global('registers', self.registers, [])

        self.log_info(f'Target: {self.target}')
        self.log_info(f'Process: {self.process}')
Beispiel #7
0
def init_serverside(debugger: lldb.SBDebugger):
    debugger_id = debugger.GetID()
    python_thread = threading.Thread(target=serve, args=(debugger_id, ))
    python_thread.start()
Beispiel #8
0
def init(debugger: lldb.SBDebugger, command: str, _3, _4):
    """Entry point."""
    server_address = command
    thrd = threading.Thread(target=_server, args=(server_address, debugger.GetID()))
    thrd.start()
Beispiel #9
0
def set_remote_path(debugger: lldb.SBDebugger, command, result, internal_dict):
    device_app = command
    error = lldb.SBError()
    debugger.GetSelectedTarget().modules[0].SetPlatformFileSpec(
        lldb.SBFileSpec(device_app))