[FE training-materials-updates] sysdev-application-debugging: ltrace is working again

Alexandre Belloni alexandre.belloni at free-electrons.com
Fri Jul 25 00:16:44 CEST 2014


Repository : git://git.free-electrons.com/training-materials.git

On branch  : sysdev-xplained
Link       : http://git.free-electrons.com/training-materials/commit/?id=cd9475ae1f1d0dc435f4737d6d5972cd76b1f4a3

>---------------------------------------------------------------

commit cd9475ae1f1d0dc435f4737d6d5972cd76b1f4a3
Author: Alexandre Belloni <alexandre.belloni at free-electrons.com>
Date:   Fri Jul 25 00:15:53 2014 +0200

    sysdev-application-debugging: ltrace is working again
    
    Signed-off-by: Alexandre Belloni <alexandre.belloni at free-electrons.com>


>---------------------------------------------------------------

cd9475ae1f1d0dc435f4737d6d5972cd76b1f4a3
 .../data/0001-ltrace-use-current-master.patch      |  101 ++++++++++++++++++++
 .../sysdev-application-debugging.tex               |   25 +++--
 2 files changed, 116 insertions(+), 10 deletions(-)

diff --git a/lab-data/sysdev/buildroot/data/0001-ltrace-use-current-master.patch b/lab-data/sysdev/buildroot/data/0001-ltrace-use-current-master.patch
new file mode 100644
index 0000000..19fbbc1
--- /dev/null
+++ b/lab-data/sysdev/buildroot/data/0001-ltrace-use-current-master.patch
@@ -0,0 +1,101 @@
+From 36592dfb950380fd7e0432a5e1be4f17eef73eda Mon Sep 17 00:00:00 2001
+From: Alexandre Belloni <alexandre.belloni at free-electrons.com>
+Date: Thu, 24 Jul 2014 23:54:20 +0200
+Subject: [PATCH] ltrace: use current master
+
+ltrace 0.7.3 is the latest release but it is actually broken on ARM
+since PTRACE_SINGLESTEP emulation has been removed, see:
+
+http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=425fc47adb5bb69f76285be77a09a3341a30799e
+
+It fails with:
+PTRACE_SINGLESTEP: Input/output error
+
+Using master solves that until a new release is made.
+
+Signed-off-by: Alexandre Belloni <alexandre.belloni at free-electrons.com>
+---
+ package/ltrace/Config.in               |  1 +
+ package/ltrace/ltrace-02-arm-plt.patch | 30 ++++++++++++++++++++++++++++++
+ package/ltrace/ltrace.mk               | 13 +++++++++----
+ 3 files changed, 40 insertions(+), 4 deletions(-)
+ create mode 100644 package/ltrace/ltrace-02-arm-plt.patch
+
+diff --git a/package/ltrace/Config.in b/package/ltrace/Config.in
+index 3448342619af..aee14bd001bc 100644
+--- a/package/ltrace/Config.in
++++ b/package/ltrace/Config.in
+@@ -3,6 +3,7 @@ config BR2_PACKAGE_LTRACE
+ 	depends on (BR2_i386 || BR2_arm || BR2_mips || BR2_mipsel \
+ 		|| BR2_powerpc || BR2_sparc || BR2_x86_64)
+ 	select BR2_PACKAGE_LIBELF
++	select BR2_PACKAGE_ELFUTILS
+ 	help
+ 	  Debugging program which runs a specified command until it exits.
+ 	  While the command is executing, ltrace intercepts and records
+diff --git a/package/ltrace/ltrace-02-arm-plt.patch b/package/ltrace/ltrace-02-arm-plt.patch
+new file mode 100644
+index 000000000000..f130ce8426e7
+--- /dev/null
++++ b/package/ltrace/ltrace-02-arm-plt.patch
+@@ -0,0 +1,30 @@
++From 04377d28135e351c8d096c4392a493e937416815 Mon Sep 17 00:00:00 2001
++From: Alexandre Belloni <alexandre.belloni at free-electrons.com>
++Date: Thu, 24 Jul 2014 23:15:20 +0200
++Subject: [PATCH] Allow building with uclibc toolchains
++
++Unfortunately, uclicbc doesn't define SHT_ARM_ATTRIBUTES in elf.h
++
++Signed-off-by: Alexandre Belloni <alexandre.belloni at free-electrons.com>
++---
++ sysdeps/linux-gnu/arm/plt.c | 4 ++++
++ 1 file changed, 4 insertions(+)
++
++diff --git a/sysdeps/linux-gnu/arm/plt.c b/sysdeps/linux-gnu/arm/plt.c
++index 9e9e37f0c5b0..a0a5795eb9cb 100644
++--- a/sysdeps/linux-gnu/arm/plt.c
+++++ b/sysdeps/linux-gnu/arm/plt.c
++@@ -28,6 +28,10 @@
++ #include "library.h"
++ #include "ltrace-elf.h"
++ 
+++#ifndef SHT_ARM_ATTRIBUTES
+++#define SHT_ARM_ATTRIBUTES     0x70000003
+++#endif
+++
++ static int
++ get_hardfp(uint64_t abi_vfp_args)
++ {
++-- 
++1.9.1
++
+diff --git a/package/ltrace/ltrace.mk b/package/ltrace/ltrace.mk
+index 99c1af64b678..0a3a90c344c1 100644
+--- a/package/ltrace/ltrace.mk
++++ b/package/ltrace/ltrace.mk
+@@ -4,13 +4,18 @@
+ #
+ ################################################################################
+ 
+-LTRACE_VERSION = 0.7.3
+-LTRACE_SITE = http://sources.buildroot.net/
+-LTRACE_SOURCE = ltrace-$(LTRACE_VERSION).tar.bz2
+-LTRACE_DEPENDENCIES = libelf
++LTRACE_VERSION = 0896ce554f80afdcba81d9754f6104f863dea803
++LTRACE_SITE = git://anonscm.debian.org/collab-maint/ltrace.git
++LTRACE_DEPENDENCIES = libelf elfutils
+ LTRACE_CONF_OPT = --disable-werror
+ LTRACE_LICENSE = GPLv2
+ LTRACE_LICENSE_FILES = COPYING
++LTRACE_AUTORECONF = YES
++
++define LTRACE_CREATE_CONFIG_M4
++	mkdir -p $(@D)/config/m4
++endef
++LTRACE_POST_PATCH_HOOKS += LTRACE_CREATE_CONFIG_M4
+ 
+ # ltrace can use libunwind only if libc has backtrace() support
+ # We don't normally do so for uClibc and we can't know if it's external
+-- 
+1.9.1
+
diff --git a/labs/sysdev-application-debugging/sysdev-application-debugging.tex b/labs/sysdev-application-debugging/sysdev-application-debugging.tex
index 12f5206..dcafcb7 100644
--- a/labs/sysdev-application-debugging/sysdev-application-debugging.tex
+++ b/labs/sysdev-application-debugging/sysdev-application-debugging.tex
@@ -13,16 +13,21 @@ Go to the \code{$HOME/felabs/sysdev/debugging} directory.
 Boot your ARM board over NFS on the filesystem produced in the {\em
   Using a build system, example with Buildroot} lab, with the same kernel.
 
-%\section{Setting up gdbserver, strace and ltrace}
-\section{Setting up gdbserver and strace}
+\section{Setting up gdbserver, strace and ltrace}
 
-%\code{gdbserver}, \code{strace} and \code{ltrace} have already been
-\code{gdbserver} and \code{strace} have already been
+\code{gdbserver}, \code{strace} and \code{ltrace} have already been
 compiled for your target architecture as part of the cross-compiling
 toolchain. Find them in the installation directory of your
 toolchain. Copy these binaries to the \code{/usr/bin/} directory in
 the root filesystem of your target system.
 
+Unfortunately, the latest \code{ltrace} release is quite old and is
+not working on recent kernels. You can go back to Buildroot, apply the
+patch named \code{0001-ltrace-use-current-master.patch}, select the
+\code{ltrace} package and build. this will build a fairly recent
+version of \code{ltrace} that you can now install in your NFS
+directory.
+
 \section{Using strace}
 
 \code{strace} allows to trace all the system calls made by a process:
@@ -54,14 +59,14 @@ code!
 Now add what the program was waiting for, and now see your program
 proceed to another bug, failing with a segmentation fault.
 
-%\section{Using ltrace}
+\section{Using ltrace}
 
-%Try to run the program through \code{ltrace}. You will see that
-%another library is required to run this utility. Find this library in
-%the toolchain and add it to your root filesystem again.
+Try to run the program through \code{ltrace}. You may see that
+another library is required to run this utility. Find this library in
+the Buildroot output and add it to your root filesystem.
 
-%Now, ltrace should run fine and you should see what the program does:
-%it tries to consume as much system memory as it can!
+Now you should see what the program does: it tries to consume as much
+system memory as it can!
 
 \section{Using gdbserver}
 



More information about the training-materials-updates mailing list