Xcode -划线,保护边和保护malloc

时间:2022-06-01 22:07:10

Can someone explain what do these options in Xcode do?

有人能解释一下Xcode中的这些选项是干什么的吗?

  • Enable Scribble
  • 使潦草
  • Enable Guard Edges
  • 使护边
  • Enable Guard Malloc
  • 使警卫Malloc

what they are and what they do and how useful can they be for debugging/testing?

它们是什么,它们做什么,它们对调试/测试有多大用处?

thanks.

谢谢。

2 个解决方案

#1


42  

From the documentation.

从文档。

  • Enable Scribble. Fill allocated memory with 0xAA and deallocated memory with 0x55.
  • 启用潦草。用0xAA填充分配的内存,用0x55释放分配的内存。
  • Enable Guard Edges. Add guard pages before and after large allocations.
  • 启用保护边缘。在大量分配之前和之后添加保护页。
  • Enable Guard Malloc. Use libgmalloc to catch common memory problems such as buffer overruns and use-after-free.
  • 启用Malloc。使用libgmalloc捕捉常见的内存问题,如缓冲区溢出和使用后无内存问题。

Scribble will make it rather obvious that you're using a memory block after it's free'd by overwriting any data that used to be in the memory block upon free.
Guard edges and Guard Malloc will help you find memory overruns and (to some extent) use-after-free by read and write protecting memory blocks to make your program crash more obviously if misusing memory.

潦草的字迹会使您很明显地看到,您正在使用一个内存块,在它被释放之后,通过在空闲时覆盖任何过去在内存块中的数据。保护边缘和保护Malloc将帮助您发现内存溢出和(在某种程度上)免读和写保护内存块,以使您的程序在滥用内存时更明显地崩溃。

#2


3  

The "documentation" link above is to Xcode in general, but more specifically RN-MallocOptions covers these (and other) options in detail.

上面的“文档”链接一般是指向Xcode的,但是更具体地说,RN-MallocOptions详细地介绍了这些(和其他)选项。

Jim Kubicek shows a nice example in Debugging Smashed Memory in Obj-C, including the important "How do I enable these in Xcode?" question:

Jim Kubicek展示了一个在object - c中调试破碎内存的很好的例子,包括重要的“如何在Xcode中启用这些内存?”

Open the ‘Edit Scheme’ window and navigate to the Diagnostics tab. You’ll want to turn on “Enable Scribble” and “Malloc Stack”. ... in short, “Enabled Scribble” will cause the allocator to write 0xAA to newly allocated memory and write 0x55 to deallocated memory. “Malloc Stack” will log the allocation and free history of your memory.

打开“编辑方案”窗口,导航到Diagnostics附签。您将需要打开“启用Scribble”和“Malloc Stack”。简而言之,“启用Scribble”将导致分配器将0xAA写入新分配的内存,并将0x55写入已分配的内存。“Malloc堆栈”将记录内存的分配和空闲历史。

If you've read this far, you'll probably be interested in Apple's Technical Notes:

如果你读过这篇文章,你可能会对苹果的技术说明感兴趣:

#1


42  

From the documentation.

从文档。

  • Enable Scribble. Fill allocated memory with 0xAA and deallocated memory with 0x55.
  • 启用潦草。用0xAA填充分配的内存,用0x55释放分配的内存。
  • Enable Guard Edges. Add guard pages before and after large allocations.
  • 启用保护边缘。在大量分配之前和之后添加保护页。
  • Enable Guard Malloc. Use libgmalloc to catch common memory problems such as buffer overruns and use-after-free.
  • 启用Malloc。使用libgmalloc捕捉常见的内存问题,如缓冲区溢出和使用后无内存问题。

Scribble will make it rather obvious that you're using a memory block after it's free'd by overwriting any data that used to be in the memory block upon free.
Guard edges and Guard Malloc will help you find memory overruns and (to some extent) use-after-free by read and write protecting memory blocks to make your program crash more obviously if misusing memory.

潦草的字迹会使您很明显地看到,您正在使用一个内存块,在它被释放之后,通过在空闲时覆盖任何过去在内存块中的数据。保护边缘和保护Malloc将帮助您发现内存溢出和(在某种程度上)免读和写保护内存块,以使您的程序在滥用内存时更明显地崩溃。

#2


3  

The "documentation" link above is to Xcode in general, but more specifically RN-MallocOptions covers these (and other) options in detail.

上面的“文档”链接一般是指向Xcode的,但是更具体地说,RN-MallocOptions详细地介绍了这些(和其他)选项。

Jim Kubicek shows a nice example in Debugging Smashed Memory in Obj-C, including the important "How do I enable these in Xcode?" question:

Jim Kubicek展示了一个在object - c中调试破碎内存的很好的例子,包括重要的“如何在Xcode中启用这些内存?”

Open the ‘Edit Scheme’ window and navigate to the Diagnostics tab. You’ll want to turn on “Enable Scribble” and “Malloc Stack”. ... in short, “Enabled Scribble” will cause the allocator to write 0xAA to newly allocated memory and write 0x55 to deallocated memory. “Malloc Stack” will log the allocation and free history of your memory.

打开“编辑方案”窗口,导航到Diagnostics附签。您将需要打开“启用Scribble”和“Malloc Stack”。简而言之,“启用Scribble”将导致分配器将0xAA写入新分配的内存,并将0x55写入已分配的内存。“Malloc堆栈”将记录内存的分配和空闲历史。

If you've read this far, you'll probably be interested in Apple's Technical Notes:

如果你读过这篇文章,你可能会对苹果的技术说明感兴趣: