diff options
Diffstat (limited to 'source/API/SBBreakpoint.cpp')
| -rw-r--r-- | source/API/SBBreakpoint.cpp | 117 | 
1 files changed, 95 insertions, 22 deletions
diff --git a/source/API/SBBreakpoint.cpp b/source/API/SBBreakpoint.cpp index fbdc0e32f498..a950ca934c68 100644 --- a/source/API/SBBreakpoint.cpp +++ b/source/API/SBBreakpoint.cpp @@ -19,9 +19,12 @@  #include "lldb/Breakpoint/BreakpointLocation.h"  #include "lldb/Breakpoint/StoppointCallbackContext.h"  #include "lldb/Core/Address.h" +#include "lldb/Core/Debugger.h"  #include "lldb/Core/Log.h"  #include "lldb/Core/Stream.h"  #include "lldb/Core/StreamFile.h" +#include "lldb/Interpreter/CommandInterpreter.h" +#include "lldb/Interpreter/ScriptInterpreter.h"  #include "lldb/Target/Process.h"  #include "lldb/Target/SectionLoadList.h"  #include "lldb/Target/Target.h" @@ -121,9 +124,11 @@ SBBreakpoint::GetID () const      if (log)      {          if (break_id == LLDB_INVALID_BREAK_ID) -            log->Printf ("SBBreakpoint(%p)::GetID () => LLDB_INVALID_BREAK_ID", m_opaque_sp.get()); +            log->Printf ("SBBreakpoint(%p)::GetID () => LLDB_INVALID_BREAK_ID", +                         static_cast<void*>(m_opaque_sp.get()));          else -            log->Printf ("SBBreakpoint(%p)::GetID () => %u", m_opaque_sp.get(), break_id); +            log->Printf ("SBBreakpoint(%p)::GetID () => %u", +                         static_cast<void*>(m_opaque_sp.get()), break_id);      }      return break_id; @@ -133,7 +138,12 @@ SBBreakpoint::GetID () const  bool  SBBreakpoint::IsValid() const  { -    return (bool) m_opaque_sp; +    if (!m_opaque_sp) +        return false; +    else if (m_opaque_sp->GetTarget().GetBreakpointByID(m_opaque_sp->GetID())) +       return true; +    else +        return false;  }  void @@ -222,7 +232,8 @@ SBBreakpoint::SetEnabled (bool enable)      Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));      if (log) -        log->Printf ("SBBreakpoint(%p)::SetEnabled (enabled=%i)", m_opaque_sp.get(), enable); +        log->Printf ("SBBreakpoint(%p)::SetEnabled (enabled=%i)", +                     static_cast<void*>(m_opaque_sp.get()), enable);      if (m_opaque_sp)      { @@ -249,7 +260,8 @@ SBBreakpoint::SetOneShot (bool one_shot)      Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));      if (log) -        log->Printf ("SBBreakpoint(%p)::SetOneShot (one_shot=%i)", m_opaque_sp.get(), one_shot); +        log->Printf ("SBBreakpoint(%p)::SetOneShot (one_shot=%i)", +                     static_cast<void*>(m_opaque_sp.get()), one_shot);      if (m_opaque_sp)      { @@ -288,8 +300,9 @@ SBBreakpoint::SetIgnoreCount (uint32_t count)      Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));      if (log) -        log->Printf ("SBBreakpoint(%p)::SetIgnoreCount (count=%u)", m_opaque_sp.get(), count); -         +        log->Printf ("SBBreakpoint(%p)::SetIgnoreCount (count=%u)", +                     static_cast<void*>(m_opaque_sp.get()), count); +      if (m_opaque_sp)      {          Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); @@ -330,7 +343,8 @@ SBBreakpoint::GetHitCount () const      Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));      if (log) -        log->Printf ("SBBreakpoint(%p)::GetHitCount () => %u", m_opaque_sp.get(), count); +        log->Printf ("SBBreakpoint(%p)::GetHitCount () => %u", +                     static_cast<void*>(m_opaque_sp.get()), count);      return count;  } @@ -347,7 +361,8 @@ SBBreakpoint::GetIgnoreCount () const      Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));      if (log) -        log->Printf ("SBBreakpoint(%p)::GetIgnoreCount () => %u", m_opaque_sp.get(), count); +        log->Printf ("SBBreakpoint(%p)::GetIgnoreCount () => %u", +                     static_cast<void*>(m_opaque_sp.get()), count);      return count;  } @@ -362,7 +377,8 @@ SBBreakpoint::SetThreadID (tid_t tid)      }      Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));      if (log) -        log->Printf ("SBBreakpoint(%p)::SetThreadID (tid=0x%4.4" PRIx64 ")", m_opaque_sp.get(), tid); +        log->Printf ("SBBreakpoint(%p)::SetThreadID (tid=0x%4.4" PRIx64 ")", +                     static_cast<void*>(m_opaque_sp.get()), tid);  } @@ -378,7 +394,8 @@ SBBreakpoint::GetThreadID ()      Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));      if (log) -        log->Printf ("SBBreakpoint(%p)::GetThreadID () => 0x%4.4" PRIx64, m_opaque_sp.get(), tid); +        log->Printf ("SBBreakpoint(%p)::GetThreadID () => 0x%4.4" PRIx64, +                     static_cast<void*>(m_opaque_sp.get()), tid);      return tid;  } @@ -387,7 +404,8 @@ SBBreakpoint::SetThreadIndex (uint32_t index)  {      Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));      if (log) -        log->Printf ("SBBreakpoint(%p)::SetThreadIndex (%u)", m_opaque_sp.get(), index); +        log->Printf ("SBBreakpoint(%p)::SetThreadIndex (%u)", +                     static_cast<void*>(m_opaque_sp.get()), index);      if (m_opaque_sp)      {          Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); @@ -408,18 +426,19 @@ SBBreakpoint::GetThreadIndex() const      }      Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));      if (log) -        log->Printf ("SBBreakpoint(%p)::GetThreadIndex () => %u", m_opaque_sp.get(), thread_idx); +        log->Printf ("SBBreakpoint(%p)::GetThreadIndex () => %u", +                     static_cast<void*>(m_opaque_sp.get()), thread_idx);      return thread_idx;  } -      void  SBBreakpoint::SetThreadName (const char *thread_name)  {      Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));      if (log) -        log->Printf ("SBBreakpoint(%p)::SetThreadName (%s)", m_opaque_sp.get(), thread_name); +        log->Printf ("SBBreakpoint(%p)::SetThreadName (%s)", +                     static_cast<void*>(m_opaque_sp.get()), thread_name);      if (m_opaque_sp)      { @@ -441,7 +460,8 @@ SBBreakpoint::GetThreadName () const      }      Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));      if (log) -        log->Printf ("SBBreakpoint(%p)::GetThreadName () => %s", m_opaque_sp.get(), name); +        log->Printf ("SBBreakpoint(%p)::GetThreadName () => %s", +                     static_cast<void*>(m_opaque_sp.get()), name);      return name;  } @@ -451,7 +471,8 @@ SBBreakpoint::SetQueueName (const char *queue_name)  {      Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));      if (log) -        log->Printf ("SBBreakpoint(%p)::SetQueueName (%s)", m_opaque_sp.get(), queue_name); +        log->Printf ("SBBreakpoint(%p)::SetQueueName (%s)", +                     static_cast<void*>(m_opaque_sp.get()), queue_name);      if (m_opaque_sp)      {          Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); @@ -472,7 +493,8 @@ SBBreakpoint::GetQueueName () const      }      Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));      if (log) -        log->Printf ("SBBreakpoint(%p)::GetQueueName () => %s", m_opaque_sp.get(), name); +        log->Printf ("SBBreakpoint(%p)::GetQueueName () => %s", +                     static_cast<void*>(m_opaque_sp.get()), name);      return name;  } @@ -488,7 +510,9 @@ SBBreakpoint::GetNumResolvedLocations() const      }      Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));      if (log) -        log->Printf ("SBBreakpoint(%p)::GetNumResolvedLocations () => %" PRIu64, m_opaque_sp.get(), (uint64_t)num_resolved); +        log->Printf ("SBBreakpoint(%p)::GetNumResolvedLocations () => %" PRIu64, +                     static_cast<void*>(m_opaque_sp.get()), +                     static_cast<uint64_t>(num_resolved));      return num_resolved;  } @@ -503,7 +527,9 @@ SBBreakpoint::GetNumLocations() const      }      Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));      if (log) -        log->Printf ("SBBreakpoint(%p)::GetNumLocations () => %" PRIu64, m_opaque_sp.get(), (uint64_t)num_locs); +        log->Printf ("SBBreakpoint(%p)::GetNumLocations () => %" PRIu64, +                     static_cast<void*>(m_opaque_sp.get()), +                     static_cast<uint64_t>(num_locs));      return num_locs;  } @@ -567,9 +593,14 @@ void  SBBreakpoint::SetCallback (BreakpointHitCallback callback, void *baton)  {      Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); -     +      if (log) -        log->Printf ("SBBreakpoint(%p)::SetCallback (callback=%p, baton=%p)", m_opaque_sp.get(), callback, baton); +    { +        void *pointer = &callback; +        log->Printf ("SBBreakpoint(%p)::SetCallback (callback=%p, baton=%p)", +                     static_cast<void*>(m_opaque_sp.get()), +                     *static_cast<void**>(&pointer), static_cast<void*>(baton)); +    }      if (m_opaque_sp)      { @@ -579,6 +610,48 @@ SBBreakpoint::SetCallback (BreakpointHitCallback callback, void *baton)      }  } +void +SBBreakpoint::SetScriptCallbackFunction (const char *callback_function_name) +{ +    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + +    if (log) +        log->Printf ("SBBreakpoint(%p)::SetScriptCallbackFunction (callback=%s)", +                     static_cast<void*>(m_opaque_sp.get()), +                     callback_function_name); + +    if (m_opaque_sp) +    { +        Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); +        BreakpointOptions *bp_options = m_opaque_sp->GetOptions(); +        m_opaque_sp->GetTarget().GetDebugger().GetCommandInterpreter().GetScriptInterpreter()->SetBreakpointCommandCallbackFunction (bp_options, +                                                                                                                                                   callback_function_name); +    } +} + +SBError +SBBreakpoint::SetScriptCallbackBody (const char *callback_body_text) +{ +    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + +    if (log) +        log->Printf ("SBBreakpoint(%p)::SetScriptCallbackBody: callback body:\n%s)", +                     static_cast<void*>(m_opaque_sp.get()), callback_body_text); + +    SBError sb_error; +    if (m_opaque_sp) +    { +        Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); +        BreakpointOptions *bp_options = m_opaque_sp->GetOptions(); +        Error error =  m_opaque_sp->GetTarget().GetDebugger().GetCommandInterpreter().GetScriptInterpreter()->SetBreakpointCommandCallback (bp_options, +                                                                                                                                    callback_body_text); +        sb_error.SetError(error); +    } +    else +        sb_error.SetErrorString("invalid breakpoint"); + +    return sb_error; +}  lldb_private::Breakpoint *  SBBreakpoint::operator->() const  | 
