Skip to contentSkip to conversation

test_kprobes: Fix implicit declaration error of test_kprobes

PATCH Applied Li Hua 2 participants 2 messages Nov 21, 2022 – Nov 22, 2022 Library code

lore
Share & tools
lore

Li Hua

author
#0 lore raw

PATCH 1/1 test_kprobes: Fix implicit declaration error of test_kprobes

If KPROBES_SANITY_TEST and ARCH_CORRECT_STACKTRACE_ON_KRETPROBE is enabled, but STACKTRACE is not set. Build failed as below:

lib/test_kprobes.c: In function ‘stacktrace_return_handler’:
lib/test_kprobes.c:228:8: error: implicit declaration of function ‘stack_trace_save’; did you mean ‘stacktrace_driver’? [-Werror=implicit-function-declaration]

  ret = stack_trace_save(stack_buf, STACK_BUF_SIZE, 0);
        ^~~~~~~~~~~~~~~~
        stacktrace_driver

cc1: all warnings being treated as errors scripts/Makefile.build:250: recipe for target 'lib/test_kprobes.o' failed make[2]: *** [lib/test_kprobes.o] Error 1

To fix this error, Select STACKTRACE if ARCH_CORRECT_STACKTRACE_ON_KRETPROBE is enabled.

Fixes 1f6d3a8f5e39 ("kprobes: Add a test case for stacktrace from kretprobe handler")
---
 lib/Kconfig.debug | 1 +
 1 file changed, 1 insertion(+)
lib/Kconfig.debug +1 -0
index c3c0b077ade3..a1005415f0f4 100644
@@ -2107,6 +2107,7 @@ config KPROBES_SANITY_TEST
 	depends on DEBUG_KERNEL
 	depends on KPROBES
 	depends on KUNIT
+	select STACKTRACE if ARCH_CORRECT_STACKTRACE_ON_KRETPROBE
 	default KUNIT_ALL_TESTS
 	help
 	  This option provides for testing basic kprobes functionality on
Signature · 1 line
2.17.1
Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · On Mon, 21 Nov 2022 11:06:20 +0800 Li Hua <[email protected]> wrote:

If KPROBES_SANITY_TEST and ARCH_CORRECT_STACKTRACE_ON_KRETPROBE is enabled, but STACKTRACE is not set. Build failed as below:

lib/test_kprobes.c: In function ‘stacktrace_return_handler’:
lib/test_kprobes.c:228:8: error: implicit declaration of function ‘stack_trace_save’; did you mean ‘stacktrace_driver’? [-Werror=implicit-function-declaration]

Quoted 8 lines
  ret = stack_trace_save(stack_buf, STACK_BUF_SIZE, 0);
        ^~~~~~~~~~~~~~~~
        stacktrace_driver

cc1: all warnings being treated as errors scripts/Makefile.build:250: recipe for target 'lib/test_kprobes.o' failed make[2]: *** [lib/test_kprobes.o] Error 1

To fix this error, Select STACKTRACE if ARCH_CORRECT_STACKTRACE_ON_KRETPROBE is enabled.

Good catch!

Thanks!

Quoted 22 lines
Fixes 1f6d3a8f5e39 ("kprobes: Add a test case for stacktrace from kretprobe handler")
---
 lib/Kconfig.debug | 1 +
 1 file changed, 1 insertion(+)
lib/Kconfig.debug +1 -0
index c3c0b077ade3..a1005415f0f4 100644
@@ -2107,6 +2107,7 @@ config KPROBES_SANITY_TEST
 	depends on DEBUG_KERNEL
 	depends on KPROBES
 	depends on KUNIT
+	select STACKTRACE if ARCH_CORRECT_STACKTRACE_ON_KRETPROBE
 	default KUNIT_ALL_TESTS
 	help
 	  This option provides for testing basic kprobes functionality on
Signature · 1 line
2.17.1
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>