Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

objtool: Include backtrace in verbose mode

Include backtrace in verbose mode. This makes it easy to gather all the
information needed for diagnosing objtool warnings.

Reviewed-by: Miroslav Benes <mbenes@suse.cz>
Link: https://lore.kernel.org/r/c255224fabcf7e64bac232fec1c77c9fc2d7d7ab.1681853186.git.jpoimboe@kernel.org
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>

+20 -24
+2 -2
tools/objtool/Documentation/objtool.txt
··· 246 246 247 247 NOTE: When requesting help with an objtool warning, please recreate with 248 248 OBJTOOL_VERBOSE=1 (e.g., "make OBJTOOL_VERBOSE=1") and send the full 249 - output, including any disassembly below the warning, to the objtool 250 - maintainers. 249 + output, including any disassembly or backtrace below the warning, to the 250 + objtool maintainers. 251 251 252 252 For asm files, if you're getting an error which doesn't make sense, 253 253 first make sure that the affected code follows the above rules.
+10 -16
tools/objtool/check.c
··· 3657 3657 3658 3658 ret = validate_branch(file, func, alt->insn, state); 3659 3659 if (ret) { 3660 - if (opts.backtrace) 3661 - BT_FUNC("(alt)", insn); 3660 + BT_INSN(insn, "(alt)"); 3662 3661 return ret; 3663 3662 } 3664 3663 } ··· 3702 3703 ret = validate_branch(file, func, 3703 3704 insn->jump_dest, state); 3704 3705 if (ret) { 3705 - if (opts.backtrace) 3706 - BT_FUNC("(branch)", insn); 3706 + BT_INSN(insn, "(branch)"); 3707 3707 return ret; 3708 3708 } 3709 3709 } ··· 3800 3802 { 3801 3803 if (insn->hint && !insn->visited && !insn->ignore) { 3802 3804 int ret = validate_branch(file, insn_func(insn), insn, *state); 3803 - if (ret && opts.backtrace) 3804 - BT_FUNC("<=== (hint)", insn); 3805 + if (ret) 3806 + BT_INSN(insn, "<=== (hint)"); 3805 3807 return ret; 3806 3808 } 3807 3809 ··· 3859 3861 3860 3862 ret = validate_unret(file, alt->insn); 3861 3863 if (ret) { 3862 - if (opts.backtrace) 3863 - BT_FUNC("(alt)", insn); 3864 + BT_INSN(insn, "(alt)"); 3864 3865 return ret; 3865 3866 } 3866 3867 } ··· 3885 3888 } 3886 3889 ret = validate_unret(file, insn->jump_dest); 3887 3890 if (ret) { 3888 - if (opts.backtrace) { 3889 - BT_FUNC("(branch%s)", insn, 3890 - insn->type == INSN_JUMP_CONDITIONAL ? "-cond" : ""); 3891 - } 3891 + BT_INSN(insn, "(branch%s)", 3892 + insn->type == INSN_JUMP_CONDITIONAL ? "-cond" : ""); 3892 3893 return ret; 3893 3894 } 3894 3895 ··· 3908 3913 3909 3914 ret = validate_unret(file, dest); 3910 3915 if (ret) { 3911 - if (opts.backtrace) 3912 - BT_FUNC("(call)", insn); 3916 + BT_INSN(insn, "(call)"); 3913 3917 return ret; 3914 3918 } 3915 3919 /* ··· 4210 4216 state->uaccess = sym->uaccess_safe; 4211 4217 4212 4218 ret = validate_branch(file, insn_func(insn), insn, *state); 4213 - if (ret && opts.backtrace) 4214 - BT_FUNC("<=== (sym)", insn); 4219 + if (ret) 4220 + BT_INSN(insn, "<=== (sym)"); 4215 4221 return ret; 4216 4222 } 4217 4223
+8 -6
tools/objtool/include/objtool/warn.h
··· 63 63 _insn->sym->warned = 1; \ 64 64 }) 65 65 66 - #define BT_FUNC(format, insn, ...) \ 67 - ({ \ 68 - struct instruction *_insn = (insn); \ 69 - char *_str = offstr(_insn->sec, _insn->offset); \ 70 - WARN(" %s: " format, _str, ##__VA_ARGS__); \ 71 - free(_str); \ 66 + #define BT_INSN(insn, format, ...) \ 67 + ({ \ 68 + if (opts.verbose || opts.backtrace) { \ 69 + struct instruction *_insn = (insn); \ 70 + char *_str = offstr(_insn->sec, _insn->offset); \ 71 + WARN(" %s: " format, _str, ##__VA_ARGS__); \ 72 + free(_str); \ 73 + } \ 72 74 }) 73 75 74 76 #define WARN_ELF(format, ...) \