void CragStackCombiner::combine(const std::vector<Crag>& crags, Crag& crag) { LOG_USER(cragstackcombinerlog) << "combining CRAGs, " << (_requireBbOverlap ? "" : " do not ") << "require bounding box overlap" << std::endl; std::map<Crag::Node, Crag::Node> prevNodeMap; std::map<Crag::Node, Crag::Node> nextNodeMap; for (unsigned int z = 1; z < crags.size(); z++) { LOG_USER(cragstackcombinerlog) << "linking CRAG " << (z-1) << " and " << z << std::endl; if (z == 1) prevNodeMap = copyNodes(crags[0], crag); else prevNodeMap = nextNodeMap; nextNodeMap = copyNodes(crags[z], crag); std::vector<std::pair<Crag::Node, Crag::Node>> links = findLinks(crags[z-1], crags[z]); for (const auto& pair : links) crag.addAdjacencyEdge( prevNodeMap[pair.first], nextNodeMap[pair.second]); } }
void Oracle::operator()( const std::vector<double>& weights, double& value, std::vector<double>& gradient) { updateCosts(weights); MultiCut::Status status = _mostViolatedMulticut.solve(); std::stringstream filename; filename << "most-violated_" << std::setw(6) << std::setfill('0') << _iteration << ".tif"; _mostViolatedMulticut.storeSolution(filename.str(), true); if (status != MultiCut::SolutionFound) UTIL_THROW_EXCEPTION( Exception, "solution not found"); value = _constant - _mostViolatedMulticut.getValue(); // value = E(y',w) - E(y*,w) + Δ(y',y*) // = B_c - <wΦ,y*> + <Δ_l,y*> + Δ_c // loss = value - B_c + <wΦ,y*> // margin = value - loss double mostViolatedEnergy = 0; for (Crag::NodeIt n(_crag); n != lemon::INVALID; ++n) if (_mostViolatedMulticut.getSelectedRegions()[n]) mostViolatedEnergy += nodeCost(weights, _nodeFeatures[n]); for (Crag::EdgeIt e(_crag); e != lemon::INVALID; ++e) if (_mostViolatedMulticut.getMergedEdges()[e]) mostViolatedEnergy += edgeCost(weights, _edgeFeatures[e]); double loss = value - _B_c + mostViolatedEnergy; double margin = value - loss; LOG_USER(oraclelog) << "Δ(y*) = " << loss << std::endl; LOG_USER(oraclelog) << "E(y') - E(y*) = " << margin << std::endl; accumulateGradient(gradient); if (optionStoreEachCurrentlyBest) { _currentBestMulticut.solve(); std::stringstream filename; filename << "current-best_" << std::setw(6) << std::setfill('0') << _iteration << ".tif"; _currentBestMulticut.storeSolution(filename.str(), true); } _iteration++; }
int arc_ocd_examine(struct target *target) { uint32_t status; struct arc32_common *arc32 = target_to_arc32(target); LOG_DEBUG("-"); CHECK_RETVAL(arc_jtag_startup(&arc32->jtag_info)); if (!target_was_examined(target)) { /* read ARC core info */ if (strncmp(target_name(target), ARCEM_STR, 6) == 0) { arc32->processor_type = ARCEM_NUM; LOG_USER("Processor type: %s", ARCEM_STR); } else if (strncmp(target_name(target), ARC600_STR, 6) == 0) { arc32->processor_type = ARC600_NUM; LOG_USER("Processor type: %s", ARC600_STR); } else if (strncmp(target_name(target), ARC700_STR, 6) == 0) { arc32->processor_type = ARC700_NUM; LOG_USER("Processor type: %s", ARC700_STR); } else { LOG_WARNING(" THIS IS A UNSUPPORTED TARGET: %s", target_name(target)); } CHECK_RETVAL(arc_jtag_status(&arc32->jtag_info, &status)); if (status & ARC_JTAG_STAT_RU) { target->state = TARGET_RUNNING; } else { /* It is first time we examine the target, it is halted * and we don't know why. Let's set debug reason, * otherwise OpenOCD will complain that reason is * unknown. */ if (target->state == TARGET_UNKNOWN) target->debug_reason = DBG_REASON_DBGRQ; target->state = TARGET_HALTED; } /* Read BCRs and configure optinal registers. */ CHECK_RETVAL(arc_regs_read_bcrs(target)); arc_regs_build_reg_list(target); CHECK_RETVAL(arc32_configure(target)); target_set_examined(target); } return ERROR_OK; }
void ImageStackPainter::setCurrentSection(unsigned int section) { if (_showColored) return; if (!_stack || _stack->size() == 0 || _imagePainters.size() == 0) return; _section = std::min(section, _stack->size() - 1); for (unsigned int i = 0; i < _numImages; i++) { int imageIndex = std::max(std::min(static_cast<int>(_section) + static_cast<int>(i - _numImages/2), static_cast<int>(_stack->size()) - 1), 0); LOG_ALL(imagestackpainterlog) << "index for image " << i << " is " << imageIndex << std::endl; _imagePainters[i]->setImage((*_stack)[imageIndex]); if ((*_stack)[imageIndex]->getIdentifier() != "") LOG_USER(imagestackpainterlog) << "showing image " << (*_stack)[imageIndex]->getIdentifier() << std::endl; } util::rect<double> size = _imagePainters[0]->getSize(); _imageHeight = size.height(); size.minY -= _numImages/2*_imageHeight + _numImages*_gap/2; size.maxY += (_numImages/2 - (_numImages + 1)%2)*_imageHeight + _numImages*_gap/2; setSize(size); LOG_ALL(imagestackpainterlog) << "current section set to " << _section << std::endl; }
void MeshViewController::addMesh(float label) { LOG_USER(meshviewcontrollerlog) << "showing label " << label << std::endl; if (_meshCache.count(label)) { _meshes->add(label, _meshCache[label]); return; } typedef ExplicitVolumeLabelAdaptor<ExplicitVolume<float>> Adaptor; Adaptor adaptor(*_labels, label); sg_gui::MarchingCubes<Adaptor> marchingCubes; std::shared_ptr<sg_gui::Mesh> mesh = marchingCubes.generateSurface( adaptor, sg_gui::MarchingCubes<Adaptor>::AcceptAbove(0), optionCubeSize, optionCubeSize, optionCubeSize); _meshes->add(label, mesh); _meshCache[label] = mesh; }
int Message_Unit::process_client_buffer(Block_Buffer &buf) { msg_tick_ = Time_Value::gettimeofday(); int cid = 0; uint32_t len = 0; uint32_t msg_id = 0; uint32_t serial_cipher = 0; uint32_t msg_time_cipher = 0; if (buf.read_int32(cid) || buf.read_uint32(len) || buf.read_uint32(msg_id) || buf.read_uint32(serial_cipher) || buf.read_uint32(msg_time_cipher)) { LOG_USER("deserialize error, cid:%d len:%d msg_id:%d", cid, len, msg_id); monitor()->close_client_by_cid(cid, Time_Value(2), 10000101); return -1; } process_client_msg(msg_id, cid, buf, serial_cipher, msg_time_cipher); count_process_time(msg_id); return 0; }
void Epoll_Watcher::process_timer_event(void) { GUARD(Mutex, mon, tq_lock_); if (end_flag_ == 1) return ; Event_Handler *evh = 0; while (1) { if (tq_.empty()) break; if ((evh = this->tq_.top()) == 0) { LOG_USER("evh == 0"); continue; } Time_Value now(Time_Value::gettimeofday()); if (evh->get_absolute_tv() <= now) { this->tq_.pop(); evh->handle_timeout(now); if (! (evh->get_timer_flag() & EVENT_ONCE_TIMER)) { now += evh->get_relative_tv(); evh->set_tv(now); this->tq_.push(evh); } else { timer_set_.erase(evh); evh->handle_remove(); } } else { break; } } }
/** Logs summary of ARMv7-M state for a halted target. */ int armv7m_arch_state(struct target *target) { struct armv7m_common *armv7m = target_to_armv7m(target); struct arm *arm = &armv7m->arm; uint32_t ctrl, sp; /* avoid filling log waiting for fileio reply */ if (arm->semihosting_hit_fileio) return ERROR_OK; ctrl = buf_get_u32(arm->core_cache->reg_list[ARMV7M_CONTROL].value, 0, 32); sp = buf_get_u32(arm->core_cache->reg_list[ARMV7M_R13].value, 0, 32); LOG_USER("target halted due to %s, current mode: %s %s\n" "xPSR: %#8.8" PRIx32 " pc: %#8.8" PRIx32 " %csp: %#8.8" PRIx32 "%s%s", debug_reason_name(target), arm_mode_name(arm->core_mode), armv7m_exception_string(armv7m->exception_number), buf_get_u32(arm->cpsr->value, 0, 32), buf_get_u32(arm->pc->value, 0, 32), (ctrl & 0x02) ? 'p' : 'm', sp, arm->is_semihosting ? ", semihosting" : "", arm->is_semihosting_fileio ? " fileio" : ""); return ERROR_OK; }
/** Logs summary of ARM920 state for a halted target. */ int arm920t_arch_state(struct target *target) { static const char *state[] = { "disabled", "enabled" }; struct arm920t_common *arm920t = target_to_arm920(target); struct arm *armv4_5; if (arm920t->common_magic != ARM920T_COMMON_MAGIC) { LOG_ERROR("BUG: %s", arm920_not); return ERROR_TARGET_INVALID; } armv4_5 = &arm920t->arm7_9_common.armv4_5_common; arm_arch_state(target); LOG_USER("MMU: %s, D-Cache: %s, I-Cache: %s", state[arm920t->armv4_5_mmu.mmu_enabled], state[arm920t->armv4_5_mmu.armv4_5_cache.d_u_cache_enabled], state[arm920t->armv4_5_mmu.armv4_5_cache.i_cache_enabled]); return ERROR_OK; }
static int jim_echo(Jim_Interp *interp, int argc, Jim_Obj *const *argv) { if (argc != 2) return JIM_ERR; const char *str = Jim_GetString(argv[1], NULL); LOG_USER("%s", str); return JIM_OK; }
int avr32_ap7k_arch_state(struct target *target) { struct avr32_ap7k_common *ap7k = target_to_ap7k(target); LOG_USER("target halted due to %s, pc: 0x%8.8" PRIx32 "", debug_reason_name(target), ap7k->jtag.dpc); return ERROR_OK; }
int lakemont_arch_state(struct target *t) { struct x86_32_common *x86_32 = target_to_x86_32(t); LOG_USER("target halted due to %s at 0x%08" PRIx32 " in %s mode", debug_reason_name(t), buf_get_u32(x86_32->cache->reg_list[EIP].value, 0, 32), (buf_get_u32(x86_32->cache->reg_list[CR0].value, 0, 32) & CR0_PE) ? "protected" : "real"); return ERROR_OK; }
void LogManager::printChannels() { if (LogChannel::getChannels()->size() == 0) { LOG_USER(out) << "No output channels for this application available." << std::endl; return; } std::string prevChannelName = ""; LOG_USER(out) << std::endl << "Valid output channels are:" << std::endl << "\t"; for (channel_it i = LogChannel::getChannels()->begin(); i != LogChannel::getChannels()->end(); i++) { if ((*i)->getName() != prevChannelName) { LOG_USER(out) << (*i)->getName() << " "; prevChannelName = (*i)->getName(); } } LOG_USER(out) << std::endl << std::endl; }
int mips32_arch_state(struct target *target) { struct mips32_common *mips32 = target_to_mips32(target); LOG_USER("target halted in %s mode due to %s, pc: 0x%8.8" PRIx32 "", mips_isa_strings[mips32->isa_mode], debug_reason_name(target), buf_get_u32(mips32->core_cache->reg_list[MIPS32_PC].value, 0, 32)); return ERROR_OK; }
int zy1000_speed(int speed) { if(speed == 0) { /*0 means RCLK*/ speed = 0; ZY1000_POKE(ZY1000_JTAG_BASE+0x10, 0x100); LOG_DEBUG("jtag_speed using RCLK"); } else { if(speed > 8190 || speed < 2) { LOG_USER("valid ZY1000 jtag_speed=[8190,2]. Divisor is 64MHz / even values between 8190-2, i.e. min 7814Hz, max 32MHz"); return ERROR_INVALID_ARGUMENTS; } LOG_USER("jtag_speed %d => JTAG clk=%f", speed, 64.0/(float)speed); ZY1000_POKE(ZY1000_JTAG_BASE+0x14, 0x100); ZY1000_POKE(ZY1000_JTAG_BASE+0x1c, speed&~1); } return ERROR_OK; }
void AdjacencyAnnotator::pruneChildEdges(Crag& crag) { std::vector<Crag::CragEdge> siblingEdges; for (Crag::CragEdge e : crag.edges()) if (isSiblingEdge(crag, e)) siblingEdges.push_back(e); for (Crag::CragEdge e : siblingEdges) crag.erase(e); LOG_USER(adjacencyannotatorlog) << "pruned " << siblingEdges.size() << " child adjacency edges" << std::endl; }
static int do_resume(struct target *t) { /* needs proper handling later */ t->state = TARGET_DEBUG_RUNNING; if (restore_context(t) != ERROR_OK) return ERROR_FAIL; if (exit_probemode(t) != ERROR_OK) return ERROR_FAIL; t->state = TARGET_RUNNING; t->debug_reason = DBG_REASON_NOTHALTED; LOG_USER("target running"); return target_call_event_callbacks(t, TARGET_EVENT_RESUMED); }
void AdjacencyAnnotator::propagateLeafAdjacencies(Crag& crag) { _numAdded = 0; for (Crag::CragNode n : crag.nodes()) if (crag.isRootNode(n)) recurseAdjacencies(crag, n); if (optionPruneChildEdges) pruneChildEdges(crag); LOG_USER(adjacencyannotatorlog) << "added " << _numAdded << " super node adjacency edges" << std::endl; }
/* architecture specific status reply */ static int arm11_arch_state(struct target *target) { struct arm11_common *arm11 = target_to_arm11(target); int retval; retval = arm_arch_state(target); /* REVISIT also display ARM11-specific MMU and cache status ... */ if (target->debug_reason == DBG_REASON_WATCHPOINT) LOG_USER("Watchpoint triggered at PC %#08x", (unsigned) arm11->dpm.wp_pc); return retval; }
static int arm720t_arch_state(struct target *target) { struct arm720t_common *arm720t = target_to_arm720(target); static const char *state[] = { "disabled", "enabled" }; arm_arch_state(target); LOG_USER("MMU: %s, Cache: %s", state[arm720t->armv4_5_mmu.mmu_enabled], state[arm720t->armv4_5_mmu.armv4_5_cache.d_u_cache_enabled]); return ERROR_OK; }
void QuadraticSolver::solve() { double value; std::string message; if (_solver->solve(*_solution, value, message)) { LOG_USER(quadraticsolverlog) << "optimal solution found" << std::endl; } else { LOG_ERROR(quadraticsolverlog) << "error: " << message << std::endl; } }
static int exit_probemode(struct target *t) { uint32_t tapstatus = get_tapstatus(t); LOG_DEBUG("TS before PM exit = 0x%08" PRIx32, tapstatus); if (!(tapstatus & TS_PM_BIT)) { LOG_USER("core not in PM"); return ERROR_OK; } scan.out[0] = PROBEMODE; if (irscan(t, scan.out, NULL, LMT_IRLEN) != ERROR_OK) return ERROR_FAIL; scan.out[0] = 0; if (drscan(t, scan.out, scan.in, 1) != ERROR_OK) return ERROR_FAIL; return ERROR_OK; }
int zy1000_init(void) { LOG_USER("%s", ZYLIN_OPENOCD_VERSION); ZY1000_POKE(ZY1000_JTAG_BASE+0x10, 0x30); // Turn on LED1 & LED2 setPower(true); // on by default /* deassert resets. Important to avoid infinite loop waiting for SRST to deassert */ zy1000_reset(0, 0); zy1000_speed(jtag_speed); bitbang_interface = &zy1000_bitbang; return ERROR_OK; }
int main(int optionc, char** optionv) { try { /******** * INIT * ********/ // init command line parser util::ProgramOptions::init(optionc, optionv); // init logger logger::LogManager::init(); LOG_USER(logger::out) << "[main] starting..." << std::endl; // read hashes and their coefs std::vector<SegmentHash> hashes = readVariables(optionLabels.as<std::string>()); std::map<SegmentHash, double> coefs = readCoefficients(optionTedCoefficientFile.as<std::string>()); // assemble cost_function.txt std::ofstream costFunctionFile(optionCostFunctionFile.as<std::string>()); double constant = 0; costFunctionFile << "numVar " << hashes.size() << std::endl; for (unsigned int i = 0; i < hashes.size(); i++) { double coef = coefs[hashes[i]]; costFunctionFile << "c" << i << " " << coef << std::endl; if (coef < 0) constant += -coef; } costFunctionFile << "constant " << constant << std::endl; /********* * SETUP * *********/ } catch (Exception& e) { handleException(e, std::cerr); } }
int Epoll_Watcher::handle_timeout(const Time_Value &tv) { GUARD(Mutex, mon, io_lock_); std::vector<Event_Handler *> remove_vec; for (Heart_Map::iterator it = io_heart_map_[io_heart_idx_].begin(); it != io_heart_map_[io_heart_idx_].end(); ++it) { remove_vec.push_back(it->second); } for (std::vector<Event_Handler *>::iterator it = remove_vec.begin(); it != remove_vec.end(); ++it) { LOG_USER("handle_close timeout, fd:%d", (*it)->get_fd()); (*it)->handle_close(Link_Close(LINK_CLOSE_TIMEOUT, 0)); } io_heart_map_[io_heart_idx_].clear(); io_heart_idx_ = next_heart_idx(); return 0; }
static int dsp5680xx_build_sector_list(struct flash_bank *bank) { uint32_t offset = HFM_FLASH_BASE_ADDR; bank->sectors = malloc(sizeof(struct flash_sector) * bank->num_sectors); int i; for (i = 0; i < bank->num_sectors; ++i) { bank->sectors[i].offset = i * HFM_SECTOR_SIZE; bank->sectors[i].size = HFM_SECTOR_SIZE; offset += bank->sectors[i].size; bank->sectors[i].is_erased = -1; bank->sectors[i].is_protected = -1; } LOG_USER("%s not tested yet.", __func__); return ERROR_OK; }
void LinearSolver::solve() { double value; std::string message; if (_solver->solve(*_solution, value, message)) { LOG_USER(linearsolverlog) << "optimal solution found" << std::endl; } else { LOG_ERROR(linearsolverlog) << "error: " << message << std::endl; } LOG_ALL(linearsolverlog) << "solution: " << _solution->getVector() << std::endl; }
int Message_Unit::process_timer_buffer(Block_Buffer &buf) { msg_tick_ = Time_Value::gettimeofday(); uint32_t len = 0; uint32_t msg_id = 0; if (buf.read_uint32(len) || buf.read_uint32(msg_id)) { LOG_USER("deserialize error, cid:%d len:%d msg_id:%d", len, msg_id); return -1; } process_timer_msg(msg_id, buf, msg_tick_); count_process_time(msg_id); return 0; }
static void command_help_show_wrap(const char *str, unsigned n, unsigned n2) { const char *cp = str, *last = str; while (*cp) { const char *next = last; do { cp = next; do { next++; } while (*next != ' ' && *next != '\t' && *next != '\0'); } while ((next - last < HELP_LINE_WIDTH(n)) && *next != '\0'); if (next - last < HELP_LINE_WIDTH(n)) cp = next; command_help_show_indent(n); LOG_USER("%.*s", (int)(cp - last), last); last = cp + 1; n = n2; } }
int arm_arch_state(struct target *target) { struct arm *arm = target_to_arm(target); if (arm->common_magic != ARM_COMMON_MAGIC) { LOG_ERROR("BUG: called for a non-ARM target"); return ERROR_FAIL; } LOG_USER("target halted in %s state due to %s, current mode: %s\n" "cpsr: 0x%8.8" PRIx32 " pc: 0x%8.8" PRIx32 "%s", arm_state_strings[arm->core_state], debug_reason_name(target), arm_mode_name(arm->core_mode), buf_get_u32(arm->cpsr->value, 0, 32), buf_get_u32(arm->pc->value, 0, 32), arm->is_semihosting ? ", semihosting" : ""); return ERROR_OK; }