Jump to content

[UVM Connect] it works with std::vector, but __gnu_debug::vector fails.

Recommended Posts

Hi UVM Connect exports,

As title, druing developing, we sometimes hope to replace std::vector with __gnu_debug::vector for debugging purpose. However, this replacement makes uvmc to encounter a fatal error as below (with Questa 10.1)

** Fatal: (SIGABRT) Bad handle or reference


Fatal error in Module uvmc_pkg at ....uvmc2.2/src/connect/sv/uvmc_tlm1.sv line 36

is there any suggestion how to handle this? thanks!

insert a std to gnu_debuger converter could help, however, its not convinent any more.

Link to comment
Share on other sites

The uvmc_packer has several operator<< and operator>> methods defined for the built-in and std:: STL types. When you use an *extension* of std::vector, there is no longer a direct match with any of the provided methods, so the compiler tries to choose the best match. Unfortunately, the compiler chooses operator>>( T& ), as this matches better than operator>> (&std::vector<T> ), which requires conversion. Operator>> (T&) was meant to support enumeration types. It is dangerous because it matches just about anything that doesn't have a direct match with the other operator>> implementations.

To verify this is what is happening, please try the following.

(1) go to UVM Connect src/connect/sc/uvmc_packer.h, and comment out the implementation of operator>>(ENUM&), beginning with line 273:

/* // a little dangerous

template <typename ENUM> uvmc_packer& operator>> (ENUM& a) {

int enum_val;

(*this) >> enum_val;

a = reinterpret_cast<ENUM&>(enum_val);

return *this;



(2) Recompile the UVM Connect library and your user code. With the above removed from consideration, the compiler should now choose operator>> (&std:vector<T>) for your debug vectors and you should be fine.

There is a downside: you’ve removed built-in support for unpacking of enumeration types. If your transaction type has an enumeration field, you’ll now need to unpack through an temporary integer. For example, your do_unpack function in the converter changes from this:

template <>

uvmc_converter<Packet> …

static void do_unpack(Packet &t, uvmc_packer &packer) {


packer >> t.enum_field;

changes to this:

template <>

uvmc_converter<Packet> …

static void do_unpack(Packet &t, uvmc_packer &packer) {


uint32 tmp;

packer >> tmp;

t.enum_field = (enum_type)tmp;

You only need to do this in do_unpack. Packing (do_pack) works, as enums are automatically converted to integers when packing.

If you prefer support for STL debug over support of unpacking enums, then you can consider step 1 a permanent solution. If you need both, then you could copy uvmc_packer::operator>> and uvmc_packer::operator<< for the std::vector<T> and change the type to __gnu_debug::vector<T>. This will give the compiler a direct match, but you will only get debug support for vectors, not lists, maps, etc.

I tried to compile with –D_GLIBCXX_DEBUG, but that didn’t work (and I don’t have the bandwidth to figure out why). If it did work, you wouldn’t have to modify any user code, as this switch is supposed to compile in the debug versions of the STL types without need of STL extensions. Might be worth investigating on your end if you have the time and interest.


Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...