bool CommentsProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const { CommentsModel *srcModel = static_cast<CommentsModel *>(sourceModel()); if (srcModel->isNested()) { // Disable sorting return false; } if (!left.isValid() || !right.isValid()) return false; if (left.parent().isValid() || right.parent().isValid()) return false; auto leftComment = left.data(CommentsModel::CommentDescriptionRole).value<CommentDescription>(); auto rightComment = right.data(CommentsModel::CommentDescriptionRole).value<CommentDescription>(); switch (left.column()) { case CommentsModel::OffsetColumn: return leftComment.offset < rightComment.offset; case CommentsModel::FunctionColumn: return Core()->cmdFunctionAt(leftComment.offset) < Core()->cmdFunctionAt(rightComment.offset); case CommentsModel::CommentColumn: return leftComment.name < rightComment.name; default: break; } return false; }
void CRender3D::DrawProfiler() { if (_iProfilerState > 0) { Core()->RenderProfilerText("======Render3D Profiler=====", ColorWhite()); Core()->RenderProfilerText(("Objects on screen :" + UIntToStr(_uiObjsDrawnCount)).c_str(), ColorWhite()); Core()->RenderProfilerText(("Render delay :" + UInt64ToStr(_ui64DrawDelay / 1000) + "." + UIntToStr(_ui64DrawDelay % 1000) + " ms").c_str(), ColorWhite()); } }
CBitmapFont::CBitmapFont(uint uiInstIdx, ITexture *pTex, const TFontHeader &stHeader, TCharBox *pChars): CInstancedObj(uiInstIdx), _pTex(pTex), _fScale(1.f), _stHeader(stHeader), _uiBufferSize(16)// never less than 16 { _pBuffer = new float[_uiBufferSize]; memcpy(_astChars, pChars, sizeof(TCharBox) * 224); _pRender2D = Core()->pRender()->pRender2D(); _pRender3D = Core()->pRender()->pRender3D(); }
CTexture::CTexture(uint uiInstIdx, ICoreTexture *pCoreTex, uint uiWidth, uint uiHeight): CInstancedObj(uiInstIdx), _pCoreTexture(pCoreTex), _uiWidth(uiWidth), _uiHeight(uiHeight), _uiFrameWidth(0), _uiFrameHeight(0) { memcpy(_quad, c_fQuad, sizeof(float)*8); _pCoreRenderer = Core()->pCoreRenderer(); _pRender2D = Core()->pRender()->pRender2D(); }
VisualNavbar::VisualNavbar(MainWindow *main, QWidget *parent) : QToolBar(main), graphicsView(new QGraphicsView), cursorGraphicsItem(nullptr), main(main) { Q_UNUSED(parent); setObjectName("visualNavbar"); setWindowTitle(tr("Visual navigation bar")); // setMovable(false); setContentsMargins(0, 0, 0, 0); // If line below is used, with the dark theme the paintEvent is not called // and the result is wrong. Something to do with overwriting the style sheet :/ //setStyleSheet("QToolBar { border: 0px; border-bottom: 0px; border-top: 0px; border-width: 0px;}"); /* QComboBox *addsCombo = new QComboBox(); addsCombo->addItem(""); addsCombo->addItem("Entry points"); addsCombo->addItem("Marks"); */ addWidget(this->graphicsView); //addWidget(addsCombo); connect(Core(), SIGNAL(seekChanged(RVA)), this, SLOT(on_seekChanged(RVA))); connect(Core(), SIGNAL(refreshAll()), this, SLOT(fetchAndPaintData())); connect(Core(), SIGNAL(functionsChanged()), this, SLOT(updateMetadataAndPaint())); connect(Core(), SIGNAL(flagsChanged()), this, SLOT(updateMetadataAndPaint())); graphicsScene = new QGraphicsScene(this); const QBrush bg = QBrush(QColor(74, 74, 74)); graphicsScene->setBackgroundBrush(bg); this->graphicsView->setAlignment(Qt::AlignLeft); this->graphicsView->setMinimumHeight(20); this->graphicsView->setMaximumHeight(20); this->graphicsView->setFrameShape(QFrame::NoFrame); this->graphicsView->setRenderHints(0); this->graphicsView->setScene(graphicsScene); this->graphicsView->setRenderHints(QPainter::Antialiasing); this->graphicsView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); this->graphicsView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); // So the graphicsView doesn't intercept mouse events. this->graphicsView->setEnabled(false); this->graphicsView->setMouseTracking(true); setMouseTracking(true); }
void CommentsWidget::refreshTree() { commentsModel->beginReloadComments(); comments = Core()->getAllComments("CCu"); nestedComments.clear(); for (CommentDescription comment : comments) { QString fcnName = Core()->cmdFunctionAt(comment.offset); nestedComments[fcnName].append(comment); } commentsModel->endReloadComments(); qhelpers::adjustColumns(ui->commentsTreeView, 3, 0); }
Core ParseCore(const pugi::xml_node &input, const std::map<int, UP_Assembly_t> &assemblies) { Core core; int n_core_enabled = 0; for (auto core_xml = input.child("core"); core_xml; core_xml = core_xml.next_sibling("core")) { bool core_enabled = true; if (!core_xml.attribute("enabled").empty()) { core_enabled = core_xml.attribute("enabled").as_bool(); } if (core_enabled) { core = Core(core_xml, assemblies); n_core_enabled++; } } if (n_core_enabled == 0) { throw EXCEPT("No enabled core specifications."); } if (n_core_enabled > 1) { throw EXCEPT("More than one enabled core specification found. Tell " "me which one to use"); } return core; }
void ImportsWidget::on_importsTreeView_doubleClicked(const QModelIndex &index) { if (!index.isValid()) return; Core()->seek(index.data(ImportsModel::AddressRole).toLongLong()); }
ImportsWidget::ImportsWidget(MainWindow *main, QAction *action) : CutterDockWidget(main, action), ui(new Ui::ImportsWidget), importsModel(new ImportsModel(&imports, this)), importsProxyModel(new ImportsProxyModel(importsModel, this)) { ui->setupUi(this); ui->importsTreeView->setModel(importsProxyModel); ui->importsTreeView->sortByColumn(ImportsModel::NameColumn, Qt::AscendingOrder); // Ctrl-F to show/hide the filter entry QShortcut *searchShortcut = new QShortcut(QKeySequence::Find, this); connect(searchShortcut, &QShortcut::activated, ui->quickFilterView, &QuickFilterView::showFilter); searchShortcut->setContext(Qt::WidgetWithChildrenShortcut); // Esc to clear the filter entry QShortcut *clearShortcut = new QShortcut(QKeySequence(Qt::Key_Escape), this); connect(clearShortcut, &QShortcut::activated, ui->quickFilterView, &QuickFilterView::clearFilter); clearShortcut->setContext(Qt::WidgetWithChildrenShortcut); connect(ui->quickFilterView, SIGNAL(filterTextChanged(const QString &)), importsProxyModel, SLOT(setFilterWildcard(const QString &))); connect(ui->quickFilterView, SIGNAL(filterClosed()), ui->importsTreeView, SLOT(setFocus())); setScrollMode(); connect(Core(), SIGNAL(refreshAll()), this, SLOT(refreshImports())); }
CRender3D::CRender3D(uint uiInstIdx): CInstancedObj(uiInstIdx), _iProfilerState(0), _iDrawAxes(0), _iDrawLights(0), _bFrCalculated(false), _uiObjsDrawnCount(0) { _pCoreRenderer = Core()->pCoreRenderer(); bool supported; _pCoreRenderer->IsFeatureSupported(CRFT_LEGACY_FIXED_FUNCTION_PIPELINE_API, supported); if (supported) { _pCoreRenderer->GetFixedFunctionPipelineAPI(_pFFP); _pFFP->GetMaxLightsPerPassCount(_uiMaxLightsCount); } else { _pFFP = NULL; _uiMaxLightsCount = 0; } int i_value; _pCoreRenderer->GetDeviceMetric(CRMT_MAX_TEXTURE_LAYERS, i_value); _uiMaxTexUnits = (uint)i_value; _stCurState.pCurTexs.resize(_uiMaxTexUnits, NULL); Console()->RegComVar("rnd3d_profiler", "Displays Render 3D subsystems profiler.", &_iProfilerState, 0, 1); Console()->RegComVar("rnd3d_draw_axes", "Draws coordinate axes for every object on screen.", &_iDrawAxes, 0, 1); Console()->RegComVar("rnd3d_draw_lights", "Visualizes lights on on screen.", &_iDrawLights, 0, 1); }
void ImportsWidget::refreshImports() { importsModel->beginReload(); imports = Core()->getAllImports(); importsModel->endReload(); qhelpers::adjustColumns(ui->importsTreeView, 4, 0); }
void AdamantSkillTreePlugin::OnLoad() { { _viewer = new SkillTreeViewer(this); Core()->getInterface()->registerPluginPage(this, QIcon(":/icons/dark/tree.png"), "Skill Tree", "Plan and explore Path of Exile's Passive Skill Tree", _viewer); } }
GraphOptionsWidget::GraphOptionsWidget(PreferencesDialog */*dialog*/, QWidget *parent) : QDialog(parent), ui(new Ui::GraphOptionsWidget) { ui->setupUi(this); updateOptionsFromVars(); connect(Core(), SIGNAL(graphOptionsChanged()), this, SLOT(updateOptionsFromVars())); }
ForceInline UInt WinMain2(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWChar lpCmdLine, Int nCmdShow) { CCGCore Core(NULL); UNREFERENCED_PARAMETER(hInstance); UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); UNREFERENCED_PARAMETER(nCmdShow); return Core.Run(); }
void CommentsWidget::on_commentsTreeView_doubleClicked(const QModelIndex &index) { if (!index.isValid()) return; if (commentsModel->isNested() && !index.parent().isValid()) return; auto comment = index.data(CommentsModel::CommentDescriptionRole).value<CommentDescription>(); Core()->seek(comment.offset); }
void VisualNavbar::updateMetadata() { for (int i = 0; i < mappedSegments.length(); i++) { mappedSegments[i].functions.clear(); mappedSegments[i].symbols.clear(); mappedSegments[i].strings.clear(); } QList<FunctionDescription> functions = Core()->getAllFunctions(); for (auto function : functions) { auto mappedSegment = mappedSegmentForAddress(function.offset); if (mappedSegment) { MappedSegmentMetadata metadata; metadata.address = function.offset; metadata.size = function.size; mappedSegment->functions.append(metadata); } } QList<SymbolDescription> symbols = Core()->getAllSymbols(); for (auto symbol : symbols) { auto mappedSegment = mappedSegmentForAddress(symbol.vaddr); if (mappedSegment) { MappedSegmentMetadata metadata; metadata.address = symbol.vaddr; metadata.size = 1; mappedSegment->symbols.append(metadata); } } QList<StringDescription> strings = Core()->getAllStrings(); for (auto string : strings) { MappedSegment *mappedSegment = mappedSegmentForAddress(string.vaddr); if (mappedSegment) { MappedSegmentMetadata metadata; metadata.address = string.vaddr; metadata.size = string.string.length(); mappedSegment->strings.append(metadata); } } }
void VisualNavbar::mousePressEvent(QMouseEvent *event) { qreal x = event->localPos().x(); RVA address = localXToAddress(x); if (address != RVA_INVALID) { QToolTip::showText(event->globalPos(), toolTipForAddress(address), this); if (event->buttons() & Qt::LeftButton) { event->accept(); Core()->seek(address); } } }
void AdamantShopPlugin::OnLoad() { StashViewerPlugin* plugin = dynamic_cast<StashViewerPlugin*>(Core()->getPluginManager()->getPluginByIID("adamant.stashviewer")); if (plugin == nullptr) { // Error, requires StashViewerPlugin return; } _stashViewer = plugin->getStashViewer(); if (_stashViewer == nullptr) { // Couldn't fetch StashViewer return; } Core()->settings()->beginGroup("data"); const QStringList leagues = Core()->settings()->value("leagues").toStringList(); Core()->settings()->endGroup(); { _viewer = new ShopViewer(this, _stashViewer); Core()->getInterface()->registerPluginPage(this, QIcon(":/icons/dark/cart.png"), "Shops", "Manage shop threads.", _viewer); _viewer->setLeagues(leagues); } if (false) { _templateViewer = new TemplateViewer(this); Core()->getInterface()->registerPluginPage(this, QIcon(":/icons/dark/embed.png"), "Shop Templates", "Manage shop templates.", _templateViewer); } qRegisterMetaType<Shop*>(); qRegisterMetaType<ShopList>(); loadShops(leagues); // TODO(rory): Remove this { Item* item = nullptr; QFile file("test.item"); if (file.open(QFile::ReadOnly | QFile::Text)) { QJsonDocument doc = QJsonDocument::fromJson(file.readAll()); file.close(); item = new Item(doc.object()); } for (Shop* shop : _shops.values()) { shop->generateShopContent([&item](const QString &id) { Q_UNUSED(id); return item; }); } } }
HRESULT CALLBACK CTexture::Free() { bool can_delete; Core()->pResMan()->RemoveResource(this, can_delete); if (can_delete) { delete this; return S_OK; } else return S_FALSE; }
DGLE_RESULT DGLE_API CRender::GetRenderTarget(ITexture *&prTargetTex) { ICoreTexture *p_cur_target_ctex; _pCoreRenderer->GetRenderTarget(p_cur_target_ctex); if (p_cur_target_ctex == NULL) { prTargetTex = NULL; return S_OK; } uint count; Core()->pResMan()->GetResourcesCount(count); for (uint i = 0; i < count; ++i) { IEngineBaseObject *p_obj; Core()->pResMan()->GetResourceByIndex(i, p_obj); E_ENGINE_OBJECT_TYPE type; p_obj->GetType(type); if (type == EOT_TEXTURE) { ICoreTexture *p_ctex; ((ITexture *)p_obj)->GetCoreTexture(p_ctex); if (p_ctex == p_cur_target_ctex) { prTargetTex = (ITexture *)p_obj; return S_OK; } } } return E_FAIL; }
void CRender3D::SetDefaultStates() { uint vp_x, vp_y, vp_width, vp_height; _pCoreRenderer->GetViewport(vp_x, vp_y, vp_width, vp_height); _stCurState.fFovAngle = 60.f; _stCurState.fZNear = 0.25f; _stCurState.fZFar = 1000.f; _SetPerspectiveMatrix(vp_width, vp_height); _stCurState.matrixStack.Clear(MatrixIdentity()); _pCoreRenderer->SetMatrix(_stCurState.matrixStack.Top()); _stCurState.isLightingEnabled = false; _stCurState.stGlobalAmbient = TColor4(50, 50, 50, 255); _stCurState.stFogDesc.bEnabled = false; _stCurState.stFogDesc.stColor = ColorGray(); _stCurState.stFogDesc.fStart = 500.f; _stCurState.stFogDesc.fEnd = 1000.f; if (_pFFP) { _pFFP->ToggleGlobalLighting(_stCurState.isLightingEnabled); _pFFP->SetGloablAmbientLight(_stCurState.stGlobalAmbient); _pFFP->SetFogEnabled(_stCurState.stFogDesc.bEnabled); _pFFP->SetFogColor(_stCurState.stFogDesc.stColor); _pFFP->ConfigureFog(_stCurState.stFogDesc.fStart, _stCurState.stFogDesc.fEnd); } _stCurState.eBlendingMode = BE_NORMAL; _stCurState.stBlendStateDesc = TBlendStateDesc(); _pCoreRenderer->SetBlendState(_stCurState.stBlendStateDesc); _stCurState.stDepthStencilDesc = TDepthStencilDesc(); _pCoreRenderer->SetDepthStencilState(_stCurState.stDepthStencilDesc); _stCurState.stRasterStateDesc = TRasterizerStateDesc(); _stCurState.stRasterStateDesc.eCullMode = PCM_BACK; _pCoreRenderer->SetRasterizerState(_stCurState.stRasterStateDesc); _stCurState.stColor = ColorWhite(); _pCoreRenderer->SetColor(_stCurState.stColor); _stCurState.pCurMat = INVALID_MATERIAL; Core()->pRender()->Unbind(EOT_UNKNOWN); }
CommentsWidget::CommentsWidget(MainWindow *main, QAction *action) : CutterDockWidget(main, action), ui(new Ui::CommentsWidget), main(main) { ui->setupUi(this); commentsModel = new CommentsModel(&comments, &nestedComments, this); commentsProxyModel = new CommentsProxyModel(commentsModel, this); ui->commentsTreeView->setModel(commentsProxyModel); ui->commentsTreeView->sortByColumn(CommentsModel::CommentColumn, Qt::AscendingOrder); // Ctrl-F to show/hide the filter entry QShortcut *searchShortcut = new QShortcut(QKeySequence::Find, this); connect(searchShortcut, &QShortcut::activated, ui->quickFilterView, &QuickFilterView::showFilter); searchShortcut->setContext(Qt::WidgetWithChildrenShortcut); // Esc to clear the filter entry QShortcut *clearShortcut = new QShortcut(QKeySequence(Qt::Key_Escape), this); connect(clearShortcut, &QShortcut::activated, ui->quickFilterView, &QuickFilterView::clearFilter); clearShortcut->setContext(Qt::WidgetWithChildrenShortcut); connect(ui->quickFilterView, SIGNAL(filterTextChanged(const QString &)), commentsProxyModel, SLOT(setFilterWildcard(const QString &))); connect(ui->quickFilterView, SIGNAL(filterClosed()), ui->commentsTreeView, SLOT(setFocus())); setScrollMode(); ui->actionHorizontal->setChecked(true); this->setContextMenuPolicy(Qt::CustomContextMenu); connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(showTitleContextMenu(const QPoint &))); connect(Core(), SIGNAL(commentsChanged()), this, SLOT(refreshTree())); connect(Core(), SIGNAL(refreshAll()), this, SLOT(refreshTree())); }
void VisualNavbar::drawCursor() { RVA offset = Core()->getOffset(); double cursor_x = addressToLocalX(offset); if (cursorGraphicsItem != nullptr) { graphicsScene->removeItem(cursorGraphicsItem); delete cursorGraphicsItem; cursorGraphicsItem = nullptr; } if (std::isnan(cursor_x)) { return; } int h = this->graphicsView->height(); cursorGraphicsItem = new QGraphicsRectItem(cursor_x, 0, 2, h); cursorGraphicsItem->setPen(Qt::NoPen); cursorGraphicsItem->setBrush(QBrush(Config()->getColor("gui.navbar.err"))); graphicsScene->addItem(cursorGraphicsItem); }
int runSimulation(Memory& mem, bool LOG_EN){ int ret = 0; Core core = Core(0x4, LOG_EN); core.bindMemory(&mem); // execute a code from the entry point (0x4) while (1){ if (LOG_EN){ std::cout << "-----" << std::endl; } try{ core.fetch(); ret=core.execute(); } catch (const std::domain_error& ex){ std::cout << "Memory access error: " << ex.what() << std::endl; ret = 3; } if (ret){ if (ret == 2){ std::cout << "Wrong instruction opcode" << std::endl; } if (ret == 1){ // got HALT, the only good simulation finish condition std::cout << "Got HALT, finishing simulation" << std::endl; } else{ std::cout << "Simulation terminated due to errors" << std::endl; } break; } } core.printRegFile(); return ret; }
void CRender3D::EndFrame() { _ui64DrawDelay = GetPerfTimer() - _ui64DrawDelay - Core()->pRender()->pRender2D()->GetAverallDelay(); }
void CalculateProcessorTopology(CPUNumaNodes& out_nodes, uint32_t& out_numThreadsPerProcGroup) { out_nodes.clear(); out_numThreadsPerProcGroup = 0; #if defined(_WIN32) std::vector<KAFFINITY> threadMaskPerProcGroup; static std::mutex m; std::lock_guard<std::mutex> l(m); DWORD bufSize = 0; BOOL ret = GetLogicalProcessorInformationEx(RelationProcessorCore, nullptr, &bufSize); SWR_ASSERT(ret == FALSE && GetLastError() == ERROR_INSUFFICIENT_BUFFER); PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX pBufferMem = (PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX)malloc(bufSize); SWR_ASSERT(pBufferMem); ret = GetLogicalProcessorInformationEx(RelationProcessorCore, pBufferMem, &bufSize); SWR_ASSERT(ret != FALSE, "Failed to get Processor Topology Information"); uint32_t count = bufSize / pBufferMem->Size; PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX pBuffer = pBufferMem; for (uint32_t i = 0; i < count; ++i) { SWR_ASSERT(pBuffer->Relationship == RelationProcessorCore); for (uint32_t g = 0; g < pBuffer->Processor.GroupCount; ++g) { auto& gmask = pBuffer->Processor.GroupMask[g]; uint32_t threadId = 0; uint32_t procGroup = gmask.Group; Core* pCore = nullptr; uint32_t numThreads = (uint32_t)_mm_popcount_sizeT(gmask.Mask); while (BitScanForwardSizeT((unsigned long*)&threadId, gmask.Mask)) { // clear mask KAFFINITY threadMask = KAFFINITY(1) << threadId; gmask.Mask &= ~threadMask; if (procGroup >= threadMaskPerProcGroup.size()) { threadMaskPerProcGroup.resize(procGroup + 1); } if (threadMaskPerProcGroup[procGroup] & threadMask) { // Already seen this mask. This means that we are in 32-bit mode and // have seen more than 32 HW threads for this procGroup // Don't use it #if defined(_WIN64) SWR_INVALID("Shouldn't get here in 64-bit mode"); #endif continue; } threadMaskPerProcGroup[procGroup] |= (KAFFINITY(1) << threadId); // Find Numa Node uint32_t numaId = 0; PROCESSOR_NUMBER procNum = {}; procNum.Group = WORD(procGroup); procNum.Number = UCHAR(threadId); ret = GetNumaProcessorNodeEx(&procNum, (PUSHORT)&numaId); SWR_ASSERT(ret); // Store data if (out_nodes.size() <= numaId) { out_nodes.resize(numaId + 1); } auto& numaNode = out_nodes[numaId]; numaNode.numaId = numaId; uint32_t coreId = 0; if (nullptr == pCore) { numaNode.cores.push_back(Core()); pCore = &numaNode.cores.back(); pCore->procGroup = procGroup; } pCore->threadIds.push_back(threadId); if (procGroup == 0) { out_numThreadsPerProcGroup++; } } } pBuffer = PtrAdd(pBuffer, pBuffer->Size); } free(pBufferMem); #elif defined(__linux__) || defined (__gnu_linux__) // Parse /proc/cpuinfo to get full topology std::ifstream input("/proc/cpuinfo"); std::string line; char* c; uint32_t procId = uint32_t(-1); uint32_t coreId = uint32_t(-1); uint32_t physId = uint32_t(-1); while (std::getline(input, line)) { if (line.find("processor") != std::string::npos) { auto data_start = line.find(": ") + 2; procId = std::strtoul(&line.c_str()[data_start], &c, 10); continue; } if (line.find("core id") != std::string::npos) { auto data_start = line.find(": ") + 2; coreId = std::strtoul(&line.c_str()[data_start], &c, 10); continue; } if (line.find("physical id") != std::string::npos) { auto data_start = line.find(": ") + 2; physId = std::strtoul(&line.c_str()[data_start], &c, 10); continue; } if (line.length() == 0) { if (physId + 1 > out_nodes.size()) out_nodes.resize(physId + 1); auto& numaNode = out_nodes[physId]; numaNode.numaId = physId; if (coreId + 1 > numaNode.cores.size()) numaNode.cores.resize(coreId + 1); auto& core = numaNode.cores[coreId]; core.procGroup = coreId; core.threadIds.push_back(procId); } } out_numThreadsPerProcGroup = 0; for (auto &node : out_nodes) { for (auto &core : node.cores) { out_numThreadsPerProcGroup += core.threadIds.size(); } } #elif defined(__APPLE__) auto numProcessors = 0; auto numCores = 0; auto numPhysicalIds = 0; int value; size_t size = sizeof(value); int result = sysctlbyname("hw.packages", &value, &size, NULL, 0); SWR_ASSERT(result == 0); numPhysicalIds = value; result = sysctlbyname("hw.logicalcpu", &value, &size, NULL, 0); SWR_ASSERT(result == 0); numProcessors = value; result = sysctlbyname("hw.physicalcpu", &value, &size, NULL, 0); SWR_ASSERT(result == 0); numCores = value; out_nodes.resize(numPhysicalIds); for (auto physId = 0; physId < numPhysicalIds; ++physId) { auto &numaNode = out_nodes[physId]; auto procId = 0; numaNode.cores.resize(numCores); while (procId < numProcessors) { for (auto coreId = 0; coreId < numaNode.cores.size(); ++coreId, ++procId) { auto &core = numaNode.cores[coreId]; core.procGroup = coreId; core.threadIds.push_back(procId); } } } out_numThreadsPerProcGroup = 0; for (auto &node : out_nodes) { for (auto &core : node.cores) { out_numThreadsPerProcGroup += core.threadIds.size(); } } #else #error Unsupported platform #endif // Prune empty cores and numa nodes for (auto node_it = out_nodes.begin(); node_it != out_nodes.end(); ) { // Erase empty cores (first) for (auto core_it = node_it->cores.begin(); core_it != node_it->cores.end(); ) { if (core_it->threadIds.size() == 0) { core_it = node_it->cores.erase(core_it); } else { ++core_it; } } // Erase empty numa nodes (second) if (node_it->cores.size() == 0) { node_it = out_nodes.erase(node_it); } else { ++node_it; } } }
// Main function =============================================================== void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { const mxArray *In, *String; mxArray *Out; mwSize iC; OutStyle_T OutStyle = Auto_Style; // Default: Auto-expanding char StyleIn; // Check number of inputs and outputs: if (nrhs == 0 || nrhs > 2 || nlhs > 1) { mexErrMsgIdAndTxt(ERR_ID "BadNInput", ERR_HEAD "2 inputs allowed, 1 output allowed."); } // Parse 2nd input, if it is not empty: if (nrhs == 2 && !mxIsEmpty(prhs[1])) { if (!mxIsChar(prhs[1])) { mexErrMsgIdAndTxt(ERR_ID "BadType", ERR_HEAD "2nd input [Style] must be a string."); } // "Auto", "Lean", "Fat": StyleIn = *((char *) mxGetData(prhs[1])); switch (StyleIn) { case 'a': // Fallthrough case 'A': OutStyle = Auto_Style; break; case 'l': // Fallthrough case 'L': OutStyle = Lean_Style; break; case 'f': // Fallthrough case 'F': OutStyle = Fat_Style; break; default: mexErrMsgIdAndTxt(ERR_ID "BadStyle", ERR_HEAD "Unknown Style."); } } // Get input string or cell string and call the core: ------------------------ In = prhs[0]; if (mxIsChar(In)) { // Input is a string: plhs[0] = Core((mxChar *) mxGetData(In), mxGetNumberOfElements(prhs[0]), OutStyle); } else if (mxIsCell(In)) { // Input is a cell string: plhs[0] = mxCreateCellArray(mxGetNumberOfDimensions(In), mxGetDimensions(In)); Out = plhs[0]; iC = mxGetNumberOfElements(In); while (iC-- > 0) { // Backwards, faster than FOR String = mxGetCell(In, iC); if (String == NULL) { // Uninitialized cell: mxSetCell(Out, iC, Core(NULL, 0, OutStyle)); // Reply current directory } else if (mxIsChar(String)) { // Cell element is a string mxSetCell(Out, iC, Core((mxChar *) mxGetData(String), mxGetNumberOfElements(String), OutStyle)); } else { // Bad cell element mexErrMsgIdAndTxt(ERR_ID "BadInputType", ERR_HEAD "[FileName] must be a string or cell string."); } } } else { // Bad input type: mexErrMsgIdAndTxt(ERR_ID "BadInputType", ERR_HEAD "[FileName] must be a string or cell string."); } return; }
void VisualNavbar::fetchData() { // TODO: This code is quite verbose but very readable. The goal is to // experiment until we know what we want and then start to optimize. sections = Core()->getAllSections(); // Sort sections so we don't have to filter for overlaps afterwards qSort(sections.begin(), sections.end(), sortSectionLessThan); mappedSegments.clear(); for (SectionDescription section : sections) { bool segment_found = false; for (int i = 0; i < mappedSegments.count(); i++) { MappedSegment &mappedSegment = mappedSegments[i]; // Check if the segment contains the section bool segment_contains_section_start = false; if ((mappedSegment.address_from <= section.vaddr) && (section.vaddr <= mappedSegment.address_to)) { segment_contains_section_start = true; } bool segment_contains_section_end = false; if ((mappedSegment.address_from <= section.vaddr + section.vsize) && (section.vaddr + section.vsize <= mappedSegment.address_to)) { segment_contains_section_end = true; } // Check if the section contains the segment bool section_contains_segment_start = false; bool section_contains_segment_end = false; if ((section.vaddr <= mappedSegment.address_from) && (mappedSegment.address_from <= section.vaddr + section.vsize)) { section_contains_segment_start = true; } if ((section.vaddr <= mappedSegment.address_to) && (mappedSegment.address_to <= section.vaddr + section.vsize)) { section_contains_segment_end = true; } if (segment_contains_section_start | segment_contains_section_end | section_contains_segment_start | section_contains_segment_end) { if (section.vaddr < mappedSegment.address_from) { mappedSegment.address_from = section.vaddr; } if (mappedSegment.address_to < section.vaddr + section.vsize) { mappedSegment.address_to = section.vaddr + section.vsize; } segment_found = true; mappedSegment.sectionDescriptions.append(section); break; } } if (!segment_found) { MappedSegment mappedSegment; mappedSegment.address_from = section.vaddr; mappedSegment.address_to = section.vaddr + section.vsize; mappedSegment.sectionDescriptions.append(section); mappedSegments.append(mappedSegment); } } // If the file does not contain any sections we get the segments // from the memory maps instead. // It treats each map on its own, so overlapping maps will be shown // seperated. if (sections.count() == 0) { QJsonArray maps = Core()->cmdj("omj").array(); for (QJsonValue mapValue : maps) { QJsonObject map = mapValue.toObject(); MappedSegment mappedSegment; mappedSegment.address_from = map["from"].toVariant().toULongLong(); mappedSegment.address_to = map["to"].toVariant().toULongLong(); mappedSegments.append(mappedSegment); } } totalMappedSize = 0; for (auto &mappedSegment : mappedSegments) { totalMappedSize += mappedSegment.address_to - mappedSegment.address_from; } updateMetadata(); }
QVariant CommentsModel::data(const QModelIndex &index, int role) const { if (!index.isValid() || (index.internalId() != 0 && !index.parent().isValid())) return QVariant(); int commentIndex; bool isSubnode; if (index.internalId() != 0) { /* Subnode */ commentIndex = index.parent().row(); isSubnode = true; } else { /* Root node */ commentIndex = index.row(); isSubnode = false; } QString offset; CommentDescription comment; if (isNested()) { offset = nestedComments->keys().at(commentIndex); if (isSubnode) { comment = nestedComments->operator[](offset).at(index.row()); } } else { comment = comments->at(commentIndex); } switch (role) { case Qt::DisplayRole: if (isNested()) { if (isSubnode) { switch (index.column()) { case OffsetNestedColumn: return RAddressString(comment.offset); case CommentNestedColumn: return comment.name; default: break; } } else if (index.column() == OffsetNestedColumn) { return offset; } } else { switch (index.column()) { case CommentsModel::OffsetColumn: return RAddressString(comment.offset); case CommentsModel::FunctionColumn: return Core()->cmdFunctionAt(comment.offset); case CommentsModel::CommentColumn: return comment.name; default: break; } } break; case CommentsModel::CommentDescriptionRole: if (isNested() && index.internalId() == 0) { break; } return QVariant::fromValue(comment); default: break; } return QVariant(); }
void CRender3D::UnbindMaterial() { BindMaterial(Core()->pResMan()->pIDefaultMaterial()); _stCurState.pCurMat = INVALID_MATERIAL; }