Uvm_printer formatting corrupted due to complicated string

Hi,

I want to print an item which contains header fields and raw data in this format:

name type size value

field1 type size value
field2 type size value
field3 type size value

data-byte-0 data-byte-1 … data-byte-15
data-byte-16 data-byte-17 … data-byte-31

So, I implemented do_print() in this manner:

  function void some_obj::do_print(uvm_printer printer);
    string data_string;

    data_string = {data_string,  "\n--------------------------------------------------\n"};
    foreach(m_arr[ii]) begin
      if((ii != 0) && ((ii % 16) == 0)) begin
        data_string = {data_string, "\n"};
      end
      data_string = {data_string, $sformatf("%02x ", m_arr[ii])};
    end

    printer.print_int("m_hdr_f_1", m_hdr_f_1, $bits(m_hdr_f_1));
    printer.print_int("m_hdr_f_2", m_hdr_f_2, $bits(m_hdr_f_2));
    printer.print_int("m_hdr_f_3", m_hdr_f_3, $bits(m_hdr_f_3));
    printer.print_string("m_arr", data_string);
  endfunction : do_print

But this causes some weird side effects.

  1. If data is big, then so are the number of spaces after each header field.
  2. If data is big, then so are the number of dashes in the delimiter that the UVM printer adds.

Looking at the code of the table printer I understand that this is because my data string is counted as a single string that is very long.

What can I do to avoid this issue?
I thought about extending the table printer and overriding calculate_max_widths() but it is not virtual.

Thanks,

In reply to nimrodw:

There is a limit to what can be done with uvm_printer. It is quite easy to format an object exactly the way you want it using covert2string.