forked from qt-creator/qt-creator
CDB: Parse version number from output.
Change-Id: I7b0624c6f1caf6a6a73e9956c91706a74e8ef0a0 Reviewed-by: Christian Stenger <christian.stenger@digia.com>
This commit is contained in:
@@ -265,6 +265,41 @@ ULONG64 ExtensionContext::jsExecutionContext(ExtensionCommandContext &exc,
|
|||||||
return result;
|
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
|
// Complete stop parameters with common parameters and report
|
||||||
static inline ExtensionContext::StopReasonMap
|
static inline ExtensionContext::StopReasonMap
|
||||||
completeStopReasons(CIDebugClient *client, ExtensionContext::StopReasonMap stopReasons, ULONG ex)
|
completeStopReasons(CIDebugClient *client, ExtensionContext::StopReasonMap stopReasons, ULONG ex)
|
||||||
|
|||||||
@@ -129,6 +129,17 @@ public:
|
|||||||
bool stateNotification() const { return m_stateNotification; }
|
bool stateNotification() const { return m_stateNotification; }
|
||||||
void setStateNotification(bool s) { m_stateNotification = s; }
|
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:
|
private:
|
||||||
bool isInitialized() const;
|
bool isInitialized() const;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user