[Lldb-commits] [lldb] r166000 - in /lldb/trunk: include/lldb/Target/Thread.h source/Core/Debugger.cpp source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp source/Plugins/Process/Utility/ThreadMemory.cpp source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp source/Plugins/Process/mach-core/ThreadMachCore.cpp source/Target/Process.cpp source/Target/Thread.cpp test/lang/cpp/dynamic-value/pass-to-base.cpp
Jim Ingham
jingham at apple.com
Mon Oct 15 17:09:34 PDT 2012
Author: jingham
Date: Mon Oct 15 19:09:33 2012
New Revision: 166000
URL: http://llvm.org/viewvc/llvm-project?rev=166000&view=rev
Log:
Patch from Matt Kopec <matt.kopec at intel.com> to fix the problem that if two breakpoints were set on consecutive addresses, the continue from the
first breakpoint would skip the second.
Modified:
lldb/trunk/include/lldb/Target/Thread.h
lldb/trunk/source/Core/Debugger.cpp
lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp
lldb/trunk/source/Plugins/Process/Utility/ThreadMemory.cpp
lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
lldb/trunk/source/Plugins/Process/mach-core/ThreadMachCore.cpp
lldb/trunk/source/Target/Process.cpp
lldb/trunk/source/Target/Thread.cpp
lldb/trunk/test/lang/cpp/dynamic-value/pass-to-base.cpp
Modified: lldb/trunk/include/lldb/Target/Thread.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Thread.h?rev=166000&r1=165999&r2=166000&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Thread.h (original)
+++ lldb/trunk/include/lldb/Target/Thread.h Mon Oct 15 19:09:33 2012
@@ -858,6 +858,10 @@
virtual lldb_private::Unwind *
GetUnwinder ();
+ // Check to see whether the thread is still at the last breakpoint hit that stopped it.
+ virtual const bool
+ IsStillAtLastBreakpointHit();
+
lldb::StackFrameListSP
GetStackFrameList ();
Modified: lldb/trunk/source/Core/Debugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=166000&r1=165999&r2=166000&view=diff
==============================================================================
--- lldb/trunk/source/Core/Debugger.cpp (original)
+++ lldb/trunk/source/Core/Debugger.cpp Mon Oct 15 19:09:33 2012
@@ -1952,7 +1952,7 @@
else if (::strncmp (var_name_begin, "stop-reason}", strlen("stop-reason}")) == 0)
{
StopInfoSP stop_info_sp = thread->GetStopInfo ();
- if (stop_info_sp)
+ if (stop_info_sp && stop_info_sp->IsValid())
{
cstr = stop_info_sp->GetDescription();
if (cstr && cstr[0])
@@ -1965,7 +1965,7 @@
else if (::strncmp (var_name_begin, "return-value}", strlen("return-value}")) == 0)
{
StopInfoSP stop_info_sp = thread->GetStopInfo ();
- if (stop_info_sp)
+ if (stop_info_sp && stop_info_sp->IsValid())
{
ValueObjectSP return_valobj_sp = StopInfo::GetReturnValueObject (stop_info_sp);
if (return_valobj_sp)
Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp?rev=166000&r1=165999&r2=166000&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp Mon Oct 15 19:09:33 2012
@@ -179,6 +179,9 @@
if (m_thread_stop_reason_stop_id != process_stop_id ||
(m_actual_stop_info_sp && !m_actual_stop_info_sp->IsValid()))
{
+ if (IsStillAtLastBreakpointHit())
+ return m_actual_stop_info_sp;
+
if (m_cached_stop_info_sp)
SetStopInfo (m_cached_stop_info_sp);
else
Modified: lldb/trunk/source/Plugins/Process/Utility/ThreadMemory.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/ThreadMemory.cpp?rev=166000&r1=165999&r2=166000&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/ThreadMemory.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Utility/ThreadMemory.cpp Mon Oct 15 19:09:33 2012
@@ -107,6 +107,9 @@
if (m_thread_stop_reason_stop_id != process_stop_id ||
(m_actual_stop_info_sp && !m_actual_stop_info_sp->IsValid()))
{
+ if (IsStillAtLastBreakpointHit())
+ return m_actual_stop_info_sp;
+
// If GetGDBProcess().SetThreadStopInfo() doesn't find a stop reason
// for this thread, then m_actual_stop_info_sp will not ever contain
// a valid stop reason and the "m_actual_stop_info_sp->IsValid() == false"
Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp?rev=166000&r1=165999&r2=166000&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp Mon Oct 15 19:09:33 2012
@@ -225,6 +225,9 @@
if (m_thread_stop_reason_stop_id != process_stop_id ||
(m_actual_stop_info_sp && !m_actual_stop_info_sp->IsValid()))
{
+ if (IsStillAtLastBreakpointHit())
+ return m_actual_stop_info_sp;
+
// If GetGDBProcess().SetThreadStopInfo() doesn't find a stop reason
// for this thread, then m_actual_stop_info_sp will not ever contain
// a valid stop reason and the "m_actual_stop_info_sp->IsValid() == false"
Modified: lldb/trunk/source/Plugins/Process/mach-core/ThreadMachCore.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/mach-core/ThreadMachCore.cpp?rev=166000&r1=165999&r2=166000&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/mach-core/ThreadMachCore.cpp (original)
+++ lldb/trunk/source/Plugins/Process/mach-core/ThreadMachCore.cpp Mon Oct 15 19:09:33 2012
@@ -136,6 +136,9 @@
if (m_thread_stop_reason_stop_id != process_stop_id ||
(m_actual_stop_info_sp && !m_actual_stop_info_sp->IsValid()))
{
+ if (IsStillAtLastBreakpointHit())
+ return m_actual_stop_info_sp;
+
// TODO: can we query the initial state of the thread here?
// For now I am just going to pretend that a SIGSTOP happened.
Modified: lldb/trunk/source/Target/Process.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=166000&r1=165999&r2=166000&view=diff
==============================================================================
--- lldb/trunk/source/Target/Process.cpp (original)
+++ lldb/trunk/source/Target/Process.cpp Mon Oct 15 19:09:33 2012
@@ -3741,7 +3741,7 @@
}
StopInfoSP stop_info_sp = thread_sp->GetStopInfo ();
- if (stop_info_sp)
+ if (stop_info_sp && stop_info_sp->IsValid())
{
stop_info_sp->PerformAction(event_ptr);
// The stop action might restart the target. If it does, then we want to mark that in the
@@ -4905,7 +4905,8 @@
{
if (only_threads_with_stop_reason)
{
- if (thread->GetStopInfo().get() == NULL)
+ StopInfoSP stop_info_sp = thread->GetStopInfo();
+ if (stop_info_sp.get() == NULL || !stop_info_sp->IsValid())
continue;
}
thread->GetStatus (strm,
Modified: lldb/trunk/source/Target/Thread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=166000&r1=165999&r2=166000&view=diff
==============================================================================
--- lldb/trunk/source/Target/Thread.cpp (original)
+++ lldb/trunk/source/Target/Thread.cpp Mon Oct 15 19:09:33 2012
@@ -440,9 +440,11 @@
// telling the current plan it will resume, since we might change what the current
// plan is.
- lldb::addr_t pc = GetRegisterContext()->GetPC();
- BreakpointSiteSP bp_site_sp = GetProcess()->GetBreakpointSiteList().FindByAddress(pc);
- if (bp_site_sp && bp_site_sp->IsEnabled())
+ StopReason stop_reason = lldb::eStopReasonInvalid;
+ StopInfoSP stop_info_sp = GetStopInfo();
+ if (stop_info_sp.get())
+ stop_reason = stop_info_sp->GetStopReason();
+ if (stop_reason == lldb::eStopReasonBreakpoint)
{
// Note, don't assume there's a ThreadPlanStepOverBreakpoint, the target may not require anything
// special to step over a breakpoint.
@@ -506,7 +508,7 @@
// If the WillResume for the plan says we are faking a resume, then it will have set an appropriate stop info.
// In that case, don't reset it here.
- if (need_to_resume)
+ if (need_to_resume && resume_state != eStateSuspended)
{
m_actual_stop_info_sp.reset();
}
@@ -1713,3 +1715,22 @@
ClearStackFrames ();
m_reg_context_sp.reset();
}
+
+const bool
+Thread::IsStillAtLastBreakpointHit ()
+{
+ // If we are currently stopped at a breakpoint, always return that stopinfo and don't reset it.
+ // This allows threads to maintain their breakpoint stopinfo, such as when thread-stepping in
+ // multithreaded programs.
+ if (m_actual_stop_info_sp) {
+ StopReason stop_reason = m_actual_stop_info_sp->GetStopReason();
+ if (stop_reason == lldb::eStopReasonBreakpoint) {
+ uint64_t value = m_actual_stop_info_sp->GetValue();
+ lldb::addr_t pc = GetRegisterContext()->GetPC();
+ BreakpointSiteSP bp_site_sp = GetProcess()->GetBreakpointSiteList().FindByAddress(pc);
+ if (bp_site_sp && value == bp_site_sp->GetID())
+ return true;
+ }
+ }
+ return false;
+}
Modified: lldb/trunk/test/lang/cpp/dynamic-value/pass-to-base.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/cpp/dynamic-value/pass-to-base.cpp?rev=166000&r1=165999&r2=166000&view=diff
==============================================================================
--- lldb/trunk/test/lang/cpp/dynamic-value/pass-to-base.cpp (original)
+++ lldb/trunk/test/lang/cpp/dynamic-value/pass-to-base.cpp Mon Oct 15 19:09:33 2012
@@ -23,7 +23,8 @@
doSomething (A &anotherA)
{
printf ("In A %p doing something with %d.\n", this, m_a_value);
- printf ("Also have another A at %p: %d.\n", &anotherA, anotherA.Value()); // Break here in doSomething.
+ int tmp_value = anotherA.Value();
+ printf ("Also have another A at %p: %d.\n", &anotherA, tmp_value); // Break here in doSomething.
}
int
More information about the lldb-commits
mailing list