xcode LLDB 相当于 GDB 的“info malloc-history <address>”命令?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9738994/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 23:40:36  来源:igfitidea点击:

LLDB equivalent to GDB's "info malloc-history <address>" command?

iosxcodelldb

提问by user1274177

I am trying to resolve a "message sent to deallocated instance " error in iOS.

我正在尝试解决 iOS 中的“消息发送到已解除分配的实例”错误。

回答by karstux

See the LLDB-GDB command map (http://lldb.llvm.org/lldb-gdb.html) - you have to import a script, and the command is named malloc_info now. Obviously, malloc stack logging still needs to be turned on in the scheme options.

请参阅 LLDB-GDB 命令映射 ( http://lldb.llvm.org/lldb-gdb.html) - 您必须导入一个脚本,该命令现在名为 malloc_info。很明显,仍然需要在scheme选项中开启malloc stack logging。

(lldb) script import lldb.macosx.heap
(lldb) malloc_info --stack-history 0x10010d680

Unfortunately, it doesn't show dealloc's - didn't GDBs malloc-history show that as well?

不幸的是,它没有显示 dealloc 的 - GDB 的 malloc-history 也没有显示吗?

回答by avishic

Use instruments, you'll get the exact line -

使用仪器,你会得到准确的线条——

(In XCode) Run it through "Product" -> "Profile".

(在 XCode 中)通过“产品”->“配置文件”运行它。

This will start Instruments, there you should choose "Zombies"and reproduce the bug event.

这将启动 Instruments,在那里您应该选择“Zombies”并重现错误事件。

You'l get a pop-up once a zombie is called, press the chevron to see the exact line.

一旦僵尸被调用,你会得到一个弹出窗口,按 V 形图标查看确切的行

Problem is usually a bad __bridge(optional bridges __brige_retained/ __bridge_transfer/ __bridge)

问题通常是一个坏的__bridge(可选的桥梁__brige_retained/ __bridge_transfer/ __bridge

回答by Kevin Draz

You used to be able to use the malloc_history command-line tool from a shell and give it the process ID and address of interest. It appears this command is no longer installed by the latest Xcode's command line tools. :-(

您过去可以从 shell 使用 malloc_history 命令行工具,并为其提供感兴趣的进程 ID 和地址。最新的 Xcode 命令行工具似乎不再安装此命令。:-(