Esempio n. 1
0
// Fill a map with parameters to be reported for a breakpoint stop.
static StopReasonMap breakPointStopReasonParameters(PDEBUG_BREAKPOINT b)
{
    typedef StopReasonMap::value_type StopReasonMapValue;

    StopReasonMap rc;
    ULONG uId = 0;
    if (FAILED(b->GetId(&uId)))
        return rc;
    rc.insert(StopReasonMapValue(std::string("breakpointId"), toString(uId)));
    const std::pair<ULONG64, ULONG> memoryRange = breakPointMemoryRange(b);
    if (!memoryRange.first)
        return rc;
    rc.insert(StopReasonMapValue(std::string("breakpointAddress"), toString(memoryRange.first)));
    // Report the memory for data breakpoints allowing for watching for changed bits
    // on the client side.
    if (!memoryRange.second)
        return rc;
    // Try to grab a IDataSpace from somewhere to get the memory
    if (CIDebugClient *client = ExtensionContext::instance().hookedClient()) {
        IInterfacePointer<CIDebugDataSpaces> dataSpaces(client);
        if (dataSpaces) {
            const std::wstring memoryHex = memoryToHexW(dataSpaces.data(), memoryRange.first, memoryRange.second);
            if (!memoryHex.empty())
                rc.insert(StopReasonMapValue("memory", wStringToString(memoryHex)));
        } // dataSpaces
    } // client
    return rc;
}
Esempio n. 2
0
static bool gdbmiFormatBreakpoint(std::ostream &str,
                                  IDebugBreakpoint *bp,
                                  CIDebugSymbols *symbols  /* = 0 */,
                                  CIDebugDataSpaces *dataSpaces /* = 0 */,
                                  unsigned verbose, std::string *errorMessage)
{
    enum { BufSize = 512 };
    ULONG flags = 0;
    ULONG id = 0;
    if (SUCCEEDED(bp->GetId(&id)))
        str << ",id=\"" << id << '"';
    HRESULT hr = bp->GetFlags(&flags);
    if (FAILED(hr)) {
        *errorMessage = msgDebugEngineComFailed("GetFlags", hr);
        return false;
    }
    const bool deferred = (flags & DEBUG_BREAKPOINT_DEFERRED) != 0;
    formatGdbmiFlag(str, ",deferred", deferred);
    formatGdbmiFlag(str, ",enabled", (flags & DEBUG_BREAKPOINT_ENABLED) != 0);
    if (verbose) {
        formatGdbmiFlag(str, ",oneshot", (flags & DEBUG_BREAKPOINT_ONE_SHOT) != 0);
        str << ",flags=\"" << flags << '"';
        ULONG threadId = 0;
        if (SUCCEEDED(bp->GetMatchThreadId(&threadId))) // Fails if none set
            str << ",thread=\"" << threadId << '"';
        ULONG passCount = 0;
        if (SUCCEEDED(bp->GetPassCount(&passCount)))
            str << ",passcount=\"" << passCount << '"';
    }
    // Offset: Fails for deferred ones
    if (!deferred) {
        const std::pair<ULONG64, ULONG> memoryRange = breakPointMemoryRange(bp);
        if (memoryRange.first) {
            str << ",address=\"" << std::hex << std::showbase << memoryRange.first
                << std::dec << std::noshowbase << '"';
            // Resolve module to be specified in next run for speed-up.
            if (symbols) {
                const std::string module = moduleNameByOffset(symbols, memoryRange.first);
                if (!module.empty())
                    str << ",module=\"" << module << '"';
            } // symbols
            // Report the memory of watchpoints for comparing bitfields
            if (dataSpaces && memoryRange.second > 0) {
                str << ",size=\"" << memoryRange.second << '"';
                const std::wstring memoryHex = memoryToHexW(dataSpaces, memoryRange.first, memoryRange.second);
                if (!memoryHex.empty())
                    str << ",memory=\"" << gdbmiWStringFormat(memoryHex) << '"';
            }
        } // Got address
    } // !deferred
    // Expression
    if (verbose > 1) {
        char buf[BufSize];
        if (SUCCEEDED(bp->GetOffsetExpression(buf, BUFSIZ, 0)))
            str << ",expression=\"" << gdbmiStringFormat(buf) << '"';
    }
    return true;
}