2009-06-24 01:46:38 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
2016-05-29 13:52:47 -04:00
|
|
|
* Copyright 2014-2016, Rene Gollent, rene@gollent.com.
|
2009-06-24 01:46:38 +00:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
|
|
|
#ifndef THREAD_HANDLER_H
|
|
|
|
#define THREAD_HANDLER_H
|
|
|
|
|
2009-07-22 19:20:06 +00:00
|
|
|
|
2009-06-24 01:46:38 +00:00
|
|
|
#include <Referenceable.h>
|
|
|
|
#include <util/OpenHashTable.h>
|
|
|
|
|
2009-06-25 23:51:09 +00:00
|
|
|
#include "Breakpoint.h"
|
|
|
|
#include "ImageDebugInfoProvider.h"
|
2016-05-29 13:52:47 -04:00
|
|
|
#include "model/Thread.h"
|
2009-06-24 01:46:38 +00:00
|
|
|
|
|
|
|
|
2016-05-29 13:52:47 -04:00
|
|
|
class BreakpointHitEvent;
|
2009-06-25 23:51:09 +00:00
|
|
|
class BreakpointManager;
|
2016-05-29 13:52:47 -04:00
|
|
|
class DebugEvent;
|
|
|
|
class DebuggerCallEvent;
|
2009-06-24 01:46:38 +00:00
|
|
|
class DebuggerInterface;
|
2016-05-29 13:52:47 -04:00
|
|
|
class ExceptionOccurredEvent;
|
Debugger: Rework expression parsing API.
ExpressionInfo:
- No longer stores an explicit result type (this is inferred from
evaluation of the expression itself now).
- Introduce class ExpressionResult for returning the result of an
expression computation. This can currently take the form of either
a primitive value, or a value node object.
- Adjust UserInterfaceListener and ExpressionInfo::Listener to take
the above changes into account, and correspondingly adjust all
callers/listeners.
CLanguageExpressionEvaluator:
- Introduce child class Operand. This subsumes the functionality that
was previously in the separate Number class, and can represent a
primitive value, a value node or a type. Also has functionality to
implicity handle type promotion/inferring when performing calculations
between operands.
- Adjust expression parser to operate in terms of Operands rather than
Numbers. This allows a number of improvements, most notably that an
expression can now return a value node as a result rather than only
a primitive number. This capability isn't yet fully used, but paves
the way for future uses such as an expression that evaluates to a data
member, a global variable, or an arbitrary pointer of a particular type.
- Various cleanups/simplifications that were possible as a result of the above
changes.
ExpressionEvaluationWindow/ExpressionPromptWindow:
- Remove type menu field, since the expression API no longer uses it.
Adding/removing expressions in the VariablesView is temporarily disabled,
pending some further rework there to properly handle the new result object.
2014-11-15 00:31:17 -05:00
|
|
|
class ExpressionResult;
|
2014-06-13 20:25:13 -04:00
|
|
|
class ImageDebugInfoJobListener;
|
2015-08-15 16:41:24 -04:00
|
|
|
class JobListener;
|
2016-05-29 13:52:47 -04:00
|
|
|
class SignalReceivedEvent;
|
|
|
|
class SingleStepEvent;
|
2009-06-25 23:51:09 +00:00
|
|
|
class StackFrame;
|
|
|
|
class Statement;
|
2016-05-29 13:52:47 -04:00
|
|
|
class ThreadDebuggedEvent;
|
|
|
|
class WatchpointHitEvent;
|
2009-06-24 01:46:38 +00:00
|
|
|
class Worker;
|
|
|
|
|
|
|
|
|
2010-12-16 13:50:30 +00:00
|
|
|
class ThreadHandler : public BReferenceable, private ImageDebugInfoProvider,
|
2009-06-25 23:51:09 +00:00
|
|
|
private BreakpointClient {
|
2009-06-24 01:46:38 +00:00
|
|
|
public:
|
2016-05-29 13:52:47 -04:00
|
|
|
ThreadHandler(::Thread* thread, Worker* worker,
|
2009-06-25 23:51:09 +00:00
|
|
|
DebuggerInterface* debuggerInterface,
|
2015-08-15 16:41:24 -04:00
|
|
|
JobListener* listener,
|
2009-06-25 23:51:09 +00:00
|
|
|
BreakpointManager* breakpointManager);
|
2009-06-24 01:46:38 +00:00
|
|
|
~ThreadHandler();
|
|
|
|
|
|
|
|
void Init();
|
|
|
|
|
|
|
|
thread_id ThreadID() const { return fThread->ID(); }
|
2016-05-29 13:52:47 -04:00
|
|
|
::Thread* GetThread() const { return fThread; }
|
2009-06-24 01:46:38 +00:00
|
|
|
|
2015-07-29 22:31:08 -04:00
|
|
|
status_t SetBreakpointAndRun(target_addr_t address);
|
2009-07-03 14:23:19 +00:00
|
|
|
// team lock held
|
|
|
|
|
2009-06-25 23:51:09 +00:00
|
|
|
// All Handle*() methods are invoked in team debugger thread,
|
|
|
|
// looper lock held.
|
2009-06-24 01:46:38 +00:00
|
|
|
bool HandleThreadDebugged(
|
2013-07-07 12:55:23 -04:00
|
|
|
ThreadDebuggedEvent* event,
|
|
|
|
const BString& stoppedReason = BString());
|
2009-06-24 01:46:38 +00:00
|
|
|
bool HandleDebuggerCall(
|
|
|
|
DebuggerCallEvent* event);
|
|
|
|
bool HandleBreakpointHit(
|
|
|
|
BreakpointHitEvent* event);
|
|
|
|
bool HandleWatchpointHit(
|
|
|
|
WatchpointHitEvent* event);
|
|
|
|
bool HandleSingleStep(
|
|
|
|
SingleStepEvent* event);
|
|
|
|
bool HandleExceptionOccurred(
|
|
|
|
ExceptionOccurredEvent* event);
|
2015-06-26 22:29:23 -04:00
|
|
|
bool HandleSignalReceived(
|
|
|
|
SignalReceivedEvent* event);
|
2009-06-24 01:46:38 +00:00
|
|
|
|
2013-05-11 23:09:12 -04:00
|
|
|
void HandleThreadAction(uint32 action,
|
|
|
|
target_addr_t address);
|
2009-06-24 01:46:38 +00:00
|
|
|
|
|
|
|
void HandleThreadStateChanged();
|
|
|
|
void HandleCpuStateChanged();
|
|
|
|
void HandleStackTraceChanged();
|
|
|
|
|
2014-10-30 16:49:16 -04:00
|
|
|
private:
|
2014-11-08 18:20:30 -05:00
|
|
|
friend class ExpressionEvaluationListener;
|
2014-10-30 16:49:16 -04:00
|
|
|
|
2009-06-24 01:46:38 +00:00
|
|
|
private:
|
2009-06-25 23:51:09 +00:00
|
|
|
// ImageDebugInfoProvider
|
|
|
|
virtual status_t GetImageDebugInfo(Image* image,
|
|
|
|
ImageDebugInfo*& _info);
|
|
|
|
|
2009-10-15 04:40:33 +00:00
|
|
|
bool _HandleThreadStopped(CpuState* cpuState,
|
|
|
|
uint32 stoppedReason,
|
|
|
|
const BString& stoppedReasonInfo
|
|
|
|
= BString());
|
2009-06-24 01:46:38 +00:00
|
|
|
|
2013-05-16 21:16:45 -04:00
|
|
|
bool _HandleSetAddress(CpuState* cpuState,
|
|
|
|
target_addr_t address);
|
|
|
|
|
2009-06-24 01:46:38 +00:00
|
|
|
void _SetThreadState(uint32 state,
|
2009-10-15 04:40:33 +00:00
|
|
|
CpuState* cpuState, uint32 stoppedReason,
|
|
|
|
const BString& stoppedReasonInfo);
|
2009-06-24 01:46:38 +00:00
|
|
|
|
2009-06-25 23:51:09 +00:00
|
|
|
Statement* _GetStatementAtInstructionPointer(
|
|
|
|
StackFrame* frame);
|
|
|
|
|
|
|
|
void _StepFallback();
|
|
|
|
bool _DoStepOver(CpuState* cpuState);
|
|
|
|
|
|
|
|
status_t _InstallTemporaryBreakpoint(
|
|
|
|
target_addr_t address);
|
|
|
|
void _UninstallTemporaryBreakpoint();
|
|
|
|
void _ClearContinuationState();
|
|
|
|
void _RunThread(target_addr_t instructionPointer);
|
|
|
|
void _SingleStepThread(
|
|
|
|
target_addr_t instructionPointer);
|
|
|
|
|
2014-10-30 16:49:16 -04:00
|
|
|
bool _HandleBreakpointConditionIfNeeded(
|
|
|
|
CpuState* cpuState);
|
|
|
|
void _HandleBreakpointConditionEvaluated(
|
Debugger: Rework expression parsing API.
ExpressionInfo:
- No longer stores an explicit result type (this is inferred from
evaluation of the expression itself now).
- Introduce class ExpressionResult for returning the result of an
expression computation. This can currently take the form of either
a primitive value, or a value node object.
- Adjust UserInterfaceListener and ExpressionInfo::Listener to take
the above changes into account, and correspondingly adjust all
callers/listeners.
CLanguageExpressionEvaluator:
- Introduce child class Operand. This subsumes the functionality that
was previously in the separate Number class, and can represent a
primitive value, a value node or a type. Also has functionality to
implicity handle type promotion/inferring when performing calculations
between operands.
- Adjust expression parser to operate in terms of Operands rather than
Numbers. This allows a number of improvements, most notably that an
expression can now return a value node as a result rather than only
a primitive number. This capability isn't yet fully used, but paves
the way for future uses such as an expression that evaluates to a data
member, a global variable, or an arbitrary pointer of a particular type.
- Various cleanups/simplifications that were possible as a result of the above
changes.
ExpressionEvaluationWindow/ExpressionPromptWindow:
- Remove type menu field, since the expression API no longer uses it.
Adding/removing expressions in the VariablesView is temporarily disabled,
pending some further rework there to properly handle the new result object.
2014-11-15 00:31:17 -05:00
|
|
|
ExpressionResult* value);
|
|
|
|
bool _CheckStopCondition();
|
2009-06-25 23:51:09 +00:00
|
|
|
|
|
|
|
bool _HandleBreakpointHitStep(CpuState* cpuState);
|
|
|
|
bool _HandleSingleStepStep(CpuState* cpuState);
|
|
|
|
|
2013-03-29 21:05:27 -04:00
|
|
|
bool _HasExitedFrame(target_addr_t framePointer)
|
|
|
|
const;
|
|
|
|
|
2009-06-24 01:46:38 +00:00
|
|
|
private:
|
2016-05-29 13:52:47 -04:00
|
|
|
::Thread* fThread;
|
2009-06-24 01:46:38 +00:00
|
|
|
Worker* fWorker;
|
|
|
|
DebuggerInterface* fDebuggerInterface;
|
2015-08-15 16:41:24 -04:00
|
|
|
JobListener* fJobListener;
|
2009-06-25 23:51:09 +00:00
|
|
|
BreakpointManager* fBreakpointManager;
|
|
|
|
uint32 fStepMode;
|
|
|
|
Statement* fStepStatement;
|
|
|
|
target_addr_t fBreakpointAddress;
|
2013-03-29 21:05:27 -04:00
|
|
|
target_addr_t fSteppedOverFunctionAddress;
|
2009-06-25 23:51:09 +00:00
|
|
|
target_addr_t fPreviousInstructionPointer;
|
2011-12-11 22:26:43 -05:00
|
|
|
target_addr_t fPreviousFrameAddress;
|
2009-06-25 23:51:09 +00:00
|
|
|
bool fSingleStepping;
|
2014-10-30 16:49:16 -04:00
|
|
|
sem_id fConditionWaitSem;
|
Debugger: Rework expression parsing API.
ExpressionInfo:
- No longer stores an explicit result type (this is inferred from
evaluation of the expression itself now).
- Introduce class ExpressionResult for returning the result of an
expression computation. This can currently take the form of either
a primitive value, or a value node object.
- Adjust UserInterfaceListener and ExpressionInfo::Listener to take
the above changes into account, and correspondingly adjust all
callers/listeners.
CLanguageExpressionEvaluator:
- Introduce child class Operand. This subsumes the functionality that
was previously in the separate Number class, and can represent a
primitive value, a value node or a type. Also has functionality to
implicity handle type promotion/inferring when performing calculations
between operands.
- Adjust expression parser to operate in terms of Operands rather than
Numbers. This allows a number of improvements, most notably that an
expression can now return a value node as a result rather than only
a primitive number. This capability isn't yet fully used, but paves
the way for future uses such as an expression that evaluates to a data
member, a global variable, or an arbitrary pointer of a particular type.
- Various cleanups/simplifications that were possible as a result of the above
changes.
ExpressionEvaluationWindow/ExpressionPromptWindow:
- Remove type menu field, since the expression API no longer uses it.
Adding/removing expressions in the VariablesView is temporarily disabled,
pending some further rework there to properly handle the new result object.
2014-11-15 00:31:17 -05:00
|
|
|
ExpressionResult* fConditionResult;
|
2009-07-27 00:39:12 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
ThreadHandler* fNext;
|
2009-06-24 01:46:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct ThreadHandlerHashDefinition {
|
|
|
|
typedef thread_id KeyType;
|
|
|
|
typedef ThreadHandler ValueType;
|
|
|
|
|
|
|
|
size_t HashKey(thread_id key) const
|
|
|
|
{
|
|
|
|
return (size_t)key;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t Hash(const ThreadHandler* value) const
|
|
|
|
{
|
|
|
|
return HashKey(value->ThreadID());
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Compare(thread_id key, ThreadHandler* value) const
|
|
|
|
{
|
|
|
|
return value->ThreadID() == key;
|
|
|
|
}
|
|
|
|
|
2009-07-27 00:39:12 +00:00
|
|
|
ThreadHandler*& GetLink(ThreadHandler* value) const
|
2009-06-24 01:46:38 +00:00
|
|
|
{
|
2009-07-27 00:39:12 +00:00
|
|
|
return value->fNext;
|
2009-06-24 01:46:38 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2009-07-27 00:39:12 +00:00
|
|
|
typedef BOpenHashTable<ThreadHandlerHashDefinition> ThreadHandlerTable;
|
2009-06-24 01:46:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
#endif // THREAD_HANDLER_H
|