int main(int argc, char* argv[]){ // I hate everything setbuf(stdout, NULL); unsigned char val = 0xff; // Set memory (base memory and the utility page) memory = setup_mem(); if(memory == NULL){ printf("[Error] Unable to get valid memory!\n"); exit(1); } memset(memory,val,PAGE_SIZE*PAGES); memset(mpage,val,PAGE_SIZE); run = 0; printf("[Info] Memory starts at %p, pfn %i.\n" "[Info] Set as %iMB byte region, value of 0x%02X.\n", memory,_read_pagemap(memory),(PAGE_SIZE*PAGES)/(1024*1024),val); printf("[Info] Running %i iterations.\n",NUM_ITERS); #ifdef VARY_DELTA run_vary_delta(); #elif defined(HAMMER_ADDR) hammer_addr(); #else run_all_pairs(); #endif }
int spead_api_callback(struct spead_api_module_shared *s, struct spead_item_group *ig, void *data) { struct sapi_o *o; struct spead_api_item *itm; float2 *pow; int i,j; o = data; if (o == NULL){ return -1; } itm = get_spead_item_with_id(ig, SPEAD_DATA_ID); if (itm == NULL) return -1; if (o->o_data == NULL){ if (setup_mem(o, itm->io_size) < 0){ return -1; } } memcpy(o->o_data + o->o_item_size*o->o_off*o->o_chunk, itm->io_data, o->o_item_size*o->o_chunk); o->o_off++; if (o->o_off == COUNT){ fprintf(stdout, "set term x11 size 1280,720\nset view map\nsplot '-' matrix with image\n"); for (j=0; j<o->o_count; j++){ pow = (float2*) (o->o_data + o->o_item_size*j*o->o_chunk); for (i=o->o_chunk/2; i<o->o_chunk; i++){ fprintf(stdout,"%0.11f ",pow[i].x); } fprintf(stdout, "\n"); } fprintf(stdout, "e\ne\n"); o->o_off = 0; } return 0; }
void MainWindow::updateFrames() { if (core == NULL) return; static bool first_time = true; if (first_time) { setup_mem(); this->add_output(" > Adding binary information to notepad"); notepadDock->setText("# Binary information\n\n" + core->cmd("i") + "\n" + core->cmd("ie") + "\n" + core->cmd("iM") + "\n"); //first_time = false; } else { refreshMem(""); } refreshFlagspaces(); auto spi = QAbstractItemView::ScrollPerItem; auto spp = QAbstractItemView::ScrollPerPixel; // TODO: make this configurable by the user? const bool use_scrollperpixel = true; if (use_scrollperpixel) { this->flagsDock->flagsTreeWidget->setVerticalScrollMode(spp); this->symbolsDock->symbolsTreeWidget->setVerticalScrollMode(spp); this->importsDock->importsTreeWidget->setVerticalScrollMode(spp); this->functionsDock->functionsTreeWidget->setVerticalScrollMode(spp); this->stringsDock->stringsTreeWidget->setVerticalScrollMode(spp); this->relocsDock->relocsTreeWidget->setVerticalScrollMode(spp); this->memoryDock->xreFromTreeWidget_2->setVerticalScrollMode(spp); this->memoryDock->xrefToTreeWidget_2->setVerticalScrollMode(spp); } else { this->flagsDock->flagsTreeWidget->setVerticalScrollMode(spi); this->symbolsDock->symbolsTreeWidget->setVerticalScrollMode(spi); this->importsDock->importsTreeWidget->setVerticalScrollMode(spi); this->functionsDock->functionsTreeWidget->setVerticalScrollMode(spi); this->stringsDock->stringsTreeWidget->setVerticalScrollMode(spi); this->relocsDock->relocsTreeWidget->setVerticalScrollMode(spi); this->memoryDock->xreFromTreeWidget_2->setVerticalScrollMode(spi); this->memoryDock->xrefToTreeWidget_2->setVerticalScrollMode(spi); } this->functionsDock->fillFunctions(); this->importsDock->fillImports(); // FIXME, doesn't work bc it sorts strings, not numbers... sigh /* Use QListWidgetItem::setData() not the constructor to set your value. Then all will work like you expect it to work. int yourIntValue = 123456; QListWidgetItem *item = new QListWidgetItem; item->setData(Qt::DisplayRole, yourIntValue); */ //this->importsDock->importsTreeWidget->sortByColumn(1, Qt::DescendingOrder); adjustColumns(this->importsDock->importsTreeWidget); this->relocsDock->relocsTreeWidget->clear(); for (auto i: core->getList ("bin","relocs")) { QStringList pieces = i.split (","); if (pieces.length()==3) appendRow(this->relocsDock->relocsTreeWidget, pieces[0], pieces[1], pieces[2]); } adjustColumns(this->relocsDock->relocsTreeWidget); this->symbolsDock->fillSymbols(); this->stringsDock->stringsTreeWidget->clear(); for (auto i : core->getList ("bin", "strings")) { QStringList pieces = i.split (","); if (pieces.length () == 2) appendRow(this->stringsDock->stringsTreeWidget, pieces[0], pieces[1]); } adjustColumns(this->stringsDock->stringsTreeWidget); this->commentsDock->commentsTreeWidget->clear(); QList<QList<QString>> comments = this->core->getComments(); for (QList<QString> comment: comments) { /* QString name; //this->add_debug_output("Comment: " + comment[1] + ": " + comment[0]); RAnalFunction *fcn = this->core->functionAt(comment[1].toLongLong(0, 16)); if (fcn != NULL) { name = fcn->name; } else { name = ""; } */ QString fcn_name = this->core->cmdFunctionAt(comment[1]); appendRow(this->commentsDock->commentsTreeWidget, comment[1], fcn_name, comment[0].remove('"')); } adjustColumns(this->commentsDock->commentsTreeWidget); // Add nested comments QMap<QString, QList<QList<QString>>> cmts = this->core->getNestedComments(); for(auto cmt : cmts.keys()) { QTreeWidgetItem *item = new QTreeWidgetItem(this->commentsDock->nestedCommentsTreeWidget); item->setText(0, cmt); QList<QList<QString>> meow = cmts.value(cmt); for (int i = 0; i < meow.size(); ++i) { QList<QString> tmp = meow.at(i); QTreeWidgetItem *it = new QTreeWidgetItem(); it->setText(0, tmp[1]); it->setText(1, tmp[0].remove('"')); item->addChild(it); } this->commentsDock->nestedCommentsTreeWidget->addTopLevelItem(item); } adjustColumns(this->commentsDock->nestedCommentsTreeWidget); // TODO: FIXME: Remove the check for first_time; if (first_time) { sectionsWidget->tree->clear(); int row = 0; for (auto i: core->getList("bin","sections")) { QStringList a = i.split (","); if (a.length()>2) { // Fix to work with ARM bins //if (a[4].startsWith(".")) { if (a[4].contains(".")) { QString addr = a[1]; QString addr_end = "0x0"+core->itoa(core->math(a[1]+"+"+a[2])); QString size = QString::number(core->math(a[2])); QString name = a[4]; this->sectionsWidget->fillSections(row, name, size, addr, addr_end); // Used to select a color for the sections graph if (row == 10) { row = 0; } else { row++; } } } } //adjustColumns(sectionsWidget->tree); sectionsWidget->adjustColumns(); first_time = false; this->dashboardDock->updateContents(); } }