开发者

Viewing the contents of a variable in debug mode? (Other than with break points)

开发者 https://www.devze.com 2023-03-05 18:30 出处:网络
I\'m writing a pr开发者_开发技巧ogram which calculates the Mandelbrot Set (and then renders it in OpenGL under Windows) in order to utilise parallel programming techniques.

I'm writing a pr开发者_开发技巧ogram which calculates the Mandelbrot Set (and then renders it in OpenGL under Windows) in order to utilise parallel programming techniques.

I'm supposed to demonstrate the use of threads, mutexes, and semaphores; so at the moment I'm calculating the set using multiple threads (splitting the set up horizontally) and timing each thread, then adding it to a total (the total is a global variable protected by a mutex)

I'd like to be able to view the total in debug mode - is there any relatively simple way to do this, other than rendering the total in the OpenGL window, or checking the contents of the variable with break points?


If you're on windows you could use OutputDebugString and view the results with a tool called DebugView. The downside is that it will print each value on a new line instead of updating it in place (which I guess is what you prefer).

If you want to view a value that will be updated in-place, you could probably use Performance Counters, but it's much more of a hassle: First, your program would have to implement a provider. And second, you'll have to write another program (a consumer) to track this counter and display it. But if you want maximum flexibility, this API is great, since it means many programs can observe the provider's counters, and they can, for example, be logged to a file and replayed or turned into a graph.


Easiest way is to somehow output a message to the debug stream and then view it using your IDE. Under windows you can use: OuputDebugString(LPCTSTR lpOutputString);


You should be able to read the global variable from the debugger. Have you tried?

0

精彩评论

暂无评论...
验证码 换一张
取 消