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 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235
|
<?xml version="1.0" encoding="iso-8859-1"?>
<appendix id="debugger">
<title>O debugador do PHP</title>
<sect1 id="debugger-using">
<title>Usando o Debugador</title>
<para>
O debugger do PHP util para procurar "bugs" simples.
O debugador trabalha conectando numa porta <acronym>TCP</acronym> para cada seo PHP aberta. Todas as mensagens de erro sero enviadas a esta coneco TCP.
Esta informao tem inteno de "debugar" o servidor de dentro de um sistema
<acronym>IDE</acronym> ou editor de arquivos programvel (como o Emacs).
</para>
<para>
Como levantar o debugger:
<orderedlist>
<listitem>
<simpara>
Configure uma porta TCP para ele no <link
linkend="configuration.file">arquivo de configurao</link> (<link
linkend="ini.debugger.port">debugger.port</link>) e habilite ele
(<link linkend="ini.debugger.enabled">debugger.enabled</link>).
</simpara>
</listitem>
<listitem>
<simpara>
Configure um "ouvidor" TCP naquela porta em algum programa (por exemplo
<command>socket -l -s 1400</command> no UNIX).
</simpara>
</listitem>
<listitem>
<simpara>
Em seu cdigo execute "debugger_on(<replaceable>mquina</replaceable>)", onde <replaceable>mquina</replaceable> o nmero IP ou nome do computador executando o "ouvidor" <acronym>TCP</acronym> .
</simpara>
</listitem>
</orderedlist>
Agora, todas as mensagens aparecer no computador que est "ouvindo",<emphasis> mesmo que voc desligue com <function>error_reporting</function></emphasis>.
</para>
</sect1>
<sect1 id="debugger-protocol">
<title>Protocolo do Debugger</title>
<para>
O protocolo baseado em linhas. Cada linha tem um <emphasis>tipo</emphasis>, e vrias linhas compondo a <emphasis>mensagem</emphasis>. Cada mensagem comea com uma linha de tipo <literal>start</literal> e termina com uma linha de tipo <literal>end</literal>. O PHP pode emviar linhas para diferentes mensagens simultaneamente.
</para>
<para>
Uma linha tem este formato:
<informalexample>
<literallayout>
<replaceable>date</replaceable> <replaceable>time</replaceable>
<replaceable>host</replaceable>(<replaceable>pid</replaceable>)
<replaceable>type</replaceable>:
<replaceable>message-data</replaceable>
</literallayout>
</informalexample>
<variablelist>
<varlistentry>
<term><replaceable>date</replaceable></term>
<listitem>
<simpara>
Data no formato ISO 8601
(<replaceable>yyyy</replaceable>-<replaceable>mm</replaceable>-<replaceable>dd</replaceable>)
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable>time</replaceable></term>
<listitem>
<simpara>Hora, incluindo microsegundos:
<replaceable>hh</replaceable>:<replaceable>mm</replaceable>:<replaceable>uuuuuu</replaceable>
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable>host</replaceable></term>
<listitem>
<simpara>
"Nome DNS ou IP da maquina onde est o script".
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable>pid</replaceable></term>
<listitem>
<simpara>
ID do processo na <replaceable>mquina</replaceable> do processo que gerou este erro de script.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable>type</replaceable></term>
<listitem>
<para>
Tipo da linha. Informa o programa sobre como ele deve tratar os seguintes dados:
<table>
<title>Tipos de Linhas de Debug</title>
<tgroup cols="2">
<thead>
<row>
<entry>Nome</entry>
<entry>Significado</entry>
</row>
</thead>
<tbody>
<row>
<entry><literal>start</literal></entry>
<entry>
Informa ao programa que a mensagem comea aqui. O contedo de <replaceable>data</replaceable> ser o tipo de erro da mensagem, listado abaixo.
</entry>
</row>
<row>
<entry><literal>message</literal></entry>
<entry>A mensagem de erro do PHP.</entry>
</row>
<row>
<entry><literal>location</literal></entry>
<entry>
Arquivo e nmero da linha onde ocorreu o erro. A primeira linha <literal>location</literal> sempre conter o nvel superior.
<replaceable>data</replaceable> conter:
<literal><replaceable>arquivo</replaceable>:<replaceable>linha</replaceable></literal>.
Sempre existir uma linha <literal>location</literal> aps uma <literal>message</literal> e aps cada <literal>function</literal>.
</entry>
</row>
<row>
<entry>
<literal>frames</literal></entry> <entry>Nmero de janelas (frames)
na saida atual. Se houver quatro nveis, ser esperado informao sobre quatro nveis de funes chamadas.
Se no for dada nenhuma linha de janela (frame) assume que o valor 0
(o erro aconteceu no incio).
</entry>
</row>
<row>
<entry>
<literal>function</literal></entry>
<entry>
Nome da funo onde o erro apareceu. Ser repetida para cada vez que
a funo for chamada.
</entry>
</row>
<row>
<entry><literal>end</literal></entry>
<entry>
Informa ao programa que a mensagem de debug termina aqui.
</entry>
</row>
</tbody>
</tgroup>
</table>
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable>dados</replaceable></term>
<listitem>
<simpara>Linha de dados.</simpara>
</listitem>
</varlistentry>
</variablelist>
<table>
<title>Tipos de erros de debugao</title>
<tgroup cols="2">
<thead>
<row>
<entry>Debugador</entry>
<entry>Interno do PHP</entry>
</row>
</thead>
<tbody>
<row>
<entry><errortype>ateno</errortype></entry>
<entry><errortype>E_WARNING</errortype></entry>
</row>
<row>
<entry><errortype>erro</errortype></entry>
<entry><errortype>E_ERROR</errortype></entry>
</row>
<row>
<entry><errortype>interpretao</errortype></entry>
<entry><errortype>E_PARSE</errortype></entry>
</row>
<row>
<entry><errortype>notificao</errortype></entry>
<entry><errortype>E_NOTICE</errortype></entry>
</row>
<row>
<entry><errortype>grave erro</errortype></entry>
<entry><errortype>E_CORE_ERROR</errortype></entry>
</row>
<row>
<entry><errortype>grave ateno</errortype></entry>
<entry><errortype>E_CORE_WARNING</errortype></entry>
</row>
<row>
<entry><errortype>desconhecido</errortype></entry>
<entry>(qualquer outro)</entry>
</row>
</tbody>
</tgroup>
</table>
<example>
<title>Exemplo de Mensagem de Debug</title>
<literallayout>
1998-04-05 23:27:400966 lucifer.guardian.no(20481) start: notice
1998-04-05 23:27:400966 lucifer.guardian.no(20481) message: Uninitialized variable
1998-04-05 23:27:400966 lucifer.guardian.no(20481) location: (&null;):7
1998-04-05 23:27:400966 lucifer.guardian.no(20481) frames: 1
1998-04-05 23:27:400966 lucifer.guardian.no(20481) function: display
1998-04-05 23:27:400966 lucifer.guardian.no(20481) location: /home/ssb/public_html/test.php3:10
1998-04-05 23:27:400966 lucifer.guardian.no(20481) end: notice
</literallayout>
</example>
</para>
</sect1>
</appendix>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
-->
|