可以使用 stop at 命令在行号处设置断点,其中 n 是源代码行号,filename 是可选的程序文件名限定符。
(dbx) stop at filename:n
例如:
(dbx) stop at main.cc:3
如果指定的行不是可执行的源代码行,dbx 会在下一个可执行源代码行处设置断点。如果没有可执行源代码行,dbx 会发出错误。
可以使用 file 命令设置当前文件并使用 list 命令列出要在其中停止的函数来确定要停止在那里的行。然后使用 stop at 命令在源代码行设置断点,如以下示例所示。
(dbx) file t.c
(dbx) list main
10 main(int argc, char *argv[])
11 {
12 char *msg = "hello world\n";
13 printit(msg);
14 }
(dbx) stop at 13
有关指定 at 位置事件的更多信息,请参见at 事件规范。