linux/kernel/gcov/base.c
<<
0.4" /spapti /formti a 0.4" href="../linux+v3 2v9/kernel/gcov/base.c">0.4" img src="../.static/gfx/right.png" alt=">>">0. /spapti0. spap class="lxr_search">0.4"0.4" input typvalhidden" namvalnavtarget" ion val">0.4" input typvaltext" namvalsearch" idalsearch">0.4" buttopttypvalsubmit">Search0.4" Prefsi /a>0. /spapti4" /divti4" form ac0. input typvalhidden" namvalajax_lookup" idalajax_lookup" ion val">04" /formti04" div class="headingbottom">i div idalfile_contents"t
   1 /a> spap class="comment">/* /spapti   2 /a> spap class="comment"> *  This code maintains a list of ac   3 /a> spap class="comment"> * /spapti   4 /a> spap class="comment"> *    Copyright IBM Corp. 2009 /spapti   5 /a> spap class="comment"> *    Author(s): Peter Oberparleiter <oberpar@linux.vnet.ibm.com> /spapti   6 /a> spap class="comment"> * /spapti   7 /a> spap class="comment"> *    Uses gcc-internal data defini   8 /a> spap class="comment"> *    Based optthe gcov-kernel patch by: /spapti   9 /a> spap class="comment"> *               Hubertus Franke <frankeh@us.ibm.com> /spapti  .18.a> spap class="comment"> *               Nigel Hinds <nhinds@us.ibm.com> /spapti  11 /a> spap class="comment"> *               Rajan Ravindran <rajancr@us.ibm.com> /spapti  12 /a> spap class="comment"> *               Peter Oberparleiter <oberpar@linux.vnet.ibm.com> /spapti  13 /a> spap class="comment"> *               Paul Larson /spapti  14 /a> spap class="comment"> */ /spapti  15 /a>i  16 /a>#define  a href="+code=pr_fmt" class="sref">pr_fmt /a>( a href="+code=fmt" class="sref">fmt /a>)"
    spap class="string">"gcov: " /spapt  a href="+code=fmt" class="sref">fmt /a>i  17 /a>i  18 /a>#include <linux/ini<.h /a>>i  19 /a>#include <linux/module.h /a>>i  20 /a>#include <linux/mutex.h /a>>i  21 /a>#include " a href="kernel/gcov/gcov.h" class="fref">gcov.h /a>"i  22 /a>i  23 /a>static struct  a href="+code=gcov_info" class="sref">gcov_info /a> * a href="+code=gcov_info_head" class="sref">gcov_info_head /a>;i  24 /a>static int  a href="+code=gcov_events_enabled" class="sref">gcov_events_enabled /a>;i  25 /a>static  a href="+code=DEFINE_MUTEX" class="sref">DEFINE_MUTEX /a>( a href="+code=gcov_lock" class="sref">gcov_lock /a>);i  26 /a>i  27 /a> spap class="comment">/* /spapti  28 /a> spap class="comment"> * __gcov_init is called by gcc-generated constructor code for each object /spapti  29 /a> spap class="comment"> * file compiled with -fprofile-arcs. /spapti  318.a> spap class="comment"> */ /spapti  31 /a>void  a href="+code=__gcov_init" class="sref">__gcov_init /a>(struct  a href="+code=gcov_info" class="sref">gcov_info /a> * a href="+code=info" class="sref">info /a>)i  32 /a>{i  33 /a>        static unsigned int  a href="+code=gcov_vers/op" class="sref">gcov_vers/op /a>;i  34 /a>i  35 /a>         a href="+code=mutex_lock" class="sref">mutex_lock /a>(& a href="+code=gcov_lock" class="sref">gcov_lock /a>);i  36 /a>        if ( a href="+code=gcov_vers/op" class="sref">gcov_vers/op /a> == 0) {i  37 /a>                 a href="+code=gcov_vers/op" class="sref">gcov_vers/op /a> =  a href="+code=info" class="sref">info /a>-> a href="+code=vers/op" class="sref">vers/op /a>;i  38 /a>                 spap class="comment">/* /spapti  39 /a> spap class="comment">                 * Printing gcc's vers/op magic may prove useful for debugging /spapti  418.a> spap class="comment">                 * incompatibility reports. /spapti  41 /a> spap class="comment">                 */ /spapti  42 /a>                 a href="+code=pr_info" class="sref">pr_info /a>( spap class="string">"vers/op magic: 0x%x\n" /spapt,  a href="+code=gcov_vers/op" class="sref">gcov_vers/op /a>);i  43 /a>        }i  44 /a>         spap class="comment">/* /spapti  45 /a> spap class="comment">         * Add new profiling data structure to list and inform event /spapti  46 /a> spap class="comment">         * listener. /spapti  47 /a> spap class="comment">         */ /spapti  48 /a>         a href="+code=info" class="sref">info /a>-> a href="+code=next" class="sref">next /a> =  a href="+code=gcov_info_head" class="sref">gcov_info_head /a>;i  49 /a>         a href="+code=gcov_info_head" class="sref">gcov_info_head /a> =  a href="+code=info" class="sref">info /a>;i  50 /a>        if ( a href="+code=gcov_events_enabled" class="sref">gcov_events_enabled /a>)i  51 /a>                 a href="+code=gcov_event" class="sref">gcov_event /a>( a href="+code=GCOV_ADD" class="sref">GCOV_ADD /a>,  a href="+code=info" class="sref">info /a>);i  52 /a>         a href="+code=mutex_unlock" class="sref">mutex_unlock /a>(& a href="+code=gcov_lock" class="sref">gcov_lock /a>);i  53 /a>}i  54 /a> a href="+code=EXPORT_SYMBOL" class="sref">EXPORT_SYMBOL /a>( a href="+code=__gcov_init" class="sref">__gcov_init /a>);i  55 /a>i  56 /a> spap class="comment">/* /spapti  57 /a> spap class="comment"> * These func  58 /a> spap class="comment"> * no func  59 /a> spap class="comment"> */ /spapti  60 /a>void  a href="+code=__gcov_flush" class="sref">__gcov_flush /a>(void)i  61 /a>{i  62 /a>         spap class="comment">/* Unused. */ /spapti  63 /a>}i  64 /a> a href="+code=EXPORT_SYMBOL" class="sref">EXPORT_SYMBOL /a>( a href="+code=__gcov_flush" class="sref">__gcov_flush /a>);i  65 /a>i  66 /a>void  a href="+code=__gcov_merge_add" class="sref">__gcov_merge_add /a>( a href="+code=gcov_typv" class="sref">gcov_typv /a> * a href="+code=counters" class="sref">counters /a>, unsigned int  a href="+code=n_counters" class="sref">n_counters /a>)i  67 /a>{i  68 /a>         spap class="comment">/* Unused. */ /spapti  69 /a>}i  70 /a> a href="+code=EXPORT_SYMBOL" class="sref">EXPORT_SYMBOL /a>( a href="+code=__gcov_merge_add" class="sref">__gcov_merge_add /a>);i  71 /a>i  72 /a>void  a href="+code=__gcov_merge_singlv" class="sref">__gcov_merge_singlv /a>( a href="+code=gcov_typv" class="sref">gcov_typv /a> * a href="+code=counters" class="sref">counters /a>, unsigned int  a href="+code=n_counters" class="sref">n_counters /a>)i  73 /a>{i  74 /a>         spap class="comment">/* Unused. */ /spapti  75 /a>}i  76 /a> a href="+code=EXPORT_SYMBOL" class="sref">EXPORT_SYMBOL /a>( a href="+code=__gcov_merge_singlv" class="sref">__gcov_merge_singlv /a>);i  77 /a>i  78 /a>void  a href="+code=__gcov_merge_delta" class="sref">__gcov_merge_delta /a>( a href="+code=gcov_typv" class="sref">gcov_typv /a> * a href="+code=counters" class="sref">counters /a>, unsigned int  a href="+code=n_counters" class="sref">n_counters /a>)i  79 /a>{i  80 /a>         spap class="comment">/* Unused. */ /spapti  81 /a>}i  82 /a> a href="+code=EXPORT_SYMBOL" class="sref">EXPORT_SYMBOL /a>( a href="+code=__gcov_merge_delta" class="sref">__gcov_merge_delta /a>);i  83 /a>i  84 /a> spap class="comment">/** /spapti  85 /a> spap class="comment"> * gcov_enable_events - enable event reporting through gcov_event() /spapti  86 /a> spap class="comment"> * /spapti  87 /a> spap class="comment"> * Turn op reporting of profiling data load/unload-events through the /spapti  88 /a> spap class="comment"> * gcov_event() callback. Also replay all previous events once. This func  89 /a> spap class="comment"> * is needed because some events are potentially generated too early for the /spapti  918.a> spap class="comment"> * callback implementa  91 /a> spap class="comment"> */ /spapti  92 /a>void  a href="+code=gcov_enable_events" class="sref">gcov_enable_events /a>(void)i  93 /a>{i  94 /a>        struct  a href="+code=gcov_info" class="sref">gcov_info /a> * a href="+code=info" class="sref">info /a>;i  95 /a>i  96 /a>         a href="+code=mutex_lock" class="sref">mutex_lock /a>(& a href="+code=gcov_lock" class="sref">gcov_lock /a>);i  97 /a>         a href="+code=gcov_events_enabled" class="sref">gcov_events_enabled /a> = 1;i  98 /a>         spap class="comment">/* Perform event callback for previously registered entries. */ /spapti  99 /a>        for ( a href="+code=info" class="sref">info /a> =  a href="+code=gcov_info_head" class="sref">gcov_info_head /a>;  a href="+code=info" class="sref">info /a>;  a href="+code=info" class="sref">info /a> =  a href="+code=info" class="sref">info /a>-> a href="+code=next" class="sref">next /a>)i 100 /a>                 a href="+code=gcov_event" class="sref">gcov_event /a>( a href="+code=GCOV_ADD" class="sref">GCOV_ADD /a>,  a href="+code=info" class="sref">info /a>);i 101 /a>         a href="+code=mutex_unlock" class="sref">mutex_unlock /a>(& a href="+code=gcov_lock" class="sref">gcov_lock /a>);i 102 /a>}i 103 /a>i 104 /a>#ifdef  a href="+code=CONFIG_MODULES" class="sref">CONFIG_MODULES /a>i 105 /a>static  a href="+code=inline" class="sref">inline /a> int  a href="+code=withip" class="sref">withip /a>(void * a href="+code=addr" class="sref">addr /a>, void * a href="+code=start" class="sref">start /a>, unsigned long  a href="+code=size" class="sref">size /a>)i 106 /a>{i 107 /a>        return (( a href="+code=addr" class="sref">addr /a> >=  a href="+code=start" class="sref">start /a>) && ( a href="+code=addr" class="sref">addr /a> <  a href="+code=start" class="sref">start /a> +  a href="+code=size" class="sref">size /a>));i 108 /a>}i 109 /a>i 1.18.a> spap class="comment">/* Update list and generate events when modules are unloaded. */ /spapti 111 /a>static int  a href="+code=gcov_module_notifier" class="sref">gcov_module_notifier /a>(struct  a href="+code=notifier_block" class="sref">notifier_block /a> * a href="+code=nb" class="sref">nb /a>, unsigned long  a href="+code=event" class="sref">event /a>,i 112 /a>                                void * a href="+code=data" class="sref">data /a>)i 113 /a>{i 114 /a>        struct  a href="+code=module" class="sref">module /a> * a href="+code=mod" class="sref">mod /a> =  a href="+code=data" class="sref">data /a>;i 115 /a>        struct  a href="+code=gcov_info" class="sref">gcov_info /a> * a href="+code=info" class="sref">info /a>;i 116 /a>        struct  a href="+code=gcov_info" class="sref">gcov_info /a> * a href="+code=prev" class="sref">prev /a>;i 117 /a>i 118 /a>        if ( a href="+code=event" class="sref">event /a> !=  a href="+code=MODULE_STATE_GOING" class="sref">MODULE_STATE_GOING /a>)i 119 /a>                return  a href="+code=NOTIFY_OK" class="sref">NOTIFY_OK /a>;i 120 /a>         a href="+code=mutex_lock" class="sref">mutex_lock /a>(& a href="+code=gcov_lock" class="sref">gcov_lock /a>);i 121 /a>         a href="+code=prev" class="sref">prev /a> =  a href="+code=NULL" class="sref">NULL /a>;i 122 /a>         spap class="comment">/* Remove entries located in module from linked list. */ /spapti 123 /a>        for ( a href="+code=info" class="sref">info /a> =  a href="+code=gcov_info_head" class="sref">gcov_info_head /a>;  a href="+code=info" class="sref">info /a>;  a href="+code=info" class="sref">info /a> =  a href="+code=info" class="sref">info /a>-> a href="+code=next" class="sref">next /a>) {i 124 /a>                if ( a href="+code=withip" class="sref">withip /a>( a href="+code=info" class="sref">info /a>,  a href="+code=mod" class="sref">mod /a>-> a href="+code=module_core" class="sref">module_core /a>,  a href="+code=mod" class="sref">mod /a>-> a href="+code=core_size" class="sref">core_size /a>)) {i 125 /a>                        if ( a href="+code=prev" class="sref">prev /a>)i 126 /a>                                 a href="+code=prev" class="sref">prev /a>-> a href="+code=next" class="sref">next /a> =  a href="+code=info" class="sref">info /a>-> a href="+code=next" class="sref">next /a>;i 127 /a>                        elsei 128 /a>                                 a href="+code=gcov_info_head" class="sref">gcov_info_head /a> =  a href="+code=info" class="sref">info /a>-> a href="+code=next" class="sref">next /a>;i 129 /a>                        if ( a href="+code=gcov_events_enabled" class="sref">gcov_events_enabled /a>)i 130 /a>                                 a href="+code=gcov_event" class="sref">gcov_event /a>( a href="+code=GCOV_REMOVE" class="sref">GCOV_REMOVE /a>,  a href="+code=info" class="sref">info /a>);i 131 /a>                } elsei 132 /a>                         a href="+code=prev" class="sref">prev /a> =  a href="+code=info" class="sref">info /a>;i 133 /a>        }i 134 /a>         a href="+code=mutex_unlock" class="sref">mutex_unlock /a>(& a href="+code=gcov_lock" class="sref">gcov_lock /a>);i 135 /a>i 136 /a>        return  a href="+code=NOTIFY_OK" class="sref">NOTIFY_OK /a>;i 137 /a>}i 138 /a>i 139 /a>static struct  a href="+code=notifier_block" class="sref">notifier_block /a>  a href="+code=gcov_nb" class="sref">gcov_nb /a> = {i 140 /a>        . a href="+code=notifier_call" class="sref">notifier_call /a>  =  a href="+code=gcov_module_notifier" class="sref">gcov_module_notifier /a>,i 141 /a>};i 142 /a>i 143 /a>static int  a href="+code=__init" class="sref">__init /a>  a href="+code=gcov_init" class="sref">gcov_init /a>(void)i 144 /a>{i 145 /a>        return  a href="+code=register_module_notifier" class="sref">register_module_notifier /a>(& a href="+code=gcov_nb" class="sref">gcov_nb /a>);i 146 /a>}i 147 /a> a href="+code=device_initcall" class="sref">device_initcall /a>( a href="+code=gcov_init" class="sref">gcov_init /a>);i 148 /a>#endif  spap class="comment">/* CONFIG_MODULES */ /spapti 149 /a>
The original LXR software bytthe LXR community /a>, this experimental vers/op bytlxr@linux.no /a>. /divti div class="subfooter"> lxr.linux.no kindly hosted by Redpill Linpro AS /a>, provider of Linux consulting and operat/ops services since 1995. /divti /bodyti /htmlti