Пример #1
0
static void
ToolsCoreInitializeDebug(ToolsServiceState *state)
{
   RpcDebugLibData *libdata;
   RpcDebugInitializeFn initFn;

   state->debugLib = g_module_open(MODULE_NAME(vmrpcdbg), G_MODULE_BIND_LOCAL);
   if (state->debugLib == NULL) {
      g_error("Cannot load vmrpcdbg library.\n");
   }

   if (!g_module_symbol(state->debugLib,
                        "RpcDebug_Initialize",
                        (gpointer *) &initFn)) {
      g_error("Cannot find symbol: RpcDebug_Initialize\n");
   }

   libdata = initFn(&state->ctx, state->debugPlugin);
   ASSERT(libdata != NULL);
   ASSERT(libdata->debugPlugin != NULL);

   state->debugData = libdata;
#if defined(_WIN32)
   VMTools_AttachConsole();
#endif
}
Пример #2
0
int main(){
    MODULE_NAME(BOOST_TEST_MODULE);
    for (auto& item: TESTS.tests){
        printf("Running test %s\n", item.name);
        item.fn();
    }
    printf("%d tests succeeded, %d tests failed\n",
        TESTS.success, TESTS.failure);
    if (TESTS.failure > 0) {
        return -1;
    }
    return 0;
}
Пример #3
0
static PyObject *Nuitka_Function_get_module( Nuitka_FunctionObject *object )
{
    if ( object->m_dict )
    {
        PyObject *result = PyDict_GetItem( object->m_dict, const_str_plain___module__ );

        if ( result != NULL )
        {
            return INCREASE_REFCOUNT( result );
        }
    }

    return INCREASE_REFCOUNT( MODULE_NAME( object->m_module ) );
}
Пример #4
0
static PyFrameObject *MAKE_FRAME( PyCodeObject *code, PyObject *module, bool is_module )
{
    PyTraceBack_Type.tp_dealloc = (destructor)tb_dealloc;

    assertCodeObject( code );

    PyObject *globals = ((PyModuleObject *)module)->md_dict;
    assert( PyDict_Check( globals ) );

    Py_ssize_t ncells = PyTuple_GET_SIZE( code->co_cellvars );
    Py_ssize_t nfrees = PyTuple_GET_SIZE( code->co_freevars );
    Py_ssize_t extras = code->co_stacksize + code->co_nlocals + ncells + nfrees;

    Nuitka_FrameObject *result = PyObject_GC_NewVar( Nuitka_FrameObject, &Nuitka_Frame_Type, extras );

    if (unlikely( result == NULL ))
    {
        return NULL;
    }

    PyFrameObject *frame = &result->m_frame;

    frame->f_code = code;

    extras = code->co_nlocals + ncells + nfrees;
    frame->f_valuestack = frame->f_localsplus + extras;

    for ( Py_ssize_t i = 0; i < extras; i++ )
    {
        frame->f_localsplus[i] = NULL;
    }

    frame->f_locals = NULL;
    frame->f_trace = INCREASE_REFCOUNT( Py_None );

    frame->f_exc_type = NULL;
    frame->f_exc_value = NULL;
    frame->f_exc_traceback = NULL;

    frame->f_stacktop = frame->f_valuestack;
    frame->f_builtins = INCREASE_REFCOUNT( (PyObject *)dict_builtin );

    frame->f_back = NULL;

    frame->f_globals = INCREASE_REFCOUNT( globals );

    if (likely( (code->co_flags & CO_OPTIMIZED ) == CO_OPTIMIZED ))
    {
        frame->f_locals = NULL;
    }
    else if (is_module)
    {
        frame->f_locals = INCREASE_REFCOUNT( globals );
    }
    else
    {
        frame->f_locals = PyDict_New();

        if (unlikely( frame->f_locals == NULL ))
        {
            Py_DECREF( result );

            return NULL;
        }

        PyDict_SetItem(
            frame->f_locals,
            const_str_plain___module__,
            MODULE_NAME( module )
        );
    }

#if PYTHON_VERSION < 340
    frame->f_tstate = PyThreadState_GET();
#endif

    frame->f_lasti = -1;
    frame->f_lineno = code->co_firstlineno;
    frame->f_iblock = 0;

#if PYTHON_VERSION >= 340
    frame->f_gen = NULL;
    frame->f_executing = 0;
#endif

    Nuitka_GC_Track( result );
    return (PyFrameObject *)result;
}
Пример #5
0
static struct Nuitka_FrameObject *MAKE_FRAME(PyCodeObject *code, PyObject *module, bool is_module,
                                             Py_ssize_t locals_size) {
    assertCodeObject(code);

    PyObject *globals = ((PyModuleObject *)module)->md_dict;
    assert(PyDict_Check(globals));

    struct Nuitka_FrameObject *result;

    // Macro to assign result memory from GC or free list.
    allocateFromFreeList(free_list_frames, struct Nuitka_FrameObject, Nuitka_Frame_Type, locals_size);

    result->m_type_description = NULL;

    PyFrameObject *frame = &result->m_frame;

    frame->f_code = code;

    frame->f_trace = Py_None;

#if PYTHON_VERSION < 370
    frame->f_exc_type = NULL;
    frame->f_exc_value = NULL;
    frame->f_exc_traceback = NULL;
#else
    frame->f_trace_lines = 0;
    frame->f_trace_opcodes = 0;
#endif

    Py_INCREF(dict_builtin);
    frame->f_builtins = (PyObject *)dict_builtin;

    frame->f_back = NULL;

    Py_INCREF(globals);
    frame->f_globals = globals;

    if (likely((code->co_flags & CO_OPTIMIZED) == CO_OPTIMIZED)) {
        frame->f_locals = NULL;
    } else if (is_module) {
        Py_INCREF(globals);
        frame->f_locals = globals;
    } else {
        frame->f_locals = PyDict_New();

        if (unlikely(frame->f_locals == NULL)) {
            Py_DECREF(result);

            return NULL;
        }

        PyDict_SetItem(frame->f_locals, const_str_plain___module__, MODULE_NAME(module));
    }

#if PYTHON_VERSION < 340
    frame->f_tstate = PyThreadState_GET();
#endif

    frame->f_lasti = -1;
    frame->f_lineno = code->co_firstlineno;
    frame->f_iblock = 0;

#if PYTHON_VERSION >= 340
    frame->f_gen = NULL;
    frame->f_executing = 0;
#endif

    Nuitka_GC_Track(result);
    return result;
}
Пример #6
0
//need to check Hook count before call this function
int LsiApiHooks::runCallback(int level, lsi_cb_param_t *param) const
{    
    int ret = 0;
    lsi_cb_param_t rec1;
    int8_t *pEnableArray = param->_hook_info->_enable_array;
        
    LsiApiHook *hook = begin();
    LsiApiHook *hookEnd = end();  //FIXME: I found end() will change since m_iEnd will change
    int offset = (LsiApiHook *)param->_cur_hook - begin();
    if(offset > 0)
    {
        pEnableArray += offset;
        hook = (LsiApiHook *)param->_cur_hook;
    }
    
    while(hook != hookEnd)
    {
        if (*pEnableArray++ == 0)
        {
            ++hook;
            continue;
        }
        
        rec1 = *param;
        rec1._cur_hook = (void *)hook;

        if ( D_ENABLED( DL_MORE ))
        {
            if (param->_session) 
            {
                LogTracker * pTracker = ((LsiSession *)param->_session)->getLogTracker();
                LOG_D(( pTracker->getLogger(), "[%s] [%s] run Hook function for [Module:%s]", 
                    pTracker->getLogId(), s_pHkptName[ level ], MODULE_NAME( hook->_module ) ));
            } 
            else
            {
                LOG_D(( NULL, "[ServerHook: %s] run Hook function for [Module:%s]", 
                    s_pHkptName[ level ], MODULE_NAME( hook->_module ) ));
            }
        }
        
        ret = hook->_cb(&rec1);

        if ( D_ENABLED( DL_MORE ))
        {
            if (param->_session) 
            {
                LogTracker * pTracker = ((LsiSession *)param->_session)->getLogTracker();
                LOG_D(( pTracker->getLogger(), "[%s] [%s] [Module:%s] ret %d", 
                    pTracker->getLogId(), s_pHkptName[ level ], MODULE_NAME( hook->_module ), ret ));
            }
            else
            {
                LOG_D(( NULL, "[ServerHook: %s] [Module:%s] ret %d", 
                    s_pHkptName[ level ], MODULE_NAME( hook->_module ), ret ));
            }
        }
        if ((ret != 0)&&!(m_iFlag & LSI_HOOK_FLAG_NO_INTERRUPT) )
            break;
    
        ++hook;
    }
    
    return ret;
}