LCOV - code coverage report
Current view: top level - mnt/wasteland/wcohen/systemtap_write/systemtap - task_finder.cxx (source / functions) Hit Total Coverage
Test: stap.info Lines: 41 42 97.6 %
Date: 2013-03-08 Functions: 10 14 71.4 %
Branches: 13 20 65.0 %

           Branch data     Line data    Source code
       1                 :            : // task finder for user tapsets
       2                 :            : // Copyright (C) 2005-2009 Red Hat Inc.
       3                 :            : // Copyright (C) 2005-2007 Intel Corporation.
       4                 :            : //
       5                 :            : // This file is part of systemtap, and is free software.  You can
       6                 :            : // redistribute it and/or modify it under the terms of the GNU General
       7                 :            : // Public License (GPL); either version 2, or (at your option) any
       8                 :            : // later version.
       9                 :            : 
      10                 :            : 
      11                 :            : #include "session.h"
      12                 :            : #include "tapsets.h"
      13                 :            : #include "task_finder.h"
      14                 :            : #include "translate.h"
      15                 :            : #include "util.h"
      16                 :            : 
      17                 :            : #include <cstring>
      18                 :            : #include <string>
      19                 :            : 
      20                 :            : 
      21                 :            : using namespace std;
      22                 :            : using namespace __gnu_cxx;
      23                 :            : 
      24                 :            : 
      25                 :            : // ------------------------------------------------------------------------
      26                 :            : // task_finder derived 'probes': These don't really exist.  The whole
      27                 :            : // purpose of the task_finder_derived_probe_group is to make sure that
      28                 :            : // stap_start_task_finder()/stap_stop_task_finder() get called only
      29                 :            : // once and in the right place.
      30                 :            : // ------------------------------------------------------------------------
      31                 :            : 
      32         [ #  # ]:          0 : struct task_finder_derived_probe: public derived_probe
      33                 :            : {
      34                 :            :   // Dummy constructor for gcc 3.4 compatibility
      35                 :            :   task_finder_derived_probe (): derived_probe (0, 0) { assert(0); }
      36                 :            : };
      37                 :            : 
      38                 :            : 
      39         [ #  # ]:         73 : struct task_finder_derived_probe_group: public generic_dpg<task_finder_derived_probe>
      40                 :            : {
      41                 :            : public:
      42                 :         31 :   void emit_module_decls (systemtap_session& ) { }
      43                 :            :   void emit_module_init (systemtap_session& s);
      44                 :            :   void emit_module_post_init (systemtap_session& s);
      45                 :            :   void emit_module_exit (systemtap_session& s);
      46                 :            : 
      47                 :            :   // Whether or not to initialize the vma tracker
      48                 :            :   bool need_vma_tracker;
      49                 :            : };
      50                 :            : 
      51                 :            : 
      52                 :            : void
      53                 :         31 : task_finder_derived_probe_group::emit_module_init (systemtap_session& s)
      54                 :            : {
      55                 :         31 :   s.op->newline();
      56         [ +  + ]:         31 :   if (need_vma_tracker)
      57                 :            :     {
      58                 :         21 :       s.op->newline() << "/* ---- vma tracker ---- */";
      59                 :         21 :       s.op->newline() << "rc = _stp_vma_init();";
      60                 :         21 :       s.op->newline();
      61                 :            :     }
      62                 :            : 
      63                 :         31 :   s.op->newline() << "/* ---- task finder ---- */";
      64                 :         31 :   s.op->newline() << "if (rc == 0) {";
      65                 :         31 :   s.op->newline(1) << "rc = stap_start_task_finder();";
      66                 :            : 
      67                 :         31 :   s.op->newline() << "if (rc) {";
      68                 :         31 :   s.op->newline(1) << "stap_stop_task_finder();";
      69                 :         31 :   s.op->newline(-1) << "}";
      70                 :         31 :   s.op->newline(-1) << "}";
      71                 :         31 : }
      72                 :            : 
      73                 :            : 
      74                 :            : void
      75                 :         31 : task_finder_derived_probe_group::emit_module_post_init (systemtap_session& s)
      76                 :            : {
      77                 :         31 :   s.op->newline() << "/* ---- task finder ---- */";
      78                 :         31 :   s.op->newline() << "stap_task_finder_post_init();";
      79                 :         31 : }
      80                 :            : 
      81                 :            : 
      82                 :            : void
      83                 :         31 : task_finder_derived_probe_group::emit_module_exit (systemtap_session& s)
      84                 :            : {
      85                 :         31 :   s.op->newline();
      86                 :         31 :   s.op->newline() << "/* ---- task finder ---- */";
      87                 :         31 :   s.op->newline() << "stap_stop_task_finder();";
      88                 :            : 
      89         [ +  + ]:         31 :   if (need_vma_tracker)
      90                 :            :     {
      91                 :         21 :       s.op->newline();
      92                 :         21 :       s.op->newline() << "/* ---- vma tracker ---- */";
      93                 :         21 :       s.op->newline() << "_stp_vma_done();";
      94                 :            :     }
      95                 :         31 : }
      96                 :            : 
      97                 :            : 
      98                 :            : // Declare that task_finder is needed in this session
      99                 :            : void
     100                 :      11910 : enable_task_finder(systemtap_session& s)
     101                 :            : {
     102         [ +  + ]:      11910 :   if (! s.task_finder_derived_probes)
     103                 :            :     {
     104         [ +  - ]:         73 :       s.task_finder_derived_probes = new task_finder_derived_probe_group();
     105                 :         73 :       s.task_finder_derived_probes->need_vma_tracker = false;
     106                 :            :     }
     107                 :      11910 : }
     108                 :            : 
     109                 :            : // Declare that vma tracker is needed in this session,
     110                 :            : // implies that the task_finder is needed.
     111                 :            : void
     112                 :         28 : enable_vma_tracker(systemtap_session& s)
     113                 :            : {
     114                 :         28 :   enable_task_finder(s);
     115                 :         28 :   s.task_finder_derived_probes->need_vma_tracker = true;
     116                 :         28 : }
     117                 :            : 
     118                 :            : // Whether the vma tracker is needed in this session.
     119                 :            : bool
     120                 :      14597 : vma_tracker_enabled(systemtap_session& s)
     121                 :            : {
     122                 :            :   return (s.task_finder_derived_probes
     123 [ +  + ][ +  + ]:      14597 :           && s.task_finder_derived_probes->need_vma_tracker);
     124 [ +  - ][ +  - ]:       7242 : }
     125                 :            : 
     126                 :            : /* vim: set sw=2 ts=8 cino=>4,n-2,{2,^-2,t0,(0,u0,w1,M1 : */

Generated by: LCOV version 1.9