Breakpointing/triggering when a sequence is killed

Hi,
In some programming languages (like C++), there is a “destructor” function called when an object is destroyed.
SV doesn’t have destructors.
So how can one detect when an object has been destroyed, so it’s possible to identify what line of code is doing the destruction?
In particular, for sequences.

If there isn’t such a current capability, I’d request that SV be enhanced so that there was a destructor function that was called. The default would normally be to do nothing (as SV automatically does garbage collection), but it would be useful to track object lifetimes, during debug of what was causing premature object destruction, maintaining lists of objects in existence, etc.

There also times in C++ when it can be important to prevent destruction of an object until some condition is met. For example - that a file is completely written, or simply that the cause and time of destruction is logged.

Thanks,
Erik

In reply to erik.k.jessen@raytheon.com:

Automatic memory management and destructors don’t mix. And what you are asking for is closer to JAVA’s finalize() method. But that still won’t help with what you are looking for because there’s no guaranteed point where that method would be called, except by the end of simulation.

The debugging topic is very tool specific, and this forum is not setup for those kinds of issue. Contact you vendor for tips on how you can visualize sequences running on sequencer and setting breakpoint in the UVM.

In reply to dave_59:

Hi Dave,
Yeah, I know SV does automatic garbage collection. But I was really, really hoping that I’d missed something in the LRM, and that there actually was something defined in the LRM that I’d missed. Which is why I posted here.

I also know that even if the standards committee decided to move on this as fast as possible, it’d still be years before something was defined, let alone implemented. So I’m also talking to my vendor, about what can be done within the tools.

Thanks!
Erik

In reply to erik.k.jessen@raytheon.com:

Dave:
A following up question. let us say I have below psedo code, When is the object – item destroyed? end of task? end of simulation? exit of forever block?


   class montior;
     task run_phase();
        .......
       forever begin
          //other statements . cb.....
          item = seq_item create();
          aport.write(item);
       end
        .........
     endtask
endclass

Thanks

In reply to VE:

It is destroyed no earlier then when no class variable exists to reference it. Since you are sending the handle through an analysis port, that handle winds up in another component like a scoreboard or coverage collector. You need to follow the path of the handle to answer that question.

In reply to dave_59:

In reply to VE:
It is destroyed no earlier then when no class variable exists to reference it. Since you are sending the handle through an analysis port, that handle winds up in another component like a scoreboard or coverage collector. You need to follow the path of the handle to answer that question.

Thanks Dave.

Can I say that for each iteration of forever loop, the memory space which class variable item pointing to
“is destroyed no earlier then when no class variable exists to reference it. Since you are sending the handle through an analysis port, that handle winds up in another component like a scoreboard or coverage collector. You need to follow the path of the handle to answer that question.”

Thanks

In reply to VE:

Sure.