• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===-- ThreadPlanShouldStopHere.cpp ----------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #include "lldb/Target/RegisterContext.h"
11 #include "lldb/Target/Thread.h"
12 #include "lldb/Target/ThreadPlanShouldStopHere.h"
13 #include "lldb/Core/Log.h"
14 
15 using namespace lldb;
16 using namespace lldb_private;
17 
18 // C Includes
19 // C++ Includes
20 // Other libraries and framework includes
21 // Project includes
22 
23 //----------------------------------------------------------------------
24 // ThreadPlanShouldStopHere constructor
25 //----------------------------------------------------------------------
ThreadPlanShouldStopHere(ThreadPlan * owner,ThreadPlanShouldStopHereCallback callback,void * baton)26 ThreadPlanShouldStopHere::ThreadPlanShouldStopHere(ThreadPlan *owner, ThreadPlanShouldStopHereCallback callback, void *baton) :
27     m_callback (callback),
28     m_baton (baton),
29     m_owner (owner),
30     m_flags (ThreadPlanShouldStopHere::eNone)
31 {
32 }
33 
34 //----------------------------------------------------------------------
35 // Destructor
36 //----------------------------------------------------------------------
~ThreadPlanShouldStopHere()37 ThreadPlanShouldStopHere::~ThreadPlanShouldStopHere()
38 {
39 }
40 
41 void
SetShouldStopHereCallback(ThreadPlanShouldStopHereCallback callback,void * baton)42 ThreadPlanShouldStopHere::SetShouldStopHereCallback (ThreadPlanShouldStopHereCallback callback, void *baton)
43 {
44     m_callback = callback;
45     m_baton = baton;
46 }
47 
48 ThreadPlanSP
InvokeShouldStopHereCallback()49 ThreadPlanShouldStopHere::InvokeShouldStopHereCallback ()
50 {
51     if (m_callback)
52     {
53         ThreadPlanSP return_plan_sp(m_callback (m_owner, m_flags, m_baton));
54         Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
55         if (log)
56         {
57             lldb::addr_t current_addr = m_owner->GetThread().GetRegisterContext()->GetPC(0);
58 
59             if (return_plan_sp)
60             {
61                 StreamString s;
62                 return_plan_sp->GetDescription (&s, lldb::eDescriptionLevelFull);
63                 log->Printf ("ShouldStopHere callback found a step out plan from 0x%" PRIx64 ": %s.", current_addr, s.GetData());
64             }
65             else
66             {
67                 log->Printf ("ShouldStopHere callback didn't find a step out plan from: 0x%" PRIx64 ".", current_addr);
68             }
69         }
70         return return_plan_sp;
71     }
72     else
73         return ThreadPlanSP();
74 }
75