diff --git a/slides/slides.tex b/slides/slides.tex index dcfd8dd..ece4303 100644 --- a/slides/slides.tex +++ b/slides/slides.tex @@ -17,6 +17,8 @@ \setbeamertemplate{navigation symbols}{} +\newcommand{\thenalert}[1]{\only<1>{#1}\only<2>{\alert{#1}}} + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \author[Théophile Bastian]{Théophile \textsc{Bastian} \\ \small{Under supervision of Francesco Zappa Nardelli}} @@ -163,4 +165,128 @@ $1 = 84 \end{frame} +\begin{frame}[fragile]{The real DWARF} + \begin{lstlisting}[numbers=none, language=] +00009b30 48 009b34 FDE cie=0000 pc=0084950..0084b37 + DW_CFA_advance_loc: 2 to 0000000000084952 + DW_CFA_def_cfa_offset: 16 + DW_CFA_offset: r15 (r15) at cfa-16 + DW_CFA_advance_loc: 2 to 0000000000084954 + DW_CFA_def_cfa_offset: 24 + DW_CFA_offset: r14 (r14) at cfa-24 + DW_CFA_advance_loc: 2 to 0000000000084956 + DW_CFA_def_cfa_offset: 32 + DW_CFA_offset: r13 (r13) at cfa-32 + DW_CFA_advance_loc: 2 to 0000000000084958 + DW_CFA_def_cfa_offset: 40 + DW_CFA_offset: r12 (r12) at cfa-40 + DW_CFA_advance_loc: 1 to 0000000000084959 + DW_CFA_def_cfa_offset: 48 + DW_CFA_offset: r6 (rbp) at cfa-48 + DW_CFA_advance_loc: 1 to 000000000008495a + [...] + \end{lstlisting} +\end{frame} + +\begin{frame}{Why does slow matter?} + \textbf{Do we really care about speed for unwinding?} + \begin{itemize} + + \item{} After all, we're talking about \alert{debugging procedures} ran + by a \alert{human being} (slower than the machine). + + \ldots{}or are we? + + \pause{}\item{} \alert{Profiling} with polling profilers + + \pause{}\item{} \alert{Exception handling} in C++ + + \end{itemize} + + \vspace{2em} + + \begin{center} + \textbf{Debug data is not only for debugging} + \end{center} +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\section{Compiling DWARF} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\subsection{Compilation Strategy} + +\begin{frame}[fragile]{Types} + Generated data: + \lstinputlisting[language=C]{src/unwind_context.c} + \pause{} + + \vspace{1em} + Function type: + \begin{lstlisting}[language=C] +unwind_context_t _eh_elf( + unwind_context_t, instruction_pointer_t); \end{lstlisting} +\end{frame} + +\begin{frame}{Compilation overview} + \begin{itemize} + \item Compiled to \alert{C code} + \item C code then \alert{compiled to native binary} (gcc) + \begin{itemize} + \item[$\leadsto$] gcc optimisations for free + \end{itemize} + \item Compiled as \alert{separate \texttt{.so} files}, called \ehelfs{} + \bigskip{} + \item Morally a \alert{monolithic switch} on IPs + \item Each case fills the context structure + \end{itemize} +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\subsection{Outlining} + +\begin{frame}{Size optimisation: outlining} + \begin{itemize} + \item This \alert{works}, but \alert{takes space}: about \alert{7 times + heavier} than regular DWARF\@. + + \item DWARF optimisation strategy: \alert{alter previous row}. \\ + Causes slowness: we cannot do that. + + \item Remark: a lot of lines appear often. + \begin{itemize} + \item[$\leadsto$] \emph{outline} them! + \end{itemize} + \end{itemize} + + \pause{} + + \textbf{Outlining:} + \begin{itemize} + \item Turn the big switch into a binary search \alert{if/else tree} + \item \alert{Extract} the conditional bodies, put them afterwards + \item Jump to them using a \alert{label/goto} + \end{itemize} + + \pause{} + + \bigskip{} + \begin{center} + $\leadsto$ only \textbf{2.5 times heavier than DWARF} + \end{center} +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\section{Benchmarking} + +\begin{frame}{Benchmarking requirements} + \todo{} +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\subsection{} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\section{A glance at future work} + \end{document} diff --git a/slides/src/unwind_context.c b/slides/src/unwind_context.c new file mode 100644 index 0000000..eb54302 --- /dev/null +++ b/slides/src/unwind_context.c @@ -0,0 +1,4 @@ +typedef struct { + uint8_t flags; // State (registers filled, error) + uintptr_t rip, rsp, rbp, rbx; // Registers' values +} unwind_context_t;