Franco Tiveron
Franco Tiveron

Reputation: 2904

"On-the-run" Debugging/Monitoring

Is there a way/system to debug/monitor code without stopping execution? In industrial automation control programming (PLC/PAC/DCS) it is possible to connect the debugger while the program is running, and see in the code editor the value of variables and expressions, without setting breakpoints or tracepoints.

As an example, let's have a F# multithreaded application, where code is executed in a continuous loop or triggered by timers. Is there a way to attach a debugger like Visual studio Debugger and see the values of variables and expressions (in the code editor or in a watch pane) WITHOUT interrupting the execution?

It doesn't matter if it's not synchronous, it's acceptable if the debugger/monitor does not capture all the code scans.

I am tasked to create an high level controller for a process plant and I would like to use C# or F# or even C++ with a managed or native application, instead of a PAC system. But being forced to interrupt execution to debug is a huge disadvantage in this kind of application.

UPDATE First of all thanks to all for their answer. Based on those answers, though, I realized that probably I need to reformulate my question as follows:

Is anyone aware of any library/framework/package/extension that allows to work with a native or managed application in windows or linux (C#, F# or C++) the exact same way as a PAC development platform, specifically:

1) Put the dev platform in "status" mode, where it shows automatically the runtime value for variables and expressions present in the code exceprt currently visible, without interrupting execution?

2) Create watch windows that show the runtime value of variables and expressions, again without interrupting execution?

Also, what I am looking for is something that (like any PAC platform) offers these features OUT OF THE BOX, without requiring any change in the application code (like adding log instructions).

Thank you in advance

UPDATE 2

It looks like there is something (see http://vsdevaids.webs.com/); does anyone know whether they are still available somewhere?

UPDATE 3

For those interested, I managed to download the last available release of VSDEVAIDS. I installed it and looks working, but it's pointless without a licence and couldn't find information on how to reach the author.

http://www.mediafire.com/file/vvdk2e0g6091r4h/VSDevAidsInstaller.msi If somebody has better luck, please let me know.

Upvotes: 0

Views: 169

Answers (4)

Franco Tiveron
Franco Tiveron

Reputation: 2904

I have been searching for this kind of features since quite a long time with no luck, unfortunately. Submitting the question to the StackOverflow community was sort of a "last resort", so now I'm ready to conclude that it doesn't exist.

VSDevAids (as @zzxyz pointed out) is not a solution, as it requires significant support from the application itself.

Pod cpu emulators (mentioned by @Neil) aka in-circuit emulators (ICE) and their evolutions are designed to thoroughly test the interaction between firmware and hardware, not so useful in high level programming (especially if managed like .NET).

Thanks for all contributions.

Upvotes: 0

Neil
Neil

Reputation: 11899

Many years ago (think 8 bit 6502/6809 days) you could buy (or usually rent, I seem to remember a figure of £40K to purchase one in the late 80s) a processor simulator, that would allow you replace the processor in your design with a pin compatible device that had a flying lead to the simulator box. this would allow things like capturing instructions/data leading up to a processor interrupt, or some other way of stopping the processor (even a 'push button to stop code' was possible). You could even step-backwards allowing you to see why an instruction or branch happened.

In these days of multi-core, nm-technology, I doubt there is such a thing.

Upvotes: 0

zzxyz
zzxyz

Reputation: 2981

With regards to your edited question, I can almost guarantee you that what you are looking for does not exist. Consequence-free debugging/monitoring of even moderate usefulness for production code with no prior effort? I'd have heard of it. Consider that both C++ and C# are extremely cross-platform. There are a few caveats:

There are almost certainly C++ compilers built for very specific hardware that do what you require. This hardware is likely to have very limited capabilities, and the compilers are likely to otherwise be inferior to their larger counterparts, such as gcc, clang, MSVC, to name a few.

Compile-time instrumentation can do what you require, although it affects speed and memory usage, and even stability, in my experience.

There ARE also frameworks that do what you require, but not without affecting your code. For example, if you are using WPF as your UI, it's possible to monitor anything directly related to the UI of your application. But...that's hardly a better solution than log4net.

Lastly, there are tools that can monitor EVERY system call your application makes for both Windows (procmon.exe/"Process Monitor" from SysInternals) and Linux (strace). There's very little you can't find out using these. That said, the ease of use is hardly what you're looking for, and strictly internal variables are still not going to be visible. Still might be something to consider if you know you'll be making system calls with the variables you're interested in and can set up adequate filtering.

Also, you should reconsider your "No impact on the code" requirement. There are .NET frameworks that can allow you to monitor an entire class merely by making a single function call during construction, or by deriving from a class in the framework. Many modern UIs are predicated on the UIs being able to be notified of any change to the data they are monitoring. Extensive effort has gone into making this as powerful and easy as possible. But it does require you to at least consider it when writing your code.

Upvotes: 0

pm100
pm100

Reputation: 50210

this is a normal requirement - needing instrumentation / diagnostic data from a production system. Its not really a debugger. Its usually one of the first things you should establish in your system design.

Not knowing your system at all its hard to say what you need but generally they fall into 2 categories

  1. human readable trace - something like log4net is what I would recommend

  2. machine readable counters etc. Say 'number of widget shaving in last pass',..... This one is harder to generalize, you could layer it onto log4net too. Or invent your own pipe

Upvotes: 2

Related Questions