Jim Ingham | 745ac7a | 2010-11-11 19:26:09 +0000 | [diff] [blame^] | 1 | //===-- ThreadPlan.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/Target/ThreadPlan.h" |
| 11 | |
| 12 | // C Includes |
| 13 | // C++ Includes |
| 14 | // Other libraries and framework includes |
| 15 | // Project includes |
| 16 | #include "lldb/Core/Debugger.h" |
| 17 | #include "lldb/Core/Log.h" |
| 18 | #include "lldb/Core/State.h" |
| 19 | #include "lldb/Target/RegisterContext.h" |
| 20 | #include "lldb/Target/Thread.h" |
| 21 | #include "lldb/Target/Process.h" |
| 22 | #include "lldb/Target/Target.h" |
| 23 | |
| 24 | using namespace lldb; |
| 25 | using namespace lldb_private; |
| 26 | |
| 27 | ThreadPlanTracer::ThreadPlanTracer (Thread &thread, lldb::StreamSP &stream_sp) : |
| 28 | m_single_step(true), |
| 29 | m_enabled (false), |
| 30 | m_thread (thread), |
| 31 | m_stream_sp (stream_sp) |
| 32 | { |
| 33 | } |
| 34 | |
| 35 | ThreadPlanTracer::ThreadPlanTracer (Thread &thread) : |
| 36 | m_single_step(true), |
| 37 | m_enabled (false), |
| 38 | m_thread (thread), |
| 39 | m_stream_sp () |
| 40 | { |
| 41 | } |
| 42 | |
| 43 | Stream * |
| 44 | ThreadPlanTracer::GetLogStream () |
| 45 | { |
| 46 | |
| 47 | if (m_stream_sp.get()) |
| 48 | return m_stream_sp.get(); |
| 49 | else |
| 50 | return &(m_thread.GetProcess().GetTarget().GetDebugger().GetOutputStream()); |
| 51 | } |
| 52 | |
| 53 | void |
| 54 | ThreadPlanTracer::Log() |
| 55 | { |
| 56 | SymbolContext sc; |
| 57 | bool show_frame_index = false; |
| 58 | bool show_fullpaths = false; |
| 59 | |
| 60 | m_thread.GetStackFrameAtIndex(0)->Dump (GetLogStream(), show_frame_index, show_fullpaths); |
| 61 | GetLogStream()->Printf("\n"); |
| 62 | } |
| 63 | |
| 64 | bool |
| 65 | ThreadPlanTracer::TracerExplainsStop () |
| 66 | { |
| 67 | if (m_enabled && m_single_step) |
| 68 | { |
| 69 | lldb::StopInfoSP stop_info = m_thread.GetStopInfo(); |
| 70 | if (stop_info->GetStopReason() == eStopReasonTrace) |
| 71 | return true; |
| 72 | else |
| 73 | return false; |
| 74 | } |
| 75 | else |
| 76 | return false; |
| 77 | } |