void LibraryWatcher::AddDirectory(const Directory& dir, const SubdirectoryList& subdirs) { watched_dirs_[dir.id] = dir; if (subdirs.isEmpty()) { // This is a new directory that we've never seen before. // Scan it fully. ScanTransaction transaction(this, dir.id, false); transaction.SetKnownSubdirs(subdirs); transaction.AddToProgressMax(1); ScanSubdirectory(dir.path, Subdirectory(), &transaction); } else { // We can do an incremental scan - looking at the mtimes of each // subdirectory and only rescan if the directory has changed. ScanTransaction transaction(this, dir.id, true); transaction.SetKnownSubdirs(subdirs); transaction.AddToProgressMax(subdirs.count()); for (const Subdirectory& subdir : subdirs) { if (stop_requested_) return; if (scan_on_startup_) ScanSubdirectory(subdir.path, subdir, &transaction); if (monitor_) AddWatch(dir, subdir.path); } } emit CompilationsNeedUpdating(); }
void DebuggerTree::OnAddWatch(wxCommandEvent& event) { EditWatchDlg dlg; PlaceWindow(&dlg); if (dlg.ShowModal() == wxID_OK && !dlg.GetWatch().keyword.IsEmpty()) AddWatch(dlg.GetWatch().keyword, dlg.GetWatch().format); }
void LibraryWatcher::ReloadSettings() { const bool was_monitoring_before = monitor_; QSettings s; s.beginGroup(kSettingsGroup); scan_on_startup_ = s.value("startup_scan", true).toBool(); monitor_ = s.value("monitor", true).toBool(); best_image_filters_.clear(); QStringList filters = s.value("cover_art_patterns", QStringList() << "front" << "cover").toStringList(); for (const QString& filter : filters) { QString s = filter.trimmed(); if (!s.isEmpty()) best_image_filters_ << s; } if (!monitor_ && was_monitoring_before) { fs_watcher_->Clear(); } else if (monitor_ && !was_monitoring_before) { // Add all directories to all QFileSystemWatchers again for (const Directory& dir : watched_dirs_.values()) { SubdirectoryList subdirs = backend_->SubdirsInDirectory(dir.id); for (const Subdirectory& subdir : subdirs) { AddWatch(dir, subdir.path); } } } }
void AddWatchRecursive(const std::string &path, int level) { DIR *dir = opendir(path.c_str()); if (!dir) return; std::vector<std::string> subdirs; for (;;) { struct dirent *de = readdir(dir); if (!de) break; if (de->d_type == DT_DIR && strcmp(de->d_name, ".") != 0 && strcmp(de->d_name, "..") != 0) subdirs.emplace_back(de->d_name); } closedir(dir); // first set watches on all at current level, and only then recurse deeper std::string subpath; for (const auto &subdir : subdirs) { subpath = path; if (!subpath.empty() && subpath[subpath.size()-1] != '/') subpath+= '/'; subpath+= subdir; AddWatch(subpath.c_str()); } if (level < 128 && _watches.size() < 0x100) { for (const auto &subdir : subdirs) { subpath = path; if (!subpath.empty() && subpath[subpath.size()-1] != '/') subpath+= '/'; subpath+= subdir; AddWatchRecursive(subpath, level + 1); } } }
static void ToggleWatch(DBusWatch *aWatch, void *aData) { if (dbus_watch_get_enabled(aWatch)) { AddWatch(aWatch, aData); } else { RemoveWatch(aWatch, aData); } }
void WatchWidget::OnItemChanged(QTableWidgetItem* item) { if (m_updating || item->data(Qt::UserRole).isNull()) return; int row = item->data(Qt::UserRole).toInt(); int column = item->data(Qt::UserRole + 1).toInt(); if (row == -1) { if (!item->text().isEmpty()) { AddWatch(item->text(), 0); Update(); return; } } else { switch (column) { // Label case 0: if (item->text().isEmpty()) DeleteWatch(row); else PowerPC::debug_interface.UpdateWatchName(row, item->text().toStdString()); break; // Address // Hexadecimal // Decimal case 1: case 2: case 3: { bool good; quint32 value = item->text().toUInt(&good, column < 3 ? 16 : 10); if (good) { if (column == 1) PowerPC::debug_interface.UpdateWatchAddress(row, value); else PowerPC::HostWrite_U32(value, PowerPC::debug_interface.GetWatch(row).address); } else { QMessageBox::critical(this, tr("Error"), tr("Invalid input provided")); } break; } } Update(); } }
void CAccelerometer::watchAcceleration(int callbackID, const AccelerometerOptions& accelerometerOptions, uint32 watchID) { IwTrace(WM_MODULE_ACCEL,("watchAcceleration (callbackID: %d, watchID %u)", callbackID, watchID)); if (CheckAccelerometerStatus()) { Acceleration acc(0.0f, 0.0f, 0.0f, 0); getAccelValues(acc); CWMWatchData* wd = new CWMWatchData(watchID, callbackID, accelerometerOptions.frequency, accelerometerCallback); AddWatch(wd); accelerometerSuccess(callbackID, acc); } else accelerometerError(callbackID); }
void DebuggerTree::OnLoadWatchFile(wxCommandEvent& event) { WatchesArray fromFile = m_Watches; // copy current watches // ToDo: // - Currently each watch is imported as WatchType "Unspecified". This should // be changed that the file contains another (optional) column with the type. // - Change "Watch files" format to XML? // - With the current implementation sometimes the debugger tree gets weird. // - (Maybe) verify that watches are not already present? wxString fname; wxFileDialog dlg (Manager::Get()->GetAppWindow(), _T("Load debugger watch file"), _T(""), _T(""), _T("Watch files (*.watch)|*.watch|Any file (*)|*"), wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_CHANGE_DIR | compatibility::wxHideReadonly); PlaceWindow(&dlg); if (dlg.ShowModal() != wxID_OK) return; wxTextFile tf(dlg.GetPath()); if (tf.Open()) { // iterate over each line of file and send to debugger wxString cmd = tf.GetFirstLine(); while(true) { if (!cmd.IsEmpty()) // Skip empty lines { // Manager::Get()->GetLogManager()->DebugLog(_T("Adding watch \"%s\" to debugger:"), keyword); AddWatch(cmd, Undefined, false); // do not notify about new watch (we 'll do it when done) } if (tf.Eof()) break; cmd = tf.GetNextLine(); } tf.Close(); // release file handle // notify about changed watches NotifyForChangedWatches(); } else Manager::Get()->GetLogManager()->DebugLog(_T("Error opening debugger watch file: ") + fname); }
void UserTable::Load() { m_tab.Load(m_fSysTable ? IncronTab::GetSystemTablePath(m_user) : IncronTab::GetUserTablePath(m_user)); int cnt = m_tab.GetCount(); for (int i=0; i<cnt; i++) { IncronTabEntry& rE = m_tab.GetEntry(i); TPathList Paths; if (m_recursive && IsDirectory(rE.GetPath())) GetDirectoryTree(rE.GetPath(), Paths); else Paths.push_back(rE.GetPath()); for (TPathList::const_iterator iter = Paths.begin(); iter != Paths.end(); ++iter) { AddWatch(*iter, &rE); } } m_pEd->Register(this); }
WinPortFSNotify(LPCWSTR lpPathName, BOOL bWatchSubtree, DWORD dwNotifyFilter) : WinPortEvent(true, false), _watcher(0), _fd(-1), _filter(dwNotifyFilter), _watching(false) { #if defined(__APPLE__) || defined(__FreeBSD__) _fd = kqueue(); if (_fd == -1) return; #else _fd = inotify_init1(IN_CLOEXEC | IN_NONBLOCK); if (_fd == -1) return; #endif AddWatch( Wide2MB(lpPathName).c_str() ); if (bWatchSubtree) { AddWatchRecursive(Wide2MB(lpPathName), 0); } if (!_watches.empty() && pipe_cloexec(_pipe)==0) { #if defined(__APPLE__) || defined(__FreeBSD__) _events.emplace_back(); EV_SET(&_events.back(), _pipe[0], EVFILT_READ, EV_ADD | EV_ENABLE | EV_ONESHOT, 0, 0, 0); #endif _watching = true; if (pthread_create(&_watcher, nullptr, sWatcherProc, this)==0) { fprintf(stderr, "WinPortFSNotify('%ls') - watching\n", lpPathName); } else { fprintf(stderr, "WinPortFSNotify('%ls') - pthread error %u\n", lpPathName, errno); close(_pipe[0]); close(_pipe[1]); _watching = false; } } else { fprintf(stderr, "WinPortFSNotify('%ls') - not watching\n", lpPathName); } }
void *csPluginFileWatch::Entry(void) { if (fd_inotify == -1) return NULL; dirty_timer->Start(); ssize_t len; for ( ;; ) { if ((len = InotifyRead()) < 0) break; else { uint8_t *ptr = buffer; struct inotify_event *iev = (struct inotify_event *)ptr; while (len > 0) { InotifyEvent(iev); ptr += sizeof(struct inotify_event) + iev->len; len -= sizeof(struct inotify_event) + iev->len; iev = (struct inotify_event *)ptr; } } csEvent *event = EventPopWait(500); if (event == NULL) continue; switch (event->GetId()) { case csEVENT_QUIT: delete event; return NULL; case csEVENT_TIMER: { csTimer *timer = static_cast<csTimerEvent *>(event)->GetTimer(); if (timer->GetId() == _DIRTY_TIMER_ID) { csLog::Log(csLog::Debug, "%s: Initializing watches", name.c_str()); for (vector<csInotifyConf *>::iterator i = dirty_conf.begin(); i != dirty_conf.end(); i++) { try { if (!AddWatch((*i))) continue; } catch (csException &e) { delete (*i); csLog::Log(csLog::Warning, "%s: Error creating watch: %s: %s", name.c_str(), e.estring.c_str(), e.what()); } dirty_conf.erase(i); i = dirty_conf.begin(); if (i == dirty_conf.end()) break; } for (vector<csInotifyWatch *>::iterator i = watch.begin(); i != watch.end(); i++) (*i)->Initialize(fd_inotify); break; } map<string, csActionGroup *>::iterator i; for (i = action_group.begin(); i != action_group.end(); i++) { if (*(i->second) != timer->GetId()) continue; i->second->Execute(this, parent); break; } break; } #if 1 case csEVENT_PLUGIN: { csEventPlugin *event_plugin = static_cast<csEventPlugin *>(event); string type(""), source(""); event_plugin->GetValue("event_type", type); event_plugin->GetValue("event_source", source); csLog::Log(csLog::Debug, "%s: Plugin event: %s, source: %s", name.c_str(), type.c_str(), source.c_str()); break; } #endif default: break; } delete event; } return NULL; }
//ab Add Breakpoint //rb Remove Breakpoint //sp Suspend void SQDbgServer::ParseMsg(const char *msg) { switch(*((unsigned short *)msg)){ case MSG_ID('a','b'): { BreakPoint bp; if(ParseBreakpoint(msg+3,bp)){ AddBreakpoint(bp); scprintf(_SC("added bp %d %s\n"),bp._line,bp._src.c_str()); } else scprintf(_SC("error parsing add breakpoint")); } break; case MSG_ID('r','b'): { BreakPoint bp; if(ParseBreakpoint(msg+3,bp)){ RemoveBreakpoint(bp); scprintf(_SC("removed bp %d %s\n"),bp._line,bp._src.c_str()); }else scprintf(_SC("error parsing remove breakpoint")); } break; case MSG_ID('g','o'): if(_state!=eDBG_Running){ _state=eDBG_Running; BeginDocument(); BeginElement(_SC("resumed")); EndElement(_SC("resumed")); EndDocument(); // Send(_SC("<resumed/>\r\n")); scprintf(_SC("go (execution resumed)\n")); } break; case MSG_ID('s','p'): if(_state!=eDBG_Suspended){ _state=eDBG_Suspended; scprintf(_SC("suspend\n")); } break; case MSG_ID('s','o'): if(_state==eDBG_Suspended){ _state=eDBG_StepOver; } break; case MSG_ID('s','i'): if(_state==eDBG_Suspended){ _state=eDBG_StepInto; scprintf(_SC("step into\n")); } break; case MSG_ID('s','r'): if(_state==eDBG_Suspended){ _state=eDBG_StepReturn; scprintf(_SC("step return\n")); } break; case MSG_ID('d','i'): if(_state!=eDBG_Disabled){ _state=eDBG_Disabled; scprintf(_SC("disabled\n")); } break; case MSG_ID('a','w'): { Watch w; if(ParseWatch(msg+3,w)) { AddWatch(w); scprintf(_SC("added watch %d %s\n"),w._id,w._exp.c_str()); } else scprintf(_SC("error parsing add watch")); } break; case MSG_ID('r','w'): { int id; if(ParseRemoveWatch(msg+3,id)) { RemoveWatch(id); scprintf(_SC("added watch %d\n"),id); } else scprintf(_SC("error parsing remove watch")); } break; case MSG_ID('t','r'): scprintf(_SC("terminate from user\n")); break; case MSG_ID('r','d'): scprintf(_SC("ready\n")); _ready=true; break; default: scprintf(_SC("unknown packet")); } }