From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1062 invoked by alias); 22 Mar 2004 19:13:28 -0000 Mailing-List: contact sid-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: sid-owner@sources.redhat.com Received: (qmail 1005 invoked from network); 22 Mar 2004 19:13:25 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sources.redhat.com with SMTP; 22 Mar 2004 19:13:25 -0000 Received: from int-mx2.corp.redhat.com (nat-pool-rdu-dmz.redhat.com [172.16.52.200] (may be forged)) by mx1.redhat.com (8.12.10/8.12.10) with ESMTP id i2MJDNWA003520; Mon, 22 Mar 2004 14:13:23 -0500 Received: from potter.sfbay.redhat.com (potter.sfbay.redhat.com [172.16.27.15]) by int-mx2.corp.redhat.com (8.11.6/8.11.6) with ESMTP id i2MJDMM29037; Mon, 22 Mar 2004 14:13:22 -0500 Received: from redhat.com (IDENT:CcpuNP+pgt5gUSrHk7AX8NzAnCTRHnW4@vpn50-12.rdu.redhat.com [172.16.50.12]) by potter.sfbay.redhat.com (8.11.6/8.11.6) with ESMTP id i2MJDKR06241; Mon, 22 Mar 2004 11:13:20 -0800 Message-ID: <405F3AB6.1020707@redhat.com> Date: Mon, 22 Mar 2004 19:13:00 -0000 From: Dave Brolley User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.2) Gecko/20021216 MIME-Version: 1.0 To: sid@sources.redhat.com, cgen@sources.redhat.com Subject: [patch][rfa] SID cpu tracing -- attempt #2 Content-Type: multipart/mixed; boundary="------------030209010502060200050500" X-RedHat-Spam-Score: -4.9 X-SW-Source: 2004-q1/txt/msg00044.txt.bz2 This is a multi-part message in MIME format. --------------030209010502060200050500 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1096 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 --------------030209010502060200050500 Content-Type: text/plain; name="sid-trace-cgen.patch.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="sid-trace-cgen.patch.txt" Content-length: 7103 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 { [ ... ] --------------030209010502060200050500 Content-Type: text/plain; name="sid-trace.patch.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="sid-trace.patch.txt" Content-length: 2363 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 trace_pin; class cpu_trace_stream: public std::ofstream { public: *************** namespace sidutil *** 244,249 **** --- 245,255 ---- template friend cpu_trace_stream& operator<< (cpu_trace_stream& s, T t); + void trace_pin_handler (sid::host_int_4 value) + { + trace_stream << static_cast (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; --------------030209010502060200050500--