File: calls.php

package info (click to toggle)
ggcov 0.9-6
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 4,356 kB
  • ctags: 3,998
  • sloc: cpp: 17,068; sh: 12,380; ansic: 7,743; php: 1,644; perl: 1,509; makefile: 259; yacc: 23
file content (178 lines) | stat: -rw-r--r-- 4,339 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<?php
//
// ggcov - A GTK frontend for exploring gcov coverage data
// Copyright (c) 2005 Greg Banks <gnb@users.sourceforge.net>
// 
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
// 
// This 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 program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
// 
// $Id: calls.php,v 1.5 2010-05-09 05:37:14 gnb Exp $
//

require_once 'ggcov/lib/cov.php';

define('COV_ANY', '@ny');

class cov_calls_page extends cov_page
{
    var $env_;
    var $from_func_ = null;
    var $to_func_ = null;

    function cov_calls_page($e)
    {
	$this->env_ = $e;
    }

    function parse_args($get)
    {
	$cb = $this->env_->cb_;
	$node_index = $this->env_->callnode_index();

	// get scope from args
	if (array_key_exists('from', $get))
	{
	    $this->from_func_ = $get['from'];

	    if (!cov_valid::funcname($this->from_func_))
		$cb->fatal("Invalid from function");

	    if (array_key_exists($this->from_func_, $node_index))
		$this->from_id_ = $node_index[$this->from_func_];
	    else if ($this->from_func_ != COV_ANY)
		$cb->fatal("Unknown node");
	}
	if (array_key_exists('to', $get))
	{
	    $this->to_func_ = $get['to'];

	    if (!cov_valid::funcname($this->to_func_))
		$cb->fatal("Invalid to function");

	    if (array_key_exists($this->to_func_, $node_index))
		$this->to_id_ = $node_index[$this->to_func_];
	    else if ($this->to_func_ != COV_ANY)
		$cb->fatal("Unknown node");
	}
    }

    function title()
    {
	$f = ($this->from_func_ == COV_ANY || $this->from_func_ === null ?
		'' : " from $this->from_func_");
	$t = ($this->to_func_ == COV_ANY || $this->to_func_ === null
		? '' : " to $this->to_func_");
	return "Calls$f$t";
    }

    function render_calls($from_name, $from_id, $to_name)
    {
	$data = $this->env_->fetch("N$from_id");
	foreach ($data[3] as $ca)
	{
	    $name = $ca[0];
	    $count = $ca[2];
	    if ($to_name == COV_ANY || $to_name == $name)
	    {
		echo <<<HTML
	  <tr>
	    <td>$from_name</td>
	    <td>$name</td>
    <td><!-- TODO --></td>
	    <td>$count</td>
	  </tr>

HTML;
	    }
	}
    }

    function render()
    {
	$cb = $this->env_->cb_;
	$node_index = $this->env_->callnode_index();

	$self = basename($_SERVER['PHP_SELF']);
?>
	<form action="<?php echo $self; ?>" method="GET">
	<table border="0" cellpadding="5" cellspacing="0">
	  <tr>
	    <td colspan="4">
	      <table border="0" cellpadding="5" cellspacing="0">
	        <tr>
		  <td align="right">From Function:</td>
		  <td>
<?php $this->render_state_to_form('              '); ?>
		    <select name="from">
<?php
			  echo "		      <option value=\"" . COV_ANY . "\">Any Function</option>\n";
			  foreach ($node_index as $cn => $id)
			  {
			      $sel = ($cn == $this->from_func_ ? ' selected' : '');
			      echo "		      <option$sel>$cn</option>\n";
			  }
?>
		    </select>
		  </td>
		</tr>
	        <tr>
		  <td align="right">To Function:</td>
		  <td>
		    <select name="to">
<?php
			  echo "		      <option value=\"" . COV_ANY . "\">Any Function</option>\n";
			  foreach ($node_index as $cn => $id)
			  {
			      $sel = ($cn == $this->to_func_ ? ' selected' : '');
			      echo "		      <option$sel>$cn</option>\n";
			  }
?>
		    </select>
		  </td>
		</tr>
	      </table>
	    </td>
	  </tr>
	  <tr>
	    <td>From</td>
	    <td>To</td>
	    <td><!-- Line --></td>
	    <td>Count</td>
	  </tr>
<?php
	if ($this->from_func_ == COV_ANY)
	{
	    foreach ($node_index as $cn => $id)
	    {
		$this->render_calls($cn, $id, $this->to_func_);
	    }
	}
	else if ($this->from_func_ !== null)
	{
	    $this->render_calls($this->from_func_, $this->from_id_,
				$this->to_func_);
	}
?>
	  <tr>
	    <td colspan="4">
	      <input type="submit" name="update" value="Update">
	    </td>
	  </tr>
	</table>
	</form>
<?php
    }
}

?>