OLD | NEW |
---|---|
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.IO; | 8 using System.IO; |
9 using System.Text; | 9 using System.Text; |
10 using System.Windows.Forms; | 10 using System.Windows.Forms; |
11 using System.Diagnostics; | |
11 | 12 |
12 using EnvDTE; | 13 using EnvDTE; |
13 using EnvDTE80; | 14 using EnvDTE80; |
14 | 15 |
15 /// <summary> | 16 /// <summary> |
16 /// This class handles the details of finding a nexe and attaching to it. | 17 /// This class handles the details of finding a nexe and attaching to it. |
17 /// </summary> | 18 /// </summary> |
18 public class PluginDebuggerGDB : PluginDebuggerBase | 19 public class PluginDebuggerGDB : PluginDebuggerBase |
19 { | 20 { |
20 /// <summary> | 21 /// <summary> |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
53 private string gdbInitFileName_; | 54 private string gdbInitFileName_; |
54 | 55 |
55 /// <summary> | 56 /// <summary> |
56 /// Constructs the PluginDebuggerHelper. | 57 /// Constructs the PluginDebuggerHelper. |
57 /// </summary> | 58 /// </summary> |
58 /// <param name="dte">Automation object from Visual Studio.</param> | 59 /// <param name="dte">Automation object from Visual Studio.</param> |
59 /// <param name="properties">PropertyManager pointing to a valid project/pla tform.</param> | 60 /// <param name="properties">PropertyManager pointing to a valid project/pla tform.</param> |
60 public PluginDebuggerGDB(DTE2 dte, PropertyManager properties) | 61 public PluginDebuggerGDB(DTE2 dte, PropertyManager properties) |
61 : base(dte, properties) | 62 : base(dte, properties) |
62 { | 63 { |
63 irtPath_ = properties.IrtPath; | 64 string arch = "i686"; |
65 if (Environment.Is64BitOperatingSystem) | |
66 { | |
67 arch = "x86_64"; | |
68 } | |
69 | |
70 if (properties.TargetArchitecture != arch) | |
71 { | |
72 MessageBox.Show(string.Format("Debugging of {0} NaCl modules is not poss ible on this system ({1}).", | |
binji
2012/09/17 21:54:06
nit: wrap at 100
| |
73 properties.TargetArchitecture, arch)); | |
74 } | |
75 | |
76 // check chrome version | |
binji
2012/09/17 21:54:06
Not necessary for this CL, but these checks feel l
| |
77 string chrome_path = properties.LocalDebuggerCommand; | |
78 FileVersionInfo version_info = FileVersionInfo.GetVersionInfo(chrome_path) ; | |
79 string file_version = version_info.FileVersion; | |
80 if (file_version != null) | |
81 { | |
82 string major_version = file_version.Split('.')[0]; | |
83 int major_version_int = 0; | |
84 try | |
85 { | |
86 major_version_int = Convert.ToInt32(major_version); | |
87 } | |
88 catch | |
89 { | |
90 } | |
91 if (major_version_int < 22) | |
92 { | |
93 MessageBox.Show("Chrome 22 or above required for NaCl debugging (your version is " | |
94 + major_version + ")"); | |
95 return; | |
96 } | |
97 } | |
98 | |
99 // We look for the IRT in several ways, mimicing what chrome itself | |
binji
2012/09/17 21:54:06
nit: mimicking
| |
100 // does in chrome/app/client_util.cc:MakeMainDllLoader. | |
101 | |
102 // First look for the IRT alongside chrome.exe | |
103 string irt_basename = "nacl_irt_" + arch + ".nexe"; | |
104 irtPath_ = Path.Combine(Path.GetDirectoryName(chrome_path), irt_basename); | |
105 if (!File.Exists(irtPath_)) | |
106 { | |
107 // Next look for a folder alongside chrome.exe with the same name | |
108 // as the version embedded in chrome.exe. | |
109 if (file_version == null) | |
binji
2012/09/17 21:54:06
nit: the comment above makes it seem like this che
| |
110 { | |
111 if (!File.Exists(irtPath_)) | |
binji
2012/09/17 21:54:06
pull this common code out
| |
112 { | |
113 MessageBox.Show("NaCL IRT not found in chrome install.\nLooking for: " + irtPath_); | |
114 irtPath_ = null; | |
115 } | |
116 } | |
117 else | |
118 { | |
119 irtPath_ = Path.Combine(Path.GetDirectoryName(chrome_path), | |
120 file_version, irt_basename); | |
121 if (!File.Exists(irtPath_)) | |
122 { | |
123 MessageBox.Show("NaCL IRT not found in chrome install.\nLooking for: " + irtPath_); | |
124 irtPath_ = null; | |
125 } | |
126 } | |
127 } | |
128 | |
64 manifestPath_ = properties.ManifestPath; | 129 manifestPath_ = properties.ManifestPath; |
65 pluginAssembly_ = properties.PluginAssembly; | 130 pluginAssembly_ = properties.PluginAssembly; |
66 pluginProjectDirectory_ = properties.ProjectDirectory; | 131 pluginProjectDirectory_ = properties.ProjectDirectory; |
67 gdbPath_ = Path.Combine( | 132 gdbPath_ = Path.Combine( |
68 properties.SDKRootDirectory, | 133 properties.SDKRootDirectory, |
69 "toolchain", | 134 "toolchain", |
70 string.Concat("win_x86_", properties.ToolchainName), | 135 string.Concat("win_x86_", properties.ToolchainName), |
71 @"bin\x86_64-nacl-gdb.exe"); | 136 @"bin\x86_64-nacl-gdb.exe"); |
72 | 137 |
73 PluginFoundEvent += new EventHandler<PluginFoundEventArgs>(Attach); | 138 PluginFoundEvent += new EventHandler<PluginFoundEventArgs>(Attach); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
155 { | 220 { |
156 string manifestEscaped = manifestPath_.Replace("\\", "\\\\"); | 221 string manifestEscaped = manifestPath_.Replace("\\", "\\\\"); |
157 contents.AppendFormat("nacl-manifest {0}\n", manifestEscaped); | 222 contents.AppendFormat("nacl-manifest {0}\n", manifestEscaped); |
158 } | 223 } |
159 else | 224 else |
160 { | 225 { |
161 string pluginAssemblyEscaped = pluginAssembly_.Replace("\\", "\\\\"); | 226 string pluginAssemblyEscaped = pluginAssembly_.Replace("\\", "\\\\"); |
162 contents.AppendFormat("file \"{0}\"\n", pluginAssemblyEscaped); | 227 contents.AppendFormat("file \"{0}\"\n", pluginAssemblyEscaped); |
163 } | 228 } |
164 | 229 |
165 string irtPathEscaped = irtPath_.Replace("\\", "\\\\"); | 230 // irtPath_ could be null if the irt nexe was not found in the chrome |
166 contents.AppendFormat("nacl-irt {0}\n", irtPathEscaped); | 231 // install. |
232 if (irtPath_ != null) | |
233 { | |
234 string irtPathEscaped = irtPath_.Replace("\\", "\\\\"); | |
235 contents.AppendFormat("nacl-irt \"{0}\"\n", irtPathEscaped); | |
236 } | |
237 | |
167 contents.AppendFormat("target remote localhost:{0}\n", 4014); | 238 contents.AppendFormat("target remote localhost:{0}\n", 4014); |
168 | 239 |
169 // Insert breakpoints from Visual Studio project. | 240 // Insert breakpoints from Visual Studio project. |
170 if (Dte.Debugger.Breakpoints != null) | 241 if (Dte.Debugger.Breakpoints != null) |
171 { | 242 { |
172 foreach (Breakpoint bp in Dte.Debugger.Breakpoints) | 243 foreach (Breakpoint bp in Dte.Debugger.Breakpoints) |
173 { | 244 { |
174 if (!bp.Enabled) | 245 if (!bp.Enabled) |
175 { | 246 { |
176 continue; | 247 continue; |
(...skipping 30 matching lines...) Expand all Loading... | |
207 gdbProcess_.Start(); | 278 gdbProcess_.Start(); |
208 } | 279 } |
209 catch (Exception e) | 280 catch (Exception e) |
210 { | 281 { |
211 MessageBox.Show( | 282 MessageBox.Show( |
212 string.Format("NaCl-GDB Start Failed. {0}. Path: {1}", e.Message, gd bPath_)); | 283 string.Format("NaCl-GDB Start Failed. {0}. Path: {1}", e.Message, gd bPath_)); |
213 } | 284 } |
214 } | 285 } |
215 } | 286 } |
216 } | 287 } |
OLD | NEW |