Add function call tracing
Subsystems (2)
PATCH 1/2 Add function call tracing
This patch adds all the necessary functions and code that allow function tracing on the bluetoothd server. This should make race conditions and seg faults easy to debug. Off course this is not intendeed for end users.
Quoted 1 line
From
b0f4d8eeab8ee2dba77247b77ee6ce159b931d7bMon Sep 17 00:00:00 2001
From: Manuel Francisco Naranjo <[email protected]>
Date: Mon, 19 Jul 2010 13:15:22 -0300
Subject: [PATCH 1/2] Add Function call tracing
modified: Makefile.am
modified: acinclude.m4
* Add an option so configure script can be tell to enable function tracing,
for good function tracing this options need to be used:
--enable-trace \
--enable-debug \
--disable-optimization \
--disable-fortify \
--disable-pienew file: src/cyg-profile.c new file: src/cyg-profile.h
* Based on code from http://www.logix.cz/michal/devel/CygProfiler this uses -finstrument-functions from gcc and adds some function to store the tracing to a file, which will be called as bluetoothd-log.$PID
modified: src/main.c
* Allow users to enable or disable tracing (only available when configured with this option).
--- Makefile.am | 4 + acinclude.m4 | 11 ++++ src/cyg-profile.c | 169 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/cyg-profile.h | 40 +++++++++++++ src/main.c | 15 +++++ 5 files changed, 239 insertions(+), 0 deletions(-) create mode 100644 src/cyg-profile.c create mode 100644 src/cyg-profile.h
Makefile.am +4 -0
@@ -216,6 +216,10 @@ CLEANFILES += src/bluetooth.ver src/bluetooth.exp $(builtin_files) man_MANS = src/bluetoothd.8 +if TRACE +src_bluetoothd_SOURCES += src/cyg-profile.h src/cyg-profile.c +endif + if CONFIGFILES conf_DATA += src/main.conf endif
acinclude.m4 +11 -0
@@ -154,6 +154,7 @@ AC_DEFUN([AC_PATH_SNDFILE], [ AC_DEFUN([AC_ARG_BLUEZ], [ debug_enable=no + trace_enable=no optimization_enable=yes fortify_enable=yes pie_enable=yes
@@ -288,6 +289,11 @@ AC_DEFUN([AC_ARG_BLUEZ], [ debug_enable=${enableval} ]) + AC_ARG_ENABLE(trace, AC_HELP_STRING([--enable-trace], [enable compiling with function tracing information]), [ + trace_enable=${enableval} + ]) + + AC_ARG_WITH(telephony, AC_HELP_STRING([--with-telephony=DRIVER], [select telephony driver]), [ telephony_driver=${withval} ])
@@ -311,6 +317,10 @@ AC_DEFUN([AC_ARG_BLUEZ], [ CFLAGS="$CFLAGS -g" fi + if (test "${trace_enable}" = "yes" && test "${ac_cv_prog_cc_g}" = "yes"); then + CFLAGS="$CFLAGS -finstrument-functions -DTRACE" + fi + if (test "${optimization_enable}" = "no"); then CFLAGS="$CFLAGS -O0" fi
@@ -333,6 +343,7 @@ AC_DEFUN([AC_ARG_BLUEZ], [ AM_CONDITIONAL(ECHOPLUGIN, test "no" = "yes") AM_CONDITIONAL(PNATPLUGIN, test "${pnat_enable}" = "yes") AM_CONDITIONAL(TRACER, test "${tracer_enable}" = "yes") + AM_CONDITIONAL(TRACE, test "${trace_enable}" = "yes") AM_CONDITIONAL(HIDD, test "${hidd_enable}" = "yes") AM_CONDITIONAL(PAND, test "${pand_enable}" = "yes") AM_CONDITIONAL(DUND, test "${dund_enable}" = "yes")
src/cyg-profile.c new file +169 -0
169 lines not on this page · raw message
src/cyg-profile.h new file +40 -0
@@ -0,0 +1,40 @@ +/* +* cyg-profile.h - Header file for CygProfiler +* +* Michal Ludvig <[email protected]> +* http://www.logix.cz/michal/devel +* +* This source code is a public domain. +* +* See cyg-profile.c for details on usage. +*/ + +#ifndef CYG_PROFILE_H +#define CYG_PROFILE_H + +/* Public functions. */ + +#ifdef TRACE + +/* Enable/disable CygProfiler. */ +void cygprofile_enable (void ) + __attribute__ ((no_instrument_function)); +void cygprofile_disable (void ) + __attribute__ ((no_instrument_function)); + +/* Tell whether CygProfiler is enabled/disabled. */ +int cygprofile_isenabled (void ) + __attribute__ ((no_instrument_function)); + +/* Set filename of a logfile. */ +int cygprofile_setfilename (const char *filename) + __attribute__ ((no_instrument_function)); + +/* Query for a filename of a logfile. */ +char *cygprofile_getfilename (void ) + __attribute__ ((no_instrument_function)); + + +#endif //#ifdef TRACE + +#endif
src/main.c +15 -0
@@ -60,6 +60,10 @@#include <cap-ng.h> #endif +#ifdef TRACE +#include "cyg-profile.h" +#endif +#define LAST_ADAPTER_EXIT_TIMEOUT 30struct main_opts main_opts;
@@ -304,6 +308,7 @@ static gchar *option_debug = NULL;static gboolean option_detach = TRUE;static gboolean option_version = FALSE;static gboolean option_udev = FALSE; +static gboolean option_trace = FALSE;static guint last_adapter_timeout =0 ;
@@ -357,6 +362,10 @@ static GOptionEntry options[] = { "Show version information and exit" }, {"udev" ,'u' ,0 ,G_OPTION_ARG_NONE , &option_udev, "Run from udev mode of operation" }, +#ifdef TRACE + { "trace", 't', 0, G_OPTION_ARG_NONE, &option_trace, + "Create trace function calls file" }, +#endif { NULL }, };
@@ -393,6 +402,12 @@ int main(int argc, char *argv[])g_option_context_free (context); +#ifdef TRACE +if (option_trace == TRUE) { +cygprofile_enable (); + } +#endif +if (option_version == TRUE) {printf ("%s\n" ,VERSION );exit (0 );
Signature · 1 line
1.6.4.4