All of lore.kernel.org
 help / color / mirror / Atom feed
From: Josh Poimboeuf <jpoimboe@kernel.org>
To: x86@kernel.org
Cc: linux-kernel@vger.kernel.org, Peter Zijlstra <peterz@infradead.org>
Subject: [PATCH 2/5] objtool: Combine '--backtrace' with '--verbose'
Date: Mon, 27 Mar 2023 09:00:45 -0700	[thread overview]
Message-ID: <ef477e7cf3f188c623279764e831772eab2a4016.1679932620.git.jpoimboe@kernel.org> (raw)
In-Reply-To: <cover.1679932620.git.jpoimboe@kernel.org>

Get rid of the '--backtrace' option, instead including that
functionality in '--verbose'.  This makes it easy to gather all the
information needed for diagnosing objtool warnings.

Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
---
 tools/objtool/Documentation/objtool.txt |  4 ++--
 tools/objtool/builtin-check.c           |  1 -
 tools/objtool/check.c                   | 22 ++++++++--------------
 tools/objtool/include/objtool/builtin.h |  1 -
 tools/objtool/include/objtool/warn.h    | 14 ++++++++------
 5 files changed, 18 insertions(+), 24 deletions(-)

diff --git a/tools/objtool/Documentation/objtool.txt b/tools/objtool/Documentation/objtool.txt
index 7c1a46af322f..ec6f82fb414c 100644
--- a/tools/objtool/Documentation/objtool.txt
+++ b/tools/objtool/Documentation/objtool.txt
@@ -246,8 +246,8 @@ Objtool warnings
 
 NOTE: When requesting help with an objtool warning, please re-run the
 kernel build with `OBJTOOL_ARGS="--verbose" make <whatever>` and send
-the full warning output (including any function disassembly below the
-warning) to the objtool maintainers.
+the full warning output (including any function disassembly or objtool
+backtrace below the warning) to the objtool maintainers.
 
 For asm files, if you're getting an error which doesn't make sense,
 first make sure that the affected code follows the above rules.
diff --git a/tools/objtool/builtin-check.c b/tools/objtool/builtin-check.c
index b8de42f6778e..937ba5d78e08 100644
--- a/tools/objtool/builtin-check.c
+++ b/tools/objtool/builtin-check.c
@@ -84,7 +84,6 @@ static const struct option check_options[] = {
 	OPT_CALLBACK_OPTARG(0, "dump", NULL, NULL, "orc", "dump metadata", parse_dump),
 
 	OPT_GROUP("Options:"),
-	OPT_BOOLEAN(0, "backtrace", &opts.backtrace, "unwind on error"),
 	OPT_BOOLEAN(0, "backup", &opts.backup, "create .orig files before modification"),
 	OPT_BOOLEAN(0, "dry-run", &opts.dryrun, "don't write modifications"),
 	OPT_BOOLEAN(0, "link", &opts.link, "object is a linked object"),
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index cae6ac6ff246..a652b9e5c805 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -3708,8 +3708,7 @@ static int validate_branch(struct objtool_file *file, struct symbol *func,
 
 				ret = validate_branch(file, func, alt->insn, state);
 				if (ret) {
-					if (opts.backtrace)
-						BT_FUNC("(alt)", insn);
+					BT_FUNC("(alt)", insn);
 					return ret;
 				}
 			}
@@ -3755,8 +3754,7 @@ static int validate_branch(struct objtool_file *file, struct symbol *func,
 				ret = validate_branch(file, func,
 						      insn->jump_dest, state);
 				if (ret) {
-					if (opts.backtrace)
-						BT_FUNC("(branch)", insn);
+					BT_FUNC("(branch)", insn);
 					return ret;
 				}
 			}
@@ -3855,7 +3853,7 @@ static int validate_unwind_hint(struct objtool_file *file,
 {
 	if (insn->hint && !insn->visited && !insn->ignore) {
 		int ret = validate_branch(file, insn_func(insn), insn, *state);
-		if (ret && opts.backtrace)
+		if (ret)
 			BT_FUNC("<=== (hint)", insn);
 		return ret;
 	}
@@ -3914,8 +3912,7 @@ static int validate_unret(struct objtool_file *file, struct instruction *insn)
 
 				ret = validate_unret(file, alt->insn);
 				if (ret) {
-				        if (opts.backtrace)
-						BT_FUNC("(alt)", insn);
+					BT_FUNC("(alt)", insn);
 					return ret;
 				}
 			}
@@ -3942,10 +3939,8 @@ static int validate_unret(struct objtool_file *file, struct instruction *insn)
 				}
 				ret = validate_unret(file, insn->jump_dest);
 				if (ret) {
-					if (opts.backtrace) {
-						BT_FUNC("(branch%s)", insn,
-							insn->type == INSN_JUMP_CONDITIONAL ? "-cond" : "");
-					}
+					BT_FUNC("(branch%s)", insn,
+						insn->type == INSN_JUMP_CONDITIONAL ? "-cond" : "");
 					return ret;
 				}
 
@@ -3967,8 +3962,7 @@ static int validate_unret(struct objtool_file *file, struct instruction *insn)
 
 			ret = validate_unret(file, dest);
 			if (ret) {
-				if (opts.backtrace)
-					BT_FUNC("(call)", insn);
+				BT_FUNC("(call)", insn);
 				return ret;
 			}
 			/*
@@ -4254,7 +4248,7 @@ static int validate_symbol(struct objtool_file *file, struct section *sec,
 	state->uaccess = sym->uaccess_safe;
 
 	ret = validate_branch(file, insn_func(insn), insn, *state);
-	if (ret && opts.backtrace)
+	if (ret)
 		BT_FUNC("<=== (sym)", insn);
 	return ret;
 }
diff --git a/tools/objtool/include/objtool/builtin.h b/tools/objtool/include/objtool/builtin.h
index fcca6662c8b4..38aef760465e 100644
--- a/tools/objtool/include/objtool/builtin.h
+++ b/tools/objtool/include/objtool/builtin.h
@@ -28,7 +28,6 @@ struct opts {
 	bool cfi;
 
 	/* options: */
-	bool backtrace;
 	bool backup;
 	bool dryrun;
 	bool link;
diff --git a/tools/objtool/include/objtool/warn.h b/tools/objtool/include/objtool/warn.h
index b85aa440ee1f..a9ec1ed6a2e3 100644
--- a/tools/objtool/include/objtool/warn.h
+++ b/tools/objtool/include/objtool/warn.h
@@ -91,12 +91,14 @@ static inline void objdump_func(struct section *sec, unsigned long offset)
 		objdump_func(sec, offset);		\
 })
 
-#define BT_FUNC(format, insn, ...)			\
-({							\
-	struct instruction *_insn = (insn);		\
-	char *_str = offstr(_insn->sec, _insn->offset); \
-	WARN("  %s: " format, _str, ##__VA_ARGS__);	\
-	free(_str);					\
+#define BT_FUNC(format, insn, ...)				\
+({								\
+	if (opts.verbose) {					\
+		struct instruction *_insn = (insn);		\
+		char *_str = offstr(_insn->sec, _insn->offset); \
+		WARN("  %s: " format, _str, ##__VA_ARGS__);	\
+		free(_str);					\
+	}							\
 })
 
 #define WARN_ELF(format, ...)				\
-- 
2.39.2


  parent reply	other threads:[~2023-03-27 16:01 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-27 16:00 [PATCH 0/5] objtool: warning improvements Josh Poimboeuf
2023-03-27 16:00 ` [PATCH 1/5] objtool: Add '--verbose' option for disassembling affected functions Josh Poimboeuf
2023-03-28  8:47   ` Miroslav Benes
2023-03-27 16:00 ` Josh Poimboeuf [this message]
2023-03-28  8:07   ` [PATCH 2/5] objtool: Combine '--backtrace' with '--verbose' Peter Zijlstra
2023-03-28 20:19     ` Josh Poimboeuf
2023-03-29  7:25       ` Peter Zijlstra
2023-03-27 16:00 ` [PATCH 3/5] objtool: Remove superfluous dead_end_function() check Josh Poimboeuf
2023-03-27 16:00 ` [PATCH 4/5] objtool: Add per-function rate limiting for unreachable warnings Josh Poimboeuf
2023-03-28  8:11   ` Peter Zijlstra
2023-03-28 20:22     ` Josh Poimboeuf
2023-03-29  7:26       ` Peter Zijlstra
2023-03-28  9:07   ` Miroslav Benes
2023-03-27 16:00 ` [PATCH 5/5] objtool: Add "missing __noreturn" warning Josh Poimboeuf
2023-03-28  9:10   ` Miroslav Benes
2023-03-29 16:24     ` Josh Poimboeuf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ef477e7cf3f188c623279764e831772eab2a4016.1679932620.git.jpoimboe@kernel.org \
    --to=jpoimboe@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.