1ac7ddfbfSEd Maste //===-- ThreadPlanCallUserExpression.cpp ------------------------------*- C++ -*-===//
2ac7ddfbfSEd Maste //
3ac7ddfbfSEd Maste //                     The LLVM Compiler Infrastructure
4ac7ddfbfSEd Maste //
5ac7ddfbfSEd Maste // This file is distributed under the University of Illinois Open Source
6ac7ddfbfSEd Maste // License. See LICENSE.TXT for details.
7ac7ddfbfSEd Maste //
8ac7ddfbfSEd Maste //===----------------------------------------------------------------------===//
9ac7ddfbfSEd Maste 
10ac7ddfbfSEd Maste #include "lldb/Target/ThreadPlanCallUserExpression.h"
11ac7ddfbfSEd Maste 
12ac7ddfbfSEd Maste // C Includes
13ac7ddfbfSEd Maste // C++ Includes
14ac7ddfbfSEd Maste // Other libraries and framework includes
15ac7ddfbfSEd Maste #include "llvm/Support/MachO.h"
16ac7ddfbfSEd Maste // Project includes
17ac7ddfbfSEd Maste #include "lldb/lldb-private-log.h"
18ac7ddfbfSEd Maste #include "lldb/Breakpoint/Breakpoint.h"
19ac7ddfbfSEd Maste #include "lldb/Breakpoint/BreakpointLocation.h"
20ac7ddfbfSEd Maste #include "lldb/Core/Address.h"
21ac7ddfbfSEd Maste #include "lldb/Core/Log.h"
22ac7ddfbfSEd Maste #include "lldb/Core/Stream.h"
23ac7ddfbfSEd Maste #include "lldb/Expression/ClangUserExpression.h"
24ac7ddfbfSEd Maste #include "lldb/Target/LanguageRuntime.h"
25ac7ddfbfSEd Maste #include "lldb/Target/Process.h"
26ac7ddfbfSEd Maste #include "lldb/Target/RegisterContext.h"
27ac7ddfbfSEd Maste #include "lldb/Target/StopInfo.h"
28ac7ddfbfSEd Maste #include "lldb/Target/Target.h"
29ac7ddfbfSEd Maste #include "lldb/Target/Thread.h"
30ac7ddfbfSEd Maste #include "lldb/Target/ThreadPlanRunToAddress.h"
31ac7ddfbfSEd Maste 
32ac7ddfbfSEd Maste using namespace lldb;
33ac7ddfbfSEd Maste using namespace lldb_private;
34ac7ddfbfSEd Maste 
35ac7ddfbfSEd Maste //----------------------------------------------------------------------
36ac7ddfbfSEd Maste // ThreadPlanCallUserExpression: Plan to call a single function
37ac7ddfbfSEd Maste //----------------------------------------------------------------------
38ac7ddfbfSEd Maste 
39ac7ddfbfSEd Maste ThreadPlanCallUserExpression::ThreadPlanCallUserExpression (Thread &thread,
40ac7ddfbfSEd Maste                                                 Address &function,
41ac7ddfbfSEd Maste                                                 lldb::addr_t arg,
42ac7ddfbfSEd Maste                                                 bool stop_other_threads,
43ac7ddfbfSEd Maste                                                 bool unwind_on_error,
44ac7ddfbfSEd Maste                                                 bool ignore_breakpoints,
45ac7ddfbfSEd Maste                                                 lldb::addr_t *this_arg,
46ac7ddfbfSEd Maste                                                 lldb::addr_t *cmd_arg,
47ac7ddfbfSEd Maste                                                 ClangUserExpression::ClangUserExpressionSP &user_expression_sp) :
48ac7ddfbfSEd Maste     ThreadPlanCallFunction (thread, function, ClangASTType(), arg, stop_other_threads, unwind_on_error, ignore_breakpoints, this_arg, cmd_arg),
49ac7ddfbfSEd Maste     m_user_expression_sp (user_expression_sp)
50ac7ddfbfSEd Maste {
51ac7ddfbfSEd Maste     // User expressions are generally "User generated" so we should set them up to stop when done.
52ac7ddfbfSEd Maste     SetIsMasterPlan (true);
53ac7ddfbfSEd Maste     SetOkayToDiscard(false);
54ac7ddfbfSEd Maste }
55ac7ddfbfSEd Maste 
56ac7ddfbfSEd Maste ThreadPlanCallUserExpression::~ThreadPlanCallUserExpression ()
57ac7ddfbfSEd Maste {
58ac7ddfbfSEd Maste }
59ac7ddfbfSEd Maste 
60ac7ddfbfSEd Maste void
61ac7ddfbfSEd Maste ThreadPlanCallUserExpression::GetDescription (Stream *s, lldb::DescriptionLevel level)
62ac7ddfbfSEd Maste {
63ac7ddfbfSEd Maste     ThreadPlanCallFunction::GetDescription (s, level);
64ac7ddfbfSEd Maste }
65ac7ddfbfSEd Maste 
66ac7ddfbfSEd Maste StopInfoSP
67ac7ddfbfSEd Maste ThreadPlanCallUserExpression::GetRealStopInfo()
68ac7ddfbfSEd Maste {
69ac7ddfbfSEd Maste     StopInfoSP stop_info_sp = ThreadPlanCallFunction::GetRealStopInfo();
70ac7ddfbfSEd Maste 
71ac7ddfbfSEd Maste     if (stop_info_sp)
72ac7ddfbfSEd Maste     {
73ac7ddfbfSEd Maste         lldb::addr_t addr = GetStopAddress();
74ac7ddfbfSEd Maste         DynamicCheckerFunctions *checkers = m_thread.GetProcess()->GetDynamicCheckers();
75ac7ddfbfSEd Maste         StreamString s;
76ac7ddfbfSEd Maste 
77ac7ddfbfSEd Maste         if (checkers && checkers->DoCheckersExplainStop(addr, s))
78ac7ddfbfSEd Maste             stop_info_sp->SetDescription(s.GetData());
79ac7ddfbfSEd Maste     }
80ac7ddfbfSEd Maste 
81ac7ddfbfSEd Maste     return stop_info_sp;
82ac7ddfbfSEd Maste }
83