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 using System.Diagnostics; |
12 | 12 |
13 using EnvDTE; | 13 using EnvDTE; |
14 using EnvDTE80; | 14 using EnvDTE80; |
15 | 15 |
16 /// <summary> | 16 /// <summary> |
17 /// 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. |
18 /// </summary> | 18 /// </summary> |
19 public class PluginDebuggerGDB : PluginDebuggerBase | 19 public class PluginDebuggerGDB : PluginDebuggerBase |
20 { | 20 { |
21 /// <summary> | 21 /// <summary> |
22 /// Path to the actual plug-in assembly. | 22 /// Path to the actual nexe. |
23 /// </summary> | 23 /// </summary> |
24 private string pluginAssembly_; | 24 private string targetNexe_; |
25 | 25 |
26 /// <summary> | 26 /// <summary> |
27 /// Directory of the plug-in project we are debugging. | 27 /// Directory of the project we are debugging. |
28 /// </summary> | 28 /// </summary> |
29 private string pluginProjectDirectory_; | 29 private string projectDirectory_; |
30 | 30 |
31 /// <summary> | 31 /// <summary> |
32 /// Path to the NaCl IRT. | 32 /// Path to the NaCl IRT. |
33 /// </summary> | 33 /// </summary> |
34 private string irtPath_; | 34 private string irtPath_; |
35 | 35 |
36 /// <summary> | 36 /// <summary> |
37 /// Path to the project's nmf file. | 37 /// Path to the project's nmf file. |
38 /// </summary> | 38 /// </summary> |
39 private string manifestPath_; | 39 private string manifestPath_; |
(...skipping 14 matching lines...) Expand all Loading... |
54 private string gdbInitFileName_; | 54 private string gdbInitFileName_; |
55 | 55 |
56 /// <summary> | 56 /// <summary> |
57 /// Constructs the PluginDebuggerHelper. | 57 /// Constructs the PluginDebuggerHelper. |
58 /// </summary> | 58 /// </summary> |
59 /// <param name="dte">Automation object from Visual Studio.</param> | 59 /// <param name="dte">Automation object from Visual Studio.</param> |
60 /// <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> |
61 public PluginDebuggerGDB(DTE2 dte, PropertyManager properties) | 61 public PluginDebuggerGDB(DTE2 dte, PropertyManager properties) |
62 : base(dte, properties) | 62 : base(dte, properties) |
63 { | 63 { |
64 string arch = "i686"; | 64 string arch = "i686"; |
65 if (Environment.Is64BitOperatingSystem) | 65 if (Environment.Is64BitOperatingSystem) |
66 { | 66 { |
67 arch = "x86_64"; | 67 arch = "x86_64"; |
68 } | 68 } |
69 | 69 |
70 if (properties.TargetArchitecture != arch) | 70 if (!properties.IsPNaCl()) |
71 { | 71 { |
72 MessageBox.Show(string.Format("Debugging of {0} NaCl modules is not poss
ible on this system ({1}).", | 72 if (properties.TargetArchitecture != arch) |
73 properties.TargetArchitecture, arch)); | 73 { |
74 } | 74 MessageBox.Show(string.Format("Debugging of {0} NaCl modules is
not possible on this system ({1}).", |
| 75 properties.TargetArchitecture, arc
h)); |
| 76 } |
| 77 } |
75 | 78 |
76 // check chrome version | 79 // check chrome version |
77 string chrome_path = properties.LocalDebuggerCommand; | 80 string chrome_path = properties.LocalDebuggerCommand; |
78 FileVersionInfo version_info = FileVersionInfo.GetVersionInfo(chrome_path)
; | 81 FileVersionInfo version_info = FileVersionInfo.GetVersionInfo(chrome_path)
; |
79 string file_version = version_info.FileVersion; | 82 string file_version = version_info.FileVersion; |
80 if (file_version != null) | 83 if (file_version != null) |
81 { | 84 { |
82 string major_version = file_version.Split('.')[0]; | 85 string major_version = file_version.Split('.')[0]; |
83 int major_version_int = 0; | 86 int major_version_int = 0; |
84 try | 87 try |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 file_version, irt_basename); | 123 file_version, irt_basename); |
121 if (!File.Exists(irtPath_)) | 124 if (!File.Exists(irtPath_)) |
122 { | 125 { |
123 MessageBox.Show("NaCl IRT not found in chrome install.\nLooking for:
" + irtPath_); | 126 MessageBox.Show("NaCl IRT not found in chrome install.\nLooking for:
" + irtPath_); |
124 irtPath_ = null; | 127 irtPath_ = null; |
125 } | 128 } |
126 } | 129 } |
127 } | 130 } |
128 | 131 |
129 manifestPath_ = properties.ManifestPath; | 132 manifestPath_ = properties.ManifestPath; |
130 pluginAssembly_ = properties.PluginAssembly; | 133 targetNexe_ = properties.PluginAssembly; |
131 pluginProjectDirectory_ = properties.ProjectDirectory; | 134 |
| 135 if (properties.IsPNaCl()) |
| 136 { |
| 137 string basename = Path.GetFileNameWithoutExtension(targetNexe_); |
| 138 targetNexe_ = Path.Combine(Path.GetDirectoryName(targetNexe_), |
| 139 basename + "_" + arch + ".nexe"); |
| 140 |
| 141 if (!File.Exists(targetNexe_)) |
| 142 { |
| 143 MessageBox.Show( |
| 144 string.Format("Failed to find nexe to debug: {0}", targetNexe_))
; |
| 145 } |
| 146 } |
| 147 |
| 148 projectDirectory_ = properties.ProjectDirectory; |
132 gdbPath_ = Path.Combine( | 149 gdbPath_ = Path.Combine( |
133 properties.SDKRootDirectory, | 150 properties.SDKRootDirectory, |
134 "toolchain", | 151 "toolchain", |
135 string.Concat("win_x86_", properties.ToolchainName), | 152 string.Concat("win_x86_", properties.ToolchainName), |
136 @"bin\x86_64-nacl-gdb.exe"); | 153 @"bin\x86_64-nacl-gdb.exe"); |
137 | 154 |
138 Debug.WriteLine("Found gdb: {0}", gdbPath_); | 155 Debug.WriteLine("Found gdb: {0}", gdbPath_); |
139 PluginFoundEvent += new EventHandler<PluginFoundEventArgs>(Attach); | 156 PluginFoundEvent += new EventHandler<PluginFoundEventArgs>(Attach); |
140 } | 157 } |
141 | 158 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 gdbInitFileName_ = Path.GetTempFileName(); | 234 gdbInitFileName_ = Path.GetTempFileName(); |
218 StringBuilder contents = new StringBuilder(); | 235 StringBuilder contents = new StringBuilder(); |
219 | 236 |
220 if (!string.IsNullOrEmpty(manifestPath_)) | 237 if (!string.IsNullOrEmpty(manifestPath_)) |
221 { | 238 { |
222 string manifestEscaped = manifestPath_.Replace("\\", "\\\\"); | 239 string manifestEscaped = manifestPath_.Replace("\\", "\\\\"); |
223 contents.AppendFormat("nacl-manifest {0}\n", manifestEscaped); | 240 contents.AppendFormat("nacl-manifest {0}\n", manifestEscaped); |
224 } | 241 } |
225 else | 242 else |
226 { | 243 { |
227 string pluginAssemblyEscaped = pluginAssembly_.Replace("\\", "\\\\"); | 244 string pluginAssemblyEscaped = targetNexe_.Replace("\\", "\\\\"); |
228 contents.AppendFormat("file \"{0}\"\n", pluginAssemblyEscaped); | 245 contents.AppendFormat("file \"{0}\"\n", pluginAssemblyEscaped); |
229 } | 246 } |
230 | 247 |
231 // irtPath_ could be null if the irt nexe was not found in the chrome | 248 // irtPath_ could be null if the irt nexe was not found in the chrome |
232 // install. | 249 // install. |
233 if (irtPath_ != null) | 250 if (irtPath_ != null) |
234 { | 251 { |
235 string irtPathEscaped = irtPath_.Replace("\\", "\\\\"); | 252 string irtPathEscaped = irtPath_.Replace("\\", "\\\\"); |
236 contents.AppendFormat("nacl-irt \"{0}\"\n", irtPathEscaped); | 253 contents.AppendFormat("nacl-irt \"{0}\"\n", irtPathEscaped); |
237 } | 254 } |
(...skipping 30 matching lines...) Expand all Loading... |
268 contents.AppendLine("continue"); | 285 contents.AppendLine("continue"); |
269 File.WriteAllText(gdbInitFileName_, contents.ToString()); | 286 File.WriteAllText(gdbInitFileName_, contents.ToString()); |
270 | 287 |
271 // Start NaCl-GDB. | 288 // Start NaCl-GDB. |
272 try | 289 try |
273 { | 290 { |
274 gdbProcess_ = new System.Diagnostics.Process(); | 291 gdbProcess_ = new System.Diagnostics.Process(); |
275 gdbProcess_.StartInfo.UseShellExecute = true; | 292 gdbProcess_.StartInfo.UseShellExecute = true; |
276 gdbProcess_.StartInfo.FileName = gdbPath_; | 293 gdbProcess_.StartInfo.FileName = gdbPath_; |
277 gdbProcess_.StartInfo.Arguments = string.Format("-x {0}", gdbInitFileNam
e_); | 294 gdbProcess_.StartInfo.Arguments = string.Format("-x {0}", gdbInitFileNam
e_); |
278 gdbProcess_.StartInfo.WorkingDirectory = pluginProjectDirectory_; | 295 gdbProcess_.StartInfo.WorkingDirectory = projectDirectory_; |
279 gdbProcess_.Start(); | 296 gdbProcess_.Start(); |
280 } | 297 } |
281 catch (Exception e) | 298 catch (Exception e) |
282 { | 299 { |
283 MessageBox.Show( | 300 MessageBox.Show( |
284 string.Format("NaCl-GDB Start Failed. {0}. Path: {1}", e.Message, gd
bPath_)); | 301 string.Format("NaCl-GDB Start Failed. {0}. Path: {1}", e.Message, gd
bPath_)); |
285 } | 302 } |
286 } | 303 } |
287 } | 304 } |
288 } | 305 } |
OLD | NEW |