class Thread

Defined at line 35 of file ../../src/developer/debug/zxdb/client/thread.h

The flow control commands on this object (Pause, Continue, Step...) apply only to this thread

(other threads will continue to run or not run as they were previously).

Protected Members

MapSettingStore settings_

Public Methods

void Thread (Session * session)

Thread Implementation ---------------------------------------------------------------------------

Defined at line 44 of file ../../src/developer/debug/zxdb/client/thread.cc

void ~Thread ()

Defined at line 50 of file ../../src/developer/debug/zxdb/client/thread.cc

fxl::WeakPtr<Thread> GetWeakPtr ()

Defined at line 52 of file ../../src/developer/debug/zxdb/client/thread.cc

Process * GetProcess ()

Guaranteed non-null.

uint64_t GetKoid ()
const std::string & GetName ()
std::optional<debug_ipc::ThreadRecord::State> GetState ()

Returns the current state of the thread.

The state of the thread isn't necessarily up-to-date. In cases where we know the state isn't

up-to-date (we've asked it to do change but haven't heard back), GetState() will return a

nullopt. But the thread state could have changed out from under us or there could be a race

with the target, so a present state isn't guaranteed correct.

To force an update, call Process::SyncThreads() or Thread::SyncFrames().

debug_ipc::ThreadRecord::BlockedReason GetBlockedReason ()
std::optional<StopInfo> CurrentStopInfo ()

Returns the current stop info, which will only be valid if |IsBlockedOnException| is true.

bool IsBlockedOnException ()

The "blocked on exception" state has a special query function since that's the only blocked

state that has valid frames.

The other states that support valid frames (suspended and "core dump") are checked by

CurrentStopSupportsFrames(). Theoretically there should always be at least one frame in the

GetStack() if this returns true.

Defined at line 54 of file ../../src/developer/debug/zxdb/client/thread.cc

bool CurrentStopSupportsFrames ()

Defined at line 60 of file ../../src/developer/debug/zxdb/client/thread.cc

void Pause (fit::callback<void ()> on_paused)

Pauses (suspends in Zircon terms) the thread, it does not affect other threads or processes.

The backend will try to ensure the thread is actually paused before issuing the on_paused

callback. But this is best effort and not guaranteed: both because there's a timeout for the

synchronous suspending and because a different continue message could race with the reply.

void Continue (bool forward_exception)

Continues the thread, optionally forwarding the associated exception as

second-chance, allowing the process-level handler a chance to resolve the

exception before sending it back to the debugger; else, the exception is

marked as handled and the thread is resumed.

void ContinueWith (std::unique_ptr<ThreadController> controller, fit::callback<void (const Err &)> on_continue)

Continues the thread using the given ThreadController. This is used to implement the more

complex forms of stepping.

The on_continue callback does NOT indicate that the thread stopped again. It indicates the

thread controller has completed setup properly (some may fail if they depend on some thread

state to start). When the step is complete an exception will be delivered via the thread

observer (it's not always possible to correlate a given thread suspension with a given step

operation).

The on_continue callback may be issued reentrantly from within the stack of the ContinueWith

call if the controller was ready synchronously.

On failure the ThreadController will be removed and the thread will not be continued.

See also CancelAllThreadControllers() for aborting the controller.

void AddPostStopTask (PostStopTask task)
void CancelAllThreadControllers ()

Stops all thread controllers which may be doing automatic stepping. The thread will be in the

state it was in last, which might be running if it was currently running, or it might be

stopped if a step operation was in place.

void ResumeFromAsyncThreadController (std::optional<debug_ipc::ExceptionType> type)

Used by ThreadControllers that need to perform asynchronous operations from a thread stop.

When OnThreadStop() returns kFuture, the thread controller is responsible for calling this

to re-evaluate the thread controller state. See thread_controller.h comments.

The parameter allows optionally overriding the exception type for the re-delivery of the

stop notification. Often thread controllers will want to override this to "none" to force

a re-evaluation of the current location independent of the exception type. If the parameter is

nullopt, the original exception type will be used.

void JumpTo (uint64_t new_address, fit::callback<void (const Err &)> cb)

Sets the thread's IP to the given location. This requires that the thread be stopped. It will

not resume the thread.

Setting the location is asynchronous. At the time of the callback being issued, the frames of

the thread will be updated to the latest state.

Resuming the thread after issuing but before the callback is executed will pick up the new

location (if any) because the requests will be ordered. But because the jump request may fail,

the caller isn't guaranteed what location will be resumed from unless it waits for the

callback.

void NotifyControllerDone (ThreadController * controller)

Notification from a ThreadController that it has completed its job. The thread controller

should be removed from this thread and deleted.

void StepInstructions (uint64_t count)
const Stack & GetStack ()

Returns the stack object associated with this thread.

Stack & GetStack ()
fxl::RefPtr<SettingSchema> GetSchema ()

Provides the setting schema for this object.

Defined at line 67 of file ../../src/developer/debug/zxdb/client/thread.cc

MapSettingStore & settings ()

Defined at line 168 of file ../../src/developer/debug/zxdb/client/thread.h