Wednesday, July 18, 2007

Adding a CodeWarrior breakpoint from inside Visual Studio


  • This macro uses CodeWarrior's COM interface to allow you to set a breakpoint from within Visual Studio

  • If you work exclusively on GameCube or PS2, you might want to map this macro to F9



Sub CWSetBreakpointHere()
Dim objSel As TextSelection = DTE.ActiveDocument.Selection
Dim objAnchor As VirtualPoint = objSel.AnchorPoint
Dim line As Long = objAnchor.Line
Dim fileName As String = DTE.ActiveDocument.FullName()

Dim CW = CreateObject("CodeWarrior.CodeWarriorApp")
CW.Debugger.SetBreakpointInSource(fileName, line, 0)

DTE.ExecuteCommand("Debug.ToggleBreakpoint")
MsgBox("Breakpoint set in CodeWarrior: " + vbCrLf + fileName.ToString() + ":" + line.ToString())
End Sub


Once I started working on a mix of GameCube and PC project files, I found it useful to map this next macro to F9. It looks at the name of the Visual Studio Project to determine whether to use the above CWSetBreakpointHere macro, or the normal Debug.ToggleBreakpoint command.

' Sets a breakpoint through CodeWarrior if the project name ends with wii or gamecube.
Sub MyToggleBreakpoint()
Dim ProjectName As String = ActiveSolutionProjects.GetValue(0).Name
If (ProjectName.ToLower().EndsWith("gamecube") Or ProjectName.ToLower().EndsWith("wii")) Then
CWSetBreakpointHere()
Else
DTE.ExecuteCommand("Debug.ToggleBreakpoint")
End If
End Sub

No comments: