Commit 72421c18 authored by Friedemann Kleint's avatar Friedemann Kleint Committed by hjk

CDB: Pass settings maxStringLength and maxStackDepth to extension.

Change-Id: I602aa3758817026c8b4cbda1cc9fa9eff95fc691
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
parent 9c96a5a9
......@@ -43,6 +43,16 @@ WINDBG_EXTENSION_APIS ExtensionApis = {sizeof(WINDBG_EXTENSION_APIS), 0, 0, 0,
const char *ExtensionContext::stopReasonKeyC = "reason";
const char *ExtensionContext::breakPointStopReasonC = "breakpoint";
/*! \class Parameters
Externally configureable parameters.
\ingroup qtcreatorcdbext
*/
Parameters::Parameters() : maxStringLength(10000), maxStackDepth(1000)
{
}
/*! \class ExtensionContext
Global singleton with context.
......
......@@ -40,6 +40,16 @@ class LocalsSymbolGroup;
class WatchesSymbolGroup;
class OutputCallback;
// Global parameters
class Parameters
{
public:
Parameters();
unsigned maxStringLength;
unsigned maxStackDepth;
};
// Global singleton with context.
// Caches a symbolgroup per frame and thread as long as the session is accessible.
class ExtensionContext {
......@@ -105,6 +115,9 @@ public:
CIDebugClient *hookedClient() const { return m_hookedClient; }
const Parameters &parameters() const { return m_parameters; }
Parameters &parameters() { return m_parameters; }
private:
bool isInitialized() const;
......@@ -120,6 +133,7 @@ private:
StopReasonMap m_stopReason;
bool m_stateNotification;
Parameters m_parameters;
};
// Context for extension commands to be instantiated on stack in a command handler.
......
......@@ -14,6 +14,7 @@ threads
registers
modules
idle
setparameter
help
memory
expression
......
......@@ -110,7 +110,8 @@ enum Command {
CmdAddWatch,
CmdWidgetAt,
CmdBreakPoints,
CmdTest
CmdTest,
CmdSetParameter
};
static const CommandDescription commandDescriptions[] = {
......@@ -172,7 +173,8 @@ static const CommandDescription commandDescriptions[] = {
{"addwatch","Add watch expression","<iname> <expression>"},
{"widgetat","Return address of widget at position","<x> <y>"},
{"breakpoints","List breakpoints with modules","[-h] [-v]"},
{"test","Testing command","-T type | -w watch-expression"}
{"test","Testing command","-T type | -w watch-expression"},
{"setparameter","Set parameter","maxStringLength=value maxStackDepth=value"}
};
typedef std::vector<std::string> StringVector;
......@@ -893,6 +895,34 @@ extern "C" HRESULT CALLBACK idle(CIDebugClient *client, PCSTR)
return S_OK;
}
// Extension command 'setparameter':
// Parse a list of parameters: 'key=value'
extern "C" HRESULT CALLBACK setparameter(CIDebugClient *, PCSTR args)
{
int token;
StringVector tokens = commandTokens<StringVector>(args, &token);
const size_t count = tokens.size();
size_t success = 0;
for (size_t i = 0; i < count; ++i) {
const std::string &token = tokens.at(i);
const std::string::size_type equalsPos = token.find('=');
if (equalsPos != std::string::npos) {
const std::string value = token.substr(equalsPos + 1, token.size() - 1 - equalsPos);
if (!token.compare(0, equalsPos, "maxStringLength")) {
if (integerFromString(value, &ExtensionContext::instance().parameters().maxStringLength))
++success;
} else if (!token.compare(0, equalsPos, "maxStackDepth")) {
if (integerFromString(value, &ExtensionContext::instance().parameters().maxStackDepth))
++success;
}
}
}
if (success != count)
DebugPrint() << "Errors parsing setparameters command '" << args << '\'';
return S_OK;
}
// Extension command 'help':
// Display version
......
......@@ -783,6 +783,11 @@ void CdbEngine::setupInferior()
}
postCommand("sxn 0x4000001f", 0); // Do not break on WowX86 exceptions.
postCommand(".asm source_line", 0); // Source line in assembly
postCommand(m_extensionCommandPrefixBA + "setparameter maxStringLength="
+ debuggerCore()->action(MaximalStringLength)->value().toByteArray()
+ " maxStackDepth="
+ debuggerCore()->action(MaximalStackDepth)->value().toByteArray()
, 0);
postExtensionCommand("pid", QByteArray(), 0, &CdbEngine::handlePid);
}
......
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