public inbox for sid@sourceware.org
 help / color / mirror / Atom feed
From: Dave Brolley <brolley@redhat.com>
To: sid@sources.redhat.com, cgen@sources.redhat.com
Subject: [patch][rfa] SID cpu tracing -- attempt #2
Date: Mon, 22 Mar 2004 19:13:00 -0000	[thread overview]
Message-ID: <405F3AB6.1020707@redhat.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1096 bytes --]

Hi,

Reponding to Frank's concerns about my previous patch, here is an 
implementation along the lines he suggested. The idea is that each CGEN 
'set' handler and each component which is the target of a store 
operation is responsible to annotating the cpu trace with the actual 
value stored, if desired. In order to accomplish this, two changes were 
necessary.

1) The tracing code generated by CGEN is now generated before the code 
for the semantic operation. That way any annotation appears after the 
original cpu trace.

2) basic_cpu now has a "trace" pin for use by other components. Each 
value driven on the pin will be echoed as a character into the cpu's 
trace_stream. This way annotation by other components are merged 
properly with the cpu trace whether it be to cout or to a file.

I've attached sid-trace-cgen.patch.txt which shows the CGEN changes and 
a partial diff of the resulting changes to xstormy16-sem.cxx. I've also 
attached sid-trace.patch.txt which shows the changes to basic_cpu.

Tested on an internal port which requirs this functionality.

OK to commit?

Dave

[-- Attachment #2: sid-trace-cgen.patch.txt --]
[-- Type: text/plain, Size: 7103 bytes --]

Index: cgen/sid.scm
===================================================================
RCS file: /cvs/src/src/cgen/sid.scm,v
retrieving revision 1.11
diff -c -p -r1.11 sid.scm
*** cgen/sid.scm	16 Jul 2003 05:35:47 -0000	1.11
--- cgen/sid.scm	22 Mar 2004 18:48:25 -0000
***************
*** 1,5 ****
  ; Simulator generator support routines.
! ; Copyright (C) 2000, 2002, 2003 Red Hat, Inc.
  ; This file is part of CGEN.
  
  ; One goal of this file is to provide cover functions for all methods.
--- 1,5 ----
  ; Simulator generator support routines.
! ; Copyright (C) 2000-2004 Red Hat, Inc.
  ; This file is part of CGEN.
  
  ; One goal of this file is to provide cover functions for all methods.
***************
*** 1064,1084 ****
    (string-append
     "  {\n"
     "    " (mode:c-type mode) " opval = " (cx:c newval) ";\n"
-    ; Dispatch to setter code if appropriate
-    "    "
-    (if (op:setter op)
-        (let ((args (car (op:setter op)))
- 	     (expr (cadr (op:setter op))))
- 	 (rtl-c 'VOID expr
- 		(if (= (length args) 0)
- 		    (list (list 'newval mode "opval"))
- 		    (list (list (car args) 'UINT index)
- 			  (list 'newval mode "opval")))
- 		#:rtl-cover-fns? #t
- 		#:output-language (estate-output-language estate)))
-        ;else
-        (send (op:type op) 'gen-set-quiet estate mode index selector
- 		(cx:make-with-atlist mode "opval" (cx:atlist newval))))
     (if (and (with-profile?)
  	    (op:cond? op))
         (string-append "    written |= (1ULL << "
--- 1064,1069 ----
***************
*** 1119,1124 ****
--- 1104,1124 ----
  		"(USI) "
  		""))
  	"opval << dec << \"  \";\n"))
+    ; Dispatch to setter code if appropriate
+    "    "
+    (if (op:setter op)
+        (let ((args (car (op:setter op)))
+ 	     (expr (cadr (op:setter op))))
+ 	 (rtl-c 'VOID expr
+ 		(if (= (length args) 0)
+ 		    (list (list 'newval mode "opval"))
+ 		    (list (list (car args) 'UINT index)
+ 			  (list 'newval mode "opval")))
+ 		#:rtl-cover-fns? #t
+ 		#:output-language (estate-output-language estate)))
+        ;else
+        (send (op:type op) 'gen-set-quiet estate mode index selector
+ 		(cx:make-with-atlist mode "opval" (cx:atlist newval))))
     "  }\n")
  )
  
***************
*** 1126,1137 ****
    (string-append
     "  {\n"
     "    " (mode:c-type mode) " opval = " (cx:c newval) ";\n"
-    (if (op-save-index? op)
-        (string-append "    " -par-operand-macro " (" (-op-index-name op) ")"
- 		      " = " (-gen-hw-index index estate) ";\n")
-        "")
-    "    " -par-operand-macro " (" (gen-sym op) ")"
-    " = opval;\n"
     (if (op:cond? op)
         (string-append "    written |= (1ULL << "
  		      (number->string (op:num op))
--- 1126,1131 ----
***************
*** 1168,1173 ****
--- 1162,1173 ----
  	   "(USI) "
  	   ""))
     "opval << dec << \"  \";\n"
+    (if (op-save-index? op)
+        (string-append "    " -par-operand-macro " (" (-op-index-name op) ")"
+ 		      " = " (-gen-hw-index index estate) ";\n")
+        "")
+    "    " -par-operand-macro " (" (gen-sym op) ")"
+    " = opval;\n"
     "  }\n")
  )
  
Index: cgen/utils.scm
===================================================================
RCS file: /cvs/src/src/cgen/utils.scm,v
retrieving revision 1.11
diff -c -p -r1.11 utils.scm
*** cgen/utils.scm	16 Jul 2003 05:35:48 -0000	1.11
--- cgen/utils.scm	22 Mar 2004 18:48:26 -0000
***************
*** 1,5 ****
  ; Generic Utilities.
! ; Copyright (C) 2000, 2002, 2003 Red Hat, Inc.
  ; This file is part of CGEN.
  ; See file COPYING.CGEN for details.
  
--- 1,5 ----
  ; Generic Utilities.
! ; Copyright (C) 2000-2004 Red Hat, Inc.
  ; This file is part of CGEN.
  ; See file COPYING.CGEN for details.
  
***************
*** 1216,1222 ****
    (cons "\
  THIS FILE IS MACHINE GENERATED WITH CGEN.
  
! Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
  "
  	"\
  This program is free software; you can redistribute it and/or modify
--- 1216,1222 ----
    (cons "\
  THIS FILE IS MACHINE GENERATED WITH CGEN.
  
! Copyright 1996-2004 Free Software Foundation, Inc.
  "
  	"\
  This program is free software; you can redistribute it and/or modify
*************** with this program; if not, write to the 
*** 1241,1247 ****
    (cons "\
  THIS FILE IS MACHINE GENERATED WITH CGEN.
  
! Copyright (C) 2000, 2001, 2002, 2003 Red Hat, Inc.
  "
  	"\
  "))
--- 1241,1247 ----
    (cons "\
  THIS FILE IS MACHINE GENERATED WITH CGEN.
  
! Copyright (C) 2000-2004 Red Hat, Inc.
  "
  	"\
  "))
Index: sid/component/cgen-cpu/xstormy16/xstormy16-sem.cxx
===================================================================
RCS file: /cvs/src/src/sid/component/cgen-cpu/xstormy16/xstormy16-sem.cxx,v
retrieving revision 1.7
diff -c -p -r1.7 xstormy16-sem.cxx
*** sid/component/cgen-cpu/xstormy16/xstormy16-sem.cxx	5 Jul 2003 17:07:21 -0000	1.7
--- sid/component/cgen-cpu/xstormy16/xstormy16-sem.cxx	22 Mar 2004 18:48:32 -0000
***************
*** 2,8 ****
  
  THIS FILE IS MACHINE GENERATED WITH CGEN.
  
! Copyright (C) 2000, 2001, 2002, 2003 Red Hat, Inc.
  
  This file is part of the Red Hat simulators.
  
--- 2,8 ----
  
  THIS FILE IS MACHINE GENERATED WITH CGEN.
  
! Copyright (C) 2000-2004 Red Hat, Inc.
  
  This file is part of the Red Hat simulators.
  
*************** if (FLD (f_op2m)) {
*** 59,73 ****
    tmp_nvalue = FLD (f_imm16);
    {
      SI opval = ORSI (ANDSI (current_cpu->h_gr_get (((UINT) 14)), 65436), ORBI (ORBI (EQHI (ANDHI (tmp_nvalue, 255), 0), SLLHI (EQHI (tmp_nvalue, 0), 1)), ORHI (SLLHI (current_cpu->parity (tmp_nvalue), 5), SLLHI (LTQI (SRLHI (tmp_nvalue, MULSI (FLD (f_op2m), 8)), 0), 6))));
-     current_cpu->h_gr_set (((UINT) 14), opval);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << ((UINT) 14) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
    {
      HI opval = tmp_nvalue;
-     current_cpu->SETMEMHI (pc, ANDSI (FLD (f_lmem8), 65534), opval);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) ANDSI (FLD (f_lmem8), 65534) << dec << ']' << ":=0x" << hex << opval << dec << "  ";
    }
  }
  } else {
--- 59,73 ----
    tmp_nvalue = FLD (f_imm16);
    {
      SI opval = ORSI (ANDSI (current_cpu->h_gr_get (((UINT) 14)), 65436), ORBI (ORBI (EQHI (ANDHI (tmp_nvalue, 255), 0), SLLHI (EQHI (tmp_nvalue, 0), 1)), ORHI (SLLHI (current_cpu->parity (tmp_nvalue), 5), SLLHI (LTQI (SRLHI (tmp_nvalue, MULSI (FLD (f_op2m), 8)), 0), 6))));
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << ((UINT) 14) << ']' << ":=0x" << hex << opval << dec << "  ";
+     current_cpu->h_gr_set (((UINT) 14), opval);
    }
    {
      HI opval = tmp_nvalue;
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) ANDSI (FLD (f_lmem8), 65534) << dec << ']' << ":=0x" << hex << opval << dec << "  ";
+     current_cpu->SETMEMHI (pc, ANDSI (FLD (f_lmem8), 65534), opval);
    }
  }
  } else {

[ ... ]

[-- Attachment #3: sid-trace.patch.txt --]
[-- Type: text/plain, Size: 2363 bytes --]

Index: sid/include/sidcpuutil.h
===================================================================
RCS file: /cvs/src/src/sid/include/sidcpuutil.h,v
retrieving revision 1.27
diff -c -p -r1.27 sidcpuutil.h
*** sid/include/sidcpuutil.h	21 Oct 2003 21:38:24 -0000	1.27
--- sid/include/sidcpuutil.h	22 Mar 2004 18:48:33 -0000
***************
*** 1,6 ****
  // sidcpuutil.h - Elements common to CPU models.  -*- C++ -*-
  
! // Copyright (C) 1999, 2000, 2001, 2002, 2003 Red Hat.
  // This file is part of SID and is licensed under the GPL.
  // See the file COPYING.SID for conditions for redistribution.
  
--- 1,6 ----
  // sidcpuutil.h - Elements common to CPU models.  -*- C++ -*-
  
! // Copyright (C) 1999-2004 Red Hat.
  // This file is part of SID and is licensed under the GPL.
  // See the file COPYING.SID for conditions for redistribution.
  
*************** namespace sidutil
*** 213,218 ****
--- 213,219 ----
      // tracing
    private:
      string trace_filename;
+     callback_pin<basic_cpu> trace_pin;
      class cpu_trace_stream: public std::ofstream
      {
      public:
*************** namespace sidutil
*** 244,249 ****
--- 245,255 ----
      template <typename T> friend
      cpu_trace_stream& operator<< (cpu_trace_stream& s, T t);
  
+     void trace_pin_handler (sid::host_int_4 value)
+       {
+ 	trace_stream << static_cast<char> (value);
+       }
+ 
    public:
      bool trace_extract_p;
      bool trace_result_p;
*************** public:
*** 546,552 ****
        endian_set_pin (this, & basic_cpu::endian_set_pin_handler),
        debugger_bus (& this->data_bus),
        trace_stream (),
!       trace_filename ("-") // standard output
        {
  	// buses
  	this->data_bus = 0;
--- 552,559 ----
        endian_set_pin (this, & basic_cpu::endian_set_pin_handler),
        debugger_bus (& this->data_bus),
        trace_stream (),
!       trace_filename ("-"), // standard output
!       trace_pin (this, & basic_cpu::trace_pin_handler)
        {
  	// buses
  	this->data_bus = 0;
*************** public:
*** 571,576 ****
--- 578,584 ----
  	add_watchable_pin ("trap", & this->trap_type_pin); // output side
  	add_watchable_pin ("trap-code", & this->trap_code_pin);
  	add_pin ("trap", & this->trap_disposition_pin); // input side
+ 	add_pin ("trace", & this->trace_pin);
  
  	// attributes
  	this->step_insn_count = 1;

             reply	other threads:[~2004-03-22 19:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-22 19:13 Dave Brolley [this message]
2004-03-22 21:40 ` Dave Brolley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=405F3AB6.1020707@redhat.com \
    --to=brolley@redhat.com \
    --cc=cgen@sources.redhat.com \
    --cc=sid@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).