Alexander Shishenko
Alexander Shishenko

Reputation: 960

Get variables from Visual Studio debugger

I received a task to visualize an array from program, that is being debugged in VS. Is there any way to connect to Visual Studio debugging session from external program and get data from it?

Upvotes: 3

Views: 600

Answers (2)

Omer Raviv
Omer Raviv

Reputation: 11827

Theoretically, you could use the Debugger.GetExpression API to read the values from the debugger and send them to MATLAB, but if we're talking about a relatively large amount of data (such as a large matrix or vector), the chances of this solution having reasonable performance are rather slim.

An easier solution could be to just take advantage of the fact you can call your own methods from the debugger - define a method in your code that sends the data to MATLAB, make sure it's defined in the same place where the data-structure you're serializing is defined (so that the debugger won't complain about accessibility issues), and then just execute that method from the Watch or Immediate windows.

Upvotes: 2

stijn
stijn

Reputation: 35921

This is not exactly from an external program, but useful nonetheless: msdn docs and an example (or sample for C++). Now if you really want an extarnal program to access the array, you can write a custom visualizer that does not visualize anything but sends the data over a socket/pipe to another program (I once used this principle to get arrays with audio data displayed in Labview during debugging session, very handy).

Upvotes: 0

Related Questions