简单问题..如何用Gprof编译驱动程序?
我当前的Makefile:
obj-m += hello-2.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
工作正常(我可以加载驱动程序等),但如果我尝试将-pg选项添加到文件中,那么我会收到错误。
生成文件:
obj-m += hello-2.o
EXTRA_CFLAGS += -pg
LDFLAGS += -pg
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
我收到错误:
make -C /lib/modules/2.6.31/build M=/home/I/drivertest modules
make[1]: Entering directory `/home/I/linux-2.6.31'
CC [M] /home/I/drivertest/hello-2.o
Building modules, stage 2.
MODPOST 1 modules
WARNING: "mcount" [/home/I/drivertest/hello-2.ko] undefined!
CC /home/I/drivertest/hello-2.mod.o
LD [M] /home/I/drivertest/hello-2.ko
ld: unrecognized option '-pg'
ld: use the --help option for usage information
make[2]: *** [/home/I/drivertest/hello-2.ko] Error 1
make[1]: *** [modules] Error 2
make[1]: Leaving directory `/home/I/linux-2.6.31'
make: *** [all] Error 2
答案 0 :(得分:0)
您无法使用gprof配置内核模块。您需要编译一个启用了性能分析支持的内核,并使用readprofile
工具。有关详细信息,请参阅the Linux kernel documentation。
答案 1 :(得分:0)
即使您可以在内核模块上使用gprof,它也从未被宣传为能够帮助您找到瓶颈。 More on that.
答案 2 :(得分:-1)
-pg
是一个编译标志,而不是一个链接标志。将其从LDFLAGS
中删除(显然将其保留在EXTRA_CFLAGS
)。