Exemple #1
0
std::wstring expandBaseType(CComPtr<IDiaSymbol> type)
{
  std::wstring ret;
  if(!type)
  {
    return ret;
  }

  DWORD tag;
  checkResult(type->get_symTag(&tag));
  if(SymTagUDT == tag)
  {
    UDT udt(type);
    ret = udt.getKind() + L" " + udt.getName();
  }
  else if(SymTagPointerType == tag)
  {
    CComPtr<IDiaSymbol> pointee;
    checkResult(type->get_type(&pointee));

    DWORD pointeeTag;
    checkResult(pointee->get_symTag(&pointeeTag));
    if(SymTagUDT == pointeeTag)
    {
      UDT udt(pointee);
      ret = udt.getKind() + L" " + udt.getName();
    }
  }
  else if(SymTagBaseType == tag)
  {
    DWORD baseType;
    checkResult(type->get_baseType(&baseType));
    ret += getBasicTypeString(baseType);
    return ret;
  }
  else
  {
    std::wstringstream str;
    str << tag;
    str >> ret;
  }

  return ret;
}
Exemple #2
0
/* Solve time ODE using Runge-Kutta 4 */
double *
rk4(double *data, int length, double dx, double dt)
{
  // Find k1
  double *k1 = udt(data, length, dx);
  
  // Find k2
  double *data_cpy = malloc(sizeof(double) * length);
  assert(data_cpy);
  memcpy(data_cpy, data, sizeof(double) * length);
  int i; for (i = 0; i < length; i++) {
    data_cpy[i] += (dt / 2) * k1[i];
  }
  double *k2 = udt(data_cpy, length, dx);
  
  // Find k3
  memcpy(data_cpy, data, sizeof(double) * length);
  for (i = 0; i < length; i++) {
    data_cpy[i] += (dt / 2) * k2[i];
  }
  double *k3 = udt(data_cpy, length, dx);
  
  // Find k4
  memcpy(data_cpy, data, sizeof(double) * length);
  for (i = 0; i < length; i++) {
    data_cpy[i] += dt * k3[i];
  }
  double *k4 = udt(data_cpy, length, dx);
  
  // Combine results
  double *res = calloc(length, sizeof(double));
  assert(res);
  for (i = 0; i < length; i++) {
    res[i] = (dt / 6) * (k1[i] + (2*k2[i]) + (2*k3[i]) + k4[i]);
  }

  free(data_cpy);
  free(k1); free(k2); free(k3); free(k4);
  
  return res;
}
Exemple #3
0
std::wstring expandTypeSpecial(CComPtr<IDiaSymbol> type)
{
  std::wstring ret;
  if(!type)
  {
    return ret;
  }

  DWORD tag;
  checkResult(type->get_symTag(&tag));
  if(SymTagPointerType == tag)
  {
    CComPtr<IDiaSymbol> pointee;
    checkResult(type->get_type(&pointee));
    ret += expandTypeSpecial(pointee);
  }
  else if(SymTagUDT == tag)
  {
    UDT udt(type);
    ret += udt.getName();
  }
  return ret;
}
Exemple #4
0
std::wstring expandType(CComPtr<IDiaSymbol> type, const std::wstring& name)
{
  std::wstring ret;
  if(!type)
  {
    return ret;
  }

  BOOL vol;
  checkResult(type->get_volatileType(&vol));
  if(vol)
  {
    ret += L"volatile ";
  }
  BOOL con;
  checkResult(type->get_constType(&con));
  if(con)
  {
    ret += L"const ";
  }

  DWORD tag;
  checkResult(type->get_symTag(&tag));
  if(SymTagBaseType == tag)
  {
    DWORD baseType;
    checkResult(type->get_baseType(&baseType));
    ret += getBasicTypeString(baseType);
    return ret;
  }
  if(SymTagPointerType == tag)
  {
    CComPtr<IDiaSymbol> pointee;
    checkResult(type->get_type(&pointee));

    DWORD pointeeTag;
    checkResult(pointee->get_symTag(&pointeeTag));
    if(SymTagFunctionType == pointeeTag)//function pointer!
    {
      CComPtr<IDiaSymbol> returnType;
      checkResult(pointee->get_type(&returnType));
      ret += expandType(returnType);

      ret += L" (*" + name + L")(";

      CComPtr<IDiaEnumSymbols> pIDiaEnumSymbols;
      checkResult(pointee->findChildren(SymTagFunctionArgType, NULL,
        nsNone,&pIDiaEnumSymbols));

      if(!!pIDiaEnumSymbols)
      {
        LONG count;
        checkResult(pIDiaEnumSymbols->get_Count(&count));
        for(int i = 0; i < count; ++i)
        {
          if(i)ret += L", ";
          CComPtr<IDiaSymbol> pIDiaSymbol;
          checkResult(pIDiaEnumSymbols->Item(i,&pIDiaSymbol));

          CComPtr<IDiaSymbol> funcArg;
          checkResult(pIDiaSymbol->get_type(&funcArg));
          ret += expandType(funcArg);
        }
      }
      ret += L")";
      return ret;
    }

    ret += expandType(pointee);

    BOOL ref;
    checkResult(type->get_reference(&ref));
    if(ref)
    {
      ret += L"&";
    }
    else
    {
      ret += L"*";
    }

    return ret;
  }
  else if(SymTagArrayType == tag)
  {
    CComPtr<IDiaSymbol> arrayBase;
    checkResult(type->get_type(&arrayBase));

    ULONGLONG total;
    checkResult(type->get_length(&total));

    ULONGLONG len;
    checkResult(arrayBase->get_length(&len));

    ret += expandType(arrayBase);
    ret += L"[" + toString((int)(total/len)) + L"]";//sometimes seems to be inaccurate

    return ret;
  }
  else if(SymTagUDT == tag)
  {
    UDT udt(type);
    ret = udt.getKind() + L" " + udt.getName();
    return ret;
  }
  else if(SymTagEnum == tag)
  {
    ret = L"enum " + getName(type);
    return ret;
  }
  else 
  {
    __asm int 3;//JC to do
  }

  return getName(type);
}