⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 trace_intr.c

📁 TRACE的源代码,在LINUX调试程序要使用的.
💻 C
字号:
/*  This file (trace_intr.c) was created by Ron Rechenmacher <ron@fnal.gov> on    June 5, 2000. "TERMS AND CONDITIONS" governing this file are in the README    or COPYING file. If you do not have such a file, one can be obtained by    contacting Ron or Fermi Lab in Batavia IL, 60510, phone: 630-840-3000.*/#define __TRACE_INTR_C_REV	"\$RCSfile: trace_intr.c,v $(ppc)\$Revision: 1.4 $\$Date: 2002/03/12 14:36:39 $"#include <linux/trace.h>	/* traceControl_sp */#include <asm/trace_intr.h>	/* TRACE_VECTOR, BUILD_TRACE_INTERRUPT *//*  NOTE: For some reason, if the definition is placed after the includes,    the EXPORT_SYMBOL macro and /sbin/genksyms functionality does not work */char *trace_intr_c_rev = __TRACE_INTR_C_REV __TRACE_H_REV __TRACE_PROCESSOR_H_REV __TRACE_INTR_H_REV;#include <linux/time.h>		/* do_gettimeofday */#include <asm/uaccess.h>        /* copy_from_user(to,from,n) */#include <linux/ptrace.h>       /* struct pt_regs *//****************************************************************************** *   Ref. arch/ppc/kernel/head.S *       and *        arch/ppc/kernel/traps.c */voidTraceException( struct pt_regs	*regs ){	char			msg[traceControl_sp->messageSize_bytes];	struct	{   int		lvl;	    char	*msg;#	    if TRACE_COMPILER_DOES_DYNAMIC_ARRAYS == 1	    int		params[traceControl_sp->numberOfParameter_integers];#	    else	    int		params[TRACE_NUM_PARAMETER_INTS];#	    endif	}			kk;	void			*usr_space_kk_ptr;	void			*usr_space_time_ptr;	int			tid;	struct s_traceEntry     *ep;	int                     ii, *ip;    /*  Skip over trap insn.	Ref arch/ppc/kernel/ppc-stub.c:handle_exception() */    regs->nip += 4;    usr_space_time_ptr = (void *)regs->gpr[0];    tid                =         regs->gpr[5];    usr_space_kk_ptr   = (void *)regs->gpr[6];#   if 0    printk("hello from kernel land****************************************\n");    printk("kk=%p tid=%d\n", usr_space_kk_ptr, tid );#   endif    copy_from_user( &kk, usr_space_kk_ptr, sizeof(kk) );    /* COPYING MESSAGE TWICE!!! NEED TO WORK ON THIS */    copy_from_user( msg, kk.msg, traceControl_sp->messageSize_bytes );    kk.msg = msg; /* over write with kernel address */    /* NOW THE CODE IS VERY SIMILAR TO THE CODE IN:       init/trace_queue.c:traceCircularQueuePut() (MAKE THIS CODE A MACRO??) */    ep = (struct s_traceEntry *)traceCircularQueueIncrement();    do_gettimeofday( &ep->time );    TRACE_ENTRY_SPECIFIC( ep );    ep->pid = current->pid;    ep->cpu = smp_processor_id();    ep->tid = tid;    ep->lvl = kk.lvl;    strncpy( &(ep->data[0]), kk.msg, traceControl_sp->messageSize_bytes );    /*  may need to, depending upon alignment issues, add the restriction        that messageSize_bytes must be a multiple if sizeof(int)        see also trace_proc.c:XXX */    ip = (int *)&(ep->data[traceControl_sp->messageSize_bytes]);    for (ii=0; ii<traceControl_sp->numberOfParameter_integers; ii++)        ip[ii] = kk.params[ii];    copy_to_user( usr_space_time_ptr, &ep->time, sizeof(struct timeval) );    return;}   /* TraceException *//****************************************************************************** *  trace_interrupt_init * */voidtrace_interrupt_init( void ){    return;}   /* trace_interrupt_init *//* ######################################################################### *//*  EXPORT_SYMTAB get defined on the compile line for OX_OBJS make file    target */#include <linux/module.h>	/* has module code - effects alignment! *//* traceControl_sp export in kernel/ksyms.c */EXPORT_SYMBOL( traceCircularQueuePut );#ifdef MODULE/*  gcc -O -Wall -DMODULE -D__KERNEL__ -D__SMP__ -c trace_intr.c	OR    gcc -O -Wall -DMODULE -D__KERNEL__ -D__SMP__ -c trace_intr.c \-DMODVERSIONS -DEXPORT_SYMTAB \-include /usr/src/linux/include/linux/modversions.h*/intinit_module( void ){   printk( "init for trace_intr - configuring interrupt\n" );    trace_interrupt_init();    return (0);}voidcleanup_module( void ){   printk( "nothing to cleanup for trace_intr\n" );}#endif /* MODULE */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -