示例#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 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");
     }

 }