0

I'm trying to use dump_stack() so I tried a few hours to make dump_stack.ko but I could not make properly.

kesl@kesl-1080Ti:~/Downloads/trace$ make
Makefile:6: *** commands commence before first target.  Stop.

watching this error all day... How can I fix it?

Ubuntu 20.04, Kernel 5.18.0-rc6, make 3.81

I have changed my make version 4.2.1 to 3.81 but the same problem happened. I also tried hello.c and same style Makefile but had same problem.

Here is my dump_stack.c and Makefile

  1 #include <linux/module.h>                                                                                                                                                            
  2 #include <linux/kernel.h>
  3 
  4 static int myinit(void)
  5 {
  6         pr_info("dump_stack myinit\n");
  7         dump_stack();
  8         pr_info("dump_stack after\n");
  9         return 0;
 10 }
 11 
 12 static void myexit(void)
 13 {
 14         pr_info("panic myexit\n");
 15 }
 16 
 17 module_init(myinit)
 18 module_exit(myexit)
 19 MODULE_LICENSE("GPL");

dump_stack.c

  1         obj-m+= dump_stack.o
  2 
  3         KERNEL_DIR = /lib/modules/$(shell uname -r)/build                                                                                                                            
  4         PWD = $(shell pwd)
  5 
  6         all:
  7         $(MAKE) -C $(KERNEL_DIR) SUBDIRS=$(PWD) modules
  8 
  9         clean:
 10         $(MAKE) -C $(KERNEL_DIR) SUBDIRS=$(PWD) clean

Makefile

  • 2
    rule lines (like `all:` in your makefile) CANNOT begin with a tab character -- tabs should only appear at the start of command lines. The tabs are how make tells the difference between rules and commands. – Chris Dodd Sep 01 '23 at 12:39
  • It worked. I'm really appriciated. – DongSeok Son Sep 01 '23 at 13:55
  • You can find an explanation of all the errors generated by GNU Make in the manual, here: https://www.gnu.org/software/make/manual/html_node/Error-Messages.html – MadScientist Sep 01 '23 at 17:14
  • 1
    BTW, when you post code, don't add line numbers, so that people can just copy & paste your code to try it, and don't have to manually remove your line numbers. – Robert Sep 01 '23 at 20:41

0 Answers0