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

📄 trace_intr.c

📁 TRACE的源代码,在LINUX调试程序要使用的.
💻 C
字号:
/*  This file (trace_intr.c) was created by Ron Rechenmacher <ron@fnal.gov> on    Dec 15, 1999. "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 $(alpha)\$Revision: 1.3 $\$Date: 2002/03/12 14:36:38 $"#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/kernel.h>	/*  printk and includes linux/linkage.h for				    __ALIGN_STR */#include <asm/uaccess.h>	/* copy_from_user(to,from,n) */#include <linux/ptrace.h>	/* struct pt_regs needed by irq.h */#include <linux/sched.h>	/* NULL needed by smp_lock.h */#include <linux/smp.h>		/* NO_PROC_ID needed by smp_lock.h */#include <linux/smp_lock.h>	/* spinlock_t needed by irq.h */#include <linux/sched.h>	/* prof_buffer needed by irq.h */#include "irq.h"		/* SAVE_ALL used in BUILD_TRACE_INTERRUPT *//****************************************************************************** * */asmlinkage voiddo_trace_interrupt(  struct timeval	*time		   , int		tid		   , void		*ap ){	char			lcl_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;	struct s_traceEntry	*ep;	int			ii, *ip;    copy_from_user( &kk, ap, sizeof(kk) );    /* COPYING MESSAGE TWICE!!! NEED TO WORK ON THIS */    copy_from_user( lcl_msg, kk.msg, traceControl_sp->messageSize_bytes );    kk.msg = lcl_msg; /* over write with kernel address */    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( time, &ep->time, sizeof(struct timeval) );    return;}   /* do_trace_interrupt *//****************************************************************************** *  trace_interrupt_init * *//*  defined in arch/alpha/kernel/traps.c    Note: do_trace_interrupt is called (via this function ptr) from    arch/alpha/kernel/traps.c:do_entIF() which is called from    arch/alpha/kernel/entry.S:entIF: which does    "lda     $26,ret_from_sys_call"    */extern void (*trace_interrupt_routine)(  struct timeval	*time				       , int		tid				       , void		*ap );voidtrace_interrupt_init( void ){    trace_interrupt_routine = do_trace_interrupt;    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 );/* used in i386 arch */EXPORT_SYMBOL( traceCircularQueueIncrement );EXPORT_SYMBOL( trace_interrupt_routine );#ifdef MODULE/*  gcc -O -Wall -DMODULE -D__KERNEL__ -D__SMP__ -c trace_intr.c -o trace_intr.mod.o	OR    gcc -O -Wall -DMODULE -D__KERNEL__ -D__SMP__ -c trace_intr.c -o trace_intr.mod.o \-DMODVERSIONS -DEXPORT_SYMTAB \-include /usr/src/linux/include/linux/modversions.h        OR, for non SMP    gcc -O -Wall -DMODULE -D__KERNEL__ -c trace_intr.c -o trace_intr.mod.o	OR    gcc -O -Wall -DMODULE -D__KERNEL__ -c trace_intr.c -o trace_intr.mod.o \-DMODVERSIONS -DEXPORT_SYMTAB \-include /usr/src/linux/include/linux/modversions.hFOR ALPHA, YOU MUST ADD "-mno-fp-regs -ffixed-8" TO AVOID COMPILE"global register variable follows a function definition" ERROR*/intinit_module( void ){   printk( "init for trace_intr - configuring interrupt\n" );    trace_interrupt_init();    return (0);}voidcleanup_module( void ){   printk( "trace_intr: clearing trace_interrupt_routine\n" );    trace_interrupt_routine = 0;}#endif /* MODULE */

⌨️ 快捷键说明

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