class ProcessBreakpoint

Defined at line 39 of file ../../src/developer/debug/debug_agent/process_breakpoint.h

Low-level implementations of the breakpoints. A ProcessBreakpoint represents the actual

"installation" of a Breakpoint in a particular location (address). A Breakpoint can have many

locations:

b Foo() -> If Foo() is inlined, you can get 2+ locations.

In that base, that Breakpoint will have two locations, which means two "installations", or

ProcessBreakpoint.

A Breakpoint can be a software or hardware one. That will define what kind of specialization the

ProcessBreakpoint implements.

Protected Members

DebuggedProcess * process_
uint64_t address_

Public Methods

void ProcessBreakpoint (Breakpoint * breakpoint, DebuggedProcess * debugged_process, uint64_t address)

Given the initial Breakpoint object this corresponds to. Breakpoints can be added or removed

later.

Call Init() immediately after construction to initialize the parts that can report errors.

Defined at line 21 of file ../../src/developer/debug/debug_agent/process_breakpoint.cc

void ~ProcessBreakpoint ()

Defined at line 27 of file ../../src/developer/debug/debug_agent/process_breakpoint.cc

debug_ipc::BreakpointType Type ()
debug::Status Init ()

Call immediately after construction. If it returns failure, the breakpoint will not work.

Defined at line 29 of file ../../src/developer/debug/debug_agent/process_breakpoint.cc

bool Installed (zx_koid_t thread_koid)
fxl::WeakPtr<ProcessBreakpoint> GetWeakPtr ()

Defined at line 31 of file ../../src/developer/debug/debug_agent/process_breakpoint.cc

debug::Status RegisterBreakpoint (Breakpoint * breakpoint)

Adds or removes breakpoints associated with this process/address. Unregister returns whether

there are still any breakpoints referring to this address (false means this is unused and

should be deleted).

Defined at line 35 of file ../../src/developer/debug/debug_agent/process_breakpoint.cc

bool UnregisterBreakpoint (Breakpoint * breakpoint)

Defined at line 49 of file ../../src/developer/debug/debug_agent/process_breakpoint.cc

zx_koid_t process_koid ()

Defined at line 58 of file ../../src/developer/debug/debug_agent/process_breakpoint.h

DebuggedProcess * process ()

Defined at line 59 of file ../../src/developer/debug/debug_agent/process_breakpoint.h

uint64_t address ()

Defined at line 60 of file ../../src/developer/debug/debug_agent/process_breakpoint.h

const std::vector<Breakpoint *> & breakpoints ()

Defined at line 62 of file ../../src/developer/debug/debug_agent/process_breakpoint.h

bool ShouldHitThread (zx_koid_t thread_koid)

When a thread receives a breakpoint exception installed by a process breakpoint, it must check

if the breakpoint was indeed intended to apply to it (we can have thread-specific breakpoints).

Defined at line 64 of file ../../src/developer/debug/debug_agent/process_breakpoint.cc

void OnHit (DebuggedThread * hitting_thread, debug_ipc::BreakpointType exception_type, std::vector<debug_ipc::BreakpointStats> & hit_breakpoints, std::vector<debug_ipc::ThreadRecord> & other_affected_threads)

Notification that this breakpoint was just hit. All affected Breakpoints will have their stats

updated and placed in the *stats param. This makes a difference whether the exceptions was

software or hardware (debug registers) triggered.

All threads requested to be suspended (in any process) by this breakpoint's settings will be

filled into |other_affected_threads|.

IMPORTANT: The caller should check the stats and for any breakpoint with "should_delete" set,

remove the breakpoints. This can't conveniently be done within this call because it will cause

this ProcessBreakpoint object to be deleted from within itself.

Defined at line 73 of file ../../src/developer/debug/debug_agent/process_breakpoint.cc

void BeginStepOver (DebuggedThread * thread)

Call before single-stepping over a breakpoint. This will remove the breakpoint such that it

will be put back when the exception is hit and BreakpointStepHasException() is called.

This will not execute the stepping over directly, but rather enqueue it within the process so

that each stepping over is done one at a time.

The actual stepping over logic is done by |ExecuteStepOver|, which is called by the process.

NOTE: From this moment, the breakpoint "takes over" the "run-lifetime" of the thread. This

means that it will suspend and resume it according to what threads are stepping over it.

Defined at line 139 of file ../../src/developer/debug/debug_agent/process_breakpoint.cc

void EndStepOver (DebuggedThread * thread)

When a thread has a "current breakpoint" its handling and gets a single step exception, it

means that it's done stepping over it and calls this in order to resolve the stepping.

This will tell the process that this stepping over instance is done and will call

|OnBreakpointFinishedSteppingOver|, which will advance the queue so that the other queued step

overs can occur.

NOTE: Even though the thread is done stepping over, this will *not* resume the suspended

threads nor the excepted (stepping over) thread. This is done on |StepOverCleanup|.

This is because there might be another breakpoint queued up and that breakpoint needs a

chance to suspend the threads before these are unsuspended from the previous breakpoint.

Otherwise we introduce a race between the current step over breakpoint resuming the

threads and the next one suspending them.

With the new order, the process will first call the next process |ExecuteStepOver|, which

will suspend the corresponding threads and then |StepOverCleanup| will free the

threads suspended by the current one.

void ExecuteStepOver (DebuggedThread * thread)

Called by the queue-owning process.

This function actually sets up the stepping over and suspend *all* other threads. When the

thread is done stepping over, it will call the process |OnBreakpointFinishedSteppingOver|

function.

void StepOverCleanup (DebuggedThread * thread)

Frees all the suspension and exception resources held by the breakpoint. This is called by the

process.

See the comments of |EndStepOver| for more details.

debug::Status UninstallFromMemorySpace (ProcessHandle & process)

Uninstalls this breakpoint from the given process' memory space. This process handle can be a

different process than the |process_| associated with this object. This is used to clean up

breakpoints after a Posix fork() call (since the installed breakpoints will be copied with

everything else, and we want to treat the processes independently).

Defined at line 137 of file ../../src/developer/debug/debug_agent/process_breakpoint.h

debug::Status Update ()