[Lldb-commits] [lldb] r199943 - Add a "step-avoid-libraries" setting to complement the "step-avoid-regexp" setting.

Jim Ingham jingham at apple.com
Thu Jan 23 13:52:47 PST 2014


Author: jingham
Date: Thu Jan 23 15:52:47 2014
New Revision: 199943

URL: http://llvm.org/viewvc/llvm-project?rev=199943&view=rev
Log:
Add a "step-avoid-libraries" setting to complement the "step-avoid-regexp" setting.

Modified:
    lldb/trunk/include/lldb/Target/Thread.h
    lldb/trunk/include/lldb/Target/ThreadPlanStepInRange.h
    lldb/trunk/source/Target/Thread.cpp
    lldb/trunk/source/Target/ThreadPlanStepInRange.cpp

Modified: lldb/trunk/include/lldb/Target/Thread.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Thread.h?rev=199943&r1=199942&r2=199943&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Thread.h (original)
+++ lldb/trunk/include/lldb/Target/Thread.h Thu Jan 23 15:52:47 2014
@@ -44,6 +44,9 @@ public:
     const RegularExpression *
     GetSymbolsToAvoidRegexp();
     
+    FileSpecList &
+    GetLibrariesToAvoid() const;
+    
     bool
     GetTraceEnabledState() const;
 };

Modified: lldb/trunk/include/lldb/Target/ThreadPlanStepInRange.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlanStepInRange.h?rev=199943&r1=199942&r2=199943&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/ThreadPlanStepInRange.h (original)
+++ lldb/trunk/include/lldb/Target/ThreadPlanStepInRange.h Thu Jan 23 15:52:47 2014
@@ -73,7 +73,7 @@ protected:
     SetFlagsToDefault ();
     
     bool
-    FrameMatchesAvoidRegexp ();
+    FrameMatchesAvoidCriteria ();
 
 private:
 

Modified: lldb/trunk/source/Target/Thread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=199943&r1=199942&r2=199943&view=diff
==============================================================================
--- lldb/trunk/source/Target/Thread.cpp (original)
+++ lldb/trunk/source/Target/Thread.cpp Thu Jan 23 15:52:47 2014
@@ -18,6 +18,7 @@
 #include "lldb/Core/StreamString.h"
 #include "lldb/Core/RegularExpression.h"
 #include "lldb/Host/Host.h"
+#include "lldb/Interpreter/OptionValueFileSpecList.h"
 #include "lldb/Symbol/Function.h"
 #include "lldb/Target/DynamicLoader.h"
 #include "lldb/Target/ExecutionContext.h"
@@ -61,12 +62,14 @@ static PropertyDefinition
 g_properties[] =
 {
     { "step-avoid-regexp",  OptionValue::eTypeRegex  , true , REG_EXTENDED, "^std::", NULL, "A regular expression defining functions step-in won't stop in." },
+    { "step-avoid-libraries",  OptionValue::eTypeFileSpecList  , true , REG_EXTENDED, NULL, NULL, "A list of libraries that source stepping won't stop in." },
     { "trace-thread",       OptionValue::eTypeBoolean, false, false, NULL, NULL, "If true, this thread will single-step and log execution." },
     {  NULL               , OptionValue::eTypeInvalid, false, 0    , NULL, NULL, NULL  }
 };
 
 enum {
     ePropertyStepAvoidRegex,
+    ePropertyStepAvoidLibraries,
     ePropertyEnableThreadTrace
 };
 
@@ -132,6 +135,15 @@ ThreadProperties::GetSymbolsToAvoidRegex
     return m_collection_sp->GetPropertyAtIndexAsOptionValueRegex (NULL, idx);
 }
 
+FileSpecList &
+ThreadProperties::GetLibrariesToAvoid() const
+{
+    const uint32_t idx = ePropertyStepAvoidLibraries;
+    OptionValueFileSpecList *option_value = m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList (NULL, false, idx);
+    assert(option_value);
+    return option_value->GetCurrentValue();
+}
+
 bool
 ThreadProperties::GetTraceEnabledState() const
 {

Modified: lldb/trunk/source/Target/ThreadPlanStepInRange.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepInRange.cpp?rev=199943&r1=199942&r2=199943&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadPlanStepInRange.cpp (original)
+++ lldb/trunk/source/Target/ThreadPlanStepInRange.cpp Thu Jan 23 15:52:47 2014
@@ -16,6 +16,7 @@
 
 #include "lldb/lldb-private-log.h"
 #include "lldb/Core/Log.h"
+#include "lldb/Core/Module.h"
 #include "lldb/Core/Stream.h"
 #include "lldb/Symbol/Symbol.h"
 #include "lldb/Symbol/Function.h"
@@ -273,10 +274,32 @@ ThreadPlanStepInRange::SetDefaultFlagVal
 }
 
 bool
-ThreadPlanStepInRange::FrameMatchesAvoidRegexp ()
+ThreadPlanStepInRange::FrameMatchesAvoidCriteria ()
 {
     StackFrame *frame = GetThread().GetStackFrameAtIndex(0).get();
-
+    
+    // Check the library list first, as that's cheapest:
+    FileSpecList libraries_to_avoid (GetThread().GetLibrariesToAvoid());
+    size_t num_libraries = libraries_to_avoid.GetSize();
+    bool libraries_say_avoid = false;
+    SymbolContext sc(frame->GetSymbolContext(eSymbolContextModule));
+    FileSpec frame_library(sc.module_sp->GetFileSpec());
+    
+    if (frame_library)
+    {
+        for (size_t i = 0; i < num_libraries; i++)
+        {
+            const FileSpec &file_spec(libraries_to_avoid.GetFileSpecAtIndex(i));
+            if (FileSpec::Equal (file_spec, frame_library, false))
+            {
+                libraries_say_avoid = true;
+                break;
+            }
+        }
+    }
+    if (libraries_say_avoid)
+        return true;
+    
     const RegularExpression *avoid_regexp_to_use = m_avoid_regexp_ap.get();
     if (avoid_regexp_to_use == NULL)
         avoid_regexp_to_use = GetThread().GetSymbolsToAvoidRegexp();
@@ -368,8 +391,8 @@ ThreadPlanStepInRange::DefaultShouldStop
         if (!should_step_out)
         {
             ThreadPlanStepInRange *step_in_range_plan = static_cast<ThreadPlanStepInRange *> (current_plan);
-            // Don't log the should_step_out here, it's easier to do it in FrameMatchesAvoidRegexp.
-            should_step_out = step_in_range_plan->FrameMatchesAvoidRegexp ();
+            // Don't log the should_step_out here, it's easier to do it in FrameMatchesAvoidCriteria.
+            should_step_out = step_in_range_plan->FrameMatchesAvoidCriteria ();
         }
     }
     





More information about the lldb-commits mailing list