|
1606 | 1606 | \begin{slide}
|
1607 | 1607 | \sltitle{GNU debugger \texttt{gdb}}
|
1608 | 1608 | \begin{itemize}
|
1609 |
| -\item Volání:\\ |
| 1609 | +\item Usage:\\ |
1610 | 1610 | \texttt{gdb [ \emph{options} ] [ \emph{program} [ \emph{core} ] ]}
|
1611 |
| -\item Nejbì¾nìj¹í pøíkazy:\\ |
| 1611 | +\item Most common commands:\\ |
1612 | 1612 | \renewcommand{\arraystretch}{0.9}
|
1613 | 1613 | \begin{tabular}{ll}
|
1614 |
| -\texttt{run [\emph{arglist}]} & start programu\\ |
1615 |
| -\texttt{bt} & vypi¹ zásobník\\ |
1616 |
| -\texttt{print \emph{expr}} & vypi¹ výraz\\ |
1617 |
| -\texttt{set \emph{var} = \emph{expr}} & zmìò hodnotu promìnné\\ |
1618 |
| -\texttt{cont} & pokraèování bìhu programu\\ |
1619 |
| -\texttt{next}, \texttt{step} & proveï øádku (bez/s vnoøením do funkce)\\ |
1620 |
| -\texttt{break \emph{condition}} & nastavení breakpointu\\ |
1621 |
| -\texttt{help [\emph{name}]} & nápovìda\\ |
1622 |
| -\texttt{quit} & ukonèení debuggeru |
| 1614 | +\texttt{run [\emph{arglist}]} & programu start\\ |
| 1615 | +\texttt{bt} & print stack\\ |
| 1616 | +\texttt{print \emph{expr}} & print expression\\ |
| 1617 | +\texttt{set \emph{var} = \emph{expr}} & change value of variable\\ |
| 1618 | +\texttt{cont} & continue program run\\ |
| 1619 | +\texttt{next}, \texttt{step} & execute a line (with/out going into func)\\ |
| 1620 | +\texttt{break \emph{condition}} & set breakpoint\\ |
| 1621 | +\texttt{help [\emph{name}]} & print help\\ |
| 1622 | +\texttt{quit} & debugger exit |
1623 | 1623 | \end{tabular}
|
1624 | 1624 | \end{itemize}
|
1625 | 1625 | \end{slide}
|
1626 | 1626 |
|
1627 | 1627 | \begin{itemize}
|
1628 |
| -\item GNU obdoba \texttt{dbx}. Mód kompatibilní s \texttt{dbx} spustíte pøes |
1629 |
| -\texttt{-dbx}. |
1630 |
| -\item na rùzných platformách existují i debuggery s grafickým |
1631 |
| -rozhraním, napø. \texttt{workshop} (Solaris), \texttt{cvd} (IRIX), |
1632 |
| -\texttt{xxgdb} (GNU), \texttt{ddd} (GNU). Èasto fungují jako |
1633 |
| -nadstavby nad \texttt{dbx}, \texttt{gdb}. |
| 1628 | +\item GNU analogy of \texttt{dbx}. The \texttt{dbx} compatibility mode can be |
| 1629 | +enabled using the \texttt{-dbx} option. |
| 1630 | +\item Most platforms today offer debuggers with graphical front end. Often they |
| 1631 | +are implemented on top of \texttt{gdb}. |
1634 | 1632 |
|
1635 | 1633 | \item \begin{verbatim}
|
1636 | 1634 | #include <stdio.h>
|
|
1655 | 1653 | Program exited normally.
|
1656 | 1654 | (gdb) q
|
1657 | 1655 | \end{verbatim}
|
1658 |
| -\item debuggery jsou výbornými pomocníky pokud vá¹ program konèí na chyby typu |
1659 |
| -``segmentation error'' -- tj. kdy¾ zkusíte nekorektnì pøistoupit do pamìti, |
1660 |
| -napøíklad tam kde nemáte co dìlat. Kdy¾ pøi pøekladu pou¾ijete option |
1661 |
| -\texttt{-g}, uká¾e vám pak debugger pøesnì èíslo øádku, kde nastal problém. |
1662 |
| -Konkrétní pøíklad (proè se vlastnì tento program chová jak se chová??? Hint: |
1663 |
| -zkuste pøelo¾it na Solarisu pøekladaèem \texttt{cc} a spustit): |
| 1656 | +\item Debuggers are great help when your program exits with |
| 1657 | +``segmentation error'' -- i.e. when accessing memory incorrectly. |
| 1658 | +When the \texttt{-g} option is used when compiling the debugger will be able to |
| 1659 | +show exact line of code where the problem happened. |
| 1660 | +Concrete example (can you tell why the program behaves in such a way ?): |
1664 | 1661 | \begin{verbatim}
|
1665 | 1662 | $ cat -n main.c
|
1666 | 1663 | 1 int
|
|
0 commit comments