1

私は 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.

それにブレークポイントを設定しようとすると。明らかに、不明なので壊れていません。

何か助けはありますか?前もって感謝します。

4

1 に答える 1

2

ブレークポイントを設定できない理由malloc_error_breakは、この関数がまだロードされていない共有ライブラリで定義されているためです。

プログラムを一度実行すると、ブレークポイントを設定できるはずです。

startまたは、の代わりに を使用するrunと、 でプログラムが停止したときに、でブレークポイント設定できるmainはずです。malloc_error_break

于 2012-09-07T03:06:04.863 に答える