Commit 922d90c8 authored by Darek Stojaczyk's avatar Darek Stojaczyk Committed by Tomasz Zawadzki
Browse files

log: remove backtrace printing



It was broken since long ago. --enable-log-bt doesn't change
anything. log.c expects SPDK_LOG_BACKTRACE_LVL to be defined
for backtrace to work, but it's not defined anywhere.

Apparently nobody needs this, so remove it.

Change-Id: I2313fd24198b0bf718663f2eafee9b5c6efa0a7f
Signed-off-by: default avatarDarek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2194


Community-CI: Broadcom CI
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 7ef49701
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -43,9 +43,6 @@ CONFIG_CROSS_PREFIX=
# Build with debug logging. Turn off for performance testing and normal usage
CONFIG_DEBUG=n

# Build with support of backtrace printing in log messages. Requires libunwind.
CONFIG_LOG_BACKTRACE=n

# Treat warnings as errors (fail the build on any warning).
CONFIG_WERROR=n

+0 −16
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@ function usage()
	echo "                           example: aarch64-linux-gnu"
	echo ""
	echo " --enable-debug            Configure for debug builds"
	echo " --enable-log-bt           Enable support of backtrace printing in SPDK logs (requires libunwind)."
	echo " --enable-werror           Treat compiler warnings as errors"
	echo " --enable-asan             Enable address sanitizer"
	echo " --enable-ubsan            Enable undefined behavior sanitizer"
@@ -211,12 +210,6 @@ for i in "$@"; do
		--disable-debug)
			CONFIG[DEBUG]=n
			;;
		--enable-log-bt)
			CONFIG[LOG_BACKTRACE]=y
			;;
		--disable-log-bt)
			CONFIG[LOG_BACKTRACE]=n
			;;
		--enable-asan)
			CONFIG[ASAN]=y
			;;
@@ -759,15 +752,6 @@ if [[ "${CONFIG[ISCSI_INITIATOR]}" = "y" ]]; then
	fi
fi

if [[ "${CONFIG[LOG_BACKTRACE]}" = "y" ]]; then
	if ! echo -e '#include <libunwind.h>\nint main(void) { return 0; }\n' \
		| ${BUILD_CMD[@]} -lunwind - 2>/dev/null; then
		echo --enable-log-bt requires libunwind.
		echo Please install then re-run this script.
		exit 1
	fi
fi

if [[ "${CONFIG[ASAN]}" = "y" ]]; then
	if ! echo -e 'int main(void) { return 0; }\n' \
		| ${BUILD_CMD[@]} -fsanitize=address - 2>/dev/null; then
+0 −2
Original line number Diff line number Diff line
@@ -47,7 +47,6 @@

#define SPDK_APP_DEFAULT_LOG_LEVEL		SPDK_LOG_NOTICE
#define SPDK_APP_DEFAULT_LOG_PRINT_LEVEL	SPDK_LOG_INFO
#define SPDK_APP_DEFAULT_BACKTRACE_LOG_LEVEL	SPDK_LOG_ERROR
#define SPDK_APP_DEFAULT_NUM_TRACE_ENTRIES	SPDK_DEFAULT_NUM_TRACE_ENTRIES

#define SPDK_APP_DPDK_DEFAULT_MEM_SIZE		-1
@@ -636,7 +635,6 @@ spdk_app_start(struct spdk_app_opts *opts, spdk_msg_fn start_fn,
	g_spdk_app.rc = 0;

	spdk_log_set_level(SPDK_APP_DEFAULT_LOG_LEVEL);
	spdk_log_set_backtrace_level(SPDK_APP_DEFAULT_BACKTRACE_LOG_LEVEL);

	if (app_setup_env(opts) < 0) {
		return 1;
+3 −5
Original line number Diff line number Diff line
@@ -34,14 +34,12 @@
SPDK_ROOT_DIR := $(abspath $(CURDIR)/../..)
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk

SO_VER := 2
SO_MINOR := 1
SO_VER := 3
SO_MINOR := 0
SO_SUFFIX := $(SO_VER).$(SO_MINOR)

C_SRCS = log.c log_flags.c
LIBNAME = log
ifeq ($(CONFIG_LOG_BACKTRACE),y)
LOCAL_SYS_LIBS += -lunwind
endif

SPDK_MAP_FILE = $(abspath $(CURDIR)/spdk_log.map)

+0 −44
Original line number Diff line number Diff line
@@ -35,11 +35,6 @@

#include "spdk_internal/log.h"

#ifdef SPDK_LOG_BACKTRACE_LVL
#define UNW_LOCAL_ONLY
#include <libunwind.h>
#endif

static const char *const spdk_level_names[] = {
	[SPDK_LOG_ERROR]	= "ERROR",
	[SPDK_LOG_WARN]		= "WARNING",
@@ -70,44 +65,6 @@ spdk_log_close(void)
	}
}

#ifdef SPDK_LOG_BACKTRACE_LVL
static void
log_unwind_stack(FILE *fp, enum spdk_log_level level)
{
	unw_error_t err;
	unw_cursor_t cursor;
	unw_context_t uc;
	unw_word_t ip;
	unw_word_t offp;
	char f_name[64];
	int frame;

	if (level > g_spdk_log_backtrace_level) {
		return;
	}

	unw_getcontext(&uc);
	unw_init_local(&cursor, &uc);
	fprintf(fp, "*%s*: === BACKTRACE START ===\n", spdk_level_names[level]);

	unw_step(&cursor);
	for (frame = 1; unw_step(&cursor) > 0; frame++) {
		unw_get_reg(&cursor, UNW_REG_IP, &ip);
		err = unw_get_proc_name(&cursor, f_name, sizeof(f_name), &offp);
		if (err || strcmp(f_name, "main") == 0) {
			break;
		}

		fprintf(fp, "*%s*: %3d: %*s%s() at %#lx\n", spdk_level_names[level], frame, frame - 1, "", f_name,
			(unsigned long)ip);
	}
	fprintf(fp, "*%s*: === BACKTRACE END ===\n", spdk_level_names[level]);
}

#else
#define log_unwind_stack(fp, lvl)
#endif

static void
get_timestamp_prefix(char *buf, int buf_size)
{
@@ -176,7 +133,6 @@ spdk_vlog(enum spdk_log_level level, const char *file, const int line, const cha
		get_timestamp_prefix(timestamp, sizeof(timestamp));
		if (file) {
			fprintf(stderr, "%s%s:%4d:%s: *%s*: %s", timestamp, file, line, func, spdk_level_names[level], buf);
			log_unwind_stack(stderr, level);
		} else {
			fprintf(stderr, "%s%s", timestamp, buf);
		}
Loading