tberghammer updated this revision to Diff 34038.
tberghammer added a comment.

Updated the change based on the comments.

I don't fully agree with restricting the user from setting breakpoint in 
non-code locations because if LLDB classified a section incorrectly (e.g. 
haven't found the SO file for it) the user might want to still set a breakpoint 
there. In general I would like to make it possible to set a breakpoint at any 
address (even on un-aligned ones) but warn the user that it might be incorrect.


http://reviews.llvm.org/D12556

Files:
  include/lldb/Core/Address.h
  source/API/SBFrame.cpp
  source/Core/Address.cpp
  source/Target/StackFrame.cpp
  source/Target/StackFrameList.cpp

Index: source/Target/StackFrameList.cpp
===================================================================
--- source/Target/StackFrameList.cpp
+++ source/Target/StackFrameList.cpp
@@ -362,8 +362,8 @@
                         // adjustment it will point to an other section. In that case resolve the
                         // address again to the correct section plus offset form.
                         TargetSP target = m_thread.CalculateTarget();
-                        addr_t load_addr = curr_frame_address.GetOpcodeLoadAddress(target.get());
-                        curr_frame_address.SetOpcodeLoadAddress(load_addr - 1, target.get());
+                        addr_t load_addr = curr_frame_address.GetOpcodeLoadAddress(target.get(), eAddressClassCode);
+                        curr_frame_address.SetOpcodeLoadAddress(load_addr - 1, target.get(), eAddressClassCode);
                     }
                     else
                     {
Index: source/Target/StackFrame.cpp
===================================================================
--- source/Target/StackFrame.cpp
+++ source/Target/StackFrame.cpp
@@ -259,7 +259,7 @@
             TargetSP target_sp (thread_sp->CalculateTarget());
             if (target_sp)
             {
-                if (m_frame_code_addr.SetOpcodeLoadAddress (m_frame_code_addr.GetOffset(), target_sp.get()))
+                if (m_frame_code_addr.SetOpcodeLoadAddress (m_frame_code_addr.GetOffset(), target_sp.get(), eAddressClassCode))
                 {
                     ModuleSP module_sp (m_frame_code_addr.GetModule());
                     if (module_sp)
Index: source/Core/Address.cpp
===================================================================
--- source/Core/Address.cpp
+++ source/Core/Address.cpp
@@ -367,21 +367,29 @@
 }
 
 addr_t
-Address::GetOpcodeLoadAddress (Target *target) const
+Address::GetOpcodeLoadAddress (Target *target, AddressClass addr_class) const
 {
     addr_t code_addr = GetLoadAddress (target);
     if (code_addr != LLDB_INVALID_ADDRESS)
-        code_addr = target->GetOpcodeLoadAddress (code_addr, GetAddressClass());
+    {
+        if (addr_class == eAddressClassInvalid)
+            addr_class = GetAddressClass();
+        code_addr = target->GetOpcodeLoadAddress (code_addr, addr_class);
+    }
     return code_addr;
 }
 
 bool
-Address::SetOpcodeLoadAddress (lldb::addr_t load_addr, Target *target)
+Address::SetOpcodeLoadAddress (lldb::addr_t load_addr, Target *target, AddressClass addr_class)
 {
     if (SetLoadAddress (load_addr, target))
     {
         if (target)
-            m_offset = target->GetOpcodeLoadAddress (m_offset, GetAddressClass());
+        {
+            if (addr_class == eAddressClassInvalid)
+                addr_class = GetAddressClass();
+            m_offset = target->GetOpcodeLoadAddress (m_offset, addr_class);
+        }
         return true;
     }
     return false;
Index: source/API/SBFrame.cpp
===================================================================
--- source/API/SBFrame.cpp
+++ source/API/SBFrame.cpp
@@ -484,7 +484,7 @@
             frame = exe_ctx.GetFramePtr();
             if (frame)
             {
-                addr = frame->GetFrameCodeAddress().GetOpcodeLoadAddress (target);
+                addr = frame->GetFrameCodeAddress().GetOpcodeLoadAddress (target, eAddressClassCode);
             }
             else
             {
Index: include/lldb/Core/Address.h
===================================================================
--- include/lldb/Core/Address.h
+++ include/lldb/Core/Address.h
@@ -326,7 +326,8 @@
     ///     not loaded.
     //------------------------------------------------------------------
     lldb::addr_t
-    GetOpcodeLoadAddress (Target *target) const;
+    GetOpcodeLoadAddress (Target *target,
+                          lldb::AddressClass addr_class = lldb::eAddressClassInvalid) const;
 
     //------------------------------------------------------------------
     /// Get the section relative offset value.
@@ -425,7 +426,9 @@
     SetLoadAddress (lldb::addr_t load_addr, Target *target);
     
     bool
-    SetOpcodeLoadAddress (lldb::addr_t load_addr, Target *target);
+    SetOpcodeLoadAddress (lldb::addr_t load_addr,
+                          Target *target,
+                          lldb::AddressClass addr_class = lldb::eAddressClassInvalid);
 
     bool
     SetCallableLoadAddress (lldb::addr_t load_addr, Target *target);
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to