Question

I'm using Visual Studio 2008 to debug some CUDA code (NSight v3) I'm working on.

I've noticed several nice features of the VS2008 debugger, such as the ability to only break every N times or after N times using the "hitcount" feature. I've also noticed the ability to run macros or print out a message instead of breaking. However, neither of these features appear to work with NSight debugger (and as much is noted on the NVidia website for NSight v1.5).

Using GDB, I could simply type "continue 300" to continue 300 times. This is very useful to get to the 300th iteration of a loop. How do I do this in Visual Studio 2008? Note that I don't want to break at the Nth time a certain breakpoint is hit, I want to to break at the Nth time ANY breakpoint is hit.

What would also solve my problem would be the ability to print out a particular variable from within a loop for any one (but only one!) CUDA thread. Since the debugger is nice enough to not jump around between threads, I could accomplish this using a GDB script like this:

c
print my_value
c
print my_value
... N - 2 more times

which I would obviously produce using Python or bash or something.

Since apparently VS2008 relies on the underlying debugger to implement things like hit count or to print messages (as opposed to just implementing it at the top-level), I don't immediately see how to accomplish this.

Était-ce utile?

La solution

Turns out you can create a macro to do this! Here's one to simply skip 5 times:

Option Strict Off
Option Explicit Off
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports System.Diagnostics

Public Module RecordingModule


    Sub ClickContinue()
        DTE.Debugger.Go(True)
        DTE.Debugger.Go(True)
        DTE.Debugger.Go(True)
        DTE.Debugger.Go(True)
        DTE.Debugger.Go(True)
    End Sub
End Module

And this one will prompt you for a number, and then continue that many times.

Option Strict Off
Option Explicit Off
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports System.Diagnostics

Public Module RecordingModule


    Sub ClickContinue()
        numToSkip = InputBox("How many times to continue?")
        For i = 0 To CInt(numToSkip)
            DTE.Debugger.Go(True)
        Next

    End Sub
End Module

I got these by using the "Record Macro" feature and modifying the result (slightly). A lot more work than continue N, eh?

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top