void BindingManager::visitAllPyObjects(ObjectVisitor visitor, void* data) { WrapperMap copy = m_d->wrapperMapper; for (WrapperMap::iterator it = copy.begin(); it != copy.end(); ++it) { if (hasWrapper(it->first)) visitor(it->second, data); } }
static void showWrapperMap(const WrapperMap& wrapperMap) { if (Py_VerboseFlag > 0) { fprintf(stderr, "-------------------------------\n"); fprintf(stderr, "WrapperMap: %p (size: %d)\n", &wrapperMap, (int) wrapperMap.size()); WrapperMap::const_iterator iter; for (iter = wrapperMap.begin(); iter != wrapperMap.end(); ++iter) { fprintf(stderr, "key: %p, value: %p (%s, refcnt: %d)\n", iter->first, iter->second, Py_TYPE(iter->second)->tp_name, (int) ((PyObject*)iter->second)->ob_refcnt); } fprintf(stderr, "-------------------------------\n"); } }
//-------------------------------------------------------------- /// Generates XML that describes the injected processes and which /// plugins were injected. /// \return string containing the XML //-------------------------------------------------------------- gtASCIIString ProcessTracker::GetProcessesXML() { std::unordered_map< DWORD, gtASCIIString > procXMLMap; this->UpdateListOfInjectedProcesses(); ProcessInfoList injectedProcesses = this->GetListOfInjectedProcesses(); WrapperMap wrappers = GetWrapperMap(); // the strPlatform is named this way to match options in the client. #ifdef X64 gtASCIIString strPlatform = "Win64"; #else gtASCIIString strPlatform = "Win32"; #endif #ifndef CODEXL_GRAPHICS if (injectedProcesses.empty() == true) { LogConsole(logERROR, "There are no processes running which have been injected with the GPU PerfStudio server plugin\n"); LogConsole(logERROR, "Please ensure that the server has the same bitness as the target application\n"); LogConsole(logERROR, "For example, use the 64-bit GPU PerfStudio server with a 64-bit application\n"); } #endif for (ProcessInfoList::iterator procIter = injectedProcesses.begin(); procIter != injectedProcesses.end(); ++procIter) { DWORD pid = procIter->th32ProcessID; // only add the process info if it wasn't already found. if (procXMLMap.find(pid) == procXMLMap.end()) { // insert new process and the process info gtASCIIString tmpString = XML("Name", XMLEscape(procIter->szExeFile).asCharArray()); tmpString += XML("PID", pid); tmpString += XML("Path", XMLEscape(procIter->szPath).asCharArray()); tmpString += XML("Platform", strPlatform.asCharArray()); procXMLMap[ pid ] = tmpString; // if this process is the one that was launched, then we know what the args and working directory were. // we could probably get the actual args and working dir from MicroDLL if it is a different app though, which // would be the case if this app uses a launcher app. if (m_injectedAppName.compare(procIter->szPath) == 0) { tmpString = XML("Args", XMLEscape(m_injectedAppArgs.c_str()).asCharArray()); tmpString += XML("WDir", XMLEscape(m_injectedAppDir.c_str()).asCharArray()); procXMLMap[ pid ] += tmpString.asCharArray(); } } // add an API node for each of the wrappers that are injected into the app for (WrapperMap::const_iterator wrapperIter = wrappers.begin(); wrapperIter != wrappers.end(); ++wrapperIter) { // List of plugin extensions to check for. On Windows, test for 32 and 64 bit plugins. // On linux, just check for the plugin corresponding to the server bitness static const char* pluginExtensions[] = { #ifdef WIN32 GDT_DEBUG_SUFFIX GDT_BUILD_SUFFIX "." DLL_EXTENSION, "-x64" GDT_DEBUG_SUFFIX GDT_BUILD_SUFFIX "." DLL_EXTENSION #else GDT_PROJECT_SUFFIX "." DLL_EXTENSION #endif }; int numPlugins = sizeof(pluginExtensions) / sizeof(pluginExtensions[0]); for (int loop = 0; loop < numPlugins; loop++) { // check to see if this wrapper is in the application gtASCIIString strPluginName = wrapperIter->second.strPluginName; if (SG_GET_BOOL(OptionDllReplacement) == false) { strPluginName += pluginExtensions[loop]; } if (IsLibraryLoadedInProcess(pid, strPluginName.asCharArray(), NULL)) { bool attached = false; if (g_activeWrappersMap.find(FormatText("%lu/%s", pid, wrapperIter->first.c_str()).asCharArray()) != g_activeWrappersMap.end()) { // the pid/plugin string was listed in the active wrappers map, so the plugin must be active. attached = true; } procXMLMap[pid] += XMLAttrib("API", FormatText("attached='%s'", attached ? "TRUE" : "FALSE").asCharArray(), wrapperIter->second.strPluginShortDesc.asCharArray()); } } } } // concatenate the process XML and additional info gtASCIIString xml; for (std::unordered_map< DWORD, gtASCIIString >::iterator iterP = procXMLMap.begin(); iterP != procXMLMap.end(); iterP++) { xml += XML("Process", (iterP->second).asCharArray()); } gtASCIIString out = XMLHeader(); out += XML("ProcessList", xml.asCharArray()); return out; }