From 7b2abe24fccf70eb427c04729d7ecd9185e4862c Mon Sep 17 00:00:00 2001
From: Jan Altenberg <jan@linutronix.de>
Date: Thu, 29 Apr 2010 13:59:29 +0200
Subject: - Added some stuff for cross development. - Handout for the debugging
 chapter! - Added malloc() hooks

---
 .../app-debugging/pres_app-debugging_de.tex        | 30 ++++++++++++++++++----
 1 file changed, 25 insertions(+), 5 deletions(-)

(limited to 'application-devel/app-debugging/pres_app-debugging_de.tex')

diff --git a/application-devel/app-debugging/pres_app-debugging_de.tex b/application-devel/app-debugging/pres_app-debugging_de.tex
index d9482d9..7940bf4 100644
--- a/application-devel/app-debugging/pres_app-debugging_de.tex
+++ b/application-devel/app-debugging/pres_app-debugging_de.tex
@@ -6,7 +6,6 @@
 \usepackage{graphicx}
 \usepackage{lxextras}
 
-\lstset{keywordstyle=\color{blue},commentstyle=\color{orange}}
 
 \title{Block \lq Debugging\rq}
 \institute{Linutronix GmbH}
@@ -188,7 +187,7 @@ Core was generated by `./hello_segfault'.
 Program terminated with signal 11, Segmentation fault.
 #0  0x0000000000400538 in main () at hello_crash.c:6
 6		printf("Hello segfaulting world\n",
-                                        *arthur_dent);
+				*arthur_dent);
 (gdb) bt
 #0  0x0000000000400538 in main () at hello_crash.c:6
 \end{lstlisting}
@@ -324,6 +323,17 @@ Address   Size   Caller
 \end{lstlisting}
 \end{frame}
 
+\begin{frame}[containsverbatim]
+\frametitle{GLIBC eigene Mechanismen: Hooks für malloc()}
+\_\_malloc\_hook:\\
+void *function (size\_t size, const void *caller)\\
+\_\_realloc\_hook:\\
+void *function (void *ptr, size\_t size, const void *caller)\\
+\_\_free\_hook:\\
+void *function (void *ptr, const void *caller)\\
+\_\_memalign\_hook:\\
+void *function (size\_t size, size\_t alignment, const void *caller)
+\end{frame}
 \subsection{libDUMA (aka electric fence)}
 \begin{frame}[containsverbatim]
 \frametitle{libDUMA / electric fence}
@@ -370,7 +380,7 @@ DUMA: ptr=0x7f7280bddfff size=1 type='malloc()'
 \end{frame}
 
 \begin{frame}[containsverbatim]
-\frametitle{libDUMA / electric fence: Überschriebender Speicher}
+\frametitle{libDUMA / electric fence: Überschriebener Speicher}
 \begin{lstlisting}[language=C,basicstyle=\ttfamily\fontsize{8}{8}\selectfont]
 /* array_access.c */
 #include <stdio.h>
@@ -396,8 +406,8 @@ $ gcc -g -o array_access array_access.c
 \end{lstlisting}
 \end{frame}
 
-\frametitle{libDUMA / electric fence: Überschriebener Speicher}
 \begin{frame}[containsverbatim]
+\frametitle{libDUMA / electric fence: Überschriebener Speicher}
 \begin{lstlisting}[language=bash,basicstyle=\ttfamily\fontsize{9}{9}\selectfont]
 $ gcc -lduma -g -o array_access array_access.c
 $ ulimit -c unlimited
@@ -414,6 +424,16 @@ $1 = 10
 \end{lstlisting}
 \end{frame}
 
+\begin{frame}[containsverbatim]
+\frametitle{libDUMA / electric fence: Überschriebener Speicher}
+\begin{lstlisting}[language=bash,basicstyle=\ttfamily\fontsize{9}{9}\selectfont]
+$ gcc -g -o array_access array_access.c
+$ LD_PRELOAD=/usr/lib/libduma.so ./array_access
+Segmentation fault (core dumped)
+[...]
+\end{lstlisting}
+\end{frame}
+
 \subsection{valgrind}
 \begin{frame}
 \frametitle{Valgrind}
@@ -452,7 +472,7 @@ $ gcc -g -o mem_leak mem_leak.c
 \end{lstlisting}
 \end{frame}
 \begin{frame}[containsverbatim]
-\begin{lstlisting}[language=bash,basicstyle=\ttfamily\fontsize{9}{9}\selectfont]
+\begin{lstlisting}[basicstyle=\ttfamily\fontsize{9}{9}\selectfont]
 $ valgrind --leak-check=full ./mem_leak
 =5764= Memcheck, a memory error detector
 =5764= Copyright (C) 2002-2009, and GNU GPL'd, by
-- 
cgit v1.2.3

