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

#include "lldb/Breakpoint/BreakpointSite.h"

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

Public Types

enum  Type { eSoftware, eHardware, eExternal }
 

Public Member Functions

 ~BreakpointSite () override
 
uint8_t * GetTrapOpcodeBytes ()
 Returns the Opcode Bytes for this breakpoint. More...
 
const uint8_t * GetTrapOpcodeBytes () const
 Returns the Opcode Bytes for this breakpoint - const version. More...
 
size_t GetTrapOpcodeMaxByteSize () const
 Get the size of the trap opcode for this address. More...
 
bool SetTrapOpcode (const uint8_t *trap_opcode, uint32_t trap_opcode_size)
 Sets the trap opcode. More...
 
uint8_t * GetSavedOpcodeBytes ()
 Gets the original instruction bytes that were overwritten by the trap. More...
 
const uint8_t * GetSavedOpcodeBytes () const
 Gets the original instruction bytes that were overwritten by the trap const version. More...
 
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. More...
 
bool IsEnabled () const
 Tells whether the current breakpoint site is enabled or not. More...
 
void SetEnabled (bool enabled)
 Sets whether the current breakpoint site is enabled or not. More...
 
bool ShouldStop (StoppointCallbackContext *context) override
 Enquires of the breakpoint locations that produced this breakpoint site whether we should stop at this location. More...
 
void Dump (Stream *s) const override
 Standard Dump method. More...
 
void AddOwner (const lldb::BreakpointLocationSP &owner)
 The "Owners" are the breakpoint locations that share this breakpoint site. More...
 
size_t GetNumberOfOwners ()
 This method returns the number of breakpoint locations currently located at this breakpoint site. More...
 
lldb::BreakpointLocationSP GetOwnerAtIndex (size_t idx)
 This method returns the breakpoint location at index index located at this breakpoint site. More...
 
size_t CopyOwnersList (BreakpointLocationCollection &out_collection)
 This method copies the breakpoint site's owners into a new collection. More...
 
bool ValidForThisThread (Thread &thread)
 Check whether the owners of this breakpoint site have any thread specifiers, and if yes, is thread contained in any of these specifiers. More...
 
void GetDescription (Stream *s, lldb::DescriptionLevel level)
 Print a description of this breakpoint site to the stream s. More...
 
bool IsBreakpointAtThisSite (lldb::break_id_t bp_id)
 Tell whether a breakpoint has a location at this site. More...
 
bool IsInternal () const
 Tell whether ALL the breakpoints in the location collection are internal. More...
 
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
 
uint32_t GetHardwareIndex () const
 
void SetHardwareIndex (uint32_t index)
 
lldb::break_id_t GetID () const
 

Private Member Functions

void BumpHitCounts ()
 
size_t RemoveOwner (lldb::break_id_t break_id, lldb::break_id_t break_loc_id)
 The method removes the owner at break_loc_id from this breakpoint list. More...
 
 BreakpointSite (BreakpointSiteList *list, const lldb::BreakpointLocationSP &owner, 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. More...
 
uint8_t m_saved_opcode [8]
 The saved opcode bytes if this breakpoint site uses trap opcodes. More...
 
uint8_t m_trap_opcode [8]
 The opcode that was used to create the breakpoint if it is a software breakpoint site. More...
 
bool m_enabled
 Boolean indicating if this breakpoint site enabled or not. More...
 
BreakpointLocationCollection m_owners
 This has the BreakpointLocations that share this breakpoint site. More...
 
std::recursive_mutex m_owners_mutex
 This mutex protects the owners collection. More...
 

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. More...
 
lldb::addr_t m_addr
 The load address of this stop point. More...
 
bool m_is_hardware_required
 True if this point is required to use hardware (which may fail due to the lack of resources). More...
 
uint32_t m_hardware_index
 The hardware resource index for this breakpoint/watchpoint. More...
 
uint32_t m_byte_size
 The size in bytes of stoppoint, e.g. More...
 
StoppointHitCounter m_hit_counter
 Number of times this breakpoint/watchpoint has been hit. More...
 

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 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]

lldb_private::BreakpointSite::BreakpointSite ( BreakpointSiteList list,
const lldb::BreakpointLocationSP &  owner,
lldb::addr_t  m_addr,
bool  use_hardware 
)
private

◆ BreakpointSite() [2/2]

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

Member Function Documentation

◆ AddOwner()

void BreakpointSite::AddOwner ( const lldb::BreakpointLocationSP &  owner)

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

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

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

Definition at line 125 of file BreakpointSite.cpp.

References lldb_private::BreakpointLocationCollection::Add(), m_owners, and m_owners_mutex.

◆ BumpHitCounts()

void BreakpointSite::BumpHitCounts ( )
private

◆ CopyOwnersList()

size_t BreakpointSite::CopyOwnersList ( BreakpointLocationCollection out_collection)

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

It does this while the owners mutex is locked.

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

Definition at line 202 of file BreakpointSite.cpp.

References lldb_private::BreakpointLocationCollection::Add(), lldb_private::BreakpointLocationCollection::BreakpointLocations(), lldb_private::BreakpointLocationCollection::GetSize(), m_owners, and m_owners_mutex.

◆ Dump()

void BreakpointSite::Dump ( Stream s) const
overridevirtual

◆ 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 owners. 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 84 of file BreakpointSite.cpp.

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

◆ GetNextID()

break_id_t BreakpointSite::GetNextID ( )
staticprivate

Definition at line 42 of file BreakpointSite.cpp.

◆ GetNumberOfOwners()

size_t BreakpointSite::GetNumberOfOwners ( )

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

Returns
The number of owners.

Definition at line 137 of file BreakpointSite.cpp.

References lldb_private::BreakpointLocationCollection::GetSize(), m_owners, and m_owners_mutex.

◆ GetOwnerAtIndex()

BreakpointLocationSP BreakpointSite::GetOwnerAtIndex ( size_t  idx)

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

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

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

Definition at line 142 of file BreakpointSite.cpp.

References lldb_private::BreakpointLocationCollection::GetByIndex(), m_owners, and m_owners_mutex.

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

◆ GetSavedOpcodeBytes() [1/2]

const uint8_t * BreakpointSite::GetSavedOpcodeBytes ( )

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

Definition at line 115 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* lldb_private::BreakpointSite::GetSavedOpcodeBytes ( ) const

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

◆ GetTrapOpcodeBytes() [1/2]

const uint8_t * BreakpointSite::GetTrapOpcodeBytes ( )

Returns the Opcode Bytes for this breakpoint.

Definition at line 94 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* lldb_private::BreakpointSite::GetTrapOpcodeBytes ( ) const

Returns the Opcode Bytes for this breakpoint - const version.

◆ GetTrapOpcodeMaxByteSize()

size_t BreakpointSite::GetTrapOpcodeMaxByteSize ( ) const

Get the size of the trap opcode for this address.

Definition at line 100 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 159 of file BreakpointSite.cpp.

References 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 64 of file BreakpointSite.cpp.

References lldb_private::BreakpointLocationCollection::GetByIndex(), lldb_private::BreakpointLocationCollection::GetSize(), m_owners, and m_owners_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 owners, 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 121 of file BreakpointSite.cpp.

References m_enabled.

Referenced by lldb_private::process_gdb_remote::ProcessGDBRemote::DidForkSwitchHardwareTraps(), lldb_private::process_gdb_remote::ProcessGDBRemote::DidForkSwitchSoftwareBreakpoints(), ProcessKDP::DisableBreakpointSite(), lldb_private::process_gdb_remote::ProcessGDBRemote::DisableBreakpointSite(), lldb_private::Process::DisableSoftwareBreakpoint(), ProcessKDP::EnableBreakpointSite(), lldb_private::process_gdb_remote::ProcessGDBRemote::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 92 of file BreakpointSite.cpp.

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

◆ operator=()

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

◆ RemoveOwner()

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

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

Definition at line 130 of file BreakpointSite.cpp.

References lldb_private::BreakpointLocationCollection::GetSize(), m_owners, m_owners_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 50 of file BreakpointSite.cpp.

References lldb_private::StoppointHitCounter::Increment(), lldb_private::StoppointSite::m_hit_counter, m_owners, m_owners_mutex, and lldb_private::BreakpointLocationCollection::ShouldStop().

◆ ValidForThisThread()

bool BreakpointSite::ValidForThisThread ( Thread thread)

Check whether the owners 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 147 of file BreakpointSite.cpp.

References m_owners, m_owners_mutex, and lldb_private::BreakpointLocationCollection::ValidForThisThread().

Friends And Related Function Documentation

◆ BreakpointLocation

friend class BreakpointLocation
friend

Definition at line 198 of file BreakpointSite.h.

◆ Process

friend class Process
friend

Definition at line 197 of file BreakpointSite.h.

◆ StopInfoBreakpoint

friend class StopInfoBreakpoint
friend

Definition at line 202 of file BreakpointSite.h.

Member Data Documentation

◆ m_enabled

bool lldb_private::BreakpointSite::m_enabled
private

Boolean indicating if this breakpoint site enabled or not.

Definition at line 216 of file BreakpointSite.h.

Referenced by IsEnabled(), and SetEnabled().

◆ m_owners

BreakpointLocationCollection lldb_private::BreakpointSite::m_owners
private

◆ m_owners_mutex

std::recursive_mutex lldb_private::BreakpointSite::m_owners_mutex
private

◆ 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 211 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 213 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 210 of file BreakpointSite.h.

Referenced by GetType(), and SetType().


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