* ========== Copyright Header Begin ==========================================
* OpenSPARC T2 Processor File: SS_PythonTracer.h
* Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
* The above named program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License version 2 as published by the Free Software Foundation.
* The above named program is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
* You should have received a copy of the GNU General Public
* License along with this work; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
* ========== Copyright Header End ============================================
#ifndef __SS_PythonTracer_h__
#define __SS_PythonTracer_h__
class SS_PythonTracer
: public SS_Tracer
static void py_hook_exe_instr( SS_Tracer
* trc
, SS_Vaddr pc
, SS_Tte
* tte
, SS_Instr
* i
)
gstate
= PyGILState_Ensure();
SS_PythonTracer
* py_trc
= (SS_PythonTracer
*)trc
;
PyObject
*func
, *args
, *rslt
;
func
= (PyObject
*)py_trc
->py_exe_instr
;
args
= Py_BuildValue((char*)"Kll",pc
,tte
,i
);
rslt
= PyEval_CallObject(func
,args
);
PyGILState_Release(gstate
);
static void py_hook_reg_value( SS_Tracer
* trc
, SS_Registers::Index index
, uint64_t value
)
gstate
= PyGILState_Ensure();
SS_PythonTracer
* py_trc
= (SS_PythonTracer
*)trc
;
PyObject
*func
, *args
, *rslt
;
func
= (PyObject
*)py_trc
->py_reg_value
;
args
= Py_BuildValue((char*)"iK",index
,value
);
rslt
= PyEval_CallObject(func
,args
);
PyGILState_Release(gstate
);
static void py_hook_trap( SS_Tracer
* trc
, SS_Trap::Type type
, TrapMode mode
, SS_Vaddr addr
)
gstate
= PyGILState_Ensure();
SS_PythonTracer
* py_trc
= (SS_PythonTracer
*)trc
;
PyObject
*func
, *args
, *rslt
;
func
= (PyObject
*)py_trc
->py_trap
;
args
= Py_BuildValue((char*)"iiK",type
,mode
,addr
);
rslt
= PyEval_CallObject(func
,args
);
PyGILState_Release(gstate
);
static void py_hook_mem_access( SS_Tracer
* trc
, MemAccess type
, SS_Vaddr va
, SS_Tte
* tte
, uint_t size
, uint64_t* data
)
gstate
= PyGILState_Ensure();
SS_PythonTracer
* py_trc
= (SS_PythonTracer
*)trc
;
PyObject
*func
, *args
, *rslt
;
func
= (PyObject
*)py_trc
->py_mem_access
;
args
= Py_BuildValue((char*)"iKli[K]",type
,va
,tte
,size
,data
[0]);
args
= Py_BuildValue((char*)"iKli[K,K]",type
,va
,tte
,size
,data
[0],data
[1]);
args
= Py_BuildValue((char*)"iKli[K,K,K,K,K,K,K,K]",type
,va
,tte
,size
,
data
[0],data
[1],data
[2],data
[3],data
[4],data
[5],data
[6],data
[7]);
args
= Py_BuildValue((char*)"iKli[K,K]",type
,va
,tte
,size
,data
[0],data
[1]);
args
= Py_BuildValue((char*)"iKli[]",type
,va
,tte
,size
);
rslt
= PyEval_CallObject(func
,args
);
PyGILState_Release(gstate
);
static void py_hook_tlb_update( SS_Tracer
* trc
, bool insert
, SS_Tlb
* tlb
, uint_t index
, SS_Tte
* tte
)
gstate
= PyGILState_Ensure();
SS_PythonTracer
* py_trc
= (SS_PythonTracer
*)trc
;
PyObject
*func
, *args
, *rslt
;
func
= (PyObject
*)py_trc
->py_tlb_update
;
args
= Py_BuildValue((char*)"ilil",insert
,tlb
,index
,tte
);
rslt
= PyEval_CallObject(func
,args
);
PyGILState_Release(gstate
);
static void py_hook_end_instr( SS_Tracer
* trc
)
gstate
= PyGILState_Ensure();
SS_PythonTracer
* py_trc
= (SS_PythonTracer
*)trc
;
PyObject
*func
, *args
, *rslt
;
func
= (PyObject
*)py_trc
->py_end_instr
;
args
= Py_BuildValue((char*)"");
rslt
= PyEval_CallObject(func
,args
);
PyGILState_Release(gstate
);
void set_exe_instr( PyObject
* func
)
hook_exe_instr
= &py_hook_exe_instr
;
void set_reg_value( PyObject
* func
)
hook_reg_value
= &py_hook_reg_value
;
void set_trap( PyObject
* func
)
hook_trap
= &py_hook_trap
;
Py_DECREF(py_mem_access
);
void set_mem_access( PyObject
* func
)
Py_DECREF(py_mem_access
);
hook_mem_access
= &py_hook_mem_access
;
Py_DECREF(py_tlb_update
);
void set_tlb_update( PyObject
* func
)
Py_DECREF(py_tlb_update
);
hook_tlb_update
= &py_hook_tlb_update
;
void set_end_instr( PyObject
* func
)
hook_end_instr
= &py_hook_end_instr
;