示例#1
0
std::string gdbmiStack(CIDebugControl *debugControl,
                       CIDebugSymbols *debugSymbols,
                       unsigned maxFrames,
                       bool humanReadable, std::string *errorMessage)
{
    bool incomplete;
    const StackFrames frames = getStackTrace(debugControl, debugSymbols,
                                        maxFrames, &incomplete, errorMessage);
    if (frames.empty() && maxFrames > 0)
        return std::string();

    std::ostringstream str;
    str << '[';
    const StackFrames::size_type size = frames.size();
    for (StackFrames::size_type i = 0; i < size; ++i) {
        if (i)
            str << ',';
        frames.at(i).formatGDBMI(str, (int)i);
        if (humanReadable)
            str << '\n';
    }
    if (incomplete) // Empty elements indicates incomplete.
        str <<",{}";
    str << ']';
    return str.str();
}
示例#2
0
void StackHandler::prependFrames(const StackFrames &frames)
{
    if (frames.isEmpty())
        return;
    const int count = frames.size();
    beginInsertRows(QModelIndex(), 0, count - 1);
    for (int i = count - 1; i >= 0; --i)
        m_stackFrames.prepend(frames.at(i));
    endInsertRows();
    if (m_currentIndex >= 0)
        setCurrentIndex(m_currentIndex + count);
    emit stackChanged();
}
示例#3
0
void StackHandler::setFramesAndCurrentIndex(const GdbMi &frames, bool isFull)
{
    int targetFrame = -1;

    StackFrames stackFrames;
    const int n = frames.childCount();
    for (int i = 0; i != n; ++i) {
        stackFrames.append(StackFrame::parseFrame(frames.childAt(i), m_engine->runParameters()));
        const StackFrame &frame = stackFrames.back();

        // Initialize top frame to the first valid frame.
        const bool isValid = frame.isUsable() && !frame.function.isEmpty();
        if (isValid && targetFrame == -1)
            targetFrame = i;
    }

    bool canExpand = !isFull && (n >= action(MaximalStackDepth)->value().toInt());
    action(ExpandStack)->setEnabled(canExpand);
    setFrames(stackFrames, canExpand);

    // We can't jump to any file if we don't have any frames.
    if (stackFrames.isEmpty())
        return;

    // targetFrame contains the top most frame for which we have source
    // information. That's typically the frame we'd like to jump to, with
    // a few exceptions:

    // Always jump to frame #0 when stepping by instruction.
    if (m_engine->operatesByInstruction())
        targetFrame = 0;

    // If there is no frame with source, jump to frame #0.
    if (targetFrame == -1)
        targetFrame = 0;

    setCurrentIndex(targetFrame);
}
示例#4
0
 void SampleNode::add(StackFrames& stackFrames, size_t bytes, size_t frame)
 {
     if(frame > currentFrame)
     {
         currentFrame = frame;
     }

     StackFrame top(stackFrames.front());

     if(top.getFunction() == name)
     {
         stackFrames.pop_front();

         if(stackFrames.empty())
         {
             addAllocation(bytes);
             return;
         }

         StackFrame firstChild(stackFrames.front());

         std::string function(firstChild.getFunction());

         if(children.find(function) == children.end())
         {
             children[function] = SampleNode(function);
         }

         SampleNode& childNode = children[function];
         childNode.add(stackFrames, bytes, frame);
     }
     else
     {
         throw std::runtime_error("Invalid data");
     }

 }