32 m_enabled(false), m_is_hardware(hardware), m_is_watch_variable(false),
33 m_is_ephemeral(false), m_disabled_count(0), m_watch_read(0),
34 m_watch_write(0), m_watch_modify(0), m_ignore_count(0) {
41 auto type_system_or_err =
43 if (
auto err = type_system_or_err.takeError()) {
45 "Failed to set type: {0}");
47 if (
auto ts = *type_system_or_err) {
50 ts->GetBuiltinTypeForEncodingAndBitSize(
eEncodingUint, 8 * size);
58 "Failed to set type: Typesystem is no longer live: {0}");
74 bool is_synchronous) {
86 const BatonSP &callback_baton_sp,
87 bool is_synchronous) {
96 ThreadSP thread_sp = frame_sp->GetThread();
100 uint32_t return_frame_index =
106 thread_sp->GetStackFrameAtIndex(return_frame_index));
107 if (!return_frame_sp)
115 Address return_address(return_frame_sp->GetFrameCodeAddress());
121 return_addr,
true,
false);
122 if (!bp_sp || !bp_sp->HasResolvedLocations())
125 auto wvc_up = std::make_unique<WatchpointVariableContext>(
GetID(), exe_ctx);
126 auto baton_sp = std::make_shared<WatchpointVariableBaton>(std::move(wvc_up));
128 bp_sp->SetOneShot(
true);
129 bp_sp->SetBreakpointKind(
"variable watchpoint disabler");
137 assert(baton &&
"null baton");
138 if (!baton || !context)
146 LLDB_LOGF(log,
"called by breakpoint %" PRIu64
".%" PRIu64, break_id,
156 ProcessSP process_sp = target_sp->GetProcessSP();
161 target_sp->GetWatchpointList().FindByID(wvc->
watch_id);
167 "callback for watchpoint %" PRId32
168 " matched internal breakpoint execution context",
170 process_sp->DisableWatchpoint(watch_sp);
174 "callback for watchpoint %" PRId32
175 " didn't match internal breakpoint execution context",
232 newest_valueobj_sp = newest_valueobj_sp->CreateConstantValue(g_watch_name);
276 bool printed_anything =
false;
280 return printed_anything;
291 values_ss.
Printf(
"old value: %s", old_value_cstr);
293 if (
auto *old_summary_cstr =
m_old_value_sp->GetSummaryAsCString())
294 values_ss.
Printf(
"old value: %s", old_summary_cstr);
316 values_ss.
Printf(
"new value: %s", new_value_cstr);
318 if (
auto *new_summary_cstr =
m_new_value_sp->GetSummaryAsCString())
319 values_ss.
Printf(
"new value: %s", new_summary_cstr);
338 printed_anything =
true;
341 return printed_anything;
352 s->
Printf(
"Watchpoint %u: addr = 0x%8.8" PRIx64
353 " size = %u state = %s type = %s%s%s",
365 auto &resourcelist = process_sp->GetWatchpointResourceList();
367 s->
Printf(
"\n watchpoint resources:");
369 if (wpres->ConstituentsContains(
this)) {
370 s->
Printf(
"\n #%zu: ", idx);
424 : eWatchpointEventTypeDisabled);
460 if (condition ==
nullptr || condition[0] ==
'\0') {
485 lldb::WatchpointEventType eventKind) {
489 std::make_shared<WatchpointEventData>(eventKind, shared_from_this());
495 WatchpointEventType sub_type,
const WatchpointSP &new_watchpoint_sp)
496 : m_watchpoint_event(sub_type), m_new_watchpoint_sp(new_watchpoint_sp) {}
501 return "Watchpoint::WatchpointEventData";
509 return m_new_watchpoint_sp;
514 return m_watchpoint_event;
522 const EventData *event_data =
event->GetData();
536 return eWatchpointEventTypeInvalidType;
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOGF(log,...)
#define LLDB_LOG_ERROR(log, error,...)
A section + offset based address class.
lldb::addr_t GetLoadAddress(Target *target) const
Get the load address.
uint32_t GetAddressByteSize() const
Returns the size in bytes of an address of the current architecture.
void BroadcastEvent(lldb::EventSP &event_sp)
Broadcast an event which has no associated data.
Generic representation of a type in a programming language.
CompilerType GetArrayType(uint64_t size) const
A uniqued constant string class.
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
DumpValueObjectOptions & SetHideName(bool hide_name=false)
DumpValueObjectOptions & SetHideRootType(bool hide_root_type=false)
DumpValueObjectOptions & SetHideRootName(bool hide_root_name)
DumpValueObjectOptions & SetUseDynamicType(lldb::DynamicValueType dyn=lldb::eNoDynamicValues)
virtual llvm::StringRef GetFlavor() const =0
lldb::TargetSP GetTargetSP() const
Get accessor that creates a strong reference from the weak target reference contained in this object.
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
ExecutionContextScope * GetBestExecutionContextScope() const
const lldb::TargetSP & GetTargetSP() const
Get accessor to get the target shared pointer.
General Outline: When we hit a breakpoint we need to package up whatever information is needed to eva...
ExecutionContextRef exe_ctx_ref
void Increment(uint32_t difference=1)
lldb::break_id_t GetID() const
uint32_t GetHitCount() const
StoppointHitCounter m_hit_counter
Number of times this breakpoint/watchpoint has been hit.
virtual lldb::addr_t GetLoadAddress() const
uint32_t m_byte_size
The size in bytes of stoppoint, e.g.
bool HardwareRequired() const
const char * GetData() const
A stream class that can stream formatted output to a file.
size_t Indent(llvm::StringRef s="")
Indent the current line in the stream.
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
const lldb::ProcessSP & GetProcessSP() const
llvm::Expected< lldb::TypeSystemSP > GetScratchTypeSystemForLanguage(lldb::LanguageType language, bool create_on_demand=true)
@ eBroadcastBitWatchpointChanged
const ArchSpec & GetArchitecture() const
UserExpression * GetUserExpressionForLanguage(llvm::StringRef expr, llvm::StringRef prefix, SourceLanguage language, Expression::ResultType desired_type, const EvaluateExpressionOptions &options, ValueObject *ctx_obj, Status &error)
static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope, llvm::StringRef name, const Address &address, lldb::TypeSP &type_sp)
void ClearCallback()
Remove the callback from this option set.
bool InvokeCallback(StoppointCallbackContext *context, lldb::user_id_t watch_id)
Use this function to invoke the callback for a specific stop.
void SetCallback(WatchpointHitCallback callback, const lldb::BatonSP &baton_sp, bool synchronous=false)
Adds a callback to the watchpoint option set.
void GetCallbackDescription(Stream *s, lldb::DescriptionLevel level) const
Get description for callback only.
static lldb::WatchpointSP GetWatchpointFromEvent(const lldb::EventSP &event_sp)
lldb::WatchpointSP & GetWatchpoint()
lldb::WatchpointEventType GetWatchpointEventType() const
static llvm::StringRef GetFlavorString()
lldb::WatchpointSP m_new_watchpoint_sp
llvm::StringRef GetFlavor() const override
static lldb::WatchpointEventType GetWatchpointEventTypeFromEvent(const lldb::EventSP &event_sp)
void Dump(Stream *s) const override
static const WatchpointEventData * GetEventDataFromEvent(const Event *event_sp)
~WatchpointEventData() override
WatchpointEventData(lldb::WatchpointEventType sub_type, const lldb::WatchpointSP &new_watchpoint_sp)
bool IsWatchVariable() const
void SetCallback(WatchpointHitCallback callback, void *callback_baton, bool is_synchronous=false)
Set the callback action invoked when the watchpoint is hit.
Watchpoint(Target &target, lldb::addr_t addr, uint32_t size, const CompilerType *type, bool hardware=true)
bool CaptureWatchedValue(const ExecutionContext &exe_ctx)
uint32_t GetIgnoreCount() const
bool InvokeCallback(StoppointCallbackContext *context)
Invoke the callback action when the watchpoint is hit.
void SetIgnoreCount(uint32_t n)
std::unique_ptr< UserExpression > m_condition_up
void SetEnabled(bool enabled, bool notify=true)
bool IsHardware() const override
void Dump(Stream *s) const override
bool WatchedValueReportable(const ExecutionContext &exe_ctx)
void SendWatchpointChangedEvent(lldb::WatchpointEventType eventKind)
std::string GetWatchSpec()
lldb::ValueObjectSP m_new_value_sp
static bool VariableWatchpointDisabler(void *baton, lldb_private::StoppointCallbackContext *context, lldb::user_id_t break_id, lldb::user_id_t break_loc_id)
Callback routine to disable the watchpoint set on a local variable when it goes out of scope.
bool DumpSnapshots(Stream *s, const char *prefix=nullptr) const
bool IsDisabledDuringEphemeralMode()
lldb::ValueObjectSP m_old_value_sp
uint32_t m_disabled_count
bool ShouldStop(StoppointCallbackContext *context) override
void SetWatchSpec(const std::string &str)
void SetWatchVariable(bool val)
void TurnOffEphemeralMode()
const char * GetConditionText() const
Return a pointer to the text of the condition expression.
void GetDescription(Stream *s, lldb::DescriptionLevel level)
WatchpointOptions m_options
bool WatchpointRead() const
std::string m_watch_spec_str
bool SetupVariableWatchpointDisabler(lldb::StackFrameSP frame_sp) const
bool WatchpointModify() const
void SetCondition(const char *condition)
Set the watchpoint's condition.
void SetWatchpointType(uint32_t type, bool notify=true)
void SetDeclInfo(const std::string &str)
bool WatchpointWrite() const
void DumpWithLevel(Stream *s, lldb::DescriptionLevel description_level) const
void TurnOnEphemeralMode()
#define LLDB_WATCH_TYPE_WRITE
#define LLDB_INVALID_WATCH_ID
#define LLDB_WATCH_TYPE_MODIFY
#define LLDB_WATCH_TYPE_READ
#define LLDB_INVALID_ADDRESS
#define LLDB_INVALID_FRAME_ID
@ DoNoSelectMostRelevantFrame
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
bool(* WatchpointHitCallback)(void *baton, StoppointCallbackContext *context, lldb::user_id_t watch_id)
const char * toString(AppleArm64ExceptionClass EC)
std::shared_ptr< lldb_private::StackFrame > StackFrameSP
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
@ eDescriptionLevelVerbose
std::shared_ptr< lldb_private::Thread > ThreadSP
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
@ eLanguageTypeC
Non-standardized C, such as K&R.
std::shared_ptr< lldb_private::Breakpoint > BreakpointSP
std::shared_ptr< lldb_private::Process > ProcessSP
std::shared_ptr< lldb_private::Baton > BatonSP
@ eEncodingUint
unsigned integer
std::shared_ptr< lldb_private::Event > EventSP
std::shared_ptr< lldb_private::Watchpoint > WatchpointSP
std::shared_ptr< lldb_private::WatchpointResource > WatchpointResourceSP
std::shared_ptr< lldb_private::Target > TargetSP
Represents the context of a watchpoint variable.
ExecutionContext exe_ctx
The execution context associated with the watchpoint.
lldb::watch_id_t watch_id
The ID of the watchpoint.