Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
357 views
in Technique[技术] by (71.8m points)

c++ - Tell gdb to skip standard files

I'm debugging C++ code with GDB and when it enters a constructor of some object containing standard library objects, it shows me the constructor of these objects (like std::map) and everything that's underneath.

I know about the next operator, but I'd prefer to basically black list any standard library code, which is never the source of the error I'm investigating. The wished behavior is that a simple skip would send me to the next "user-land" code.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

gdb 7.12 supports file globbing to specify the files to skip in the debugger. The documentation for the same is as below:

https://sourceware.org/gdb/onlinedocs/gdb/Skipping-Over-Functions-and-Files.html

To skip stepping into all library headers in the directory /usr/include/c++/5/bits, add the below lines to ~/.gdbinit

# To skip all .h files in /usr/include/c++/5/bits
skip -gfi /usr/include/c++/5/bits/*.h

Instead to skip a specific file, say stl_vector.h, add the below lines to ~/.gdbinit

# To skip the file /usr/include/c++/5/bits/stl_vector.h
skip file /usr/include/c++/5/bits/stl_vector.h

Doing the above with gdb 7.11 and below version leads to the below error:

Ignore function pending future shared library load? (y or [n]) [answered N; input not from terminal]

However, gdb 7.12 seems to have solved the above issue.

This blog addresses the same problem for gdb version 7.11 or below.

Note - You can use the below command from the gdb command prompt to list all the files marked for skipping

info skip

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...