Beispiel #1
0
Modules getModules(CIDebugSymbols *syms, std::string *errorMessage)
{
    enum { BufSize = 1024 };

    char nameBuf[BufSize];
    char fileBuf[BufSize];

    ULONG Loaded;
    ULONG Unloaded;
    HRESULT hr = syms->GetNumberModules(&Loaded, &Unloaded);
    if (FAILED(hr)) {
        *errorMessage = msgDebugEngineComFailed("GetNumberModules", hr);
        return Modules();
    }
    const ULONG count = Loaded + Unloaded;
    Modules rc;
    rc.reserve(count);
    DEBUG_MODULE_PARAMETERS *parameters = new DEBUG_MODULE_PARAMETERS[count];
    hr = syms->GetModuleParameters(count, NULL, 0, parameters);
    if (FAILED(hr)) {
        delete [] parameters;
        *errorMessage = msgDebugEngineComFailed("GetModuleParameters", hr);
        return Modules();
    }

    for (ULONG m = 0; m < count; ++m) {
        Module module;
        module.base = parameters[m].Base;
        module.size = parameters[m].Size;
        module.deferred = parameters[m].Flags == DEBUG_SYMTYPE_DEFERRED;
        hr = syms->GetModuleNames(m, 0, fileBuf, BufSize, NULL,
                                  nameBuf, BufSize, NULL, NULL, NULL, NULL);
        if (FAILED(hr))
            break; // Fail silently should unloaded modules not work.
        module.name = nameBuf;
        module.image = fileBuf;
        rc.push_back(module);
    }
    return rc;
}
bool CSMesExecution::mergeExecutions(const ExecutionNames &sources,const ExecutionName &dest)
{
   if (executions.exists(dest))
      return false;

   Executions::modules_executions_t mod_exec;
   executions.setExecution(dest,mod_exec);
   ModuleFiles modules=Modules();

   bool first=true;
   for (ExecutionNames::const_iterator execit=sources.begin();
      execit!=sources.end();
      ++execit)
   {
      if (first)
         executions.setExecutionStatus(dest,executions.getExecutionStatus(*execit));
      else
         executions.setExecutionStatus(dest,combineExecutionStatus(executions.getExecutionStatus(dest),executions.getExecutionStatus(*execit)));
      first=false;
   }
   for (ModuleFiles::const_iterator modit=modules.begin();
      modit!=modules.end();
      ++modit)
   {
     Executions::executions_t exec;
      int nb_exec=instrumentations.modules[*modit].nb_measurements_items;
      exec.resize(nb_exec);
      for (int i=0;i<nb_exec;i++)
         exec[i]=Instrumentation::EXECUTION_STATE_NOT_EXECUTED;

      for (ExecutionNames::const_iterator execit=sources.begin();
         execit!=sources.end();
         ++execit)
      {
         Executions::executions_t e=executions.getExecutionModule(*execit,*modit);
         for (int iexec=0;iexec<nb_exec;iexec++)
            exec[iexec]=Instrumentation::combineExecution(exec[iexec],e[iexec]);
      }
      executions.setExecutionModule(dest,*modit,exec);
   }

   return true;
}
int polygon_gererator_main( int argc, char* argv[] )
{
    if( argc < 2 )
    {
        printf( "A sample tool for dumping board geometry as a set of polygons.\n" );
        printf( "Usage : %s board_file.kicad_pcb\n\n", argv[0] );
        return KI_TEST::RET_CODES::BAD_CMDLINE;
    }

    std::string filename;

    if( argc > 1 )
        filename = argv[1];

    auto brd = KI_TEST::ReadBoardFromFileOrStream( filename );

    if( !brd )
    {
        return POLY_GEN_RET_CODES::LOAD_FAILED;
    }

    for( unsigned net = 0; net < brd->GetNetCount(); net++ )
    {
        printf( "net %d\n", net );

        for( auto track : brd->Tracks() )
            process( track, net );

        for( auto mod : brd->Modules() )
        {
            for( auto pad : mod->Pads() )
                process( pad, net );
        }

        for( auto zone : brd->Zones() )
            process( zone, net );

        printf( "endnet\n" );
    }

    return KI_TEST::RET_CODES::OK;
}
Beispiel #4
0
bool utTextureLoadPVR( const char* data, uint32 size, utTextureInfo* info)
{
	// Load pvr
    ASSERT_STATIC( sizeof( PVRHeader ) == 52 );

	info->_surfaces = NULL;

	memcpy( &pvrHeader, data, 52 );

    // Store properties
    info->_width = pvrHeader.dwWidth;
    info->_height = pvrHeader.dwHeight;
	info->_depth = 1;
    info->_format = utTextureFormats::Unknown;
	info->_mipCount = pvrHeader.dwMipMapCount;

    // Get texture type
    if( pvrHeader.dwNumFaces == 6 )
    {
		info->_type = utTextureTypes::TexCube;
    }
    else
    {
		info->_type = utTextureTypes::Tex2D;
    }

    // Get pixel format
	if (pvrHeader.dwPixelFormatHigh == 0 )
	{
		switch(pvrHeader.dwPixelFormatLow)
		{
		case ePVRTPF_PVRTCI_2bpp_RGBA:
			info->_format = utTextureFormats::PVRTCI_A2BPP;
			break;
		case ePVRTPF_PVRTCI_4bpp_RGBA:
			info->_format = utTextureFormats::PVRTCI_A4BPP;
			break;
		case ePVRTPF_DXT1:
			info->_format = utTextureFormats::DXT1;
			break;
		case ePVRTPF_DXT3:
			info->_format = utTextureFormats::DXT3;
			break;
		case ePVRTPF_DXT5:
			info->_format = utTextureFormats::DXT5;
			break;
		case ePVRTPF_PVRTCI_2bpp_RGB:
			info->_format = utTextureFormats::PVRTCI_2BPP;
			break;
		case ePVRTPF_PVRTCI_4bpp_RGB:
			info->_format = utTextureFormats::PVRTCI_4BPP;
			break;
		case ePVRTPF_ETC1:
			info->_format = utTextureFormats::ETC1;
			break;
		}
	}

	if( info->_format == utTextureFormats::Unknown )
	{
		Modules().log().writeError( "Unsupported PVR pixel format" );
		return false;
	}

    // Upload texture subresources
    info->_sliceCount = info->_type == utTextureTypes::TexCube ? 6 : 1;
    unsigned char *pixels = (unsigned char *)(data + 52);

	uint32 surfaceIndex = 0;
	info->_surfaceCount = info->_sliceCount * info->_mipCount;
	info->_surfaces = new utTextureSurfaceInfo[info->_surfaceCount];

    for( uint32 i = 0; i < info->_sliceCount; ++i )
    {
        int width = pvrHeader.dwWidth, height = pvrHeader.dwHeight;

        for( uint32 j = 0; j < info->_mipCount; ++j )
        {
			size_t mipSize =  calcTextureSize( info->_format, width, height, 1 );
            if( pixels + mipSize > (unsigned char *)data + size )
 			{
				Modules::log().writeError( "Corrupt PVR" );
				return false;
			}

			utTextureSurfaceInfo& surface = info->_surfaces[surfaceIndex++];
			surface._mip = j;
			surface._slice = i;
			surface._data = pixels;
			surface._size = (uint32)mipSize;

            pixels += mipSize;
            if( width > 1 ) width >>= 1;
            if( height > 1 ) height >>= 1;
        }
    }

    ASSERT( pixels == (unsigned char *)data + size);
	return true;
}