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