30 m_enabled(false), m_is_hardware(hardware), m_is_watch_variable(false),
31 m_is_ephemeral(false), m_disabled_count(0), m_watch_read(0),
32 m_watch_write(0), m_watch_modify(0), m_ignore_count(0),
33 m_being_created(true) {
40 auto type_system_or_err =
42 if (
auto err = type_system_or_err.takeError()) {
44 "Failed to set type: {0}");
46 if (
auto ts = *type_system_or_err)
48 ts->GetBuiltinTypeForEncodingAndBitSize(
eEncodingUint, 8 * size);
51 "Failed to set type: Typesystem is no longer live: {0}");
68 bool is_synchronous) {
80 const BatonSP &callback_baton_sp,
81 bool is_synchronous) {
90 ThreadSP thread_sp = frame_sp->GetThread();
94 uint32_t return_frame_index =
100 thread_sp->GetStackFrameAtIndex(return_frame_index));
101 if (!return_frame_sp)
109 Address return_address(return_frame_sp->GetFrameCodeAddress());
115 return_addr,
true,
false);
116 if (!bp_sp || !bp_sp->HasResolvedLocations())
119 auto wvc_up = std::make_unique<WatchpointVariableContext>(
GetID(), exe_ctx);
120 auto baton_sp = std::make_shared<WatchpointVariableBaton>(std::move(wvc_up));
122 bp_sp->SetOneShot(
true);
123 bp_sp->SetBreakpointKind(
"variable watchpoint disabler");
131 assert(baton &&
"null baton");
132 if (!baton || !context)
140 LLDB_LOGF(log,
"called by breakpoint %" PRIu64
".%" PRIu64, break_id,
150 ProcessSP process_sp = target_sp->GetProcessSP();
155 target_sp->GetWatchpointList().FindByID(wvc->
watch_id);
161 "callback for watchpoint %" PRId32
162 " matched internal breakpoint execution context",
164 process_sp->DisableWatchpoint(watch_sp.get());
168 "callback for watchpoint %" PRId32
169 " didn't match internal breakpoint execution context",
226 newest_valueobj_sp = newest_valueobj_sp->CreateConstantValue(g_watch_name);
277 if (old_value_cstr && old_value_cstr[0])
278 s->
Printf(
"\n%sold value: %s", prefix, old_value_cstr);
280 const char *old_summary_cstr =
m_old_value_sp->GetSummaryAsCString();
281 if (old_summary_cstr && old_summary_cstr[0])
282 s->
Printf(
"\n%sold value: %s", prefix, old_summary_cstr);
288 if (new_value_cstr && new_value_cstr[0])
289 s->
Printf(
"\n%snew value: %s", prefix, new_value_cstr);
291 const char *new_summary_cstr =
m_new_value_sp->GetSummaryAsCString();
292 if (new_summary_cstr && new_summary_cstr[0])
293 s->
Printf(
"\n%snew value: %s", prefix, new_summary_cstr);
306 s->
Printf(
"Watchpoint %u: addr = 0x%8.8" PRIx64
307 " size = %u state = %s type = %s%s%s",
327 s->
Printf(
"\n hw_index = %i hit_count = %-4u ignore_count = %-4u",
366 : eWatchpointEventTypeDisabled);
402 if (condition ==
nullptr || condition[0] ==
'\0') {
428 lldb::WatchpointEventType eventKind) {
450 WatchpointEventType sub_type,
const WatchpointSP &new_watchpoint_sp)
451 : m_watchpoint_event(sub_type), m_new_watchpoint_sp(new_watchpoint_sp) {}
456 return "Watchpoint::WatchpointEventData";
464 return m_new_watchpoint_sp;
469 return m_watchpoint_event;
477 const EventData *event_data =
event->GetData();
491 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.
void BroadcastEvent(lldb::EventSP &event_sp)
Broadcast an event which has no associated data.
Generic representation of a type in a programming language.
A uniqued constant string class.
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
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)
uint32_t GetHardwareIndex() const
lldb::break_id_t GetID() const
uint32_t GetHitCount() const
void SetHardwareIndex(uint32_t index)
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
A stream class that can stream formatted output to a file.
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
UserExpression * GetUserExpressionForLanguage(llvm::StringRef expr, llvm::StringRef prefix, lldb::LanguageType language, Expression::ResultType desired_type, const EvaluateExpressionOptions &options, ValueObject *ctx_obj, Status &error)
const lldb::ProcessSP & GetProcessSP() const
@ eBroadcastBitWatchpointChanged
llvm::Expected< lldb::TypeSystemSP > GetScratchTypeSystemForLanguage(lldb::LanguageType language, bool create_on_demand=true)
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)
void DumpSnapshots(Stream *s, const char *prefix=nullptr) const
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 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_INVALID_INDEX32
#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)
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
@ eLanguageTypeUnknown
Unknown or invalid language value.
@ 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::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.