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/Process.h"
23#include "lldb/Target/Target.h"
24#include "lldb/Target/Thread.h"
29#include "lldb/Utility/Log.h"
30#include "lldb/Utility/Policy.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 // If we are in the middle of evaluating an expression, don't run
441 // asynchronous breakpoint commands or expressions. That could
442 // lead to infinite recursion if the command or condition re-calls
443 // the function with this breakpoint.
444 // TODO: We can keep a list of the breakpoints we've seen while
445 // running expressions in the nested
446 // PerformAction calls that can arise when the action runs a
447 // function that hits another breakpoint, and only stop running
448 // commands when we see the same breakpoint hit a second time.
449
451
452 // It is possible that the user has a breakpoint at the same site
453 // as the completed plan had (e.g. user has a breakpoint
454 // on a module entry point, and `ThreadPlanCallFunction` ends
455 // also there). We can't find an internal breakpoint in the loop
456 // later because it was already removed on the plan completion.
457 // So check if the plan was completed, and stop if so.
458 if (thread_sp->CompletedPlanOverridesBreakpoint()) {
459 m_should_stop = true;
460 thread_sp->ResetStopInfo();
461 return;
462 }
463
464 LLDB_LOGF(log, "StopInfoBreakpoint::PerformAction - Hit a "
465 "breakpoint while running an expression,"
466 " not running commands to avoid recursion.");
467 bool ignoring_breakpoints =
469 // Internal breakpoints should be allowed to do their job, we
470 // can make sure they don't do anything that would cause recursive
471 // command execution:
472 if (!m_was_all_internal) {
473 m_should_stop = !ignoring_breakpoints;
474 LLDB_LOGF(log,
475 "StopInfoBreakpoint::PerformAction - in expression, "
476 "continuing: %s.",
477 m_should_stop ? "true" : "false");
479 "hit breakpoint while running function, skipping commands "
480 "and conditions to prevent recursion",
481 process->GetTarget().GetDebugger().GetID());
482 return;
483 }
484 }
485
486 StoppointCallbackContext context(event_ptr, exe_ctx, false);
487
488 // For safety's sake let's also grab an extra reference to the
489 // breakpoint constituents of the locations we're going to examine,
490 // since the locations are going to have to get back to their
491 // breakpoints, and the locations don't keep their constituents alive.
492 // I'm just sticking the BreakpointSP's in a vector since I'm only
493 // using it to locally increment their retain counts.
494
495 // We are holding onto the breakpoint locations that were hit
496 // by this stop info between the "synchonous" ShouldStop and now.
497 // But an intervening action might have deleted one of the breakpoints
498 // we hit before we get here. So at the same time let's build a list
499 // of the still valid locations:
500 std::vector<lldb::BreakpointSP> location_constituents;
501
503 for (size_t j = 0; j < num_constituents; j++) {
504 BreakpointLocationSP loc_sp(m_async_stopped_locs.GetByIndex(j));
505 if (loc_sp->IsValid()) {
506 location_constituents.push_back(
507 loc_sp->GetBreakpoint().shared_from_this());
508 valid_locs.Add(loc_sp);
509 }
510 }
511
512 size_t num_valid_locs = valid_locs.GetSize();
513 for (size_t j = 0; j < num_valid_locs; j++) {
514 lldb::BreakpointLocationSP bp_loc_sp = valid_locs.GetByIndex(j);
515 StreamString loc_desc;
516 if (log) {
517 bp_loc_sp->GetDescription(&loc_desc, eDescriptionLevelBrief);
518 }
519 // If another action disabled this breakpoint or its location, then
520 // don't run the actions.
521 if (!bp_loc_sp->IsEnabled() ||
522 !bp_loc_sp->GetBreakpoint().IsEnabled())
523 continue;
524
525 // The breakpoint site may have many locations associated with it,
526 // not all of them valid for this thread. Skip the ones that
527 // aren't:
528 if (!bp_loc_sp->ValidForThisThread(*thread_sp)) {
529 LLDB_LOGF(log,
530 "Breakpoint %s hit on thread 0x%llx but it was not "
531 "for this thread, continuing.",
532 loc_desc.GetData(),
533 static_cast<unsigned long long>(thread_sp->GetID()));
534 continue;
535 }
536
537 // First run the precondition, but since the precondition is per
538 // breakpoint, only run it once per breakpoint.
539 std::pair<std::unordered_set<break_id_t>::iterator, bool> result =
540 precondition_breakpoints.insert(
541 bp_loc_sp->GetBreakpoint().GetID());
542 if (!result.second)
543 continue;
544
545 bool precondition_result =
546 bp_loc_sp->GetBreakpoint().EvaluatePrecondition(context);
547 if (!precondition_result) {
548 actually_said_continue = true;
549 continue;
550 }
551 // Next run the condition for the breakpoint. If that says we
552 // should stop, then we'll run the callback for the breakpoint. If
553 // the callback says we shouldn't stop that will win.
554
555 if (!bp_loc_sp->GetCondition())
556 actually_hit_any_locations = true;
557 else {
558 Status condition_error;
559 bool condition_says_stop =
560 bp_loc_sp->ConditionSaysStop(exe_ctx, condition_error);
561
562 if (!condition_error.Success()) {
563 // If the condition fails to evaluate, we are going to stop
564 // at it, so the location was hit.
565 actually_hit_any_locations = true;
566 const char *err_str =
567 condition_error.AsCString("<unknown error>");
568 LLDB_LOGF(log, "Error evaluating condition: \"%s\"\n", err_str);
569
570 StreamString strm;
571 strm << "stopped due to an error evaluating condition of "
572 "breakpoint ";
573 bp_loc_sp->GetDescription(&strm, eDescriptionLevelBrief);
574 strm << ": \"" << bp_loc_sp->GetCondition().GetText() << "\"\n";
575 strm << err_str;
576
578 strm.GetString().str(),
579 exe_ctx.GetTargetRef().GetDebugger().GetID());
580 } else {
581 LLDB_LOGF(log,
582 "Condition evaluated for breakpoint %s on thread "
583 "0x%llx condition_says_stop: %i.",
584 loc_desc.GetData(),
585 static_cast<unsigned long long>(thread_sp->GetID()),
586 condition_says_stop);
587 if (condition_says_stop)
588 actually_hit_any_locations = true;
589 else {
590 // We don't want to increment the hit count of breakpoints if
591 // the condition fails. We've already bumped it by the time
592 // we get here, so undo the bump:
593 bp_loc_sp->UndoBumpHitCount();
594 actually_said_continue = true;
595 continue;
596 }
597 }
598 }
599
600 // We've done all the checks whose failure means "we consider lldb
601 // not to have hit the breakpoint". Now we're going to check for
602 // conditions that might continue after hitting. Start with the
603 // ignore count:
604 if (!bp_loc_sp->IgnoreCountShouldStop()) {
605 actually_said_continue = true;
606 continue;
607 }
608
609 // Check the auto-continue bit on the location, do this before the
610 // callback since it may change this, but that would be for the
611 // NEXT hit. Note, you might think you could check auto-continue
612 // before the condition, and not evaluate the condition if it says
613 // to continue. But failing the condition means the breakpoint was
614 // effectively NOT HIT. So these two states are different.
615 bool auto_continue_says_stop = true;
616 if (bp_loc_sp->IsAutoContinue())
617 {
618 LLDB_LOGF(log,
619 "Continuing breakpoint %s as AutoContinue was set.",
620 loc_desc.GetData());
621 // We want this stop reported, so you will know we auto-continued
622 // but only for external breakpoints:
623 if (!bp_loc_sp->GetBreakpoint().IsInternal())
624 thread_sp->SetShouldReportStop(eVoteYes);
625 auto_continue_says_stop = false;
626 }
627
628 bool callback_says_stop = true;
629
630 // FIXME: For now the callbacks have to run in async mode - the
631 // first time we restart we need
632 // to get out of there. So set it here.
633 // When we figure out how to nest breakpoint hits then this will
634 // change.
635
636 // Don't run async callbacks in PerformAction. They have already
637 // been taken into account with async_should_stop.
638 if (!bp_loc_sp->IsCallbackSynchronous()) {
639 Debugger &debugger = thread_sp->CalculateTarget()->GetDebugger();
640 bool old_async = debugger.GetAsyncExecution();
641 debugger.SetAsyncExecution(true);
642
643 callback_says_stop = bp_loc_sp->InvokeCallback(&context);
644
645 debugger.SetAsyncExecution(old_async);
646
647 if (callback_says_stop && auto_continue_says_stop)
648 m_should_stop = true;
649 else
650 actually_said_continue = true;
651 }
652
653 if (m_should_stop && !bp_loc_sp->GetBreakpoint().IsInternal())
654 all_stopping_locs_internal = false;
655
656 // If we are going to stop for this breakpoint, then remove the
657 // breakpoint.
658 if (callback_says_stop && bp_loc_sp &&
659 bp_loc_sp->GetBreakpoint().IsOneShot()) {
660 thread_sp->GetProcess()->GetTarget().RemoveBreakpointByID(
661 bp_loc_sp->GetBreakpoint().GetID());
662 }
663 // Also make sure that the callback hasn't continued the target. If
664 // it did, when we'll set m_should_start to false and get out of
665 // here.
666 if (HasTargetRunSinceMe()) {
667 m_should_stop = false;
668 actually_said_continue = true;
669 break;
670 }
671 }
672 // At this point if nobody actually told us to continue, we should
673 // give the async breakpoint callback a chance to weigh in:
674 if (!actually_said_continue && !m_should_stop) {
675 m_should_stop = async_should_stop;
676 }
677 }
678 // We've figured out what this stop wants to do, so mark it as valid so
679 // we don't compute it again.
681 } else {
682 m_should_stop = true;
684 actually_hit_any_locations = true;
685 Log *log_process(GetLog(LLDBLog::Process));
686
687 LLDB_LOGF(log_process,
688 "Process::%s could not find breakpoint site id: %" PRId64
689 "...",
690 __FUNCTION__, m_value);
691 }
692
693 if ((!m_should_stop || all_stopping_locs_internal) &&
694 thread_sp->CompletedPlanOverridesBreakpoint()) {
695
696 // Override should_stop decision when we have completed step plan
697 // additionally to the breakpoint
698 m_should_stop = true;
699
700 // We know we're stopping for a completed plan and we don't want to
701 // show the breakpoint stop, so compute the public stop info immediately
702 // here.
703 thread_sp->CalculatePublicStopInfo();
704 } else if (!actually_hit_any_locations) {
705 // In the end, we didn't actually have any locations that passed their
706 // "was I hit" checks. So say we aren't stopped.
707 GetThread()->ResetStopInfo();
708 LLDB_LOGF(log, "Process::%s all locations failed condition checks.",
709 __FUNCTION__);
710 }
711
712 LLDB_LOGF(log,
713 "Process::%s returning from action with m_should_stop: %d.",
714 __FUNCTION__, m_should_stop);
715 }
716 }
717
718private:
721 return {};
722
723 ThreadSP thread_sp = GetThread();
724 if (!thread_sp)
725 return {};
726 ProcessSP process_sp = thread_sp->GetProcess();
727 if (!process_sp)
728 return {};
729
730 return process_sp->GetBreakpointSiteList().FindByID(m_value);
731 }
732
735 bool m_should_perform_action; // Since we are trying to preserve the "state"
736 // of the system even if we run functions
737 // etc. behind the users backs, we need to make sure we only REALLY perform
738 // the action once.
739 lldb::addr_t m_address; // We use this to capture the breakpoint site address
740 // when we create the StopInfo,
741 // in case somebody deletes it between the time the StopInfo is made and the
742 // description is asked for.
746 /// The StopInfoBreakpoint lives after the stop, and could get queried
747 /// at any time so we need to make sure that it keeps the breakpoints for
748 /// each of the locations it records alive while it is around. That's what
749 /// The BreakpointPreservingLocationCollection does.
751};
752
753// StopInfoWatchpoint
754
756public:
757 // Make sure watchpoint is properly disabled and subsequently enabled while
758 // performing watchpoint actions.
760 public:
762 watchpoint_sp(w_sp) {
763 if (process_sp && watchpoint_sp) {
764 const bool notify = false;
765 watchpoint_sp->TurnOnEphemeralMode();
766 process_sp->DisableWatchpoint(watchpoint_sp, notify);
767 process_sp->AddPreResumeAction(SentryPreResumeAction, this);
768 }
769 }
770
771 void DoReenable() {
772 if (process_sp && watchpoint_sp) {
773 bool was_disabled = watchpoint_sp->IsDisabledDuringEphemeralMode();
774 watchpoint_sp->TurnOffEphemeralMode();
775 const bool notify = false;
776 if (was_disabled) {
777 process_sp->DisableWatchpoint(watchpoint_sp, notify);
778 } else {
779 process_sp->EnableWatchpoint(watchpoint_sp, notify);
780 }
781 }
782 }
783
785 DoReenable();
786 if (process_sp)
787 process_sp->ClearPreResumeAction(SentryPreResumeAction, this);
788 }
789
790 static bool SentryPreResumeAction(void *sentry_void) {
791 WatchpointSentry *sentry = (WatchpointSentry *) sentry_void;
792 sentry->DoReenable();
793 return true;
794 }
795
796 private:
799 };
800
801 StopInfoWatchpoint(Thread &thread, break_id_t watch_id, bool silently_skip_wp)
802 : StopInfo(thread, watch_id), m_silently_skip_wp(silently_skip_wp) {}
803
804 ~StopInfoWatchpoint() override = default;
805
806 StopReason GetStopReason() const override { return eStopReasonWatchpoint; }
807
808 uint32_t GetStopReasonDataCount() const override { return 1; }
809 uint64_t GetStopReasonDataAtIndex(uint32_t idx) override {
810 if (idx == 0)
811 return GetValue();
812 return 0;
813 }
814
815 const char *GetDescription() override {
816 if (m_description.empty()) {
817 StreamString strm;
818 strm.Printf("watchpoint %" PRIi64, m_value);
819 m_description = std::string(strm.GetString());
820 }
821 return m_description.c_str();
822 }
823
824protected:
825 using StopInfoWatchpointSP = std::shared_ptr<StopInfoWatchpoint>;
826 // This plan is used to orchestrate stepping over the watchpoint for
827 // architectures (e.g. ARM) that report the watch before running the watched
828 // access. This is the sort of job you have to defer to the thread plans,
829 // if you try to do it directly in the stop info and there are other threads
830 // that needed to process this stop you will have yanked control away from
831 // them and they won't behave correctly.
833 public:
835 StopInfoWatchpointSP stop_info_sp,
836 WatchpointSP watch_sp)
837 : ThreadPlanStepInstruction(thread, false, true, eVoteNoOpinion,
839 m_stop_info_sp(stop_info_sp), m_watch_sp(watch_sp) {
840 assert(watch_sp);
841 }
842
843 bool DoWillResume(lldb::StateType resume_state,
844 bool current_plan) override {
845 if (resume_state == eStateSuspended)
846 return true;
847
848 if (!m_did_disable_wp) {
849 GetThread().GetProcess()->DisableWatchpoint(m_watch_sp, false);
850 m_did_disable_wp = true;
851 }
852 return true;
853 }
854
855 bool DoPlanExplainsStop(Event *event_ptr) override {
857 return true;
858 StopInfoSP stop_info_sp = GetThread().GetPrivateStopInfo();
859 // lldb-server resets the stop info for threads that didn't get to run,
860 // so we might have not gotten to run, but still have a watchpoint stop
861 // reason, in which case this will indeed be for us.
862 if (stop_info_sp
863 && stop_info_sp->GetStopReason() == eStopReasonWatchpoint)
864 return true;
865 return false;
866 }
867
868 void DidPop() override {
869 // Don't artifically keep the watchpoint alive.
870 m_watch_sp.reset();
871 }
872
873 bool ShouldStop(Event *event_ptr) override {
874 bool should_stop = ThreadPlanStepInstruction::ShouldStop(event_ptr);
875 bool plan_done = MischiefManaged();
876 if (plan_done) {
877 m_stop_info_sp->SetStepOverPlanComplete();
880 }
881 return should_stop;
882 }
883
885 return true;
886 }
887
888 protected:
890 if (!m_did_disable_wp)
891 return;
892 m_did_disable_wp = true;
893 GetThread().GetProcess()->EnableWatchpoint(m_watch_sp, true);
894 }
895
896 private:
899 bool m_did_disable_wp = false;
900 };
901
902 bool ShouldStopSynchronous(Event *event_ptr) override {
903 // Watchpoint callbacks run on the PST during stop processing. Push
904 // private state context so callback code sees the private reality.
906
907 // If we are running our step-over the watchpoint plan, stop if it's done
908 // and continue if it's not:
910 return m_should_stop;
911
912 // If we are running our step over plan, then stop here and let the regular
913 // ShouldStop figure out what we should do: Otherwise, give our plan
914 // more time to get run:
917
919 ThreadSP thread_sp(m_thread_wp.lock());
920 assert(thread_sp);
921
922 if (thread_sp->GetTemporaryResumeState() == eStateSuspended) {
923 // This is the second firing of a watchpoint so don't process it again.
924 LLDB_LOG(log, "We didn't run but stopped with a StopInfoWatchpoint, we "
925 "have already handled this one, don't do it again.");
926 m_should_stop = false;
928 return m_should_stop;
929 }
930
931 WatchpointSP wp_sp(
932 thread_sp->CalculateTarget()->GetWatchpointList().FindByID(GetValue()));
933 // If we can no longer find the watchpoint, we just have to stop:
934 if (!wp_sp) {
935
936 LLDB_LOGF(log,
937 "Process::%s could not find watchpoint location id: %" PRId64
938 "...",
939 __FUNCTION__, GetValue());
940
941 m_should_stop = true;
943 return true;
944 }
945
946 ExecutionContext exe_ctx(thread_sp->GetStackFrameAtIndex(0));
947 StoppointCallbackContext context(event_ptr, exe_ctx, true);
948 m_should_stop = wp_sp->ShouldStop(&context);
949 if (!m_should_stop) {
950 // This won't happen at present because we only allow one watchpoint per
951 // watched range. So we won't stop at a watched address with a disabled
952 // watchpoint. If we start allowing overlapping watchpoints, then we
953 // will have to make watchpoints be real "WatchpointSite" and delegate to
954 // all the watchpoints sharing the site. In that case, the code below
955 // would be the right thing to do.
957 return m_should_stop;
958 }
959 // If this is a system where we need to execute the watchpoint by hand
960 // after the hit, queue a thread plan to do that, and then say not to stop.
961 // Otherwise, let the async action figure out whether the watchpoint should
962 // stop
963
964 ProcessSP process_sp = exe_ctx.GetProcessSP();
965 bool wp_triggers_after = process_sp->GetWatchpointReportedAfter();
966
967 if (!wp_triggers_after) {
968 // We have to step over the watchpoint before we know what to do:
969 StopInfoWatchpointSP me_as_siwp_sp
970 = std::static_pointer_cast<StopInfoWatchpoint>(shared_from_this());
971 ThreadPlanSP step_over_wp_sp =
972 std::make_shared<ThreadPlanStepOverWatchpoint>(*(thread_sp.get()),
973 me_as_siwp_sp, wp_sp);
974 // When this plan is done we want to stop, so set this as a Controlling
975 // plan.
976 step_over_wp_sp->SetIsControllingPlan(true);
977 step_over_wp_sp->SetOkayToDiscard(false);
978
980 error = thread_sp->QueueThreadPlan(step_over_wp_sp, false);
981 // If we couldn't push the thread plan, just stop here:
982 if (!error.Success()) {
983 LLDB_LOGF(log, "Could not push our step over watchpoint plan: %s",
984 error.AsCString());
985
986 m_should_stop = true;
988 return true;
989 } else {
990 // Otherwise, don't set m_should_stop, we don't know that yet. Just
991 // say we should continue, and tell the thread we really should do so:
992 thread_sp->SetShouldRunBeforePublicStop(true);
994 return false;
995 }
996 } else {
997 // We didn't have to do anything special
999 return m_should_stop;
1000 }
1001
1002 return m_should_stop;
1003 }
1004
1005 bool ShouldStop(Event *event_ptr) override {
1006 // This just reports the work done by PerformAction or the synchronous
1007 // stop. It should only ever get called after they have had a chance to
1008 // run.
1009 assert(m_should_stop_is_valid);
1010 return m_should_stop;
1011 }
1012
1013 void PerformAction(Event *event_ptr) override {
1015
1016 Policy policy = PolicyStack::Get().Current();
1018 m_should_stop = false;
1020 LLDB_LOGF(log, "StopInfoWatchpoint::PerformAction - Hit a "
1021 "watchpoint while running an expression,"
1022 " not running commands to avoid recursion.");
1023 return;
1024 }
1025
1026 // We're going to calculate if we should stop or not in some way during the
1027 // course of this code. Also by default we're going to stop, so set that
1028 // here.
1029 m_should_stop = true;
1030
1031
1032 ThreadSP thread_sp(m_thread_wp.lock());
1033 if (thread_sp) {
1034
1035 WatchpointSP wp_sp(
1036 thread_sp->CalculateTarget()->GetWatchpointList().FindByID(
1037 GetValue()));
1038 if (wp_sp) {
1039 // This sentry object makes sure the current watchpoint is disabled
1040 // while performing watchpoint actions, and it is then enabled after we
1041 // are finished.
1042 ExecutionContext exe_ctx(thread_sp->GetStackFrameAtIndex(0));
1043 ProcessSP process_sp = exe_ctx.GetProcessSP();
1044
1045 WatchpointSentry sentry(process_sp, wp_sp);
1046
1047 if (m_silently_skip_wp) {
1048 m_should_stop = false;
1049 wp_sp->UndoHitCount();
1050 }
1051
1052 if (wp_sp->GetHitCount() <= wp_sp->GetIgnoreCount()) {
1053 m_should_stop = false;
1055 }
1056
1057 Debugger &debugger = exe_ctx.GetTargetRef().GetDebugger();
1058
1059 if (m_should_stop && wp_sp->GetConditionText() != nullptr) {
1060 // We need to make sure the user sees any parse errors in their
1061 // condition, so we'll hook the constructor errors up to the
1062 // debugger's Async I/O.
1063 ExpressionResults result_code;
1064 EvaluateExpressionOptions expr_options;
1065 expr_options.SetUnwindOnError(true);
1066 expr_options.SetIgnoreBreakpoints(true);
1067 ValueObjectSP result_value_sp;
1068 result_code = UserExpression::Evaluate(
1069 exe_ctx, expr_options, wp_sp->GetConditionText(),
1070 llvm::StringRef(), result_value_sp);
1071
1072 if (result_code == eExpressionCompleted) {
1073 if (result_value_sp) {
1074 Scalar scalar_value;
1075 if (result_value_sp->ResolveValue(scalar_value)) {
1076 if (scalar_value.ULongLong(1) == 0) {
1077 // The condition failed, which we consider "not having hit
1078 // the watchpoint" so undo the hit count here.
1079 wp_sp->UndoHitCount();
1080 m_should_stop = false;
1081 } else
1082 m_should_stop = true;
1083 LLDB_LOGF(log,
1084 "Condition successfully evaluated, result is %s.\n",
1085 m_should_stop ? "true" : "false");
1086 } else {
1087 m_should_stop = true;
1088 LLDB_LOGF(
1089 log,
1090 "Failed to get an integer result from the expression.");
1091 }
1092 }
1093 } else {
1094 const char *err_str = "<unknown error>";
1095 if (result_value_sp)
1096 err_str = result_value_sp->GetError().AsCString();
1097
1098 LLDB_LOGF(log, "Error evaluating condition: \"%s\"\n", err_str);
1099
1100 StreamString strm;
1101 strm << "stopped due to an error evaluating condition of "
1102 "watchpoint ";
1103 wp_sp->GetDescription(&strm, eDescriptionLevelBrief);
1104 strm << ": \"" << wp_sp->GetConditionText() << "\"\n";
1105 strm << err_str;
1106
1107 Debugger::ReportError(strm.GetString().str(),
1108 exe_ctx.GetTargetRef().GetDebugger().GetID());
1109 }
1110 }
1111
1112 // If the condition says to stop, we run the callback to further decide
1113 // whether to stop.
1114 if (m_should_stop) {
1115 // FIXME: For now the callbacks have to run in async mode - the
1116 // first time we restart we need
1117 // to get out of there. So set it here.
1118 // When we figure out how to nest watchpoint hits then this will
1119 // change.
1120
1121 bool old_async = debugger.GetAsyncExecution();
1122 debugger.SetAsyncExecution(true);
1123
1124 StoppointCallbackContext context(event_ptr, exe_ctx, false);
1125 bool stop_requested = wp_sp->InvokeCallback(&context);
1126
1127 debugger.SetAsyncExecution(old_async);
1128
1129 // Also make sure that the callback hasn't continued the target. If
1130 // it did, when we'll set m_should_stop to false and get out of here.
1131 if (HasTargetRunSinceMe())
1132 m_should_stop = false;
1133
1134 if (m_should_stop && !stop_requested) {
1135 // We have been vetoed by the callback mechanism.
1136 m_should_stop = false;
1137 }
1138 }
1139
1140 // Don't stop if the watched region value is unmodified, and
1141 // this is a Modify-type watchpoint.
1142 if (m_should_stop && !wp_sp->WatchedValueReportable(exe_ctx)) {
1143 wp_sp->UndoHitCount();
1144 m_should_stop = false;
1145 }
1146
1147 // Finally, if we are going to stop, print out the new & old values:
1148 if (m_should_stop) {
1149 wp_sp->CaptureWatchedValue(exe_ctx);
1150
1151 Debugger &debugger = exe_ctx.GetTargetRef().GetDebugger();
1152 StreamUP output_up = debugger.GetAsyncOutputStream();
1153 if (wp_sp->DumpSnapshots(output_up.get()))
1154 output_up->EOL();
1155 }
1156
1157 } else {
1158 Log *log_process(GetLog(LLDBLog::Process));
1159
1160 LLDB_LOGF(log_process,
1161 "Process::%s could not find watchpoint id: %" PRId64 "...",
1162 __FUNCTION__, m_value);
1163 }
1164 LLDB_LOGF(log,
1165 "Process::%s returning from action with m_should_stop: %d.",
1166 __FUNCTION__, m_should_stop);
1167
1169 }
1170 }
1171
1172private:
1177
1178 bool m_should_stop = false;
1180 // A false watchpoint hit has happened -
1181 // the thread stopped with a watchpoint
1182 // hit notification, but the watched region
1183 // was not actually accessed (as determined
1184 // by the gdb stub we're talking to).
1185 // Continue past this watchpoint without
1186 // notifying the user; on some targets this
1187 // may mean disable wp, instruction step,
1188 // re-enable wp, continue.
1189 // On others, just continue.
1193};
1194
1195// StopInfoUnixSignal
1196
1198public:
1199 StopInfoUnixSignal(Thread &thread, int signo, const char *description,
1200 std::optional<int> code)
1201 : StopInfo(thread, signo), m_code(code) {
1202 SetDescription(description);
1203 }
1204
1205 ~StopInfoUnixSignal() override = default;
1206
1207 StopReason GetStopReason() const override { return eStopReasonSignal; }
1208
1209 bool ShouldStopSynchronous(Event *event_ptr) override {
1210 ThreadSP thread_sp(m_thread_wp.lock());
1211 if (thread_sp)
1212 return thread_sp->GetProcess()->GetUnixSignals()->GetShouldStop(m_value);
1213 return false;
1214 }
1215
1216 void PerformAction([[maybe_unused]] Event *event_ptr) override {
1217 // A signal of SIGTRAP indicates that a trap instruction has been hit.
1218 if (m_value == SIGTRAP)
1220 }
1221
1222 bool ShouldStop(Event *event_ptr) override { return IsShouldStopSignal(); }
1223
1224 // If should stop returns false, check if we should notify of this event
1225 bool DoShouldNotify(Event *event_ptr) override {
1226 ThreadSP thread_sp(m_thread_wp.lock());
1227 if (thread_sp) {
1228 bool should_notify =
1229 thread_sp->GetProcess()->GetUnixSignals()->GetShouldNotify(m_value);
1230 if (should_notify) {
1231 StreamString strm;
1232 strm.Format(
1233 "thread {0:d} received signal: {1}", thread_sp->GetIndexID(),
1234 thread_sp->GetProcess()->GetUnixSignals()->GetSignalAsStringRef(
1235 m_value));
1237 strm.GetData());
1238 }
1239 return should_notify;
1240 }
1241 return true;
1242 }
1243
1244 void WillResume(lldb::StateType resume_state) override {
1245 ThreadSP thread_sp(m_thread_wp.lock());
1246 if (thread_sp) {
1247 if (!thread_sp->GetProcess()->GetUnixSignals()->GetShouldSuppress(
1248 m_value))
1249 thread_sp->SetResumeSignal(m_value);
1250 }
1251 }
1252
1253 const char *GetDescription() override {
1254 if (m_description.empty()) {
1255 ThreadSP thread_sp(m_thread_wp.lock());
1256 if (thread_sp) {
1257 UnixSignalsSP unix_signals = thread_sp->GetProcess()->GetUnixSignals();
1258 StreamString strm;
1259 strm << "signal ";
1260
1261 std::string signal_name =
1262 unix_signals->GetSignalDescription(m_value, m_code);
1263 if (signal_name.size())
1264 strm << signal_name;
1265 else
1266 strm.Printf("%" PRIi64, m_value);
1267
1268 m_description = std::string(strm.GetString());
1269 }
1270 }
1271 return m_description.c_str();
1272 }
1273
1274 bool ShouldSelect() const override { return IsShouldStopSignal(); }
1275
1276 uint32_t GetStopReasonDataCount() const override { return 1; }
1277 uint64_t GetStopReasonDataAtIndex(uint32_t idx) override {
1278 if (idx == 0)
1279 return GetValue();
1280 return 0;
1281 }
1282
1283private:
1284 // In siginfo_t terms, if m_value is si_signo, m_code is si_code.
1285 std::optional<int> m_code;
1286
1287 bool IsShouldStopSignal() const {
1288 if (ThreadSP thread_sp = m_thread_wp.lock())
1289 return thread_sp->GetProcess()->GetUnixSignals()->GetShouldStop(m_value);
1290 return false;
1291 }
1292};
1293
1294// StopInfoInterrupt
1295
1297public:
1298 StopInfoInterrupt(Thread &thread, int signo, const char *description)
1299 : StopInfo(thread, signo) {
1300 SetDescription(description);
1301 }
1302
1303 ~StopInfoInterrupt() override = default;
1304
1305 StopReason GetStopReason() const override {
1307 }
1308
1309 const char *GetDescription() override {
1310 if (m_description.empty()) {
1311 m_description = "async interrupt";
1312 }
1313 return m_description.c_str();
1314 }
1315
1316 uint32_t GetStopReasonDataCount() const override { return 1; }
1317 uint64_t GetStopReasonDataAtIndex(uint32_t idx) override {
1318 if (idx == 0)
1319 return GetValue();
1320 else
1321 return 0;
1322 }
1323};
1324
1325// StopInfoTrace
1326
1327class StopInfoTrace : public StopInfo {
1328public:
1330
1331 ~StopInfoTrace() override = default;
1332
1333 StopReason GetStopReason() const override { return eStopReasonTrace; }
1334
1335 const char *GetDescription() override {
1336 if (m_description.empty())
1337 return "trace";
1338 else
1339 return m_description.c_str();
1340 }
1341
1342 std::optional<uint32_t>
1343 GetSuggestedStackFrameIndex(bool inlined_stack) override {
1344 // Trace only knows how to adjust inlined stacks:
1345 if (!inlined_stack)
1346 return {};
1347
1348 ThreadSP thread_sp = GetThread();
1349 StackFrameSP frame_0_sp = thread_sp->GetStackFrameAtIndex(0);
1350 if (!frame_0_sp)
1351 return {};
1352 if (!frame_0_sp->IsInlined())
1353 return {};
1354 Block *block_ptr = frame_0_sp->GetFrameBlock();
1355 if (!block_ptr)
1356 return {};
1357 Address pc_address = frame_0_sp->GetFrameCodeAddress();
1358 AddressRange containing_range;
1359 if (!block_ptr->GetRangeContainingAddress(pc_address, containing_range) ||
1360 pc_address != containing_range.GetBaseAddress())
1361 return {};
1362
1363 int num_inlined_functions = 0;
1364
1365 for (Block *container_ptr = block_ptr->GetInlinedParent();
1366 container_ptr != nullptr;
1367 container_ptr = container_ptr->GetInlinedParent()) {
1368 if (!container_ptr->GetRangeContainingAddress(pc_address,
1369 containing_range))
1370 break;
1371 if (pc_address != containing_range.GetBaseAddress())
1372 break;
1373
1374 num_inlined_functions++;
1375 }
1376 inlined_stack = true;
1377 return num_inlined_functions + 1;
1378 }
1379};
1380
1381// StopInfoException
1382
1384public:
1385 StopInfoException(Thread &thread, const char *description)
1386 : StopInfo(thread, LLDB_INVALID_UID) {
1387 if (description)
1388 SetDescription(description);
1389 }
1390
1391 ~StopInfoException() override = default;
1392
1393 StopReason GetStopReason() const override { return eStopReasonException; }
1394
1395 const char *GetDescription() override {
1396 if (m_description.empty())
1397 return "exception";
1398 else
1399 return m_description.c_str();
1400 }
1401 uint32_t GetStopReasonDataCount() const override { return 1; }
1402 uint64_t GetStopReasonDataAtIndex(uint32_t idx) override {
1403 if (idx == 0)
1404 return GetValue();
1405 else
1406 return 0;
1407 }
1408};
1409
1410// StopInfoProcessorTrace
1411
1413public:
1414 StopInfoProcessorTrace(Thread &thread, const char *description)
1415 : StopInfo(thread, LLDB_INVALID_UID) {
1416 if (description)
1417 SetDescription(description);
1418 }
1419
1420 ~StopInfoProcessorTrace() override = default;
1421
1422 StopReason GetStopReason() const override {
1424 }
1425
1426 const char *GetDescription() override {
1427 if (m_description.empty())
1428 return "processor trace event";
1429 else
1430 return m_description.c_str();
1431 }
1432};
1433
1434// StopInfoHistoryBoundary
1435
1437public:
1438 StopInfoHistoryBoundary(Thread &thread, const char *description)
1439 : StopInfo(thread, LLDB_INVALID_UID) {
1440 if (description)
1441 SetDescription(description);
1442 }
1443
1444 ~StopInfoHistoryBoundary() override = default;
1445
1446 StopReason GetStopReason() const override {
1448 }
1449
1450 const char *GetDescription() override {
1451 if (m_description.empty())
1452 return "history boundary";
1453 return m_description.c_str();
1454 }
1455};
1456
1457// StopInfoThreadPlan
1458
1460public:
1461 StopInfoThreadPlan(ThreadPlanSP &plan_sp, ValueObjectSP &return_valobj_sp,
1462 ExpressionVariableSP &expression_variable_sp)
1463 : StopInfo(plan_sp->GetThread(), LLDB_INVALID_UID), m_plan_sp(plan_sp),
1464 m_return_valobj_sp(return_valobj_sp),
1465 m_expression_variable_sp(expression_variable_sp) {}
1466
1467 ~StopInfoThreadPlan() override = default;
1468
1470
1471 const char *GetDescription() override {
1472 if (m_description.empty()) {
1473 StreamString strm;
1474 m_plan_sp->GetDescription(&strm, eDescriptionLevelBrief);
1475 m_description = std::string(strm.GetString());
1476 }
1477 return m_description.c_str();
1478 }
1479
1481
1485
1486protected:
1487 bool ShouldStop(Event *event_ptr) override {
1488 if (m_plan_sp)
1489 return m_plan_sp->ShouldStop(event_ptr);
1490 else
1491 return StopInfo::ShouldStop(event_ptr);
1492 }
1493
1494private:
1498};
1499
1500// StopInfoExec
1501
1502class StopInfoExec : public StopInfo {
1503public:
1505
1506 ~StopInfoExec() override = default;
1507
1508 bool ShouldStop(Event *event_ptr) override {
1509 ThreadSP thread_sp(m_thread_wp.lock());
1510 if (thread_sp)
1511 return thread_sp->GetProcess()->GetStopOnExec();
1512 return false;
1513 }
1514
1515 StopReason GetStopReason() const override { return eStopReasonExec; }
1516
1517 const char *GetDescription() override { return "exec"; }
1518
1519protected:
1520 void PerformAction(Event *event_ptr) override {
1521 // Only perform the action once
1523 return;
1524 m_performed_action = true;
1525 ThreadSP thread_sp(m_thread_wp.lock());
1526 if (thread_sp)
1527 thread_sp->GetProcess()->DidExec();
1528 }
1529
1531};
1532
1533
1534// StopInfoFork
1535
1536class StopInfoFork : public StopInfo {
1537public:
1538 StopInfoFork(Thread &thread, lldb::pid_t child_pid, lldb::tid_t child_tid)
1539 : StopInfo(thread, child_pid), m_child_pid(child_pid),
1540 m_child_tid(child_tid) {}
1541
1542 ~StopInfoFork() override = default;
1543
1544 bool ShouldStop(Event *event_ptr) override {
1545 // During expression evaluation, return true so that the fork event
1546 // reaches RunThreadPlan as a real stop (not auto-restarted by
1547 // DoOnRemoval). RunThreadPlan decides whether to stop or continue
1548 // based on the stop-on-fork option.
1549 //
1550 // We check per-thread (not just process-wide IsRunningExpression)
1551 // because other threads may fork concurrently after the
1552 // try-all-threads timeout releases them.
1553 ThreadSP thread_sp(m_thread_wp.lock());
1554 if (thread_sp) {
1555 ProcessSP process_sp = thread_sp->GetProcess();
1556 if (process_sp && process_sp->GetModIDRef().IsRunningExpression() &&
1557 thread_sp->IsRunningCallFunctionPlan())
1558 return true;
1559 }
1560 return false;
1561 }
1562
1563 StopReason GetStopReason() const override { return eStopReasonFork; }
1564
1565 const char *GetDescription() override { return "fork"; }
1566
1567 uint32_t GetStopReasonDataCount() const override { return 1; }
1568 uint64_t GetStopReasonDataAtIndex(uint32_t idx) override {
1569 if (idx == 0)
1570 return GetValue();
1571 else
1572 return 0;
1573 }
1574
1575protected:
1576 void PerformAction(Event *event_ptr) override {
1577 // Only perform the action once
1579 return;
1580 m_performed_action = true;
1581 ThreadSP thread_sp(m_thread_wp.lock());
1582 if (thread_sp) {
1583 bool is_expression_fork =
1584 thread_sp->GetProcess()->GetModIDRef().IsRunningExpression() &&
1585 thread_sp->IsRunningCallFunctionPlan();
1586 thread_sp->GetProcess()->DidFork(m_child_pid, m_child_tid,
1587 is_expression_fork);
1588 }
1589 }
1590
1592
1593private:
1596};
1597
1598// StopInfoVFork
1599
1600class StopInfoVFork : public StopInfo {
1601public:
1602 StopInfoVFork(Thread &thread, lldb::pid_t child_pid, lldb::tid_t child_tid)
1603 : StopInfo(thread, child_pid), m_child_pid(child_pid),
1604 m_child_tid(child_tid) {}
1605
1606 ~StopInfoVFork() override = default;
1607
1608 bool ShouldStop(Event *event_ptr) override {
1609 ThreadSP thread_sp(m_thread_wp.lock());
1610 if (thread_sp) {
1611 ProcessSP process_sp = thread_sp->GetProcess();
1612 if (process_sp && process_sp->GetModIDRef().IsRunningExpression() &&
1613 thread_sp->IsRunningCallFunctionPlan())
1614 return true;
1615 }
1616 return false;
1617 }
1618
1619 StopReason GetStopReason() const override { return eStopReasonVFork; }
1620
1621 const char *GetDescription() override { return "vfork"; }
1622
1623 uint32_t GetStopReasonDataCount() const override { return 1; }
1624 uint64_t GetStopReasonDataAtIndex(uint32_t idx) override {
1625 if (idx == 0)
1626 return GetValue();
1627 return 0;
1628 }
1629
1630protected:
1631 void PerformAction(Event *event_ptr) override {
1632 // Only perform the action once
1634 return;
1635 m_performed_action = true;
1636 ThreadSP thread_sp(m_thread_wp.lock());
1637 if (thread_sp) {
1638 bool is_expression_fork =
1639 thread_sp->GetProcess()->GetModIDRef().IsRunningExpression() &&
1640 thread_sp->IsRunningCallFunctionPlan();
1641 thread_sp->GetProcess()->DidVFork(m_child_pid, m_child_tid,
1642 is_expression_fork);
1643 }
1644 }
1645
1647
1648private:
1651};
1652
1653// StopInfoVForkDone
1654
1656public:
1657 StopInfoVForkDone(Thread &thread) : StopInfo(thread, 0) {}
1658
1659 ~StopInfoVForkDone() override = default;
1660
1661 bool ShouldStop(Event *event_ptr) override {
1662 ThreadSP thread_sp(m_thread_wp.lock());
1663 if (thread_sp) {
1664 ProcessSP process_sp = thread_sp->GetProcess();
1665 if (process_sp && process_sp->GetModIDRef().IsRunningExpression() &&
1666 thread_sp->IsRunningCallFunctionPlan())
1667 return true;
1668 }
1669 return false;
1670 }
1671
1672 StopReason GetStopReason() const override { return eStopReasonVForkDone; }
1673
1674 const char *GetDescription() override { return "vforkdone"; }
1675
1676protected:
1677 void PerformAction(Event *event_ptr) override {
1678 // Only perform the action once
1680 return;
1681 m_performed_action = true;
1682 ThreadSP thread_sp(m_thread_wp.lock());
1683 if (thread_sp)
1684 thread_sp->GetProcess()->DidVForkDone();
1685 }
1686
1688};
1689
1690} // namespace lldb_private
1691
1693 break_id_t break_id) {
1694 thread.SetThreadHitBreakpointSite();
1695
1696 return std::make_shared<StopInfoBreakpoint>(thread, break_id);
1697}
1698
1700 break_id_t break_id,
1701 bool should_stop) {
1702 return std::make_shared<StopInfoBreakpoint>(thread, break_id, should_stop);
1703}
1704
1705// LWP_TODO: We'll need a CreateStopReasonWithWatchpointResourceID akin
1706// to CreateStopReasonWithBreakpointSiteID
1708 break_id_t watch_id,
1709 bool silently_continue) {
1710 return std::make_shared<StopInfoWatchpoint>(thread, watch_id,
1711 silently_continue);
1712}
1713
1715 const char *description,
1716 std::optional<int> code) {
1717 thread.GetProcess()->GetUnixSignals()->IncrementSignalHitCount(signo);
1718 return std::make_shared<StopInfoUnixSignal>(thread, signo, description, code);
1719}
1720
1722 const char *description) {
1723 return std::make_shared<StopInfoInterrupt>(thread, signo, description);
1724}
1725
1727 return std::make_shared<StopInfoTrace>(thread);
1728}
1729
1731 ThreadPlanSP &plan_sp, ValueObjectSP return_valobj_sp,
1732 ExpressionVariableSP expression_variable_sp) {
1733 return std::make_shared<StopInfoThreadPlan>(plan_sp, return_valobj_sp,
1734 expression_variable_sp);
1735}
1736
1738 const char *description) {
1739 return std::make_shared<StopInfoException>(thread, description);
1740}
1741
1743 const char *description) {
1744 return std::make_shared<StopInfoProcessorTrace>(thread, description);
1745}
1746
1748 const char *description) {
1749 return std::make_shared<StopInfoHistoryBoundary>(thread, description);
1750}
1751
1753 return std::make_shared<StopInfoExec>(thread);
1754}
1755
1757 lldb::pid_t child_pid,
1758 lldb::tid_t child_tid) {
1759 return std::make_shared<StopInfoFork>(thread, child_pid, child_tid);
1760}
1761
1762
1764 lldb::pid_t child_pid,
1765 lldb::tid_t child_tid) {
1766 return std::make_shared<StopInfoVFork>(thread, child_pid, child_tid);
1767}
1768
1770 return std::make_shared<StopInfoVForkDone>(thread);
1771}
1772
1774 if (stop_info_sp &&
1775 stop_info_sp->GetStopReason() == eStopReasonPlanComplete) {
1776 StopInfoThreadPlan *plan_stop_info =
1777 static_cast<StopInfoThreadPlan *>(stop_info_sp.get());
1778 return plan_stop_info->GetReturnValueObject();
1779 } else
1780 return ValueObjectSP();
1781}
1782
1784 if (stop_info_sp &&
1785 stop_info_sp->GetStopReason() == eStopReasonPlanComplete) {
1786 StopInfoThreadPlan *plan_stop_info =
1787 static_cast<StopInfoThreadPlan *>(stop_info_sp.get());
1788 return plan_stop_info->GetExpressionVariable();
1789 } else
1790 return ExpressionVariableSP();
1791}
1792
1795 lldb::addr_t *crashing_address) {
1796 if (!stop_info_sp) {
1797 return ValueObjectSP();
1798 }
1799
1800 const char *description = stop_info_sp->GetDescription();
1801 if (!description) {
1802 return ValueObjectSP();
1803 }
1804
1805 ThreadSP thread_sp = stop_info_sp->GetThread();
1806 if (!thread_sp) {
1807 return ValueObjectSP();
1808 }
1809
1810 StackFrameSP frame_sp =
1811 thread_sp->GetSelectedFrame(DoNoSelectMostRelevantFrame);
1812
1813 if (!frame_sp) {
1814 return ValueObjectSP();
1815 }
1816
1817 const char address_string[] = "address=";
1818
1819 const char *address_loc = strstr(description, address_string);
1820 if (!address_loc) {
1821 return ValueObjectSP();
1822 }
1823
1824 address_loc += (sizeof(address_string) - 1);
1825
1826 uint64_t address = strtoull(address_loc, nullptr, 0);
1827 if (crashing_address) {
1828 *crashing_address = address;
1829 }
1830
1831 return frame_sp->GuessValueForAddress(address);
1832}
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:376
#define LLDB_LOGF(log,...)
Definition Log.h:390
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:83
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:396
void SetIgnoreBreakpoints(bool ignore=false)
Definition Target.h:400
"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 pops a policy on destruction.
Definition Policy.h:110
Guard PushPrivateState(Policy::PrivateStatePurpose purpose=Policy::PrivateStatePurpose::Default)
All Push* methods delegate to the named static factories on Policy, which already inherit from Curren...
Definition Policy.h:132
static PolicyStack & Get()
Definition Policy.cpp:21
Policy Current() const
Definition Policy.cpp:26
bool GetIgnoreBreakpointsInExpressions() const
Definition Process.cpp:257
static void AddRestartedReason(Event *event_ptr, const char *reason)
Definition Process.cpp:4804
A plug-in interface definition class for debugging a process.
Definition Process.h:359
Target & GetTarget()
Get the target object pointer for this module.
Definition Process.h:1258
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:719
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:750
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:834
bool DoWillResume(lldb::StateType resume_state, bool current_plan) override
Definition StopInfo.cpp:843
WatchpointSentry(ProcessSP p_sp, WatchpointSP w_sp)
Definition StopInfo.cpp:761
static bool SentryPreResumeAction(void *sentry_void)
Definition StopInfo.cpp:790
~StopInfoWatchpoint() override=default
std::shared_ptr< StopInfoWatchpoint > StopInfoWatchpointSP
Definition StopInfo.cpp:825
StopInfoWatchpoint(Thread &thread, break_id_t watch_id, bool silently_skip_wp)
Definition StopInfo.cpp:801
uint32_t GetStopReasonDataCount() const override
Definition StopInfo.cpp:808
const char * GetDescription() override
Definition StopInfo.cpp:815
void PerformAction(Event *event_ptr) override
bool ShouldStop(Event *event_ptr) override
bool ShouldStopSynchronous(Event *event_ptr) override
Definition StopInfo.cpp:902
uint64_t GetStopReasonDataAtIndex(uint32_t idx) override
Definition StopInfo.cpp:809
StopReason GetStopReason() const override
Definition StopInfo.cpp:806
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:1326
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:162
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:339
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:33
Capabilities capabilities
Definition Policy.h:66
lldb::user_id_t GetID() const
Get accessor for the user ID.
Definition UserID.h:47
#define SIGTRAP