LLDB mainline
StopInfo.cpp
Go to the documentation of this file.
1//===-- StopInfo.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
9#include <array>
10#include <cstdint>
11#include <string>
12
18#include "lldb/Core/Debugger.h"
20#include "lldb/Symbol/Block.h"
21#include "lldb/Target/Policy.h"
22#include "lldb/Target/Process.h"
24#include "lldb/Target/Target.h"
25#include "lldb/Target/Thread.h"
30#include "lldb/Utility/Log.h"
33
34using namespace lldb;
35using namespace lldb_private;
36
37StopInfo::StopInfo(Thread &thread, uint64_t value)
38 : m_thread_wp(thread.shared_from_this()),
39 m_stop_id(thread.GetProcess()->GetStopID()),
40 m_resume_id(thread.GetProcess()->GetResumeID()), m_value(value),
43
44bool StopInfo::IsValid() const {
45 ThreadSP thread_sp(m_thread_wp.lock());
46 if (thread_sp)
47 return thread_sp->GetProcess()->GetStopID() == m_stop_id;
48 return false;
49}
50
52 ThreadSP thread_sp(m_thread_wp.lock());
53 if (thread_sp) {
54 m_stop_id = thread_sp->GetProcess()->GetStopID();
55 m_resume_id = thread_sp->GetProcess()->GetResumeID();
56 }
57}
58
60 ThreadSP thread_sp(m_thread_wp.lock());
61
62 if (thread_sp) {
63 lldb::StateType ret_type = thread_sp->GetProcess()->GetPrivateState();
64 if (ret_type == eStateRunning) {
65 return true;
66 } else if (ret_type == eStateStopped) {
67 // This is a little tricky. We want to count "run and stopped again
68 // before you could ask this question as a "TRUE" answer to
69 // HasTargetRunSinceMe. But we don't want to include any running of the
70 // target done for expressions. So we track both resumes, and resumes
71 // caused by expressions, and check if there are any resumes
72 // NOT caused
73 // by expressions.
74
75 uint32_t curr_resume_id = thread_sp->GetProcess()->GetResumeID();
76 uint32_t last_user_expression_id =
77 thread_sp->GetProcess()->GetLastUserExpressionResumeID();
78 if (curr_resume_id == m_resume_id) {
79 return false;
80 } else if (curr_resume_id > last_user_expression_id) {
81 return true;
82 }
83 }
84 }
85 return false;
86}
87
91
92 // We don't expect to see byte sequences longer than four bytes long for
93 // any breakpoint instructions known to LLDB.
94 std::array<uint8_t, 4> bytes_at_pc = {0, 0, 0, 0};
95 auto reg_ctx_sp = GetThread()->GetRegisterContext();
96 auto process_sp = GetThread()->GetProcess();
97 addr_t pc = reg_ctx_sp->GetPC();
98 if (!process_sp->ReadMemory(pc, bytes_at_pc.data(), bytes_at_pc.size(),
99 error)) {
100 // If this fails, we simply don't handle the step-over-break logic.
101 LLDB_LOG(log, "failed to read program bytes at pc address {}, error {}", pc,
102 error);
103 return;
104 }
105
106 auto &target = process_sp->GetTarget();
107 auto platform_sp = target.GetPlatform();
108 size_t size_hint =
109 platform_sp->GetTrapOpcodeSizeHint(target, Address(pc), bytes_at_pc);
110 llvm::ArrayRef<uint8_t> platform_opcode =
111 platform_sp->SoftwareTrapOpcodeBytes(target.GetArchitecture(), size_hint);
112
113 Architecture *arch_plugin = target.GetArchitecturePlugin();
114 llvm::ArrayRef<uint8_t> inst_bytes(bytes_at_pc.data(), bytes_at_pc.size());
115 if (arch_plugin &&
116 arch_plugin->IsValidTrapInstruction(platform_opcode, inst_bytes)) {
117 LLDB_LOG(log, "stepping over breakpoint in inferior to new pc: {}",
118 pc + platform_opcode.size());
119 reg_ctx_sp->SetPC(pc + platform_opcode.size());
120 }
121}
122
123// StopInfoBreakpoint
124
125namespace lldb_private {
127public:
128 // We use a "breakpoint preserving BreakpointLocationCollection because we
129 // may need to hand out the "breakpoint hit" list as any point, potentially
130 // after the breakpoint has been deleted. But we still need to refer to them.
139
140 StopInfoBreakpoint(Thread &thread, break_id_t break_id, bool should_stop)
141 : StopInfo(thread, break_id), m_should_stop(should_stop),
144 m_was_all_internal(false), m_was_one_shot(false),
146 StoreBPInfo();
147 }
148
149 ~StopInfoBreakpoint() override = default;
150
151 void StoreBPInfo() {
152 ThreadSP thread_sp(m_thread_wp.lock());
153 if (thread_sp) {
155 if (bp_site_sp) {
156 uint32_t num_constituents = bp_site_sp->GetNumberOfConstituents();
157 if (num_constituents == 1) {
158 BreakpointLocationSP bp_loc_sp = bp_site_sp->GetConstituentAtIndex(0);
159 if (bp_loc_sp) {
160 Breakpoint & bkpt = bp_loc_sp->GetBreakpoint();
161 m_break_id = bkpt.GetID();
162 m_was_one_shot = bkpt.IsOneShot();
164 }
165 } else {
166 m_was_all_internal = true;
167 for (uint32_t i = 0; i < num_constituents; i++) {
168 if (!bp_site_sp->GetConstituentAtIndex(i)
169 ->GetBreakpoint()
170 .IsInternal()) {
171 m_was_all_internal = false;
172 break;
173 }
174 }
175 }
176 m_address = bp_site_sp->GetLoadAddress();
177 }
178 }
179 }
180
182 ProcessSP process_sp(thread.GetProcess());
183 if (process_sp) {
185 if (bp_site_sp)
186 return bp_site_sp->ValidForThisThread(thread);
187 }
188 return false;
189 }
190
191 StopReason GetStopReason() const override { return eStopReasonBreakpoint; }
192
193 bool ShouldStopSynchronous(Event *event_ptr) override {
194 // Breakpoint callbacks run on the PST during stop processing. Push
195 // private state context so callback code sees the private reality.
197
198 ThreadSP thread_sp(m_thread_wp.lock());
199 if (thread_sp) {
201 // Only check once if we should stop at a breakpoint
203 if (bp_site_sp) {
204 ExecutionContext exe_ctx(thread_sp->GetStackFrameAtIndex(0));
205 StoppointCallbackContext context(event_ptr, exe_ctx, true);
206 bp_site_sp->BumpHitCounts();
208 bp_site_sp->ShouldStop(&context, m_async_stopped_locs);
209 } else {
211
212 LLDB_LOGF(log,
213 "Process::%s could not find breakpoint site id: %" PRId64
214 "...",
215 __FUNCTION__, m_value);
216
217 m_should_stop = true;
218 }
220 }
221 return m_should_stop;
222 }
223 return false;
224 }
225
226 bool DoShouldNotify(Event *event_ptr) override {
227 return !m_was_all_internal;
228 }
229
230 const char *GetDescription() override {
231 // FIXME: only print m_async_stopped_locs.
232 if (m_description.empty()) {
233 ThreadSP thread_sp(m_thread_wp.lock());
234 if (thread_sp) {
236 if (bp_site_sp) {
237 StreamString strm;
238 // If we have just hit an internal breakpoint, and it has a kind
239 // description, print that instead of the full breakpoint printing:
240 if (bp_site_sp->IsInternal()) {
241 size_t num_constituents = bp_site_sp->GetNumberOfConstituents();
242 for (size_t idx = 0; idx < num_constituents; idx++) {
243 const char *kind = bp_site_sp->GetConstituentAtIndex(idx)
244 ->GetBreakpoint()
245 .GetBreakpointKind();
246 if (kind != nullptr) {
247 m_description.assign(kind);
248 return kind;
249 }
250 }
251 }
252
253 strm.Printf("breakpoint ");
254 m_async_stopped_locs.GetDescription(&strm, eDescriptionLevelBrief);
255 m_description = std::string(strm.GetString());
256 } else {
257 StreamString strm;
259 BreakpointSP break_sp =
260 thread_sp->GetProcess()->GetTarget().GetBreakpointByID(
261 m_break_id);
262 if (break_sp) {
263 if (break_sp->IsInternal()) {
264 const char *kind = break_sp->GetBreakpointKind();
265 if (kind)
266 strm.Printf("internal %s breakpoint(%d).", kind, m_break_id);
267 else
268 strm.Printf("internal breakpoint(%d).", m_break_id);
269 } else {
270 strm.Printf("breakpoint %d.", m_break_id);
271 }
272 } else {
273 if (m_was_one_shot)
274 strm.Printf("one-shot breakpoint %d", m_break_id);
275 else
276 strm.Printf("breakpoint %d which has been deleted.",
277 m_break_id);
278 }
279 } else if (m_address == LLDB_INVALID_ADDRESS)
280 strm.Printf("breakpoint site %" PRIi64
281 " which has been deleted - unknown address",
282 m_value);
283 else
284 strm.Printf("breakpoint site %" PRIi64
285 " which has been deleted - was at 0x%" PRIx64,
287
288 m_description = std::string(strm.GetString());
289 }
290 }
291 }
292 return m_description.c_str();
293 }
294
295 uint32_t GetStopReasonDataCount() const override {
296 size_t num_async_locs = m_async_stopped_locs.GetSize();
297 // If we have async locations, they are the ones we should report:
298 if (num_async_locs > 0)
299 return num_async_locs * 2;
300
301 // Otherwise report the number of locations at this breakpoint's site.
303 if (bp_site_sp)
304 return bp_site_sp->GetNumberOfConstituents() * 2;
305 return 0; // Breakpoint must have cleared itself...
306 }
307
308 uint64_t GetStopReasonDataAtIndex(uint32_t idx) override {
309 uint32_t bp_index = idx / 2;
310 BreakpointLocationSP loc_to_report_sp;
311
312 size_t num_async_locs = m_async_stopped_locs.GetSize();
313 if (num_async_locs > 0) {
314 // GetByIndex returns an empty SP if we ask past its contents:
315 loc_to_report_sp = m_async_stopped_locs.GetByIndex(bp_index);
316 } else {
318 if (bp_site_sp)
319 loc_to_report_sp = bp_site_sp->GetConstituentAtIndex(bp_index);
320 }
321 if (loc_to_report_sp) {
322 if (idx & 1) {
323 // Odd idx, return the breakpoint location ID
324 return loc_to_report_sp->GetID();
325 } else {
326 // Even idx, return the breakpoint ID
327 return loc_to_report_sp->GetBreakpoint().GetID();
328 }
329 }
331 }
332
333 std::optional<uint32_t>
334 GetSuggestedStackFrameIndex(bool inlined_stack) override {
335 if (!inlined_stack)
336 return {};
337
338 ThreadSP thread_sp(m_thread_wp.lock());
339 if (!thread_sp)
340 return {};
342 if (!bp_site_sp)
343 return {};
344
345 return bp_site_sp->GetSuggestedStackFrameIndex();
346 }
347
348 bool ShouldShow() const override { return !m_was_all_internal; }
349
350 bool ShouldSelect() const override { return !m_was_all_internal; }
351
352protected:
353 bool ShouldStop(Event *event_ptr) override {
354 // This just reports the work done by PerformAction or the synchronous
355 // stop. It should only ever get called after they have had a chance to
356 // run.
358 return m_should_stop;
359 }
360
361 void PerformAction(Event *event_ptr) override {
363 return;
365 bool all_stopping_locs_internal = true;
366
367 ThreadSP thread_sp(m_thread_wp.lock());
368
369 if (thread_sp) {
371
372 if (!thread_sp->IsValid()) {
373 // This shouldn't ever happen, but just in case, don't do more harm.
374 LLDB_LOGF(log, "PerformAction got called with an invalid thread.");
375 m_should_stop = true;
377 return;
378 }
379
381 std::unordered_set<break_id_t> precondition_breakpoints;
382 // Breakpoints that fail their condition check are not considered to
383 // have been hit. If the only locations at this site have failed their
384 // conditions, we should change the stop-info to none. Otherwise, if we
385 // hit another breakpoint on a different thread which does stop, users
386 // will see a breakpont hit with a failed condition, which is wrong.
387 // Use this variable to tell us if that is true.
388 bool actually_hit_any_locations = false;
389 if (bp_site_sp) {
390 // Let's copy the constituents list out of the site and store them in a
391 // local list. That way if one of the breakpoint actions changes the
392 // site, then we won't be operating on a bad list.
393 BreakpointLocationCollection site_locations;
394 size_t num_constituents = m_async_stopped_locs.GetSize();
395
396 if (num_constituents == 0) {
397 m_should_stop = true;
398 actually_hit_any_locations = true; // We're going to stop, don't
399 // change the stop info.
400 } else {
401 // We go through each location, and test first its precondition -
402 // this overrides everything. Note, we only do this once per
403 // breakpoint - not once per location... Then check the condition.
404 // If the condition says to stop, then we run the callback for that
405 // location. If that callback says to stop as well, then we set
406 // m_should_stop to true; we are going to stop. But we still want to
407 // give all the breakpoints whose conditions say we are going to stop
408 // a chance to run their callbacks. Of course if any callback
409 // restarts the target by putting "continue" in the callback, then
410 // we're going to restart, without running the rest of the callbacks.
411 // And in this case we will end up not stopping even if another
412 // location said we should stop. But that's better than not running
413 // all the callbacks.
414
415 // There's one other complication here. We may have run an async
416 // breakpoint callback that said we should stop. We only want to
417 // override that if another breakpoint action says we shouldn't
418 // stop. If nobody else has an opinion, then we should stop if the
419 // async callback says we should. An example of this is the async
420 // shared library load notification breakpoint and the setting
421 // stop-on-sharedlibrary-events.
422 // We'll keep the async value in async_should_stop, and track whether
423 // anyone said we should NOT stop in actually_said_continue.
424 bool async_should_stop = false;
426 async_should_stop = m_should_stop;
427 bool actually_said_continue = false;
428
429 m_should_stop = false;
430
431 // We don't select threads as we go through them testing breakpoint
432 // conditions and running commands. So we need to set the thread for
433 // expression evaluation here:
434 ThreadList::ExpressionExecutionThreadPusher thread_pusher(thread_sp);
435
436 ExecutionContext exe_ctx(thread_sp->GetStackFrameAtIndex(0));
437 Process *process = exe_ctx.GetProcessPtr();
438 Policy policy = PolicyStack::Get().Current();
440 process->GetModIDRef().IsRunningExpression()) {
441 // If we are in the middle of evaluating an expression, don't run
442 // asynchronous breakpoint commands or expressions. That could
443 // lead to infinite recursion if the command or condition re-calls
444 // the function with this breakpoint.
445 // TODO: We can keep a list of the breakpoints we've seen while
446 // running expressions in the nested
447 // PerformAction calls that can arise when the action runs a
448 // function that hits another breakpoint, and only stop running
449 // commands when we see the same breakpoint hit a second time.
450
452
453 // It is possible that the user has a breakpoint at the same site
454 // as the completed plan had (e.g. user has a breakpoint
455 // on a module entry point, and `ThreadPlanCallFunction` ends
456 // also there). We can't find an internal breakpoint in the loop
457 // later because it was already removed on the plan completion.
458 // So check if the plan was completed, and stop if so.
459 if (thread_sp->CompletedPlanOverridesBreakpoint()) {
460 m_should_stop = true;
461 thread_sp->ResetStopInfo();
462 return;
463 }
464
465 LLDB_LOGF(log, "StopInfoBreakpoint::PerformAction - Hit a "
466 "breakpoint while running an expression,"
467 " not running commands to avoid recursion.");
468 bool ignoring_breakpoints =
470 // Internal breakpoints should be allowed to do their job, we
471 // can make sure they don't do anything that would cause recursive
472 // command execution:
473 if (!m_was_all_internal) {
474 m_should_stop = !ignoring_breakpoints;
475 LLDB_LOGF(log,
476 "StopInfoBreakpoint::PerformAction - in expression, "
477 "continuing: %s.",
478 m_should_stop ? "true" : "false");
480 "hit breakpoint while running function, skipping commands "
481 "and conditions to prevent recursion",
482 process->GetTarget().GetDebugger().GetID());
483 return;
484 }
485 }
486
487 StoppointCallbackContext context(event_ptr, exe_ctx, false);
488
489 // For safety's sake let's also grab an extra reference to the
490 // breakpoint constituents of the locations we're going to examine,
491 // since the locations are going to have to get back to their
492 // breakpoints, and the locations don't keep their constituents alive.
493 // I'm just sticking the BreakpointSP's in a vector since I'm only
494 // using it to locally increment their retain counts.
495
496 // We are holding onto the breakpoint locations that were hit
497 // by this stop info between the "synchonous" ShouldStop and now.
498 // But an intervening action might have deleted one of the breakpoints
499 // we hit before we get here. So at the same time let's build a list
500 // of the still valid locations:
501 std::vector<lldb::BreakpointSP> location_constituents;
502
504 for (size_t j = 0; j < num_constituents; j++) {
505 BreakpointLocationSP loc_sp(m_async_stopped_locs.GetByIndex(j));
506 if (loc_sp->IsValid()) {
507 location_constituents.push_back(
508 loc_sp->GetBreakpoint().shared_from_this());
509 valid_locs.Add(loc_sp);
510 }
511 }
512
513 size_t num_valid_locs = valid_locs.GetSize();
514 for (size_t j = 0; j < num_valid_locs; j++) {
515 lldb::BreakpointLocationSP bp_loc_sp = valid_locs.GetByIndex(j);
516 StreamString loc_desc;
517 if (log) {
518 bp_loc_sp->GetDescription(&loc_desc, eDescriptionLevelBrief);
519 }
520 // If another action disabled this breakpoint or its location, then
521 // don't run the actions.
522 if (!bp_loc_sp->IsEnabled() ||
523 !bp_loc_sp->GetBreakpoint().IsEnabled())
524 continue;
525
526 // The breakpoint site may have many locations associated with it,
527 // not all of them valid for this thread. Skip the ones that
528 // aren't:
529 if (!bp_loc_sp->ValidForThisThread(*thread_sp)) {
530 LLDB_LOGF(log,
531 "Breakpoint %s hit on thread 0x%llx but it was not "
532 "for this thread, continuing.",
533 loc_desc.GetData(),
534 static_cast<unsigned long long>(thread_sp->GetID()));
535 continue;
536 }
537
538 // First run the precondition, but since the precondition is per
539 // breakpoint, only run it once per breakpoint.
540 std::pair<std::unordered_set<break_id_t>::iterator, bool> result =
541 precondition_breakpoints.insert(
542 bp_loc_sp->GetBreakpoint().GetID());
543 if (!result.second)
544 continue;
545
546 bool precondition_result =
547 bp_loc_sp->GetBreakpoint().EvaluatePrecondition(context);
548 if (!precondition_result) {
549 actually_said_continue = true;
550 continue;
551 }
552 // Next run the condition for the breakpoint. If that says we
553 // should stop, then we'll run the callback for the breakpoint. If
554 // the callback says we shouldn't stop that will win.
555
556 if (!bp_loc_sp->GetCondition())
557 actually_hit_any_locations = true;
558 else {
559 Status condition_error;
560 bool condition_says_stop =
561 bp_loc_sp->ConditionSaysStop(exe_ctx, condition_error);
562
563 if (!condition_error.Success()) {
564 // If the condition fails to evaluate, we are going to stop
565 // at it, so the location was hit.
566 actually_hit_any_locations = true;
567 const char *err_str =
568 condition_error.AsCString("<unknown error>");
569 LLDB_LOGF(log, "Error evaluating condition: \"%s\"\n", err_str);
570
571 StreamString strm;
572 strm << "stopped due to an error evaluating condition of "
573 "breakpoint ";
574 bp_loc_sp->GetDescription(&strm, eDescriptionLevelBrief);
575 strm << ": \"" << bp_loc_sp->GetCondition().GetText() << "\"\n";
576 strm << err_str;
577
579 strm.GetString().str(),
580 exe_ctx.GetTargetRef().GetDebugger().GetID());
581 } else {
582 LLDB_LOGF(log,
583 "Condition evaluated for breakpoint %s on thread "
584 "0x%llx condition_says_stop: %i.",
585 loc_desc.GetData(),
586 static_cast<unsigned long long>(thread_sp->GetID()),
587 condition_says_stop);
588 if (condition_says_stop)
589 actually_hit_any_locations = true;
590 else {
591 // We don't want to increment the hit count of breakpoints if
592 // the condition fails. We've already bumped it by the time
593 // we get here, so undo the bump:
594 bp_loc_sp->UndoBumpHitCount();
595 actually_said_continue = true;
596 continue;
597 }
598 }
599 }
600
601 // We've done all the checks whose failure means "we consider lldb
602 // not to have hit the breakpoint". Now we're going to check for
603 // conditions that might continue after hitting. Start with the
604 // ignore count:
605 if (!bp_loc_sp->IgnoreCountShouldStop()) {
606 actually_said_continue = true;
607 continue;
608 }
609
610 // Check the auto-continue bit on the location, do this before the
611 // callback since it may change this, but that would be for the
612 // NEXT hit. Note, you might think you could check auto-continue
613 // before the condition, and not evaluate the condition if it says
614 // to continue. But failing the condition means the breakpoint was
615 // effectively NOT HIT. So these two states are different.
616 bool auto_continue_says_stop = true;
617 if (bp_loc_sp->IsAutoContinue())
618 {
619 LLDB_LOGF(log,
620 "Continuing breakpoint %s as AutoContinue was set.",
621 loc_desc.GetData());
622 // We want this stop reported, so you will know we auto-continued
623 // but only for external breakpoints:
624 if (!bp_loc_sp->GetBreakpoint().IsInternal())
625 thread_sp->SetShouldReportStop(eVoteYes);
626 auto_continue_says_stop = false;
627 }
628
629 bool callback_says_stop = true;
630
631 // FIXME: For now the callbacks have to run in async mode - the
632 // first time we restart we need
633 // to get out of there. So set it here.
634 // When we figure out how to nest breakpoint hits then this will
635 // change.
636
637 // Don't run async callbacks in PerformAction. They have already
638 // been taken into account with async_should_stop.
639 if (!bp_loc_sp->IsCallbackSynchronous()) {
640 Debugger &debugger = thread_sp->CalculateTarget()->GetDebugger();
641 bool old_async = debugger.GetAsyncExecution();
642 debugger.SetAsyncExecution(true);
643
644 callback_says_stop = bp_loc_sp->InvokeCallback(&context);
645
646 debugger.SetAsyncExecution(old_async);
647
648 if (callback_says_stop && auto_continue_says_stop)
649 m_should_stop = true;
650 else
651 actually_said_continue = true;
652 }
653
654 if (m_should_stop && !bp_loc_sp->GetBreakpoint().IsInternal())
655 all_stopping_locs_internal = false;
656
657 // If we are going to stop for this breakpoint, then remove the
658 // breakpoint.
659 if (callback_says_stop && bp_loc_sp &&
660 bp_loc_sp->GetBreakpoint().IsOneShot()) {
661 thread_sp->GetProcess()->GetTarget().RemoveBreakpointByID(
662 bp_loc_sp->GetBreakpoint().GetID());
663 }
664 // Also make sure that the callback hasn't continued the target. If
665 // it did, when we'll set m_should_start to false and get out of
666 // here.
667 if (HasTargetRunSinceMe()) {
668 m_should_stop = false;
669 actually_said_continue = true;
670 break;
671 }
672 }
673 // At this point if nobody actually told us to continue, we should
674 // give the async breakpoint callback a chance to weigh in:
675 if (!actually_said_continue && !m_should_stop) {
676 m_should_stop = async_should_stop;
677 }
678 }
679 // We've figured out what this stop wants to do, so mark it as valid so
680 // we don't compute it again.
682 } else {
683 m_should_stop = true;
685 actually_hit_any_locations = true;
686 Log *log_process(GetLog(LLDBLog::Process));
687
688 LLDB_LOGF(log_process,
689 "Process::%s could not find breakpoint site id: %" PRId64
690 "...",
691 __FUNCTION__, m_value);
692 }
693
694 if ((!m_should_stop || all_stopping_locs_internal) &&
695 thread_sp->CompletedPlanOverridesBreakpoint()) {
696
697 // Override should_stop decision when we have completed step plan
698 // additionally to the breakpoint
699 m_should_stop = true;
700
701 // We know we're stopping for a completed plan and we don't want to
702 // show the breakpoint stop, so compute the public stop info immediately
703 // here.
704 thread_sp->CalculatePublicStopInfo();
705 } else if (!actually_hit_any_locations) {
706 // In the end, we didn't actually have any locations that passed their
707 // "was I hit" checks. So say we aren't stopped.
708 GetThread()->ResetStopInfo();
709 LLDB_LOGF(log, "Process::%s all locations failed condition checks.",
710 __FUNCTION__);
711 }
712
713 LLDB_LOGF(log,
714 "Process::%s returning from action with m_should_stop: %d.",
715 __FUNCTION__, m_should_stop);
716 }
717 }
718
719private:
722 return {};
723
724 ThreadSP thread_sp = GetThread();
725 if (!thread_sp)
726 return {};
727 ProcessSP process_sp = thread_sp->GetProcess();
728 if (!process_sp)
729 return {};
730
731 return process_sp->GetBreakpointSiteList().FindByID(m_value);
732 }
733
736 bool m_should_perform_action; // Since we are trying to preserve the "state"
737 // of the system even if we run functions
738 // etc. behind the users backs, we need to make sure we only REALLY perform
739 // the action once.
740 lldb::addr_t m_address; // We use this to capture the breakpoint site address
741 // when we create the StopInfo,
742 // in case somebody deletes it between the time the StopInfo is made and the
743 // description is asked for.
747 /// The StopInfoBreakpoint lives after the stop, and could get queried
748 /// at any time so we need to make sure that it keeps the breakpoints for
749 /// each of the locations it records alive while it is around. That's what
750 /// The BreakpointPreservingLocationCollection does.
752};
753
754// StopInfoWatchpoint
755
757public:
758 // Make sure watchpoint is properly disabled and subsequently enabled while
759 // performing watchpoint actions.
761 public:
763 watchpoint_sp(w_sp) {
764 if (process_sp && watchpoint_sp) {
765 const bool notify = false;
766 watchpoint_sp->TurnOnEphemeralMode();
767 process_sp->DisableWatchpoint(watchpoint_sp, notify);
768 process_sp->AddPreResumeAction(SentryPreResumeAction, this);
769 }
770 }
771
772 void DoReenable() {
773 if (process_sp && watchpoint_sp) {
774 bool was_disabled = watchpoint_sp->IsDisabledDuringEphemeralMode();
775 watchpoint_sp->TurnOffEphemeralMode();
776 const bool notify = false;
777 if (was_disabled) {
778 process_sp->DisableWatchpoint(watchpoint_sp, notify);
779 } else {
780 process_sp->EnableWatchpoint(watchpoint_sp, notify);
781 }
782 }
783 }
784
786 DoReenable();
787 if (process_sp)
788 process_sp->ClearPreResumeAction(SentryPreResumeAction, this);
789 }
790
791 static bool SentryPreResumeAction(void *sentry_void) {
792 WatchpointSentry *sentry = (WatchpointSentry *) sentry_void;
793 sentry->DoReenable();
794 return true;
795 }
796
797 private:
800 };
801
802 StopInfoWatchpoint(Thread &thread, break_id_t watch_id, bool silently_skip_wp)
803 : StopInfo(thread, watch_id), m_silently_skip_wp(silently_skip_wp) {}
804
805 ~StopInfoWatchpoint() override = default;
806
807 StopReason GetStopReason() const override { return eStopReasonWatchpoint; }
808
809 uint32_t GetStopReasonDataCount() const override { return 1; }
810 uint64_t GetStopReasonDataAtIndex(uint32_t idx) override {
811 if (idx == 0)
812 return GetValue();
813 return 0;
814 }
815
816 const char *GetDescription() override {
817 if (m_description.empty()) {
818 StreamString strm;
819 strm.Printf("watchpoint %" PRIi64, m_value);
820 m_description = std::string(strm.GetString());
821 }
822 return m_description.c_str();
823 }
824
825protected:
826 using StopInfoWatchpointSP = std::shared_ptr<StopInfoWatchpoint>;
827 // This plan is used to orchestrate stepping over the watchpoint for
828 // architectures (e.g. ARM) that report the watch before running the watched
829 // access. This is the sort of job you have to defer to the thread plans,
830 // if you try to do it directly in the stop info and there are other threads
831 // that needed to process this stop you will have yanked control away from
832 // them and they won't behave correctly.
834 public:
836 StopInfoWatchpointSP stop_info_sp,
837 WatchpointSP watch_sp)
838 : ThreadPlanStepInstruction(thread, false, true, eVoteNoOpinion,
840 m_stop_info_sp(stop_info_sp), m_watch_sp(watch_sp) {
841 assert(watch_sp);
842 }
843
844 bool DoWillResume(lldb::StateType resume_state,
845 bool current_plan) override {
846 if (resume_state == eStateSuspended)
847 return true;
848
849 if (!m_did_disable_wp) {
850 GetThread().GetProcess()->DisableWatchpoint(m_watch_sp, false);
851 m_did_disable_wp = true;
852 }
853 return true;
854 }
855
856 bool DoPlanExplainsStop(Event *event_ptr) override {
858 return true;
859 StopInfoSP stop_info_sp = GetThread().GetPrivateStopInfo();
860 // lldb-server resets the stop info for threads that didn't get to run,
861 // so we might have not gotten to run, but still have a watchpoint stop
862 // reason, in which case this will indeed be for us.
863 if (stop_info_sp
864 && stop_info_sp->GetStopReason() == eStopReasonWatchpoint)
865 return true;
866 return false;
867 }
868
869 void DidPop() override {
870 // Don't artifically keep the watchpoint alive.
871 m_watch_sp.reset();
872 }
873
874 bool ShouldStop(Event *event_ptr) override {
875 bool should_stop = ThreadPlanStepInstruction::ShouldStop(event_ptr);
876 bool plan_done = MischiefManaged();
877 if (plan_done) {
878 m_stop_info_sp->SetStepOverPlanComplete();
881 }
882 return should_stop;
883 }
884
886 return true;
887 }
888
889 protected:
891 if (!m_did_disable_wp)
892 return;
893 m_did_disable_wp = true;
894 GetThread().GetProcess()->EnableWatchpoint(m_watch_sp, true);
895 }
896
897 private:
900 bool m_did_disable_wp = false;
901 };
902
903 bool ShouldStopSynchronous(Event *event_ptr) override {
904 // Watchpoint callbacks run on the PST during stop processing. Push
905 // private state context so callback code sees the private reality.
907
908 // If we are running our step-over the watchpoint plan, stop if it's done
909 // and continue if it's not:
911 return m_should_stop;
912
913 // If we are running our step over plan, then stop here and let the regular
914 // ShouldStop figure out what we should do: Otherwise, give our plan
915 // more time to get run:
918
920 ThreadSP thread_sp(m_thread_wp.lock());
921 assert(thread_sp);
922
923 if (thread_sp->GetTemporaryResumeState() == eStateSuspended) {
924 // This is the second firing of a watchpoint so don't process it again.
925 LLDB_LOG(log, "We didn't run but stopped with a StopInfoWatchpoint, we "
926 "have already handled this one, don't do it again.");
927 m_should_stop = false;
929 return m_should_stop;
930 }
931
932 WatchpointSP wp_sp(
933 thread_sp->CalculateTarget()->GetWatchpointList().FindByID(GetValue()));
934 // If we can no longer find the watchpoint, we just have to stop:
935 if (!wp_sp) {
936
937 LLDB_LOGF(log,
938 "Process::%s could not find watchpoint location id: %" PRId64
939 "...",
940 __FUNCTION__, GetValue());
941
942 m_should_stop = true;
944 return true;
945 }
946
947 ExecutionContext exe_ctx(thread_sp->GetStackFrameAtIndex(0));
948 StoppointCallbackContext context(event_ptr, exe_ctx, true);
949 m_should_stop = wp_sp->ShouldStop(&context);
950 if (!m_should_stop) {
951 // This won't happen at present because we only allow one watchpoint per
952 // watched range. So we won't stop at a watched address with a disabled
953 // watchpoint. If we start allowing overlapping watchpoints, then we
954 // will have to make watchpoints be real "WatchpointSite" and delegate to
955 // all the watchpoints sharing the site. In that case, the code below
956 // would be the right thing to do.
958 return m_should_stop;
959 }
960 // If this is a system where we need to execute the watchpoint by hand
961 // after the hit, queue a thread plan to do that, and then say not to stop.
962 // Otherwise, let the async action figure out whether the watchpoint should
963 // stop
964
965 ProcessSP process_sp = exe_ctx.GetProcessSP();
966 bool wp_triggers_after = process_sp->GetWatchpointReportedAfter();
967
968 if (!wp_triggers_after) {
969 // We have to step over the watchpoint before we know what to do:
970 StopInfoWatchpointSP me_as_siwp_sp
971 = std::static_pointer_cast<StopInfoWatchpoint>(shared_from_this());
972 ThreadPlanSP step_over_wp_sp =
973 std::make_shared<ThreadPlanStepOverWatchpoint>(*(thread_sp.get()),
974 me_as_siwp_sp, wp_sp);
975 // When this plan is done we want to stop, so set this as a Controlling
976 // plan.
977 step_over_wp_sp->SetIsControllingPlan(true);
978 step_over_wp_sp->SetOkayToDiscard(false);
979
981 error = thread_sp->QueueThreadPlan(step_over_wp_sp, false);
982 // If we couldn't push the thread plan, just stop here:
983 if (!error.Success()) {
984 LLDB_LOGF(log, "Could not push our step over watchpoint plan: %s",
985 error.AsCString());
986
987 m_should_stop = true;
989 return true;
990 } else {
991 // Otherwise, don't set m_should_stop, we don't know that yet. Just
992 // say we should continue, and tell the thread we really should do so:
993 thread_sp->SetShouldRunBeforePublicStop(true);
995 return false;
996 }
997 } else {
998 // We didn't have to do anything special
1000 return m_should_stop;
1001 }
1002
1003 return m_should_stop;
1004 }
1005
1006 bool ShouldStop(Event *event_ptr) override {
1007 // This just reports the work done by PerformAction or the synchronous
1008 // stop. It should only ever get called after they have had a chance to
1009 // run.
1010 assert(m_should_stop_is_valid);
1011 return m_should_stop;
1012 }
1013
1014 void PerformAction(Event *event_ptr) override {
1016
1017 Policy policy = PolicyStack::Get().Current();
1019 m_should_stop = false;
1021 LLDB_LOGF(log, "StopInfoWatchpoint::PerformAction - Hit a "
1022 "watchpoint while running an expression,"
1023 " not running commands to avoid recursion.");
1024 return;
1025 }
1026
1027 // We're going to calculate if we should stop or not in some way during the
1028 // course of this code. Also by default we're going to stop, so set that
1029 // here.
1030 m_should_stop = true;
1031
1032
1033 ThreadSP thread_sp(m_thread_wp.lock());
1034 if (thread_sp) {
1035
1036 WatchpointSP wp_sp(
1037 thread_sp->CalculateTarget()->GetWatchpointList().FindByID(
1038 GetValue()));
1039 if (wp_sp) {
1040 // This sentry object makes sure the current watchpoint is disabled
1041 // while performing watchpoint actions, and it is then enabled after we
1042 // are finished.
1043 ExecutionContext exe_ctx(thread_sp->GetStackFrameAtIndex(0));
1044 ProcessSP process_sp = exe_ctx.GetProcessSP();
1045
1046 WatchpointSentry sentry(process_sp, wp_sp);
1047
1048 if (m_silently_skip_wp) {
1049 m_should_stop = false;
1050 wp_sp->UndoHitCount();
1051 }
1052
1053 if (wp_sp->GetHitCount() <= wp_sp->GetIgnoreCount()) {
1054 m_should_stop = false;
1056 }
1057
1058 Debugger &debugger = exe_ctx.GetTargetRef().GetDebugger();
1059
1060 if (m_should_stop && wp_sp->GetConditionText() != nullptr) {
1061 // We need to make sure the user sees any parse errors in their
1062 // condition, so we'll hook the constructor errors up to the
1063 // debugger's Async I/O.
1064 ExpressionResults result_code;
1065 EvaluateExpressionOptions expr_options;
1066 expr_options.SetUnwindOnError(true);
1067 expr_options.SetIgnoreBreakpoints(true);
1068 ValueObjectSP result_value_sp;
1069 result_code = UserExpression::Evaluate(
1070 exe_ctx, expr_options, wp_sp->GetConditionText(),
1071 llvm::StringRef(), result_value_sp);
1072
1073 if (result_code == eExpressionCompleted) {
1074 if (result_value_sp) {
1075 Scalar scalar_value;
1076 if (result_value_sp->ResolveValue(scalar_value)) {
1077 if (scalar_value.ULongLong(1) == 0) {
1078 // The condition failed, which we consider "not having hit
1079 // the watchpoint" so undo the hit count here.
1080 wp_sp->UndoHitCount();
1081 m_should_stop = false;
1082 } else
1083 m_should_stop = true;
1084 LLDB_LOGF(log,
1085 "Condition successfully evaluated, result is %s.\n",
1086 m_should_stop ? "true" : "false");
1087 } else {
1088 m_should_stop = true;
1089 LLDB_LOGF(
1090 log,
1091 "Failed to get an integer result from the expression.");
1092 }
1093 }
1094 } else {
1095 const char *err_str = "<unknown error>";
1096 if (result_value_sp)
1097 err_str = result_value_sp->GetError().AsCString();
1098
1099 LLDB_LOGF(log, "Error evaluating condition: \"%s\"\n", err_str);
1100
1101 StreamString strm;
1102 strm << "stopped due to an error evaluating condition of "
1103 "watchpoint ";
1104 wp_sp->GetDescription(&strm, eDescriptionLevelBrief);
1105 strm << ": \"" << wp_sp->GetConditionText() << "\"\n";
1106 strm << err_str;
1107
1108 Debugger::ReportError(strm.GetString().str(),
1109 exe_ctx.GetTargetRef().GetDebugger().GetID());
1110 }
1111 }
1112
1113 // If the condition says to stop, we run the callback to further decide
1114 // whether to stop.
1115 if (m_should_stop) {
1116 // FIXME: For now the callbacks have to run in async mode - the
1117 // first time we restart we need
1118 // to get out of there. So set it here.
1119 // When we figure out how to nest watchpoint hits then this will
1120 // change.
1121
1122 bool old_async = debugger.GetAsyncExecution();
1123 debugger.SetAsyncExecution(true);
1124
1125 StoppointCallbackContext context(event_ptr, exe_ctx, false);
1126 bool stop_requested = wp_sp->InvokeCallback(&context);
1127
1128 debugger.SetAsyncExecution(old_async);
1129
1130 // Also make sure that the callback hasn't continued the target. If
1131 // it did, when we'll set m_should_stop to false and get out of here.
1132 if (HasTargetRunSinceMe())
1133 m_should_stop = false;
1134
1135 if (m_should_stop && !stop_requested) {
1136 // We have been vetoed by the callback mechanism.
1137 m_should_stop = false;
1138 }
1139 }
1140
1141 // Don't stop if the watched region value is unmodified, and
1142 // this is a Modify-type watchpoint.
1143 if (m_should_stop && !wp_sp->WatchedValueReportable(exe_ctx)) {
1144 wp_sp->UndoHitCount();
1145 m_should_stop = false;
1146 }
1147
1148 // Finally, if we are going to stop, print out the new & old values:
1149 if (m_should_stop) {
1150 wp_sp->CaptureWatchedValue(exe_ctx);
1151
1152 Debugger &debugger = exe_ctx.GetTargetRef().GetDebugger();
1153 StreamUP output_up = debugger.GetAsyncOutputStream();
1154 if (wp_sp->DumpSnapshots(output_up.get()))
1155 output_up->EOL();
1156 }
1157
1158 } else {
1159 Log *log_process(GetLog(LLDBLog::Process));
1160
1161 LLDB_LOGF(log_process,
1162 "Process::%s could not find watchpoint id: %" PRId64 "...",
1163 __FUNCTION__, m_value);
1164 }
1165 LLDB_LOGF(log,
1166 "Process::%s returning from action with m_should_stop: %d.",
1167 __FUNCTION__, m_should_stop);
1168
1170 }
1171 }
1172
1173private:
1178
1179 bool m_should_stop = false;
1181 // A false watchpoint hit has happened -
1182 // the thread stopped with a watchpoint
1183 // hit notification, but the watched region
1184 // was not actually accessed (as determined
1185 // by the gdb stub we're talking to).
1186 // Continue past this watchpoint without
1187 // notifying the user; on some targets this
1188 // may mean disable wp, instruction step,
1189 // re-enable wp, continue.
1190 // On others, just continue.
1194};
1195
1196// StopInfoUnixSignal
1197
1199public:
1200 StopInfoUnixSignal(Thread &thread, int signo, const char *description,
1201 std::optional<int> code)
1202 : StopInfo(thread, signo), m_code(code) {
1203 SetDescription(description);
1204 }
1205
1206 ~StopInfoUnixSignal() override = default;
1207
1208 StopReason GetStopReason() const override { return eStopReasonSignal; }
1209
1210 bool ShouldStopSynchronous(Event *event_ptr) override {
1211 ThreadSP thread_sp(m_thread_wp.lock());
1212 if (thread_sp)
1213 return thread_sp->GetProcess()->GetUnixSignals()->GetShouldStop(m_value);
1214 return false;
1215 }
1216
1217 void PerformAction([[maybe_unused]] Event *event_ptr) override {
1218 // A signal of SIGTRAP indicates that a trap instruction has been hit.
1219 if (m_value == SIGTRAP)
1221 }
1222
1223 bool ShouldStop(Event *event_ptr) override { return IsShouldStopSignal(); }
1224
1225 // If should stop returns false, check if we should notify of this event
1226 bool DoShouldNotify(Event *event_ptr) override {
1227 ThreadSP thread_sp(m_thread_wp.lock());
1228 if (thread_sp) {
1229 bool should_notify =
1230 thread_sp->GetProcess()->GetUnixSignals()->GetShouldNotify(m_value);
1231 if (should_notify) {
1232 StreamString strm;
1233 strm.Format(
1234 "thread {0:d} received signal: {1}", thread_sp->GetIndexID(),
1235 thread_sp->GetProcess()->GetUnixSignals()->GetSignalAsStringRef(
1236 m_value));
1238 strm.GetData());
1239 }
1240 return should_notify;
1241 }
1242 return true;
1243 }
1244
1245 void WillResume(lldb::StateType resume_state) override {
1246 ThreadSP thread_sp(m_thread_wp.lock());
1247 if (thread_sp) {
1248 if (!thread_sp->GetProcess()->GetUnixSignals()->GetShouldSuppress(
1249 m_value))
1250 thread_sp->SetResumeSignal(m_value);
1251 }
1252 }
1253
1254 const char *GetDescription() override {
1255 if (m_description.empty()) {
1256 ThreadSP thread_sp(m_thread_wp.lock());
1257 if (thread_sp) {
1258 UnixSignalsSP unix_signals = thread_sp->GetProcess()->GetUnixSignals();
1259 StreamString strm;
1260 strm << "signal ";
1261
1262 std::string signal_name =
1263 unix_signals->GetSignalDescription(m_value, m_code);
1264 if (signal_name.size())
1265 strm << signal_name;
1266 else
1267 strm.Printf("%" PRIi64, m_value);
1268
1269 m_description = std::string(strm.GetString());
1270 }
1271 }
1272 return m_description.c_str();
1273 }
1274
1275 bool ShouldSelect() const override { return IsShouldStopSignal(); }
1276
1277 uint32_t GetStopReasonDataCount() const override { return 1; }
1278 uint64_t GetStopReasonDataAtIndex(uint32_t idx) override {
1279 if (idx == 0)
1280 return GetValue();
1281 return 0;
1282 }
1283
1284private:
1285 // In siginfo_t terms, if m_value is si_signo, m_code is si_code.
1286 std::optional<int> m_code;
1287
1288 bool IsShouldStopSignal() const {
1289 if (ThreadSP thread_sp = m_thread_wp.lock())
1290 return thread_sp->GetProcess()->GetUnixSignals()->GetShouldStop(m_value);
1291 return false;
1292 }
1293};
1294
1295// StopInfoInterrupt
1296
1298public:
1299 StopInfoInterrupt(Thread &thread, int signo, const char *description)
1300 : StopInfo(thread, signo) {
1301 SetDescription(description);
1302 }
1303
1304 ~StopInfoInterrupt() override = default;
1305
1306 StopReason GetStopReason() const override {
1308 }
1309
1310 const char *GetDescription() override {
1311 if (m_description.empty()) {
1312 m_description = "async interrupt";
1313 }
1314 return m_description.c_str();
1315 }
1316
1317 uint32_t GetStopReasonDataCount() const override { return 1; }
1318 uint64_t GetStopReasonDataAtIndex(uint32_t idx) override {
1319 if (idx == 0)
1320 return GetValue();
1321 else
1322 return 0;
1323 }
1324};
1325
1326// StopInfoTrace
1327
1328class StopInfoTrace : public StopInfo {
1329public:
1331
1332 ~StopInfoTrace() override = default;
1333
1334 StopReason GetStopReason() const override { return eStopReasonTrace; }
1335
1336 const char *GetDescription() override {
1337 if (m_description.empty())
1338 return "trace";
1339 else
1340 return m_description.c_str();
1341 }
1342
1343 std::optional<uint32_t>
1344 GetSuggestedStackFrameIndex(bool inlined_stack) override {
1345 // Trace only knows how to adjust inlined stacks:
1346 if (!inlined_stack)
1347 return {};
1348
1349 ThreadSP thread_sp = GetThread();
1350 StackFrameSP frame_0_sp = thread_sp->GetStackFrameAtIndex(0);
1351 if (!frame_0_sp)
1352 return {};
1353 if (!frame_0_sp->IsInlined())
1354 return {};
1355 Block *block_ptr = frame_0_sp->GetFrameBlock();
1356 if (!block_ptr)
1357 return {};
1358 Address pc_address = frame_0_sp->GetFrameCodeAddress();
1359 AddressRange containing_range;
1360 if (!block_ptr->GetRangeContainingAddress(pc_address, containing_range) ||
1361 pc_address != containing_range.GetBaseAddress())
1362 return {};
1363
1364 int num_inlined_functions = 0;
1365
1366 for (Block *container_ptr = block_ptr->GetInlinedParent();
1367 container_ptr != nullptr;
1368 container_ptr = container_ptr->GetInlinedParent()) {
1369 if (!container_ptr->GetRangeContainingAddress(pc_address,
1370 containing_range))
1371 break;
1372 if (pc_address != containing_range.GetBaseAddress())
1373 break;
1374
1375 num_inlined_functions++;
1376 }
1377 inlined_stack = true;
1378 return num_inlined_functions + 1;
1379 }
1380};
1381
1382// StopInfoException
1383
1385public:
1386 StopInfoException(Thread &thread, const char *description)
1387 : StopInfo(thread, LLDB_INVALID_UID) {
1388 if (description)
1389 SetDescription(description);
1390 }
1391
1392 ~StopInfoException() override = default;
1393
1394 StopReason GetStopReason() const override { return eStopReasonException; }
1395
1396 const char *GetDescription() override {
1397 if (m_description.empty())
1398 return "exception";
1399 else
1400 return m_description.c_str();
1401 }
1402 uint32_t GetStopReasonDataCount() const override { return 1; }
1403 uint64_t GetStopReasonDataAtIndex(uint32_t idx) override {
1404 if (idx == 0)
1405 return GetValue();
1406 else
1407 return 0;
1408 }
1409};
1410
1411// StopInfoProcessorTrace
1412
1414public:
1415 StopInfoProcessorTrace(Thread &thread, const char *description)
1416 : StopInfo(thread, LLDB_INVALID_UID) {
1417 if (description)
1418 SetDescription(description);
1419 }
1420
1421 ~StopInfoProcessorTrace() override = default;
1422
1423 StopReason GetStopReason() const override {
1425 }
1426
1427 const char *GetDescription() override {
1428 if (m_description.empty())
1429 return "processor trace event";
1430 else
1431 return m_description.c_str();
1432 }
1433};
1434
1435// StopInfoHistoryBoundary
1436
1438public:
1439 StopInfoHistoryBoundary(Thread &thread, const char *description)
1440 : StopInfo(thread, LLDB_INVALID_UID) {
1441 if (description)
1442 SetDescription(description);
1443 }
1444
1445 ~StopInfoHistoryBoundary() override = default;
1446
1447 StopReason GetStopReason() const override {
1449 }
1450
1451 const char *GetDescription() override {
1452 if (m_description.empty())
1453 return "history boundary";
1454 return m_description.c_str();
1455 }
1456};
1457
1458// StopInfoThreadPlan
1459
1461public:
1462 StopInfoThreadPlan(ThreadPlanSP &plan_sp, ValueObjectSP &return_valobj_sp,
1463 ExpressionVariableSP &expression_variable_sp)
1464 : StopInfo(plan_sp->GetThread(), LLDB_INVALID_UID), m_plan_sp(plan_sp),
1465 m_return_valobj_sp(return_valobj_sp),
1466 m_expression_variable_sp(expression_variable_sp) {}
1467
1468 ~StopInfoThreadPlan() override = default;
1469
1471
1472 const char *GetDescription() override {
1473 if (m_description.empty()) {
1474 StreamString strm;
1475 m_plan_sp->GetDescription(&strm, eDescriptionLevelBrief);
1476 m_description = std::string(strm.GetString());
1477 }
1478 return m_description.c_str();
1479 }
1480
1482
1486
1487protected:
1488 bool ShouldStop(Event *event_ptr) override {
1489 if (m_plan_sp)
1490 return m_plan_sp->ShouldStop(event_ptr);
1491 else
1492 return StopInfo::ShouldStop(event_ptr);
1493 }
1494
1495private:
1499};
1500
1501// StopInfoExec
1502
1503class StopInfoExec : public StopInfo {
1504public:
1506
1507 ~StopInfoExec() override = default;
1508
1509 bool ShouldStop(Event *event_ptr) override {
1510 ThreadSP thread_sp(m_thread_wp.lock());
1511 if (thread_sp)
1512 return thread_sp->GetProcess()->GetStopOnExec();
1513 return false;
1514 }
1515
1516 StopReason GetStopReason() const override { return eStopReasonExec; }
1517
1518 const char *GetDescription() override { return "exec"; }
1519
1520protected:
1521 void PerformAction(Event *event_ptr) override {
1522 // Only perform the action once
1524 return;
1525 m_performed_action = true;
1526 ThreadSP thread_sp(m_thread_wp.lock());
1527 if (thread_sp)
1528 thread_sp->GetProcess()->DidExec();
1529 }
1530
1532};
1533
1534
1535// StopInfoFork
1536
1537class StopInfoFork : public StopInfo {
1538public:
1539 StopInfoFork(Thread &thread, lldb::pid_t child_pid, lldb::tid_t child_tid)
1540 : StopInfo(thread, child_pid), m_child_pid(child_pid),
1541 m_child_tid(child_tid) {}
1542
1543 ~StopInfoFork() override = default;
1544
1545 bool ShouldStop(Event *event_ptr) override {
1546 // During expression evaluation, return true so that the fork event
1547 // reaches RunThreadPlan as a real stop (not auto-restarted by
1548 // DoOnRemoval). RunThreadPlan decides whether to stop or continue
1549 // based on the stop-on-fork option.
1550 //
1551 // We check per-thread (not just process-wide IsRunningExpression)
1552 // because other threads may fork concurrently after the
1553 // try-all-threads timeout releases them.
1554 ThreadSP thread_sp(m_thread_wp.lock());
1555 if (thread_sp) {
1556 ProcessSP process_sp = thread_sp->GetProcess();
1557 if (process_sp && process_sp->GetModIDRef().IsRunningExpression() &&
1558 thread_sp->IsRunningCallFunctionPlan())
1559 return true;
1560 }
1561 return false;
1562 }
1563
1564 StopReason GetStopReason() const override { return eStopReasonFork; }
1565
1566 const char *GetDescription() override { return "fork"; }
1567
1568 uint32_t GetStopReasonDataCount() const override { return 1; }
1569 uint64_t GetStopReasonDataAtIndex(uint32_t idx) override {
1570 if (idx == 0)
1571 return GetValue();
1572 else
1573 return 0;
1574 }
1575
1576protected:
1577 void PerformAction(Event *event_ptr) override {
1578 // Only perform the action once
1580 return;
1581 m_performed_action = true;
1582 ThreadSP thread_sp(m_thread_wp.lock());
1583 if (thread_sp) {
1584 bool is_expression_fork =
1585 thread_sp->GetProcess()->GetModIDRef().IsRunningExpression() &&
1586 thread_sp->IsRunningCallFunctionPlan();
1587 thread_sp->GetProcess()->DidFork(m_child_pid, m_child_tid,
1588 is_expression_fork);
1589 }
1590 }
1591
1593
1594private:
1597};
1598
1599// StopInfoVFork
1600
1601class StopInfoVFork : public StopInfo {
1602public:
1603 StopInfoVFork(Thread &thread, lldb::pid_t child_pid, lldb::tid_t child_tid)
1604 : StopInfo(thread, child_pid), m_child_pid(child_pid),
1605 m_child_tid(child_tid) {}
1606
1607 ~StopInfoVFork() override = default;
1608
1609 bool ShouldStop(Event *event_ptr) override {
1610 ThreadSP thread_sp(m_thread_wp.lock());
1611 if (thread_sp) {
1612 ProcessSP process_sp = thread_sp->GetProcess();
1613 if (process_sp && process_sp->GetModIDRef().IsRunningExpression() &&
1614 thread_sp->IsRunningCallFunctionPlan())
1615 return true;
1616 }
1617 return false;
1618 }
1619
1620 StopReason GetStopReason() const override { return eStopReasonVFork; }
1621
1622 const char *GetDescription() override { return "vfork"; }
1623
1624 uint32_t GetStopReasonDataCount() const override { return 1; }
1625 uint64_t GetStopReasonDataAtIndex(uint32_t idx) override {
1626 if (idx == 0)
1627 return GetValue();
1628 return 0;
1629 }
1630
1631protected:
1632 void PerformAction(Event *event_ptr) override {
1633 // Only perform the action once
1635 return;
1636 m_performed_action = true;
1637 ThreadSP thread_sp(m_thread_wp.lock());
1638 if (thread_sp) {
1639 bool is_expression_fork =
1640 thread_sp->GetProcess()->GetModIDRef().IsRunningExpression() &&
1641 thread_sp->IsRunningCallFunctionPlan();
1642 thread_sp->GetProcess()->DidVFork(m_child_pid, m_child_tid,
1643 is_expression_fork);
1644 }
1645 }
1646
1648
1649private:
1652};
1653
1654// StopInfoVForkDone
1655
1657public:
1658 StopInfoVForkDone(Thread &thread) : StopInfo(thread, 0) {}
1659
1660 ~StopInfoVForkDone() override = default;
1661
1662 bool ShouldStop(Event *event_ptr) override {
1663 ThreadSP thread_sp(m_thread_wp.lock());
1664 if (thread_sp) {
1665 ProcessSP process_sp = thread_sp->GetProcess();
1666 if (process_sp && process_sp->GetModIDRef().IsRunningExpression() &&
1667 thread_sp->IsRunningCallFunctionPlan())
1668 return true;
1669 }
1670 return false;
1671 }
1672
1673 StopReason GetStopReason() const override { return eStopReasonVForkDone; }
1674
1675 const char *GetDescription() override { return "vforkdone"; }
1676
1677protected:
1678 void PerformAction(Event *event_ptr) override {
1679 // Only perform the action once
1681 return;
1682 m_performed_action = true;
1683 ThreadSP thread_sp(m_thread_wp.lock());
1684 if (thread_sp)
1685 thread_sp->GetProcess()->DidVForkDone();
1686 }
1687
1689};
1690
1691} // namespace lldb_private
1692
1694 break_id_t break_id) {
1695 thread.SetThreadHitBreakpointSite();
1696
1697 return std::make_shared<StopInfoBreakpoint>(thread, break_id);
1698}
1699
1701 break_id_t break_id,
1702 bool should_stop) {
1703 return std::make_shared<StopInfoBreakpoint>(thread, break_id, should_stop);
1704}
1705
1706// LWP_TODO: We'll need a CreateStopReasonWithWatchpointResourceID akin
1707// to CreateStopReasonWithBreakpointSiteID
1709 break_id_t watch_id,
1710 bool silently_continue) {
1711 return std::make_shared<StopInfoWatchpoint>(thread, watch_id,
1712 silently_continue);
1713}
1714
1716 const char *description,
1717 std::optional<int> code) {
1718 thread.GetProcess()->GetUnixSignals()->IncrementSignalHitCount(signo);
1719 return std::make_shared<StopInfoUnixSignal>(thread, signo, description, code);
1720}
1721
1723 const char *description) {
1724 return std::make_shared<StopInfoInterrupt>(thread, signo, description);
1725}
1726
1728 return std::make_shared<StopInfoTrace>(thread);
1729}
1730
1732 ThreadPlanSP &plan_sp, ValueObjectSP return_valobj_sp,
1733 ExpressionVariableSP expression_variable_sp) {
1734 return std::make_shared<StopInfoThreadPlan>(plan_sp, return_valobj_sp,
1735 expression_variable_sp);
1736}
1737
1739 const char *description) {
1740 return std::make_shared<StopInfoException>(thread, description);
1741}
1742
1744 const char *description) {
1745 return std::make_shared<StopInfoProcessorTrace>(thread, description);
1746}
1747
1749 const char *description) {
1750 return std::make_shared<StopInfoHistoryBoundary>(thread, description);
1751}
1752
1754 return std::make_shared<StopInfoExec>(thread);
1755}
1756
1758 lldb::pid_t child_pid,
1759 lldb::tid_t child_tid) {
1760 return std::make_shared<StopInfoFork>(thread, child_pid, child_tid);
1761}
1762
1763
1765 lldb::pid_t child_pid,
1766 lldb::tid_t child_tid) {
1767 return std::make_shared<StopInfoVFork>(thread, child_pid, child_tid);
1768}
1769
1771 return std::make_shared<StopInfoVForkDone>(thread);
1772}
1773
1775 if (stop_info_sp &&
1776 stop_info_sp->GetStopReason() == eStopReasonPlanComplete) {
1777 StopInfoThreadPlan *plan_stop_info =
1778 static_cast<StopInfoThreadPlan *>(stop_info_sp.get());
1779 return plan_stop_info->GetReturnValueObject();
1780 } else
1781 return ValueObjectSP();
1782}
1783
1785 if (stop_info_sp &&
1786 stop_info_sp->GetStopReason() == eStopReasonPlanComplete) {
1787 StopInfoThreadPlan *plan_stop_info =
1788 static_cast<StopInfoThreadPlan *>(stop_info_sp.get());
1789 return plan_stop_info->GetExpressionVariable();
1790 } else
1791 return ExpressionVariableSP();
1792}
1793
1796 lldb::addr_t *crashing_address) {
1797 if (!stop_info_sp) {
1798 return ValueObjectSP();
1799 }
1800
1801 const char *description = stop_info_sp->GetDescription();
1802 if (!description) {
1803 return ValueObjectSP();
1804 }
1805
1806 ThreadSP thread_sp = stop_info_sp->GetThread();
1807 if (!thread_sp) {
1808 return ValueObjectSP();
1809 }
1810
1811 StackFrameSP frame_sp =
1812 thread_sp->GetSelectedFrame(DoNoSelectMostRelevantFrame);
1813
1814 if (!frame_sp) {
1815 return ValueObjectSP();
1816 }
1817
1818 const char address_string[] = "address=";
1819
1820 const char *address_loc = strstr(description, address_string);
1821 if (!address_loc) {
1822 return ValueObjectSP();
1823 }
1824
1825 address_loc += (sizeof(address_string) - 1);
1826
1827 uint64_t address = strtoull(address_loc, nullptr, 0);
1828 if (crashing_address) {
1829 *crashing_address = address;
1830 }
1831
1832 return frame_sp->GuessValueForAddress(address);
1833}
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
Definition Log.h:364
#define LLDB_LOGF(log,...)
Definition Log.h:378
A section + offset based address range class.
Address & GetBaseAddress()
Get accessor for the base address of the range.
A section + offset based address class.
Definition Address.h:62
virtual bool IsValidTrapInstruction(llvm::ArrayRef< uint8_t > reference, llvm::ArrayRef< uint8_t > observed) const
Returns whether a given byte sequence is a valid trap instruction for the architecture.
A class that describes a single lexical block.
Definition Block.h:41
bool GetRangeContainingAddress(const Address &addr, AddressRange &range)
Definition Block.cpp:248
Block * GetInlinedParent()
Get the inlined parent block for this block.
Definition Block.cpp:212
lldb::BreakpointLocationSP GetByIndex(size_t i)
Returns a shared pointer to the breakpoint location with index i.
void Add(const lldb::BreakpointLocationSP &bp_loc_sp)
Add the breakpoint bp_loc_sp to the list.
size_t GetSize() const
Returns the number of elements in this breakpoint location list.
General Outline: A breakpoint has four main parts, a filter, a resolver, the list of breakpoint locat...
Definition Breakpoint.h:81
bool IsOneShot() const
Check the OneShot state.
bool IsInternal() const
Tell whether this breakpoint is an "internal" breakpoint.
A class to manage flag bits.
Definition Debugger.h:100
void SetAsyncExecution(bool async)
static void ReportWarning(std::string message, std::optional< lldb::user_id_t > debugger_id=std::nullopt, std::once_flag *once=nullptr)
Report warning events.
static void ReportError(std::string message, std::optional< lldb::user_id_t > debugger_id=std::nullopt, std::once_flag *once=nullptr)
Report error events.
lldb::StreamUP GetAsyncOutputStream()
void SetUnwindOnError(bool unwind=false)
Definition Target.h:395
void SetIgnoreBreakpoints(bool ignore=false)
Definition Target.h:399
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
const lldb::ProcessSP & GetProcessSP() const
Get accessor to get the process shared pointer.
Target & GetTargetRef() const
Returns a reference to the target object.
Process * GetProcessPtr() const
Returns a pointer to the process object.
RAII guard that pushes a policy on construction and pops on destruction.
Definition Policy.h:104
static PolicyStack & Get()
Definition Policy.h:87
Policy Current() const
Definition Policy.cpp:17
bool IsRunningExpression() const
Definition Process.h:281
bool GetIgnoreBreakpointsInExpressions() const
Definition Process.cpp:255
static void AddRestartedReason(Event *event_ptr, const char *reason)
Definition Process.cpp:4775
A plug-in interface definition class for debugging a process.
Definition Process.h:356
const ProcessModID & GetModIDRef() const
Definition Process.h:1488
Target & GetTarget()
Get the target object pointer for this module.
Definition Process.h:1254
unsigned long long ULongLong(unsigned long long fail_value=0) const
Definition Scalar.cpp:365
An error handling class.
Definition Status.h:118
const char * AsCString(const char *default_error_str="unknown error") const
Get the error string associated with the current error.
Definition Status.cpp:194
bool Success() const
Test for success condition.
Definition Status.cpp:303
void PerformAction(Event *event_ptr) override
Definition StopInfo.cpp:361
BreakpointSiteSP GetBreakpointSiteSP() const
Definition StopInfo.cpp:720
std::optional< uint32_t > GetSuggestedStackFrameIndex(bool inlined_stack) override
This gives the StopInfo a chance to suggest a stack frame to select.
Definition StopInfo.cpp:334
const char * GetDescription() override
Definition StopInfo.cpp:230
bool ShouldStopSynchronous(Event *event_ptr) override
Definition StopInfo.cpp:193
bool IsValidForOperatingSystemThread(Thread &thread) override
Definition StopInfo.cpp:181
bool DoShouldNotify(Event *event_ptr) override
Definition StopInfo.cpp:226
bool ShouldShow() const override
Returns true if this is a stop reason that should be shown to a user when viewing the thread with thi...
Definition StopInfo.cpp:348
uint32_t GetStopReasonDataCount() const override
Definition StopInfo.cpp:295
~StopInfoBreakpoint() override=default
bool ShouldSelect() const override
Returns true if this is a stop reason that should cause a thread to be selected when stopping.
Definition StopInfo.cpp:350
StopInfoBreakpoint(Thread &thread, break_id_t break_id, bool should_stop)
Definition StopInfo.cpp:140
StopInfoBreakpoint(Thread &thread, break_id_t break_id)
Definition StopInfo.cpp:131
BreakpointLocationCollection m_async_stopped_locs
The StopInfoBreakpoint lives after the stop, and could get queried at any time so we need to make sur...
Definition StopInfo.cpp:751
bool ShouldStop(Event *event_ptr) override
Definition StopInfo.cpp:353
uint64_t GetStopReasonDataAtIndex(uint32_t idx) override
Definition StopInfo.cpp:308
StopReason GetStopReason() const override
Definition StopInfo.cpp:191
uint64_t GetStopReasonDataAtIndex(uint32_t idx) override
const char * GetDescription() override
uint32_t GetStopReasonDataCount() const override
~StopInfoException() override=default
StopInfoException(Thread &thread, const char *description)
StopReason GetStopReason() const override
~StopInfoExec() override=default
StopInfoExec(Thread &thread)
const char * GetDescription() override
StopReason GetStopReason() const override
void PerformAction(Event *event_ptr) override
bool ShouldStop(Event *event_ptr) override
uint32_t GetStopReasonDataCount() const override
void PerformAction(Event *event_ptr) override
bool ShouldStop(Event *event_ptr) override
StopReason GetStopReason() const override
uint64_t GetStopReasonDataAtIndex(uint32_t idx) override
StopInfoFork(Thread &thread, lldb::pid_t child_pid, lldb::tid_t child_tid)
~StopInfoFork() override=default
const char * GetDescription() override
StopReason GetStopReason() const override
const char * GetDescription() override
~StopInfoHistoryBoundary() override=default
StopInfoHistoryBoundary(Thread &thread, const char *description)
uint32_t GetStopReasonDataCount() const override
StopInfoInterrupt(Thread &thread, int signo, const char *description)
const char * GetDescription() override
StopReason GetStopReason() const override
uint64_t GetStopReasonDataAtIndex(uint32_t idx) override
~StopInfoInterrupt() override=default
StopInfoProcessorTrace(Thread &thread, const char *description)
~StopInfoProcessorTrace() override=default
const char * GetDescription() override
StopReason GetStopReason() const override
bool ShouldStop(Event *event_ptr) override
~StopInfoThreadPlan() override=default
ExpressionVariableSP m_expression_variable_sp
ExpressionVariableSP GetExpressionVariable()
const char * GetDescription() override
StopReason GetStopReason() const override
StopInfoThreadPlan(ThreadPlanSP &plan_sp, ValueObjectSP &return_valobj_sp, ExpressionVariableSP &expression_variable_sp)
const char * GetDescription() override
~StopInfoTrace() override=default
StopReason GetStopReason() const override
StopInfoTrace(Thread &thread)
std::optional< uint32_t > GetSuggestedStackFrameIndex(bool inlined_stack) override
This gives the StopInfo a chance to suggest a stack frame to select.
StopInfoUnixSignal(Thread &thread, int signo, const char *description, std::optional< int > code)
void WillResume(lldb::StateType resume_state) override
bool DoShouldNotify(Event *event_ptr) override
~StopInfoUnixSignal() override=default
const char * GetDescription() override
std::optional< int > m_code
bool ShouldStopSynchronous(Event *event_ptr) override
uint32_t GetStopReasonDataCount() const override
bool ShouldStop(Event *event_ptr) override
StopReason GetStopReason() const override
uint64_t GetStopReasonDataAtIndex(uint32_t idx) override
bool ShouldSelect() const override
Returns true if this is a stop reason that should cause a thread to be selected when stopping.
void PerformAction(Event *event_ptr) override
const char * GetDescription() override
~StopInfoVForkDone() override=default
bool ShouldStop(Event *event_ptr) override
StopReason GetStopReason() const override
void PerformAction(Event *event_ptr) override
bool ShouldStop(Event *event_ptr) override
uint64_t GetStopReasonDataAtIndex(uint32_t idx) override
StopReason GetStopReason() const override
void PerformAction(Event *event_ptr) override
~StopInfoVFork() override=default
StopInfoVFork(Thread &thread, lldb::pid_t child_pid, lldb::tid_t child_tid)
const char * GetDescription() override
uint32_t GetStopReasonDataCount() const override
ThreadPlanStepOverWatchpoint(Thread &thread, StopInfoWatchpointSP stop_info_sp, WatchpointSP watch_sp)
Definition StopInfo.cpp:835
bool DoWillResume(lldb::StateType resume_state, bool current_plan) override
Definition StopInfo.cpp:844
WatchpointSentry(ProcessSP p_sp, WatchpointSP w_sp)
Definition StopInfo.cpp:762
static bool SentryPreResumeAction(void *sentry_void)
Definition StopInfo.cpp:791
~StopInfoWatchpoint() override=default
std::shared_ptr< StopInfoWatchpoint > StopInfoWatchpointSP
Definition StopInfo.cpp:826
StopInfoWatchpoint(Thread &thread, break_id_t watch_id, bool silently_skip_wp)
Definition StopInfo.cpp:802
uint32_t GetStopReasonDataCount() const override
Definition StopInfo.cpp:809
const char * GetDescription() override
Definition StopInfo.cpp:816
void PerformAction(Event *event_ptr) override
bool ShouldStop(Event *event_ptr) override
bool ShouldStopSynchronous(Event *event_ptr) override
Definition StopInfo.cpp:903
uint64_t GetStopReasonDataAtIndex(uint32_t idx) override
Definition StopInfo.cpp:810
StopReason GetStopReason() const override
Definition StopInfo.cpp:807
std::string m_description
Definition StopInfo.h:233
static lldb::StopInfoSP CreateStopReasonWithPlan(lldb::ThreadPlanSP &plan, lldb::ValueObjectSP return_valobj_sp, lldb::ExpressionVariableSP expression_variable_sp)
uint64_t GetValue() const
Definition StopInfo.h:46
static lldb::ExpressionVariableSP GetExpressionVariable(lldb::StopInfoSP &stop_info_sp)
static lldb::ValueObjectSP GetReturnValueObject(lldb::StopInfoSP &stop_info_sp)
static lldb::StopInfoSP CreateStopReasonToTrace(Thread &thread)
static lldb::StopInfoSP CreateStopReasonVFork(Thread &thread, lldb::pid_t child_pid, lldb::tid_t child_tid)
static lldb::StopInfoSP CreateStopReasonWithInterrupt(Thread &thread, int signo, const char *description)
bool IsValid() const
Definition StopInfo.cpp:44
StructuredData::ObjectSP m_extended_info
Definition StopInfo.h:238
static lldb::StopInfoSP CreateStopReasonWithSignal(Thread &thread, int signo, const char *description=nullptr, std::optional< int > code=std::nullopt)
lldb::ThreadSP GetThread() const
Definition StopInfo.h:35
static lldb::StopInfoSP CreateStopReasonFork(Thread &thread, lldb::pid_t child_pid, lldb::tid_t child_tid)
static lldb::StopInfoSP CreateStopReasonVForkDone(Thread &thread)
static lldb::StopInfoSP CreateStopReasonWithWatchpointID(Thread &thread, lldb::break_id_t watch_id, bool silently_continue=false)
virtual void SetDescription(const char *desc_cstr)
Definition StopInfo.h:74
static lldb::StopInfoSP CreateStopReasonWithException(Thread &thread, const char *description)
static lldb::StopInfoSP CreateStopReasonWithBreakpointSiteID(Thread &thread, lldb::break_id_t break_id)
static lldb::StopInfoSP CreateStopReasonHistoryBoundary(Thread &thread, const char *description)
static lldb::ValueObjectSP GetCrashingDereference(lldb::StopInfoSP &stop_info_sp, lldb::addr_t *crashing_address=nullptr)
LazyBool m_override_should_notify
Definition StopInfo.h:234
static lldb::StopInfoSP CreateStopReasonProcessorTrace(Thread &thread, const char *description)
static lldb::StopInfoSP CreateStopReasonWithExec(Thread &thread)
friend class Thread
Definition StopInfo.h:251
StopInfo(Thread &thread, uint64_t value)
Definition StopInfo.cpp:37
lldb::ThreadWP m_thread_wp
Definition StopInfo.h:228
LazyBool m_override_should_stop
Definition StopInfo.h:235
virtual bool ShouldStop(Event *event_ptr)
Definition StopInfo.h:219
General Outline: When we hit a breakpoint we need to package up whatever information is needed to eva...
lldb::break_id_t GetID() const
Definition Stoppoint.cpp:22
const char * GetData() const
llvm::StringRef GetString() const
void Format(const char *format, Args &&... args)
Forwards the arguments to llvm::formatv and writes to the stream.
Definition Stream.h:370
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition Stream.cpp:134
Debugger & GetDebugger() const
Definition Target.h:1323
bool DoPlanExplainsStop(Event *event_ptr) override
ThreadPlanStepInstruction(Thread &thread, bool step_over, bool stop_others, Vote report_stop_vote, Vote report_run_vote)
Thread & GetThread()
Returns the Thread that is using this thread plan.
virtual lldb::StopInfoSP GetPrivateStopInfo(bool calculate=true)
Definition Thread.cpp:401
void SetStopInfo(const lldb::StopInfoSP &stop_info_sp)
Definition Thread.cpp:479
lldb::ProcessSP GetProcess() const
Definition Thread.h:161
static lldb::ExpressionResults Evaluate(ExecutionContext &exe_ctx, const EvaluateExpressionOptions &options, llvm::StringRef expr_cstr, llvm::StringRef expr_prefix, lldb::ValueObjectSP &result_valobj_sp, std::string *fixed_expression=nullptr, ValueObject *ctx_obj=nullptr)
Evaluate one expression in the scratch context of the target passed in the exe_ctx and return its res...
#define LLDB_INVALID_BREAK_ID
#define LLDB_INVALID_UID
#define LLDB_INVALID_ADDRESS
@ 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.
Definition Log.h:327
std::shared_ptr< lldb_private::ThreadPlan > ThreadPlanSP
std::shared_ptr< lldb_private::StackFrame > StackFrameSP
std::shared_ptr< lldb_private::BreakpointSite > BreakpointSiteSP
std::shared_ptr< lldb_private::BreakpointLocation > BreakpointLocationSP
@ eDescriptionLevelBrief
std::shared_ptr< lldb_private::Thread > ThreadSP
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
std::shared_ptr< lldb_private::ExpressionVariable > ExpressionVariableSP
std::shared_ptr< lldb_private::UnixSignals > UnixSignalsSP
StateType
Process and Thread States.
@ eStateStopped
Process or thread is stopped and can be examined.
@ eStateSuspended
Process or thread is in a suspended state as far as the debugger is concerned while other processes o...
@ eStateRunning
Process or thread is running and can't be examined.
std::shared_ptr< lldb_private::Breakpoint > BreakpointSP
ExpressionResults
The results of expression evaluation.
@ eExpressionCompleted
int32_t break_id_t
Definition lldb-types.h:87
std::shared_ptr< lldb_private::Process > ProcessSP
uint64_t pid_t
Definition lldb-types.h:83
std::shared_ptr< lldb_private::Watchpoint > WatchpointSP
std::shared_ptr< lldb_private::StopInfo > StopInfoSP
uint64_t addr_t
Definition lldb-types.h:80
StopReason
Thread stop reasons.
@ eStopReasonPlanComplete
@ eStopReasonHistoryBoundary
@ eStopReasonBreakpoint
@ eStopReasonExec
Program was re-exec'ed.
@ eStopReasonVForkDone
@ eStopReasonInterrupt
Thread requested interrupt.
@ eStopReasonProcessorTrace
@ eStopReasonException
@ eStopReasonWatchpoint
std::unique_ptr< lldb_private::Stream > StreamUP
uint64_t tid_t
Definition lldb-types.h:84
Describes what view of the process a thread should see and what operations it is allowed to perform.
Definition Policy.h:32
Capabilities capabilities
Definition Policy.h:55
static Policy PrivateState()
Definition Policy.h:59
lldb::user_id_t GetID() const
Get accessor for the user ID.
Definition UserID.h:47
#define SIGTRAP