【发布时间】:2014-05-14 15:42:13
【问题描述】:
我正在尝试逐步完成 llvm 的 opt 程序(用于作业),讲师建议在 runOnFunction 处设置断点。我在其中一个文件中看到了这一点:
bool InstCombiner::runOnFunction(Function &F) { /* (Code removed for SO) */ }
但 gdb 似乎没有找到 runOnFunction 断点。我突然想到问题可能出在名称空间上?我试过了,但 gdb 永远不会中断,它只是创建 fooOpt.s 文件:
(gdb) b runOnFunction
Function "runOnFunction" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (runOnFunction) pending.
(gdb) r -S -instcombine -debug -o ~/Desktop/fooOpt.s ~/Desktop/foo.s
我在 Mac 上,所以我没有 objdump,但 otool 产生了 560 万行,因为 runOnFunction 不止一次出现在那里,因此作为起点涉水似乎并不合理。
【问题讨论】:
-
InstCombiner不是命名空间,它是类。它是来自llvm命名空间的类llvm::InstCombiner。因此,正确的命令可能听起来像break 'llvm::InstCombiner::runOnFunction(llvm::Function &F)'甚至只是break sourceFile.cpp:line,其中 line 是 runOnFunction 中的第一条语句
标签: namespaces gdb llvm