LLDB mainline
ThreadPlanCallUserExpression.cpp
Go to the documentation of this file.
1//===-- ThreadPlanCallUserExpression.cpp ----------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
10
13#include "lldb/Core/Address.h"
17#include "lldb/Host/HostInfo.h"
19#include "lldb/Target/Process.h"
22#include "lldb/Target/Target.h"
23#include "lldb/Target/Thread.h"
26#include "lldb/Utility/Log.h"
27#include "lldb/Utility/Stream.h"
28
29using namespace lldb;
30using namespace lldb_private;
31
32// ThreadPlanCallUserExpression: Plan to call a single function
33
35 Thread &thread, Address &function, llvm::ArrayRef<lldb::addr_t> args,
36 const EvaluateExpressionOptions &options,
37 lldb::UserExpressionSP &user_expression_sp)
38 : ThreadPlanCallFunction(thread, function, CompilerType(), args, options),
39 m_user_expression_sp(user_expression_sp) {
40 // User expressions are generally "User generated" so we should set them up
41 // to stop when done.
43 SetOkayToDiscard(false);
44}
45
47
50 if (level == eDescriptionLevelBrief)
51 s->Printf("User Expression thread plan");
52 else
54}
55
59 m_user_expression_sp->WillStartExecuting();
60}
61
66}
67
69 Log *log = GetLog(LLDBLog::Step);
70
71 if (IsPlanComplete()) {
72 LLDB_LOGF(log, "ThreadPlanCallFunction(%p): Completed call function plan.",
73 static_cast<void *>(this));
74
76 lldb::addr_t function_stack_top;
77 lldb::addr_t function_stack_bottom;
78 lldb::addr_t function_stack_pointer = GetFunctionStackPointer();
79
80 function_stack_bottom = function_stack_pointer - HostInfo::GetPageSize();
81 function_stack_top = function_stack_pointer;
82
83 DiagnosticManager diagnostics;
84
85 ExecutionContext exe_ctx(GetThread());
86
87 m_user_expression_sp->FinalizeJITExecution(
88 diagnostics, exe_ctx, m_result_var_sp, function_stack_bottom,
89 function_stack_top);
90 }
91
93 return true;
94 } else {
95 return false;
96 }
97}
98
101
102 if (stop_info_sp) {
105 StreamString s;
106
107 if (checkers && checkers->DoCheckersExplainStop(addr, s))
108 stop_info_sp->SetDescription(s.GetData());
109 }
110
111 return stop_info_sp;
112}
113
116 m_user_expression_sp->DidFinishExecuting();
117}
#define LLDB_LOGF(log,...)
Definition: Log.h:349
A section + offset based address class.
Definition: Address.h:62
Generic representation of a type in a programming language.
Definition: CompilerType.h:36
Encapsulates dynamic check functions used by expressions.
virtual bool DoCheckersExplainStop(lldb::addr_t addr, Stream &message)=0
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
DynamicCheckerFunctions * GetDynamicCheckers()
Definition: Process.h:2353
const char * GetData() const
Definition: StreamString.h:43
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:134
virtual lldb::StopInfoSP GetRealStopInfo()
void GetDescription(Stream *s, lldb::DescriptionLevel level) override
Print a description of this thread to the stream s.
void GetDescription(Stream *s, lldb::DescriptionLevel level) override
Print a description of this thread to the stream s.
ThreadPlanCallUserExpression(Thread &thread, Address &function, llvm::ArrayRef< lldb::addr_t > args, const EvaluateExpressionOptions &options, lldb::UserExpressionSP &user_expression_sp)
Thread & GetThread()
Returns the Thread that is using this thread plan.
Definition: ThreadPlan.cpp:42
void SetOkayToDiscard(bool value)
Definition: ThreadPlan.h:406
virtual bool MischiefManaged()
Definition: ThreadPlan.cpp:72
bool SetIsControllingPlan(bool value)
Definition: ThreadPlan.h:398
A class that represents a running process on the host machine.
Definition: SBAttachInfo.h:14
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition: Log.h:314
Definition: SBAddress.h:15
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
@ eDescriptionLevelBrief
std::shared_ptr< lldb_private::UserExpression > UserExpressionSP
Definition: lldb-forward.h:324
std::shared_ptr< lldb_private::StopInfo > StopInfoSP
Definition: lldb-forward.h:419
uint64_t addr_t
Definition: lldb-types.h:79