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
15f48169bbSJim Ingham #include "llvm/Support/MachO.h"
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,
41f48169bbSJim Ingham                                                 lldb::addr_t arg,
42*6fbc48bcSJim Ingham                                                 const EvaluateExpressionOptions &options,
43f48169bbSJim Ingham                                                 lldb::addr_t *this_arg,
4417827830SSean Callanan                                                 lldb::addr_t *cmd_arg,
45f48169bbSJim Ingham                                                 ClangUserExpression::ClangUserExpressionSP &user_expression_sp) :
46*6fbc48bcSJim Ingham     ThreadPlanCallFunction (thread, function, ClangASTType(), arg, options, this_arg, cmd_arg),
47f48169bbSJim Ingham     m_user_expression_sp (user_expression_sp)
48f48169bbSJim Ingham {
49923886ceSJim Ingham     // User expressions are generally "User generated" so we should set them up to stop when done.
50923886ceSJim Ingham     SetIsMasterPlan (true);
51923886ceSJim Ingham     SetOkayToDiscard(false);
52f48169bbSJim Ingham }
53f48169bbSJim Ingham 
54f48169bbSJim Ingham ThreadPlanCallUserExpression::~ThreadPlanCallUserExpression ()
55f48169bbSJim Ingham {
56f48169bbSJim Ingham }
57f48169bbSJim Ingham 
58f48169bbSJim Ingham void
59f48169bbSJim Ingham ThreadPlanCallUserExpression::GetDescription (Stream *s, lldb::DescriptionLevel level)
60f48169bbSJim Ingham {
61f48169bbSJim Ingham     ThreadPlanCallFunction::GetDescription (s, level);
62ce553d88SJim Ingham }
63ce553d88SJim Ingham 
64ce553d88SJim Ingham StopInfoSP
65ce553d88SJim Ingham ThreadPlanCallUserExpression::GetRealStopInfo()
66ce553d88SJim Ingham {
67ce553d88SJim Ingham     StopInfoSP stop_info_sp = ThreadPlanCallFunction::GetRealStopInfo();
6860c4118cSJim Ingham 
6960c4118cSJim Ingham     if (stop_info_sp)
7060c4118cSJim Ingham     {
71ce553d88SJim Ingham         lldb::addr_t addr = GetStopAddress();
721ac04c30SGreg Clayton         DynamicCheckerFunctions *checkers = m_thread.GetProcess()->GetDynamicCheckers();
73ce553d88SJim Ingham         StreamString s;
74ce553d88SJim Ingham 
75ce553d88SJim Ingham         if (checkers && checkers->DoCheckersExplainStop(addr, s))
76ce553d88SJim Ingham             stop_info_sp->SetDescription(s.GetData());
7760c4118cSJim Ingham     }
78ce553d88SJim Ingham 
79ce553d88SJim Ingham     return stop_info_sp;
80f48169bbSJim Ingham }
81