找到当前在gdb中调试的可执行文件的源代码路径 [英] Find the path of the source code for the executable being currently debugged in gdb

查看:1429
本文介绍了找到当前在gdb中调试的可执行文件的源代码路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在main中设置一个断点并用正确的源代码调试代码,但我不知道gdb是从哪里获取源代码的。



源代码在CWD中不存在。



如何从gdb的代码中找到代码?

 信息源




源文件是ac
编译目录是/ home / user / test
位于/ home / user / test / ac
包含17行。
源语言是c。
使用DWARF 2调试格式进行编译。
包含预处理器宏信息。


I can set a breakpoint in main and debug the code with the correct source code, but I don't know where gdb is taking the source code from.

The source code is not present in CWD.

How to find from which location gdb is taking the code?

解决方案

You can use gdb command:

info source

Sample output:

Current source file is a.c
Compilation directory is /home/user/test
Located in /home/user/test/a.c
Contains 17 lines.
Source language is c.
Compiled with DWARF 2 debugging format.
Includes preprocessor macro info.

这篇关于找到当前在gdb中调试的可执行文件的源代码路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆