Netbeans C/C++ on Linux "step in to" Linux C 运行时代码?
Netbeans C/C++ on Linux "step in to" Linux C runtime code?
在Linux上使用netbeans调试C/C++代码时,是否可以像Visual Studio在Windows上一样"介入"本机C运行时库(以查看malloc()等的源代码?
如果没有,任何Linux IDE都可以吗?
malloc
和许多函数都有编译器的特定实现。通常您无法以这种方式访问它们的源代码。例如,在 gcc/g++ 中,malloc
以 <cstdlib>
形式声明,并在.dll
文件中作为外部函数实现。
在Visual Studio中,你可以浏览一些声明,看到一些奇怪的代码,但它们只是一些高级代码来调用真正的malloc
。你看不到malloc
的真正实现。
例如,在我步入malloc
后的测试中,我看到了下面的代码,它只是对内部函数的调用,等等......最后你什么也看不到:
extern "C" _CRTIMP void * __cdecl malloc (
size_t nSize
)
{
void *res = _nh_malloc_dbg(nSize, _newmode, _NORMAL_BLOCK, NULL, 0);
RTCCALLBACK(_RTC_Allocate_hook, (res, nSize, 0));
return res;
}
您可以在 Debian 或 Ubuntu(或派生)发行版上安装 libc6-dbg
(或 libc-dbg
)软件包。
然后使用 set debug-file-directory 命令 gdb
由于Linux是自由软件,你可以研究malloc
的源代码;你的发行版可能使用了GNU libc的一些修补变体;你也可以研究MUSL libc,它的源代码对我来说似乎更具可读性。
FWIW, malloc(3) 肯定在使用像 mmap(2) 这样的系统调用......
在许多发行版上,您可以从源代码重建打包的软件(例如,使用 apt-build
...
但是,如果您是新手,我不建议您重建libc
因为它是几乎所有应用程序的核心部分!
相关文章:
- 函数在Windows或Linux上运行时表现不同
- 在 Linux 上C++:在作为 systemd 服务运行时侦听键盘输入
- 在 Linux 上没有 /proc/self/exe 的 C/C++ 运行时可执行文件的大小?
- C++ Linux 运行时basic_string::_M_construct null 无效错误
- 在VS2015中访问类成员时运行时错误,但在Linux上未访问时出错
- C++ 可执行文件在运行时找不到库,即使它在 /usr/lib 中(在 Linux 上)
- 如何在 Linux 运行时检查堆栈使用情况?
- Linux 与 Windows,C++读取 CSV 文件的运行时性能差异
- 如何在 Linux 上将所有第三方运行时依赖项包含在 cmake/cpack 生成的包中
- 唯一的字符代码在 Linux 中运行时不起作用,但在 Windows (C++) 中很好
- 通过Linux命令行执行时,可执行文件运行正常 - 调用C System()命令时运行时错误
- Netbeans C/C++ on Linux "step in to" Linux C 运行时代码?
- Linux gnu++11,在运行时获取"Enable multithreading to use std::thread: Operation not permitted"
- 在Windows和Linux中运行时获得不同的输出,以便在C++中进行冒泡排序
- 在Linux中编译的程序;t检测'n'在Windows运行时所在的fstream中换行
- 当多个高优先级线程在多个内核上运行时,Linux内核没有响应
- gcc(Linux/MinGW)是否存在编译器标志,以便在运行时引发除以零的错误
- 在Linux运行时重写libstdc++搜索路径
- 用于在运行时记录调用堆栈的库(Windows/Linux)
- 文件/运行时权限的Unix/Linux API