1f48169bbSJim Ingham //===-- ThreadPlanCallUserExpression.cpp ------------------------------*- C++ -*-===//
2f48169bbSJim Ingham //
3f48169bbSJim Ingham //                     The LLVM Compiler Infrastructure
4f48169bbSJim Ingham //
5f48169bbSJim Ingham // This file is distributed under the University of Illinois Open Source
6f48169bbSJim Ingham // License. See LICENSE.TXT for details.
7f48169bbSJim Ingham //
8f48169bbSJim Ingham //===----------------------------------------------------------------------===//
9f48169bbSJim Ingham 
10f48169bbSJim Ingham #include "lldb/Target/ThreadPlanCallUserExpression.h"
11f48169bbSJim Ingham 
12f48169bbSJim Ingham // C Includes
13f48169bbSJim Ingham // C++ Includes
14f48169bbSJim Ingham // Other libraries and framework includes
15*46d005dbSJim Ingham 
16f48169bbSJim Ingham // Project includes
17f48169bbSJim Ingham #include "lldb/lldb-private-log.h"
18f48169bbSJim Ingham #include "lldb/Breakpoint/Breakpoint.h"
19f48169bbSJim Ingham #include "lldb/Breakpoint/BreakpointLocation.h"
20f48169bbSJim Ingham #include "lldb/Core/Address.h"
21f48169bbSJim Ingham #include "lldb/Core/Log.h"
22f48169bbSJim Ingham #include "lldb/Core/Stream.h"
23f48169bbSJim Ingham #include "lldb/Expression/ClangUserExpression.h"
24f48169bbSJim Ingham #include "lldb/Target/LanguageRuntime.h"
25f48169bbSJim Ingham #include "lldb/Target/Process.h"
26f48169bbSJim Ingham #include "lldb/Target/RegisterContext.h"
27f48169bbSJim Ingham #include "lldb/Target/StopInfo.h"
28f48169bbSJim Ingham #include "lldb/Target/Target.h"
29f48169bbSJim Ingham #include "lldb/Target/Thread.h"
30f48169bbSJim Ingham #include "lldb/Target/ThreadPlanRunToAddress.h"
31f48169bbSJim Ingham 
32f48169bbSJim Ingham using namespace lldb;
33f48169bbSJim Ingham using namespace lldb_private;
34f48169bbSJim Ingham 
35f48169bbSJim Ingham //----------------------------------------------------------------------
36f48169bbSJim Ingham // ThreadPlanCallUserExpression: Plan to call a single function
37f48169bbSJim Ingham //----------------------------------------------------------------------
38f48169bbSJim Ingham 
39f48169bbSJim Ingham ThreadPlanCallUserExpression::ThreadPlanCallUserExpression (Thread &thread,
40f48169bbSJim Ingham                                                 Address &function,
41a464f3d4SSean Callanan                                                 llvm::ArrayRef<lldb::addr_t> args,
426fbc48bcSJim Ingham                                                 const EvaluateExpressionOptions &options,
43f48169bbSJim Ingham                                                 ClangUserExpression::ClangUserExpressionSP &user_expression_sp) :
44a464f3d4SSean Callanan     ThreadPlanCallFunction (thread, function, ClangASTType(), args, options),
45f48169bbSJim Ingham     m_user_expression_sp (user_expression_sp)
46f48169bbSJim Ingham {
47923886ceSJim Ingham     // User expressions are generally "User generated" so we should set them up to stop when done.
48923886ceSJim Ingham     SetIsMasterPlan (true);
49923886ceSJim Ingham     SetOkayToDiscard(false);
50f48169bbSJim Ingham }
51f48169bbSJim Ingham 
52f48169bbSJim Ingham ThreadPlanCallUserExpression::~ThreadPlanCallUserExpression ()
53f48169bbSJim Ingham {
54f48169bbSJim Ingham }
55f48169bbSJim Ingham 
56f48169bbSJim Ingham void
57f48169bbSJim Ingham ThreadPlanCallUserExpression::GetDescription (Stream *s, lldb::DescriptionLevel level)
58f48169bbSJim Ingham {
59f48169bbSJim Ingham     ThreadPlanCallFunction::GetDescription (s, level);
60ce553d88SJim Ingham }
61ce553d88SJim Ingham 
62ce553d88SJim Ingham StopInfoSP
63ce553d88SJim Ingham ThreadPlanCallUserExpression::GetRealStopInfo()
64ce553d88SJim Ingham {
65ce553d88SJim Ingham     StopInfoSP stop_info_sp = ThreadPlanCallFunction::GetRealStopInfo();
6660c4118cSJim Ingham 
6760c4118cSJim Ingham     if (stop_info_sp)
6860c4118cSJim Ingham     {
69ce553d88SJim Ingham         lldb::addr_t addr = GetStopAddress();
701ac04c30SGreg Clayton         DynamicCheckerFunctions *checkers = m_thread.GetProcess()->GetDynamicCheckers();
71ce553d88SJim Ingham         StreamString s;
72ce553d88SJim Ingham 
73ce553d88SJim Ingham         if (checkers && checkers->DoCheckersExplainStop(addr, s))
74ce553d88SJim Ingham             stop_info_sp->SetDescription(s.GetData());
7560c4118cSJim Ingham     }
76ce553d88SJim Ingham 
77ce553d88SJim Ingham     return stop_info_sp;
78f48169bbSJim Ingham }
79