LLDB mainline
Public Types | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Friends | List of all members
lldb_private::BreakpointSite Class Reference

Class that manages the actual breakpoint that will be inserted into the running program. More...

#include "lldb/Breakpoint/BreakpointSite.h"

Inheritance diagram for lldb_private::BreakpointSite:
Inheritance graph
[legend]

Public Types

enum  Type { eSoftware , eHardware , eExternal }
 
typedef lldb::break_id_t SiteID
 
typedef lldb::break_id_t ConstituentID
 

Public Member Functions

 ~BreakpointSite () override
 
uint8_t * GetTrapOpcodeBytes ()
 Returns the Opcode Bytes for this breakpoint.
 
const uint8_t * GetTrapOpcodeBytes () const
 Returns the Opcode Bytes for this breakpoint - const version.
 
size_t GetTrapOpcodeMaxByteSize () const
 Get the size of the trap opcode for this address.
 
bool SetTrapOpcode (const uint8_t *trap_opcode, uint32_t trap_opcode_size)
 Sets the trap opcode.
 
uint8_t * GetSavedOpcodeBytes ()
 Gets the original instruction bytes that were overwritten by the trap.
 
const uint8_t * GetSavedOpcodeBytes () const
 Gets the original instruction bytes that were overwritten by the trap const version.
 
bool IntersectsRange (lldb::addr_t addr, size_t size, lldb::addr_t *intersect_addr, size_t *intersect_size, size_t *opcode_offset) const
 Says whether addr and size size intersects with the address intersect_addr.
 
bool IsEnabled () const
 Tells whether the current breakpoint site is enabled or not.
 
void SetEnabled (bool enabled)
 Sets whether the current breakpoint site is enabled or not.
 
bool ShouldStop (StoppointCallbackContext *context) override
 Enquires of the breakpoint locations that produced this breakpoint site whether we should stop at this location.
 
void Dump (Stream *s) const override
 Standard Dump method.
 
void AddConstituent (const lldb::BreakpointLocationSP &constituent)
 The "Constituents" are the breakpoint locations that share this breakpoint site.
 
size_t GetNumberOfConstituents ()
 This method returns the number of breakpoint locations currently located at this breakpoint site.
 
lldb::BreakpointLocationSP GetConstituentAtIndex (size_t idx)
 This method returns the breakpoint location at index index located at this breakpoint site.
 
size_t CopyConstituentsList (BreakpointLocationCollection &out_collection)
 This method copies the breakpoint site's constituents into a new collection.
 
bool ValidForThisThread (Thread &thread)
 Check whether the constituents of this breakpoint site have any thread specifiers, and if yes, is thread contained in any of these specifiers.
 
void GetDescription (Stream *s, lldb::DescriptionLevel level)
 Print a description of this breakpoint site to the stream s.
 
bool IsBreakpointAtThisSite (lldb::break_id_t bp_id)
 Tell whether a breakpoint has a location at this site.
 
bool IsInternal () const
 Tell whether ALL the breakpoints in the location collection are internal.
 
bool IsHardware () const override
 
BreakpointSite::Type GetType () const
 
void SetType (BreakpointSite::Type type)
 
- Public Member Functions inherited from lldb_private::StoppointSite
 StoppointSite (lldb::break_id_t bid, lldb::addr_t m_addr, bool hardware)
 
 StoppointSite (lldb::break_id_t bid, lldb::addr_t m_addr, uint32_t byte_size, bool hardware)
 
virtual ~StoppointSite ()=default
 
virtual lldb::addr_t GetLoadAddress () const
 
virtual void SetLoadAddress (lldb::addr_t addr)
 
uint32_t GetByteSize () const
 
uint32_t GetHitCount () const
 
void ResetHitCount ()
 
bool HardwareRequired () const
 
virtual bool IsHardware () const =0
 
virtual bool ShouldStop (StoppointCallbackContext *context)=0
 
virtual void Dump (Stream *stream) const =0
 
lldb::break_id_t GetID () const
 

Private Member Functions

void BumpHitCounts ()
 
size_t RemoveConstituent (lldb::break_id_t break_id, lldb::break_id_t break_loc_id)
 The method removes the constituent at break_loc_id from this breakpoint list.
 
 BreakpointSite (const lldb::BreakpointLocationSP &constituent, lldb::addr_t m_addr, bool use_hardware)
 
 BreakpointSite (const BreakpointSite &)=delete
 
const BreakpointSiteoperator= (const BreakpointSite &)=delete
 

Static Private Member Functions

static lldb::break_id_t GetNextID ()
 

Private Attributes

BreakpointSite::Type m_type
 The type of this breakpoint site.
 
uint8_t m_saved_opcode [8]
 The saved opcode bytes if this breakpoint site uses trap opcodes.
 
uint8_t m_trap_opcode [8]
 The opcode that was used to create the breakpoint if it is a software breakpoint site.
 
bool m_enabled
 Boolean indicating if this breakpoint site enabled or not.
 
BreakpointLocationCollection m_constituents
 This has the BreakpointLocations that share this breakpoint site.
 
std::recursive_mutex m_constituents_mutex
 This mutex protects the constituents collection.
 

Friends

class Process
 
class BreakpointLocation
 
class StopInfoBreakpoint
 

Additional Inherited Members

- Protected Attributes inherited from lldb_private::StoppointSite
lldb::break_id_t m_id
 Stoppoint site ID.
 
lldb::addr_t m_addr
 The load address of this stop point.
 
bool m_is_hardware_required
 True if this point is required to use hardware (which may fail due to the lack of resources).
 
uint32_t m_byte_size
 The size in bytes of stoppoint, e.g.
 
StoppointHitCounter m_hit_counter
 Number of times this breakpoint/watchpoint has been hit.
 

Detailed Description

Class that manages the actual breakpoint that will be inserted into the running program.

The BreakpointSite class handles the physical breakpoint that is actually inserted in the target program. As such, it is also the one that gets hit, when the program stops. It keeps a list of all BreakpointLocations that share this physical site. When the breakpoint is hit, all the locations are informed by the breakpoint site. Breakpoint sites are owned by the process.

Definition at line 35 of file BreakpointSite.h.

Member Typedef Documentation

◆ ConstituentID

Definition at line 49 of file BreakpointSite.h.

◆ SiteID

Definition at line 48 of file BreakpointSite.h.

Member Enumeration Documentation

◆ Type

Enumerator
eSoftware 
eHardware 
eExternal 

Definition at line 38 of file BreakpointSite.h.

Constructor & Destructor Documentation

◆ ~BreakpointSite()

BreakpointSite::~BreakpointSite ( )
override

◆ BreakpointSite() [1/2]

BreakpointSite::BreakpointSite ( const lldb::BreakpointLocationSP constituent,
lldb::addr_t  m_addr,
bool  use_hardware 
)
private

◆ BreakpointSite() [2/2]

lldb_private::BreakpointSite::BreakpointSite ( const BreakpointSite )
privatedelete

Member Function Documentation

◆ AddConstituent()

void BreakpointSite::AddConstituent ( const lldb::BreakpointLocationSP constituent)

The "Constituents" are the breakpoint locations that share this breakpoint site.

The method adds the constituent to this breakpoint site's constituent list.

Parameters
[in]constituentconstituent is the Breakpoint Location to add.

Definition at line 123 of file BreakpointSite.cpp.

References lldb_private::BreakpointLocationCollection::Add(), m_constituents, and m_constituents_mutex.

◆ BumpHitCounts()

void BreakpointSite::BumpHitCounts ( )
private

◆ CopyConstituentsList()

size_t BreakpointSite::CopyConstituentsList ( BreakpointLocationCollection out_collection)

This method copies the breakpoint site's constituents into a new collection.

It does this while the constituents mutex is locked.

Parameters
[out]out_collectionThe BreakpointLocationCollection into which to put the constituents of this breakpoint site.
Returns
The number of elements copied into out_collection.

Definition at line 199 of file BreakpointSite.cpp.

References lldb_private::BreakpointLocationCollection::Add(), lldb_private::BreakpointLocationCollection::BreakpointLocations(), lldb_private::BreakpointLocationCollection::GetSize(), m_constituents, and m_constituents_mutex.

◆ Dump()

void BreakpointSite::Dump ( Stream s) const
overridevirtual

◆ GetConstituentAtIndex()

BreakpointLocationSP BreakpointSite::GetConstituentAtIndex ( size_t  idx)

This method returns the breakpoint location at index index located at this breakpoint site.

The constituents are listed ordinally from 0 to GetNumberOfConstituents() - 1 so you can use this method to iterate over the constituents

Parameters
[in]idxThe index in the list of constituents for which you wish the constituent location.
Returns
A shared pointer to the breakpoint location at that index.

Definition at line 140 of file BreakpointSite.cpp.

References lldb_private::BreakpointLocationCollection::GetByIndex(), m_constituents, and m_constituents_mutex.

Referenced by lldb_private::Platform::GetSoftwareBreakpointTrapOpcode(), and lldb_private::PlatformDarwin::GetSoftwareBreakpointTrapOpcode().

◆ GetDescription()

void BreakpointSite::GetDescription ( Stream s,
lldb::DescriptionLevel  level 
)

Print a description of this breakpoint site to the stream s.

GetDescription tells you about the breakpoint site's constituents. Use BreakpointSite::Dump(Stream *) to get information about the breakpoint site itself.

Parameters
[in]sThe stream to which to print the description.
[in]levelThe description level that indicates the detail level to provide.
See also
lldb::DescriptionLevel

Definition at line 82 of file BreakpointSite.cpp.

References lldb::eDescriptionLevelBrief, lldb_private::BreakpointLocationCollection::GetDescription(), lldb_private::StoppointSite::GetID(), lldb_private::StoppointSite::GetLoadAddress(), m_constituents, m_constituents_mutex, and lldb_private::Stream::Printf().

◆ GetNextID()

break_id_t BreakpointSite::GetNextID ( )
staticprivate

Definition at line 40 of file BreakpointSite.cpp.

◆ GetNumberOfConstituents()

size_t BreakpointSite::GetNumberOfConstituents ( )

This method returns the number of breakpoint locations currently located at this breakpoint site.

Returns
The number of constituents.

Definition at line 135 of file BreakpointSite.cpp.

References lldb_private::BreakpointLocationCollection::GetSize(), m_constituents, and m_constituents_mutex.

◆ GetSavedOpcodeBytes() [1/2]

uint8_t * BreakpointSite::GetSavedOpcodeBytes ( )

Gets the original instruction bytes that were overwritten by the trap.

Definition at line 113 of file BreakpointSite.cpp.

References m_saved_opcode.

Referenced by lldb_private::Process::DisableSoftwareBreakpoint(), lldb_private::Process::EnableSoftwareBreakpoint(), and lldb_private::Process::WriteMemory().

◆ GetSavedOpcodeBytes() [2/2]

const uint8_t * BreakpointSite::GetSavedOpcodeBytes ( ) const

Gets the original instruction bytes that were overwritten by the trap const version.

Definition at line 115 of file BreakpointSite.cpp.

References m_saved_opcode.

◆ GetTrapOpcodeBytes() [1/2]

uint8_t * BreakpointSite::GetTrapOpcodeBytes ( )

Returns the Opcode Bytes for this breakpoint.

Definition at line 92 of file BreakpointSite.cpp.

References m_trap_opcode.

Referenced by lldb_private::Process::DisableSoftwareBreakpoint(), and lldb_private::Process::EnableSoftwareBreakpoint().

◆ GetTrapOpcodeBytes() [2/2]

const uint8_t * BreakpointSite::GetTrapOpcodeBytes ( ) const

Returns the Opcode Bytes for this breakpoint - const version.

Definition at line 94 of file BreakpointSite.cpp.

References m_trap_opcode.

◆ GetTrapOpcodeMaxByteSize()

size_t BreakpointSite::GetTrapOpcodeMaxByteSize ( ) const

Get the size of the trap opcode for this address.

Definition at line 98 of file BreakpointSite.cpp.

References m_trap_opcode.

◆ GetType()

BreakpointSite::Type lldb_private::BreakpointSite::GetType ( ) const
inline

◆ IntersectsRange()

bool BreakpointSite::IntersectsRange ( lldb::addr_t  addr,
size_t  size,
lldb::addr_t intersect_addr,
size_t *  intersect_size,
size_t *  opcode_offset 
) const

Says whether addr and size size intersects with the address intersect_addr.

Definition at line 157 of file BreakpointSite.cpp.

References eSoftware, GetType(), lldbassert, lldb_private::StoppointSite::m_addr, and lldb_private::StoppointSite::m_byte_size.

Referenced by lldb_private::Process::WriteMemory().

◆ IsBreakpointAtThisSite()

bool BreakpointSite::IsBreakpointAtThisSite ( lldb::break_id_t  bp_id)

Tell whether a breakpoint has a location at this site.

Parameters
[in]bp_idThe breakpoint id to query.
Returns
true if bp_id has a location that is at this site, false otherwise.

Definition at line 62 of file BreakpointSite.cpp.

References lldb_private::BreakpointLocationCollection::GetByIndex(), lldb_private::BreakpointLocationCollection::GetSize(), m_constituents, and m_constituents_mutex.

◆ IsEnabled()

bool BreakpointSite::IsEnabled ( ) const

Tells whether the current breakpoint site is enabled or not.

This is a low-level enable bit for the breakpoint sites. If a breakpoint site has no enabled constituents, it should just get removed. This enable/disable is for the low-level target code to enable and disable breakpoint sites when single stepping, etc.

Definition at line 119 of file BreakpointSite.cpp.

References m_enabled.

Referenced by lldb_private::process_gdb_remote::ProcessGDBRemote::DidForkSwitchHardwareTraps(), lldb_private::process_gdb_remote::ProcessGDBRemote::DidForkSwitchSoftwareBreakpoints(), lldb_private::process_gdb_remote::ProcessGDBRemote::DisableBreakpointSite(), ProcessKDP::DisableBreakpointSite(), lldb_private::Process::DisableSoftwareBreakpoint(), lldb_private::process_gdb_remote::ProcessGDBRemote::EnableBreakpointSite(), lldb_private::ScriptedProcess::EnableBreakpointSite(), ProcessKDP::EnableBreakpointSite(), and lldb_private::Process::EnableSoftwareBreakpoint().

◆ IsHardware()

bool lldb_private::BreakpointSite::IsHardware ( ) const
inlineoverridevirtual

◆ IsInternal()

bool BreakpointSite::IsInternal ( ) const

Tell whether ALL the breakpoints in the location collection are internal.

Returns
true if all breakpoint locations are owned by internal breakpoints, false otherwise.

Definition at line 90 of file BreakpointSite.cpp.

References lldb_private::BreakpointLocationCollection::IsInternal(), and m_constituents.

◆ operator=()

const BreakpointSite & lldb_private::BreakpointSite::operator= ( const BreakpointSite )
privatedelete

◆ RemoveConstituent()

size_t BreakpointSite::RemoveConstituent ( lldb::break_id_t  break_id,
lldb::break_id_t  break_loc_id 
)
private

The method removes the constituent at break_loc_id from this breakpoint list.

Definition at line 128 of file BreakpointSite.cpp.

References lldb_private::BreakpointLocationCollection::GetSize(), m_constituents, m_constituents_mutex, and lldb_private::BreakpointLocationCollection::Remove().

◆ SetEnabled()

void BreakpointSite::SetEnabled ( bool  enabled)

◆ SetTrapOpcode()

bool BreakpointSite::SetTrapOpcode ( const uint8_t *  trap_opcode,
uint32_t  trap_opcode_size 
)

◆ SetType()

void lldb_private::BreakpointSite::SetType ( BreakpointSite::Type  type)
inline

◆ ShouldStop()

bool BreakpointSite::ShouldStop ( StoppointCallbackContext context)
overridevirtual

Enquires of the breakpoint locations that produced this breakpoint site whether we should stop at this location.

Parameters
[in]contextThis contains the information about this stop.
Returns
true if we should stop, false otherwise.

Implements lldb_private::StoppointSite.

Definition at line 48 of file BreakpointSite.cpp.

References lldb_private::StoppointHitCounter::Increment(), m_constituents, m_constituents_mutex, lldb_private::StoppointSite::m_hit_counter, and lldb_private::BreakpointLocationCollection::ShouldStop().

◆ ValidForThisThread()

bool BreakpointSite::ValidForThisThread ( Thread thread)

Check whether the constituents of this breakpoint site have any thread specifiers, and if yes, is thread contained in any of these specifiers.

Parameters
[in]threadThe thread against which to test.

return true if the collection contains at least one location that would be valid for this thread, false otherwise.

Definition at line 145 of file BreakpointSite.cpp.

References m_constituents, m_constituents_mutex, and lldb_private::BreakpointLocationCollection::ValidForThisThread().

Friends And Related Function Documentation

◆ BreakpointLocation

friend class BreakpointLocation
friend

Definition at line 203 of file BreakpointSite.h.

◆ Process

friend class Process
friend

Definition at line 202 of file BreakpointSite.h.

◆ StopInfoBreakpoint

friend class StopInfoBreakpoint
friend

Definition at line 207 of file BreakpointSite.h.

Member Data Documentation

◆ m_constituents

BreakpointLocationCollection lldb_private::BreakpointSite::m_constituents
private

◆ m_constituents_mutex

std::recursive_mutex lldb_private::BreakpointSite::m_constituents_mutex
private

◆ m_enabled

bool lldb_private::BreakpointSite::m_enabled
private

Boolean indicating if this breakpoint site enabled or not.

Definition at line 222 of file BreakpointSite.h.

Referenced by IsEnabled(), and SetEnabled().

◆ m_saved_opcode

uint8_t lldb_private::BreakpointSite::m_saved_opcode[8]
private

The saved opcode bytes if this breakpoint site uses trap opcodes.

Definition at line 217 of file BreakpointSite.h.

Referenced by GetSavedOpcodeBytes().

◆ m_trap_opcode

uint8_t lldb_private::BreakpointSite::m_trap_opcode[8]
private

The opcode that was used to create the breakpoint if it is a software breakpoint site.

Definition at line 219 of file BreakpointSite.h.

Referenced by GetTrapOpcodeBytes(), GetTrapOpcodeMaxByteSize(), and SetTrapOpcode().

◆ m_type

BreakpointSite::Type lldb_private::BreakpointSite::m_type
private

The type of this breakpoint site.

Definition at line 216 of file BreakpointSite.h.

Referenced by GetType(), and SetType().


The documentation for this class was generated from the following files: