From owner-svn-ports-head@FreeBSD.ORG Mon Dec 22 14:50:48 2014 Return-Path: Delivered-To: svn-ports-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 117328BB; Mon, 22 Dec 2014 14:50:48 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E628C37B; Mon, 22 Dec 2014 14:50:47 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sBMEolD8076627; Mon, 22 Dec 2014 14:50:47 GMT (envelope-from rea@FreeBSD.org) Received: (from rea@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sBMEolgq076624; Mon, 22 Dec 2014 14:50:47 GMT (envelope-from rea@FreeBSD.org) Message-Id: <201412221450.sBMEolgq076624@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: rea set sender to rea@FreeBSD.org using -f From: Eygene Ryabinkin Date: Mon, 22 Dec 2014 14:50:47 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r375240 - in head/www/squid: . files X-SVN-Group: ports-head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the ports tree for head List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Dec 2014 14:50:48 -0000 Author: rea Date: Mon Dec 22 14:50:46 2014 New Revision: 375240 URL: https://svnweb.freebsd.org/changeset/ports/375240 QAT: https://qat.redports.org/buildarchive/r375240/ Log: www/squid: implement proper backtrace support Now Squid will print full backtrace for problematic cases when it is about to die on some signal and should emit stacktrace. You'll obviously need to compile it with STACKTRACES option. Tested at: KIAE Grid production Squid cluster MFC after: 1 week MFH: 2014Q4 Sponsored by: Kurchatov Institute of Atomic Energy Added: head/www/squid/files/extra-patch-gen-stacktrace (contents, props changed) Modified: head/www/squid/Makefile Modified: head/www/squid/Makefile ============================================================================== --- head/www/squid/Makefile Mon Dec 22 14:36:52 2014 (r375239) +++ head/www/squid/Makefile Mon Dec 22 14:50:46 2014 (r375240) @@ -2,7 +2,7 @@ PORTNAME= squid PORTVERSION= 3.4.10 -PORTREVISION= 1 +PORTREVISION= 2 CATEGORIES= www ipv6 MASTER_SITES= http://www.squid-cache.org/Versions/v3/${PORTVERSION:R}/ \ http://www2.us.squid-cache.org/Versions/v3/${PORTVERSION:R}/ \ @@ -97,6 +97,7 @@ SNMP_CONFIGURE_ENABLE= snmp SSL_CONFIGURE_ENABLE= ssl SSL_CRTD_CONFIGURE_ENABLE= ssl-crtd STACKTRACES_CONFIGURE_ENABLE= stacktraces +STACKTRACES_LIB_DEPENDS= libunwind.so:${PORTSDIR}/devel/libunwind TP_IPFW_CONFIGURE_ENABLE= ipfw-transparent TP_IPF_CONFIGURE_ENABLE= ipf-transparent TP_PF_CONFIGURE_ENABLE= pf-transparent @@ -300,7 +301,9 @@ LDFLAGS+= -L${OPENSSLLIB} .if ${PORT_OPTIONS:MSTACKTRACES} CFLAGS+= -g +LDFLAGS+= -lunwind -L${LOCALBASE}/lib STRIP= +EXTRA_PATCHES+= ${FILESDIR}/extra-patch-gen-stacktrace .endif .if ${PORT_OPTIONS:MDEBUG} || defined(WITH_DEBUG) Added: head/www/squid/files/extra-patch-gen-stacktrace ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/www/squid/files/extra-patch-gen-stacktrace Mon Dec 22 14:50:46 2014 (r375240) @@ -0,0 +1,124 @@ +--- src/tools.cc.orig 2014-10-31 12:36:43.000000000 +0300 ++++ src/tools.cc 2014-11-21 14:11:25.000000000 +0300 +@@ -71,6 +71,13 @@ + #include + #endif + ++#if PRINT_STACK_TRACE ++#ifdef __FreeBSD__ ++#define UNW_LOCAL_ONLY ++#include ++#endif ++#endif ++ + #define DEAD_MSG "\ + The Squid Cache (version %s) died.\n\ + \n\ +@@ -411,6 +418,45 @@ + } + + #endif ++#ifdef __FreeBSD__ ++ do { ++ unw_context_t unw_ctx; ++ unw_cursor_t unw_cp; ++ unw_word_t sp, ip, off; ++ int rc = 0; ++ char procname[256]; ++ size_t frame; ++ ++ bzero((void *)&unw_ctx, sizeof(unw_ctx)); ++ bzero((void *)&unw_cp, sizeof(unw_cp)); ++ ++ if ((rc = unw_getcontext(&unw_ctx))) { ++ fprintf(debug_log, "Failed to trace own stack: " ++ "unw_context() said '%s'.\n", unw_strerror(rc)); ++ break; ++ } ++ if ((rc = unw_init_local(&unw_cp, &unw_ctx))) { ++ fprintf(debug_log, "Failed to trace own stack: " ++ "unw_init_local() said '%s'.\n", unw_strerror(rc)); ++ break; ++ } ++ frame = 0; ++ fprintf(debug_log, "Backtrace follows (deepest frame first):\n"); ++ while ((rc = unw_step(&unw_cp)) > 0) { ++ frame++; ++ ip = 0; sp = 0; ++ unw_get_reg(&unw_cp, UNW_REG_IP, &ip); ++ unw_get_reg(&unw_cp, UNW_REG_SP, &sp); ++ off = 0; ++ rc = unw_get_proc_name(&unw_cp, procname, sizeof(procname), &off); ++ if (rc) ++ snprintf (procname, sizeof(procname), "[unknown]"); ++ fprintf(debug_log, "#%zd: %s + 0x%zx, ip = 0x%zx, sp = 0x%zx\n", ++ frame, procname, (size_t)off, (size_t)ip, (size_t)sp); ++ } ++ fprintf(debug_log, "Use addr2line of similar to translate offsets to line information.\n"); ++ } while (0); ++#endif /* __FreeBSD__ */ + #endif /* PRINT_STACK_TRACE */ + + #if SA_RESETHAND == 0 && !_SQUID_WINDOWS_ +--- src/tools.cc.orig 2014-10-31 12:36:43.000000000 +0300 ++++ src/tools.cc 2014-11-21 14:11:25.000000000 +0300 +@@ -71,6 +71,13 @@ + #include + #endif + ++#if PRINT_STACK_TRACE ++#ifdef __FreeBSD__ ++#define UNW_LOCAL_ONLY ++#include ++#endif ++#endif ++ + #define DEAD_MSG "\ + The Squid Cache (version %s) died.\n\ + \n\ +@@ -411,6 +418,45 @@ + } + + #endif ++#ifdef __FreeBSD__ ++ do { ++ unw_context_t unw_ctx; ++ unw_cursor_t unw_cp; ++ unw_word_t sp, ip, off; ++ int rc = 0; ++ char procname[256]; ++ size_t frame; ++ ++ bzero((void *)&unw_ctx, sizeof(unw_ctx)); ++ bzero((void *)&unw_cp, sizeof(unw_cp)); ++ ++ if ((rc = unw_getcontext(&unw_ctx))) { ++ fprintf(debug_log, "Failed to trace own stack: " ++ "unw_context() said '%s'.\n", unw_strerror(rc)); ++ break; ++ } ++ if ((rc = unw_init_local(&unw_cp, &unw_ctx))) { ++ fprintf(debug_log, "Failed to trace own stack: " ++ "unw_init_local() said '%s'.\n", unw_strerror(rc)); ++ break; ++ } ++ frame = 0; ++ fprintf(debug_log, "Backtrace follows (deepest frame first):\n"); ++ while ((rc = unw_step(&unw_cp)) > 0) { ++ frame++; ++ ip = 0; sp = 0; ++ unw_get_reg(&unw_cp, UNW_REG_IP, &ip); ++ unw_get_reg(&unw_cp, UNW_REG_SP, &sp); ++ off = 0; ++ rc = unw_get_proc_name(&unw_cp, procname, sizeof(procname), &off); ++ if (rc) ++ snprintf (procname, sizeof(procname), "[unknown]"); ++ fprintf(debug_log, "#%zd: %s + 0x%zx, ip = 0x%zx, sp = 0x%zx\n", ++ frame, procname, (size_t)off, (size_t)ip, (size_t)sp); ++ } ++ fprintf(debug_log, "Use addr2line of similar to translate offsets to line information.\n"); ++ } while (0); ++#endif /* __FreeBSD__ */ + #endif /* PRINT_STACK_TRACE */ + + #if SA_RESETHAND == 0 && !_SQUID_WINDOWS_