Greg Clayton | f4b47e1 | 2010-08-04 01:40:35 +0000 | [diff] [blame] | 1 | //===-- StopInfo.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 | |
Daniel Malea | 93a6430 | 2012-12-05 00:20:57 +0000 | [diff] [blame] | 10 | #include "lldb/lldb-python.h" |
| 11 | |
Greg Clayton | f4b47e1 | 2010-08-04 01:40:35 +0000 | [diff] [blame] | 12 | #include "lldb/Target/StopInfo.h" |
| 13 | |
| 14 | // C Includes |
| 15 | // C++ Includes |
| 16 | #include <string> |
| 17 | |
| 18 | // Other libraries and framework includes |
| 19 | // Project includes |
| 20 | #include "lldb/Core/Log.h" |
Greg Clayton | 4e78f60 | 2010-11-18 18:52:36 +0000 | [diff] [blame] | 21 | #include "lldb/Breakpoint/Breakpoint.h" |
Greg Clayton | f4b47e1 | 2010-08-04 01:40:35 +0000 | [diff] [blame] | 22 | #include "lldb/Breakpoint/BreakpointLocation.h" |
| 23 | #include "lldb/Breakpoint/StoppointCallbackContext.h" |
Johnny Chen | 01a6786 | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 24 | #include "lldb/Breakpoint/Watchpoint.h" |
Jim Ingham | 4b53618 | 2011-08-09 02:12:22 +0000 | [diff] [blame] | 25 | #include "lldb/Core/Debugger.h" |
Greg Clayton | f4b47e1 | 2010-08-04 01:40:35 +0000 | [diff] [blame] | 26 | #include "lldb/Core/StreamString.h" |
Jim Ingham | 4b53618 | 2011-08-09 02:12:22 +0000 | [diff] [blame] | 27 | #include "lldb/Expression/ClangUserExpression.h" |
| 28 | #include "lldb/Target/Target.h" |
Greg Clayton | f4b47e1 | 2010-08-04 01:40:35 +0000 | [diff] [blame] | 29 | #include "lldb/Target/Thread.h" |
| 30 | #include "lldb/Target/ThreadPlan.h" |
| 31 | #include "lldb/Target/Process.h" |
| 32 | #include "lldb/Target/UnixSignals.h" |
| 33 | |
| 34 | using namespace lldb; |
| 35 | using namespace lldb_private; |
| 36 | |
| 37 | StopInfo::StopInfo (Thread &thread, uint64_t value) : |
| 38 | m_thread (thread), |
Greg Clayton | 1ac04c3 | 2012-02-21 00:09:25 +0000 | [diff] [blame] | 39 | m_stop_id (thread.GetProcess()->GetStopID()), |
| 40 | m_resume_id (thread.GetProcess()->GetResumeID()), |
Jim Ingham | 0161b49 | 2013-02-09 01:29:05 +0000 | [diff] [blame] | 41 | m_value (value), |
| 42 | m_override_set(false), |
| 43 | m_override_value(true) |
Greg Clayton | f4b47e1 | 2010-08-04 01:40:35 +0000 | [diff] [blame] | 44 | { |
| 45 | } |
| 46 | |
| 47 | bool |
| 48 | StopInfo::IsValid () const |
| 49 | { |
Greg Clayton | 1ac04c3 | 2012-02-21 00:09:25 +0000 | [diff] [blame] | 50 | return m_thread.GetProcess()->GetStopID() == m_stop_id; |
Greg Clayton | f4b47e1 | 2010-08-04 01:40:35 +0000 | [diff] [blame] | 51 | } |
| 52 | |
Jim Ingham | 7778703 | 2011-01-20 02:03:18 +0000 | [diff] [blame] | 53 | void |
| 54 | StopInfo::MakeStopInfoValid () |
| 55 | { |
Greg Clayton | 1ac04c3 | 2012-02-21 00:09:25 +0000 | [diff] [blame] | 56 | m_stop_id = m_thread.GetProcess()->GetStopID(); |
| 57 | m_resume_id = m_thread.GetProcess()->GetResumeID(); |
Jim Ingham | 7778703 | 2011-01-20 02:03:18 +0000 | [diff] [blame] | 58 | } |
| 59 | |
Jim Ingham | 0faa43f | 2011-11-08 03:00:11 +0000 | [diff] [blame] | 60 | bool |
| 61 | StopInfo::HasTargetRunSinceMe () |
Jim Ingham | 4b53618 | 2011-08-09 02:12:22 +0000 | [diff] [blame] | 62 | { |
Greg Clayton | 1ac04c3 | 2012-02-21 00:09:25 +0000 | [diff] [blame] | 63 | lldb::StateType ret_type = m_thread.GetProcess()->GetPrivateState(); |
Jim Ingham | 0faa43f | 2011-11-08 03:00:11 +0000 | [diff] [blame] | 64 | if (ret_type == eStateRunning) |
| 65 | { |
| 66 | return true; |
| 67 | } |
| 68 | else if (ret_type == eStateStopped) |
| 69 | { |
| 70 | // This is a little tricky. We want to count "run and stopped again before you could |
| 71 | // ask this question as a "TRUE" answer to HasTargetRunSinceMe. But we don't want to |
| 72 | // include any running of the target done for expressions. So we track both resumes, |
| 73 | // and resumes caused by expressions, and check if there are any resumes NOT caused |
| 74 | // by expressions. |
| 75 | |
Greg Clayton | 1ac04c3 | 2012-02-21 00:09:25 +0000 | [diff] [blame] | 76 | uint32_t curr_resume_id = m_thread.GetProcess()->GetResumeID(); |
| 77 | uint32_t last_user_expression_id = m_thread.GetProcess()->GetLastUserExpressionResumeID (); |
Jim Ingham | 0faa43f | 2011-11-08 03:00:11 +0000 | [diff] [blame] | 78 | if (curr_resume_id == m_resume_id) |
| 79 | { |
| 80 | return false; |
| 81 | } |
| 82 | else if (curr_resume_id > last_user_expression_id) |
| 83 | { |
| 84 | return true; |
| 85 | } |
| 86 | } |
| 87 | return false; |
Jim Ingham | 4b53618 | 2011-08-09 02:12:22 +0000 | [diff] [blame] | 88 | } |
| 89 | |
Greg Clayton | f4b47e1 | 2010-08-04 01:40:35 +0000 | [diff] [blame] | 90 | //---------------------------------------------------------------------- |
| 91 | // StopInfoBreakpoint |
| 92 | //---------------------------------------------------------------------- |
| 93 | |
Jim Ingham | 4b53618 | 2011-08-09 02:12:22 +0000 | [diff] [blame] | 94 | namespace lldb_private |
| 95 | { |
Greg Clayton | f4b47e1 | 2010-08-04 01:40:35 +0000 | [diff] [blame] | 96 | class StopInfoBreakpoint : public StopInfo |
| 97 | { |
| 98 | public: |
| 99 | |
| 100 | StopInfoBreakpoint (Thread &thread, break_id_t break_id) : |
| 101 | StopInfo (thread, break_id), |
| 102 | m_description(), |
| 103 | m_should_stop (false), |
Jim Ingham | 0f16e73 | 2011-02-08 05:20:59 +0000 | [diff] [blame] | 104 | m_should_stop_is_valid (false), |
Jim Ingham | 52c7d20 | 2011-10-28 01:12:19 +0000 | [diff] [blame] | 105 | m_should_perform_action (true), |
Jim Ingham | ca36cd1 | 2012-10-05 19:16:31 +0000 | [diff] [blame] | 106 | m_address (LLDB_INVALID_ADDRESS), |
| 107 | m_break_id(LLDB_INVALID_BREAK_ID), |
| 108 | m_was_one_shot (false) |
Greg Clayton | f4b47e1 | 2010-08-04 01:40:35 +0000 | [diff] [blame] | 109 | { |
Jim Ingham | ca36cd1 | 2012-10-05 19:16:31 +0000 | [diff] [blame] | 110 | StoreBPInfo(); |
Greg Clayton | f4b47e1 | 2010-08-04 01:40:35 +0000 | [diff] [blame] | 111 | } |
| 112 | |
Jim Ingham | 36f3b36 | 2010-10-14 23:45:03 +0000 | [diff] [blame] | 113 | StopInfoBreakpoint (Thread &thread, break_id_t break_id, bool should_stop) : |
| 114 | StopInfo (thread, break_id), |
| 115 | m_description(), |
| 116 | m_should_stop (should_stop), |
Jim Ingham | 0f16e73 | 2011-02-08 05:20:59 +0000 | [diff] [blame] | 117 | m_should_stop_is_valid (true), |
Jim Ingham | 52c7d20 | 2011-10-28 01:12:19 +0000 | [diff] [blame] | 118 | m_should_perform_action (true), |
Jim Ingham | ca36cd1 | 2012-10-05 19:16:31 +0000 | [diff] [blame] | 119 | m_address (LLDB_INVALID_ADDRESS), |
| 120 | m_break_id(LLDB_INVALID_BREAK_ID), |
| 121 | m_was_one_shot (false) |
| 122 | { |
| 123 | StoreBPInfo(); |
| 124 | } |
| 125 | |
| 126 | void StoreBPInfo () |
Jim Ingham | 36f3b36 | 2010-10-14 23:45:03 +0000 | [diff] [blame] | 127 | { |
Greg Clayton | 1ac04c3 | 2012-02-21 00:09:25 +0000 | [diff] [blame] | 128 | BreakpointSiteSP bp_site_sp (m_thread.GetProcess()->GetBreakpointSiteList().FindByID (m_value)); |
Jim Ingham | 52c7d20 | 2011-10-28 01:12:19 +0000 | [diff] [blame] | 129 | if (bp_site_sp) |
| 130 | { |
Jim Ingham | ca36cd1 | 2012-10-05 19:16:31 +0000 | [diff] [blame] | 131 | if (bp_site_sp->GetNumberOfOwners() == 1) |
| 132 | { |
| 133 | BreakpointLocationSP bp_loc_sp = bp_site_sp->GetOwnerAtIndex(0); |
| 134 | if (bp_loc_sp) |
| 135 | { |
| 136 | m_break_id = bp_loc_sp->GetBreakpoint().GetID(); |
| 137 | m_was_one_shot = bp_loc_sp->GetBreakpoint().IsOneShot(); |
| 138 | } |
| 139 | } |
| 140 | m_address = bp_site_sp->GetLoadAddress(); |
Jim Ingham | 52c7d20 | 2011-10-28 01:12:19 +0000 | [diff] [blame] | 141 | } |
Jim Ingham | 36f3b36 | 2010-10-14 23:45:03 +0000 | [diff] [blame] | 142 | } |
| 143 | |
Greg Clayton | f4b47e1 | 2010-08-04 01:40:35 +0000 | [diff] [blame] | 144 | virtual ~StopInfoBreakpoint () |
| 145 | { |
| 146 | } |
| 147 | |
| 148 | virtual StopReason |
| 149 | GetStopReason () const |
| 150 | { |
| 151 | return eStopReasonBreakpoint; |
| 152 | } |
| 153 | |
| 154 | virtual bool |
Jim Ingham | 6d66ce6 | 2012-04-20 21:16:56 +0000 | [diff] [blame] | 155 | ShouldStopSynchronous (Event *event_ptr) |
Greg Clayton | f4b47e1 | 2010-08-04 01:40:35 +0000 | [diff] [blame] | 156 | { |
| 157 | if (!m_should_stop_is_valid) |
| 158 | { |
| 159 | // Only check once if we should stop at a breakpoint |
Greg Clayton | 1ac04c3 | 2012-02-21 00:09:25 +0000 | [diff] [blame] | 160 | BreakpointSiteSP bp_site_sp (m_thread.GetProcess()->GetBreakpointSiteList().FindByID (m_value)); |
Greg Clayton | f4b47e1 | 2010-08-04 01:40:35 +0000 | [diff] [blame] | 161 | if (bp_site_sp) |
| 162 | { |
Greg Clayton | 1ac04c3 | 2012-02-21 00:09:25 +0000 | [diff] [blame] | 163 | ExecutionContext exe_ctx (m_thread.GetStackFrameAtIndex(0)); |
| 164 | StoppointCallbackContext context (event_ptr, exe_ctx, true); |
Greg Clayton | f4b47e1 | 2010-08-04 01:40:35 +0000 | [diff] [blame] | 165 | m_should_stop = bp_site_sp->ShouldStop (&context); |
| 166 | } |
| 167 | else |
| 168 | { |
Greg Clayton | 5160ce5 | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 169 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS)); |
Greg Clayton | f4b47e1 | 2010-08-04 01:40:35 +0000 | [diff] [blame] | 170 | |
| 171 | if (log) |
Daniel Malea | d01b295 | 2012-11-29 21:49:15 +0000 | [diff] [blame] | 172 | log->Printf ("Process::%s could not find breakpoint site id: %" PRId64 "...", __FUNCTION__, m_value); |
Greg Clayton | f4b47e1 | 2010-08-04 01:40:35 +0000 | [diff] [blame] | 173 | |
| 174 | m_should_stop = true; |
| 175 | } |
| 176 | m_should_stop_is_valid = true; |
| 177 | } |
| 178 | return m_should_stop; |
| 179 | } |
Jim Ingham | 3ebcf7f | 2010-08-10 00:59:59 +0000 | [diff] [blame] | 180 | |
Jim Ingham | f57b435 | 2012-11-10 02:08:14 +0000 | [diff] [blame] | 181 | virtual bool |
| 182 | ShouldNotify (Event *event_ptr) |
| 183 | { |
| 184 | BreakpointSiteSP bp_site_sp (m_thread.GetProcess()->GetBreakpointSiteList().FindByID (m_value)); |
| 185 | if (bp_site_sp) |
| 186 | { |
| 187 | bool all_internal = true; |
| 188 | |
| 189 | for (uint32_t i = 0; i < bp_site_sp->GetNumberOfOwners(); i++) |
| 190 | { |
| 191 | if (!bp_site_sp->GetOwnerAtIndex(i)->GetBreakpoint().IsInternal()) |
| 192 | { |
| 193 | all_internal = false; |
| 194 | break; |
| 195 | } |
| 196 | } |
| 197 | return all_internal == false; |
| 198 | } |
| 199 | return true; |
| 200 | } |
| 201 | |
| 202 | virtual const char * |
| 203 | GetDescription () |
| 204 | { |
| 205 | if (m_description.empty()) |
| 206 | { |
| 207 | BreakpointSiteSP bp_site_sp (m_thread.GetProcess()->GetBreakpointSiteList().FindByID (m_value)); |
| 208 | if (bp_site_sp) |
| 209 | { |
| 210 | StreamString strm; |
Jim Ingham | 2995077 | 2013-01-26 02:19:28 +0000 | [diff] [blame] | 211 | // If we have just hit an internal breakpoint, and it has a kind description, print that instead of the |
| 212 | // full breakpoint printing: |
| 213 | if (bp_site_sp->IsInternal()) |
| 214 | { |
| 215 | size_t num_owners = bp_site_sp->GetNumberOfOwners(); |
| 216 | for (size_t idx = 0; idx < num_owners; idx++) |
| 217 | { |
| 218 | const char *kind = bp_site_sp->GetOwnerAtIndex(idx)->GetBreakpoint().GetBreakpointKind(); |
| 219 | if (kind != NULL) |
| 220 | { |
| 221 | m_description.assign (kind); |
| 222 | return kind; |
| 223 | } |
| 224 | } |
| 225 | } |
| 226 | |
Jim Ingham | f57b435 | 2012-11-10 02:08:14 +0000 | [diff] [blame] | 227 | strm.Printf("breakpoint "); |
| 228 | bp_site_sp->GetDescription(&strm, eDescriptionLevelBrief); |
| 229 | m_description.swap (strm.GetString()); |
| 230 | } |
| 231 | else |
| 232 | { |
| 233 | StreamString strm; |
| 234 | if (m_break_id != LLDB_INVALID_BREAK_ID) |
| 235 | { |
Jim Ingham | 0ac5709 | 2013-02-14 03:05:42 +0000 | [diff] [blame] | 236 | BreakpointSP break_sp = m_thread.GetProcess()->GetTarget().GetBreakpointByID(m_break_id); |
| 237 | if (break_sp) |
| 238 | { |
| 239 | if (break_sp->IsInternal()) |
| 240 | { |
| 241 | const char *kind = break_sp->GetBreakpointKind(); |
| 242 | if (kind) |
| 243 | strm.Printf ("internal %s breakpoint(%d).", kind, m_break_id); |
| 244 | else |
| 245 | strm.Printf ("internal breakpoint(%d).", m_break_id); |
| 246 | } |
| 247 | else |
| 248 | { |
| 249 | strm.Printf ("breakpoint %d.", m_break_id); |
| 250 | } |
| 251 | } |
Jim Ingham | f57b435 | 2012-11-10 02:08:14 +0000 | [diff] [blame] | 252 | else |
Jim Ingham | 0ac5709 | 2013-02-14 03:05:42 +0000 | [diff] [blame] | 253 | { |
| 254 | if (m_was_one_shot) |
| 255 | strm.Printf ("one-shot breakpoint %d", m_break_id); |
| 256 | else |
| 257 | strm.Printf ("breakpoint %d which has been deleted.", m_break_id); |
| 258 | } |
Jim Ingham | f57b435 | 2012-11-10 02:08:14 +0000 | [diff] [blame] | 259 | } |
| 260 | else if (m_address == LLDB_INVALID_ADDRESS) |
Daniel Malea | d01b295 | 2012-11-29 21:49:15 +0000 | [diff] [blame] | 261 | strm.Printf("breakpoint site %" PRIi64 " which has been deleted - unknown address", m_value); |
Jim Ingham | f57b435 | 2012-11-10 02:08:14 +0000 | [diff] [blame] | 262 | else |
Daniel Malea | d01b295 | 2012-11-29 21:49:15 +0000 | [diff] [blame] | 263 | strm.Printf("breakpoint site %" PRIi64 " which has been deleted - was at 0x%" PRIx64, m_value, m_address); |
Jim Ingham | f57b435 | 2012-11-10 02:08:14 +0000 | [diff] [blame] | 264 | |
| 265 | m_description.swap (strm.GetString()); |
| 266 | } |
| 267 | } |
| 268 | return m_description.c_str(); |
| 269 | } |
| 270 | |
| 271 | protected: |
Jim Ingham | 6d66ce6 | 2012-04-20 21:16:56 +0000 | [diff] [blame] | 272 | bool |
| 273 | ShouldStop (Event *event_ptr) |
| 274 | { |
| 275 | // This just reports the work done by PerformAction or the synchronous stop. It should |
| 276 | // only ever get called after they have had a chance to run. |
| 277 | assert (m_should_stop_is_valid); |
| 278 | return m_should_stop; |
| 279 | } |
| 280 | |
Jim Ingham | 3ebcf7f | 2010-08-10 00:59:59 +0000 | [diff] [blame] | 281 | virtual void |
| 282 | PerformAction (Event *event_ptr) |
| 283 | { |
Jim Ingham | 0f16e73 | 2011-02-08 05:20:59 +0000 | [diff] [blame] | 284 | if (!m_should_perform_action) |
| 285 | return; |
| 286 | m_should_perform_action = false; |
| 287 | |
Greg Clayton | 5160ce5 | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 288 | Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS); |
Jim Ingham | 4b53618 | 2011-08-09 02:12:22 +0000 | [diff] [blame] | 289 | |
Jim Ingham | 5cb9a18 | 2013-03-28 00:13:30 +0000 | [diff] [blame] | 290 | if (!m_thread.IsValid()) |
| 291 | { |
| 292 | // This shouldn't ever happen, but just in case, don't do more harm. |
| 293 | log->Printf ("PerformAction got called with an invalid thread."); |
Jim Ingham | 8af3b9c | 2013-03-29 01:18:12 +0000 | [diff] [blame] | 294 | m_should_stop = true; |
| 295 | m_should_stop_is_valid = true; |
Jim Ingham | 5cb9a18 | 2013-03-28 00:13:30 +0000 | [diff] [blame] | 296 | return; |
| 297 | } |
| 298 | |
Greg Clayton | 1ac04c3 | 2012-02-21 00:09:25 +0000 | [diff] [blame] | 299 | BreakpointSiteSP bp_site_sp (m_thread.GetProcess()->GetBreakpointSiteList().FindByID (m_value)); |
Jim Ingham | 79ea1d8 | 2011-12-09 04:17:31 +0000 | [diff] [blame] | 300 | |
Jim Ingham | 3ebcf7f | 2010-08-10 00:59:59 +0000 | [diff] [blame] | 301 | if (bp_site_sp) |
| 302 | { |
| 303 | size_t num_owners = bp_site_sp->GetNumberOfOwners(); |
Jim Ingham | 79ea1d8 | 2011-12-09 04:17:31 +0000 | [diff] [blame] | 304 | |
| 305 | if (num_owners == 0) |
Jim Ingham | 3ebcf7f | 2010-08-10 00:59:59 +0000 | [diff] [blame] | 306 | { |
Jim Ingham | 79ea1d8 | 2011-12-09 04:17:31 +0000 | [diff] [blame] | 307 | m_should_stop = true; |
| 308 | } |
| 309 | else |
| 310 | { |
| 311 | // We go through each location, and test first its condition. If the condition says to stop, |
| 312 | // then we run the callback for that location. If that callback says to stop as well, then |
| 313 | // we set m_should_stop to true; we are going to stop. |
| 314 | // But we still want to give all the breakpoints whose conditions say we are going to stop a |
| 315 | // chance to run their callbacks. |
| 316 | // Of course if any callback restarts the target by putting "continue" in the callback, then |
| 317 | // we're going to restart, without running the rest of the callbacks. And in this case we will |
| 318 | // end up not stopping even if another location said we should stop. But that's better than not |
| 319 | // running all the callbacks. |
| 320 | |
| 321 | m_should_stop = false; |
| 322 | |
Greg Clayton | 1ac04c3 | 2012-02-21 00:09:25 +0000 | [diff] [blame] | 323 | ExecutionContext exe_ctx (m_thread.GetStackFrameAtIndex(0)); |
Jim Ingham | 184e981 | 2013-01-15 02:47:48 +0000 | [diff] [blame] | 324 | Process *process = exe_ctx.GetProcessPtr(); |
| 325 | if (process->GetModIDRef().IsLastResumeForUserExpression()) |
| 326 | { |
| 327 | // If we are in the middle of evaluating an expression, don't run asynchronous breakpoint commands or |
| 328 | // expressions. That could lead to infinite recursion if the command or condition re-calls the function |
| 329 | // with this breakpoint. |
| 330 | // TODO: We can keep a list of the breakpoints we've seen while running expressions in the nested |
| 331 | // PerformAction calls that can arise when the action runs a function that hits another breakpoint, |
| 332 | // and only stop running commands when we see the same breakpoint hit a second time. |
| 333 | |
| 334 | m_should_stop_is_valid = true; |
| 335 | if (log) |
| 336 | log->Printf ("StopInfoBreakpoint::PerformAction - Hit a breakpoint while running an expression," |
| 337 | " not running commands to avoid recursion."); |
| 338 | bool ignoring_breakpoints = process->GetIgnoreBreakpointsInExpressions(); |
| 339 | if (ignoring_breakpoints) |
| 340 | { |
| 341 | m_should_stop = false; |
| 342 | // Internal breakpoints will always stop. |
| 343 | for (size_t j = 0; j < num_owners; j++) |
| 344 | { |
| 345 | lldb::BreakpointLocationSP bp_loc_sp = bp_site_sp->GetOwnerAtIndex(j); |
| 346 | if (bp_loc_sp->GetBreakpoint().IsInternal()) |
| 347 | { |
| 348 | m_should_stop = true; |
| 349 | break; |
| 350 | } |
| 351 | } |
| 352 | } |
| 353 | else |
| 354 | { |
| 355 | m_should_stop = true; |
| 356 | } |
| 357 | if (log) |
| 358 | log->Printf ("StopInfoBreakpoint::PerformAction - in expression, continuing: %s.", |
| 359 | m_should_stop ? "true" : "false"); |
| 360 | process->GetTarget().GetDebugger().GetAsyncOutputStream()->Printf("Warning: hit breakpoint while " |
| 361 | "running function, skipping commands and conditions to prevent recursion."); |
| 362 | return; |
| 363 | } |
| 364 | |
Greg Clayton | 1ac04c3 | 2012-02-21 00:09:25 +0000 | [diff] [blame] | 365 | StoppointCallbackContext context (event_ptr, exe_ctx, false); |
Jim Ingham | dbd3c4d | 2013-04-11 22:53:47 +0000 | [diff] [blame] | 366 | |
| 367 | // Let's copy the breakpoint locations out of the site and store them in a local list. That way if |
| 368 | // one of the breakpoint actions changes the site, then we won't be operating on a bad list. |
| 369 | |
| 370 | BreakpointLocationCollection site_locations; |
| 371 | for (size_t j = 0; j < num_owners; j++) |
| 372 | site_locations.Add(bp_site_sp->GetOwnerAtIndex(j)); |
Jim Ingham | 4b53618 | 2011-08-09 02:12:22 +0000 | [diff] [blame] | 373 | |
Jim Ingham | 4b53618 | 2011-08-09 02:12:22 +0000 | [diff] [blame] | 374 | for (size_t j = 0; j < num_owners; j++) |
| 375 | { |
Jim Ingham | dbd3c4d | 2013-04-11 22:53:47 +0000 | [diff] [blame] | 376 | lldb::BreakpointLocationSP bp_loc_sp = site_locations.GetByIndex(j); |
| 377 | |
| 378 | // If another action disabled this breakpoint or its location, then don't run the actions. |
| 379 | if (!bp_loc_sp->IsEnabled() || !bp_loc_sp->GetBreakpoint().IsEnabled()) |
| 380 | continue; |
| 381 | |
| 382 | // The breakpoint site may have many locations associated with it, not all of them valid for |
| 383 | // this thread. Skip the ones that aren't: |
| 384 | if (!bp_loc_sp->ValidForThisThread(&m_thread)) |
| 385 | continue; |
Jim Ingham | 79ea1d8 | 2011-12-09 04:17:31 +0000 | [diff] [blame] | 386 | |
| 387 | // First run the condition for the breakpoint. If that says we should stop, then we'll run |
Jim Ingham | dbd3c4d | 2013-04-11 22:53:47 +0000 | [diff] [blame] | 388 | // the callback for the breakpoint. If the callback says we shouldn't stop that will win. |
Jim Ingham | 79ea1d8 | 2011-12-09 04:17:31 +0000 | [diff] [blame] | 389 | |
| 390 | bool condition_says_stop = true; |
Jim Ingham | 4b53618 | 2011-08-09 02:12:22 +0000 | [diff] [blame] | 391 | if (bp_loc_sp->GetConditionText() != NULL) |
| 392 | { |
| 393 | // We need to make sure the user sees any parse errors in their condition, so we'll hook the |
| 394 | // constructor errors up to the debugger's Async I/O. |
| 395 | |
Jim Ingham | 4b53618 | 2011-08-09 02:12:22 +0000 | [diff] [blame] | 396 | ValueObjectSP result_valobj_sp; |
| 397 | |
| 398 | ExecutionResults result_code; |
| 399 | ValueObjectSP result_value_sp; |
Jim Ingham | 184e981 | 2013-01-15 02:47:48 +0000 | [diff] [blame] | 400 | const bool unwind_on_error = true; |
| 401 | const bool ignore_breakpoints = true; |
Jim Ingham | 4b53618 | 2011-08-09 02:12:22 +0000 | [diff] [blame] | 402 | Error error; |
Greg Clayton | 1ac04c3 | 2012-02-21 00:09:25 +0000 | [diff] [blame] | 403 | result_code = ClangUserExpression::EvaluateWithError (exe_ctx, |
Jim Ingham | 6d66ce6 | 2012-04-20 21:16:56 +0000 | [diff] [blame] | 404 | eExecutionPolicyOnlyWhenNeeded, |
Sean Callanan | c7b6506 | 2011-11-07 23:35:40 +0000 | [diff] [blame] | 405 | lldb::eLanguageTypeUnknown, |
Sean Callanan | 20bb3aa | 2011-12-21 22:22:58 +0000 | [diff] [blame] | 406 | ClangUserExpression::eResultTypeAny, |
Jim Ingham | 184e981 | 2013-01-15 02:47:48 +0000 | [diff] [blame] | 407 | unwind_on_error, |
| 408 | ignore_breakpoints, |
Sean Callanan | 3bfdaa2 | 2011-09-15 02:13:07 +0000 | [diff] [blame] | 409 | bp_loc_sp->GetConditionText(), |
| 410 | NULL, |
| 411 | result_value_sp, |
Greg Clayton | 26ab83d | 2012-10-31 20:49:04 +0000 | [diff] [blame] | 412 | error, |
| 413 | true, |
| 414 | ClangUserExpression::kDefaultTimeout); |
Jim Ingham | 4b53618 | 2011-08-09 02:12:22 +0000 | [diff] [blame] | 415 | if (result_code == eExecutionCompleted) |
| 416 | { |
| 417 | if (result_value_sp) |
| 418 | { |
| 419 | Scalar scalar_value; |
| 420 | if (result_value_sp->ResolveValue (scalar_value)) |
| 421 | { |
| 422 | if (scalar_value.ULongLong(1) == 0) |
Jim Ingham | 79ea1d8 | 2011-12-09 04:17:31 +0000 | [diff] [blame] | 423 | condition_says_stop = false; |
Jim Ingham | 4b53618 | 2011-08-09 02:12:22 +0000 | [diff] [blame] | 424 | else |
Jim Ingham | 79ea1d8 | 2011-12-09 04:17:31 +0000 | [diff] [blame] | 425 | condition_says_stop = true; |
Jim Ingham | 4b53618 | 2011-08-09 02:12:22 +0000 | [diff] [blame] | 426 | if (log) |
| 427 | log->Printf("Condition successfully evaluated, result is %s.\n", |
| 428 | m_should_stop ? "true" : "false"); |
| 429 | } |
| 430 | else |
| 431 | { |
Jim Ingham | 79ea1d8 | 2011-12-09 04:17:31 +0000 | [diff] [blame] | 432 | condition_says_stop = true; |
Jim Ingham | 4b53618 | 2011-08-09 02:12:22 +0000 | [diff] [blame] | 433 | if (log) |
| 434 | log->Printf("Failed to get an integer result from the expression."); |
| 435 | } |
| 436 | } |
| 437 | } |
| 438 | else |
| 439 | { |
Greg Clayton | 1ac04c3 | 2012-02-21 00:09:25 +0000 | [diff] [blame] | 440 | Debugger &debugger = exe_ctx.GetTargetRef().GetDebugger(); |
Jim Ingham | 4b53618 | 2011-08-09 02:12:22 +0000 | [diff] [blame] | 441 | StreamSP error_sp = debugger.GetAsyncErrorStream (); |
| 442 | error_sp->Printf ("Stopped due to an error evaluating condition of breakpoint "); |
| 443 | bp_loc_sp->GetDescription (error_sp.get(), eDescriptionLevelBrief); |
| 444 | error_sp->Printf (": \"%s\"", |
| 445 | bp_loc_sp->GetConditionText()); |
| 446 | error_sp->EOL(); |
| 447 | const char *err_str = error.AsCString("<Unknown Error>"); |
| 448 | if (log) |
| 449 | log->Printf("Error evaluating condition: \"%s\"\n", err_str); |
| 450 | |
| 451 | error_sp->PutCString (err_str); |
| 452 | error_sp->EOL(); |
| 453 | error_sp->Flush(); |
| 454 | // If the condition fails to be parsed or run, we should stop. |
Jim Ingham | 79ea1d8 | 2011-12-09 04:17:31 +0000 | [diff] [blame] | 455 | condition_says_stop = true; |
Jim Ingham | 4b53618 | 2011-08-09 02:12:22 +0000 | [diff] [blame] | 456 | } |
| 457 | } |
| 458 | |
Jim Ingham | 79ea1d8 | 2011-12-09 04:17:31 +0000 | [diff] [blame] | 459 | // If this location's condition says we should aren't going to stop, |
| 460 | // then don't run the callback for this location. |
| 461 | if (!condition_says_stop) |
| 462 | continue; |
| 463 | |
| 464 | bool callback_says_stop; |
| 465 | |
| 466 | // FIXME: For now the callbacks have to run in async mode - the first time we restart we need |
| 467 | // to get out of there. So set it here. |
| 468 | // When we figure out how to nest breakpoint hits then this will change. |
| 469 | |
Greg Clayton | 1ac04c3 | 2012-02-21 00:09:25 +0000 | [diff] [blame] | 470 | Debugger &debugger = m_thread.CalculateTarget()->GetDebugger(); |
Jim Ingham | 79ea1d8 | 2011-12-09 04:17:31 +0000 | [diff] [blame] | 471 | bool old_async = debugger.GetAsyncExecution(); |
| 472 | debugger.SetAsyncExecution (true); |
| 473 | |
| 474 | callback_says_stop = bp_loc_sp->InvokeCallback (&context); |
| 475 | |
| 476 | debugger.SetAsyncExecution (old_async); |
| 477 | |
| 478 | if (callback_says_stop) |
| 479 | m_should_stop = true; |
Jim Ingham | ca36cd1 | 2012-10-05 19:16:31 +0000 | [diff] [blame] | 480 | |
| 481 | // If we are going to stop for this breakpoint, then remove the breakpoint. |
| 482 | if (callback_says_stop && bp_loc_sp && bp_loc_sp->GetBreakpoint().IsOneShot()) |
| 483 | { |
| 484 | m_thread.GetProcess()->GetTarget().RemoveBreakpointByID (bp_loc_sp->GetBreakpoint().GetID()); |
| 485 | } |
Jim Ingham | 79ea1d8 | 2011-12-09 04:17:31 +0000 | [diff] [blame] | 486 | |
| 487 | // Also make sure that the callback hasn't continued the target. |
| 488 | // If it did, when we'll set m_should_start to false and get out of here. |
| 489 | if (HasTargetRunSinceMe ()) |
| 490 | { |
| 491 | m_should_stop = false; |
Jim Ingham | 4b53618 | 2011-08-09 02:12:22 +0000 | [diff] [blame] | 492 | break; |
Jim Ingham | 79ea1d8 | 2011-12-09 04:17:31 +0000 | [diff] [blame] | 493 | } |
Jim Ingham | 4b53618 | 2011-08-09 02:12:22 +0000 | [diff] [blame] | 494 | } |
Jim Ingham | 3ebcf7f | 2010-08-10 00:59:59 +0000 | [diff] [blame] | 495 | } |
Jim Ingham | 79ea1d8 | 2011-12-09 04:17:31 +0000 | [diff] [blame] | 496 | // We've figured out what this stop wants to do, so mark it as valid so we don't compute it again. |
| 497 | m_should_stop_is_valid = true; |
| 498 | |
Jim Ingham | 3ebcf7f | 2010-08-10 00:59:59 +0000 | [diff] [blame] | 499 | } |
| 500 | else |
| 501 | { |
Jim Ingham | 79ea1d8 | 2011-12-09 04:17:31 +0000 | [diff] [blame] | 502 | m_should_stop = true; |
| 503 | m_should_stop_is_valid = true; |
Greg Clayton | 5160ce5 | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 504 | Log * log_process(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS)); |
Jim Ingham | 3ebcf7f | 2010-08-10 00:59:59 +0000 | [diff] [blame] | 505 | |
Jason Molenda | ccd41e5 | 2012-10-04 22:47:07 +0000 | [diff] [blame] | 506 | if (log_process) |
Daniel Malea | d01b295 | 2012-11-29 21:49:15 +0000 | [diff] [blame] | 507 | log_process->Printf ("Process::%s could not find breakpoint site id: %" PRId64 "...", __FUNCTION__, m_value); |
Jim Ingham | 3ebcf7f | 2010-08-10 00:59:59 +0000 | [diff] [blame] | 508 | } |
Jim Ingham | 4b53618 | 2011-08-09 02:12:22 +0000 | [diff] [blame] | 509 | if (log) |
| 510 | log->Printf ("Process::%s returning from action with m_should_stop: %d.", __FUNCTION__, m_should_stop); |
Jim Ingham | 3ebcf7f | 2010-08-10 00:59:59 +0000 | [diff] [blame] | 511 | } |
Greg Clayton | f4b47e1 | 2010-08-04 01:40:35 +0000 | [diff] [blame] | 512 | |
| 513 | private: |
| 514 | std::string m_description; |
| 515 | bool m_should_stop; |
| 516 | bool m_should_stop_is_valid; |
Jim Ingham | 0f16e73 | 2011-02-08 05:20:59 +0000 | [diff] [blame] | 517 | bool m_should_perform_action; // Since we are trying to preserve the "state" of the system even if we run functions |
| 518 | // etc. behind the users backs, we need to make sure we only REALLY perform the action once. |
Jim Ingham | 52c7d20 | 2011-10-28 01:12:19 +0000 | [diff] [blame] | 519 | lldb::addr_t m_address; // We use this to capture the breakpoint site address when we create the StopInfo, |
| 520 | // in case somebody deletes it between the time the StopInfo is made and the |
| 521 | // description is asked for. |
Jim Ingham | ca36cd1 | 2012-10-05 19:16:31 +0000 | [diff] [blame] | 522 | lldb::break_id_t m_break_id; |
| 523 | bool m_was_one_shot; |
Greg Clayton | f4b47e1 | 2010-08-04 01:40:35 +0000 | [diff] [blame] | 524 | }; |
| 525 | |
| 526 | |
| 527 | //---------------------------------------------------------------------- |
| 528 | // StopInfoWatchpoint |
| 529 | //---------------------------------------------------------------------- |
| 530 | |
| 531 | class StopInfoWatchpoint : public StopInfo |
| 532 | { |
| 533 | public: |
Jim Ingham | f57b435 | 2012-11-10 02:08:14 +0000 | [diff] [blame] | 534 | // Make sure watchpoint is properly disabled and subsequently enabled while performing watchpoint actions. |
| 535 | class WatchpointSentry { |
| 536 | public: |
| 537 | WatchpointSentry(Process *p, Watchpoint *w): |
| 538 | process(p), |
| 539 | watchpoint(w) |
| 540 | { |
| 541 | if (process && watchpoint) |
| 542 | { |
Jim Ingham | 1b5792e | 2012-12-18 02:03:49 +0000 | [diff] [blame] | 543 | const bool notify = false; |
Jim Ingham | f57b435 | 2012-11-10 02:08:14 +0000 | [diff] [blame] | 544 | watchpoint->TurnOnEphemeralMode(); |
Jim Ingham | 1b5792e | 2012-12-18 02:03:49 +0000 | [diff] [blame] | 545 | process->DisableWatchpoint(watchpoint, notify); |
Jim Ingham | f57b435 | 2012-11-10 02:08:14 +0000 | [diff] [blame] | 546 | } |
| 547 | } |
| 548 | ~WatchpointSentry() |
| 549 | { |
| 550 | if (process && watchpoint) |
| 551 | { |
| 552 | if (!watchpoint->IsDisabledDuringEphemeralMode()) |
Jim Ingham | 1b5792e | 2012-12-18 02:03:49 +0000 | [diff] [blame] | 553 | { |
| 554 | const bool notify = false; |
| 555 | process->EnableWatchpoint(watchpoint, notify); |
| 556 | } |
Jim Ingham | f57b435 | 2012-11-10 02:08:14 +0000 | [diff] [blame] | 557 | watchpoint->TurnOffEphemeralMode(); |
| 558 | } |
| 559 | } |
| 560 | private: |
| 561 | Process *process; |
| 562 | Watchpoint *watchpoint; |
| 563 | }; |
Greg Clayton | f4b47e1 | 2010-08-04 01:40:35 +0000 | [diff] [blame] | 564 | |
| 565 | StopInfoWatchpoint (Thread &thread, break_id_t watch_id) : |
Johnny Chen | fd158f4 | 2011-09-21 22:47:15 +0000 | [diff] [blame] | 566 | StopInfo(thread, watch_id), |
| 567 | m_description(), |
| 568 | m_should_stop(false), |
| 569 | m_should_stop_is_valid(false) |
Greg Clayton | f4b47e1 | 2010-08-04 01:40:35 +0000 | [diff] [blame] | 570 | { |
| 571 | } |
| 572 | |
| 573 | virtual ~StopInfoWatchpoint () |
| 574 | { |
| 575 | } |
| 576 | |
| 577 | virtual StopReason |
| 578 | GetStopReason () const |
| 579 | { |
| 580 | return eStopReasonWatchpoint; |
| 581 | } |
| 582 | |
Jim Ingham | f57b435 | 2012-11-10 02:08:14 +0000 | [diff] [blame] | 583 | virtual const char * |
| 584 | GetDescription () |
| 585 | { |
| 586 | if (m_description.empty()) |
| 587 | { |
| 588 | StreamString strm; |
Daniel Malea | d01b295 | 2012-11-29 21:49:15 +0000 | [diff] [blame] | 589 | strm.Printf("watchpoint %" PRIi64, m_value); |
Jim Ingham | f57b435 | 2012-11-10 02:08:14 +0000 | [diff] [blame] | 590 | m_description.swap (strm.GetString()); |
| 591 | } |
| 592 | return m_description.c_str(); |
| 593 | } |
| 594 | |
| 595 | protected: |
Johnny Chen | fd158f4 | 2011-09-21 22:47:15 +0000 | [diff] [blame] | 596 | virtual bool |
Jim Ingham | 9b620f3 | 2013-02-22 21:23:43 +0000 | [diff] [blame] | 597 | ShouldStopSynchronous (Event *event_ptr) |
Johnny Chen | fd158f4 | 2011-09-21 22:47:15 +0000 | [diff] [blame] | 598 | { |
| 599 | // ShouldStop() method is idempotent and should not affect hit count. |
Johnny Chen | 16dcf71 | 2011-10-17 18:58:00 +0000 | [diff] [blame] | 600 | // See Process::RunPrivateStateThread()->Process()->HandlePrivateEvent() |
| 601 | // -->Process()::ShouldBroadcastEvent()->ThreadList::ShouldStop()-> |
| 602 | // Thread::ShouldStop()->ThreadPlanBase::ShouldStop()-> |
| 603 | // StopInfoWatchpoint::ShouldStop() and |
| 604 | // Event::DoOnRemoval()->Process::ProcessEventData::DoOnRemoval()-> |
| 605 | // StopInfoWatchpoint::PerformAction(). |
Johnny Chen | fd158f4 | 2011-09-21 22:47:15 +0000 | [diff] [blame] | 606 | if (m_should_stop_is_valid) |
| 607 | return m_should_stop; |
| 608 | |
Johnny Chen | 01a6786 | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 609 | WatchpointSP wp_sp = |
Greg Clayton | 1ac04c3 | 2012-02-21 00:09:25 +0000 | [diff] [blame] | 610 | m_thread.CalculateTarget()->GetWatchpointList().FindByID(GetValue()); |
Johnny Chen | 01a6786 | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 611 | if (wp_sp) |
Johnny Chen | fd158f4 | 2011-09-21 22:47:15 +0000 | [diff] [blame] | 612 | { |
| 613 | // Check if we should stop at a watchpoint. |
Greg Clayton | 1ac04c3 | 2012-02-21 00:09:25 +0000 | [diff] [blame] | 614 | ExecutionContext exe_ctx (m_thread.GetStackFrameAtIndex(0)); |
| 615 | StoppointCallbackContext context (event_ptr, exe_ctx, true); |
Johnny Chen | 01a6786 | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 616 | m_should_stop = wp_sp->ShouldStop (&context); |
Johnny Chen | fd158f4 | 2011-09-21 22:47:15 +0000 | [diff] [blame] | 617 | } |
| 618 | else |
| 619 | { |
Greg Clayton | 5160ce5 | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 620 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS)); |
Johnny Chen | fd158f4 | 2011-09-21 22:47:15 +0000 | [diff] [blame] | 621 | |
| 622 | if (log) |
Daniel Malea | d01b295 | 2012-11-29 21:49:15 +0000 | [diff] [blame] | 623 | log->Printf ("Process::%s could not find watchpoint location id: %" PRId64 "...", |
Johnny Chen | fd158f4 | 2011-09-21 22:47:15 +0000 | [diff] [blame] | 624 | __FUNCTION__, GetValue()); |
| 625 | |
| 626 | m_should_stop = true; |
| 627 | } |
| 628 | m_should_stop_is_valid = true; |
| 629 | return m_should_stop; |
| 630 | } |
| 631 | |
Jim Ingham | 9b620f3 | 2013-02-22 21:23:43 +0000 | [diff] [blame] | 632 | bool |
| 633 | ShouldStop (Event *event_ptr) |
| 634 | { |
| 635 | // This just reports the work done by PerformAction or the synchronous stop. It should |
| 636 | // only ever get called after they have had a chance to run. |
| 637 | assert (m_should_stop_is_valid); |
| 638 | return m_should_stop; |
| 639 | } |
| 640 | |
Johnny Chen | 16dcf71 | 2011-10-17 18:58:00 +0000 | [diff] [blame] | 641 | virtual void |
| 642 | PerformAction (Event *event_ptr) |
| 643 | { |
Greg Clayton | 5160ce5 | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 644 | Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS); |
Johnny Chen | 16dcf71 | 2011-10-17 18:58:00 +0000 | [diff] [blame] | 645 | // We're going to calculate if we should stop or not in some way during the course of |
| 646 | // this code. Also by default we're going to stop, so set that here. |
| 647 | m_should_stop = true; |
| 648 | |
| 649 | WatchpointSP wp_sp = |
Greg Clayton | 1ac04c3 | 2012-02-21 00:09:25 +0000 | [diff] [blame] | 650 | m_thread.CalculateTarget()->GetWatchpointList().FindByID(GetValue()); |
Johnny Chen | 16dcf71 | 2011-10-17 18:58:00 +0000 | [diff] [blame] | 651 | if (wp_sp) |
| 652 | { |
Greg Clayton | 1ac04c3 | 2012-02-21 00:09:25 +0000 | [diff] [blame] | 653 | ExecutionContext exe_ctx (m_thread.GetStackFrameAtIndex(0)); |
Johnny Chen | 209bd65 | 2012-08-13 21:09:54 +0000 | [diff] [blame] | 654 | Process* process = exe_ctx.GetProcessPtr(); |
Johnny Chen | 0f7ad8d | 2012-08-21 22:06:34 +0000 | [diff] [blame] | 655 | |
Johnny Chen | 66535a3 | 2012-08-21 22:15:58 +0000 | [diff] [blame] | 656 | // This sentry object makes sure the current watchpoint is disabled while performing watchpoint actions, |
| 657 | // and it is then enabled after we are finished. |
Johnny Chen | 0f7ad8d | 2012-08-21 22:06:34 +0000 | [diff] [blame] | 658 | WatchpointSentry sentry(process, wp_sp.get()); |
| 659 | |
Enrico Granata | f04a219 | 2012-07-13 23:18:48 +0000 | [diff] [blame] | 660 | { |
| 661 | // check if this process is running on an architecture where watchpoints trigger |
| 662 | // before the associated instruction runs. if so, disable the WP, single-step and then |
| 663 | // re-enable the watchpoint |
Enrico Granata | f04a219 | 2012-07-13 23:18:48 +0000 | [diff] [blame] | 664 | if (process) |
| 665 | { |
| 666 | uint32_t num; bool wp_triggers_after; |
| 667 | if (process->GetWatchpointSupportInfo(num, wp_triggers_after).Success()) |
| 668 | { |
| 669 | if (!wp_triggers_after) |
| 670 | { |
Enrico Granata | f04a219 | 2012-07-13 23:18:48 +0000 | [diff] [blame] | 671 | ThreadPlan *new_plan = m_thread.QueueThreadPlanForStepSingleInstruction(false, // step-over |
| 672 | false, // abort_other_plans |
| 673 | true); // stop_other_threads |
| 674 | new_plan->SetIsMasterPlan (true); |
| 675 | new_plan->SetOkayToDiscard (false); |
| 676 | process->GetThreadList().SetSelectedThreadByID (m_thread.GetID()); |
| 677 | process->Resume (); |
| 678 | process->WaitForProcessToStop (NULL); |
| 679 | process->GetThreadList().SetSelectedThreadByID (m_thread.GetID()); |
| 680 | MakeStopInfoValid(); // make sure we do not fail to stop because of the single-step taken above |
Enrico Granata | f04a219 | 2012-07-13 23:18:48 +0000 | [diff] [blame] | 681 | } |
| 682 | } |
| 683 | } |
| 684 | } |
Johnny Chen | 209bd65 | 2012-08-13 21:09:54 +0000 | [diff] [blame] | 685 | |
Johnny Chen | 16dcf71 | 2011-10-17 18:58:00 +0000 | [diff] [blame] | 686 | if (m_should_stop && wp_sp->GetConditionText() != NULL) |
| 687 | { |
| 688 | // We need to make sure the user sees any parse errors in their condition, so we'll hook the |
| 689 | // constructor errors up to the debugger's Async I/O. |
Johnny Chen | 16dcf71 | 2011-10-17 18:58:00 +0000 | [diff] [blame] | 690 | ExecutionResults result_code; |
| 691 | ValueObjectSP result_value_sp; |
Jim Ingham | 184e981 | 2013-01-15 02:47:48 +0000 | [diff] [blame] | 692 | const bool unwind_on_error = true; |
| 693 | const bool ignore_breakpoints = true; |
Johnny Chen | 16dcf71 | 2011-10-17 18:58:00 +0000 | [diff] [blame] | 694 | Error error; |
Greg Clayton | 1ac04c3 | 2012-02-21 00:09:25 +0000 | [diff] [blame] | 695 | result_code = ClangUserExpression::EvaluateWithError (exe_ctx, |
Sean Callanan | 2201905 | 2012-09-08 01:51:48 +0000 | [diff] [blame] | 696 | eExecutionPolicyOnlyWhenNeeded, |
Sean Callanan | c7b6506 | 2011-11-07 23:35:40 +0000 | [diff] [blame] | 697 | lldb::eLanguageTypeUnknown, |
Sean Callanan | 20bb3aa | 2011-12-21 22:22:58 +0000 | [diff] [blame] | 698 | ClangUserExpression::eResultTypeAny, |
Jim Ingham | 184e981 | 2013-01-15 02:47:48 +0000 | [diff] [blame] | 699 | unwind_on_error, |
| 700 | ignore_breakpoints, |
Johnny Chen | 16dcf71 | 2011-10-17 18:58:00 +0000 | [diff] [blame] | 701 | wp_sp->GetConditionText(), |
| 702 | NULL, |
| 703 | result_value_sp, |
Enrico Granata | 3372f58 | 2012-07-16 23:10:35 +0000 | [diff] [blame] | 704 | error, |
Greg Clayton | 26ab83d | 2012-10-31 20:49:04 +0000 | [diff] [blame] | 705 | true, |
| 706 | ClangUserExpression::kDefaultTimeout); |
Johnny Chen | 16dcf71 | 2011-10-17 18:58:00 +0000 | [diff] [blame] | 707 | if (result_code == eExecutionCompleted) |
| 708 | { |
| 709 | if (result_value_sp) |
| 710 | { |
| 711 | Scalar scalar_value; |
| 712 | if (result_value_sp->ResolveValue (scalar_value)) |
| 713 | { |
| 714 | if (scalar_value.ULongLong(1) == 0) |
| 715 | { |
| 716 | // We have been vetoed. This takes precedence over querying |
| 717 | // the watchpoint whether it should stop (aka ignore count and |
| 718 | // friends). See also StopInfoWatchpoint::ShouldStop() as well |
| 719 | // as Process::ProcessEventData::DoOnRemoval(). |
| 720 | m_should_stop = false; |
| 721 | } |
| 722 | else |
| 723 | m_should_stop = true; |
| 724 | if (log) |
| 725 | log->Printf("Condition successfully evaluated, result is %s.\n", |
| 726 | m_should_stop ? "true" : "false"); |
| 727 | } |
| 728 | else |
| 729 | { |
| 730 | m_should_stop = true; |
| 731 | if (log) |
| 732 | log->Printf("Failed to get an integer result from the expression."); |
| 733 | } |
| 734 | } |
| 735 | } |
| 736 | else |
| 737 | { |
Greg Clayton | 1ac04c3 | 2012-02-21 00:09:25 +0000 | [diff] [blame] | 738 | Debugger &debugger = exe_ctx.GetTargetRef().GetDebugger(); |
Johnny Chen | 16dcf71 | 2011-10-17 18:58:00 +0000 | [diff] [blame] | 739 | StreamSP error_sp = debugger.GetAsyncErrorStream (); |
Johnny Chen | 5f3bf63 | 2012-01-24 23:19:25 +0000 | [diff] [blame] | 740 | error_sp->Printf ("Stopped due to an error evaluating condition of watchpoint "); |
Johnny Chen | 16dcf71 | 2011-10-17 18:58:00 +0000 | [diff] [blame] | 741 | wp_sp->GetDescription (error_sp.get(), eDescriptionLevelBrief); |
| 742 | error_sp->Printf (": \"%s\"", |
| 743 | wp_sp->GetConditionText()); |
| 744 | error_sp->EOL(); |
| 745 | const char *err_str = error.AsCString("<Unknown Error>"); |
| 746 | if (log) |
| 747 | log->Printf("Error evaluating condition: \"%s\"\n", err_str); |
| 748 | |
| 749 | error_sp->PutCString (err_str); |
| 750 | error_sp->EOL(); |
| 751 | error_sp->Flush(); |
| 752 | // If the condition fails to be parsed or run, we should stop. |
| 753 | m_should_stop = true; |
| 754 | } |
| 755 | } |
Johnny Chen | 1320641 | 2012-08-09 23:10:57 +0000 | [diff] [blame] | 756 | |
| 757 | // If the condition says to stop, we run the callback to further decide whether to stop. |
| 758 | if (m_should_stop) |
| 759 | { |
Johnny Chen | 209bd65 | 2012-08-13 21:09:54 +0000 | [diff] [blame] | 760 | StoppointCallbackContext context (event_ptr, exe_ctx, false); |
Johnny Chen | 1320641 | 2012-08-09 23:10:57 +0000 | [diff] [blame] | 761 | bool stop_requested = wp_sp->InvokeCallback (&context); |
| 762 | // Also make sure that the callback hasn't continued the target. |
| 763 | // If it did, when we'll set m_should_stop to false and get out of here. |
| 764 | if (HasTargetRunSinceMe ()) |
| 765 | m_should_stop = false; |
| 766 | |
| 767 | if (m_should_stop && !stop_requested) |
| 768 | { |
| 769 | // We have been vetoed by the callback mechanism. |
| 770 | m_should_stop = false; |
| 771 | } |
| 772 | } |
Jim Ingham | a7dfb66 | 2012-10-23 07:20:06 +0000 | [diff] [blame] | 773 | // Finally, if we are going to stop, print out the new & old values: |
| 774 | if (m_should_stop) |
| 775 | { |
| 776 | wp_sp->CaptureWatchedValue(exe_ctx); |
| 777 | |
| 778 | Debugger &debugger = exe_ctx.GetTargetRef().GetDebugger(); |
| 779 | StreamSP output_sp = debugger.GetAsyncOutputStream (); |
| 780 | wp_sp->DumpSnapshots(output_sp.get()); |
| 781 | output_sp->EOL(); |
| 782 | output_sp->Flush(); |
| 783 | } |
| 784 | |
Johnny Chen | 16dcf71 | 2011-10-17 18:58:00 +0000 | [diff] [blame] | 785 | } |
| 786 | else |
| 787 | { |
Greg Clayton | 5160ce5 | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 788 | Log * log_process(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS)); |
Johnny Chen | 16dcf71 | 2011-10-17 18:58:00 +0000 | [diff] [blame] | 789 | |
Jason Molenda | ccd41e5 | 2012-10-04 22:47:07 +0000 | [diff] [blame] | 790 | if (log_process) |
Daniel Malea | d01b295 | 2012-11-29 21:49:15 +0000 | [diff] [blame] | 791 | log_process->Printf ("Process::%s could not find watchpoint id: %" PRId64 "...", __FUNCTION__, m_value); |
Johnny Chen | 16dcf71 | 2011-10-17 18:58:00 +0000 | [diff] [blame] | 792 | } |
| 793 | if (log) |
| 794 | log->Printf ("Process::%s returning from action with m_should_stop: %d.", __FUNCTION__, m_should_stop); |
Jim Ingham | a7dfb66 | 2012-10-23 07:20:06 +0000 | [diff] [blame] | 795 | |
Jim Ingham | 9b620f3 | 2013-02-22 21:23:43 +0000 | [diff] [blame] | 796 | m_should_stop_is_valid = true; |
| 797 | |
Johnny Chen | 16dcf71 | 2011-10-17 18:58:00 +0000 | [diff] [blame] | 798 | } |
| 799 | |
Greg Clayton | f4b47e1 | 2010-08-04 01:40:35 +0000 | [diff] [blame] | 800 | private: |
| 801 | std::string m_description; |
Johnny Chen | fd158f4 | 2011-09-21 22:47:15 +0000 | [diff] [blame] | 802 | bool m_should_stop; |
| 803 | bool m_should_stop_is_valid; |
Greg Clayton | f4b47e1 | 2010-08-04 01:40:35 +0000 | [diff] [blame] | 804 | }; |
| 805 | |
| 806 | |
| 807 | |
| 808 | //---------------------------------------------------------------------- |
| 809 | // StopInfoUnixSignal |
| 810 | //---------------------------------------------------------------------- |
| 811 | |
| 812 | class StopInfoUnixSignal : public StopInfo |
| 813 | { |
| 814 | public: |
| 815 | |
| 816 | StopInfoUnixSignal (Thread &thread, int signo) : |
Greg Clayton | a658fd2 | 2011-06-04 01:26:29 +0000 | [diff] [blame] | 817 | StopInfo (thread, signo) |
Greg Clayton | f4b47e1 | 2010-08-04 01:40:35 +0000 | [diff] [blame] | 818 | { |
| 819 | } |
| 820 | |
| 821 | virtual ~StopInfoUnixSignal () |
| 822 | { |
| 823 | } |
| 824 | |
| 825 | |
| 826 | virtual StopReason |
| 827 | GetStopReason () const |
| 828 | { |
| 829 | return eStopReasonSignal; |
| 830 | } |
| 831 | |
| 832 | virtual bool |
Jim Ingham | 0161b49 | 2013-02-09 01:29:05 +0000 | [diff] [blame] | 833 | ShouldStopSynchronous (Event *event_ptr) |
| 834 | { |
| 835 | return m_thread.GetProcess()->GetUnixSignals().GetShouldStop (m_value); |
| 836 | } |
| 837 | |
| 838 | virtual bool |
Greg Clayton | f4b47e1 | 2010-08-04 01:40:35 +0000 | [diff] [blame] | 839 | ShouldStop (Event *event_ptr) |
| 840 | { |
Greg Clayton | 1ac04c3 | 2012-02-21 00:09:25 +0000 | [diff] [blame] | 841 | return m_thread.GetProcess()->GetUnixSignals().GetShouldStop (m_value); |
Greg Clayton | f4b47e1 | 2010-08-04 01:40:35 +0000 | [diff] [blame] | 842 | } |
| 843 | |
| 844 | |
| 845 | // If should stop returns false, check if we should notify of this event |
| 846 | virtual bool |
| 847 | ShouldNotify (Event *event_ptr) |
| 848 | { |
Jim Ingham | 0161b49 | 2013-02-09 01:29:05 +0000 | [diff] [blame] | 849 | bool should_notify = m_thread.GetProcess()->GetUnixSignals().GetShouldNotify (m_value); |
| 850 | if (should_notify) |
| 851 | { |
| 852 | StreamString strm; |
| 853 | strm.Printf ("thread %d received signal: %s", |
| 854 | m_thread.GetIndexID(), |
| 855 | m_thread.GetProcess()->GetUnixSignals().GetSignalAsCString (m_value)); |
| 856 | Process::ProcessEventData::AddRestartedReason(event_ptr, strm.GetData()); |
| 857 | } |
| 858 | return should_notify; |
Greg Clayton | f4b47e1 | 2010-08-04 01:40:35 +0000 | [diff] [blame] | 859 | } |
| 860 | |
| 861 | |
| 862 | virtual void |
| 863 | WillResume (lldb::StateType resume_state) |
| 864 | { |
Greg Clayton | 1ac04c3 | 2012-02-21 00:09:25 +0000 | [diff] [blame] | 865 | if (m_thread.GetProcess()->GetUnixSignals().GetShouldSuppress(m_value) == false) |
Greg Clayton | f4b47e1 | 2010-08-04 01:40:35 +0000 | [diff] [blame] | 866 | m_thread.SetResumeSignal(m_value); |
| 867 | } |
| 868 | |
| 869 | virtual const char * |
| 870 | GetDescription () |
| 871 | { |
| 872 | if (m_description.empty()) |
| 873 | { |
| 874 | StreamString strm; |
Greg Clayton | 1ac04c3 | 2012-02-21 00:09:25 +0000 | [diff] [blame] | 875 | const char *signal_name = m_thread.GetProcess()->GetUnixSignals().GetSignalAsCString (m_value); |
Greg Clayton | f4b47e1 | 2010-08-04 01:40:35 +0000 | [diff] [blame] | 876 | if (signal_name) |
Greg Clayton | 0603aa9 | 2010-10-04 01:05:56 +0000 | [diff] [blame] | 877 | strm.Printf("signal %s", signal_name); |
Greg Clayton | f4b47e1 | 2010-08-04 01:40:35 +0000 | [diff] [blame] | 878 | else |
Daniel Malea | d01b295 | 2012-11-29 21:49:15 +0000 | [diff] [blame] | 879 | strm.Printf("signal %" PRIi64, m_value); |
Greg Clayton | f4b47e1 | 2010-08-04 01:40:35 +0000 | [diff] [blame] | 880 | m_description.swap (strm.GetString()); |
| 881 | } |
| 882 | return m_description.c_str(); |
| 883 | } |
Greg Clayton | f4b47e1 | 2010-08-04 01:40:35 +0000 | [diff] [blame] | 884 | }; |
| 885 | |
| 886 | //---------------------------------------------------------------------- |
| 887 | // StopInfoTrace |
| 888 | //---------------------------------------------------------------------- |
| 889 | |
| 890 | class StopInfoTrace : public StopInfo |
| 891 | { |
| 892 | public: |
| 893 | |
| 894 | StopInfoTrace (Thread &thread) : |
| 895 | StopInfo (thread, LLDB_INVALID_UID) |
| 896 | { |
| 897 | } |
| 898 | |
| 899 | virtual ~StopInfoTrace () |
| 900 | { |
| 901 | } |
| 902 | |
| 903 | virtual StopReason |
| 904 | GetStopReason () const |
| 905 | { |
| 906 | return eStopReasonTrace; |
| 907 | } |
| 908 | |
| 909 | virtual const char * |
| 910 | GetDescription () |
| 911 | { |
Greg Clayton | a658fd2 | 2011-06-04 01:26:29 +0000 | [diff] [blame] | 912 | if (m_description.empty()) |
Greg Clayton | f4b47e1 | 2010-08-04 01:40:35 +0000 | [diff] [blame] | 913 | return "trace"; |
Greg Clayton | a658fd2 | 2011-06-04 01:26:29 +0000 | [diff] [blame] | 914 | else |
| 915 | return m_description.c_str(); |
| 916 | } |
| 917 | }; |
| 918 | |
| 919 | |
| 920 | //---------------------------------------------------------------------- |
| 921 | // StopInfoException |
| 922 | //---------------------------------------------------------------------- |
| 923 | |
| 924 | class StopInfoException : public StopInfo |
| 925 | { |
| 926 | public: |
| 927 | |
| 928 | StopInfoException (Thread &thread, const char *description) : |
| 929 | StopInfo (thread, LLDB_INVALID_UID) |
| 930 | { |
| 931 | if (description) |
| 932 | SetDescription (description); |
| 933 | } |
| 934 | |
| 935 | virtual |
| 936 | ~StopInfoException () |
| 937 | { |
| 938 | } |
| 939 | |
| 940 | virtual StopReason |
| 941 | GetStopReason () const |
| 942 | { |
| 943 | return eStopReasonException; |
| 944 | } |
| 945 | |
| 946 | virtual const char * |
| 947 | GetDescription () |
| 948 | { |
| 949 | if (m_description.empty()) |
| 950 | return "exception"; |
| 951 | else |
| 952 | return m_description.c_str(); |
Greg Clayton | f4b47e1 | 2010-08-04 01:40:35 +0000 | [diff] [blame] | 953 | } |
| 954 | }; |
| 955 | |
| 956 | |
| 957 | //---------------------------------------------------------------------- |
| 958 | // StopInfoThreadPlan |
| 959 | //---------------------------------------------------------------------- |
| 960 | |
| 961 | class StopInfoThreadPlan : public StopInfo |
| 962 | { |
| 963 | public: |
| 964 | |
Jim Ingham | 73ca05a | 2011-12-17 01:35:57 +0000 | [diff] [blame] | 965 | StopInfoThreadPlan (ThreadPlanSP &plan_sp, ValueObjectSP &return_valobj_sp) : |
Greg Clayton | f4b47e1 | 2010-08-04 01:40:35 +0000 | [diff] [blame] | 966 | StopInfo (plan_sp->GetThread(), LLDB_INVALID_UID), |
Jim Ingham | 73ca05a | 2011-12-17 01:35:57 +0000 | [diff] [blame] | 967 | m_plan_sp (plan_sp), |
| 968 | m_return_valobj_sp (return_valobj_sp) |
Greg Clayton | f4b47e1 | 2010-08-04 01:40:35 +0000 | [diff] [blame] | 969 | { |
| 970 | } |
| 971 | |
| 972 | virtual ~StopInfoThreadPlan () |
| 973 | { |
| 974 | } |
| 975 | |
| 976 | virtual StopReason |
| 977 | GetStopReason () const |
| 978 | { |
| 979 | return eStopReasonPlanComplete; |
| 980 | } |
| 981 | |
| 982 | virtual const char * |
| 983 | GetDescription () |
| 984 | { |
| 985 | if (m_description.empty()) |
| 986 | { |
| 987 | StreamString strm; |
| 988 | m_plan_sp->GetDescription (&strm, eDescriptionLevelBrief); |
| 989 | m_description.swap (strm.GetString()); |
| 990 | } |
| 991 | return m_description.c_str(); |
| 992 | } |
Jim Ingham | 73ca05a | 2011-12-17 01:35:57 +0000 | [diff] [blame] | 993 | |
| 994 | ValueObjectSP |
| 995 | GetReturnValueObject() |
| 996 | { |
| 997 | return m_return_valobj_sp; |
| 998 | } |
Jim Ingham | 0161b49 | 2013-02-09 01:29:05 +0000 | [diff] [blame] | 999 | |
| 1000 | protected: |
| 1001 | virtual bool |
| 1002 | ShouldStop (Event *event_ptr) |
| 1003 | { |
| 1004 | if (m_plan_sp) |
| 1005 | return m_plan_sp->ShouldStop(event_ptr); |
| 1006 | else |
| 1007 | return StopInfo::ShouldStop(event_ptr); |
| 1008 | } |
Greg Clayton | f4b47e1 | 2010-08-04 01:40:35 +0000 | [diff] [blame] | 1009 | |
| 1010 | private: |
| 1011 | ThreadPlanSP m_plan_sp; |
Jim Ingham | 73ca05a | 2011-12-17 01:35:57 +0000 | [diff] [blame] | 1012 | ValueObjectSP m_return_valobj_sp; |
Greg Clayton | f4b47e1 | 2010-08-04 01:40:35 +0000 | [diff] [blame] | 1013 | }; |
Greg Clayton | 90ba811 | 2012-12-05 00:16:59 +0000 | [diff] [blame] | 1014 | |
| 1015 | class StopInfoExec : public StopInfo |
| 1016 | { |
| 1017 | public: |
| 1018 | |
| 1019 | StopInfoExec (Thread &thread) : |
| 1020 | StopInfo (thread, LLDB_INVALID_UID), |
| 1021 | m_performed_action (false) |
| 1022 | { |
| 1023 | } |
| 1024 | |
| 1025 | virtual |
| 1026 | ~StopInfoExec () |
| 1027 | { |
| 1028 | } |
| 1029 | |
| 1030 | virtual StopReason |
| 1031 | GetStopReason () const |
| 1032 | { |
| 1033 | return eStopReasonExec; |
| 1034 | } |
| 1035 | |
| 1036 | virtual const char * |
| 1037 | GetDescription () |
| 1038 | { |
| 1039 | return "exec"; |
| 1040 | } |
| 1041 | protected: |
Greg Clayton | 90ba811 | 2012-12-05 00:16:59 +0000 | [diff] [blame] | 1042 | |
| 1043 | virtual void |
| 1044 | PerformAction (Event *event_ptr) |
| 1045 | { |
| 1046 | // Only perform the action once |
| 1047 | if (m_performed_action) |
| 1048 | return; |
| 1049 | m_performed_action = true; |
| 1050 | m_thread.GetProcess()->DidExec(); |
| 1051 | } |
| 1052 | |
| 1053 | bool m_performed_action; |
| 1054 | }; |
| 1055 | |
Jim Ingham | 4b53618 | 2011-08-09 02:12:22 +0000 | [diff] [blame] | 1056 | } // namespace lldb_private |
Greg Clayton | f4b47e1 | 2010-08-04 01:40:35 +0000 | [diff] [blame] | 1057 | |
| 1058 | StopInfoSP |
| 1059 | StopInfo::CreateStopReasonWithBreakpointSiteID (Thread &thread, break_id_t break_id) |
| 1060 | { |
| 1061 | return StopInfoSP (new StopInfoBreakpoint (thread, break_id)); |
| 1062 | } |
| 1063 | |
| 1064 | StopInfoSP |
Jim Ingham | 36f3b36 | 2010-10-14 23:45:03 +0000 | [diff] [blame] | 1065 | StopInfo::CreateStopReasonWithBreakpointSiteID (Thread &thread, break_id_t break_id, bool should_stop) |
| 1066 | { |
| 1067 | return StopInfoSP (new StopInfoBreakpoint (thread, break_id, should_stop)); |
| 1068 | } |
| 1069 | |
| 1070 | StopInfoSP |
Greg Clayton | f4b47e1 | 2010-08-04 01:40:35 +0000 | [diff] [blame] | 1071 | StopInfo::CreateStopReasonWithWatchpointID (Thread &thread, break_id_t watch_id) |
| 1072 | { |
| 1073 | return StopInfoSP (new StopInfoWatchpoint (thread, watch_id)); |
| 1074 | } |
| 1075 | |
| 1076 | StopInfoSP |
| 1077 | StopInfo::CreateStopReasonWithSignal (Thread &thread, int signo) |
| 1078 | { |
| 1079 | return StopInfoSP (new StopInfoUnixSignal (thread, signo)); |
| 1080 | } |
| 1081 | |
| 1082 | StopInfoSP |
| 1083 | StopInfo::CreateStopReasonToTrace (Thread &thread) |
| 1084 | { |
| 1085 | return StopInfoSP (new StopInfoTrace (thread)); |
| 1086 | } |
| 1087 | |
| 1088 | StopInfoSP |
Jim Ingham | 73ca05a | 2011-12-17 01:35:57 +0000 | [diff] [blame] | 1089 | StopInfo::CreateStopReasonWithPlan (ThreadPlanSP &plan_sp, ValueObjectSP return_valobj_sp) |
Greg Clayton | f4b47e1 | 2010-08-04 01:40:35 +0000 | [diff] [blame] | 1090 | { |
Jim Ingham | 73ca05a | 2011-12-17 01:35:57 +0000 | [diff] [blame] | 1091 | return StopInfoSP (new StopInfoThreadPlan (plan_sp, return_valobj_sp)); |
Greg Clayton | f4b47e1 | 2010-08-04 01:40:35 +0000 | [diff] [blame] | 1092 | } |
Greg Clayton | a658fd2 | 2011-06-04 01:26:29 +0000 | [diff] [blame] | 1093 | |
| 1094 | StopInfoSP |
| 1095 | StopInfo::CreateStopReasonWithException (Thread &thread, const char *description) |
| 1096 | { |
| 1097 | return StopInfoSP (new StopInfoException (thread, description)); |
| 1098 | } |
Jim Ingham | 73ca05a | 2011-12-17 01:35:57 +0000 | [diff] [blame] | 1099 | |
Greg Clayton | 90ba811 | 2012-12-05 00:16:59 +0000 | [diff] [blame] | 1100 | StopInfoSP |
| 1101 | StopInfo::CreateStopReasonWithExec (Thread &thread) |
| 1102 | { |
| 1103 | return StopInfoSP (new StopInfoExec (thread)); |
| 1104 | } |
| 1105 | |
Jim Ingham | 73ca05a | 2011-12-17 01:35:57 +0000 | [diff] [blame] | 1106 | ValueObjectSP |
| 1107 | StopInfo::GetReturnValueObject(StopInfoSP &stop_info_sp) |
| 1108 | { |
| 1109 | if (stop_info_sp && stop_info_sp->GetStopReason() == eStopReasonPlanComplete) |
| 1110 | { |
| 1111 | StopInfoThreadPlan *plan_stop_info = static_cast<StopInfoThreadPlan *>(stop_info_sp.get()); |
| 1112 | return plan_stop_info->GetReturnValueObject(); |
| 1113 | } |
| 1114 | else |
| 1115 | return ValueObjectSP(); |
| 1116 | } |