【问题标题】:GDB / "malloc_error_break" not definedGDB /“malloc_error_break”未定义
【发布时间】:2012-09-07 02:16:42
【问题描述】:

我正在尝试了解有关 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.

当我尝试在其上设置断点时。显然,它不会因为未知而崩溃。

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

【问题讨论】:

    标签: c macos memory gdb malloc


    【解决方案1】:

    您无法在malloc_error_break 上设置断点的原因是该函数是在一个共享库中定义的,该库尚未被加载。

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-05-07
      • 2017-10-22
      • 1970-01-01
      • 1970-01-01
      • 2017-01-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多