gpt4 book ai didi

linux - 如何编译要使用 Gprof 进行分析的驱动程序

转载 作者:太空宇宙 更新时间:2023-11-04 04:35:24 33 4
gpt4 key购买 nike

简单的问题..如何编译要使用 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

最佳答案

您无法使用 gprof 分析内核模块。您需要编译启用分析支持的内核并使用 readprofile 工具。请参阅the Linux kernel documentation了解更多详情。

关于linux - 如何编译要使用 Gprof 进行分析的驱动程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3684867/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com