Esempio n. 1
0
//--------------------------------------------------------------------------
// Initialize PPC debugger plugin
static bool init_plugin(void)
{
    if (ph.id != PLFM_PPC)
        return false;

    setup_registers();

    for (int k = 0; k < custom_format_count; ++k)
    {
        int dfid = register_custom_data_format(0, &custom_formats[k]);
        if (dfid < 0)
            msg("---: %d - Could not register custom format: %s - %lld bytes - %d wide\n", (uint32)k, custom_formats[k].name, (uint64)custom_formats[k].value_size, (uint32)custom_formats[k].text_width);
        else
            msg("---: %d - Registered custom format: %s - %lld bytes - %d wide\n", (uint32)k, custom_formats[k].name, (uint64)custom_formats[k].value_size, (uint32)custom_formats[k].text_width);

        custom_formats[k].ud = (void*)dfid;
    }

    intvec_t dts;
    int dt_count = get_custom_data_types(&dts);
    for (int i = 0; i < dt_count; ++i)
    {
        const data_type_t* t = get_custom_data_type(dts[i]);
        msg("%d - Type: %s - %lld bytes\n", (uint32)i, t->name, (uint64)t->value_size);
    }

    intvec_t dfs;
    int df_count = get_custom_data_formats(&dfs, 0);
    for (int j = 0; j < df_count; ++j)
    {
        const data_format_t* f = get_custom_data_format(0, dfs[j]);
        msg("---: %d - Format: %s - %lld bytes - %d wide\n", (uint32)j, f->name, (uint64)f->value_size, (uint32)f->text_width);
    }

    return true;
}
Esempio n. 2
0
  int register_df(int dtid, PyObject *py_obj)
  {
    // Already registered?
    if ( dfid >= 0 )
      return dfid;

    memset(&df, 0, sizeof(df));
    df.cbsize = sizeof(df);
    df.ud = this;

    PYW_GIL_CHECK_LOCKED_SCOPE();
    do
    {
      ref_t py_attr;

      // name
      if ( !PyW_GetStringAttr(py_obj, S_NAME, &df_name) )
        break;
      df.name = df_name.c_str();

      // menu_name (optional)
      if ( PyW_GetStringAttr(py_obj, S_MENU_NAME, &df_menu_name) )
        df.menu_name = df_menu_name.c_str();

      // props
      py_attr = PyW_TryGetAttrString(py_obj, S_PROPS);
      if ( py_attr != NULL && PyInt_Check(py_attr.o) )
        df.props = PyInt_AsLong(py_attr.o);

      // hotkey
      if ( PyW_GetStringAttr(py_obj, S_HOTKEY, &df_hotkey) )
        df.hotkey = df_hotkey.c_str();

      // value_size
      py_attr = PyW_TryGetAttrString(py_obj, S_VALUE_SIZE);
      if ( py_attr != NULL && PyInt_Check(py_attr.o) )
        df.value_size = PyInt_AsLong(py_attr.o);

      // text_width
      py_attr = PyW_TryGetAttrString(py_obj, S_TEXT_WIDTH);
      if ( py_attr != NULL && PyInt_Check(py_attr.o) )
        df.text_width = PyInt_AsLong(py_attr.o);

      // print cb
      py_attr = PyW_TryGetAttrString(py_obj, S_PRINTF);
      if ( py_attr != NULL && PyCallable_Check(py_attr.o) )
        df.print = s_print;

      // scan cb
      py_attr = PyW_TryGetAttrString(py_obj, S_SCAN);
      if ( py_attr != NULL && PyCallable_Check(py_attr.o) )
        df.scan = s_scan;

      // analyze cb
      py_attr = PyW_TryGetAttrString(py_obj, S_ANALYZE);
      if ( py_attr != NULL && PyCallable_Check(py_attr.o) )
        df.analyze = s_analyze;

      // Now try to register
      dfid = register_custom_data_format(dtid, &df);
      if ( dfid < 0 )
        break;

      // Hold reference to the PyObject
      Py_INCREF(py_obj);
      py_self = py_obj;

      // Update the format ID
      py_attr = newref_t(PyInt_FromLong(dfid));
      PyObject_SetAttrString(py_obj, S_ID, py_attr.o);
    } while ( false );
    return dfid;
  }