cgen_bi_endian_cpu::end_trace

Dave Brolley <[email protected]>
Newsgroups gmane.comp.emulators.sid.devel
Organization Red Hat Canada, Ltd
Message-ID <[email protected]>
I've comitted the attached patch (approved by fche)  which addresses a 
problem when building sid with recent gcc compilers. The problem is that

    this->trace_stream << endl;

does not call

   template <typename T>
    basic_cpu::cpu_trace_stream& operator<< 
(basic_cpu::cpu_trace_stream& s, T t)

as expected. As a result, sid's tracing output comes out all on one line 
when tracing is to cout. The patch defines a new method of 
basic_cpu::cpu_trace_stream which can be explicitely called to avoid the 
ambiguity.

The patch also changes an unnecessary dynamic_cast to a static_cast. 
Something we noticed while investigating.

Dave
sidtrace.patch.txt (text/plain, 1.6 KB)
Index: sid/component/cgen-cpu/compCGEN.cxx
===================================================================
RCS file: /cvs/src/src/sid/component/cgen-cpu/compCGEN.cxx,v
retrieving revision 1.11
diff -c -p -r1.11 compCGEN.cxx
*** sid/component/cgen-cpu/compCGEN.cxx	15 Jan 2003 20:04:57 -0000	1.11
--- sid/component/cgen-cpu/compCGEN.cxx	21 Aug 2003 21:20:25 -0000
*************** cgen_bi_endian_cpu::begin_trace (PCADDR 
*** 250,256 ****
  void
  cgen_bi_endian_cpu::end_trace ()
  {
!   this->trace_stream << endl;
  }
  
  // Counter support
--- 250,256 ----
  void
  cgen_bi_endian_cpu::end_trace ()
  {
!   trace_stream.end_line ();
  }
  
  // Counter support
Index: sid/include/sidcpuutil.h
===================================================================
RCS file: /cvs/src/src/sid/include/sidcpuutil.h,v
retrieving revision 1.25
diff -c -p -r1.25 sidcpuutil.h
*** sid/include/sidcpuutil.h	16 Apr 2003 18:15:16 -0000	1.25
--- sid/include/sidcpuutil.h	21 Aug 2003 21:20:27 -0000
*************** namespace sidutil
*** 227,232 ****
--- 227,239 ----
  	std::ofstream::open (filename.c_str (), std::ios::app);
  	cout_p = false;
        }
+       void end_line ()
+       {
+ 	if (LIKELY (cout_p))
+ 	  std::cout << std::endl;
+ 	else
+ 	  *this << std::endl;
+       }
        bool cout_p;
      };
  
*************** public:
*** 611,617 ****
        if (LIKELY (s.cout_p))
  	std::cout << t;
        else
! 	dynamic_cast <std::ofstream&> (s) << t;
        return s;
      }
    
--- 618,624 ----
        if (LIKELY (s.cout_p))
  	std::cout << t;
        else
! 	static_cast <std::ofstream&> (s) << t;
        return s;
      }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.