From 05407f6b252d6f148274e389126373cef2552cec Mon Sep 17 00:00:00 2001 From: Jim Ingham Date: Tue, 22 Jun 2010 21:12:54 +0000 Subject: [PATCH] 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 --- lldb/include/lldb/Breakpoint/BreakpointLocation.h | 6 ++++-- lldb/include/lldb/Breakpoint/BreakpointOptions.h | 5 +++-- lldb/source/API/SBBreakpointLocation.cpp | 8 ++++---- lldb/source/Breakpoint/BreakpointLocation.cpp | 8 ++++---- lldb/source/Breakpoint/BreakpointOptions.cpp | 4 ++-- lldb/source/Commands/CommandObjectBreakpointCommand.cpp | 2 +- 6 files changed, 18 insertions(+), 15 deletions(-) diff --git a/lldb/include/lldb/Breakpoint/BreakpointLocation.h b/lldb/include/lldb/Breakpoint/BreakpointLocation.h index 7aed5589ec19..1ab667dd9387 100644 --- a/lldb/include/lldb/Breakpoint/BreakpointLocation.h +++ b/lldb/include/lldb/Breakpoint/BreakpointLocation.h @@ -251,14 +251,16 @@ public: 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 /// A pointer to the containing breakpoint's options if this /// location doesn't have its own copy. //------------------------------------------------------------------ const BreakpointOptions * - GetOptionsNoCopy () const; + GetOptionsNoCreate () const; bool ValidForThisThread (Thread *thread); diff --git a/lldb/include/lldb/Breakpoint/BreakpointOptions.h b/lldb/include/lldb/Breakpoint/BreakpointOptions.h index 9dbfd80371e8..c6206df5ead9 100644 --- a/lldb/include/lldb/Breakpoint/BreakpointOptions.h +++ b/lldb/include/lldb/Breakpoint/BreakpointOptions.h @@ -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 /// The thread specification pointer for this option, or NULL if none has /// been set yet. //------------------------------------------------------------------ const ThreadSpec * - GetThreadSpec () const; + GetThreadSpecNoCreate () const; //------------------------------------------------------------------ /// Returns a pointer to the ThreadSpec for this option, creating it. diff --git a/lldb/source/API/SBBreakpointLocation.cpp b/lldb/source/API/SBBreakpointLocation.cpp index 206d5fdddf0c..b5e78596e878 100644 --- a/lldb/source/API/SBBreakpointLocation.cpp +++ b/lldb/source/API/SBBreakpointLocation.cpp @@ -104,7 +104,7 @@ SBBreakpointLocation::GetThreadID () { tid_t sb_thread_id = (lldb::tid_t) LLDB_INVALID_THREAD_ID; 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; } @@ -121,7 +121,7 @@ SBBreakpointLocation::GetThreadIndex() const { 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) return 0; else @@ -143,7 +143,7 @@ SBBreakpointLocation::GetThreadName () const { 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) return NULL; else @@ -164,7 +164,7 @@ SBBreakpointLocation::GetQueueName () const { 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) return NULL; else diff --git a/lldb/source/Breakpoint/BreakpointLocation.cpp b/lldb/source/Breakpoint/BreakpointLocation.cpp index ef9c43152b41..dfaa4eba2523 100644 --- a/lldb/source/Breakpoint/BreakpointLocation.cpp +++ b/lldb/source/Breakpoint/BreakpointLocation.cpp @@ -140,7 +140,7 @@ BreakpointLocation::ClearCallback () int32_t BreakpointLocation::GetIgnoreCount () { - return GetOptionsNoCopy()->GetIgnoreCount(); + return GetOptionsNoCreate()->GetIgnoreCount(); } void @@ -150,7 +150,7 @@ BreakpointLocation::SetIgnoreCount (int32_t n) } const BreakpointOptions * -BreakpointLocation::GetOptionsNoCopy () const +BreakpointLocation::GetOptionsNoCreate () const { if (m_options_ap.get() != NULL) return m_options_ap.get(); @@ -173,7 +173,7 @@ BreakpointLocation::GetLocationOptions () bool 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 @@ -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 " "hw_index = %i hit_count = %-4u ignore_count = %-4u", GetID(), - GetOptionsNoCopy()->GetThreadSpec()->GetTID(), + GetOptionsNoCreate()->GetThreadSpecNoCreate()->GetTID(), (uint64_t) m_address.GetLoadAddress(m_owner.GetTarget().GetProcessSP().get()), (m_options_ap.get() ? m_options_ap->IsEnabled() : m_owner.IsEnabled()) ? "enabled " : "disabled", IsHardware() ? "hardware" : "software", diff --git a/lldb/source/Breakpoint/BreakpointOptions.cpp b/lldb/source/Breakpoint/BreakpointOptions.cpp index c3625140d767..fae9a7bfba94 100644 --- a/lldb/source/Breakpoint/BreakpointOptions.cpp +++ b/lldb/source/Breakpoint/BreakpointOptions.cpp @@ -173,7 +173,7 @@ BreakpointOptions::SetIgnoreCount (int32_t n) } const ThreadSpec * -BreakpointOptions::GetThreadSpec () const +BreakpointOptions::GetThreadSpecNoCreate () const { 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 // 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) { diff --git a/lldb/source/Commands/CommandObjectBreakpointCommand.cpp b/lldb/source/Commands/CommandObjectBreakpointCommand.cpp index cc0687c7b64d..e080450710d3 100644 --- a/lldb/source/Commands/CommandObjectBreakpointCommand.cpp +++ b/lldb/source/Commands/CommandObjectBreakpointCommand.cpp @@ -536,7 +536,7 @@ CommandObjectBreakpointCommandList::Execute (Args& command, { BreakpointLocationSP bp_loc_sp(bp->FindLocationByID (cur_bp_id.GetLocationID())); if (bp_loc_sp) - bp_options = bp_loc_sp->GetOptionsNoCopy(); + bp_options = bp_loc_sp->GetOptionsNoCreate(); else { result.AppendErrorWithFormat("Invalid breakpoint ID: %u.%u.\n",