Debugger: Adapt CliDumpMemoryCommand to new expression interface.
- CliDumpMemoryCommand now requests asynchronous expression evaluation like the other users of expressions.
This commit is contained in:
@@ -16,13 +16,14 @@
|
|||||||
|
|
||||||
#include <AutoLocker.h>
|
#include <AutoLocker.h>
|
||||||
|
|
||||||
#include "CLanguageExpressionEvaluator.h"
|
|
||||||
#include "CliContext.h"
|
#include "CliContext.h"
|
||||||
|
#include "CppLanguage.h"
|
||||||
#include "Number.h"
|
#include "Number.h"
|
||||||
#include "Team.h"
|
#include "Team.h"
|
||||||
#include "TeamMemoryBlock.h"
|
#include "TeamMemoryBlock.h"
|
||||||
#include "UiUtils.h"
|
#include "UiUtils.h"
|
||||||
#include "UserInterface.h"
|
#include "UserInterface.h"
|
||||||
|
#include "Value.h"
|
||||||
|
|
||||||
|
|
||||||
CliDumpMemoryCommand::CliDumpMemoryCommand()
|
CliDumpMemoryCommand::CliDumpMemoryCommand()
|
||||||
@@ -31,6 +32,14 @@ CliDumpMemoryCommand::CliDumpMemoryCommand()
|
|||||||
"%s [\"]address|expression[\"] [num]\n"
|
"%s [\"]address|expression[\"] [num]\n"
|
||||||
"Reads and displays the contents of memory at the target address.")
|
"Reads and displays the contents of memory at the target address.")
|
||||||
{
|
{
|
||||||
|
fLanguage = new(std::nothrow) CppLanguage();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
CliDumpMemoryCommand::~CliDumpMemoryCommand()
|
||||||
|
{
|
||||||
|
if (fLanguage != NULL)
|
||||||
|
fLanguage->ReleaseReference();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -43,13 +52,34 @@ CliDumpMemoryCommand::Execute(int argc, const char* const* argv,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CLanguageExpressionEvaluator evaluator;
|
if (fLanguage == NULL) {
|
||||||
target_addr_t address;
|
printf("Unable to evaluate expression: %s\n", strerror(B_NO_MEMORY));
|
||||||
try {
|
return;
|
||||||
Number value = evaluator.Evaluate(argv[1], B_UINT64_TYPE);
|
}
|
||||||
address = value.GetValue().ToUInt64();
|
|
||||||
} catch(...) {
|
target_addr_t address = 0;
|
||||||
printf("Error parsing address/expression.\n");
|
context.SetCurrentExpression(argv[1]);
|
||||||
|
context.GetUserInterfaceListener()->ExpressionEvaluationRequested(
|
||||||
|
fLanguage, argv[1], B_UINT64_TYPE);
|
||||||
|
context.WaitForEvents(CliContext::EVENT_EXPRESSION_EVALUATED);
|
||||||
|
if (context.IsTerminating())
|
||||||
|
return;
|
||||||
|
|
||||||
|
BString errorMessage;
|
||||||
|
Value* value = context.GetExpressionValue();
|
||||||
|
if (value != NULL) {
|
||||||
|
BVariant variantValue;
|
||||||
|
value->ToVariant(variantValue);
|
||||||
|
if (variantValue.Type() == B_UINT64_TYPE)
|
||||||
|
address = variantValue.ToUInt64();
|
||||||
|
else
|
||||||
|
value->ToString(errorMessage);
|
||||||
|
} else
|
||||||
|
errorMessage = strerror(context.GetExpressionResult());
|
||||||
|
|
||||||
|
if (!errorMessage.IsEmpty()) {
|
||||||
|
printf("Unable to evaluate expression: %s\n",
|
||||||
|
errorMessage.String());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012, Rene Gollent, [email protected].
|
* Copyright 2012-2014, Rene Gollent, [email protected].
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef CLI_DUMP_MEMORY_COMMAND_H
|
#ifndef CLI_DUMP_MEMORY_COMMAND_H
|
||||||
@@ -9,13 +9,19 @@
|
|||||||
#include "CliCommand.h"
|
#include "CliCommand.h"
|
||||||
|
|
||||||
|
|
||||||
|
class SourceLanguage;
|
||||||
|
|
||||||
|
|
||||||
class CliDumpMemoryCommand : public CliCommand {
|
class CliDumpMemoryCommand : public CliCommand {
|
||||||
public:
|
public:
|
||||||
CliDumpMemoryCommand();
|
CliDumpMemoryCommand();
|
||||||
|
virtual ~CliDumpMemoryCommand();
|
||||||
|
|
||||||
virtual void Execute(int argc, const char* const* argv,
|
virtual void Execute(int argc, const char* const* argv,
|
||||||
CliContext& context);
|
CliContext& context);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
SourceLanguage* fLanguage;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user