Commit 5492dc45 authored by David Schulz's avatar David Schulz

CDB: Parse version number from output.

Change-Id: I7b0624c6f1caf6a6a73e9956c91706a74e8ef0a0
Reviewed-by: default avatarChristian Stenger <christian.stenger@digia.com>
parent 62ba2b76
......@@ -265,6 +265,41 @@ ULONG64 ExtensionContext::jsExecutionContext(ExtensionCommandContext &exc,
return result;
}
ExtensionContext::CdbVersion ExtensionContext::cdbVersion()
{
static CdbVersion version;
static bool first = true;
if (!first)
return version;
first = false;
startRecordingOutput();
const HRESULT hr = m_control->OutputVersionInformation(DEBUG_OUTCTL_ALL_CLIENTS);
if (FAILED(hr)) {
stopRecordingOutput();
return version;
}
const std::wstring &output = stopRecordingOutput();
const std::wstring &versionOutput = L"Microsoft (R) Windows Debugger Version";
auto majorPos = output.find(versionOutput);
if (majorPos == std::wstring::npos)
return version;
majorPos += versionOutput.length();
std::wstring::size_type minorPos;
std::wstring::size_type patchPos;
try {
version.major = std::stoi(output.substr(majorPos), &minorPos);
minorPos += majorPos + 1;
version.minor = std::stoi(output.substr(minorPos), &patchPos);
patchPos += minorPos + 1;
version.patch = std::stoi(output.substr(patchPos));
}
catch (...)
{
version.clear();
}
return version;
}
// Complete stop parameters with common parameters and report
static inline ExtensionContext::StopReasonMap
completeStopReasons(CIDebugClient *client, ExtensionContext::StopReasonMap stopReasons, ULONG ex)
......
......@@ -129,6 +129,17 @@ public:
bool stateNotification() const { return m_stateNotification; }
void setStateNotification(bool s) { m_stateNotification = s; }
struct CdbVersion
{
CdbVersion() : major(0), minor(0), patch(0) {}
int major;
int minor;
int patch;
void clear () { major = minor = patch = 0; }
};
CdbVersion cdbVersion();
private:
bool isInitialized() const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment