gpt4 book ai didi

c - GDB/"malloc_error_break"未定义

转载 作者:太空宇宙 更新时间:2023-11-04 03:00:51 25 4
gpt4 key购买 nike

我正在尝试了解更多有关 malloc 和 free 的信息,因此我创建了一个实现这些功能的 dylib,并且正在加载到一个通用系统二进制文件中。但是,它有错误,我正在尝试调试它们。

  • malloc.dylib 是我的动态库

这是 gdb 输出:

(gdb) set env DYLD_INSERT_LIBRARIES malloc.dylib
(gdb) break malloc_error_break
Function "malloc_error_break" not defined.
Make breakpoint pending on future shared library load? (y or [n]) n
(gdb) r
Starting program: /bin/ls
[+] init()
[-] myMalloc requesting: 4096 bytes
[-] memory address: 200000
bash(2035) malloc: *** error for object 0x200000: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug

Program terminated with signal SIGABRT, Aborted.
The program no longer exists.
(gdb)

我对消息感到困惑

Function "malloc_error_break" not defined.

当我尝试在其上设置断点时。显然,它并没有崩溃,因为它是未知的。

有什么帮助吗?提前致谢。

最佳答案

你不能在 malloc_error_break 上设置断点的原因是这个函数是在一个还没有加载的共享库中定义的。

你应该可以在运行程序一次后设置断点。

或者,使用 start 而不是 run,当程序在 main 上停止时,您应该然后能够在 malloc_error_break 上设置断点。

关于c - GDB/"malloc_error_break"未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12310860/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com