Ejemplo n.º 1
0
void CStackTraceImpl::Expand(CStackTrace::TStack& stack)
{
    char** syms = backtrace_symbols(&m_Stack[0], m_Stack.size());
    for (size_t i = 0;  i < m_Stack.size();  ++i) {
        string sym = syms[i];

        CStackTrace::SStackFrameInfo info;
        info.func = sym.empty() ? "???" : sym;
        info.file = "???";
        info.offs = 0;
        info.line = 0;

        string::size_type pos = sym.find_first_of("(");
        if (pos != string::npos) {
            info.module = sym.substr(0, pos);
            sym.erase(0, pos + 1);
        }

        pos = sym.find_first_of(")");
        if (pos != string::npos) {
            sym.erase(pos);
            pos = sym.find_last_of("+");
            if (pos != string::npos) {
                string sub = sym.substr(pos + 1, sym.length() - pos);
                info.func = sym.substr(0, pos);
                info.offs = NStr::StringToInt(sub, 0, 16);
            }
        }

        //
        // name demangling
        //
        if ( !info.func.empty()  &&  info.func[0] == '_') {
#if NCBI_COMPILER_VERSION >= 310
            // use abi::__cxa_demangle
            size_t len = 0;
            char* buf = 0;
            int status = 0;
            buf = abi::__cxa_demangle(info.func.c_str(),
                                      buf, &len, &status);
            if ( !status ) {
                info.func = buf;
                free(buf);
            }
#endif
        }

        stack.push_back(info);
    }

    free(syms);
}
Ejemplo n.º 2
0
 //умножение
 void mul()
 {
     if(Data.size()>1)
     {
         double x = Data.pop();
         double y = Data.pop();
         Data.push(x*y);
         it++;
     }
     else error("cann't execute mul, stack is empty");
 }
Ejemplo n.º 3
0
 //разность
 void sub()
 {
     if(Data.size()>1)
     {
         double y = Data.pop();
         double x = Data.pop();
         Data.push(x-y);
         it++;
     }
     else error("cann't execute add, stack is empty");
 }
Ejemplo n.º 4
0
 //деление
 void div()
 {
     if(Data.size()>1)
     {
         double y = Data.pop();
         double x = Data.pop();
         if(y) Data.push(x/y);
         else error("devide by zero");
         it++;
     }
     else error("cann't execute add, stack is empty");
 }
Ejemplo n.º 5
0
unsigned int CErrorStack::Count()
{
    TStack *cStack = m_cErrors.get();
    return cStack->size() - 1;
}
Ejemplo n.º 6
0
void CErrorStack::Clear()
{
    TStack *cStack = m_cErrors.get();
    while (cStack->size() > 1)
        cStack->pop();
}
Ejemplo n.º 7
0
void CErrorStack::Pop()
{
    TStack *cStack = m_cErrors.get();
    if (cStack->size() > 1)
        cStack->pop();
}