Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: visual_studio/NativeClientVSAddIn/NativeClientVSAddIn/PluginDebuggerBase.cs

Issue 10823267: NaCl VS Addin Crash Fix (Closed) Base URL: https://nativeclient-sdk.googlecode.com/svn/trunk/src
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | visual_studio/NativeClientVSAddIn/NativeClientVSAddIn/PluginDebuggerGDB.cs » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 namespace NativeClientVSAddIn 5 namespace NativeClientVSAddIn
6 { 6 {
7 using System; 7 using System;
8 using System.Collections.Generic; 8 using System.Collections.Generic;
9 using System.Windows.Forms; 9 using System.Windows.Forms;
10 10
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 } 116 }
117 117
118 /// <summary> 118 /// <summary>
119 /// This is called periodically by the Visual Studio UI thread to look for o ur plug-in process 119 /// This is called periodically by the Visual Studio UI thread to look for o ur plug-in process
120 /// and attach the debugger to it. The call is triggered by the pluginFinde rTimer_ object. 120 /// and attach the debugger to it. The call is triggered by the pluginFinde rTimer_ object.
121 /// </summary> 121 /// </summary>
122 /// <param name="unused">The parameter is not used.</param> 122 /// <param name="unused">The parameter is not used.</param>
123 /// <param name="unused1">The parameter is not used.</param> 123 /// <param name="unused1">The parameter is not used.</param>
124 public void FindAndAttachToPlugin(object unused, EventArgs unused1) 124 public void FindAndAttachToPlugin(object unused, EventArgs unused1)
125 { 125 {
126 StringComparison ignoreCase = StringComparison.InvariantCultureIgnoreCase;
127
126 // This function is called by the main Visual Studio event loop and we may have put the event 128 // This function is called by the main Visual Studio event loop and we may have put the event
127 // on the queue just before disposing it meaning this could be called afte r we've disposed. 129 // on the queue just before disposing it meaning this could be called afte r we've disposed.
128 if (Disposed) 130 if (Disposed)
129 { 131 {
130 return; 132 return;
131 } 133 }
132 134
133 StringComparison ignoreCase = StringComparison.InvariantCultureIgnoreCase;
134
135 // Set the main chrome process that was started by visual studio. If it's not chrome 135 // Set the main chrome process that was started by visual studio. If it's not chrome
136 // or not found then we have no business attaching to any plug-ins so retu rn. 136 // or not found then we have no business attaching to any plug-ins so retu rn.
137 if (debuggedChromeMainProcess_ == null) 137 if (debuggedChromeMainProcess_ == null)
138 { 138 {
139 foreach (Process proc in Dte.Debugger.DebuggedProcesses) 139 foreach (Process proc in Dte.Debugger.DebuggedProcesses)
140 { 140 {
141 if (proc.Name.EndsWith(Strings.ChromeProcessName, ignoreCase)) 141 if (proc.Name.EndsWith(Strings.ChromeProcessName, ignoreCase))
142 { 142 {
143 debuggedChromeMainProcess_ = System.Diagnostics.Process.GetProcessBy Id(proc.ProcessID); 143 debuggedChromeMainProcess_ = System.Diagnostics.Process.GetProcessBy Id(proc.ProcessID);
144 break; 144 break;
145 } 145 }
146 } 146 }
147 147
148 return; 148 return;
149 } 149 }
150 150
151 if (debuggedChromeMainProcess_.HasExited)
152 {
153 // Might happen if we're shutting down debugging.
154 return;
155 }
156
151 // Get the list of all descendants of the main chrome process. 157 // Get the list of all descendants of the main chrome process.
152 uint mainChromeProcId = (uint)debuggedChromeMainProcess_.Id; 158 uint mainChromeProcId = (uint)debuggedChromeMainProcess_.Id;
153 List<ProcessInfo> chromeDescendants = processSearcher_.GetDescendants(main ChromeProcId); 159 List<ProcessInfo> chromeDescendants = processSearcher_.GetDescendants(main ChromeProcId);
154 string mainChromeFlags = chromeDescendants.Find(p => p.ID == mainChromePro cId).CommandLine; 160 if (chromeDescendants.Count == 0)
161 {
162 // Might happen if we're shutting down debugging.
163 return;
164 }
165
166 ProcessInfo mainProcInfo = chromeDescendants.Find(p => p.ID == mainChromeP rocId);
167 if (mainProcInfo == null)
168 {
169 // Might happen if we're shutting down debugging.
170 return;
171 }
172
173 string mainChromeFlags = mainProcInfo.CommandLine;
155 174
156 // From the list of descendants, find the plug-in by it's command line arg uments and 175 // From the list of descendants, find the plug-in by it's command line arg uments and
157 // process name as well as not being attached to already. 176 // process name as well as not being attached to already.
158 List<ProcessInfo> plugins = chromeDescendants.FindAll(p => 177 List<ProcessInfo> plugins = chromeDescendants.FindAll(p =>
159 IsPluginProcess(p, mainChromeFlags) && !pluginFinderForbiddenPids_.Con tains(p.ID)); 178 IsPluginProcess(p, mainChromeFlags) && !pluginFinderForbiddenPids_.Con tains(p.ID));
160 179
161 // Attach to all plug-ins that we found. 180 // Attach to all plug-ins that we found.
162 foreach (ProcessInfo process in plugins) 181 foreach (ProcessInfo process in plugins)
163 { 182 {
164 // If we are attaching to a plug-in, add it to the forbidden list to ens ure we 183 // If we are attaching to a plug-in, add it to the forbidden list to ens ure we
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 this.ProcessID = pid; 230 this.ProcessID = pid;
212 } 231 }
213 232
214 /// <summary> 233 /// <summary>
215 /// Gets or sets process ID of the found plug-in. 234 /// Gets or sets process ID of the found plug-in.
216 /// </summary> 235 /// </summary>
217 public uint ProcessID { get; set; } 236 public uint ProcessID { get; set; }
218 } 237 }
219 } 238 }
220 } 239 }
OLDNEW
« no previous file with comments | « no previous file | visual_studio/NativeClientVSAddIn/NativeClientVSAddIn/PluginDebuggerGDB.cs » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698