forked from qt-creator/qt-creator
CDB extension: Introduce flags for exception handling to call command.
Change-Id: Ib913fe43755da16856c084e0ca72086dee596158 Reviewed-by: David Schulz <david.schulz@digia.com>
This commit is contained in:
@@ -349,7 +349,17 @@ bool ExtensionContext::reportLong(char code, int token, const char *serviceName,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char *goCommandForCall(unsigned callFlags)
|
||||||
|
{
|
||||||
|
if (callFlags & ExtensionContext::CallWithExceptionsHandled)
|
||||||
|
return "~. gh";
|
||||||
|
else if (callFlags & ExtensionContext::CallWithExceptionsNotHandled)
|
||||||
|
return "~. gN";
|
||||||
|
return "~. g";
|
||||||
|
}
|
||||||
|
|
||||||
bool ExtensionContext::call(const std::string &functionCall,
|
bool ExtensionContext::call(const std::string &functionCall,
|
||||||
|
unsigned callFlags,
|
||||||
std::wstring *output,
|
std::wstring *output,
|
||||||
std::string *errorMessage)
|
std::string *errorMessage)
|
||||||
{
|
{
|
||||||
@@ -366,7 +376,7 @@ bool ExtensionContext::call(const std::string &functionCall,
|
|||||||
}
|
}
|
||||||
// Execute in current thread. TODO: This must not crash, else we are in an inconsistent state
|
// Execute in current thread. TODO: This must not crash, else we are in an inconsistent state
|
||||||
// (need to call 'gh', etc.)
|
// (need to call 'gh', etc.)
|
||||||
hr = m_control->Execute(DEBUG_OUTCTL_ALL_CLIENTS, "~. g", DEBUG_EXECUTE_ECHO);
|
hr = m_control->Execute(DEBUG_OUTCTL_ALL_CLIENTS, goCommandForCall(callFlags), DEBUG_EXECUTE_ECHO);
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
*errorMessage = msgDebugEngineComFailed("Execute", hr);
|
*errorMessage = msgDebugEngineComFailed("Execute", hr);
|
||||||
return 0;
|
return 0;
|
||||||
@@ -378,9 +388,9 @@ bool ExtensionContext::call(const std::string &functionCall,
|
|||||||
*output = stopRecordingOutput();
|
*output = stopRecordingOutput();
|
||||||
// Crude attempt at recovering from a crash: Issue 'gN' (go with exception not handled).
|
// Crude attempt at recovering from a crash: Issue 'gN' (go with exception not handled).
|
||||||
const bool crashed = output->find(L"This exception may be expected and handled.") != std::string::npos;
|
const bool crashed = output->find(L"This exception may be expected and handled.") != std::string::npos;
|
||||||
if (crashed) {
|
if (crashed && !callFlags) {
|
||||||
m_stopReason.clear();
|
m_stopReason.clear();
|
||||||
hr = m_control->Execute(DEBUG_OUTCTL_ALL_CLIENTS, "~. gN", DEBUG_EXECUTE_ECHO);
|
hr = m_control->Execute(DEBUG_OUTCTL_ALL_CLIENTS, goCommandForCall(CallWithExceptionsNotHandled), DEBUG_EXECUTE_ECHO);
|
||||||
m_control->WaitForEvent(0, INFINITE);
|
m_control->WaitForEvent(0, INFINITE);
|
||||||
*errorMessage = "A crash occurred while calling: " + functionCall;
|
*errorMessage = "A crash occurred while calling: " + functionCall;
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -58,6 +58,11 @@ class ExtensionContext {
|
|||||||
|
|
||||||
ExtensionContext();
|
ExtensionContext();
|
||||||
public:
|
public:
|
||||||
|
enum CallFlags {
|
||||||
|
CallWithExceptionsHandled = 0x1,
|
||||||
|
CallWithExceptionsNotHandled = 0x2
|
||||||
|
};
|
||||||
|
|
||||||
// Key used to report stop reason in StopReasonMap
|
// Key used to report stop reason in StopReasonMap
|
||||||
static const char *stopReasonKeyC;
|
static const char *stopReasonKeyC;
|
||||||
static const char *breakPointStopReasonC; // pre-defined stop reasons
|
static const char *breakPointStopReasonC; // pre-defined stop reasons
|
||||||
@@ -109,7 +114,7 @@ public:
|
|||||||
void startRecordingOutput();
|
void startRecordingOutput();
|
||||||
std::wstring stopRecordingOutput();
|
std::wstring stopRecordingOutput();
|
||||||
// Execute a function call and record the output.
|
// Execute a function call and record the output.
|
||||||
bool call(const std::string &functionCall, std::wstring *output, std::string *errorMessage);
|
bool call(const std::string &functionCall, unsigned callFlags, std::wstring *output, std::string *errorMessage);
|
||||||
|
|
||||||
CIDebugClient *hookedClient() const { return m_hookedClient; }
|
CIDebugClient *hookedClient() const { return m_hookedClient; }
|
||||||
|
|
||||||
|
|||||||
@@ -655,7 +655,7 @@ std::string widgetAt(const SymbolGroupValueContext &ctx, int x, int y, std::stri
|
|||||||
callStr << std::showbase << std::hex << symbols.front().second
|
callStr << std::showbase << std::hex << symbols.front().second
|
||||||
<< std::noshowbase << std::dec << '(' << x << ',' << y << ')';
|
<< std::noshowbase << std::dec << '(' << x << ',' << y << ')';
|
||||||
std::wstring wOutput;
|
std::wstring wOutput;
|
||||||
if (!ExtensionContext::instance().call(callStr.str(), &wOutput, errorMessage))
|
if (!ExtensionContext::instance().call(callStr.str(), 0, &wOutput, errorMessage))
|
||||||
return std::string();
|
return std::string();
|
||||||
// Returns: ".call returns\nclass QWidget * 0x00000000`022bf100\nbla...".
|
// Returns: ".call returns\nclass QWidget * 0x00000000`022bf100\nbla...".
|
||||||
// Chop lines in front and after 'class ...' and convert first line.
|
// Chop lines in front and after 'class ...' and convert first line.
|
||||||
|
|||||||
@@ -3084,7 +3084,7 @@ static int assignQStringI(SymbolGroupNode *n, const char *className,
|
|||||||
<< v.address() << ',' << data.stringLength << ')';
|
<< v.address() << ',' << data.stringLength << ')';
|
||||||
std::wstring wOutput;
|
std::wstring wOutput;
|
||||||
std::string errorMessage;
|
std::string errorMessage;
|
||||||
return ExtensionContext::instance().call(callStr.str(), &wOutput, &errorMessage) ?
|
return ExtensionContext::instance().call(callStr.str(), 0, &wOutput, &errorMessage) ?
|
||||||
assignQStringI(n, className, data, ctx, false) : 5;
|
assignQStringI(n, className, data, ctx, false) : 5;
|
||||||
}
|
}
|
||||||
// Write data.
|
// Write data.
|
||||||
|
|||||||
Reference in New Issue
Block a user