Commit 845cef82 authored by Friedemann Kleint's avatar Friedemann Kleint

CDB extension: Introduce flags for exception handling to call command.

Change-Id: Ib913fe43755da16856c084e0ca72086dee596158
Reviewed-by: default avatarDavid Schulz <david.schulz@digia.com>
parent 280d7f2a
......@@ -349,7 +349,17 @@ bool ExtensionContext::reportLong(char code, int token, const char *serviceName,
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,
unsigned callFlags,
std::wstring *output,
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
// (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)) {
*errorMessage = msgDebugEngineComFailed("Execute", hr);
return 0;
......@@ -378,9 +388,9 @@ bool ExtensionContext::call(const std::string &functionCall,
*output = stopRecordingOutput();
// 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;
if (crashed) {
if (crashed && !callFlags) {
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);
*errorMessage = "A crash occurred while calling: " + functionCall;
return false;
......
......@@ -58,6 +58,11 @@ class ExtensionContext {
ExtensionContext();
public:
enum CallFlags {
CallWithExceptionsHandled = 0x1,
CallWithExceptionsNotHandled = 0x2
};
// Key used to report stop reason in StopReasonMap
static const char *stopReasonKeyC;
static const char *breakPointStopReasonC; // pre-defined stop reasons
......@@ -109,7 +114,7 @@ public:
void startRecordingOutput();
std::wstring stopRecordingOutput();
// 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; }
......
......@@ -655,7 +655,7 @@ std::string widgetAt(const SymbolGroupValueContext &ctx, int x, int y, std::stri
callStr << std::showbase << std::hex << symbols.front().second
<< std::noshowbase << std::dec << '(' << x << ',' << y << ')';
std::wstring wOutput;
if (!ExtensionContext::instance().call(callStr.str(), &wOutput, errorMessage))
if (!ExtensionContext::instance().call(callStr.str(), 0, &wOutput, errorMessage))
return std::string();
// Returns: ".call returns\nclass QWidget * 0x00000000`022bf100\nbla...".
// 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 << ')';
std::wstring wOutput;
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;
}
// Write data.
......
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