| 181 | } |
| 182 | |
| 183 | void WinDbgMemoryProvider::querySessionInfo() |
| 184 | { |
| 185 | #ifdef _WIN32 |
| 186 | if (!m_client) return; |
| 187 | HRESULT hr; |
| 188 | |
| 189 | if (m_control) { |
| 190 | ULONG debugClass = 0, debugQualifier = 0; |
| 191 | hr = m_control->GetDebuggeeType(&debugClass, &debugQualifier); |
| 192 | qDebug() << "[WinDbg] GetDebuggeeType hr=" << Qt::hex << (unsigned long)hr |
| 193 | << "class=" << debugClass << "qualifier=" << debugQualifier; |
| 194 | if (SUCCEEDED(hr)) { |
| 195 | m_isLive = (debugQualifier < DEBUG_DUMP_SMALL); |
| 196 | m_writable = m_isLive; |
| 197 | } |
| 198 | } |
| 199 | |
| 200 | if (m_symbols) { |
| 201 | ULONG numModules = 0, numUnloaded = 0; |
| 202 | hr = m_symbols->GetNumberModules(&numModules, &numUnloaded); |
| 203 | qDebug() << "[WinDbg] GetNumberModules hr=" << Qt::hex << (unsigned long)hr |
| 204 | << "loaded=" << numModules << "unloaded=" << numUnloaded; |
| 205 | if (SUCCEEDED(hr) && numModules > 0) { |
| 206 | char modName[256] = {}; |
| 207 | ULONG modSize = 0; |
| 208 | hr = m_symbols->GetModuleNames(0, 0, nullptr, 0, nullptr, |
| 209 | modName, sizeof(modName), &modSize, |
| 210 | nullptr, 0, nullptr); |
| 211 | if (SUCCEEDED(hr) && modSize > 0) |
| 212 | m_name = QString::fromUtf8(modName); |
| 213 | } |
| 214 | } |
| 215 | |
| 216 | if (m_name.isEmpty()) |
| 217 | m_name = m_isLive ? QStringLiteral("DbgEng (Live)") : QStringLiteral("DbgEng (Dump)"); |
| 218 | |
| 219 | if (m_symbols) { |
| 220 | ULONG numModules = 0, numUnloaded = 0; |
| 221 | hr = m_symbols->GetNumberModules(&numModules, &numUnloaded); |
| 222 | if (SUCCEEDED(hr) && numModules > 0) { |
| 223 | ULONG64 moduleBase = 0; |
| 224 | hr = m_symbols->GetModuleByIndex(0, &moduleBase); |
| 225 | qDebug() << "[WinDbg] Module 0 base=" << Qt::hex << moduleBase; |
| 226 | if (SUCCEEDED(hr)) |
| 227 | m_base = moduleBase; |
| 228 | } |
| 229 | } |
| 230 | |
| 231 | if (m_base && m_dataSpaces) { |
| 232 | uint8_t probe[2] = {}; |
| 233 | ULONG got = 0; |
| 234 | hr = m_dataSpaces->ReadVirtual(m_base, probe, 2, &got); |
| 235 | qDebug() << "[WinDbg] Probe read at" << Qt::hex << m_base |
| 236 | << "hr=" << (unsigned long)hr << "got=" << got |
| 237 | << "bytes:" << (int)probe[0] << (int)probe[1]; |
| 238 | if (FAILED(hr) || got == 0) { |
| 239 | qWarning() << "[WinDbg] Probe read FAILED — cleaning up"; |
| 240 | cleanup(); |
nothing calls this directly
no outgoing calls
no test coverage detected