how to save the debugging state at matlab?

10 Ansichten (letzte 30 Tage)
敬 杨
敬 杨 am 28 Mai 2025
Bearbeitet: Matt J am 29 Mai 2025
Hi everyone,
I'm debugging a computational program on a server. This program rarely encounters errors, but when it does, the error occurs deep within a chain of function calls. I would like to save the complete state at the moment the error occurs, so that I can load this state on my local PC and debug it more conveniently.
Currently, after an error occurs on the server, I can save the variables at each level of the function call stack. However, this approach does not allow me to load and debug the state on my local PC, making the process very inconvenient.
Is there a way in MATLAB to save the full debugging state? Or are there any alternative methods to address this issue?

Antworten (1)

Walter Roberson
Walter Roberson am 29 Mai 2025
Generally speaking, it is not possible to save the full debugging state.
Generally speaking, the current state of variables might include objects that cannot effectively be serialized. For example:
  • tcp sockets
  • COM port or .NET state
  • open files
  • java objects
  • memory pointers to C or C++ objects
Generally speaking, in order to be able to approach what you are hoping for, you need to structure your code in a way that takes "snapshots" of important variables, together with a way that can reconstruct the state of the variables given a snapshot. Then have your code take snapshots periodically, and take a snapshot at the time the error occurs, and compare the state of the two most recent snapshots to try to debug the problem.

Tags

Produkte


Version

R2024b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by