[Lldb-commits] [lldb] r157225 - in /lldb/trunk: include/lldb/Breakpoint/BreakpointResolverFileLine.h include/lldb/Target/Target.h source/API/SBTarget.cpp source/Breakpoint/BreakpointResolverFileLine.cpp source/Commands/CommandObjectBreakpoint.cpp source/Commands/CommandObjectBreakpoint.h source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp source/Plugins/Platform/MacOSX/PlatformDarwin.cpp source/Target/Target.cpp

Jim Ingham jingham at apple.com
Mon May 21 17:12:21 PDT 2012


Author: jingham
Date: Mon May 21 19:12:20 2012
New Revision: 157225

URL: http://llvm.org/viewvc/llvm-project?rev=157225&view=rev
Log:
Also push file & line breakpoints past the prologue.  Also added a "-K" argument to the relevant
"break set" commands to set this per breakpoint.  Also, some CreateBreakpoint API's in the lldb_private
namespace had "internal" first and "skip_prologue" second.  "internal should always be last.  Fixed that.

rdar://problem/11484729

Modified:
    lldb/trunk/include/lldb/Breakpoint/BreakpointResolverFileLine.h
    lldb/trunk/include/lldb/Target/Target.h
    lldb/trunk/source/API/SBTarget.cpp
    lldb/trunk/source/Breakpoint/BreakpointResolverFileLine.cpp
    lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp
    lldb/trunk/source/Commands/CommandObjectBreakpoint.h
    lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
    lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
    lldb/trunk/source/Target/Target.cpp

Modified: lldb/trunk/include/lldb/Breakpoint/BreakpointResolverFileLine.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/BreakpointResolverFileLine.h?rev=157225&r1=157224&r2=157225&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Breakpoint/BreakpointResolverFileLine.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/BreakpointResolverFileLine.h Mon May 21 19:12:20 2012
@@ -31,7 +31,8 @@
     BreakpointResolverFileLine (Breakpoint *bkpt,
                                 const FileSpec &resolver,
                                 uint32_t line_no,
-                                bool check_inlines);
+                                bool check_inlines,
+                                bool skip_prologue);
 
     virtual
     ~BreakpointResolverFileLine ();
@@ -62,6 +63,7 @@
     FileSpec m_file_spec; // This is the file spec we are looking for.
     uint32_t m_line_number; // This is the line number that we are looking for.
     bool m_inlines; // This determines whether the resolver looks for inlined functions or not.
+    bool m_skip_prologue;
 
 private:
     DISALLOW_COPY_AND_ASSIGN(BreakpointResolverFileLine);

Modified: lldb/trunk/include/lldb/Target/Target.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=157225&r1=157224&r2=157225&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Target.h (original)
+++ lldb/trunk/include/lldb/Target/Target.h Mon May 21 19:12:20 2012
@@ -448,6 +448,7 @@
                       const FileSpec &file,
                       uint32_t line_no,
                       bool check_inlines,
+                      LazyBool skip_prologue = eLazyBoolCalculate,
                       bool internal = false);
 
     // Use this to create breakpoint that matches regex against the source lines in files given in source_file_list:
@@ -474,8 +475,8 @@
     CreateFuncRegexBreakpoint (const FileSpecList *containingModules,
                       const FileSpecList *containingSourceFiles,
                       RegularExpression &func_regexp,
-                      bool internal = false,
-                      LazyBool skip_prologue = eLazyBoolCalculate);
+                      LazyBool skip_prologue = eLazyBoolCalculate,
+                      bool internal = false);
 
     // Use this to create a function breakpoint by name in containingModule, or all modules if it is NULL
     // When "skip_prologue is set to eLazyBoolCalculate, we use the current target 
@@ -485,8 +486,8 @@
                       const FileSpecList *containingSourceFiles,
                       const char *func_name,
                       uint32_t func_name_type_mask, 
-                      bool internal = false,
-                      LazyBool skip_prologue = eLazyBoolCalculate);
+                      LazyBool skip_prologue = eLazyBoolCalculate,
+                      bool internal = false);
                       
     lldb::BreakpointSP
     CreateExceptionBreakpoint (enum lldb::LanguageType language, bool catch_bp, bool throw_bp, bool internal = false);
@@ -500,16 +501,16 @@
                       const char *func_names[],
                       size_t num_names, 
                       uint32_t func_name_type_mask, 
-                      bool internal = false,
-                      LazyBool skip_prologue = eLazyBoolCalculate);
+                      LazyBool skip_prologue = eLazyBoolCalculate,
+                      bool internal = false);
 
     lldb::BreakpointSP
     CreateBreakpoint (const FileSpecList *containingModules,
                       const FileSpecList *containingSourceFiles,
                       const std::vector<std::string> &func_names,
                       uint32_t func_name_type_mask,
-                      bool internal = false,
-                      LazyBool skip_prologue = eLazyBoolCalculate);
+                      LazyBool skip_prologue = eLazyBoolCalculate,
+                      bool internal = false);
 
 
     // Use this to create a general breakpoint:

Modified: lldb/trunk/source/API/SBTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=157225&r1=157224&r2=157225&view=diff
==============================================================================
--- lldb/trunk/source/API/SBTarget.cpp (original)
+++ lldb/trunk/source/API/SBTarget.cpp Mon May 21 19:12:20 2012
@@ -1170,7 +1170,11 @@
     if (target_sp && line != 0)
     {
         Mutex::Locker api_locker (target_sp->GetAPIMutex());
-        *sb_bp = target_sp->CreateBreakpoint (NULL, *sb_file_spec, line, true, false);
+        
+        const bool check_inlines = true;
+        const bool internal = false;
+        const LazyBool skip_prologue = eLazyBoolCalculate;
+        *sb_bp = target_sp->CreateBreakpoint (NULL, *sb_file_spec, line, check_inlines, skip_prologue, internal);
     }
 
     if (log)
@@ -1200,15 +1204,18 @@
     if (target_sp.get())
     {
         Mutex::Locker api_locker (target_sp->GetAPIMutex());
+        
+        const bool internal = false;
+        const LazyBool skip_prologue = eLazyBoolCalculate;
         if (module_name && module_name[0])
         {
             FileSpecList module_spec_list;
             module_spec_list.Append (FileSpec (module_name, false));
-            *sb_bp = target_sp->CreateBreakpoint (&module_spec_list, NULL, symbol_name, eFunctionNameTypeAuto, false);
+            *sb_bp = target_sp->CreateBreakpoint (&module_spec_list, NULL, symbol_name, eFunctionNameTypeAuto, skip_prologue, internal);
         }
         else
         {
-            *sb_bp = target_sp->CreateBreakpoint (NULL, NULL, symbol_name, eFunctionNameTypeAuto, false);
+            *sb_bp = target_sp->CreateBreakpoint (NULL, NULL, symbol_name, eFunctionNameTypeAuto, skip_prologue, internal);
         }
     }
     
@@ -1242,12 +1249,15 @@
     TargetSP target_sp(GetSP());
     if (target_sp && symbol_name && symbol_name[0])
     {
+        const bool internal = false;
+        const LazyBool skip_prologue = eLazyBoolCalculate;
         Mutex::Locker api_locker (target_sp->GetAPIMutex());
         *sb_bp = target_sp->CreateBreakpoint (module_list.get(), 
                                                 comp_unit_list.get(), 
                                                 symbol_name, 
                                                 name_type_mask, 
-                                                false);
+                                                skip_prologue,
+                                                internal);
     }
     
     if (log)
@@ -1273,12 +1283,15 @@
     if (target_sp && num_names > 0)
     {
         Mutex::Locker api_locker (target_sp->GetAPIMutex());
+        const bool internal = false;
+        const LazyBool skip_prologue = eLazyBoolCalculate;
         *sb_bp = target_sp->CreateBreakpoint (module_list.get(), 
                                                 comp_unit_list.get(), 
                                                 symbol_names,
                                                 num_names,
                                                 name_type_mask, 
-                                                false);
+                                                skip_prologue,
+                                                internal);
     }
     
     if (log)
@@ -1314,17 +1327,19 @@
     {
         Mutex::Locker api_locker (target_sp->GetAPIMutex());
         RegularExpression regexp(symbol_name_regex);
+        const bool internal = false;
+        const LazyBool skip_prologue = eLazyBoolCalculate;
         
         if (module_name && module_name[0])
         {
             FileSpecList module_spec_list;
             module_spec_list.Append (FileSpec (module_name, false));
             
-            *sb_bp = target_sp->CreateFuncRegexBreakpoint (&module_spec_list, NULL, regexp, false);
+            *sb_bp = target_sp->CreateFuncRegexBreakpoint (&module_spec_list, NULL, regexp, skip_prologue, internal);
         }
         else
         {
-            *sb_bp = target_sp->CreateFuncRegexBreakpoint (NULL, NULL, regexp, false);
+            *sb_bp = target_sp->CreateFuncRegexBreakpoint (NULL, NULL, regexp, skip_prologue, internal);
         }
     }
 
@@ -1350,8 +1365,10 @@
     {
         Mutex::Locker api_locker (target_sp->GetAPIMutex());
         RegularExpression regexp(symbol_name_regex);
+        const bool internal = false;
+        const LazyBool skip_prologue = eLazyBoolCalculate;
         
-        *sb_bp = target_sp->CreateFuncRegexBreakpoint (module_list.get(), comp_unit_list.get(), regexp, false);
+        *sb_bp = target_sp->CreateFuncRegexBreakpoint (module_list.get(), comp_unit_list.get(), regexp, skip_prologue, internal);
     }
 
     if (log)

Modified: lldb/trunk/source/Breakpoint/BreakpointResolverFileLine.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointResolverFileLine.cpp?rev=157225&r1=157224&r2=157225&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/BreakpointResolverFileLine.cpp (original)
+++ lldb/trunk/source/Breakpoint/BreakpointResolverFileLine.cpp Mon May 21 19:12:20 2012
@@ -16,6 +16,7 @@
 #include "lldb/Breakpoint/BreakpointLocation.h"
 #include "lldb/Core/Log.h"
 #include "lldb/Core/StreamString.h"
+#include "lldb/Target/Target.h"
 #include "lldb/lldb-private-log.h"
 
 using namespace lldb;
@@ -29,12 +30,14 @@
     Breakpoint *bkpt,
     const FileSpec &file_spec,
     uint32_t line_no,
-    bool check_inlines
+    bool check_inlines,
+    bool skip_prologue
 ) :
     BreakpointResolver (bkpt, BreakpointResolver::FileLineResolver),
     m_file_spec (file_spec),
     m_line_number (line_no),
-    m_inlines (check_inlines)
+    m_inlines (check_inlines),
+    m_skip_prologue(skip_prologue)
 {
 }
 
@@ -135,12 +138,36 @@
                     {
                         if (filter.AddressPasses(line_start))
                         {
+                            // If the line number is before the prologue end, move it there...
+                            bool skipped_prologue = false;
+                            if (m_skip_prologue)
+                            {
+                                if (sc.function)
+                                {
+                                    Address prologue_addr(sc.function->GetAddressRange().GetBaseAddress());
+                                    if (prologue_addr.IsValid() && (line_start == prologue_addr))
+                                    {
+                                        const uint32_t prologue_byte_size = sc.function->GetPrologueByteSize();
+                                        if (prologue_byte_size)
+                                        {
+                                            prologue_addr.Slide(prologue_byte_size);
+                     
+                                            if (filter.AddressPasses(prologue_addr))
+                                            {
+                                                skipped_prologue = true;
+                                                line_start = prologue_addr;
+                                            }
+                                        }
+                                    }
+                                }
+                            }
+                        
                             BreakpointLocationSP bp_loc_sp (m_breakpoint->AddLocation(line_start));
                             if (log && bp_loc_sp && !m_breakpoint->IsInternal())
                             {
                                 StreamString s;
                                 bp_loc_sp->GetDescription (&s, lldb::eDescriptionLevelVerbose);
-                                log->Printf ("Added location: %s\n", s.GetData());
+                                log->Printf ("Added location (skipped prologue: %s): %s \n", skipped_prologue ? "yes" : "no", s.GetData());
                             }
                         }
                         else if (log)

Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp?rev=157225&r1=157224&r2=157225&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Mon May 21 19:12:20 2012
@@ -66,7 +66,8 @@
     m_queue_name(),
     m_catch_bp (false),
     m_throw_bp (false),
-    m_language (eLanguageTypeUnknown)
+    m_language (eLanguageTypeUnknown),
+    m_skip_prologue (eLazyBoolCalculate)
 {
 }
 
@@ -78,6 +79,7 @@
 // update the numbers passed to LLDB_OPT_SET_FROM_TO(...) appropriately.
 #define LLDB_OPT_FILE ( LLDB_OPT_SET_FROM_TO(1, 9) & ~LLDB_OPT_SET_2 )
 #define LLDB_OPT_NOT_10 ( LLDB_OPT_SET_FROM_TO(1, 10) & ~LLDB_OPT_SET_10 )
+#define LLDB_OPT_SKIP_PROLOGUE ( LLDB_OPT_SET_1 | LLDB_OPT_SET_FROM_TO(3,8) )
 
 OptionDefinition
 CommandObjectBreakpointSet::CommandOptions::g_option_table[] =
@@ -148,6 +150,9 @@
     { LLDB_OPT_SET_10, false, "on-catch", 'h', required_argument, NULL, 0, eArgTypeBoolean,
         "Set the breakpoint on exception catcH." },
 
+    { LLDB_OPT_SKIP_PROLOGUE, false, "skip-prologue", 'K', required_argument, NULL, 0, eArgTypeBoolean,
+        "sKip the prologue if the breakpoint is at the beginning of a function.  If not set the target.skip-prologue setting is used." },
+
     { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
 };
 
@@ -295,6 +300,19 @@
             if (!success)
                 error.SetErrorStringWithFormat ("Invalid boolean value for on-catch option: '%s'", option_arg);
         }
+        case 'K':
+        {
+            bool success;
+            bool value;
+            value = Args::StringToBoolean (option_arg, true, &success);
+            if (value)
+                m_skip_prologue = eLazyBoolYes;
+            else
+                m_skip_prologue = eLazyBoolNo;
+                
+            if (!success)
+                error.SetErrorStringWithFormat ("Invalid boolean value for skip prologue option: '%s'", option_arg);
+        }
         break;
         default:
             error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
@@ -323,6 +341,7 @@
     m_language = eLanguageTypeUnknown;
     m_catch_bp = false;
     m_throw_bp = true;
+    m_skip_prologue = eLazyBoolCalculate;
 }
 
 //-------------------------------------------------------------------------
@@ -430,6 +449,8 @@
     FileSpec module_spec;
     bool use_module = false;
     int num_modules = m_options.m_modules.GetSize();
+    
+    const bool internal = false;
 
     if ((num_modules > 0) && (break_type != eSetTypeAddress))
         use_module = true;
@@ -461,7 +482,9 @@
                 bp = target->CreateBreakpoint (&(m_options.m_modules),
                                                file,
                                                m_options.m_line_num,
-                                               m_options.m_check_inlines).get();
+                                               m_options.m_check_inlines,
+                                               m_options.m_skip_prologue,
+                                               internal).get();
             }
             break;
 
@@ -480,7 +503,8 @@
                                                &(m_options.m_filenames),
                                                m_options.m_func_names,
                                                name_type_mask,
-                                               Breakpoint::Exact).get();
+                                               m_options.m_skip_prologue,
+                                               internal).get();
             }
             break;
 
@@ -497,7 +521,11 @@
                     return false;
                 }
                 
-                bp = target->CreateFuncRegexBreakpoint (&(m_options.m_modules), &(m_options.m_filenames), regexp).get();
+                bp = target->CreateFuncRegexBreakpoint (&(m_options.m_modules),
+                                                        &(m_options.m_filenames),
+                                                        regexp,
+                                                        m_options.m_skip_prologue,
+                                                        internal).get();
             }
             break;
         case eSetTypeSourceRegexp: // Breakpoint by regexp on source text.

Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.h?rev=157225&r1=157224&r2=157225&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectBreakpoint.h (original)
+++ lldb/trunk/source/Commands/CommandObjectBreakpoint.h Mon May 21 19:12:20 2012
@@ -116,6 +116,7 @@
         bool m_catch_bp;
         bool m_throw_bp;
         lldb::LanguageType m_language;
+        LazyBool m_skip_prologue;
 
     };
 

Modified: lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp?rev=157225&r1=157224&r2=157225&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp (original)
+++ lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp Mon May 21 19:12:20 2012
@@ -710,7 +710,7 @@
         DEBUG_PRINTF("DynamicLoaderDarwinKernel::%s() process state = %s\n", __FUNCTION__, StateAsCString(m_process->GetState()));
 
         
-        const bool internal_bp = false;
+        const bool internal_bp = true;
         const LazyBool skip_prologue = eLazyBoolNo;
         FileSpecList module_spec_list;
         module_spec_list.Append (m_kernel.module_sp->GetFileSpec());
@@ -718,8 +718,8 @@
                                                                   NULL,
                                                                   "OSKextLoadedKextSummariesUpdated",
                                                                   eFunctionNameTypeFull,
-                                                                  internal_bp,
-                                                                  skip_prologue).get();
+                                                                  skip_prologue,
+                                                                  internal_bp).get();
 
         bp->SetCallback (DynamicLoaderDarwinKernel::BreakpointHitCallback, this, true);
         m_break_id = bp->GetID();

Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp?rev=157225&r1=157224&r2=157225&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp Mon May 21 19:12:20 2012
@@ -848,12 +848,15 @@
         bp_modules.Append(FileSpec(bp_module, false));
     }
 
+    bool internal = true;
+    LazyBool skip_prologue = eLazyBoolNo;
     bp_sp = target.CreateBreakpoint (&bp_modules,
                                      NULL,
                                      g_bp_names,
                                      sizeof(g_bp_names)/sizeof(const char *),
                                      eFunctionNameTypeFull,
-                                     true);
+                                     skip_prologue,
+                                     internal);
 
     return bp_sp;
 }

Modified: lldb/trunk/source/Target/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=157225&r1=157224&r2=157225&view=diff
==============================================================================
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Mon May 21 19:12:20 2012
@@ -234,10 +234,17 @@
 
 
 BreakpointSP
-Target::CreateBreakpoint (const FileSpecList *containingModules, const FileSpec &file, uint32_t line_no, bool check_inlines, bool internal)
+Target::CreateBreakpoint (const FileSpecList *containingModules,
+                          const FileSpec &file,
+                          uint32_t line_no,
+                          bool check_inlines,
+                          LazyBool skip_prologue,
+                          bool internal)
 {
     SearchFilterSP filter_sp(GetSearchFilterForModuleList (containingModules));
-    BreakpointResolverSP resolver_sp(new BreakpointResolverFileLine (NULL, file, line_no, check_inlines));
+    
+    BreakpointResolverSP resolver_sp(new BreakpointResolverFileLine (NULL, file, line_no, check_inlines,
+                                                                     skip_prologue == eLazyBoolCalculate ? GetSkipPrologue() : skip_prologue));
     return CreateBreakpoint (filter_sp, resolver_sp, internal);
 }
 
@@ -273,8 +280,8 @@
                           const FileSpecList *containingSourceFiles,
                           const char *func_name, 
                           uint32_t func_name_type_mask, 
-                          bool internal,
-                          LazyBool skip_prologue)
+                          LazyBool skip_prologue,
+                          bool internal)
 {
     BreakpointSP bp_sp;
     if (func_name)
@@ -296,8 +303,8 @@
                           const FileSpecList *containingSourceFiles,
                           const std::vector<std::string> &func_names,
                           uint32_t func_name_type_mask,
-                          bool internal,
-                          LazyBool skip_prologue)
+                          LazyBool skip_prologue,
+                          bool internal)
 {
     BreakpointSP bp_sp;
     size_t num_names = func_names.size();
@@ -320,8 +327,8 @@
                           const char *func_names[],
                           size_t num_names, 
                           uint32_t func_name_type_mask, 
-                          bool internal,
-                          LazyBool skip_prologue)
+                          LazyBool skip_prologue,
+                          bool internal)
 {
     BreakpointSP bp_sp;
     if (num_names > 0)
@@ -377,7 +384,8 @@
 }
 
 SearchFilterSP
-Target::GetSearchFilterForModuleAndCUList (const FileSpecList *containingModules, const FileSpecList *containingSourceFiles)
+Target::GetSearchFilterForModuleAndCUList (const FileSpecList *containingModules,
+                                           const FileSpecList *containingSourceFiles)
 {
     if (containingSourceFiles == NULL || containingSourceFiles->GetSize() == 0)
         return GetSearchFilterForModuleList(containingModules);
@@ -399,10 +407,10 @@
 
 BreakpointSP
 Target::CreateFuncRegexBreakpoint (const FileSpecList *containingModules, 
-                          const FileSpecList *containingSourceFiles,
-                          RegularExpression &func_regex, 
-                          bool internal,
-                          LazyBool skip_prologue)
+                                   const FileSpecList *containingSourceFiles,
+                                   RegularExpression &func_regex, 
+                                   LazyBool skip_prologue,
+                                   bool internal)
 {
     SearchFilterSP filter_sp(GetSearchFilterForModuleAndCUList (containingModules, containingSourceFiles));
     BreakpointResolverSP resolver_sp(new BreakpointResolverName (NULL, 





More information about the lldb-commits mailing list