Debugger: Add job for expression evaluation.
This commit is contained in:
parent
5ac34e5a78
commit
feab8604c9
64
src/apps/debugger/jobs/ExpressionEvaluationJob.cpp
Normal file
64
src/apps/debugger/jobs/ExpressionEvaluationJob.cpp
Normal file
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright 2014, Rene Gollent, rene@gollent.com.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
#include "Jobs.h"
|
||||
|
||||
#include <String.h>
|
||||
|
||||
#include <AutoLocker.h>
|
||||
|
||||
#include "SourceLanguage.h"
|
||||
#include "StackFrame.h"
|
||||
#include "Team.h"
|
||||
#include "Value.h"
|
||||
|
||||
|
||||
ExpressionEvaluationJob::ExpressionEvaluationJob(Team* team,
|
||||
SourceLanguage* language, const char* expression, type_code resultType,
|
||||
StackFrame* frame)
|
||||
:
|
||||
fKey(expression, JOB_TYPE_EVALUATE_EXPRESSION),
|
||||
fTeam(team),
|
||||
fLanguage(language),
|
||||
fExpression(expression),
|
||||
fResultType(resultType),
|
||||
fFrame(frame)
|
||||
{
|
||||
fLanguage->AcquireReference();
|
||||
if (fFrame != NULL)
|
||||
fFrame->AcquireReference();
|
||||
}
|
||||
|
||||
|
||||
ExpressionEvaluationJob::~ExpressionEvaluationJob()
|
||||
{
|
||||
fLanguage->ReleaseReference();
|
||||
if (fFrame != NULL)
|
||||
fFrame->ReleaseReference();
|
||||
}
|
||||
|
||||
|
||||
const JobKey&
|
||||
ExpressionEvaluationJob::Key() const
|
||||
{
|
||||
return fKey;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
ExpressionEvaluationJob::Do()
|
||||
{
|
||||
Value* value = NULL;
|
||||
status_t result = fLanguage->EvaluateExpression(fExpression, fResultType,
|
||||
value);
|
||||
BReference<Value> reference;
|
||||
if (value != NULL)
|
||||
reference.SetTo(value, true);
|
||||
|
||||
AutoLocker<Team> teamLocker(fTeam);
|
||||
fTeam->NotifyExpressionEvaluated(fExpression.String(), result, value);
|
||||
|
||||
return B_OK;
|
||||
}
|
@ -6,6 +6,7 @@
|
||||
#ifndef JOBS_H
|
||||
#define JOBS_H
|
||||
|
||||
#include <String.h>
|
||||
|
||||
#include "ImageDebugInfoLoadingState.h"
|
||||
#include "ImageDebugInfoProvider.h"
|
||||
@ -20,6 +21,7 @@ class DebuggerInterface;
|
||||
class Function;
|
||||
class FunctionInstance;
|
||||
class Image;
|
||||
class SourceLanguage;
|
||||
class StackFrame;
|
||||
class StackFrameValues;
|
||||
class Team;
|
||||
@ -29,6 +31,7 @@ class TeamTypeInformation;
|
||||
class Thread;
|
||||
class Type;
|
||||
class TypeComponentPath;
|
||||
class Value;
|
||||
class ValueLocation;
|
||||
class ValueNode;
|
||||
class ValueNodeChild;
|
||||
@ -45,7 +48,8 @@ enum {
|
||||
JOB_TYPE_LOAD_SOURCE_CODE,
|
||||
JOB_TYPE_GET_STACK_FRAME_VALUE,
|
||||
JOB_TYPE_RESOLVE_VALUE_NODE_VALUE,
|
||||
JOB_TYPE_GET_MEMORY_BLOCK
|
||||
JOB_TYPE_GET_MEMORY_BLOCK,
|
||||
JOB_TYPE_EVALUATE_EXPRESSION
|
||||
};
|
||||
|
||||
|
||||
@ -226,4 +230,26 @@ private:
|
||||
};
|
||||
|
||||
|
||||
class ExpressionEvaluationJob : public Job {
|
||||
public:
|
||||
ExpressionEvaluationJob(Team* team,
|
||||
SourceLanguage* language,
|
||||
const char* expression,
|
||||
type_code resultType,
|
||||
StackFrame* frame);
|
||||
virtual ~ExpressionEvaluationJob();
|
||||
|
||||
virtual const JobKey& Key() const;
|
||||
virtual status_t Do();
|
||||
|
||||
private:
|
||||
SimpleJobKey fKey;
|
||||
Team* fTeam;
|
||||
SourceLanguage* fLanguage;
|
||||
BString fExpression;
|
||||
type_code fResultType;
|
||||
StackFrame* fFrame;
|
||||
};
|
||||
|
||||
|
||||
#endif // JOBS_H
|
||||
|
Loading…
Reference in New Issue
Block a user