---
title: "iOS 调试问题小结"
author: "简单的茶"
date: "2014-06-12T11:17:04Z"
tags: []
categories: ["移动开发"]
slug: "ios"
draft: false
lastmod: "2014-06-20T16:04:37Z"
id: 2078693
url: "https://lisai.iteye.com/blog/2078693"
---

1. XCode 提示 ”set a breakpoint in malloc_error_break to debug “时，如何设置 malloc_error_debug?
    solution: 
     Step 1: Set a breakpoint on malloc_error_break() by opening the Breakpoint Navigator (View->Navigators->Show Breakpoint Navigator or ⌘7), clicking the plus button in the lower left corner, and selecting "Add Symbolic Breakpoint". In the popup that comes up, enter malloc_error_break (without quotes of course) in the Symbol field, then click Done.
     Step 2: specify any module: try setting "libsystem_c.dylib"

2. 用 XCode 调试程序时，遇到 exc_bad_access 时，需要用 malloc_history pid memory_address 来查看内存分配情况，那么如何知道该 app 的 pid 呢？
     solution: 打开 activity monitor, 在 memory 选项卡中找到该 app 的名称，该条对呀的PID就是我们需要的进程号啦。

3. lldb 中有一个命令 po，全程是 print object

4. 发生异常时，使用 po $eax 查看异常信息
    explaination: $eax 是 CPU 的寄存器之一。在异常情况下，该寄存器会包含一个指针的 NSException 对象。$eax 只用于模拟器，如果在真机上调试，你需要使用寄存器 $R0
   与之相关的命令还有:po , po 等

5. Background audio is not supported in iPhone simulator.