Files
archived-doc-pt-br/reference/errorfunc/functions/debug-backtrace.xml
Leonardo Lara Rodrigues 146f827023 sync with en rev
2025-05-16 10:47:32 -03:00

283 lines
8.0 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: a124543dd3f6b1e5567b07420d23899e582514dc Maintainer: leonardolara Status: ready -->
<refentry xml:id="function.debug-backtrace" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>debug_backtrace</refname>
<refpurpose>Gera uma rastreamento retroativo</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>array</type><methodname>debug_backtrace</methodname>
<methodparam choice="opt"><type>int</type><parameter>options</parameter><initializer><constant>DEBUG_BACKTRACE_PROVIDE_OBJECT</constant></initializer></methodparam>
<methodparam choice="opt"><type>int</type><parameter>limit</parameter><initializer>0</initializer></methodparam>
</methodsynopsis>
<para>
<function>debug_backtrace</function> gera um rastreamento retroativo do PHP.
</para>
</refsect1>
<refsect1 role="parameters"><!-- {{{ -->
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>options</parameter></term>
<listitem>
<para>
Este parâmetro é uma máscara de bits para as seguintes opções:
<table>
<title>Opções de <function>debug_backtrace</function></title>
<tgroup cols="2">
<tbody>
<row>
<entry>DEBUG_BACKTRACE_PROVIDE_OBJECT</entry>
<entry>
Define se o índice "object" deve ou não ser preenchido.
</entry>
</row>
<row>
<entry>DEBUG_BACKTRACE_IGNORE_ARGS</entry>
<entry>
Define se o índice "args" deve ou não ser omitido, e consequentemente todos os argumentos de métodos e funções,
para economizar memória.
</entry>
</row>
</tbody>
</tgroup>
</table>
<note>
<para>
Existem quatro combinações possíveis:
<table>
<title>Opções de <function>debug_backtrace</function></title>
<tgroup cols="2">
<tbody>
<row>
<entry><code>debug_backtrace()</code></entry>
<entry morerows="2" valign="middle">
Preenche ambos os índices
</entry>
</row>
<row>
<entry><code>debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT)</code></entry>
</row>
<row>
<entry><code>debug_backtrace(1)</code></entry>
</row>
<row>
<entry><code>debug_backtrace(0)</code></entry>
<entry valign="middle">
Omite o índice <literal>"object"</literal> e preenche o índice <literal>"args"</literal>.
</entry>
</row>
<row>
<entry><code>debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS)</code></entry>
<entry morerows="1" valign="middle">
Omite o índice <literal>"object"</literal> <emphasis>e</emphasis> o índice <literal>"args"</literal>.
</entry>
</row>
<row>
<entry><code>debug_backtrace(2)</code></entry>
</row>
<row>
<entry><code>debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT|DEBUG_BACKTRACE_IGNORE_ARGS)</code></entry>
<entry morerows="1" valign="middle">
Preenche o índice <literal>"object"</literal> <emphasis>e</emphasis> omite o índice <literal>"args"</literal>.
</entry>
</row>
<row>
<entry><code>debug_backtrace(3)</code></entry>
</row>
</tbody>
</tgroup>
</table>
</para>
</note>
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>limit</parameter></term>
<listitem>
<para>
Este parâmetro pode ser usado para limitar o número de estruturas de pilha retornados.
Por padrão (<parameter>limit</parameter>=<literal>0</literal>) todas as estruturas são retornadas.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1><!-- }}} -->
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Retorna um array de <type>array</type>s associativos. Os elementos possíveis retornados
são os seguintes:
</para>
<para>
<table>
<title>Elementos possíveis retornados de <function>debug_backtrace</function></title>
<tgroup cols="3">
<thead>
<row>
<entry>&Name;</entry>
<entry>&Type;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>function</entry>
<entry><type>string</type></entry>
<entry>
O nome da função atual. Consulte também
<link linkend="language.constants.magic">__FUNCTION__</link>.
</entry>
</row>
<row>
<entry>line</entry>
<entry><type>int</type></entry>
<entry>
O número da linha atual. Consulte também
<link linkend="language.constants.magic">__LINE__</link>.
</entry>
</row>
<row>
<entry>file</entry>
<entry><type>string</type></entry>
<entry>
O nome do arquivo atual. Consulte também
<link linkend="language.constants.magic">__FILE__</link>.
</entry>
</row>
<row>
<entry>class</entry>
<entry><type>string</type></entry>
<entry>
O nome da <link linkend="language.oop5">classe</link> atual. Consulte também
<link linkend="language.constants.magic">__CLASS__</link>
</entry>
</row>
<row>
<entry>object</entry>
<entry><type>object</type></entry>
<entry>
O <link linkend="language.oop5">objeto</link> atual.
</entry>
</row>
<row>
<entry>type</entry>
<entry><type>string</type></entry>
<entry>
O tipo de chamada atual. Se for chamada de método, "-&gt;" é retornado. Se for chamada de
método estático, "::" é retornado. Se for chamada de função, nada é retornado.
</entry>
</row>
<row>
<entry>args</entry>
<entry><type>array</type></entry>
<entry>
Se for dentro de uma função, isto lista os arumentos da função. Se
for dentro de um arquivo incluído, isto lista o nome do arquivo incluído.
</entry>
</row>
</tbody>
</tgroup>
</table>
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Exemplo de <function>debug_backtrace</function></title>
<programlisting role="php">
<![CDATA[
<?php
// filename: /tmp/a.php
function a_test($str)
{
echo "\nHi: $str";
var_dump(debug_backtrace());
}
a_test('friend');
?>
<?php
// filename: /tmp/b.php
include_once '/tmp/a.php';
?>
]]>
</programlisting>
<para>
Resultados similares ao seguinte ao executar
<filename>/tmp/b.php</filename>:
</para>
<screen>
<![CDATA[
Hi: friend
array(2) {
[0]=>
array(4) {
["file"] => string(10) "/tmp/a.php"
["line"] => int(10)
["function"] => string(6) "a_test"
["args"]=>
array(1) {
[0] => &string(6) "friend"
}
}
[1]=>
array(4) {
["file"] => string(10) "/tmp/b.php"
["line"] => int(2)
["args"] =>
array(1) {
[0] => string(10) "/tmp/a.php"
}
["function"] => string(12) "include_once"
}
}
]]>
</screen>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>trigger_error</function></member>
<member><function>debug_print_backtrace</function></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- 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:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->