Translation

(itstool) path: sect3/para
Start up gdb by typing
0/220
Context English Portuguese (Brazil) State
For that to work well, the code that calls <function>fork</function> to create the child needs to do something like the following (courtesy of the <command>gdb</command> info pages):
<lineannotation>…</lineannotation>
if ((pid = fork()) &lt; 0) /* _Always_ check this */
error();
else if (pid == 0) { /* child */
int PauseMode = 1;

while (PauseMode)
sleep(10); /* Wait until someone attaches to us */
<lineannotation>…</lineannotation>
} else { /* parent */
<lineannotation>…</lineannotation>
<lineannotation>…</lineannotation>
if ((pid = fork()) &lt; 0) /* _Always_ check this */
error();
else if (pid == 0) { /* child */
int PauseMode = 1;

while (PauseMode)
sleep(10); /* Wait until someone attaches to us */
<lineannotation>…</lineannotation>
} else { /* parent */
<lineannotation>…</lineannotation>
Now all that is needed is to attach to the child, set <symbol>PauseMode</symbol> to <literal>0</literal> with <userinput>expr PauseMode = 0</userinput> and wait for the <function>sleep()</function> call to return. Agora tudo que você tem a fazer é anexar à criança, definir <symbol> PauseMode </symbol> para <literal> 0 </literal> e aguarde o <function> dormir() </function> ligue para voltar!
Remote Debugging Using LLDB Depuração do Kernel On-Line Usando o DDB
The described functionality is available starting with LLDB version 12.0.0. Users of FreeBSD releases containing an earlier LLDB version may wish to use the snapshot available in <link xlink:href="@@URL_RELPREFIX@@/doc/en_US.ISO8859-1/books/handbook/ports-using.html">ports or packages</link>, as <package>devel/llvm-devel</package>.
Starting with LLDB 12.0.0, remote debugging is supported on FreeBSD. This means that <command>lldb-server</command> can be started to debug a program on one host, while the interactive <command>lldb</command> client connects to it from another one.
To launch a new process to be debugged remotely, run <command>lldb-server</command> on the remote server by typing
<prompt>%</prompt> <userinput>lldb-server g <replaceable>host:port</replaceable> -- <replaceable>progname</replaceable></userinput> <prompt>%</prompt> <userinput>comm -23 ../<replaceable>old</replaceable> ../<replaceable>new</replaceable></userinput>
The process will be stopped immediately after launching, and <command>lldb-server</command> will wait for the client to connect.
Start <command>lldb</command> locally and type the following command to connect to the remote server:
(lldb) <userinput>gdb-remote <replaceable>host:port</replaceable></userinput> (gdb) <userinput>attach <replaceable>pid</replaceable></userinput>
<command>lldb-server</command> can also attach to a running process. To do that, type the following on the remote server:
<prompt>%</prompt> <userinput>lldb-server g <replaceable>host:port</replaceable> --attach <replaceable>pid-or-name</replaceable></userinput> <prompt>%</prompt> <userinput>comm -23 ../<replaceable>old</replaceable> ../<replaceable>new</replaceable></userinput>
Using gdb
Starting gdb
Start up gdb by typing
<prompt>%</prompt> <userinput>gdb <replaceable>progname</replaceable></userinput> <prompt>%</prompt> <userinput>gdb <replaceable>progname</replaceable></userinput>
although many people prefer to run it inside <application>Emacs</application>. To do this, type: embora muitas pessoas prefiram correr dentro <application> Emacs </application> . Você pode fazer isso por:
<userinput>M-x gdb RET <replaceable>progname</replaceable> RET</userinput> <userinput>M-x gdb RET <replaceable>progname</replaceable> RET</userinput>
Finally, for those finding its text-based command-prompt style off-putting, there is a graphical front-end for it (<package>devel/xxgdb</package>) in the Ports Collection. Finalmente, se você achar que o estilo de prompt de comando baseado em texto é desagradável, há um front-end gráfico para ele ( <package> devel / xxgdb </package> ) na coleção de Portos
Running a Program with gdb Executando um programa no depurador
Compile the program with <option>-g</option> to get the most out of using <command>gdb</command>. It will work without, but will only display the name of the function currently running, instead of the source code. A line like: Você precisará ter compilado o programa com o <option value=-g> -g </option> opção para tirar o máximo proveito do uso <command> gdb </command> . Ele funcionará sem, mas você verá apenas o nome da função em que está, em vez do código-fonte. Se você vir uma linha como:
… (no debugging symbols found) … … (no debugging symbols found) …
when <command>gdb</command> starts up means that the program was not compiled with <option>-g</option>. quando <command> gdb </command> inicia, você saberá que o programa não foi compilado com o <option value=-g> -g </option> opção.
At the <command>gdb</command> prompt, type <userinput>break main</userinput>. This will tell the debugger to skip the preliminary set-up code in the program being run and to stop execution at the beginning of the program's code. Now type <userinput>run</userinput> to start the program— it will start at the beginning of the set-up code and then get stopped by the debugger when it calls <function>main()</function>. No <command> gdb </command> prompt, digite <userinput> quebrar principal </userinput> . Isso dirá ao depurador que você não está interessado em observar o código de configuração preliminar no programa que está sendo executado e que ele deve interromper a execução no início de seu código. Agora digite <userinput> corre </userinput> para iniciar o programa - ele será iniciado no início do código de configuração e, em seguida, será interrompido pelo depurador quando ele for chamado <function> a Principal() </function> . (Se você já se perguntou onde <function> a Principal() </function> é chamado, agora você sabe!).
To step through the program a line at a time, press <command>n</command>. When at a function call, step into it by pressing <command>s</command>. Once in a function call, return from it by pressing <command>f</command>, or use <command>up</command> and <command>down</command> to take a quick look at the caller. Agora você pode percorrer o programa, uma linha de cada vez, pressionando <command> n </command> . Se você chegar a uma chamada de função, poderá entrar nela pressionando <command> s </command> . Quando estiver em uma chamada de função, você pode retornar de uma chamada de função pressionando <command> f </command> . Você também pode usar <command> acima </command> e <command> baixa </command> para dar uma olhada rápida no chamador
Here is a simple example of how to spot a mistake in a program with <command>gdb</command>. This is our program (with a deliberate mistake): Aqui está um exemplo simples de como identificar um erro em um programa com <command> gdb </command> . Este é o nosso programa (com um erro deliberado):
<prompt>%</prompt> <userinput>cc -g -o temp temp.c</userinput>
<prompt>%</prompt> <userinput>./temp</userinput>
This is my program
anint = 4231
<prompt>%</prompt> <userinput>cc -g -o temp temp.c</userinput>
<prompt>%</prompt> <userinput>./temp</userinput>
This is my program
anint = 4231
That was not what we expected! Time to see what is going on! Isso não foi o que esperávamos! Hora de ver o que está acontecendo!
<prompt>%</prompt> <userinput>gdb temp</userinput>
GDB is free software and you are welcome to distribute copies of it
under certain conditions; type "show copying" to see the conditions.
There is absolutely no warranty for GDB; type "show warranty" for details.
GDB 4.13 (i386-unknown-freebsd), Copyright 1994 Free Software Foundation, Inc.
(gdb) <userinput>break main</userinput> <lineannotation>Skip the set-up code</lineannotation>
Breakpoint 1 at 0x160f: file temp.c, line 9. <lineannotation>gdb puts breakpoint at main()</lineannotation>
(gdb) <userinput>run</userinput> <lineannotation>Run as far as main()</lineannotation>
Starting program: /home/james/tmp/temp <lineannotation>Program starts running</lineannotation>

Breakpoint 1, main () at temp.c:9 <lineannotation>gdb stops at main()</lineannotation>
(gdb) <userinput>n</userinput> <lineannotation>Go to next line</lineannotation>
This is my program <lineannotation>Program prints out</lineannotation>
(gdb) <userinput>s</userinput> <lineannotation>step into bazz()</lineannotation>
bazz (anint=4231) at temp.c:17 <lineannotation>gdb displays stack frame</lineannotation>
(gdb)
<prompt>%</prompt> <userinput>gdb temp</userinput>
GDB is free software and you are welcome to distribute copies of it
under certain conditions; type "show copying" to see the conditions.
There is absolutely no warranty for GDB; type "show warranty" for details.
GDB 4.13 (i386-unknown-freebsd), Copyright 1994 Free Software Foundation, Inc.
(gdb) <userinput>break main</userinput> <lineannotation>Skip the set-up code</lineannotation>
Breakpoint 1 at 0x160f: file temp.c, line 9. <lineannotation>gdb puts breakpoint at main()</lineannotation>
(gdb) <userinput>run</userinput> <lineannotation>Run as far as main()</lineannotation>
Starting program: /home/james/tmp/temp <lineannotation>Program starts running</lineannotation>

Breakpoint 1, main () at temp.c:9 <lineannotation>gdb stops at main()</lineannotation>
(gdb) <userinput>n</userinput> <lineannotation>Go to next line</lineannotation>
This is my program <lineannotation>Program prints out</lineannotation>
(gdb) <userinput>s</userinput> <lineannotation>step into bazz()</lineannotation>
bazz (anint=4231) at temp.c:17 <lineannotation>gdb displays stack frame</lineannotation>
(gdb)
Hang on a minute! How did <symbol>anint</symbol> get to be <literal>4231</literal>? Was it not set to <literal>5</literal> in <function>main()</function>? Let us move up to <function>main()</function> and have a look. Espere um minuto! Como foi <symbol> não anint </symbol> chegar a ser <literal> 4231 </literal> ? Nós não definimos para sermos <literal> 5 </literal> dentro <function> a Principal() </function> ? Vamos subir para <function> a Principal() </function> e dê uma olhada.

Loading…

No matching activity found.

Browse all component changes

Glossary

English Portuguese (Brazil)
No related strings found in the glossary.

Source information

Source string comment
(itstool) path: sect3/para
Source string location
book.translate.xml:2090
String age
5 months ago
Source string age
5 months ago
Translation file
books/pt_BR/developers-handbook.po, string 377