コード例 #1
0
ファイル: DebugCLI.cs プロジェクト: heon21st/flashdevelop
		internal virtual bool watchpointAdd(WatchAction a)
		{
			return m_watchpoints.Add(a) >= 0;
		}
コード例 #2
0
ファイル: DebugCLI.cs プロジェクト: heon21st/flashdevelop
		/// <summary> Request to add a new watchpoint
		/// This may result in one of two things happening
		/// (1) a new watchpoint could be added or
		/// (2) an existing watchpoint may be modified.
		/// 
		/// The watch, awatch, and rwatch commands will set a watchpoint on the
		/// given expression. The different commands control the read/write aspect
		/// of the watchpoint.
		/// 
		/// awatch will trigger a break if the expression is read or written.
		/// rwatch will trigger a break if the expression is read.
		/// watch will trigger a break if the expression is written.
		/// </summary>
		internal virtual void  doWatch(bool read, bool write)
		{
			try
			{
				System.Text.StringBuilder sb = new System.Text.StringBuilder();
				
				/* pull the rest of the line */
				String s = restOfLine();
				
				int flags = 3;
				if (read && write)
					flags = WatchKind.READWRITE;
				else if (read)
					flags = WatchKind.READ;
				else if (write)
					flags = WatchKind.WRITE;
				
				// snapshot of our existing list
				Watch[] list = m_session.WatchList;
				
				// We need to separate the front part the 'a.b' in 'a.b.c' 
				// of the expression to resolve it into a variable 
				// We usually get back a VariableFacade which contains
				// the context id (i.e the variable id) and the member name.
				ValueExp expr = parseExpression(s);
				VariableFacade result = (VariableFacade) evalExpression(expr);
				
				// extract the 2 pieces and get the raw variable.
				int varId = result.Context; // TODO fix this???  -mike
				String memberName = result.getName();
				Value v = m_session.getValue(varId);
				
				// attempt to set.
				Watch w = m_session.setWatch(v, memberName, flags);
				if (w == null)
				{
					// failed
					System.Collections.IDictionary args = new System.Collections.Hashtable();
					args["expression"] = s; //$NON-NLS-1$
					err(LocalizationManager.getLocalizedTextString("watchpointCouldNotBeSet", args)); //$NON-NLS-1$
				}
				else
				{
					// if modified then lists are same length
					// otherwise 1 will be added
					Watch[] newList = m_session.WatchList;
					if (newList.Length == list.Length)
					{
						// modified, lets locate the one that changed
						// and reset it
						int at = missingWatchpointIndexOf(newList);
						WatchAction a = null;
						try
						{
							a = watchpointAt(at);
						}
						catch (System.IndexOutOfRangeException)
						{
							// this is pretty bad it means the player thinks we have a watchpoint
							// but we don't have a record of it.  So let's create a new one
							// and hope that we are now in sync with the player.
							a = new WatchAction(w);
						}
						
						// modify our view of the watchpoint
						int id = a.Id;
						a.resetWatch(w);
						
						System.Collections.IDictionary args = new System.Collections.Hashtable();
						args["watchpointNumber"] = System.Convert.ToString(id); //$NON-NLS-1$
						args["expression"] = s; //$NON-NLS-1$
						args["watchpointMode"] = getWatchpointModeString(a.Kind); //$NON-NLS-1$
						sb.Append(LocalizationManager.getLocalizedTextString("changedWatchpointMode", args)); //$NON-NLS-1$
					}
					else
					{
						// newly added
						WatchAction a = new WatchAction(w);
						watchpointAdd(a);
						
						int which = a.Id;
						System.Collections.IDictionary args = new System.Collections.Hashtable();
						args["watchpointNumber"] = System.Convert.ToString(which); //$NON-NLS-1$
						args["expression"] = s; //$NON-NLS-1$
						sb.Append(LocalizationManager.getLocalizedTextString("createdWatchpoint", args)); //$NON-NLS-1$
					}
					output(sb.ToString());
				}
			}
			catch (System.IndexOutOfRangeException)
			{
				// We should really do some cleanup after this exception
				// since it most likely means we can't find the watchpoint
				// that was just modified, therefore our watchlists are
				// out of sync with those of the API.
				err(LocalizationManager.getLocalizedTextString("badWatchpointNumber")); //$NON-NLS-1$
			}
			catch (System.NullReferenceException)
			{
				err(LocalizationManager.getLocalizedTextString("couldNotEvaluate")); //$NON-NLS-1$
			}
			catch (System.InvalidCastException)
			{
				err(LocalizationManager.getLocalizedTextString("couldNotResolveExpression")); //$NON-NLS-1$
			}
		}