Make an explicit GetThreadSpecNoCreate accessor so you don't have to get the const-ness right to ensure you are not making a copy of the owning breakpoint's ThreadSpec in a breakpoint location. Also change the name from NoCopy to NoCreate since that's clearer.

llvm-svn: 106578
This commit is contained in:
Jim Ingham 2010-06-22 21:12:54 +00:00
parent 6250bd9e3c
commit 05407f6b25
6 changed files with 18 additions and 15 deletions

View File

@ -251,14 +251,16 @@ public:
GetLocationOptions (); GetLocationOptions ();
//------------------------------------------------------------------ //------------------------------------------------------------------
/// Use this to access location specific breakpoint options. /// Use this to access breakpoint options from this breakpoint location.
/// This will point to the owning breakpoint's options unless options have
/// been set specifically on this location.
/// ///
/// @return /// @return
/// A pointer to the containing breakpoint's options if this /// A pointer to the containing breakpoint's options if this
/// location doesn't have its own copy. /// location doesn't have its own copy.
//------------------------------------------------------------------ //------------------------------------------------------------------
const BreakpointOptions * const BreakpointOptions *
GetOptionsNoCopy () const; GetOptionsNoCreate () const;
bool bool
ValidForThisThread (Thread *thread); ValidForThisThread (Thread *thread);

View File

@ -125,13 +125,14 @@ public:
//------------------------------------------------------------------ //------------------------------------------------------------------
//------------------------------------------------------------------ //------------------------------------------------------------------
/// Return the current thread spec. This is used to pass to Thread::MatchesSpec. /// Return the current thread spec for this option. This will return NULL if the no thread
/// specifications have been set for this Option yet.
/// @return /// @return
/// The thread specification pointer for this option, or NULL if none has /// The thread specification pointer for this option, or NULL if none has
/// been set yet. /// been set yet.
//------------------------------------------------------------------ //------------------------------------------------------------------
const ThreadSpec * const ThreadSpec *
GetThreadSpec () const; GetThreadSpecNoCreate () const;
//------------------------------------------------------------------ //------------------------------------------------------------------
/// Returns a pointer to the ThreadSpec for this option, creating it. /// Returns a pointer to the ThreadSpec for this option, creating it.

View File

@ -104,7 +104,7 @@ SBBreakpointLocation::GetThreadID ()
{ {
tid_t sb_thread_id = (lldb::tid_t) LLDB_INVALID_THREAD_ID; tid_t sb_thread_id = (lldb::tid_t) LLDB_INVALID_THREAD_ID;
if (m_break_loc_sp) if (m_break_loc_sp)
sb_thread_id = m_break_loc_sp->GetLocationOptions()->GetThreadSpec()->GetTID(); sb_thread_id = m_break_loc_sp->GetLocationOptions()->GetThreadSpecNoCreate()->GetTID();
return sb_thread_id; return sb_thread_id;
} }
@ -121,7 +121,7 @@ SBBreakpointLocation::GetThreadIndex() const
{ {
if (m_break_loc_sp) if (m_break_loc_sp)
{ {
const ThreadSpec *thread_spec = m_break_loc_sp->GetOptionsNoCopy()->GetThreadSpec(); const ThreadSpec *thread_spec = m_break_loc_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate();
if (thread_spec == NULL) if (thread_spec == NULL)
return 0; return 0;
else else
@ -143,7 +143,7 @@ SBBreakpointLocation::GetThreadName () const
{ {
if (m_break_loc_sp) if (m_break_loc_sp)
{ {
const ThreadSpec *thread_spec = m_break_loc_sp->GetOptionsNoCopy()->GetThreadSpec(); const ThreadSpec *thread_spec = m_break_loc_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate();
if (thread_spec == NULL) if (thread_spec == NULL)
return NULL; return NULL;
else else
@ -164,7 +164,7 @@ SBBreakpointLocation::GetQueueName () const
{ {
if (m_break_loc_sp) if (m_break_loc_sp)
{ {
const ThreadSpec *thread_spec = m_break_loc_sp->GetOptionsNoCopy()->GetThreadSpec(); const ThreadSpec *thread_spec = m_break_loc_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate();
if (thread_spec == NULL) if (thread_spec == NULL)
return NULL; return NULL;
else else

View File

@ -140,7 +140,7 @@ BreakpointLocation::ClearCallback ()
int32_t int32_t
BreakpointLocation::GetIgnoreCount () BreakpointLocation::GetIgnoreCount ()
{ {
return GetOptionsNoCopy()->GetIgnoreCount(); return GetOptionsNoCreate()->GetIgnoreCount();
} }
void void
@ -150,7 +150,7 @@ BreakpointLocation::SetIgnoreCount (int32_t n)
} }
const BreakpointOptions * const BreakpointOptions *
BreakpointLocation::GetOptionsNoCopy () const BreakpointLocation::GetOptionsNoCreate () const
{ {
if (m_options_ap.get() != NULL) if (m_options_ap.get() != NULL)
return m_options_ap.get(); return m_options_ap.get();
@ -173,7 +173,7 @@ BreakpointLocation::GetLocationOptions ()
bool bool
BreakpointLocation::ValidForThisThread (Thread *thread) BreakpointLocation::ValidForThisThread (Thread *thread)
{ {
return thread->MatchesSpec(GetOptionsNoCopy()->GetThreadSpec()); return thread->MatchesSpec(GetOptionsNoCreate()->GetThreadSpecNoCreate());
} }
// RETURNS - true if we should stop at this breakpoint, false if we // RETURNS - true if we should stop at this breakpoint, false if we
@ -383,7 +383,7 @@ BreakpointLocation::Dump(Stream *s) const
s->Printf("BreakpointLocation %u: tid = %4.4x load addr = 0x%8.8llx state = %s type = %s breakpoint " s->Printf("BreakpointLocation %u: tid = %4.4x load addr = 0x%8.8llx state = %s type = %s breakpoint "
"hw_index = %i hit_count = %-4u ignore_count = %-4u", "hw_index = %i hit_count = %-4u ignore_count = %-4u",
GetID(), GetID(),
GetOptionsNoCopy()->GetThreadSpec()->GetTID(), GetOptionsNoCreate()->GetThreadSpecNoCreate()->GetTID(),
(uint64_t) m_address.GetLoadAddress(m_owner.GetTarget().GetProcessSP().get()), (uint64_t) m_address.GetLoadAddress(m_owner.GetTarget().GetProcessSP().get()),
(m_options_ap.get() ? m_options_ap->IsEnabled() : m_owner.IsEnabled()) ? "enabled " : "disabled", (m_options_ap.get() ? m_options_ap->IsEnabled() : m_owner.IsEnabled()) ? "enabled " : "disabled",
IsHardware() ? "hardware" : "software", IsHardware() ? "hardware" : "software",

View File

@ -173,7 +173,7 @@ BreakpointOptions::SetIgnoreCount (int32_t n)
} }
const ThreadSpec * const ThreadSpec *
BreakpointOptions::GetThreadSpec () const BreakpointOptions::GetThreadSpecNoCreate () const
{ {
return m_thread_spec_ap.get(); return m_thread_spec_ap.get();
} }
@ -200,7 +200,7 @@ BreakpointOptions::GetDescription (Stream *s, lldb::DescriptionLevel level) cons
// Figure out if there are any options not at their default value, and only print // Figure out if there are any options not at their default value, and only print
// anything if there are: // anything if there are:
if (m_ignore_count != 0 || !m_enabled || (GetThreadSpec() != NULL && GetThreadSpec()->HasSpecification ())) if (m_ignore_count != 0 || !m_enabled || (GetThreadSpecNoCreate() != NULL && GetThreadSpecNoCreate()->HasSpecification ()))
{ {
if (level == lldb::eDescriptionLevelVerbose) if (level == lldb::eDescriptionLevelVerbose)
{ {

View File

@ -536,7 +536,7 @@ CommandObjectBreakpointCommandList::Execute (Args& command,
{ {
BreakpointLocationSP bp_loc_sp(bp->FindLocationByID (cur_bp_id.GetLocationID())); BreakpointLocationSP bp_loc_sp(bp->FindLocationByID (cur_bp_id.GetLocationID()));
if (bp_loc_sp) if (bp_loc_sp)
bp_options = bp_loc_sp->GetOptionsNoCopy(); bp_options = bp_loc_sp->GetOptionsNoCreate();
else else
{ {
result.AppendErrorWithFormat("Invalid breakpoint ID: %u.%u.\n", result.AppendErrorWithFormat("Invalid breakpoint ID: %u.%u.\n",