[英]Single stepping until exit from function gdb
I have a project which I am working on and it has multiple files and I use make to compile the project.我有一个正在处理的项目,它有多个文件,我使用 make 来编译该项目。 Here is the makefile
这是生成文件
CC = /opt/gcc-4.7-cilkplus/bin/gcc
CFLAGS = -ggdb3 -Wall
COMPLILEFLAGS = `mysql_config --include` -I/opt/gcc-4.7-cilkplus/include/
LINKERINFO = `mysql_config --cflags --libs` -lrt -lm -lz
CILKFLAGS = -lcilkrts
# To be provided at the commandline
DIR = './bloom'
MODE = '2'
FILENAME = 'database.info'
exec: main.o mysql-client.o databaseConnection-common.o murmurhash3.o bloom-filter.o md5.o auxilary-functions.o
$(CC) $(CFLAGS) -o exec main.o mysql-client.o databaseConnection-common.o murmurhash3.o bloom-filter.o \
md5.o auxilary-functions.c $(LINKERINFO) $(CILKFLAGS)
main.o: main.c mysql-client.h databaseConnection-common.h bloom-filter.h
$(CC) $(CFLAGS) $(COMPLILEFLAGS) -c main.c $(CILKFLAGS)
bloom-filter.o: bloom-filter.c bloom-filter.h murmurhash3.h auxilary-functions.h
$(CC) $(CFLAGS) $(COMPLILEFLAGS) -c bloom-filter.c
murmurhash3.o: murmurhash3.c murmurhash3.h
$(CC) $(CFLAGS) -c murmurhash3.c
md5.o: md5.c md5.h
$(CC) $(CFLAGS) -c md5.c
mysql-client.o: mysql-client.c mysql-client.h databaseConnection-common.h
$(CC) $(CFLAGS) $(COMPLILEFLAGS) -c mysql-client.c
databaseConnection-common.o: databaseConnection-common.c databaseConnection-common.h
$(CC) $(CFLAGS) $(COMPLILEFLAGS) -c databaseConnection-common.c
auxilary-functions.o: auxilary-functions.h auxilary-functions.c
$(CC) $(CFLAGS) -c auxilary-functions.c
run:
./exec $(MODE) $(FILENAME) $(DIR)
I set breakpoint
at some location and then do next
form there but I get我在某个位置设置
breakpoint
,然后在那里执行next
表单,但我得到
Single stepping until exit from function bf_dup_eleminate_read, which has no line number information.
bf_dup_eleminate_read
is a function in bloom-filter.c
. bf_dup_eleminate_read
是bloom-filter.c
一个函数。 I cannot understand why this is happening even if bloom-filter.c
is compiled with proper options即使用适当的选项编译了
bloom-filter.c
我也不明白为什么会发生这种情况
I don not see anywhere the -g
flag. 我在任何地方都看不到
-g
标志。 It informs compiler to emit debugging info, so you need to add it to compilation line, if you wish gdb to show you line numbers. 它通知编译器发出调试信息,因此,如果希望gdb显示行号,则需要将其添加到编译行。
Try to update your gdb. 尝试更新您的gdb。 It might be that your
gcc
version was too new. 可能是您的
gcc
版本太新了。 I got the same problem and fixed it after updated my gdb. 更新gdb后,我遇到了相同的问题并修复了它。
Well its 2021 so things are a bit different now.好吧,现在是 2021 年,所以现在情况有些不同。 Typicly I find the
-ggdb
flag more useful.通常我发现
-ggdb
标志更有用。 It isn't only more verbose, it also seems to be less error prone (but thats my opinion).它不仅更冗长,而且似乎更不容易出错(但这是我的观点)。 You also need to make sure that you add the
-ggdb
flag to all the object files as well.您还需要确保将
-ggdb
标志添加到所有目标文件中。 To give some sort of reference, and a more solid way to get your project going if its not debugging as expected.提供某种参考,以及在项目未按预期调试的情况下以更可靠的方式启动项目。 Here is a snippet from a project I just built and debugged sucessfully in
VSCode v1.62.1
.这是我刚刚在
VSCode v1.62.1
成功构建和调试的项目的片段。 It was compiled w/ GNU C++ Compiler g++ 10.3
, debugged with GNU Debugger gdb v9.2
, and built using the make command via GNU Make 4.2.1
它使用
GNU C++ Compiler g++ 10.3
,使用GNU Debugger gdb v9.2
,并通过GNU Make 4.2.1
使用 make 命令构建
# Here is an example from my current project that I debug on vscode
TARGET = A10
ALL = fraction.o main.o
GCC = g++
FLAGS = -Wall -c
${TARGET}: fraction.o main.o
${GCC} -Wall -ggdb ${ALL} -o ${TARGET}
main.o: main.cpp fraction.h
${GCC} -Wall -ggdb -c main.cpp
fraction.o: fraction.cpp fraction.h
${GCC} -Wall -ggdb -c fraction.cpp fraction.h
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.