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.Collections.Generic; | 8 using System.Collections.Generic; |
9 using System.IO; | 9 using System.IO; |
10 using System.Linq; | 10 using System.Linq; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 /// Path to the actual plug-in assembly. | 57 /// Path to the actual plug-in assembly. |
58 /// </summary> | 58 /// </summary> |
59 private string pluginAssembly_; | 59 private string pluginAssembly_; |
60 | 60 |
61 /// <summary> | 61 /// <summary> |
62 /// Path to the NaCl IRT. | 62 /// Path to the NaCl IRT. |
63 /// </summary> | 63 /// </summary> |
64 private string irtPath_; | 64 private string irtPath_; |
65 | 65 |
66 /// <summary> | 66 /// <summary> |
| 67 /// Path to the project's nmf file. |
| 68 /// </summary> |
| 69 private string manifestPath_; |
| 70 |
| 71 /// <summary> |
67 /// Root directory of the installed NaCl SDK. | 72 /// Root directory of the installed NaCl SDK. |
68 /// </summary> | 73 /// </summary> |
69 private string sdkRootDirectory_; | 74 private string sdkRootDirectory_; |
70 | 75 |
71 /// <summary> | 76 /// <summary> |
72 /// If debugging a .nexe this is the nacl-gdb process object. | 77 /// If debugging a .nexe this is the nacl-gdb process object. |
73 /// </summary> | 78 /// </summary> |
74 private System.Diagnostics.Process gdbProcess_; | 79 private System.Diagnostics.Process gdbProcess_; |
75 | 80 |
76 /// <summary> | 81 /// <summary> |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 /// <summary> | 187 /// <summary> |
183 /// Initializes the PluginDebuggerHelper with the current project settings | 188 /// Initializes the PluginDebuggerHelper with the current project settings |
184 /// If project settings are unsupported for NaCl/Pepper debugging then | 189 /// If project settings are unsupported for NaCl/Pepper debugging then |
185 /// the object is not initialized and we return false. | 190 /// the object is not initialized and we return false. |
186 /// </summary> | 191 /// </summary> |
187 /// <returns>True if the object is successfully initialized, false otherwise
.</returns> | 192 /// <returns>True if the object is successfully initialized, false otherwise
.</returns> |
188 public bool LoadProjectSettings() | 193 public bool LoadProjectSettings() |
189 { | 194 { |
190 isProperlyInitialized_ = false; | 195 isProperlyInitialized_ = false; |
191 | 196 |
| 197 string platformToolset; |
| 198 |
192 // We require that there is only a single start-up project. | 199 // We require that there is only a single start-up project. |
193 // If multiple start-up projects are specified then we use the first and | 200 // If multiple start-up projects are specified then we use the first and |
194 // leave a warning message in the Web Server output pane. | 201 // leave a warning message in the Web Server output pane. |
195 Array startupProjects = dte_.Solution.SolutionBuild.StartupProjects as Arr
ay; | 202 Array startupProjects = dte_.Solution.SolutionBuild.StartupProjects as Arr
ay; |
196 if (startupProjects == null || startupProjects.Length == 0) | 203 if (startupProjects == null || startupProjects.Length == 0) |
197 { | 204 { |
198 throw new ArgumentOutOfRangeException("startupProjects.Length"); | 205 throw new ArgumentOutOfRangeException("startupProjects.Length"); |
199 } | 206 } |
200 else if (startupProjects.Length > 1) | 207 else if (startupProjects.Length > 1) |
201 { | 208 { |
(...skipping 24 matching lines...) Expand all Loading... |
226 } | 233 } |
227 | 234 |
228 // We only support certain project types (e.g. C/C++ projects). Otherwise
we fail. | 235 // We only support certain project types (e.g. C/C++ projects). Otherwise
we fail. |
229 // If supported, extract necessary information from specific project type. | 236 // If supported, extract necessary information from specific project type. |
230 if (Utility.IsVisualCProject(startProject)) | 237 if (Utility.IsVisualCProject(startProject)) |
231 { | 238 { |
232 VCConfiguration config = Utility.GetActiveVCConfiguration(startProject); | 239 VCConfiguration config = Utility.GetActiveVCConfiguration(startProject); |
233 IVCRulePropertyStorage general = config.Rules.Item("ConfigurationGeneral
"); | 240 IVCRulePropertyStorage general = config.Rules.Item("ConfigurationGeneral
"); |
234 VCLinkerTool linker = config.Tools.Item("VCLinkerTool"); | 241 VCLinkerTool linker = config.Tools.Item("VCLinkerTool"); |
235 VCProject vcproj = (VCProject)startProject.Object; | 242 VCProject vcproj = (VCProject)startProject.Object; |
| 243 |
236 sdkRootDirectory_ = general.GetEvaluatedPropertyValue("VSNaClSDKRoot"); | 244 sdkRootDirectory_ = general.GetEvaluatedPropertyValue("VSNaClSDKRoot"); |
| 245 platformToolset = general.GetEvaluatedPropertyValue("PlatformToolset"); |
237 pluginOutputDirectory_ = config.Evaluate(config.OutputDirectory); | 246 pluginOutputDirectory_ = config.Evaluate(config.OutputDirectory); |
238 pluginAssembly_ = config.Evaluate(linker.OutputFile); | 247 pluginAssembly_ = config.Evaluate(linker.OutputFile); |
239 pluginProjectDirectory_ = vcproj.ProjectDirectory; // Macros not allowe
d here. | 248 pluginProjectDirectory_ = vcproj.ProjectDirectory; // Macros not allowe
d here. |
| 249 |
| 250 if (projectPlatformType_ == ProjectPlatformType.NaCl) |
| 251 { |
| 252 irtPath_ = general.GetEvaluatedPropertyValue("NaClIrtPath"); |
| 253 manifestPath_ = general.GetEvaluatedPropertyValue("NaClManifestPath"); |
| 254 } |
240 } | 255 } |
241 else | 256 else |
242 { | 257 { |
243 return false; | 258 return false; |
244 } | 259 } |
245 | 260 |
246 if (string.IsNullOrEmpty(sdkRootDirectory_)) | 261 if (string.IsNullOrEmpty(sdkRootDirectory_)) |
247 { | 262 { |
248 MessageBox.Show( | 263 MessageBox.Show( |
249 string.Format(Strings.SDKPathNotSetFormat, Strings.SDKPathEnvironmen
tVariable)); | 264 string.Format(Strings.SDKPathNotSetFormat, Strings.SDKPathEnvironmen
tVariable)); |
250 return false; | 265 return false; |
251 } | 266 } |
252 | 267 |
253 sdkRootDirectory_ = sdkRootDirectory_.TrimEnd("/\\".ToArray<char>()); | 268 sdkRootDirectory_ = sdkRootDirectory_.TrimEnd("/\\".ToArray<char>()); |
254 | 269 |
255 // TODO(tysand): Add user option to specify this. | 270 // TODO(tysand): Add user option to specify this. |
256 int webServerPort = 5103; | 271 int webServerPort = 5103; |
257 webServerExecutable_ = "python.exe"; | 272 webServerExecutable_ = "python.exe"; |
258 webServerArguments_ = string.Format( | 273 webServerArguments_ = string.Format( |
259 "{0}\\examples\\httpd.py --no_dir_check {1}", | 274 "{0}\\examples\\httpd.py --no_dir_check {1}", |
260 sdkRootDirectory_, | 275 sdkRootDirectory_, |
261 webServerPort); | 276 webServerPort); |
262 | 277 |
263 // TODO(tysand): Update this to nacl-gdb when it is ready. Should be able
to remove irtPath_. | 278 gdbPath_ = Path.Combine( |
264 gdbPath_ = sdkRootDirectory_ + @"\gdb-remote-x86-64\gdb.exe"; | 279 sdkRootDirectory_, "toolchain", platformToolset, @"bin\x86_64-nacl-gdb
.exe"); |
265 irtPath_ = sdkRootDirectory_ + @"\tools\irt_x86_64.nexe"; | |
266 | 280 |
267 debuggedChromeMainProcess_ = null; | 281 debuggedChromeMainProcess_ = null; |
268 | 282 |
269 isProperlyInitialized_ = true; | 283 isProperlyInitialized_ = true; |
270 return true; | 284 return true; |
271 } | 285 } |
272 | 286 |
273 /// <summary> | 287 /// <summary> |
274 /// This function should be called to start the PluginDebuggerHelper functio
nality. | 288 /// This function should be called to start the PluginDebuggerHelper functio
nality. |
275 /// </summary> | 289 /// </summary> |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 /// <summary> | 436 /// <summary> |
423 /// Attaches the NaCl GDB debugger to the NaCl plug-in process. Handles loa
ding symbols | 437 /// Attaches the NaCl GDB debugger to the NaCl plug-in process. Handles loa
ding symbols |
424 /// and breakpoints from Visual Studio. | 438 /// and breakpoints from Visual Studio. |
425 /// </summary> | 439 /// </summary> |
426 /// <param name="src">The parameter is not used.</param> | 440 /// <param name="src">The parameter is not used.</param> |
427 /// <param name="args"> | 441 /// <param name="args"> |
428 /// Contains the process ID to attach to, unused since debug stub is already
attached. | 442 /// Contains the process ID to attach to, unused since debug stub is already
attached. |
429 /// </param> | 443 /// </param> |
430 private void AttachNaClGDB(object src, PluginFoundEventArgs args) | 444 private void AttachNaClGDB(object src, PluginFoundEventArgs args) |
431 { | 445 { |
432 // NOTE: The settings listed here are a placeholder until nacl-gdb is read
y. | |
433 // Specifically, 'set architecture' and 'add-symbol-file' calls. See
TODO comments. | |
434 | |
435 // Clean up any pre-existing GDB process (can happen if user reloads page)
. | 446 // Clean up any pre-existing GDB process (can happen if user reloads page)
. |
436 KillGDBProcess(); | 447 KillGDBProcess(); |
437 | 448 |
438 gdbInitFileName_ = Path.GetTempFileName(); | 449 gdbInitFileName_ = Path.GetTempFileName(); |
439 string projectDir = pluginProjectDirectory_.TrimEnd('\\'); | |
440 string pluginAssemblyEscaped = pluginAssembly_.Replace("\\", "\\\\"); | 450 string pluginAssemblyEscaped = pluginAssembly_.Replace("\\", "\\\\"); |
441 string irtPathEscaped = irtPath_.Replace("\\", "\\\\"); | 451 string irtPathEscaped = irtPath_.Replace("\\", "\\\\"); |
442 | 452 |
443 // Create the initialization file to read in on GDB start. | 453 // Create the initialization file to read in on GDB start. |
444 StringBuilder contents = new StringBuilder(); | 454 StringBuilder contents = new StringBuilder(); |
445 | 455 |
446 // TODO(tysand): Allow user setting for debug stub port (currently 4014). | 456 if (!string.IsNullOrEmpty(manifestPath_)) |
447 contents.AppendFormat("target remote localhost:{0}", 4014); | 457 { |
448 contents.AppendLine(); | 458 string manifestEscaped = manifestPath_.Replace("\\", "\\\\"); |
| 459 contents.AppendFormat("nacl-manifest {0}\n", manifestEscaped); |
| 460 } |
| 461 else |
| 462 { |
| 463 contents.AppendFormat("file \"{0}\"\n", pluginAssemblyEscaped); |
| 464 } |
449 | 465 |
450 // TODO(tysand): Nacl-gdb should detect this automatically making this cal
l unnecessary. | 466 contents.AppendFormat("nacl-irt {0}\n", irtPathEscaped); |
451 contents.Append("set architecture i386:x86-64"); | 467 contents.AppendFormat("target remote localhost:{0}\n", 4014); |
452 contents.AppendLine(); | |
453 contents.AppendFormat("cd {0}", projectDir); | |
454 contents.AppendLine(); | |
455 | |
456 // TODO(tysand): Nacl-gdb should handle the offset automatically. Remove 0
xC00020080. | |
457 contents.AppendFormat("add-symbol-file \"{0}\" 0xC00020080", pluginAssembl
yEscaped); | |
458 contents.AppendLine(); | |
459 | |
460 // TODO(tysand): Nacl-gdb should handle loading the irt automatically. Rem
ove this line. | |
461 contents.AppendFormat("add-symbol-file \"{0}\" 0xC0fc00080", irtPathEscape
d); | |
462 contents.AppendLine(); | |
463 | 468 |
464 // Insert breakpoints from Visual Studio project. | 469 // Insert breakpoints from Visual Studio project. |
465 foreach (Breakpoint bp in dte_.Debugger.Breakpoints) | 470 foreach (Breakpoint bp in dte_.Debugger.Breakpoints) |
466 { | 471 { |
467 if (bp.Enabled && | 472 if (bp.Enabled && |
468 bp.LocationType == dbgBreakpointLocationType.dbgBreakpointLocationTy
peFile) | 473 bp.LocationType == dbgBreakpointLocationType.dbgBreakpointLocationTy
peFile) |
469 { | 474 { |
470 contents.AppendFormat("b {0}:{1}", Path.GetFileName(bp.File), bp.FileL
ine); | 475 contents.AppendFormat("b {0}:{1}", Path.GetFileName(bp.File), bp.FileL
ine); |
471 contents.AppendLine(); | 476 contents.AppendLine(); |
472 } | 477 } |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
575 this.ProcessID = pid; | 580 this.ProcessID = pid; |
576 } | 581 } |
577 | 582 |
578 /// <summary> | 583 /// <summary> |
579 /// Gets or sets process ID of the found plug-in. | 584 /// Gets or sets process ID of the found plug-in. |
580 /// </summary> | 585 /// </summary> |
581 public uint ProcessID { get; set; } | 586 public uint ProcessID { get; set; } |
582 } | 587 } |
583 } | 588 } |
584 } | 589 } |
OLD | NEW |