blob: 231dc033210158c6ab2597b5bb408cdf18ef939e [file] [log] [blame]
Chris Lattner24943d22010-06-08 16:52:24 +00001//===-- Thread.cpp ----------------------------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#include "lldb/lldb-private-log.h"
Jim Ingham3c7b5b92010-06-16 02:00:15 +000011#include "lldb/Breakpoint/BreakpointLocation.h"
Greg Claytona830adb2010-10-04 01:05:56 +000012#include "lldb/Core/Debugger.h"
Chris Lattner24943d22010-06-08 16:52:24 +000013#include "lldb/Core/Log.h"
14#include "lldb/Core/Stream.h"
15#include "lldb/Core/StreamString.h"
Jim Ingham20594b12010-09-08 03:14:33 +000016#include "lldb/Core/RegularExpression.h"
Chris Lattner24943d22010-06-08 16:52:24 +000017#include "lldb/Host/Host.h"
18#include "lldb/Target/DynamicLoader.h"
19#include "lldb/Target/ExecutionContext.h"
Jim Inghamb66cd072010-09-28 01:25:32 +000020#include "lldb/Target/ObjCLanguageRuntime.h"
Chris Lattner24943d22010-06-08 16:52:24 +000021#include "lldb/Target/Process.h"
22#include "lldb/Target/RegisterContext.h"
Greg Clayton643ee732010-08-04 01:40:35 +000023#include "lldb/Target/StopInfo.h"
Greg Clayton7661a982010-07-23 16:45:51 +000024#include "lldb/Target/Target.h"
Chris Lattner24943d22010-06-08 16:52:24 +000025#include "lldb/Target/Thread.h"
26#include "lldb/Target/ThreadPlan.h"
27#include "lldb/Target/ThreadPlanCallFunction.h"
Chris Lattner24943d22010-06-08 16:52:24 +000028#include "lldb/Target/ThreadPlanBase.h"
29#include "lldb/Target/ThreadPlanStepInstruction.h"
30#include "lldb/Target/ThreadPlanStepOut.h"
31#include "lldb/Target/ThreadPlanStepOverBreakpoint.h"
32#include "lldb/Target/ThreadPlanStepThrough.h"
33#include "lldb/Target/ThreadPlanStepInRange.h"
34#include "lldb/Target/ThreadPlanStepOverRange.h"
35#include "lldb/Target/ThreadPlanRunToAddress.h"
36#include "lldb/Target/ThreadPlanStepUntil.h"
Jim Ingham3c7b5b92010-06-16 02:00:15 +000037#include "lldb/Target/ThreadSpec.h"
Jim Ingham71219082010-08-12 02:14:28 +000038#include "lldb/Target/Unwind.h"
Chris Lattner24943d22010-06-08 16:52:24 +000039
40using namespace lldb;
41using namespace lldb_private;
42
43Thread::Thread (Process &process, lldb::tid_t tid) :
44 UserID (tid),
Jim Ingham20594b12010-09-08 03:14:33 +000045 ThreadInstanceSettings (*(Thread::GetSettingsController().get())),
Benjamin Kramer36a08102010-07-16 12:32:33 +000046 m_process (process),
Greg Clayton643ee732010-08-04 01:40:35 +000047 m_actual_stop_info_sp (),
Chris Lattner24943d22010-06-08 16:52:24 +000048 m_index_id (process.GetNextThreadIndexID ()),
49 m_reg_context_sp (),
Chris Lattner24943d22010-06-08 16:52:24 +000050 m_state (eStateUnloaded),
Greg Clayton782b9cc2010-08-25 00:35:26 +000051 m_state_mutex (Mutex::eMutexTypeRecursive),
Chris Lattner24943d22010-06-08 16:52:24 +000052 m_plan_stack (),
Chris Lattner24943d22010-06-08 16:52:24 +000053 m_completed_plan_stack(),
Greg Claytonf40e3082010-08-26 02:28:22 +000054 m_curr_frames_ap (),
Chris Lattner24943d22010-06-08 16:52:24 +000055 m_resume_signal (LLDB_INVALID_SIGNAL_NUMBER),
Jim Ingham71219082010-08-12 02:14:28 +000056 m_resume_state (eStateRunning),
57 m_unwinder_ap ()
58
Chris Lattner24943d22010-06-08 16:52:24 +000059{
60 Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT);
61 if (log)
62 log->Printf ("%p Thread::Thread(tid = 0x%4.4x)", this, GetID());
63
64 QueueFundamentalPlan(true);
Caroline Tice1ebef442010-09-27 00:30:10 +000065 UpdateInstanceName();
Chris Lattner24943d22010-06-08 16:52:24 +000066}
67
68
69Thread::~Thread()
70{
71 Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT);
72 if (log)
73 log->Printf ("%p Thread::~Thread(tid = 0x%4.4x)", this, GetID());
74}
75
76int
77Thread::GetResumeSignal () const
78{
79 return m_resume_signal;
80}
81
82void
83Thread::SetResumeSignal (int signal)
84{
85 m_resume_signal = signal;
86}
87
88StateType
89Thread::GetResumeState () const
90{
91 return m_resume_state;
92}
93
94void
95Thread::SetResumeState (StateType state)
96{
97 m_resume_state = state;
98}
99
Jim Ingham6297a3a2010-10-20 00:39:53 +0000100lldb::StopInfoSP
Greg Clayton643ee732010-08-04 01:40:35 +0000101Thread::GetStopInfo ()
Chris Lattner24943d22010-06-08 16:52:24 +0000102{
Jim Ingham6297a3a2010-10-20 00:39:53 +0000103 ThreadPlanSP plan_sp (GetCompletedPlan());
104 if (plan_sp)
105 return StopInfo::CreateStopReasonWithPlan (plan_sp);
106 else
107 return GetPrivateStopReason ();
Chris Lattner24943d22010-06-08 16:52:24 +0000108}
109
110bool
111Thread::ThreadStoppedForAReason (void)
112{
Greg Clayton643ee732010-08-04 01:40:35 +0000113 return GetPrivateStopReason () != NULL;
Chris Lattner24943d22010-06-08 16:52:24 +0000114}
115
116StateType
117Thread::GetState() const
118{
119 // If any other threads access this we will need a mutex for it
120 Mutex::Locker locker(m_state_mutex);
121 return m_state;
122}
123
124void
125Thread::SetState(StateType state)
126{
127 Mutex::Locker locker(m_state_mutex);
128 m_state = state;
129}
130
131void
132Thread::WillStop()
133{
134 ThreadPlan *current_plan = GetCurrentPlan();
135
136 // FIXME: I may decide to disallow threads with no plans. In which
137 // case this should go to an assert.
138
139 if (!current_plan)
140 return;
141
142 current_plan->WillStop();
143}
144
145void
146Thread::SetupForResume ()
147{
148 if (GetResumeState() != eStateSuspended)
149 {
150
151 // If we're at a breakpoint push the step-over breakpoint plan. Do this before
152 // telling the current plan it will resume, since we might change what the current
153 // plan is.
154
155 lldb::addr_t pc = GetRegisterContext()->GetPC();
156 BreakpointSiteSP bp_site_sp = GetProcess().GetBreakpointSiteList().FindByAddress(pc);
157 if (bp_site_sp && bp_site_sp->IsEnabled())
158 {
159 // Note, don't assume there's a ThreadPlanStepOverBreakpoint, the target may not require anything
160 // special to step over a breakpoint.
Jim Ingham5a47e8b2010-06-19 04:45:32 +0000161
162 ThreadPlan *cur_plan = GetCurrentPlan();
Chris Lattner24943d22010-06-08 16:52:24 +0000163
Jim Ingham5a47e8b2010-06-19 04:45:32 +0000164 if (cur_plan->GetKind() != ThreadPlan::eKindStepOverBreakpoint)
165 {
166 ThreadPlanStepOverBreakpoint *step_bp_plan = new ThreadPlanStepOverBreakpoint (*this);
167 if (step_bp_plan)
Chris Lattner24943d22010-06-08 16:52:24 +0000168 {
Jim Ingham5a47e8b2010-06-19 04:45:32 +0000169 ThreadPlanSP step_bp_plan_sp;
170 step_bp_plan->SetPrivate (true);
171
Chris Lattner24943d22010-06-08 16:52:24 +0000172 if (GetCurrentPlan()->RunState() != eStateStepping)
173 {
Jim Ingham5a47e8b2010-06-19 04:45:32 +0000174 step_bp_plan->SetAutoContinue(true);
Chris Lattner24943d22010-06-08 16:52:24 +0000175 }
Jim Ingham5a47e8b2010-06-19 04:45:32 +0000176 step_bp_plan_sp.reset (step_bp_plan);
Chris Lattner24943d22010-06-08 16:52:24 +0000177 QueueThreadPlan (step_bp_plan_sp, false);
178 }
179 }
180 }
181 }
182}
183
184bool
185Thread::WillResume (StateType resume_state)
186{
187 // At this point clear the completed plan stack.
188 m_completed_plan_stack.clear();
189 m_discarded_plan_stack.clear();
190
Greg Clayton643ee732010-08-04 01:40:35 +0000191 StopInfo *stop_info = GetPrivateStopReason().get();
192 if (stop_info)
193 stop_info->WillResume (resume_state);
Chris Lattner24943d22010-06-08 16:52:24 +0000194
195 // Tell all the plans that we are about to resume in case they need to clear any state.
196 // We distinguish between the plan on the top of the stack and the lower
197 // plans in case a plan needs to do any special business before it runs.
198
199 ThreadPlan *plan_ptr = GetCurrentPlan();
200 plan_ptr->WillResume(resume_state, true);
201
202 while ((plan_ptr = GetPreviousPlan(plan_ptr)) != NULL)
203 {
204 plan_ptr->WillResume (resume_state, false);
205 }
Greg Clayton643ee732010-08-04 01:40:35 +0000206
Greg Clayton643ee732010-08-04 01:40:35 +0000207 m_actual_stop_info_sp.reset();
Chris Lattner24943d22010-06-08 16:52:24 +0000208 return true;
209}
210
211void
212Thread::DidResume ()
213{
214 SetResumeSignal (LLDB_INVALID_SIGNAL_NUMBER);
215}
216
217bool
218Thread::ShouldStop (Event* event_ptr)
219{
220 ThreadPlan *current_plan = GetCurrentPlan();
221 bool should_stop = true;
222
223 Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP);
224 if (log)
225 {
226 StreamString s;
227 DumpThreadPlans(&s);
228 log->PutCString (s.GetData());
229 }
230
231 if (current_plan->PlanExplainsStop())
232 {
Jim Ingham5a47e8b2010-06-19 04:45:32 +0000233 bool over_ride_stop = current_plan->ShouldAutoContinue(event_ptr);
Chris Lattner24943d22010-06-08 16:52:24 +0000234 while (1)
235 {
236 should_stop = current_plan->ShouldStop(event_ptr);
237 if (current_plan->MischiefManaged())
238 {
239 if (should_stop)
240 current_plan->WillStop();
241
242 // If a Master Plan wants to stop, and wants to stick on the stack, we let it.
243 // Otherwise, see if the plan's parent wants to stop.
244
245 if (should_stop && current_plan->IsMasterPlan() && !current_plan->OkayToDiscard())
246 {
247 PopPlan();
248 break;
249 }
250 else
251 {
252
253 PopPlan();
254
255 current_plan = GetCurrentPlan();
256 if (current_plan == NULL)
257 {
258 break;
259 }
260 }
261
262 }
263 else
264 {
265 break;
266 }
267 }
Jim Ingham5a47e8b2010-06-19 04:45:32 +0000268 if (over_ride_stop)
269 should_stop = false;
Chris Lattner24943d22010-06-08 16:52:24 +0000270 }
271 else
272 {
273 // If the current plan doesn't explain the stop, then, find one that
274 // does and let it handle the situation.
275 ThreadPlan *plan_ptr = current_plan;
276 while ((plan_ptr = GetPreviousPlan(plan_ptr)) != NULL)
277 {
278 if (plan_ptr->PlanExplainsStop())
279 {
280 should_stop = plan_ptr->ShouldStop (event_ptr);
281 break;
282 }
283
284 }
285 }
286
287 return should_stop;
288}
289
290Vote
291Thread::ShouldReportStop (Event* event_ptr)
292{
293 StateType thread_state = GetResumeState ();
Greg Clayton5205f0b2010-09-03 17:10:42 +0000294 Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP);
295
296 if (thread_state == eStateSuspended || thread_state == eStateInvalid)
297 {
298 if (log)
299 log->Printf ("Thread::ShouldReportStop() tid = 0x%4.4x: returning vote %i (state was suspended or invalid)\n", GetID(), eVoteNoOpinion);
Chris Lattner24943d22010-06-08 16:52:24 +0000300 return eVoteNoOpinion;
Greg Clayton5205f0b2010-09-03 17:10:42 +0000301 }
Chris Lattner24943d22010-06-08 16:52:24 +0000302
303 if (m_completed_plan_stack.size() > 0)
304 {
305 // Don't use GetCompletedPlan here, since that suppresses private plans.
Greg Clayton5205f0b2010-09-03 17:10:42 +0000306 if (log)
307 log->Printf ("Thread::ShouldReportStop() tid = 0x%4.4x: returning vote for complete stack's back plan\n", GetID());
Chris Lattner24943d22010-06-08 16:52:24 +0000308 return m_completed_plan_stack.back()->ShouldReportStop (event_ptr);
309 }
310 else
Greg Clayton5205f0b2010-09-03 17:10:42 +0000311 {
312 if (log)
313 log->Printf ("Thread::ShouldReportStop() tid = 0x%4.4x: returning vote for current plan\n", GetID());
Chris Lattner24943d22010-06-08 16:52:24 +0000314 return GetCurrentPlan()->ShouldReportStop (event_ptr);
Greg Clayton5205f0b2010-09-03 17:10:42 +0000315 }
Chris Lattner24943d22010-06-08 16:52:24 +0000316}
317
318Vote
319Thread::ShouldReportRun (Event* event_ptr)
320{
321 StateType thread_state = GetResumeState ();
322 if (thread_state == eStateSuspended
323 || thread_state == eStateInvalid)
324 return eVoteNoOpinion;
325
326 if (m_completed_plan_stack.size() > 0)
327 {
328 // Don't use GetCompletedPlan here, since that suppresses private plans.
329 return m_completed_plan_stack.back()->ShouldReportRun (event_ptr);
330 }
331 else
332 return GetCurrentPlan()->ShouldReportRun (event_ptr);
333}
334
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000335bool
336Thread::MatchesSpec (const ThreadSpec *spec)
337{
338 if (spec == NULL)
339 return true;
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000340
Jim Ingham649492b2010-06-18 01:00:58 +0000341 return spec->ThreadPassesBasicTests(this);
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000342}
343
Chris Lattner24943d22010-06-08 16:52:24 +0000344void
345Thread::PushPlan (ThreadPlanSP &thread_plan_sp)
346{
347 if (thread_plan_sp)
348 {
Jim Ingham6297a3a2010-10-20 00:39:53 +0000349 m_plan_stack.push_back (thread_plan_sp);
Chris Lattner24943d22010-06-08 16:52:24 +0000350
351 thread_plan_sp->DidPush();
352
353 Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP);
354 if (log)
355 {
356 StreamString s;
357 thread_plan_sp->GetDescription (&s, lldb::eDescriptionLevelFull);
Jim Ingham6297a3a2010-10-20 00:39:53 +0000358 log->Printf("Pushing plan: \"%s\", tid = 0x%4.4x.",
Chris Lattner24943d22010-06-08 16:52:24 +0000359 s.GetData(),
Jim Ingham6297a3a2010-10-20 00:39:53 +0000360 thread_plan_sp->GetThread().GetID());
Chris Lattner24943d22010-06-08 16:52:24 +0000361 }
362 }
363}
364
365void
366Thread::PopPlan ()
367{
368 Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP);
369
Jim Ingham6297a3a2010-10-20 00:39:53 +0000370 if (m_plan_stack.empty())
Chris Lattner24943d22010-06-08 16:52:24 +0000371 return;
372 else
373 {
374 ThreadPlanSP &plan = m_plan_stack.back();
375 if (log)
376 {
Greg Claytonf04d6612010-09-03 22:45:01 +0000377 log->Printf("Popping plan: \"%s\", tid = 0x%4.4x, immediate = false.", plan->GetName(), plan->GetThread().GetID());
Chris Lattner24943d22010-06-08 16:52:24 +0000378 }
379 m_completed_plan_stack.push_back (plan);
380 plan->WillPop();
381 m_plan_stack.pop_back();
382 }
383}
384
385void
386Thread::DiscardPlan ()
387{
388 if (m_plan_stack.size() > 1)
389 {
390 ThreadPlanSP &plan = m_plan_stack.back();
391 m_discarded_plan_stack.push_back (plan);
392 plan->WillPop();
393 m_plan_stack.pop_back();
394 }
395}
396
397ThreadPlan *
398Thread::GetCurrentPlan ()
399{
Jim Ingham6297a3a2010-10-20 00:39:53 +0000400 if (m_plan_stack.empty())
Chris Lattner24943d22010-06-08 16:52:24 +0000401 return NULL;
402 else
403 return m_plan_stack.back().get();
404}
405
406ThreadPlanSP
407Thread::GetCompletedPlan ()
408{
409 ThreadPlanSP empty_plan_sp;
410 if (!m_completed_plan_stack.empty())
411 {
412 for (int i = m_completed_plan_stack.size() - 1; i >= 0; i--)
413 {
414 ThreadPlanSP completed_plan_sp;
415 completed_plan_sp = m_completed_plan_stack[i];
416 if (!completed_plan_sp->GetPrivate ())
417 return completed_plan_sp;
418 }
419 }
420 return empty_plan_sp;
421}
422
423bool
424Thread::IsThreadPlanDone (ThreadPlan *plan)
425{
426 ThreadPlanSP empty_plan_sp;
427 if (!m_completed_plan_stack.empty())
428 {
429 for (int i = m_completed_plan_stack.size() - 1; i >= 0; i--)
430 {
431 if (m_completed_plan_stack[i].get() == plan)
432 return true;
433 }
434 }
435 return false;
436}
437
438bool
439Thread::WasThreadPlanDiscarded (ThreadPlan *plan)
440{
441 ThreadPlanSP empty_plan_sp;
442 if (!m_discarded_plan_stack.empty())
443 {
444 for (int i = m_discarded_plan_stack.size() - 1; i >= 0; i--)
445 {
446 if (m_discarded_plan_stack[i].get() == plan)
447 return true;
448 }
449 }
450 return false;
451}
452
453ThreadPlan *
454Thread::GetPreviousPlan (ThreadPlan *current_plan)
455{
456 if (current_plan == NULL)
457 return NULL;
458
459 int stack_size = m_completed_plan_stack.size();
460 for (int i = stack_size - 1; i > 0; i--)
461 {
462 if (current_plan == m_completed_plan_stack[i].get())
463 return m_completed_plan_stack[i-1].get();
464 }
465
466 if (stack_size > 0 && m_completed_plan_stack[0].get() == current_plan)
467 {
Chris Lattner24943d22010-06-08 16:52:24 +0000468 if (m_plan_stack.size() > 0)
469 return m_plan_stack.back().get();
470 else
471 return NULL;
472 }
473
474 stack_size = m_plan_stack.size();
475 for (int i = stack_size - 1; i > 0; i--)
476 {
477 if (current_plan == m_plan_stack[i].get())
478 return m_plan_stack[i-1].get();
479 }
480 return NULL;
481}
482
483void
484Thread::QueueThreadPlan (ThreadPlanSP &thread_plan_sp, bool abort_other_plans)
485{
486 if (abort_other_plans)
487 DiscardThreadPlans(true);
488
489 PushPlan (thread_plan_sp);
490}
491
492void
Jim Inghamea9d4262010-11-05 19:25:48 +0000493Thread::DiscardThreadPlansUpToPlan (lldb::ThreadPlanSP &up_to_plan_sp)
494{
495 Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP);
496 if (log)
497 {
498 log->Printf("Discarding thread plans for thread tid = 0x%4.4x, up to %p", GetID(), up_to_plan_sp.get());
499 }
500
501 int stack_size = m_plan_stack.size();
502
503 // If the input plan is NULL, discard all plans. Otherwise make sure this plan is in the
504 // stack, and if so discard up to and including it.
505
506 if (up_to_plan_sp.get() == NULL)
507 {
508 for (int i = stack_size - 1; i > 0; i--)
509 DiscardPlan();
510 }
511 else
512 {
513 bool found_it = false;
514 for (int i = stack_size - 1; i > 0; i--)
515 {
516 if (m_plan_stack[i] == up_to_plan_sp)
517 found_it = true;
518 }
519 if (found_it)
520 {
521 bool last_one = false;
522 for (int i = stack_size - 1; i > 0 && !last_one ; i--)
523 {
524 if (GetCurrentPlan() == up_to_plan_sp.get())
525 last_one = true;
526 DiscardPlan();
527 }
528 }
529 }
530 return;
531}
532
533void
Chris Lattner24943d22010-06-08 16:52:24 +0000534Thread::DiscardThreadPlans(bool force)
535{
Chris Lattner24943d22010-06-08 16:52:24 +0000536 Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP);
537 if (log)
538 {
Greg Claytonf04d6612010-09-03 22:45:01 +0000539 log->Printf("Discarding thread plans for thread (tid = 0x%4.4x, force %d)", GetID(), force);
Chris Lattner24943d22010-06-08 16:52:24 +0000540 }
541
542 if (force)
543 {
544 int stack_size = m_plan_stack.size();
545 for (int i = stack_size - 1; i > 0; i--)
546 {
547 DiscardPlan();
548 }
549 return;
550 }
551
552 while (1)
553 {
554
555 int master_plan_idx;
556 bool discard;
557
558 // Find the first master plan, see if it wants discarding, and if yes discard up to it.
559 for (master_plan_idx = m_plan_stack.size() - 1; master_plan_idx >= 0; master_plan_idx--)
560 {
561 if (m_plan_stack[master_plan_idx]->IsMasterPlan())
562 {
563 discard = m_plan_stack[master_plan_idx]->OkayToDiscard();
564 break;
565 }
566 }
567
568 if (discard)
569 {
570 // First pop all the dependent plans:
571 for (int i = m_plan_stack.size() - 1; i > master_plan_idx; i--)
572 {
573
574 // FIXME: Do we need a finalize here, or is the rule that "PrepareForStop"
575 // for the plan leaves it in a state that it is safe to pop the plan
576 // with no more notice?
577 DiscardPlan();
578 }
579
580 // Now discard the master plan itself.
581 // The bottom-most plan never gets discarded. "OkayToDiscard" for it means
582 // discard it's dependent plans, but not it...
583 if (master_plan_idx > 0)
584 {
585 DiscardPlan();
586 }
587 }
588 else
589 {
590 // If the master plan doesn't want to get discarded, then we're done.
591 break;
592 }
593
594 }
595 // FIXME: What should we do about the immediate plans?
596}
597
598ThreadPlan *
599Thread::QueueFundamentalPlan (bool abort_other_plans)
600{
601 ThreadPlanSP thread_plan_sp (new ThreadPlanBase(*this));
602 QueueThreadPlan (thread_plan_sp, abort_other_plans);
603 return thread_plan_sp.get();
604}
605
606ThreadPlan *
607Thread::QueueThreadPlanForStepSingleInstruction (bool step_over, bool abort_other_plans, bool stop_other_threads)
608{
609 ThreadPlanSP thread_plan_sp (new ThreadPlanStepInstruction (*this, step_over, stop_other_threads, eVoteNoOpinion, eVoteNoOpinion));
610 QueueThreadPlan (thread_plan_sp, abort_other_plans);
611 return thread_plan_sp.get();
612}
613
614ThreadPlan *
Greg Clayton8f5fd6b2010-06-12 18:59:55 +0000615Thread::QueueThreadPlanForStepRange
616(
617 bool abort_other_plans,
618 StepType type,
619 const AddressRange &range,
620 const SymbolContext &addr_context,
621 lldb::RunMode stop_other_threads,
622 bool avoid_code_without_debug_info
623)
Chris Lattner24943d22010-06-08 16:52:24 +0000624{
625 ThreadPlanSP thread_plan_sp;
626 if (type == eStepTypeInto)
Greg Clayton8f5fd6b2010-06-12 18:59:55 +0000627 {
628 ThreadPlanStepInRange *plan = new ThreadPlanStepInRange (*this, range, addr_context, stop_other_threads);
629 if (avoid_code_without_debug_info)
630 plan->GetFlags().Set (ThreadPlanShouldStopHere::eAvoidNoDebug);
631 else
632 plan->GetFlags().Clear (ThreadPlanShouldStopHere::eAvoidNoDebug);
633 thread_plan_sp.reset (plan);
634 }
Chris Lattner24943d22010-06-08 16:52:24 +0000635 else
636 thread_plan_sp.reset (new ThreadPlanStepOverRange (*this, range, addr_context, stop_other_threads));
637
638 QueueThreadPlan (thread_plan_sp, abort_other_plans);
639 return thread_plan_sp.get();
640}
641
642
643ThreadPlan *
644Thread::QueueThreadPlanForStepOverBreakpointPlan (bool abort_other_plans)
645{
646 ThreadPlanSP thread_plan_sp (new ThreadPlanStepOverBreakpoint (*this));
647 QueueThreadPlan (thread_plan_sp, abort_other_plans);
648 return thread_plan_sp.get();
649}
650
651ThreadPlan *
652Thread::QueueThreadPlanForStepOut (bool abort_other_plans, SymbolContext *addr_context, bool first_insn,
653 bool stop_other_threads, Vote stop_vote, Vote run_vote)
654{
655 ThreadPlanSP thread_plan_sp (new ThreadPlanStepOut (*this, addr_context, first_insn, stop_other_threads, stop_vote, run_vote));
656 QueueThreadPlan (thread_plan_sp, abort_other_plans);
657 return thread_plan_sp.get();
658}
659
660ThreadPlan *
661Thread::QueueThreadPlanForStepThrough (bool abort_other_plans, bool stop_other_threads)
662{
Jim Inghamb66cd072010-09-28 01:25:32 +0000663 // Try the dynamic loader first:
Chris Lattner24943d22010-06-08 16:52:24 +0000664 ThreadPlanSP thread_plan_sp(GetProcess().GetDynamicLoader()->GetStepThroughTrampolinePlan (*this, stop_other_threads));
Jim Inghamb66cd072010-09-28 01:25:32 +0000665 // If that didn't come up with anything, try the ObjC runtime plugin:
666 if (thread_plan_sp.get() == NULL)
667 {
668 ObjCLanguageRuntime *objc_runtime = GetProcess().GetObjCLanguageRuntime();
669 if (objc_runtime)
670 thread_plan_sp = objc_runtime->GetStepThroughTrampolinePlan (*this, stop_other_threads);
671 }
672
Chris Lattner24943d22010-06-08 16:52:24 +0000673 if (thread_plan_sp.get() == NULL)
674 {
675 thread_plan_sp.reset(new ThreadPlanStepThrough (*this, stop_other_threads));
676 if (thread_plan_sp && !thread_plan_sp->ValidatePlan (NULL))
Greg Claytonf8e98a62010-07-23 15:37:46 +0000677 return NULL;
Chris Lattner24943d22010-06-08 16:52:24 +0000678 }
679 QueueThreadPlan (thread_plan_sp, abort_other_plans);
680 return thread_plan_sp.get();
681}
682
683ThreadPlan *
Chris Lattner24943d22010-06-08 16:52:24 +0000684Thread::QueueThreadPlanForCallFunction (bool abort_other_plans,
685 Address& function,
686 lldb::addr_t arg,
687 bool stop_other_threads,
688 bool discard_on_error)
689{
690 ThreadPlanSP thread_plan_sp (new ThreadPlanCallFunction (*this, function, arg, stop_other_threads, discard_on_error));
691 QueueThreadPlan (thread_plan_sp, abort_other_plans);
692 return thread_plan_sp.get();
693}
694
695ThreadPlan *
696Thread::QueueThreadPlanForCallFunction (bool abort_other_plans,
697 Address& function,
698 ValueList &args,
699 bool stop_other_threads,
700 bool discard_on_error)
701{
702 ThreadPlanSP thread_plan_sp (new ThreadPlanCallFunction (*this, function, args, stop_other_threads, discard_on_error));
703 QueueThreadPlan (thread_plan_sp, abort_other_plans);
704 return thread_plan_sp.get();
705}
706
707ThreadPlan *
708Thread::QueueThreadPlanForRunToAddress (bool abort_other_plans,
709 Address &target_addr,
710 bool stop_other_threads)
711{
712 ThreadPlanSP thread_plan_sp (new ThreadPlanRunToAddress (*this, target_addr, stop_other_threads));
713 QueueThreadPlan (thread_plan_sp, abort_other_plans);
714 return thread_plan_sp.get();
715}
716
717ThreadPlan *
718Thread::QueueThreadPlanForStepUntil (bool abort_other_plans,
719 lldb::addr_t *address_list,
720 size_t num_addresses,
721 bool stop_other_threads)
722{
723 ThreadPlanSP thread_plan_sp (new ThreadPlanStepUntil (*this, address_list, num_addresses, stop_other_threads));
724 QueueThreadPlan (thread_plan_sp, abort_other_plans);
725 return thread_plan_sp.get();
726
727}
728
729uint32_t
730Thread::GetIndexID () const
731{
732 return m_index_id;
733}
734
735void
736Thread::DumpThreadPlans (lldb_private::Stream *s) const
737{
738 uint32_t stack_size = m_plan_stack.size();
Greg Claytonf04d6612010-09-03 22:45:01 +0000739 int i;
740 s->Printf ("Plan Stack for thread #%u: tid = 0x%4.4x, stack_size = %d\n", GetIndexID(), GetID(), stack_size);
741 for (i = stack_size - 1; i >= 0; i--)
Chris Lattner24943d22010-06-08 16:52:24 +0000742 {
743 s->Printf ("Element %d: ", i);
744 s->IndentMore();
745 m_plan_stack[i]->GetDescription (s, eDescriptionLevelFull);
746 s->IndentLess();
747 s->EOL();
748 }
749
Chris Lattner24943d22010-06-08 16:52:24 +0000750 stack_size = m_completed_plan_stack.size();
751 s->Printf ("Completed Plan Stack: %d elements.\n", stack_size);
Greg Claytonf04d6612010-09-03 22:45:01 +0000752 for (i = stack_size - 1; i >= 0; i--)
Chris Lattner24943d22010-06-08 16:52:24 +0000753 {
754 s->Printf ("Element %d: ", i);
755 s->IndentMore();
756 m_completed_plan_stack[i]->GetDescription (s, eDescriptionLevelFull);
757 s->IndentLess();
758 s->EOL();
759 }
760
761 stack_size = m_discarded_plan_stack.size();
762 s->Printf ("Discarded Plan Stack: %d elements.\n", stack_size);
Greg Claytonf04d6612010-09-03 22:45:01 +0000763 for (int i = stack_size - 1; i >= 0; i--)
Chris Lattner24943d22010-06-08 16:52:24 +0000764 {
765 s->Printf ("Element %d: ", i);
766 s->IndentMore();
767 m_discarded_plan_stack[i]->GetDescription (s, eDescriptionLevelFull);
768 s->IndentLess();
769 s->EOL();
770 }
771
772}
773
774Target *
775Thread::CalculateTarget ()
776{
777 return m_process.CalculateTarget();
778}
779
780Process *
781Thread::CalculateProcess ()
782{
783 return &m_process;
784}
785
786Thread *
787Thread::CalculateThread ()
788{
789 return this;
790}
791
792StackFrame *
793Thread::CalculateStackFrame ()
794{
795 return NULL;
796}
797
798void
Greg Claytona830adb2010-10-04 01:05:56 +0000799Thread::CalculateExecutionContext (ExecutionContext &exe_ctx)
Chris Lattner24943d22010-06-08 16:52:24 +0000800{
Greg Claytona830adb2010-10-04 01:05:56 +0000801 m_process.CalculateExecutionContext (exe_ctx);
Chris Lattner24943d22010-06-08 16:52:24 +0000802 exe_ctx.thread = this;
803 exe_ctx.frame = NULL;
804}
805
Greg Clayton782b9cc2010-08-25 00:35:26 +0000806
807StackFrameList &
808Thread::GetStackFrameList ()
809{
Greg Claytonf40e3082010-08-26 02:28:22 +0000810 if (m_curr_frames_ap.get() == NULL)
Greg Clayton5205f0b2010-09-03 17:10:42 +0000811 m_curr_frames_ap.reset (new StackFrameList (*this, m_prev_frames_sp, true));
Greg Claytonf40e3082010-08-26 02:28:22 +0000812 return *m_curr_frames_ap;
Greg Clayton782b9cc2010-08-25 00:35:26 +0000813}
814
815
816
Jim Ingham71219082010-08-12 02:14:28 +0000817uint32_t
818Thread::GetStackFrameCount()
819{
Greg Clayton782b9cc2010-08-25 00:35:26 +0000820 return GetStackFrameList().GetNumFrames();
821}
Greg Clayton33ed1702010-08-24 00:45:41 +0000822
Greg Clayton33ed1702010-08-24 00:45:41 +0000823
Greg Clayton782b9cc2010-08-25 00:35:26 +0000824void
825Thread::ClearStackFrames ()
826{
Greg Clayton5205f0b2010-09-03 17:10:42 +0000827 if (m_curr_frames_ap.get() && m_curr_frames_ap->GetNumFrames (false) > 1)
828 m_prev_frames_sp.reset (m_curr_frames_ap.release());
829 else
830 m_curr_frames_ap.release();
831
832// StackFrameList::Merge (m_curr_frames_ap, m_prev_frames_sp);
833// assert (m_curr_frames_ap.get() == NULL);
Jim Ingham71219082010-08-12 02:14:28 +0000834}
835
836lldb::StackFrameSP
837Thread::GetStackFrameAtIndex (uint32_t idx)
838{
Greg Clayton72b71582010-09-02 21:44:10 +0000839 return GetStackFrameList().GetFrameAtIndex(idx);
Jim Ingham71219082010-08-12 02:14:28 +0000840}
841
Greg Claytonc12b6b42010-10-10 22:28:11 +0000842uint32_t
843Thread::GetSelectedFrameIndex ()
844{
845 return GetStackFrameList().GetSelectedFrameIndex();
846}
847
848
Chris Lattner24943d22010-06-08 16:52:24 +0000849lldb::StackFrameSP
Jim Inghamc8332952010-08-26 21:32:51 +0000850Thread::GetSelectedFrame ()
Chris Lattner24943d22010-06-08 16:52:24 +0000851{
Jim Inghamc8332952010-08-26 21:32:51 +0000852 return GetStackFrameAtIndex (GetStackFrameList().GetSelectedFrameIndex());
Chris Lattner24943d22010-06-08 16:52:24 +0000853}
854
855uint32_t
Jim Inghamc8332952010-08-26 21:32:51 +0000856Thread::SetSelectedFrame (lldb_private::StackFrame *frame)
Chris Lattner24943d22010-06-08 16:52:24 +0000857{
Jim Inghamc8332952010-08-26 21:32:51 +0000858 return GetStackFrameList().SetSelectedFrame(frame);
Chris Lattner24943d22010-06-08 16:52:24 +0000859}
860
861void
Jim Inghamc8332952010-08-26 21:32:51 +0000862Thread::SetSelectedFrameByIndex (uint32_t idx)
Chris Lattner24943d22010-06-08 16:52:24 +0000863{
Jim Inghamc8332952010-08-26 21:32:51 +0000864 GetStackFrameList().SetSelectedFrameByIndex(idx);
Chris Lattner24943d22010-06-08 16:52:24 +0000865}
866
867void
Greg Claytona830adb2010-10-04 01:05:56 +0000868Thread::DumpUsingSettingsFormat (Stream &strm, uint32_t frame_idx)
Chris Lattner24943d22010-06-08 16:52:24 +0000869{
Greg Claytona830adb2010-10-04 01:05:56 +0000870 ExecutionContext exe_ctx;
871 SymbolContext frame_sc;
872 CalculateExecutionContext (exe_ctx);
Chris Lattner24943d22010-06-08 16:52:24 +0000873
Greg Claytona830adb2010-10-04 01:05:56 +0000874 if (frame_idx != LLDB_INVALID_INDEX32)
Chris Lattner24943d22010-06-08 16:52:24 +0000875 {
Greg Claytona830adb2010-10-04 01:05:56 +0000876 StackFrameSP frame_sp(GetStackFrameAtIndex (frame_idx));
Chris Lattner24943d22010-06-08 16:52:24 +0000877 if (frame_sp)
878 {
Greg Claytona830adb2010-10-04 01:05:56 +0000879 exe_ctx.frame = frame_sp.get();
880 frame_sc = exe_ctx.frame->GetSymbolContext(eSymbolContextEverything);
Chris Lattner24943d22010-06-08 16:52:24 +0000881 }
882 }
883
Greg Claytona830adb2010-10-04 01:05:56 +0000884 const char *thread_format = GetProcess().GetTarget().GetDebugger().GetThreadFormat();
885 assert (thread_format);
886 const char *end = NULL;
887 Debugger::FormatPrompt (thread_format,
888 exe_ctx.frame ? &frame_sc : NULL,
889 &exe_ctx,
890 NULL,
891 strm,
892 &end);
Chris Lattner24943d22010-06-08 16:52:24 +0000893}
894
895lldb::ThreadSP
896Thread::GetSP ()
897{
898 return m_process.GetThreadList().GetThreadSPForThreadPtr(this);
899}
Jim Ingham20594b12010-09-08 03:14:33 +0000900
901lldb::UserSettingsControllerSP
902Thread::GetSettingsController (bool finish)
903{
904 static UserSettingsControllerSP g_settings_controller (new ThreadSettingsController);
905 static bool initialized = false;
906
907 if (!initialized)
908 {
909 initialized = UserSettingsController::InitializeSettingsController (g_settings_controller,
910 Thread::ThreadSettingsController::global_settings_table,
911 Thread::ThreadSettingsController::instance_settings_table);
912 }
913
914 if (finish)
915 {
916 UserSettingsController::FinalizeSettingsController (g_settings_controller);
917 g_settings_controller.reset();
918 initialized = false;
919 }
920
921 return g_settings_controller;
922}
923
Caroline Tice1ebef442010-09-27 00:30:10 +0000924void
925Thread::UpdateInstanceName ()
926{
927 StreamString sstr;
928 const char *name = GetName();
929
930 if (name && name[0] != '\0')
931 sstr.Printf ("%s", name);
932 else if ((GetIndexID() != 0) || (GetID() != 0))
933 sstr.Printf ("0x%4.4x", GetIndexID(), GetID());
934
935 if (sstr.GetSize() > 0)
936 Thread::GetSettingsController()->RenameInstanceSettings (GetInstanceName().AsCString(), sstr.GetData());
937}
938
Jim Ingham20594b12010-09-08 03:14:33 +0000939//--------------------------------------------------------------
940// class Thread::ThreadSettingsController
941//--------------------------------------------------------------
942
943Thread::ThreadSettingsController::ThreadSettingsController () :
944 UserSettingsController ("thread", Process::GetSettingsController())
945{
Caroline Tice004afcb2010-09-08 17:48:55 +0000946 m_default_settings.reset (new ThreadInstanceSettings (*this, false,
947 InstanceSettings::GetDefaultName().AsCString()));
Jim Ingham20594b12010-09-08 03:14:33 +0000948}
949
950Thread::ThreadSettingsController::~ThreadSettingsController ()
951{
952}
953
954lldb::InstanceSettingsSP
Greg Claytond0a5a232010-09-19 02:33:57 +0000955Thread::ThreadSettingsController::CreateInstanceSettings (const char *instance_name)
Jim Ingham20594b12010-09-08 03:14:33 +0000956{
Caroline Tice004afcb2010-09-08 17:48:55 +0000957 ThreadInstanceSettings *new_settings = new ThreadInstanceSettings (*(Thread::GetSettingsController().get()),
958 false, instance_name);
Jim Ingham20594b12010-09-08 03:14:33 +0000959 lldb::InstanceSettingsSP new_settings_sp (new_settings);
960 return new_settings_sp;
961}
962
963//--------------------------------------------------------------
964// class ThreadInstanceSettings
965//--------------------------------------------------------------
966
Caroline Tice004afcb2010-09-08 17:48:55 +0000967ThreadInstanceSettings::ThreadInstanceSettings (UserSettingsController &owner, bool live_instance, const char *name) :
Caroline Tice75b11a32010-09-16 19:05:55 +0000968 InstanceSettings (owner, (name == NULL ? InstanceSettings::InvalidName().AsCString() : name), live_instance),
Jim Ingham20594b12010-09-08 03:14:33 +0000969 m_avoid_regexp_ap ()
970{
Caroline Tice396704b2010-09-09 18:26:37 +0000971 // CopyInstanceSettings is a pure virtual function in InstanceSettings; it therefore cannot be called
972 // until the vtables for ThreadInstanceSettings are properly set up, i.e. AFTER all the initializers.
973 // For this reason it has to be called here, rather than in the initializer or in the parent constructor.
Caroline Tice75b11a32010-09-16 19:05:55 +0000974 // This is true for CreateInstanceName() too.
975
976 if (GetInstanceName() == InstanceSettings::InvalidName())
977 {
978 ChangeInstanceName (std::string (CreateInstanceName().AsCString()));
979 m_owner.RegisterInstanceSettings (this);
980 }
Caroline Tice396704b2010-09-09 18:26:37 +0000981
982 if (live_instance)
Jim Ingham20594b12010-09-08 03:14:33 +0000983 {
984 const lldb::InstanceSettingsSP &pending_settings = m_owner.FindPendingSettings (m_instance_name);
985 CopyInstanceSettings (pending_settings,false);
Caroline Tice396704b2010-09-09 18:26:37 +0000986 //m_owner.RemovePendingSettings (m_instance_name);
Jim Ingham20594b12010-09-08 03:14:33 +0000987 }
988}
989
990ThreadInstanceSettings::ThreadInstanceSettings (const ThreadInstanceSettings &rhs) :
991 InstanceSettings (*(Thread::GetSettingsController().get()), CreateInstanceName().AsCString()),
992 m_avoid_regexp_ap ()
993{
994 if (m_instance_name != InstanceSettings::GetDefaultName())
995 {
996 const lldb::InstanceSettingsSP &pending_settings = m_owner.FindPendingSettings (m_instance_name);
997 CopyInstanceSettings (pending_settings,false);
998 m_owner.RemovePendingSettings (m_instance_name);
999 }
1000 if (rhs.m_avoid_regexp_ap.get() != NULL)
1001 m_avoid_regexp_ap.reset(new RegularExpression(rhs.m_avoid_regexp_ap->GetText()));
1002}
1003
1004ThreadInstanceSettings::~ThreadInstanceSettings ()
1005{
1006}
1007
1008ThreadInstanceSettings&
1009ThreadInstanceSettings::operator= (const ThreadInstanceSettings &rhs)
1010{
1011 if (this != &rhs)
1012 {
1013 if (rhs.m_avoid_regexp_ap.get() != NULL)
1014 m_avoid_regexp_ap.reset(new RegularExpression(rhs.m_avoid_regexp_ap->GetText()));
1015 else
1016 m_avoid_regexp_ap.reset(NULL);
1017 }
1018
1019 return *this;
1020}
1021
1022
1023void
1024ThreadInstanceSettings::UpdateInstanceSettingsVariable (const ConstString &var_name,
1025 const char *index_value,
1026 const char *value,
1027 const ConstString &instance_name,
1028 const SettingEntry &entry,
1029 lldb::VarSetOperationType op,
1030 Error &err,
1031 bool pending)
1032{
1033 if (var_name == StepAvoidRegexpVarName())
1034 {
1035 std::string regexp_text;
1036 if (m_avoid_regexp_ap.get() != NULL)
1037 regexp_text.append (m_avoid_regexp_ap->GetText());
1038 UserSettingsController::UpdateStringVariable (op, regexp_text, value, err);
1039 if (regexp_text.empty())
1040 m_avoid_regexp_ap.reset();
1041 else
1042 {
1043 m_avoid_regexp_ap.reset(new RegularExpression(regexp_text.c_str()));
1044
1045 }
1046 }
1047}
1048
1049void
1050ThreadInstanceSettings::CopyInstanceSettings (const lldb::InstanceSettingsSP &new_settings,
1051 bool pending)
1052{
1053 if (new_settings.get() == NULL)
1054 return;
1055
1056 ThreadInstanceSettings *new_process_settings = (ThreadInstanceSettings *) new_settings.get();
1057 if (new_process_settings->GetSymbolsToAvoidRegexp() != NULL)
1058 m_avoid_regexp_ap.reset (new RegularExpression (new_process_settings->GetSymbolsToAvoidRegexp()->GetText()));
1059 else
1060 m_avoid_regexp_ap.reset ();
1061}
1062
Caroline Ticebcb5b452010-09-20 21:37:42 +00001063bool
Jim Ingham20594b12010-09-08 03:14:33 +00001064ThreadInstanceSettings::GetInstanceSettingsValue (const SettingEntry &entry,
Caroline Tice5bc8c972010-09-20 20:44:43 +00001065 const ConstString &var_name,
1066 StringList &value,
Caroline Ticebcb5b452010-09-20 21:37:42 +00001067 Error *err)
Jim Ingham20594b12010-09-08 03:14:33 +00001068{
1069 if (var_name == StepAvoidRegexpVarName())
1070 {
1071 if (m_avoid_regexp_ap.get() != NULL)
1072 {
1073 std::string regexp_text("\"");
1074 regexp_text.append(m_avoid_regexp_ap->GetText());
1075 regexp_text.append ("\"");
1076 value.AppendString (regexp_text.c_str());
1077 }
Caroline Tice5bc8c972010-09-20 20:44:43 +00001078
Jim Ingham20594b12010-09-08 03:14:33 +00001079 }
1080 else
Caroline Ticebcb5b452010-09-20 21:37:42 +00001081 {
1082 if (err)
1083 err->SetErrorStringWithFormat ("unrecognized variable name '%s'", var_name.AsCString());
1084 return false;
1085 }
1086 return true;
Jim Ingham20594b12010-09-08 03:14:33 +00001087}
1088
Jim Ingham20594b12010-09-08 03:14:33 +00001089const ConstString
1090ThreadInstanceSettings::CreateInstanceName ()
1091{
1092 static int instance_count = 1;
1093 StreamString sstr;
1094
1095 sstr.Printf ("thread_%d", instance_count);
1096 ++instance_count;
1097
1098 const ConstString ret_val (sstr.GetData());
1099 return ret_val;
1100}
1101
1102const ConstString &
1103ThreadInstanceSettings::StepAvoidRegexpVarName ()
1104{
1105 static ConstString run_args_var_name ("step-avoid-regexp");
1106
1107 return run_args_var_name;
1108}
1109
1110//--------------------------------------------------
1111// ThreadSettingsController Variable Tables
1112//--------------------------------------------------
1113
1114SettingEntry
1115Thread::ThreadSettingsController::global_settings_table[] =
1116{
1117 //{ "var-name", var-type , "default", enum-table, init'd, hidden, "help-text"},
1118 { NULL, eSetVarTypeNone, NULL, NULL, 0, 0, NULL }
1119};
1120
1121
1122SettingEntry
1123Thread::ThreadSettingsController::instance_settings_table[] =
1124{
1125 //{ "var-name", var-type, "default", enum-table, init'd, hidden, "help-text"},
1126 { "step-avoid-regexp", eSetVarTypeString, "", NULL, false, false, "A regular expression defining functions step-in won't stop in." },
1127 { NULL, eSetVarTypeNone, NULL, NULL, 0, 0, NULL }
1128};
1129
Jim Inghamccd584d2010-09-23 17:40:12 +00001130lldb::StackFrameSP
1131Thread::GetStackFrameSPForStackFramePtr (StackFrame *stack_frame_ptr)
1132{
1133 return GetStackFrameList().GetStackFrameSPForStackFramePtr (stack_frame_ptr);
1134}
Caroline Tice7826c882010-10-26 03:11:13 +00001135
1136const char *
1137Thread::StopReasonAsCString (lldb::StopReason reason)
1138{
1139 switch (reason)
1140 {
1141 case eStopReasonInvalid: return "invalid";
1142 case eStopReasonNone: return "none";
1143 case eStopReasonTrace: return "trace";
1144 case eStopReasonBreakpoint: return "breakpoint";
1145 case eStopReasonWatchpoint: return "watchpoint";
1146 case eStopReasonSignal: return "signal";
1147 case eStopReasonException: return "exception";
1148 case eStopReasonPlanComplete: return "plan complete";
1149 }
1150
1151
1152 static char unknown_state_string[64];
1153 snprintf(unknown_state_string, sizeof (unknown_state_string), "StopReason = %i", reason);
1154 return unknown_state_string;
1155}
1156
1157const char *
1158Thread::RunModeAsCString (lldb::RunMode mode)
1159{
1160 switch (mode)
1161 {
1162 case eOnlyThisThread: return "only this thread";
1163 case eAllThreads: return "all threads";
1164 case eOnlyDuringStepping: return "only during stepping";
1165 }
1166
1167 static char unknown_state_string[64];
1168 snprintf(unknown_state_string, sizeof (unknown_state_string), "RunMode = %i", mode);
1169 return unknown_state_string;
1170}