Is it possible to print the contxt of a uvm_object?

I’m using the contxt field of create() to override certain instances of a uvm_object, but not others. I’ve been able to get that working, but haven’t figured out how to check the context of an object.

For example, say I create an object in this manner:

 tom = CatObject::type_id::create(.name("tom"), .contxt("House"));

Is there any way to check what the contxt of tom is later? get_full_name() only prints the name of the uvm_object. If I can override the type based on contxt, that information must be stored somewhere. How do I print it?

In reply to jms8:

The reason for this is because uvm_objects are designed to be passed from one component to another, such as sequence_items which are created in a sequence and then passed to a driver.

Since the objects are passed around and don’t have a parent, their context would dynamically change based upon where they are accessed from. Therefore, the full name is just the object name with no parental hierarchy.

I hate to be argumentative, but you did not answer my question. I actually already know why get_full_name() does not include the contxt for uvm_objects.

What I want to know is, is there any way to print the contxt of a uvm_object, since it is clear it is recorded somewhere. If it’s not possible/ you don’t know, just tell me that.

In reply to jms8:
Your assumption is incorrect - the context is not recorded anywhere. The context is used to help make the decision about what override to apply. You only get see the result of that decision, not the factors that led to it.

You can use the virtual methods get_object_type() or get_type_name() to help find out what the resulting typo is.

if (tom.get_object_type() == CatObject::get_type())
  // was not overridden
else if (tom.get_object_type() == DogObject::get_type())
  // was overriden with a DogObject
else ...

In reply to dave_59:

Ok I think you answered my question. It seems like the only way to check that I set the contxt of the object successfully is to override it and then check the type of the object. That makes sense.

However I want to triple check my understanding of “context is not recorded anywhere”. Does this mean when I create a uvm_object with a contxt, it uses that contxt to check for any overrides, then throws that information away? What about the parent field for uvm_objects that are not sequences? If I set that when creating a uvm_object, does that information also get used to check for overrides and then gets thrown away after the object has been created?

This is very interesting. Thanks for you help!

In reply to jms8:
Only the name argument gets passed to umm_object through its constructor, new(); there is no parent field inside umm_object. If you really want a good understanding, check the source code for uvm_object_registry::create()