GDB Source Code Lookup path

Source: Internet
Author: User

At the time of the GDB program, sometimes you will find that the source code files can not be found, for those with debugging information System library or third-party library, many times when you really want GDB to chase his source code, you will find that GDB can not find these source code path. There are two options at this time:

"1" If GdB tells you at this time that you cannot find the source file path with the debug repository, the path address given is an absolute path, such as

/home/rickyk/qt-4.8. 6/src/corelib/tools/qstring. CPP: no file or directory

This hint, you should use GDB to provide the

Set Substitute-path

This is actually very well understood, is the substitution rule, if you want to see the current substitution rules, you can

Show Substitute-path

For example, we need to qstring.cpp this file at this time, but for some reason we can't find it in/home/rickyk/qt-4.8.6/src/corelib/tools/qstring.cpp, but we can do it in/home/ Found in the Rickyk/qt-everywhere-opensource-src-4.8.6/src/corelib/tools/qstring.cpp, we

Set substitute-path/home/rickyk/qt-4.8. 6 /home/rickyk/qt-everywhere-opensource-src-4.8. 6

What does that mean? In fact, it is to let GDB see/home/rickyk/qt-4.8.6 when he will do automatic replacement to/home/rickyk/qt-everywhere-opensource-src.4.8.6, that is to say gdb can correctly know this file. At this point we'll show substitute-path and we can see that the conversion rules have been added.

(GDB) Show substitute-path List of all source path substitution rules:  '/home/rickyk/qt-4.8.  6' , ' /home/rickyk/qt-everywhere-opensource-src-4.8.6'.

"2" if gdb pop-up error message at this time is not the concept of absolute path, but the concept of relative path

./A.CPP does not have that file or directory

So at this point you can use GDB's second source code path----directory (dir) dirname to specify, that is, if our a.cpp is not in the current directory, but in the current directory under the Bak folder, we just

dir Bak

At this point, our gdb will replace the whole dir you added to the front of the relative path , and do the stitching yourself, that is, now the./a.cpp became./bak/a.cpp.

Notice the difference between the two, for the absolute path, you need to give the substitution rules for him to do string substitution, for the relative path, you need to give him a directory to do stitching, also a bit prefix meaning, here prefix by you, but the relative path of the overall structure is given by GDB, and then complete the stitching operation.

GDB Source Code Lookup path

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.